buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
|
|---|---|---|---|---|
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
vector<pair<int, int>> vpii;
int num, ans;
char cm;
while (cin >> num >> cm >> ans && num != 0 && ans != 0) {
vpii.push_back(make_pair(ans, num));
}
sort(vpii.begin(), vpii.end(), greater<pair<int, int>>());
int prv = 10000000;
int rank = 0;
map<int, int> mii;
for (int i = 0; i < vpii.size(); i++) {
if (vpii[i].first < prv) {
rank++;
mii[vpii[i].second] = rank;
prv = vpii[i].first;
} else if (vpii[i].first == prv) {
mii[vpii[i].second] = rank;
}
}
int nn;
while (cin >> nn) {
cout << mii[nn] << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
vector<pair<int, int>> vpii;
int num, ans;
char cm;
while (cin >> num >> cm >> ans && (num != 0 || ans != 0)) {
vpii.push_back(make_pair(ans, num));
}
sort(vpii.begin(), vpii.end(), greater<pair<int, int>>());
int prv = 10000000;
int rank = 0;
map<int, int> mii;
for (int i = 0; i < vpii.size(); i++) {
if (vpii[i].first < prv) {
rank++;
mii[vpii[i].second] = rank;
prv = vpii[i].first;
} else if (vpii[i].first == prv) {
mii[vpii[i].second] = rank;
}
}
int nn;
while (cin >> nn) {
cout << mii[nn] << endl;
}
return 0;
}
|
[["+", 0, 52, 15, 339, 51, 16, 12, 23, 0, 24], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["+", 0, 52, 15, 339, 51, 16, 12, 23, 0, 25]]
| 1
| 220
|
#include <cmath>
#include <iomanip>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int p[100], Score[30] = {};
int n, s;
int call, rank;
while (scanf("%d,%d", &n, &s), n | s) {
p[n - 1] = s;
Score[s]++;
}
while (cin >> call) {
rank = 1;
for (int i = 29; i >= p[call - 1] - 1; --i) {
if (Score[i])
++rank;
}
cout << rank << endl;
}
return 0;
}
|
#include <cmath>
#include <iomanip>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int p[100], Score[30] = {};
int n, s;
int call, rank;
while (scanf("%d,%d", &n, &s), n | s) {
p[n - 1] = s;
Score[s - 1]++;
}
while (cin >> call) {
rank = 0;
for (int i = 29; i >= p[call - 1] - 1; --i) {
if (Score[i]) {
++rank;
}
}
cout << rank << endl;
}
return 0;
}
|
[["+", 0, 27, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 27, 28, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
| 1
| 132
|
score = []
until (t = gets.split(',').map(&:to_i))== [0,0]
score << [t[0] , t[1], 0]
end
score.sort!{ |x, y| x[1] <=> y[1] }.reverse!
score.length.times do |i|
# p score
if i == 0
score[i][2] = 1
else
if score[i-1][1] == score[i][1]
score[i][2] = score[i-1][2]
else
score[i][2] = score[i-1][2] + 1
end
end
end
while gets
puts score[$_.to_i][2]
end
|
score = []
until (t = gets.split(',').map(&:to_i))== [0,0]
score << [t[0] , t[1], 0]
end
score.sort!{ |x, y| x[1] <=> y[1] }.reverse!
score.length.times do |i|
# p score
if i == 0
score[i][2] = 1
else
if score[i-1][1] == score[i][1]
score[i][2] = score[i-1][2]
else
score[i][2] = score[i-1][2] + 1
end
end
end
while gets
puts score.assoc($_.to_i)[2]
end
|
[["-", 0, 652, 3, 4, 0, 742, 500, 742, 0, 70], ["+", 0, 652, 3, 4, 0, 742, 500, 652, 17, 131], ["+", 0, 652, 3, 4, 0, 742, 500, 652, 735, 22], ["+", 3, 4, 0, 742, 500, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 742, 500, 742, 0, 73], ["+", 3, 4, 0, 742, 500, 652, 3, 4, 0, 25]]
| 4
| 161
|
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0061
"""
import sys
def calc_rank(data):
scores = {} # ?????????key, ???????????????id???????????????value??¨?????????????????????
for id, point in data:
if point in scores:
scores[point].append(id)
else:
scores[point] = [id]
ranks = [k for k in scores.keys()] # ranks.index(point) ?????????????????????????????????
ranks.sort(reverse=True)
ranks.insert(0, 0) # index???1?????????????????????????????????????????????????????\
return scores, ranks
def check_rank(scores, ranks, id):
for k, v in scores.items():
if id in v:
return ranks.index(k)
def main(args):
data = []
id, point = [int(x) for x in input().strip().split(',')]
while id != 0 or point != 0:
data.append((id, point))
id, point = [int(x) for x in input().strip().split(',')]
scores, ranks = calc_rank(data)
for line in sys.stdin:
id = int(line.strip())
result = check_rank(scores, ranks, id)
print(result)
if __name__ == '__main__':
main(sys.argv[1:])
|
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0061
"""
import sys
def calc_rank(data):
scores = {} # ?????????key, ???????????????id???????????????value??¨?????????????????????
for id, point in data:
if point in scores:
scores[point].append(id)
else:
scores[point] = [id]
ranks = [k for k in scores.keys()] # ranks.index(point) ???????????????????????????????????????????????????
ranks.sort(reverse=True)
ranks.insert(0, -1) # index???1?????????????????????????????????????????????????????\
return scores, ranks
def check_rank(scores, ranks, id):
for k, v in scores.items():
if id in v:
return ranks.index(k)
def main(args):
data = []
id, point = [int(x) for x in input().strip().split(',')]
while id != 0 or point != 0:
data.append((id, point))
id, point = [int(x) for x in input().strip().split(',')]
scores, ranks = calc_rank(data)
for line in sys.stdin:
id = int(line.strip())
result = check_rank(scores, ranks, id)
print(result)
if __name__ == '__main__':
main(sys.argv[1:])
|
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 28, 612]]
| 5
| 255
|
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
teams = [0 for i in range(101)]
points = [False for i in range(31)]
while True:
a,b = [int(i) for i in input().split(",")]
if a == 0 and b == 0:
break
teams[a] = b
points[b] = True
N = list(get_input())
for l in range(len(N)):
q = int(N[l])
p = teams[q]
ans = 0
for i in range(30,0,-1):
if points[i]:
ans += 1
if i == p:
break
print(ans)
|
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
teams = [0 for i in range(101)]
points = [False for i in range(31)]
while True:
a,b = [int(i) for i in input().split(",")]
if a == 0 and b == 0:
break
teams[a] = b
points[b] = True
N = list(get_input())
for l in range(len(N)):
q = int(N[l])
p = teams[q]
ans = 0
for i in range(30,-1,-1):
if points[i]:
ans += 1
if i == p:
break
print(ans)
|
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 664, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 664, 28, 612]]
| 5
| 165
|
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
int[][] num;
while ((line = br.readLine()) != null) {
num = new int[10][10];
for (int i = 0; i < 10; i++) {
num[9][i] = (int)(line.charAt(i) - '0');
}
for (int i = 8; i >= 0; i--) {
for (int j = 0; j <= i; j++) {
num[i][j] = (num[i + 1][j] + num[i + 1][j + 1]) % 10;
}
}
System.out.print(num[0][0]);
}
}
}
|
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
int[][] num;
while ((line = br.readLine()) != null) {
num = new int[10][10];
for (int i = 0; i < 10; i++) {
num[9][i] = (int)(line.charAt(i) - '0');
}
for (int i = 8; i >= 0; i--) {
for (int j = 0; j <= i; j++) {
num[i][j] = (num[i + 1][j] + num[i + 1][j + 1]) % 10;
}
}
System.out.println(num[0][0]);
}
}
}
|
[["-", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22]]
| 3
| 199
|
import java.util.Scanner;
public class Main {
private Scanner sc;
public static void main(String[] args) { new Main(); }
public Main() {
sc = new Scanner(System.in);
while (sc.hasNextLine() == true) {
String line = sc.nextLine();
int[][] map = new int[10][10];
for (int i = 0; i < map.length; i++) {
map[0][i] = line.charAt(i) - '0';
}
for (int j = 1; j < map.length; j++) {
for (int i = 0; i < (map.length - j); i++) {
map[j][i] = map[j - 1][i] + map[j - 1][i + 1];
}
}
System.out.println(map[9][0]);
}
}
}
|
import java.util.Scanner;
public class Main {
private Scanner sc;
public static void main(String[] args) { new Main(); }
public Main() {
sc = new Scanner(System.in);
while (sc.hasNextLine() == true) {
String line = sc.nextLine();
int[][] map = new int[10][10];
for (int i = 0; i < map.length; i++) {
map[0][i] = line.charAt(i) - '0';
}
for (int j = 1; j < map.length; j++) {
for (int i = 0; i < (map.length - j); i++) {
map[j][i] = (map[j - 1][i] + map[j - 1][i + 1]) % 10;
}
}
System.out.println(map[9][0]);
}
}
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 499]]
| 3
| 206
|
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int MX = 200000;
bool sieve[MX];
void prepare() {
memset(sieve, false, sizeof sieve);
sieve[0] = sieve[1] = true;
for (int i = 2; i * i < MX; ++i) {
if (!sieve[i]) {
for (int j = i * i; j < MX; j += i) {
sieve[j] = true;
}
}
}
}
int main() {
prepare();
int n;
while (cin >> n) {
long long sum = 0;
for (int i = 0; 0 < n; ++i) {
if (!sieve[i]) {
sum += i;
n--;
}
}
cout << sum << endl;
}
return 0;
}
|
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int MX = 200000;
bool sieve[MX];
void prepare() {
memset(sieve, false, sizeof sieve);
sieve[0] = sieve[1] = true;
for (int i = 2; i * i < MX; ++i) {
if (!sieve[i]) {
for (int j = i * i; j < MX; j += i) {
sieve[j] = true;
}
}
}
}
int main() {
prepare();
int n;
while (cin >> n, n) {
long long sum = 0;
for (int i = 0; 0 < n; ++i) {
if (!sieve[i]) {
sum += i;
n--;
}
}
cout << sum << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
| 1
| 175
|
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
bool f[105000];
int n;
long long int sum[105000];
memset(f, false, sizeof(f));
sum[0] = 0;
for (int i = 2; i <= 105000; i++) {
if (f[i])
continue;
for (int j = i * i; j < 105000; j += i)
f[j] = true;
}
int k = 1;
for (int j = 2; j <= 105000; j++) {
if (!f[j]) {
sum[k] = sum[k - 1] + j;
k++;
}
}
while (1) {
cin >> n;
if (n == 0)
break;
cout << sum[n] << endl;
}
return 0;
}
|
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
bool f[105000];
int n;
long long int sum[105000];
memset(f, false, sizeof(f));
sum[0] = 0;
for (int i = 2; i * i <= 105000; i++) {
if (f[i])
continue;
for (int j = i * i; j < 105000; j += i)
f[j] = true;
}
int k = 1;
for (int j = 2; j <= 105000; j++) {
if (!f[j]) {
sum[k] = sum[k - 1] + j;
k++;
}
}
while (1) {
cin >> n;
if (n == 0)
break;
cout << sum[n] << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22]]
| 1
| 179
|
#include <cmath>
#include <cstdio>
using namespace std;
int dp[10010];
int prime(int n) {
int i, j, d;
if (n == 1) {
return dp[1] = 2;
};
d = dp[n - 1];
for (i = d + 1;; i++) {
for (j = 2;; j++) {
if (i % j == 0)
break;
if (j == (int)sqrt(i)) {
return dp[n] = i;
}
}
}
}
int main() {
int n, i;
long long sum = 0;
while (scanf("%d", &n) && n) {
if (n == 0)
break;
for (i = 1; i <= n; i++)
sum += prime(i);
printf("%d\n", sum);
sum = 0;
}
return 0;
}
|
#include <cmath>
#include <cstdio>
using namespace std;
int dp[10010];
int prime(int n) {
int i, j, d;
if (n == 1) {
return dp[1] = 2;
};
d = dp[n - 1];
for (i = d + 1;; i++) {
for (j = 2;; j++) {
if (i % j == 0)
break;
if (j == (int)sqrt(i) + 1) {
return dp[n] = i;
}
}
}
}
int main() {
int n, i;
long long sum = 0;
while (scanf("%d", &n) && n) {
if (n == 0)
break;
for (i = 1; i <= n; i++)
sum += prime(i);
printf("%d\n", sum);
sum = 0;
}
return 0;
}
|
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 191
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
const int N = 200000;
bitset<N> sosu;
int ans[10000];
int cnt = 0;
int sum = 0;
sosu.set();
for (int i = 2; i < N; ++i) {
if (sosu.test(i)) {
sum += i;
ans[cnt] = sum;
++cnt;
if (cnt == 10000)
break;
for (ll j = i * i; j < N; j += i) {
sosu.reset(j);
}
}
}
ll n;
while (1) {
cin >> n;
if (!n)
break;
cout << ans[n - 1] << endl;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
const ll N = 200000;
bitset<N> sosu;
int ans[10000];
int cnt = 0;
int sum = 0;
sosu.set();
for (ll i = 2; i < N; ++i) {
if (sosu.test(i)) {
sum += i;
ans[cnt] = sum;
++cnt;
if (cnt == 10000)
break;
for (ll j = i * i; j < N; j += i) {
sosu.reset(j);
}
}
}
ll n;
while (1) {
cin >> n;
if (!n)
break;
cout << ans[n - 1] << endl;
}
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 78]]
| 1
| 172
|
#include <cmath>
#include <iostream>
using namespace std;
int x[1000000], y[100000], n, cnt;
int main() {
for (int i = 2; i < 200000; i++) {
for (int j = 2; j <= sqrt(i); j++) {
if (j % i == 0) {
goto E;
}
}
x[i] = 0;
E:;
}
for (int i = 0; i < 200000; i++) {
if (x[i] == 1) {
cnt++;
y[cnt] = y[cnt - 1] + i;
}
}
while (1) {
cin >> n;
if (!n) {
break;
}
cout << y[n] << endl;
}
}
|
#include <cmath>
#include <iostream>
using namespace std;
int x[1000000], y[100000], n, cnt;
int main() {
for (int i = 2; i < 200000; i++) {
for (int j = 2; j <= sqrt(i); j++) {
if (i % j == 0) {
goto E;
}
}
x[i] = 1;
E:;
}
for (int i = 0; i < 200000; i++) {
if (x[i] == 1) {
cnt++;
y[cnt] = y[cnt - 1] + i;
}
}
while (1) {
cin >> n;
if (!n) {
break;
}
cout << y[n] << endl;
}
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13]]
| 1
| 159
|
#include <cmath>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 105000
using namespace std;
int main() {
/*for(int k = 1; k<MAX;k++)
{
if(PrimeCheck(v[k+1]))
{
//cout << v[k+1] << " ";
v2[d] = v[k+1];
d++;
}
}
//rep(i,d) cout << v2[i] << " ";
//cout << d << endl;*/
int number;
while (cin >> number, number) {
int counter = 0;
vector<bool> v(MAX + 1, 0);
vector<int> v2(10008, 0);
rep(i, MAX) v[i + 1] = true;
long long answer = 0;
int lim = (int)sqrt(number);
int d = 0;
// cout << lim <<" ";
for (int i = 2; i < MAX; i++) {
if (v[i]) {
for (int j = 2; j < MAX / i; j++) {
v[j * i] = false;
// cout << " " << i << "i*j= " << i*j;
}
v2[d] = i;
d++;
}
}
// rep(i,number) cout << v[i+1] << " ";
for (int i = 2; i < MAX + 1; i++) {
if (v[i]) {
answer += i;
counter++;
// cout << " " << i;
if (counter == number)
break;
}
}
cout /*<< " answer is "*/ << answer << endl;
}
return 0;
}
|
#include <cmath>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 105000
using namespace std;
int main() {
/*for(int k = 1; k<MAX;k++)
{
if(PrimeCheck(v[k+1]))
{
//cout << v[k+1] << " ";
v2[d] = v[k+1];
d++;
}
}
//rep(i,d) cout << v2[i] << " ";
//cout << d << endl;*/
int number;
while (cin >> number, number) {
int counter = 0;
vector<bool> v(MAX + 1, 0);
vector<int> v2(MAX, 0);
rep(i, MAX) v[i + 1] = true;
long long answer = 0;
int lim = (int)sqrt(number);
int d = 0;
// cout << lim <<" ";
for (int i = 2; i < MAX; i++) {
if (v[i]) {
for (int j = 2; j < MAX / i; j++) {
v[j * i] = false;
// cout << " " << i << "i*j= " << i*j;
}
v2[d] = i;
d++;
}
}
// rep(i,number) cout << v[i+1] << " ";
for (int i = 2; i < MAX + 1; i++) {
if (v[i]) {
answer += i;
counter++;
// cout << " " << i;
if (counter == number)
break;
}
}
cout /*<< " answer is "*/ << answer << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22]]
| 1
| 225
|
#include <math.h>
#include <stdio.h>
int isprime(int x) {
int i;
if (x == 2) {
return 1;
}
if (x < 2 || x % 2 == 0) {
return 0;
}
i = 3;
while (i <= sqrt(x)) {
if (x % i == 0) {
return 0;
}
i = i + 2;
}
return 1;
}
int main() {
int n, c = 0, l[10001] = {0}, j = 0;
for (int i = 0; i <= 10000000; i++) {
if (isprime(i)) {
c += i;
l[j] = c;
j++;
}
}
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
printf("%d\n", l[n - 1]);
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int isprime(int x) {
int i;
if (x == 2) {
return 1;
}
if (x < 2 || x % 2 == 0) {
return 0;
}
i = 3;
while (i <= sqrt(x)) {
if (x % i == 0) {
return 0;
}
i = i + 2;
}
return 1;
}
int main() {
int n, c = 0, l[10001] = {0}, j = 0;
for (int i = 0; i <= 104730; i++) {
if (isprime(i)) {
c += i;
l[j] = c;
j++;
}
}
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
printf("%d\n", l[n - 1]);
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 189
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define dump(n) cout << "# " << #n << "=" << (n) << endl
#define debug(n) \
cout << __FILE__ << "," << __LINE__ << ": # " << #n << "=" << (n) << endl
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, n) repi(i, 0, n)
#define iter(c) __typeof((c).begin())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define allof(c) (c).begin(), (c).end()
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
int main() {
vi prime(1, 2);
for (int i = 3; prime.size() <= 10; i += 2) {
bool ok = true;
for (int j = 0; prime[j] * prime[j] <= i; j++) {
if (i % prime[j] == 0) {
ok = false;
break;
}
}
if (ok)
prime.push_back(i);
}
for (int n; cin >> n, n;)
cout << accumulate(prime.begin(), prime.begin() + n, 0) << endl;
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define dump(n) cout << "# " << #n << "=" << (n) << endl
#define debug(n) \
cout << __FILE__ << "," << __LINE__ << ": # " << #n << "=" << (n) << endl
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, n) repi(i, 0, n)
#define iter(c) __typeof((c).begin())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define allof(c) (c).begin(), (c).end()
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
int main() {
vi prime(1, 2);
for (int i = 3; prime.size() <= 10000; i += 2) {
bool ok = true;
for (int j = 0; prime[j] * prime[j] <= i; j++) {
if (i % prime[j] == 0) {
ok = false;
break;
}
}
if (ok)
prime.push_back(i);
}
for (int n; cin >> n, n;)
cout << accumulate(prime.begin(), prime.begin() + n, 0) << endl;
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 267
|
#include <iostream>
using namespace std;
int main() {
int prime[10001], p = 3, psum[10001], n;
prime[1] = 2, prime[2] = 3;
for (int i = 5; p < 10001; i++) {
int f = 0;
for (int j = 1; prime[j] * prime[j] <= i; j++)
if (i % prime[j] == 0) {
f = 1;
break;
}
if (!f)
prime[p++] = i;
}
psum[1] = 2;
for (int i = 2; i < 100001; i++)
psum[i] = psum[i - 1] + prime[i];
while (1) {
cin >> n;
if (!n)
break;
cout << psum[n] << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int prime[10001], p = 3, psum[10001], n;
prime[1] = 2, prime[2] = 3;
for (int i = 5; p < 10001; i++) {
int f = 0;
for (int j = 1; prime[j] * prime[j] <= i; j++)
if (i % prime[j] == 0) {
f = 1;
break;
}
if (!f)
prime[p++] = i;
}
psum[1] = 2;
for (int i = 2; i < 10001; i++)
psum[i] = psum[i - 1] + prime[i];
while (1) {
cin >> n;
if (!n)
break;
cout << psum[n] << endl;
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 185
|
#include <bitset>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000
int main() {
bitset<MAX> is_prime;
is_prime.set();
is_prime[0] = false, is_prime[1] = false;
for (int i = 2; i * i <= MAX; i++) {
for (int j = i + i; j <= MAX; j += i) {
is_prime[j] = false;
}
}
vector<int> prime;
for (int i = 0; i < MAX; i++) {
if (prime[i]) {
prime.push_back(i);
}
}
if (prime.size() < 10000) {
printf("error\n");
return 0;
}
int N;
while (scanf("%d ", &N) == 1) {
if (N == 0) {
break;
}
int sum = 0;
for (int i = 0; i < N; i++) {
sum += prime[i];
}
printf("%d\n", sum);
}
return 0;
}
|
#include <bitset>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000
int main() {
bitset<MAX + 1> is_prime;
is_prime.set();
is_prime[0] = false, is_prime[1] = false;
for (int i = 2; i * i <= MAX; i++) {
for (int j = i + i; j <= MAX; j += i) {
is_prime[j] = false;
}
}
vector<int> prime;
for (int i = 0; i <= MAX; i++) {
if (is_prime[i]) {
prime.push_back(i);
}
}
if (prime.size() < 10000) {
printf("error\n");
return 0;
}
int N;
while (scanf("%d ", &N) == 1) {
if (N == 0) {
break;
}
int sum = 0;
for (int i = 0; i < N; i++) {
sum += prime[i];
}
printf("%d\n", sum);
}
return 0;
}
|
[["+", 0, 43, 39, 344, 3, 347, 0, 16, 17, 72], ["+", 0, 43, 39, 344, 3, 347, 0, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 69, 28, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 69, 28, 22]]
| 1
| 222
|
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
int main() {
vector<int> table(1000000, 1);
table[0] = table[1] = 0;
for (int i = 2; i * i < 1000000; i++)
if (table[i])
for (int j = i * 2; j < 1000000; j += i)
table[j] = 0;
vector<int> p;
REP(i, table.size())
if (table[i])
p.push_back(i);
vector<int> sp;
sp.push_back(0);
REP(i, 100) { sp.push_back(sp[i] + p[i]); }
int n;
while (cin >> n, n) {
cout << sp[n] << endl;
}
}
|
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
int main() {
vector<int> table(1000000, 1);
table[0] = table[1] = 0;
for (int i = 2; i * i < 1000000; i++)
if (table[i])
for (int j = i * 2; j < 1000000; j += i)
table[j] = 0;
vector<int> p;
REP(i, table.size())
if (table[i])
p.push_back(i);
vector<int> sp;
sp.push_back(0);
REP(i, 10001) { sp.push_back(sp[i] + p[i]); }
int n;
while (cin >> n, n) {
cout << sp[n] << endl;
}
}
|
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
| 1
| 203
|
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
const int primemax = 500000;
bool prime[primemax];
void init() {
for (int i = 0; i < primemax; i++) {
prime[i] = true;
}
prime[0] = prime[1] = false;
for (int i = 2; i < primemax; i++) {
if (prime[i]) {
for (int j = i * 2; j < primemax / j; j += i) {
prime[j] = false;
}
}
}
}
int main() {
init();
int n;
while (1) {
cin >> n;
if (n == 0)
break;
int res = 0;
int i = 2;
while (n > 0) {
if (prime[i]) {
n--;
res += i;
}
i++;
}
cout << res << endl;
}
return 0;
}
|
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
const int primemax = 500000;
bool prime[primemax];
void init() {
for (int i = 0; i < primemax; i++) {
prime[i] = true;
}
prime[0] = prime[1] = false;
for (int i = 2; i * i < primemax; i++) {
if (prime[i]) {
for (int j = i * 2; j < primemax; j += i) {
prime[j] = false;
}
}
}
}
int main() {
init();
int n;
while (1) {
cin >> n;
if (n == 0)
break;
int res = 0;
int i = 2;
while (n > 0) {
if (prime[i]) {
n--;
res += i;
}
i++;
}
cout << res << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 17, 85], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 12, 22]]
| 1
| 199
|
max=110000
array=[*2..max]
2.upto(Math.sqrt(max)) do |num1|
array.reject! do |num2|
(num2%num1==0)&&(num2>num1)
end
end
p array.size
while gets
break if $_.to_i==0
x=0
for i in 0...$_.to_i
x+=array[i]
end
puts x
end
|
max=110000
array=[*2..max]
2.upto(Math.sqrt(max)) do |num1|
array.reject! do |num2|
(num2%num1==0)&&(num2>num1)
end
end
while gets
break if $_.to_i==0
x=0
for i in 0...$_.to_i
x+=array[i]
end
puts x
end
|
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 0, 493, 0, 652, 3, 4, 0, 652, 486, 22], ["-", 0, 493, 0, 652, 3, 4, 0, 652, 17, 131], ["-", 0, 493, 0, 652, 3, 4, 0, 652, 735, 22]]
| 4
| 82
|
max = 105000
sn = max.to_f**0.5.ceil
is_prime = [false, false] + [true]*(max-1)
(2..sn).each do |i|
next unless is_prime[i]
(i*i).step(max, i) do |j|
is_prime[j] = false
end
end
prime_list = (2..max).to_a.select{ |i| is_prime[i] }
puts prime_list.size
while n = gets.to_i do
break if n == 0
puts prime_list[0..(n-1)].inject(:+)
end
|
max = 105000
sn = max.to_f**0.5.ceil
is_prime = [false, false] + [true]*(max-1)
(2..sn).each do |i|
next unless is_prime[i]
(i*i).step(max, i) do |j|
is_prime[j] = false
end
end
prime_list = (2..max).to_a.select{ |i| is_prime[i] }
while n = gets.to_i do
break if n == 0
puts prime_list[0..(n-1)].inject(:+)
end
|
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 0, 493, 0, 652, 3, 4, 0, 652, 486, 22], ["-", 0, 493, 0, 652, 3, 4, 0, 652, 17, 131], ["-", 0, 493, 0, 652, 3, 4, 0, 652, 735, 22]]
| 4
| 123
|
import sys
from itertools import *
n=104730;a=list(range(n));a[:2]=0,0
for i in range(2,323):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(range(n),a))
for e in sys.stdin:
if'0'!=e:print(sum(p[:int(e)]))
|
import sys
from itertools import *
n=104730;a=list(range(n));a[:2]=0,0
for i in range(2,323):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(range(n),a))
for e in sys.stdin:
if'0\n'!=e:print(sum(p[:int(e)]))
|
[["+", 0, 57, 15, 666, 0, 557, 0, 6, 0, 44]]
| 5
| 107
|
import math
r = 10000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
for j in range(2*i+1,r,i+1):
p[j] = 0
while True:
n = int(input())
if not n:
break
i, num, sum = 0, 1, 0
while num < n:
if p[i] == 1:
num += 1
sum += i
i += 1
print(sum)
|
import math
r = 200000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
for j in range(2*i+1,r,i+1):
p[j] = 0
while True:
n = int(input())
if not n:
break
i, num, sum = 0, 0, 0
while num < n:
if p[i] == 1:
num += 1
sum += i+1
i += 1
print(sum)
|
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 432, 0, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 432, 0, 612], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 72], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 12, 612]]
| 5
| 122
|
import math
r = 105000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
for j in range(2*i+1,r,i+1):
p[j] = 0
prime = [0 for i in range(10000)]
j = 0
for i in range(len(p)):
if p[i]:
prime[j] = i+1
j += 1
while True:
n = int(input())
if not n:
break
print(sum(prime[:n]))
|
import math
r = 105000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
for j in range(2*i+1,r,i+1):
p[j] = 0
prime = [0 for i in range(11000)]
j = 0
for i in range(len(p)):
if p[i]:
prime[j] = i+1
j += 1
while True:
n = int(input())
if not n:
break
print(sum(prime[:n]))
|
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612]]
| 5
| 139
|
import math
prime = [0 for i in range(11000)]
k = 0
r = 105000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
prime[k] = i+1
k += 1
l = i
for j in range(2*i+1,r,i+1):
p[j] = 0
for i in range(l,r):
if p[i]:
prime[k] = i+1
k += 1
while True:
n = int(input())
if not n:
break
print(sum(prime[:n]))
|
import math
prime = [0 for i in range(11000)]
k = 0
r = 105000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
prime[k] = i+1
k += 1
l = i
for j in range(2*i+1,r,i+1):
p[j] = 0
for i in range(l+1,r):
if p[i]:
prime[k] = i+1
k += 1
while True:
n = int(input())
if not n:
break
print(sum(prime[:n]))
|
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
| 5
| 152
|
<?php
while (true) {
fscanf(STDIN, '%d %d %d', $a, $b, $n);
if (feof(STDIN)) {
break;
}
$s = 0;
$mod = $a > $b ? $a % $b : $a;
for ($i = 0; $i < $n; $i++) {
$mod *= 10;
$s += (int) ($mod / $b);
$mod = $mod >= $b ? $mod % $b : $mod;
}
echo $s . PHP_EOL;
}
|
<?php
while (true) {
fscanf(STDIN, '%d %d %d', $a, $b, $n);
if (feof(STDIN)) {
break;
}
$s = 0;
$mod = $a >= $b ? $a % $b : $a;
for ($i = 0; $i < $n; $i++) {
$mod *= 10;
$s += (int) ($mod / $b);
$mod = $mod >= $b ? $mod % $b : $mod;
}
echo $s . PHP_EOL;
}
|
[["-", 0, 1, 0, 11, 12, 41, 15, 16, 17, 47], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 17, 20]]
| 6
| 121
|
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextDouble()) {
BigDecimal a = sc.nextBigDecimal(), b = sc.nextBigDecimal();
int n = sc.nextInt();
String d = a.divide(b, n + 1, 0).toString();
int i = 0, ans = 0;
while (d.charAt(i) != '.')
i++;
while (n-- > 0)
ans += d.charAt(++i) - '0';
System.out.println(ans);
}
}
}
|
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextBigDecimal()) {
BigDecimal a = sc.nextBigDecimal(), b = sc.nextBigDecimal();
int n = sc.nextInt();
String d = a.divide(b, n + 2, 0).toPlainString();
int i = 0, ans = 0;
while (d.charAt(i) != '.')
i++;
while (n-- > 0)
ans += d.charAt(++i) - '0';
System.out.println(ans);
}
}
}
|
[["-", 8, 196, 0, 52, 15, 15, 0, 492, 141, 22], ["+", 8, 196, 0, 52, 15, 15, 0, 492, 141, 22], ["-", 51, 492, 500, 492, 3, 4, 0, 16, 12, 499], ["+", 51, 492, 500, 492, 3, 4, 0, 16, 12, 499], ["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]]
| 3
| 149
|
import java.math.*;
import java.util.*;
class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int a, b, c;
while (s.hasNext()) {
a = s.nextInt();
b = s.nextInt();
c = s.nextInt();
BigDecimal bd = new BigDecimal(a);
bd = bd.setScale(c + 5);
bd = bd.divide(new BigDecimal(b), RoundingMode.HALF_DOWN)
.remainder(new BigDecimal(1));
int sum = 0;
String str = bd.toString();
// System.out.println(str);
for (int i = 0; i < c; i++)
sum += str.charAt(2 + i) - '0';
System.out.println(sum);
}
}
}
|
import java.math.*;
import java.util.*;
class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int a, b, c;
while (s.hasNext()) {
a = s.nextInt();
b = s.nextInt();
c = s.nextInt();
BigDecimal bd = new BigDecimal(a);
bd = bd.setScale(c + 5);
bd = bd.divide(new BigDecimal(b), RoundingMode.HALF_DOWN)
.remainder(new BigDecimal(1));
int sum = 0;
String str = bd.toPlainString();
// System.out.println(str);
for (int i = 0; i < c; i++)
sum += str.charAt(2 + i) - '0';
System.out.println(sum);
}
}
}
|
[["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]]
| 3
| 179
|
#include <stdio.h>
int main() {
int i, j;
int n[10];
char s[11];
while (scanf("%s", s) != -1) {
for (i = 0; i < 10; i++) {
n[i] = s[i] - '0';
}
for (i = 9; i > 0; i--) {
for (j = 0; j < i; j++) {
n[j] = (n[j] + n[j + 1]) % 10;
printf("%d\n", n[0]);
}
}
}
return 0;
}
|
#include <stdio.h>
int main() {
int i, j;
int n[10];
char s[11];
while (scanf("%s", s) != -1) {
for (i = 0; i < 10; i++)
n[i] = s[i] - '0';
for (i = 9; i > 0; i--)
for (j = 0; j < i; j++)
n[j] = (n[j] + n[j + 1]) % 10;
printf("%d\n", n[0]);
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 8, 9, 0, 45], ["-", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 7, 8, 9, 0, 45], ["-", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46]]
| 0
| 136
|
main() {
int n, i, x[10];
while (scanf("%d", &n) != -1) {
for (i = 0; i < 10; i++) {
x[i] = n % 10;
n /= 10;
}
printf("%d\n", (x[0] + x[1] * 9 + x[2] * 36 + x[3] * 84 + x[4] * 126 +
x[5] * 126 + x[6] * 84 + x[7] * 36 + x[8] * 9 + x[9]) %
10);
}
return 0;
}
|
main() {
long long n, i, x[10];
while (scanf("%lld", &n) != -1) {
for (i = 0; i < 10; i++) {
x[i] = n % 10;
n /= 10;
}
printf("%lld\n", (x[0] + x[1] * 9 + x[2] * 36 + x[3] * 84 + x[4] * 126 +
x[5] * 126 + x[6] * 84 + x[7] * 36 + x[8] * 9 + x[9]) %
10);
}
return 0;
}
|
[["-", 36, 36, 0, 30, 0, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 140
|
#include <stdio.h>
int main(void) {
char a[10];
while (scanf("%s", &a) != EOF) {
int b[10], i, j;
for (i = 0; i < 10; i++)
b[i] = a[i] - '0';
for (i = 8; i > 0; i--) {
for (j = 0; j <= i; j++) {
b[j] = (b[j] + b[j + 1]) % 10;
}
}
printf("%d\n", b[0]);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
char a[10];
while (scanf("%s", &a) != EOF) {
int b[10], i, j;
for (i = 0; i < 10; i++)
b[i] = a[i] - '0';
for (i = 8; i >= 0; i--) {
for (j = 0; j <= i; j++) {
b[j] = (b[j] + b[j + 1]) % 10;
}
}
printf("%d\n", b[0]);
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 20]]
| 0
| 135
|
#include <iostream>
using namespace std;
string s;
int a[10][10];
main() {
while (cin >> s) {
for (int i = 0; i < 10; i++)
a[0][i] = s[i] - '0';
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9 - i; j++)
a[i + 1][j] = (a[i][j] + a[i][j + 1]) % 10;
}
cout << a[10][0] << endl;
}
}
|
#include <iostream>
using namespace std;
string s;
int a[10][10];
main() {
while (cin >> s) {
for (int i = 0; i < 10; i++)
a[0][i] = s[i] - '0';
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9 - i; j++)
a[i + 1][j] = (a[i][j] + a[i][j + 1]) % 10;
}
cout << a[9][0] << endl;
}
}
|
[["-", 31, 16, 12, 69, 28, 69, 341, 342, 0, 13], ["+", 31, 16, 12, 69, 28, 69, 341, 342, 0, 13]]
| 1
| 138
|
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
string s[10];
cin >> s[0];
s[0] += "0";
for (int i = 1; i < 10; i++) {
for (int j = 0; j < 10; j++) {
s[i][j] = (s[i - 1][j] - '0') % 10 + (s[i - 1][j + 1] - '0') % 10;
s[i][j] %= 10;
s[i][j] += '0';
}
}
cout << s[9][0] << endl;
}
|
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
string s[10];
while (cin >> s[0]) {
s[0] += "0";
for (int i = 1; i < 10; i++) {
for (int j = 0; j < 10; j++) {
s[i][j] = (s[i - 1][j] - '0') % 10 + (s[i - 1][j + 1] - '0') % 10;
s[i][j] %= 10;
s[i][j] += '0';
}
}
cout << s[9][0] << endl;
}
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 160
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int num[11][11];
string number;
cin >> number;
for (int i = 0; i < number.size(); i++) {
num[0][i] = number[i] - '0';
}
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
num[i][j] = (num[i - 1][j - 1] + num[i - 1][j]) % 10;
}
}
cout << num[9][9] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int num[11][11];
string number;
while (cin >> number) {
for (int i = 0; i < number.size(); i++) {
num[0][i] = number[i] - '0';
}
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
num[i][j] = (num[i - 1][j - 1] + num[i - 1][j]) % 10;
}
}
cout << num[9][9] << endl;
}
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 143
|
#include <bits/stdc++.h>
using namespace std;
using db = double;
using ll = long long;
using vi = vector<int>;
#define op operator
#define pb push_back
int a[13][13];
int main() {
cout << fixed << setprecision(9);
ios ::sync_with_stdio(0);
for (string s; cin >> s;) {
for (int i = 0; i < 10; i++)
a[0][i] = s[i] - '0';
for (int i = 1; i < 10; i++)
for (int j = 0; j < 10 - i; j++)
a[i][j] = (a[i - 1][j] + a[i - 1][j - 1]) % 10;
cout << a[9][0] << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using db = double;
using ll = long long;
using vi = vector<int>;
#define op operator
#define pb push_back
int a[13][13];
int main() {
cout << fixed << setprecision(9);
ios ::sync_with_stdio(0);
for (string s; cin >> s;) {
for (int i = 0; i < 10; i++)
a[0][i] = s[i] - '0';
for (int i = 1; i < 10; i++)
for (int j = 0; j < 10 - i; j++)
a[i][j] = (a[i - 1][j] + a[i - 1][j + 1]) % 10;
cout << a[9][0] << '\n';
}
return 0;
}
|
[["-", 0, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 17, 72]]
| 1
| 186
|
#include <cstdio>
using namespace std;
int a[10], n;
int main() {
while (scanf("%d", &n) != EOF) {
for (int i = 9; i >= 0; i--) {
a[i] = n % 10;
n /= 10;
}
for (int i = 9; i > 0; i--) {
for (int j = 0; j < i; j++) {
a[j] = (a[j] + a[j + 1]) % 10;
}
}
printf("%d\n", a[0]);
}
return 0;
}
|
#include <cstdio>
using namespace std;
int a[10];
long n;
int main() {
while (scanf("%ld", &n) != EOF) {
for (int i = 9; i >= 0; i--) {
a[i] = n % 10;
n /= 10;
}
for (int i = 9; i > 0; i--) {
for (int j = 0; j < i; j++) {
a[j] = (a[j] + a[j + 1]) % 10;
}
}
printf("%d\n", a[0]);
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 0, 35], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 134
|
#include <cstdio>
int main() {
char s[11], a, i;
for (; fgets(s, 11, stdin);) {
for (a = 9; a >= 0; a--)
for (i = 0; i < a; s[i] = (s[i] + s[i + 1] - 6) % 10 + 48, i++)
;
printf("%c\n", *s);
}
}
|
#include <cstdio>
int main() {
char s[15], a, i;
for (; fgets(s, 15, stdin);) {
for (a = 9; a >= 0; a--)
for (i = 0; i < a; s[i] = (s[i] + s[i + 1] - 6) % 10 + 48, i++)
;
printf("%c\n", *s);
}
}
|
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 7, 15, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 7, 15, 2, 3, 4, 0, 13]]
| 1
| 96
|
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> a(10);
while (scanf("%1d ", a) == 1) {
for (int i = 1; i < 10; i++) {
scanf("%1d ", &a[i]);
}
for (int i = 9; i >= 1; i--) {
vector<int> b(i);
for (int j = 0; j < i; j++) {
b[j] = (a[j] + a[j + 1]) % 10;
}
a = b;
}
printf("%d\n", a[0]);
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> a(10);
while (scanf("%1d ", &a[0]) == 1) {
for (int i = 1; i < 10; i++) {
scanf("%1d ", &a[i]);
}
for (int i = 9; i >= 1; i--) {
vector<int> b(i);
for (int j = 0; j < i; j++) {
b[j] = (a[j] + a[j + 1]) % 10;
}
a = b;
}
printf("%d\n", a[0]);
}
return 0;
}
|
[["+", 51, 16, 31, 2, 3, 4, 0, 66, 17, 67], ["+", 3, 4, 0, 66, 28, 69, 341, 342, 0, 70], ["+", 3, 4, 0, 66, 28, 69, 341, 342, 0, 13], ["+", 3, 4, 0, 66, 28, 69, 341, 342, 0, 73]]
| 1
| 151
|
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#define N 10
using namespace std;
int main() {
string inp;
cin >> inp;
vector<int> vec;
for (int i = 0; i < N; i++) {
if (inp[i] == '0') {
vec.push_back(0);
} else {
vec.push_back((int)inp[i] - '0');
}
}
while (vec.size() > 1) {
vector<int> tmpvec;
for (int i = 0; i < vec.size() - 1; i++) {
tmpvec.push_back((vec[i] + vec[i + 1]) % 10);
}
vec = tmpvec;
}
cout << vec[0] << endl;
return 0;
}
|
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#define N 10
using namespace std;
int main() {
string inp;
while (cin >> inp) {
vector<int> vec;
for (int i = 0; i < N; i++) {
if (inp[i] == '0') {
vec.push_back(0);
} else {
vec.push_back((int)inp[i] - '0');
}
}
while (vec.size() > 1) {
vector<int> tmpvec;
for (int i = 0; i < vec.size() - 1; i++) {
tmpvec.push_back((vec[i] + vec[i + 1]) % 10);
}
vec = tmpvec;
}
cout << vec[0] << endl;
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 169
|
#include <iostream>
using namespace std;
int main() {
string s;
int num[10];
int tmp[10];
cin >> s;
for (int i = 0; i < s.size(); ++i)
if ('0' <= s[i] && s[i] <= '9')
num[i] = s[i] - '0';
for (int i = 9; i > 0; --i) {
for (int j = 0; j < i; ++j)
tmp[j] = (num[j] + num[j + 1]) % 10;
for (int j = 0; j < i; ++j)
num[j] = tmp[j];
}
cout << num[0] << "\n";
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
string s;
int num[10];
int tmp[10];
while (cin >> s) {
for (int i = 0; i < s.size(); ++i)
if ('0' <= s[i] && s[i] <= '9')
num[i] = s[i] - '0';
for (int i = 9; i > 0; --i) {
for (int j = 0; j < i; ++j)
tmp[j] = (num[j] + num[j + 1]) % 10;
for (int j = 0; j < i; ++j)
num[j] = tmp[j];
}
cout << num[0] << "\n";
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 172
|
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string.h>
using namespace std;
int output(int num[10], int len) {
if (len == 1) {
return num[0];
} else {
int temp[10] = {0};
len--;
for (int i = 0; i < len; i++) {
temp[i] = (num[i] + num[i + 1]) % 10;
}
return output(temp, len);
}
}
int main() {
string in;
while (cin >> in) {
int num[10];
for (int i = 0; i < 10; i++) {
num[i] = in[i] - '0';
}
cout << output(num, 10);
}
}
|
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string.h>
using namespace std;
int output(int num[10], int len) {
if (len == 1) {
return num[0];
} else {
int temp[10] = {0};
len--;
for (int i = 0; i < len; i++) {
temp[i] = (num[i] + num[i + 1]) % 10;
}
return output(temp, len);
}
}
int main() {
string in;
while (cin >> in) {
int num[10];
for (int i = 0; i < 10; i++) {
num[i] = in[i] - '0';
}
cout << output(num, 10) << endl;
}
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 167
|
def suicide(lis):
if len(lis) == 1:
print(lis[0])
pokakito = []
for i in range(len(lis)-1):
check = lis[i] + lis[i+1]
one = int(str(check)[-1])
pokakito.append(one)
else:
suicide(pokakito)
while True:
try:
lis = [int(char) for char in input()]
suicide(lis)
except EOFError:
break
|
def suicide(lis):
if len(lis) == 1:
print(lis[0])
return
pokakito = []
for i in range(len(lis)-1):
check = lis[i] + lis[i+1]
one = int(str(check)[-1])
pokakito.append(one)
else:
suicide(pokakito)
while True:
try:
lis = [int(char) for char in input()]
suicide(lis)
except EOFError:
break
|
[["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38]]
| 5
| 103
|
#include <algorithm>
#include <iostream>
#include <string>
int main() {
char c;
int a = 0;
std::string s, x;
for (; std::cin >> s >> c;) {
x = s;
reverse(x.begin(), x.end());
if (x == s)
a++;
}
std::cout << a << "\n";
}
|
#include <algorithm>
#include <iostream>
#include <string>
int main() {
int a = 0;
std::string s, x;
for (; std::cin >> s;) {
x = s;
reverse(x.begin(), x.end());
if (x == s)
a++;
}
std::cout << a << "\n";
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 152], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
| 1
| 79
|
s = 0
while a = gets.chop
f = 1
a.size.times{|i|
f = 0 if a[i] != a[~i]
}
s += f
end
p s
|
s = 0
while a = gets
a.chop!
f = 1
a.size.times{|i|
f = 0 if a[i] != a[~i]
}
s += f
end
p s
|
[["+", 0, 493, 0, 89, 8, 170, 0, 652, 486, 22], ["-", 0, 493, 0, 89, 15, 662, 12, 652, 735, 22], ["+", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22]]
| 4
| 42
|
count = 0
while True:
a = input()
b = a[::-1]
if a == b: count+=1
print(count)
|
count = 0
try:
while True:
a = input()
b = a[::-1]
if a == b: count+=1
except EOFError: pass
print(count)
|
[["+", 36, 36, 36, 36, 0, 656, 0, 246, 0, 247], ["+", 36, 36, 36, 36, 0, 656, 0, 246, 0, 102], ["+", 36, 36, 0, 656, 0, 246, 0, 671, 0, 672], ["+", 36, 36, 0, 656, 0, 246, 0, 671, 0, 22], ["+", 36, 36, 0, 656, 0, 246, 0, 671, 0, 102], ["+", 0, 246, 0, 671, 0, 196, 0, 674, 0, 675]]
| 5
| 32
|
import sys
print(e[:-1]==e[-2::-1]for e in sys.stdin)
|
import sys
print(sum(e[:-1]==e[-2::-1]for e in sys.stdin))
|
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 668, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 668, 0, 25]]
| 5
| 27
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum = 0;
while (sc.hasNext()) {
char[] c = sc.next().toCharArray();
for (int i = 0; i < c.length; i++) {
if (intJudge(c[i])) {
String str = c[i] + "";
for (int j = i + 1; j < c.length; j++) {
if (intJudge(c[j])) {
str += (c[j] + "");
}
i = j;
}
sum += Integer.parseInt(str);
}
}
}
System.out.println(sum);
}
static boolean intJudge(char c) {
try {
Integer.parseInt(c + "");
return true;
} catch (NumberFormatException e) {
return false;
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum = 0;
while (sc.hasNext()) {
char[] c = sc.next().toCharArray();
for (int i = 0; i < c.length; i++) {
if (intJudge(c[i])) {
String str = c[i] + "";
for (int j = i + 1; j < c.length; j++) {
if (intJudge(c[j])) {
str += (c[j] + "");
} else {
break;
}
i = j;
}
sum += Integer.parseInt(str);
}
}
}
System.out.println(sum);
}
static boolean intJudge(char c) {
try {
Integer.parseInt(c + "");
return true;
} catch (NumberFormatException e) {
return false;
}
}
}
|
[["+", 64, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 75, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
| 3
| 207
|
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int count;
int sum;
sum = 0;
while (sc.hasNext()) {
count = 0;
String str = sc.next();
for (int i = 0; i < str.length(); i++) {
if ('0' <= str.charAt(i) && str.charAt(i) <= '9') {
count *= 10;
count += str.charAt(i) - '0';
} else {
sum += count;
count = 0;
}
}
}
System.out.println(sum);
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int count;
int sum;
sum = 0;
while (sc.hasNext()) {
count = 0;
String str = sc.next();
for (int i = 0; i < str.length(); i++) {
if ('0' <= str.charAt(i) && str.charAt(i) <= '9') {
count *= 10;
count += str.charAt(i) - '0';
} else {
sum += count;
count = 0;
}
}
sum += count;
}
System.out.println(sum);
}
}
|
[["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
| 3
| 145
|
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
char[] list = new char[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
int count = 0;
while (sc.hasNext()) {
String a = sc.next();
StringBuffer b = new StringBuffer();
for (int i = 0; i < a.length(); i++) {
if (Arrays.binarySearch(list, a.charAt(i)) >= 0) {
b.append(a.charAt(i));
} else {
if (b.length() != 0) {
count += Integer.parseInt(b.toString());
b = new StringBuffer();
}
}
if (i + 1 == a.length() || b.length() != 0) {
count += Integer.parseInt(b.toString());
}
}
}
out.println(count);
out.flush();
}
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
}
|
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
char[] list = new char[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
int count = 0;
while (sc.hasNext()) {
String a = sc.next();
StringBuffer b = new StringBuffer();
for (int i = 0; i < a.length(); i++) {
if (Arrays.binarySearch(list, a.charAt(i)) >= 0) {
b.append(a.charAt(i));
} else {
if (b.length() != 0) {
count += Integer.parseInt(b.toString());
b = new StringBuffer();
}
}
if (i + 1 == a.length() && b.length() != 0) {
count += Integer.parseInt(b.toString());
}
}
}
out.println(count);
out.flush();
}
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
}
|
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 98]]
| 3
| 683
|
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
int count = 0;
while ((line = br.readLine()) != null) {
int a = 0;
boolean f = false;
for (int i = 0; i < line.length(); i++) {
if (!f) {
count += a;
a = 0;
}
f = false;
if (line.charAt(i) >= '0' && line.charAt(i) <= '9') {
a = a * 10 + (int)(line.charAt(i) - '0');
f = true;
}
}
}
System.out.println(count);
}
}
|
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
int count = 0;
while ((line = br.readLine()) != null) {
int a = 0;
boolean f = false;
for (int i = 0; i < line.length(); i++) {
if (!f) {
count += a;
a = 0;
}
f = false;
if (line.charAt(i) >= '0' && line.charAt(i) <= '9') {
a = a * 10 + (int)(line.charAt(i) - '0');
f = true;
}
}
count += a;
}
System.out.println(count);
}
}
|
[["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
| 3
| 171
|
public class Main {
public void run(java.io.InputStream in, java.io.PrintStream out) {
java.util.Scanner sc = new java.util.Scanner(in);
String s;
char[] c;
int res, i, l;
res = 0;
for (; sc.hasNext();) {
s = sc.next();
c = new char[s.length()];
for (i = 0; i < s.length(); i++)
c[i] = s.charAt(i);
for (i = 0; i < s.length(); i++) {
if (c[i] >= '0' && c[i] <= '9') {
for (l = i; i < s.length() && c[i] >= '0' && c[i] <= '9';)
i++;
res += readint(c, l, i);
}
}
out.println(res);
}
sc.close();
}
public static void main(String[] args) {
(new Main()).run(System.in, System.out);
}
private static int readint(char[] ch, int l, int r) {
int i, d, res;
d = 1;
res = 0;
for (i = r - 1; i >= l; i--) {
res += d * (int)(ch[i] - '0');
d *= 10;
}
return res;
}
}
|
public class Main {
public void run(java.io.InputStream in, java.io.PrintStream out) {
java.util.Scanner sc = new java.util.Scanner(in);
String s;
char[] c;
int res, i, l;
res = 0;
for (; sc.hasNext();) {
s = sc.next();
c = new char[s.length()];
for (i = 0; i < s.length(); i++)
c[i] = s.charAt(i);
for (i = 0; i < s.length(); i++) {
if (c[i] >= '0' && c[i] <= '9') {
for (l = i; i < s.length() && c[i] >= '0' && c[i] <= '9';)
i++;
res += readint(c, l, i);
}
}
}
out.println(res);
sc.close();
}
public static void main(String[] args) {
(new Main()).run(System.in, System.out);
}
private static int readint(char[] ch, int l, int r) {
int i, d, res;
d = 1;
res = 0;
for (i = r - 1; i >= l; i--) {
res += d * (int)(ch[i] - '0');
d *= 10;
}
return res;
}
}
|
[["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 3
| 318
|
import java.util.Scanner;
public class Main {
private Scanner sc;
public static void main(String[] args) { new Main(); }
public Main() {
sc = new Scanner(System.in);
int num = 0;
while (sc.hasNextLine() == true) {
String line = sc.nextLine();
int state = 0;
int tmp = 0;
for (int i = 0; i < line.length(); i++) {
if (Character.isDigit(line.charAt(i)) == true) {
tmp = tmp * 10 + (line.charAt(i) - '0');
state++;
} else {
if (state > 0) {
num = num + tmp;
state = 0;
tmp = 0;
}
}
}
}
System.out.println(num);
}
}
|
import java.util.Scanner;
public class Main {
private Scanner sc;
public static void main(String[] args) { new Main(); }
public Main() {
sc = new Scanner(System.in);
int num = 0;
while (sc.hasNextLine() == true) {
String line = sc.nextLine();
int state = 0;
int tmp = 0;
for (int i = 0; i < line.length(); i++) {
if (Character.isDigit(line.charAt(i)) == true) {
tmp = tmp * 10 + (line.charAt(i) - '0');
state++;
} else {
if (state > 0) {
num = num + tmp;
state = 0;
tmp = 0;
}
}
}
num = num + tmp;
}
System.out.println(num);
}
}
|
[["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 17, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 519, 0, 52, 8, 196, 0, 1, 0, 35]]
| 3
| 177
|
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
BigInteger sum = new BigInteger("0");
while (sc.hasNextLine()) {
String str = sc.nextLine();
String[] a = str.split("[D]");
for (int i = 0; i < a.length; i++) {
if (a[i].length() > 0) {
sum = sum.add(new BigInteger(a[i]));
}
}
}
System.out.println(sum.toString());
}
}
|
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
BigInteger sum = new BigInteger("0");
while (sc.hasNext()) {
String str = sc.next();
String[] a = str.split("[^0-9]");
for (int i = 0; i < a.length; i++) {
if (a[i].length() > 0) {
sum = sum.add(new BigInteger(a[i]));
}
}
}
System.out.println(sum.toString());
}
}
|
[["-", 8, 196, 0, 52, 15, 15, 0, 492, 141, 22], ["+", 8, 196, 0, 52, 15, 15, 0, 492, 141, 22], ["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["-", 49, 200, 51, 492, 3, 4, 0, 5, 0, 491], ["+", 49, 200, 51, 492, 3, 4, 0, 5, 0, 491]]
| 3
| 148
|
import java.math.*;
import java.util.*;
class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
BigInteger ret = new BigInteger("0");
while (s.hasNext()) {
String str = s.next();
String[] a = str.split("[a-zA-Z.]");
for (int i = 0; i < a.length; i++) {
if (a[i].length() > 0)
ret = ret.add(new BigInteger(a[i]));
}
}
System.out.println(ret.toString());
}
}
|
import java.math.*;
import java.util.*;
class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
BigInteger ret = new BigInteger("0");
while (s.hasNext()) {
String str = s.next();
String[] a = str.split("[^0-9]");
for (int i = 0; i < a.length; i++) {
if (a[i].length() > 0)
ret = ret.add(new BigInteger(a[i]));
}
}
System.out.println(ret.toString());
}
}
|
[["-", 49, 200, 51, 492, 3, 4, 0, 5, 0, 491], ["+", 49, 200, 51, 492, 3, 4, 0, 5, 0, 491]]
| 3
| 145
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
long sum = 0;
long tmp = 0;
while (stdIn.hasNext()) {
String a = stdIn.nextLine();
char[] b = new char[100];
b = a.toCharArray();
tmp = 0;
for (int i = 0; i < b.length; i++) {
if (b[i] >= '0' && b[i] <= '9') {
tmp *= 10;
tmp += b[i] - '0';
} else {
sum += tmp;
tmp = 0;
}
}
}
sum += tmp;
System.out.println(sum);
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
long sum = 0;
long tmp = 0;
while (stdIn.hasNext()) {
String a = stdIn.nextLine();
char[] b = new char[100];
b = a.toCharArray();
tmp = 0;
for (int i = 0; i < b.length; i++) {
if (b[i] >= '0' && b[i] <= '9') {
tmp *= 10;
tmp += b[i] - '0';
} else {
sum += tmp;
tmp = 0;
}
}
sum += tmp;
}
System.out.println(sum);
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
| 3
| 160
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum = 0;
while (sc.hasNext()) {
String s = sc.next();
int start = 0;
for (int i = 0; i < s.length(); i++) {
if (s.codePointAt(i) > 47 && s.codePointAt(i) < 58) {
start = i;
while (i < s.length() && s.codePointAt(i + 1) > 47 &&
s.codePointAt(i + 1) < 58)
i++;
sum += Integer.valueOf(s.substring(start, i + 1));
}
}
}
System.out.println(sum);
}
}
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum = 0;
while (sc.hasNext()) {
String s = sc.next();
int start = 0;
for (int i = 0; i < s.length(); i++) {
if (s.codePointAt(i) > 47 && s.codePointAt(i) < 58) {
start = i;
while (i < s.length() - 1 && s.codePointAt(i + 1) > 47 &&
s.codePointAt(i + 1) < 58)
i++;
sum += Integer.valueOf(s.substring(start, i + 1));
}
}
}
System.out.println(sum);
}
}
|
[["+", 0, 16, 31, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 12, 499]]
| 3
| 172
|
#include <math.h>
#include <stdio.h>
#include <string.h>
int main() {
int i, j, k;
int n = 0;
char s[81];
while (scanf("%s", s) != -1) {
for (i = 0; i < strlen(s); i++) {
if ('1' <= s[i] && s[i] <= '9') {
for (j = i + 1; j < strlen(s); j++) {
if (s[j] < '0' || '9' < s[j]) {
break;
}
}
for (k = 0; k < j - i; k++) {
n += (s[i + k] - '0') * pow(10, j - i - k - 1);
i = j;
}
}
}
}
printf("%d\n", n);
return 0;
}
|
#include <math.h>
#include <stdio.h>
#include <string.h>
int main() {
int i, j, k;
int n = 0;
char s[81];
while (scanf("%s", s) != -1) {
for (i = 0; i < strlen(s); i++) {
if ('1' <= s[i] && s[i] <= '9') {
for (j = i + 1; j < strlen(s); j++) {
if (s[j] < '0' || '9' < s[j])
break;
}
for (k = 0; k < j - i; k++)
n += (s[i + k] - '0') * pow(10, j - i - k - 1);
i = j;
}
}
}
printf("%d\n", n);
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 45], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46]]
| 0
| 191
|
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
int main(void) {
char str[81];
int count = 0, length, i, j = 0, k = 0;
while (scanf("%s", str) != EOF) {
length = strlen(str);
for (i = length - 1; i >= 0; i--) {
if (isdigit(str[i])) {
j = 0;
while (1) {
if (isdigit(str[i - j])) {
count += (str[i - j] - '0') * (pow(10, j));
k++;
} else {
i -= k;
break;
}
j++;
}
}
}
}
printf("%d\n", count);
return 0;
}
|
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
int main(void) {
char str[81];
int count = 0, length, i, j = 0, k = 0;
while (scanf("%s", str) != EOF) {
length = strlen(str);
for (i = length - 1; i >= 0; i--) {
if (isdigit(str[i])) {
j = 0;
k = 0;
while (1) {
if (isdigit(str[i - j])) {
count += (str[i - j] - '0') * (pow(10, j));
k++;
} else {
i -= k;
break;
}
j++;
}
}
}
}
printf("%d\n", count);
return 0;
}
|
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
| 0
| 165
|
#include <math.h>
#include <stdio.h>
int main() {
int i = 0, j, sum = 0;
char ch;
int str[6];
while ((ch = getchar()) != EOF) {
if (isdigit(ch) != 0) {
str[i++] = ch - '0';
} else if (i != 0) {
for (j = 0; j < i; j++) {
sum += str[j] * pow(10, i - j - 1);
}
i = 0;
}
}
printf("sum=%d\n", sum);
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main() {
int i = 0, j, sum = 0;
char ch;
int str[6];
while ((ch = getchar()) != EOF) {
if (isdigit(ch) != 0) {
str[i++] = ch - '0';
} else if (i != 0) {
for (j = 0; j < i; j++) {
sum += str[j] * pow(10, i - j - 1);
}
i = 0;
}
}
printf("%d\n", sum);
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 126
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int i, len;
int pass = 0;
char line[100];
while (1) {
if (scanf("%s", line) == -1)
break;
len = strlen(line);
for (i = 0; i < len; i++) {
if (line[i] < '0' || line[i] > '9')
line[i] = 0;
}
for (i = 0; i < len; i++) {
if (line[i] != 0) {
pass += atoi(&line[i]);
i += strlen(&line[i]);
}
}
printf("%d\n", pass);
}
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int i, len;
int pass = 0;
char line[100];
while (1) {
if (scanf("%s", line) == -1)
break;
len = strlen(line);
for (i = 0; i < len; i++) {
if (line[i] < '0' || line[i] > '9')
line[i] = 0;
}
for (i = 0; i < len; i++) {
if (line[i] != 0) {
pass += atoi(&line[i]);
i += strlen(&line[i]);
}
}
}
printf("%d\n", pass);
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 0
| 159
|
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
int main() {
string st;
int ans = 0;
while (getline(cin, st)) {
int num = 0;
for (auto c : st) {
if (isdigit(c)) {
num *= 10;
num += c - '0';
} else {
ans += num;
num = 0;
}
}
}
cout << ans << endl;
return 0;
}
|
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
int main() {
string st;
int ans = 0;
while (getline(cin, st)) {
int num = 0;
for (auto c : st) {
if (isdigit(c)) {
num *= 10;
num += c - '0';
} else {
ans += num;
num = 0;
}
}
ans += num;
}
cout << ans << endl;
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 106
|
#include <cctype>
#include <iostream>
using namespace std;
string sentence;
typedef string::const_iterator State;
int parse(State &it) {
int ret = 0;
while (isdigit(*it)) {
ret = ret * 10;
ret = ret + *it - '0';
it++;
}
return ret;
}
int main(void) {
int sum = 0;
while (cin >> sentence) {
for (State it = sentence.begin(); it != sentence.end(); it++) {
if (isdigit(*it)) {
sum += parse(it);
}
}
}
cout << sum << endl;
return 0;
}
|
#include <cctype>
#include <iostream>
using namespace std;
string sentence;
typedef string::const_iterator State;
int parse(State &it) {
int ret = 0;
while (isdigit(*it)) {
ret = ret * 10;
ret = ret + *it - '0';
it++;
}
return ret;
}
int main(void) {
int sum = 0;
while (cin >> sentence) {
for (State it = sentence.begin(); it != sentence.end(); it++) {
if (isdigit(*it)) {
sum += parse(it);
it--;
}
}
}
cout << sum << endl;
return 0;
}
|
[["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
| 1
| 134
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int main() {
string s;
int ans = 0;
while (cin >> s) {
string num;
rep(i, s.size()) {
if ('0' <= s[i] && s[i] <= '9')
num += s[i];
else {
ans += atoi(num.c_str());
num.clear();
}
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
/*
int main() {
string s;
int ans = 0;
while (cin >> s) {
rep(i, s.size()) {
int n = 0;
while ('0' <= s[i + n] && s[i + n] <= '9') n++;
ans += atoi(s.substr(i, n).c_str());
i += n;
}
}
cout << ans << endl;
} */
int main() {
string s;
int ans = 0;
while (cin >> s) {
s += ' ';
string num;
rep(i, s.size()) {
if ('0' <= s[i] && s[i] <= '9')
num += s[i];
else {
ans += atoi(num.c_str());
num.clear();
}
}
}
cout << ans << endl;
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 1, 0, 11, 12, 103, 0, 104], ["+", 8, 9, 0, 1, 0, 11, 12, 103, 0, 125], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 268
|
#include <bits/stdc++.h>
#define range(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define rep(i, n) range(i, 0, n)
using namespace std;
int main(void) {
int ans = 0;
while (1) {
string s;
cin >> s;
if (cin.eof())
break;
int n = s.size();
int cur = 0;
rep(i, n) {
if (isdigit(s[i])) {
cur = cur * 10 + (s[i] - '0');
} else {
ans += cur;
cur = 0;
}
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
#define range(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define rep(i, n) range(i, 0, n)
using namespace std;
int main(void) {
int ans = 0;
while (1) {
string s;
cin >> s;
if (cin.eof())
break;
int n = s.size();
int cur = 0;
rep(i, n) {
if (isdigit(s[i])) {
cur = cur * 10 + (s[i] - '0');
} else {
ans += cur;
cur = 0;
}
}
ans += cur;
}
cout << ans << endl;
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 130
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
int c = 0;
while (cin >> str) {
int t = 0;
for (int i = 0; i < str.length(); i++) {
if (str[i] >= '0' && str[i] <= '9')
t = t * 10 + str[i] - '0';
else {
c += t;
t = 0;
}
}
}
cout << c << endl;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
int c = 0;
while (cin >> str) {
int t = 0;
for (int i = 0; i < str.length(); i++) {
if (str[i] >= '0' && str[i] <= '9')
t = t * 10 + str[i] - '0';
else {
c += t;
t = 0;
}
}
c += t;
}
cout << c << endl;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 107
|
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
using namespace std;
int main() {
int ans = 0;
string s;
while (cin >> s) {
rep(i, 0, s.size()) {
if (s[i] - '0' >= 0 && s[i] - '0' < 10) {
rep(j, i + 1, s.size()) {
if (s[j] - '0' < 0 || s[j] - '0' >= 10 || j == s.size() - 1) {
if (j == s.size() - 1)
j++;
ans += atoi(s.substr(i, j - i).c_str());
// cout<<atoi(s.substr(i,j-i).c_str())<<endl;
i = j;
break;
}
}
}
}
}
o(ans);
}
|
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
using namespace std;
int main() {
int ans = 0;
string s;
while (cin >> s) {
rep(i, 0, s.size()) {
if (s[i] - '0' >= 0 && s[i] - '0' < 10) {
rep(j, i, s.size()) {
if (s[j] - '0' < 0 || s[j] - '0' >= 10 || j == s.size() - 1) {
if (j == s.size() - 1)
j++;
ans += atoi(s.substr(i, j - i).c_str());
// cout<<atoi(s.substr(i,j-i).c_str())<<endl;
i = j;
break;
}
}
}
}
}
o(ans);
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 218
|
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for (int i = a; i < b; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
struct edge {
int to, time, cost;
};
const double eps = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;
const double infd = (double)1e+9;
int sum = 0;
std::string str;
std::string::iterator it;
int number() {
int ret = 0;
while (isdigit(*it)) {
ret *= 10;
ret += (*it - '0');
++it;
}
return ret;
}
int main() {
while (std::cin >> str) {
it = str.begin();
while (it != str.end()) {
if (isdigit(*it))
sum += number();
++it;
}
}
std::cout << sum << std::endl;
return 0;
}
|
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for (int i = a; i < b; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
struct edge {
int to, time, cost;
};
const double eps = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;
const double infd = (double)1e+9;
int sum = 0;
std::string str;
std::string::iterator it;
int number() {
int ret = 0;
while (isdigit(*it)) {
ret *= 10;
ret += (*it - '0');
++it;
}
return ret;
}
int main() {
while (std::cin >> str) {
str += ".";
it = str.begin();
while (it != str.end()) {
if (isdigit(*it))
sum += number();
++it;
}
}
std::cout << sum << std::endl;
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 1, 0, 11, 12, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 251
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
string str;
int ans, num;
ans = 0;
num = 0;
while (true) {
num = 0;
cin >> str;
if (cin.eof()) {
break;
}
for (int i = 0; i < str.size(); i++) {
if (str[i] >= '0' && str[i] <= '9') {
num *= 10;
num += (str[i] - '0');
} else {
ans += num;
num = 0;
}
}
}
printf("%d\n", ans);
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
string str;
int ans, num;
ans = 0;
num = 0;
while (true) {
num = 0;
cin >> str;
if (cin.eof()) {
break;
}
for (int i = 0; i < str.size(); i++) {
if (str[i] >= '0' && str[i] <= '9') {
num *= 10;
num += (str[i] - '0');
} else {
ans += num;
num = 0;
}
}
ans += num;
}
printf("%d\n", ans);
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 141
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second
#define PI acos(-1.0)
#define INF 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
string s;
int sum = 0;
int changei(string s) {
int res;
stringstream ss;
ss << s;
ss >> res;
return res;
}
int main() {
while (cin >> s) {
string t;
int co = 0, st = -1;
REP(i, s.size()) {
if (st < 0 && s[i] >= '0' && s[i] <= '9') {
st = i;
co++;
} else if (st > 0) {
if (s[i] >= '0' && s[i] <= '9') {
co++;
} else {
t = s.substr(st, co);
sum += changei(t);
st = -1;
}
}
if (i == s.size() - 1 && st >= 0) {
t = s.substr(st, co);
sum += changei(t);
st = -1;
}
}
}
cout << sum << endl;
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second
#define PI acos(-1.0)
#define INF 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
string s;
int sum = 0;
int changei(string s) {
int res;
stringstream ss;
ss << s;
ss >> res;
return res;
}
int main() {
while (cin >> s) {
string t;
int co = 0, st = -1;
REP(i, s.size()) {
if (st < 0 && s[i] >= '0' && s[i] <= '9') {
st = i;
co++;
} else if (st >= 0) {
if (s[i] >= '0' && s[i] <= '9') {
co++;
} else {
t = s.substr(st, co);
sum += changei(t);
st = -1;
}
}
if (i == s.size() - 1 && st >= 0) {
t = s.substr(st, co);
sum += changei(t);
st = -1;
}
}
}
cout << sum << endl;
}
|
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 20]]
| 1
| 319
|
#include <iostream>
using namespace std;
int main() {
string s;
int ans = 0;
int sum;
int flag = 1;
int temp = 0;
while (cin >> s) {
sum = 0;
for (int i = 0; i < s.size(); i++) {
if ('0' <= s[i] && s[i] <= '9') {
sum = 10 * sum + (s[i] - '0');
} else {
ans += sum;
sum = 0;
}
}
}
cout << ans << endl;
}
|
#include <iostream>
using namespace std;
int main() {
string s;
int ans = 0;
int sum;
int flag = 1;
int temp = 0;
while (cin >> s) {
sum = 0;
for (int i = 0; i < s.size(); i++) {
if ('0' <= s[i] && s[i] <= '9') {
sum = 10 * sum + (s[i] - '0');
} else {
ans += sum;
sum = 0;
}
}
ans += sum;
}
cout << ans << endl;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 121
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <stack>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v) \
for (int i = 0; i < (n); i++) { \
int j; \
cin >> j; \
v.push_back(j); \
}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl
int main() {
char c;
int intset = 0, ans = 0;
while (getchar() != EOF) {
if ('0' <= c && c <= '9') {
intset *= 10;
intset += c - '0';
} else {
ans += intset;
intset = 0;
}
}
cout << ans << endl;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <stack>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v) \
for (int i = 0; i < (n); i++) { \
int j; \
cin >> j; \
v.push_back(j); \
}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl
int main() {
char c;
int intset = 0, ans = 0;
while ((c = getchar()) != EOF) {
if ('0' <= c && c <= '9') {
intset *= 10;
intset += c - '0';
} else {
ans += intset;
intset = 0;
}
}
cout << ans << endl;
}
|
[["+", 0, 52, 15, 339, 51, 16, 31, 23, 0, 24], ["+", 15, 339, 51, 16, 31, 23, 0, 42, 0, 22], ["+", 15, 339, 51, 16, 31, 23, 0, 42, 0, 32], ["+", 51, 16, 31, 23, 0, 2, 3, 4, 0, 25]]
| 1
| 134
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int ans = 0, num;
string s;
while (cin >> s) {
num = 0;
for (int i = 0; i < s.size(); i++) {
if ('0' <= s[i] && s[i] <= '9') {
num = num * 10 + (s[i] - '0');
} else {
ans += num;
num = 0;
}
}
}
cout << ans << endl;
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int ans = 0, num;
string s;
while (cin >> s) {
num = 0;
for (int i = 0; i < s.size(); i++) {
if ('0' <= s[i] && s[i] <= '9') {
num = num * 10 + (s[i] - '0');
} else {
ans += num;
num = 0;
}
}
ans += num;
}
cout << ans << endl;
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 115
|
#include <iostream>
#include <string>
using namespace std;
int findNumber(string s) {
int tmp = 0, res = 0;
for (int i = 0; i < s.size(); i++) {
if (0 <= s[i] - '0' && s[i] - '0' < 10) {
tmp *= 10;
tmp += s[i] - '0';
} else {
res += tmp;
tmp = 0;
}
}
return res;
}
int main() {
string s;
int sum = 0;
while (cin >> s) {
sum += findNumber(s);
}
cout << sum << endl;
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int findNumber(string s) {
int tmp = 0, res = 0;
for (int i = 0; i < s.size(); i++) {
if (0 <= s[i] - '0' && s[i] - '0' < 10) {
tmp *= 10;
tmp += s[i] - '0';
} else {
res += tmp;
tmp = 0;
}
}
return res + tmp;
}
int main() {
string s;
int sum = 0;
while (cin >> s) {
sum += findNumber(s);
}
cout << sum << endl;
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 22]]
| 1
| 138
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
int sum = 0;
while (getline(cin, s)) {
string sa;
for (int i = 0; i < s.size(); i++) {
if (s[i] >= '0' && s[i] <= '9') {
sa.push_back(s[i]);
} else {
if (i != 0 && s[i - 1] >= '0' && s[i - 1] <= '9') {
int a = stoi(sa);
sum += a;
sa.clear();
}
}
}
if (!sa.empty() && sa[s.size() - 1] >= '0' && sa[s.size() - 1] <= '9') {
int a = stoi(sa);
sum += a;
sa.clear();
}
}
cout << sum << endl;
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
int sum = 0;
while (getline(cin, s)) {
string sa;
for (int i = 0; i < s.size(); i++) {
if (s[i] >= '0' && s[i] <= '9') {
sa.push_back(s[i]);
} else {
if (i != 0 && s[i - 1] >= '0' && s[i - 1] <= '9') {
int a = stoi(sa);
sum += a;
sa.clear();
}
}
}
if (!sa.empty() && sa[sa.size() - 1] >= '0' && sa[sa.size() - 1] <= '9') {
int a = stoi(sa);
sum += a;
sa.clear();
}
}
cout << sum << endl;
return 0;
}
|
[["-", 341, 342, 0, 16, 31, 2, 63, 118, 28, 22], ["+", 341, 342, 0, 16, 31, 2, 63, 118, 28, 22]]
| 1
| 207
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int ans = 0;
string s;
while (getline(cin, s)) {
int n = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '1')
n = n * 10 + 1;
else if (s[i] == '2')
n = n * 10 + 2;
else if (s[i] == '3')
n = n * 10 + 3;
else if (s[i] == '4')
n = n * 10 + 4;
else if (s[i] == '5')
n = n * 10 + 5;
else if (s[i] == '6')
n = n * 10 + 6;
else if (s[i] == '7')
n = n * 10 + 7;
else if (s[i] == '8')
n = n * 10 + 8;
else if (s[i] == '9')
n = n * 10 + 9;
else if (s[i] == '0')
n = n * 10 + 0;
else {
ans += n;
n = 0;
}
}
}
cout << ans << endl;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int ans = 0;
string s;
while (getline(cin, s)) {
int n = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '1')
n = n * 10 + 1;
else if (s[i] == '2')
n = n * 10 + 2;
else if (s[i] == '3')
n = n * 10 + 3;
else if (s[i] == '4')
n = n * 10 + 4;
else if (s[i] == '5')
n = n * 10 + 5;
else if (s[i] == '6')
n = n * 10 + 6;
else if (s[i] == '7')
n = n * 10 + 7;
else if (s[i] == '8')
n = n * 10 + 8;
else if (s[i] == '9')
n = n * 10 + 9;
else if (s[i] == '0')
n = n * 10 + 0;
else {
ans += n;
n = 0;
}
}
ans += n;
}
cout << ans << endl;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 274
|
#include <stdio.h>
int main() {
int r = 0, j, i;
char s[128];
while (scanf("%s", s) != EOF) {
j = 0;
i = 0;
while (s[i] != 0) {
if (s[i] >= '0' && s[i] <= '9') {
j *= 10;
j += (s[i] - '0');
} else {
r += j;
j = 0;
}
i++;
}
}
printf("%d\n", r);
return 0;
}
|
#include <stdio.h>
int main() {
int r = 0, j, i;
char s[128];
while (scanf("%s", s) != EOF) {
j = 0;
i = 0;
while (s[i] != 0) {
if (s[i] >= '0' && s[i] <= '9') {
j *= 10;
j += (s[i] - '0');
} else {
r += j;
j = 0;
}
i++;
}
r += j;
}
printf("%d\n", r);
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 123
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
unsigned int x, sum = 0;
while (cin >> str) {
for (string::size_type i = 0; i < str.length(); i++) {
x = 0;
while (isdigit(str[i])) {
x = 10 * x + str[i] - '0';
i++;
}
if (x > 0) {
sum += x;
}
}
cout << sum << '\n';
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
unsigned int x, sum = 0;
while (cin >> str) {
for (string::size_type i = 0; i < str.length(); i++) {
x = 0;
while (isdigit(str[i])) {
x = 10 * x + str[i] - '0';
i++;
}
if (x > 0) {
sum += x;
}
}
}
cout << sum << '\n';
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 112
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool isdigit(char c);
int main() {
string str;
int num = 0;
int ans = 0;
while (cin >> str) {
for (int i = 0; i < str.size(); ++i) {
if (isdigit(str[i])) {
if (isdigit(str[i - 1])) {
num *= 10;
num += (int)(str[i] - '0');
} else if (isdigit(str[i])) {
num += (int)(str[i] - '0');
}
}
if (!isdigit(str[i + 1])) {
ans += num;
num = 0;
}
}
cout << ans << endl;
}
return 0;
}
bool isdigit(char c) {
switch (c) {
case '0':
return true;
case '1':
return true;
case '2':
return true;
case '3':
return true;
case '4':
return true;
case '5':
return true;
case '6':
return true;
case '7':
return true;
case '8':
return true;
case '9':
return true;
default:
return false;
}
}
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool isdigit(char c);
int main() {
string str;
int num = 0;
int ans = 0;
while (cin >> str) {
for (int i = 0; i < str.size(); ++i) {
if (isdigit(str[i])) {
if (isdigit(str[i - 1])) {
num *= 10;
num += (int)(str[i] - '0');
} else if (isdigit(str[i])) {
num += (int)(str[i] - '0');
}
}
if (!isdigit(str[i + 1])) {
ans += num;
num = 0;
}
}
}
cout << ans << endl;
return 0;
}
bool isdigit(char c) {
switch (c) {
case '0':
return true;
case '1':
return true;
case '2':
return true;
case '3':
return true;
case '4':
return true;
case '5':
return true;
case '6':
return true;
case '7':
return true;
case '8':
return true;
case '9':
return true;
default:
return false;
}
}
|
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 270
|
#include <iostream>
using namespace std;
int main() {
string text;
int s = 0, n = 0;
while (cin >> text) {
for (int i = 0; i < text.size(); i++) {
if ('0' <= text[i] && text[i] <= '9') {
n *= 10;
n += (text[i] - '0');
} else {
s += n;
n = 0;
}
}
n = 0;
}
cout << s << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
string text;
int s = 0, n = 0;
while (cin >> text) {
for (int i = 0; i < text.size(); i++) {
if ('0' <= text[i] && text[i] <= '9') {
n *= 10;
n += (text[i] - '0');
} else {
s += n;
n = 0;
}
}
s += n;
n = 0;
}
cout << s << endl;
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 115
|
#include <stdio.h>
int main() {
double d[8];
int i;
while (scanf("%lf", &d[0]) != EOF) {
for (i = 1; i < 8; i++)
scanf("%lf", &d[i]);
if ((d[0] <= d[4] && d[4] <= d[2] || d[4] <= d[0] && d[0] <= d[6]) &&
(d[1] <= d[5] && d[5] <= d[3] || d[5] <= d[1] && d[1] <= d[7])) {
printf("Yes\n");
} else
printf("No\n");
}
return 0;
}
|
#include <stdio.h>
int main() {
double d[8];
int i;
while (scanf("%lf", &d[0]) != EOF) {
for (i = 1; i < 8; i++)
scanf("%lf", &d[i]);
if ((d[0] <= d[4] && d[4] <= d[2] || d[4] <= d[0] && d[0] <= d[6]) &&
(d[1] <= d[5] && d[5] <= d[3] || d[5] <= d[1] && d[1] <= d[7])) {
printf("YES\n");
} else
printf("NO\n");
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 170
|
#include <stdio.h>
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1,
&yb1, &xb2, &yb2) != EOF) {
if ((((xb1 <= xa1) && (xa1 <= xb2)) || ((xb1 <= xa2) && (xa2 <= xb2)) ||
((xa1 <= xb1) && (xb1 <= xa2)) || ((xa1 <= xb2) && (xb2 <= xa2))) &&
(((yb1 <= ya1) && (ya1 <= yb2)) || ((yb1 <= ya2) && (ya2 <= yb2)) ||
((ya1 <= yb1) && (yb1 <= ya2)) || ((ya1 <= yb2) && (yb2 <= ya2)))) {
printf("YES");
} else {
printf("NO");
}
}
return 0;
}
|
#include <stdio.h>
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1,
&yb1, &xb2, &yb2) != EOF) {
if ((((xb1 <= xa1) && (xa1 <= xb2)) || ((xb1 <= xa2) && (xa2 <= xb2)) ||
((xa1 <= xb1) && (xb1 <= xa2)) || ((xa1 <= xb2) && (xb2 <= xa2))) &&
(((yb1 <= ya1) && (ya1 <= yb2)) || ((yb1 <= ya2) && (ya2 <= yb2)) ||
((ya1 <= yb1) && (yb1 <= ya2)) || ((ya1 <= yb2) && (yb2 <= ya2)))) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 202
|
#include <stdio.h>
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1,
&yb1, &xb2, &yb2) != EOF) {
if (xb1 <= xa2 && xa1 <= xb2 && yb1 <= ya2 && ya1 <= yb2) {
printf("YES");
} else {
printf("NO");
}
}
return 0;
}
|
#include <stdio.h>
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1,
&yb1, &xb2, &yb2) != EOF) {
if (xb1 <= xa2 && xa1 <= xb2 && yb1 <= ya2 && ya1 <= yb2) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 102
|
#include <iostream>
using namespace std;
int main() {
double ax1, ax2, ay1, ay2, bx1, bx2, by1, by2;
while (cin >> ax1 >> ay1 >> ax2 >> ay2 >> bx1 >> by1 >> bx2 >> by2) {
if (ax1 <= by2 && by1 <= ay2 && bx1 <= ax2 && ay1 <= by2)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
double ax1, ax2, ay1, ay2, bx1, bx2, by1, by2;
while (cin >> ax1 >> ay1 >> ax2 >> ay2 >> bx1 >> by1 >> bx2 >> by2) {
if (ax1 <= bx2 && by1 <= ay2 && bx1 <= ax2 && ay1 <= by2)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 51, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 12, 22]]
| 1
| 89
|
#include <iostream>
using namespace std;
int main() {
double ax1, ax2, ay1, ay2, bx1, bx2, by1, by2;
while (cin >> ax1 >> ay1 >> ax2 >> ay2 >> bx1 >> by1 >> bx2 >> by2) {
if (ax1 <= by2 && by1 <= ay2 && bx1 <= ax2 && ay1 <= by2)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
double ax1, ax2, ay1, ay2, bx1, bx2, by1, by2;
while (cin >> ax1 >> ay1 >> ax2 >> ay2 >> bx1 >> by1 >> bx2 >> by2)
if (ax1 <= bx2 && by1 <= ay2 && bx1 <= ax2 && ay1 <= by2)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["-", 51, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 89
|
#include <iostream>
using namespace std;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
if (xa1 <= xb2 && xa2 >= xb1 && ya1 >= yb2 && xa2 >= yb1) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
if (xa1 <= xb2 && xa2 >= xb1 && ya1 <= yb2 && ya2 >= yb1) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 20], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 19], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]]
| 1
| 93
|
#include <iostream>
using namespace std;
int x[4], y[4];
int main() {
while (cin >> x[0] >> y[0]) {
cin >> x[1] >> y[1];
cin >> x[2] >> y[2];
cin >> x[3] >> y[3];
if (x[0] > x[1])
swap(x[0], x[1]);
if (x[2] > x[3])
swap(x[2], x[3]);
if (y[0] > y[1])
swap(y[0], y[1]);
if (y[2] > y[3])
swap(y[2], y[3]);
int OK = 1;
if (x[1] < x[2] || x[0] > x[3])
OK = 0;
if (y[1] < y[2] || y[0] > y[3])
OK = 0;
if (OK == 0) {
cout << "NO" << endl;
}
if (OK == 1) {
cout << "YES" << endl;
}
}
}
|
#include <iostream>
using namespace std;
long double x[4], y[4];
int main() {
while (cin >> x[0] >> y[0]) {
cin >> x[1] >> y[1];
cin >> x[2] >> y[2];
cin >> x[3] >> y[3];
if (x[0] > x[1])
swap(x[0], x[1]);
if (x[2] > x[3])
swap(x[2], x[3]);
if (y[0] > y[1])
swap(y[0], y[1]);
if (y[2] > y[3])
swap(y[2], y[3]);
int OK = 1;
if (x[1] < x[2] || x[0] > x[3])
OK = 0;
if (y[1] < y[2] || y[0] > y[3])
OK = 0;
if (OK == 0) {
cout << "NO" << endl;
}
if (OK == 1) {
cout << "YES" << endl;
}
}
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 39, 40]]
| 1
| 264
|
#include <stdio.h>
int main() {
double xa1, xa2, ya1, ya2, xb1, xb2, yb1, yb2;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1,
&xb2, &yb2) != EOF) {
if (xa1 > xb2 || ya1 > yb2 || xb1 > xa2 || yb1 > xa2) {
printf("NO\n");
} else {
printf("YES\n");
}
}
return 0;
}
|
#include <stdio.h>
int main() {
double xa1, xa2, ya1, ya2, xb1, xb2, yb1, yb2;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1,
&xb2, &yb2) != EOF) {
if (xa1 > xb2 || ya1 > yb2 || xb1 > xa2 || yb1 > ya2) {
printf("NO\n");
} else {
printf("YES\n");
}
}
return 0;
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
| 1
| 104
|
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cctype> // require tolower, toupper
#include <cfloat>
#include <climits>
#include <cmath> // require fabs
#include <cstdio> // require scanf printf
#include <cstdlib> // require abs exit atof atoi
#include <cstring> // require memset
#include <ctime> // require srand
#include <deque>
#include <fstream> // require freopen
#include <functional>
#include <iomanip> // require setw
#include <iostream>
#include <limits>
#include <map>
#include <numeric> // require accumulate
#include <queue>
#include <set>
#include <sstream> // require stringstream
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main() {
// cut here before submit
// freopen ("testcase.IR", "r", stdin );
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1,
&yb1, &xb2, &yb2) != EOF) {
bool overlop = true;
if (xb1 < xa1 || xa2 < xb1 || yb1 < ya1 || ya2 < yb1)
overlop = false;
if (overlop) {
printf("YES\n");
} else {
printf("NO\n");
} // end if
} // end loop
return 0;
}
|
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cctype> // require tolower, toupper
#include <cfloat>
#include <climits>
#include <cmath> // require fabs
#include <cstdio> // require scanf printf
#include <cstdlib> // require abs exit atof atoi
#include <cstring> // require memset
#include <ctime> // require srand
#include <deque>
#include <fstream> // require freopen
#include <functional>
#include <iomanip> // require setw
#include <iostream>
#include <limits>
#include <map>
#include <numeric> // require accumulate
#include <queue>
#include <set>
#include <sstream> // require stringstream
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main() {
// cut here before submit
// freopen ("testcase.IR", "r", stdin );
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1,
&yb1, &xb2, &yb2) != EOF) {
bool overlop = true;
if (xb2 < xa1 || xa2 < xb1 || yb2 < ya1 || ya2 < yb1)
overlop = false;
if (overlop) {
printf("YES\n");
} else {
printf("NO\n");
} // end if
} // end loop
return 0;
}
|
[["-", 51, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22]]
| 1
| 208
|
#include <cstdio>
int main() {
float xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (scanf("%f%f%f%f%f%f%f%f", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2,
&yb2) != -1) {
if (xa1 <= xb2 && xb1 <= xa2 && ya1 <= yb2 && yb2 <= ya2)
printf("YES\n");
else
printf("NO\n");
}
}
|
#include <cstdio>
int main() {
float xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (scanf("%f%f%f%f%f%f%f%f", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2,
&yb2) != -1) {
if (xa1 <= xb2 && xb1 <= xa2 && ya1 <= yb2 && yb1 <= ya2)
printf("YES\n");
else
printf("NO\n");
}
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]]
| 1
| 97
|
#include <iostream>
using namespace std;
struct P {
int x;
int y;
};
int main() {
P a, b, c, d;
while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y) {
if (c.x <= b.x && d.x <= a.x && c.y <= b.y && d.y <= a.y)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
struct P {
double x;
double y;
};
int main() {
P a, b, c, d;
while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y) {
if (c.x <= b.x && a.x <= d.x && c.y <= b.y && a.y <= d.y)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 0, 30, 0, 122, 8, 123, 0, 124, 39, 40], ["+", 0, 30, 0, 122, 8, 123, 0, 124, 39, 40], ["-", 31, 16, 31, 16, 12, 16, 31, 118, 28, 22], ["+", 31, 16, 31, 16, 12, 16, 31, 118, 28, 22], ["-", 31, 16, 31, 16, 12, 16, 12, 118, 28, 22], ["+", 31, 16, 31, 16, 12, 16, 12, 118, 28, 22], ["-", 15, 339, 51, 16, 12, 16, 31, 118, 28, 22], ["+", 15, 339, 51, 16, 12, 16, 31, 118, 28, 22], ["-", 15, 339, 51, 16, 12, 16, 12, 118, 28, 22], ["+", 15, 339, 51, 16, 12, 16, 12, 118, 28, 22]]
| 1
| 124
|
#include <iostream>
using namespace std;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2;
if (!(xb2 < xa1 || xa2 < xb1 || ya1 > yb2 || ya2 < yb1))
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
if (!(xb2 < xa1 || xa2 < xb1 || ya1 > yb2 || ya2 < yb1))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 88
|
#include <cmath>
#include <cstdio>
using namespace std;
int main(void) {
double xa1, ya1, xa2, ya2; // A左下,右上
double xb1, yb1, xb2, yb2; // B左下,右上
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1,
&yb1, &xb2, &yb2) != EOF) {
bool f = false;
double xaa = (xa1 > xa2) ? xa1 : xa2;
double xab = (xa1 > xa2) ? xa2 : xa1;
double yaa = (ya1 > ya2) ? ya1 : ya2;
double yab = (ya1 > ya2) ? ya2 : ya1;
double xba = (xb1 > xb2) ? xb1 : xb2;
double xbb = (xb1 > xb2) ? xb2 : xb1;
double yba = (yb1 > yb2) ? yb1 : yb2;
double ybb = (yb1 > yb2) ? yb2 : yb1;
if (xab <= xb1 && xb1 <= xaa) {
if (yab <= yb1 && yb1 <= yaa)
f = true;
if (yab <= yb2 && yb2 <= yaa)
f = true;
if (ybb <= ya1 && ya1 <= yba)
f = true;
if (ybb <= ya2 && ya2 <= yba)
f = true;
}
if (xab <= xb2 && xb2 <= xaa) {
if (yab <= yb1 && yb1 <= yaa)
f = true;
if (yab <= yb2 && yb2 <= yaa)
f = true;
if (ybb <= ya1 && ya1 <= yba)
f = true;
if (ybb <= ya2 && ya2 <= yba)
f = true;
}
if (xbb <= xa1 && xa1 <= xba) {
if (yab <= yb1 && yb1 <= yaa)
f = true;
if (yab <= yb2 && yb2 <= yaa)
f = true;
if (ybb <= ya1 && ya1 <= yba)
f = true;
if (ybb <= ya2 && ya2 <= yba)
f = true;
}
if (xbb <= xa2 && xa2 <= xba) {
if (yab <= yb1 && yb1 <= yaa)
f = true;
if (yab <= yb2 && yb2 <= yaa)
f = true;
if (ybb <= ya1 && ya1 <= yba)
f = true;
if (ybb <= ya2 && ya2 <= yba)
f = true;
}
if (f)
puts("YES");
else {
puts("NO");
break;
}
}
return 0;
}
|
#include <cmath>
#include <cstdio>
using namespace std;
int main(void) {
double xa1, ya1, xa2, ya2; // A左下,右上
double xb1, yb1, xb2, yb2; // B左下,右上
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1,
&yb1, &xb2, &yb2) != EOF) {
bool f = false;
double xaa = (xa1 > xa2) ? xa1 : xa2;
double xab = (xa1 > xa2) ? xa2 : xa1;
double yaa = (ya1 > ya2) ? ya1 : ya2;
double yab = (ya1 > ya2) ? ya2 : ya1;
double xba = (xb1 > xb2) ? xb1 : xb2;
double xbb = (xb1 > xb2) ? xb2 : xb1;
double yba = (yb1 > yb2) ? yb1 : yb2;
double ybb = (yb1 > yb2) ? yb2 : yb1;
if (xab <= xb1 && xb1 <= xaa) {
if (yab <= yb1 && yb1 <= yaa)
f = true;
if (yab <= yb2 && yb2 <= yaa)
f = true;
if (ybb <= ya1 && ya1 <= yba)
f = true;
if (ybb <= ya2 && ya2 <= yba)
f = true;
}
if (xab <= xb2 && xb2 <= xaa) {
if (yab <= yb1 && yb1 <= yaa)
f = true;
if (yab <= yb2 && yb2 <= yaa)
f = true;
if (ybb <= ya1 && ya1 <= yba)
f = true;
if (ybb <= ya2 && ya2 <= yba)
f = true;
}
if (xbb <= xa1 && xa1 <= xba) {
if (yab <= yb1 && yb1 <= yaa)
f = true;
if (yab <= yb2 && yb2 <= yaa)
f = true;
if (ybb <= ya1 && ya1 <= yba)
f = true;
if (ybb <= ya2 && ya2 <= yba)
f = true;
}
if (xbb <= xa2 && xa2 <= xba) {
if (yab <= yb1 && yb1 <= yaa)
f = true;
if (yab <= yb2 && yb2 <= yaa)
f = true;
if (ybb <= ya1 && ya1 <= yba)
f = true;
if (ybb <= ya2 && ya2 <= yba)
f = true;
}
if (f)
puts("YES");
else
puts("NO");
}
return 0;
}
|
[["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35], ["-", 0, 57, 75, 76, 0, 9, 0, 93, 0, 94], ["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
| 1
| 479
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
if (((xb1 <= xa1 && xa1 <= xb1) || (xa1 <= xb1 && xb1 <= xa2)) &&
((yb1 <= ya1 && ya1 <= yb2) || (ya1 <= yb1 && yb1 <= ya2))) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
if (((xb1 <= xa1 && xa1 <= xb2) || (xa1 <= xb1 && xb1 <= xa2)) &&
((yb1 <= ya1 && ya1 <= yb2) || (ya1 <= yb1 && yb1 <= ya2))) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 0, 16, 31, 23, 0, 16, 12, 16, 12, 22], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 12, 22]]
| 1
| 123
|
#include <iostream>
using namespace std;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2)
cout << ((xb1 <= xa2 && xa1 <= xb2 && yb1 >= ya2 && ya1 >= yb2) ? "YES"
: "NO")
<< endl;
}
|
#include <iostream>
using namespace std;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2)
cout << ((xb1 <= xa2 && xa1 <= xb2 && yb1 <= ya2 && ya1 <= yb2) ? "YES"
: "NO")
<< endl;
}
|
[["-", 15, 23, 0, 16, 31, 16, 12, 16, 17, 20], ["+", 15, 23, 0, 16, 31, 16, 12, 16, 17, 19], ["-", 0, 41, 15, 23, 0, 16, 12, 16, 17, 20], ["+", 0, 41, 15, 23, 0, 16, 12, 16, 17, 19]]
| 1
| 81
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define INF 100000000
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i, n) for (int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a, b) memset((a), (b), sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<int> PQ;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
if (xa1 <= xb1 && ya1 <= yb1 && xa2 >= xb2 && ya2 >= yb2)
cout << "YES" << endl;
else if (xb1 <= xa1 && xa1 <= xb2 && ya1 <= yb1 && ya2 >= yb2)
cout << "YES" << endl;
else if (xb1 <= xa2 && xa2 <= xb2 && ya1 <= yb1 && ya2 >= yb2)
cout << "YES" << endl;
else if (yb1 <= ya1 && ya1 <= yb2 && xa1 <= xb1 && xa2 >= xb2)
cout << "Yes" << endl;
else if (yb1 <= ya2 && ya2 <= yb2 && xa1 <= xb1 && xa2 >= xb2)
cout << "Yes" << endl;
else if (xb1 <= xa1 && xa1 <= xb2 && yb1 <= ya1 && ya1 <= yb2)
cout << "YES" << endl;
else if (xb1 <= xa1 && xa1 <= xb2 && yb1 <= ya2 && ya2 <= yb2)
cout << "YES" << endl;
else if (xb1 <= xa2 && xa2 <= xb2 && yb1 <= ya1 && ya1 <= yb2)
cout << "YES" << endl;
else if (xb1 <= xa2 && xa2 <= xb2 && yb1 <= ya2 && ya2 <= yb2)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define INF 100000000
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i, n) for (int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a, b) memset((a), (b), sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<int> PQ;
int main() {
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
if (xa1 <= xb1 && ya1 <= yb1 && xa2 >= xb2 && ya2 >= yb2)
cout << "YES" << endl;
else if (xb1 <= xa1 && xa1 <= xb2 && ya1 <= yb1 && ya2 >= yb2)
cout << "YES" << endl;
else if (xb1 <= xa2 && xa2 <= xb2 && ya1 <= yb1 && ya2 >= yb2)
cout << "YES" << endl;
else if (yb1 <= ya1 && ya1 <= yb2 && xa1 <= xb1 && xa2 >= xb2)
cout << "YES" << endl;
else if (yb1 <= ya2 && ya2 <= yb2 && xa1 <= xb1 && xa2 >= xb2)
cout << "YES" << endl;
else if (xb1 <= xa1 && xa1 <= xb2 && yb1 <= ya1 && ya1 <= yb2)
cout << "YES" << endl;
else if (xb1 <= xa1 && xa1 <= xb2 && yb1 <= ya2 && ya2 <= yb2)
cout << "YES" << endl;
else if (xb1 <= xa2 && xa2 <= xb2 && yb1 <= ya1 && ya1 <= yb2)
cout << "YES" << endl;
else if (xb1 <= xa2 && xa2 <= xb2 && yb1 <= ya2 && ya2 <= yb2)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 423
|
while gets
xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = $_.split.map(&:to_i)
if (xa2 < xb1) || (ya2 < yb1) || (xa1 > xb2) || (ya1 > yb2)
puts "NO"
else
puts "YES"
end
end
|
while gets
xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = $_.split.map(&:to_f)
if (xa2 < xb1) || (ya2 < yb1) || (xa1 > xb2) || (ya1 > yb2)
puts "NO"
else
puts "YES"
end
end
|
[["-", 0, 662, 12, 652, 3, 4, 0, 752, 0, 753], ["+", 0, 662, 12, 652, 3, 4, 0, 752, 0, 753]]
| 4
| 62
|
import sys
for s in sys.stdin:
xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = list(map(float,s.split()))
if xb1 < xa1 or xa2 < xb1: print("NO")
elif yb2 < ya1 or ya2 < yb1: print("NO")
else: print("YES")
|
import sys
for s in sys.stdin:
xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = list(map(float,s.split()))
if xb2 < xa1 or xa2 < xb1: print("NO")
elif yb2 < ya1 or ya2 < yb1: print("NO")
else: print("YES")
|
[["-", 8, 196, 0, 57, 15, 679, 31, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 0, 22]]
| 5
| 76
|
while True:
try:
xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = list(map(float, input().split()))
print("NO" if (xb2 < xa1 or xa2 < xb1 or yb2 < ya1 or ya2 < ya1) else "YES")
except:
break
|
while True:
try:
xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = list(map(float, input().split()))
print("NO" if (xb2 < xa1 or xa2 < xb1 or yb2 < ya1 or ya2 < yb1) else "YES")
except:
break
|
[["-", 0, 41, 0, 23, 0, 679, 12, 666, 0, 22], ["+", 0, 41, 0, 23, 0, 679, 12, 666, 0, 22]]
| 5
| 67
|
x = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(/\s/);
y = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
for (i = 0; i < x.length - 1; i += 3) {
count = 0;
for (j = 0; j < 10; j++) {
if (y[j] <= 20 - (x[i] * 1 + x[i + 1] * 1) && y[j] != x[i + 2] &&
y[j] != x[i + 1] && y[j] != x[i]) {
count++;
}
}
if (count >= 4) {
console.log("Yes");
} else {
console.log("No");
}
}
|
x = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(/\s/);
y = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
for (i = 0; i < x.length - 1; i += 3) {
count = 0;
for (j = 0; j < 10; j++) {
if (y[j] <= 20 - (x[i] * 1 + x[i + 1] * 1) && y[j] != x[i + 2] &&
y[j] != x[i + 1] && y[j] != x[i]) {
count++;
}
}
if (count >= 4) {
console.log("YES");
} else {
console.log("NO");
}
}
|
[["-", 0, 1, 0, 2, 3, 3, 0, 557, 0, 491], ["+", 0, 1, 0, 2, 3, 3, 0, 557, 0, 491]]
| 2
| 189
|
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
boolean[] c = new boolean[11];
Arrays.fill(c, true);
c[0] = false;
int C1 = sc.nextInt();
int C2 = sc.nextInt();
int C3 = sc.nextInt();
c[C1] = false;
c[C2] = false;
c[C3] = false;
int sum = C1 + C2;
int cnt = 0;
for (int i = 1; i <= 10; i++) {
if (c[i] && sum + i <= 15) {
cnt++;
}
}
if (cnt >= 4) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
sc.close();
}
}
|
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
boolean[] c = new boolean[11];
Arrays.fill(c, true);
c[0] = false;
int C1 = sc.nextInt();
int C2 = sc.nextInt();
int C3 = sc.nextInt();
c[C1] = false;
c[C2] = false;
c[C3] = false;
int sum = C1 + C2;
int cnt = 0;
for (int i = 1; i <= 10; i++) {
if (c[i] && sum + i <= 20) {
cnt++;
}
}
if (cnt >= 4) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
sc.close();
}
}
|
[["-", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499]]
| 3
| 212
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.