akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
   int a,b,c ;
   cin >> a >> b >> c ;
  
  if(a+b+c>=22)
   cout << "bust" << endl ;
  else
   cout << "win" << endl ;
    
    return 0;
}



Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>
using namespace std;
//#define int long long

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;

	vector<int> all(n + 5);
	for (int i = 0; i < m; i++)
	{
		int l,  r;
		cin >> l >> r;
		all[l]++;
		all[r + 1]--;
	}
	vector<int> pref(n + 5);
	for (int i = 1; i < n+4; i++)
	{
		pref[i] = pref[i - 1] + all[i];
	}
	int cnt = 0;
	for (auto i : pref)
	{
		if (i == m)
			cnt++;
	}
	cout << cnt << "\n";
}


Measured memory_bytes: 1024
import static java.lang.Integer.parseInt;
import java.io.*;

class Main{
    public static void main(String[] a) throws IOException{

        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String s;

        while((s = input.readLine())!=null){
            String[] num = s.split(" ",0);
            int x = parseInt(num[0]);
            int y = parseInt(num[1]);
            if(0 <= x && x <=1000000 && 0 <= y && y <= 1000000){
                int z = x + y;
                System.out.println(Integer.toString(z).length());
            }
        }
    }
}

Measured memory_bytes: 24180
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };

int main() {
	long long a, b, ans = 1;
	cin >> a >> b;
	for (long long i = 2; i <= sqrt(b); ++i) {
		long long mon = 0;
		while (b%i == 0) {
			b /= i;
			++mon;
		}
		mon /= a;
		for (long long j = 0; j < mon; ++j) {
			ans *= i;
		}
	}

	if (a == 1) { ans *= b; }

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>

using namespace std;

vector<double> M;
double h;

int main(){
  
  while(1){
    cin >>h;
    M.push_back(h);
    sort(M.begin(),M.end());
    if(cin.eof()){break;}
  }
      printf("%.1f\n",M[M.size()-1]-M[0]);
  return 0;
}

Measured memory_bytes: 1260
# -*- coding: utf-8 -*-

import sys
import os
import math

def jump_candidate(pos):
    x = pos[0]
    y = pos[1]

    candidate_list = []

    A = []
    A.append((-2, 0))
    A.append((-2, -1))
    A.append((-2, +1))
    A.append((+2, 0))
    A.append((+2, -1))
    A.append((+2, +1))
    A.append((0, -2))
    A.append((-1, -2))
    A.append((+1, -2))
    A.append((0, +2))
    A.append((-1, +2))
    A.append((+1, +2))

    for a in A:
        next_x = x + a[0]
        next_y = y + a[1]
        if 0 <= next_x <= 9 and 0 <= next_y <= 9:
            candidate_list.append((next_x, next_y))

    return candidate_list

def in_sprinkler_range(frog_pos, sprinkler_pos):
    fx = frog_pos[0]
    fy = frog_pos[1]
    sx = sprinkler_pos[0]
    sy = sprinkler_pos[1]

    if sx - 1 <= fx <= sx + 1 and sy - 1 <= fy <= sy + 1:
        return True
    else:
        return False


for s in sys.stdin:
    px, py = map(int, s.split())

    if px == py == 0:
        break

    n = int(input())

    lst = list(map(int, input().split()))

    # solve
    survivers = [(px, py)]
    for i in range(n):
        sprinkler = (lst[2 * i], lst[2 * i + 1])

        next_survivers = []

        for surviver in survivers:
            pos_candidates = jump_candidate(surviver)

            for jump_pos in pos_candidates:
                if in_sprinkler_range(sprinkler, jump_pos):
                    next_survivers.append(jump_pos)

        survivers = next_survivers

    if len(survivers) == 0:
        print('NA')
    else:
        print('OK')

Measured memory_bytes: 7760
n = int(input())
key_dict = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for i in range(n):
    key = input()
    key_dict[key] += 1
print("AC x " + str(key_dict["AC"]))
print("WA x " + str(key_dict["WA"]))
print("TLE x " + str(key_dict["TLE"]))
print("RE x " + str(key_dict["RE"]))

Measured memory_bytes: 9108
#include <math.h>
#include <stdio.h>

int ispower(int n) {
	int a, b;

	for (a = 1; a < 50; a++)
		for (b = 2; b < 50; b++)
			if (pow(a, b) == n)
				return 1;
	return 0;
}

int main() {
	int x, n, max;

	scanf("%d", &x);
	max = 0;
	for (n = 1; n <= x; n++)
		if (ispower(n) && max < n)
			max = n;
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 512
<?php
fscanf(STDIN, "%d %d", $m, $d);
if ($m < 4 || $d < 22) exit('0');
$x = 0;
for ($i = 4; $i <= $m; $i++) {
	for ($j = 22; $j <= $d; $j++) {
		$d1 = $j % 10;
		$d2 = intdiv($j, 10);
		if ($d1 >= 2 && $d2 >= 2 && $d1 * $d2 == $i) $x++;
	}
}
echo $x;

Measured memory_bytes: 4604
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)


int main (void)
{
  int n,m,k;
  scanf("%d %d %d \n",&n,&m,&k);
  rep(i,n+1){
    rep(j,m+1){
      if (m*i+j*n-2*i*j==k) {
        puts("Yes");
        return 0;
      }  
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
import static java.lang.Math.*;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main{
    static void walkingTakashi(List<Long> list, long X, long K, long D) {
        long x = abs(X);
        if (x / D >= K)
            list.add(x - D * K);
        else {
            //(x / D)回移動するので, (x / D)*Dだけxは進む
            long k = K - x / D;
            x -= (x / D) * D;
            //往復
            if (k % 2 == 0)
                list.add(x);
            else
                list.add(abs(x - D));
        }

    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        long X = std.nextLong();
        long K = std.nextLong();
        long D = std.nextLong();

        List<Long> list = new ArrayList<Long>();
        walkingTakashi(list, X, K, D);

        Collections.sort(list);
        System.out.println(list.get(0));
    }

}


Measured memory_bytes: 35744
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define X first
#define Y second
#define in(x, y) (0 <= (x) && (x) < w && 0 <= (y) && (y) < h)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

char v[25][25];
int item[110][25][25];
int dp[2][25][25][1<<10];
bool ok[1<<10];

int value[10];
int s[10], e[10];

int dx[] = {0, 1, 0, -1, 0};
int dy[] = {1, 0, -1, 0, 0};
int main(){
	int w, h;
	while(cin >> w >> h, w|h){
		MEMSET(item, 0);
		MEMSET(dp, 0);
		MEMSET(ok, 0);
		rep(i, h) rep(j, w) cin >> v[i][j];
		int k;
		cin >> k;
		rep(i, k){
			int x;
			cin >> x;
			cin >> value[x] >> s[x] >> e[x];
		}

		rep(i, h) rep(j, w){
			if(v[i][j] == 'P'){
				dp[0][i][j][0] = 1;
				v[i][j] ='.';
			}else if(v[i][j] != '.'){
				int x = v[i][j]-'0';
				rep(d, 4){
					int nx = j+dx[d], ny = i+dy[d];
					if(!in(nx, ny)) continue;
					for(int t = s[x]; t < e[x]; ++t) item[t][ny][nx] |= 1<<x;
				}
			}
		}

		rep(t, 101) rep(y, h) rep(x, w) rep(k, 1<<10) rep(d, 5){
			if(!dp[t&1][y][x][k]) continue;
			int nx = x+dx[d], ny = y+dy[d];
			if(in(nx, ny) && (v[ny][nx] == '.')){
				int bits = k|item[t+1][ny][nx]|item[t][y][x];
				dp[(t+1)&1][ny][nx][bits] = 1;
				ok[bits] = 1;
			}
		}

		int ans = 0;
		rep(i, 1<<10){
			if(ok[i]){
				int tmp = 0;
				rep(j, 10){
					if(i&(1<<j)) tmp += value[j];
				}
				ans = max(ans, tmp);
			}
		}
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 6436
#include<iostream>
#include<queue>
#include<cstring>

typedef std::pair<int, int> P;
int dx[] = { 0, 1, 0, -1 }, dy[] = { 1, 0, -1, 0 };

int w, h;
char map[1001][1001];
P point[10];
int used[1001][1001];

int bfs(int sx, int sy, int gx, int gy){
	memset(used, -1, sizeof(used));
	used[sy][sx] = 0;

	std::queue<P> que;
	que.push(P(sx, sy));
	
	while (!que.empty()){
		P p = que.front();
		que.pop();

		if (p.first == gx && p.second == gy)break;
		
		for (int i = 0; i < 4; i++){
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx >= 0 && nx < w && ny >= 0 && ny < h && map[ny][nx] != 'X' && used[ny][nx] == -1){
				used[ny][nx] = used[p.second][p.first] + 1;
				que.push(P(nx, ny));
			}
		}
	}

	return used[gy][gx];
}

int main(){
	int n, ans = 0;

	std::cin >> h >> w >> n;

	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			std::cin >> map[i][j];

			if (map[i][j] == 'S')point[0] = P(j, i);
			if (1 <= (map[i][j] - '0') && (map[i][j] - '0') <= 9)point[map[i][j] - '0'] = P(j, i);
		}
	}

	for (int i = 0; i < n; i++){
		ans += bfs(point[i].first, point[i].second, point[i + 1].first, point[i + 1].second);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, k, q;
  cin >> n >> k >> q;

  vector<int> a(n, k - q);
  for (int i = 0; i < q; ++i) {
    int p;
    cin >> p;
    --p;

    ++a[p];
  }

  for (int i = 0; i < n; ++i) {
    if (a[i] > 0) cout << "Yes\n";
    else cout << "No\n";
  }

  return (0);
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;

int main()
{
	int a = 0, b = 0, i = 0;
	int v,n;
	while(cin >> v){
		cin.ignore();
		cin >> n;
		a += v * n;
		b += n;
		++i;
	}
	cout << a << endl << ((b * 10 / i) + 5) / 10 << endl;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
  int i,j,v,A[1000],n;
  
  scanf("%d",&n);


  for(i = 0; i < n ; i++){
    scanf("%d",&A[i]);
  }

  for (i = 0;i < n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);

  for(i = 1; i <= n-1 ; i++){ 

    v = A[i];
    j = i -1;
    while (j >= 0 && A[j] >v)
      {
	A[j+1] = A[j];
	j--;
      }
    A[j+1] = v;
  for (j = 0;j < n-1;j++){
    printf("%d ",A[j]);
  }
  printf("%d\n",A[n-1]);
  }

 


  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
using namespace std;

int main(){
 int n;
 int flag=0;
 char s[100];

 cin>>n;

 for(int i=0;i<n;i++){
     cin>>s[i];
     
     if(s[i]=='Y'){
         flag=1;
     }
 }

if(flag==0){
    cout<<"Three";
}
else{
    cout<<"Four";
}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n,m = map(int, input().split())
d = {}
py = []
for i in range(1,m+1):
    p,y = map(int, input().split())
    py.append((p,y))
    if p not in d:
        d[p] = []
    d[p].append([y,i])

ret = {}
for k in d.keys():
    d[k] = sorted(d[k])
    ret[k] = {}
    for i in range(len(d[k])):
        ret[k][d[k][i][0]] = i+1

for p,y in py:
    print("{:06}{:06}".format(p,ret[p][y]))


Measured memory_bytes: 83524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;
    string s = to_string(N);
    int f=0;
    rep(i,s.size()){
        f+=s[i]-'0';
    }
    if(N%f==0) cout << "Yes" << endl;
    else cout << "No" <<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	} else if (n == 2) {
		int a, b;
		cin >> a >> b;
		int ans = a + b;
		cout << ans << endl;
		return 0;
	}
}

Measured memory_bytes: 256
x = int(input())
if x == 2:
    print(2)
    exit()
while True:
    flg = 0
    for i in range(2,int(x**0.5)+1):
        if x%i == 0:
            flg += 1
        if i == int(x**0.5) and flg == 0:
            print(x)
            exit()
    x += 1



Measured memory_bytes: 9248
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
const ll MOD = (ll)1e9 + 7;
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    ll n;
    cin >> n;
    ll ans = 1;
    repn(i, n)
    {
        ans = i * ans % MOD;
    }

    cout << ans << endl;

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

long long dp[100005];

int main()
{
  int n,w,iw,iv;

  scanf("%d%d",&n,&w);
  for(int c=0;c<n;c++)
  {
    scanf("%d%d",&iw,&iv);
    for(int c2=w;c2>=iw;c2--)
    dp[c2]=max(dp[c2],dp[c2-iw]+iv);
  }
  printf("%lld\n",dp[w]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s=="SUN"){
    cout << 7 << endl;
  }
  if(s=="MON"){
    cout << 6 << endl;
  }
  if(s=="TUE"){
    cout << 5 << endl;
  }
  if(s=="WED"){
    cout << 4 << endl;
  }
  if(s=="THU"){
    cout << 3 << endl;
  }
  if(s=="FRI"){
    cout << 2 << endl;
  }
  if(s=="SAT"){
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 

int main() {
  
  int N;
  cin >> N;
  
  int num = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 1; j*j <= i; j++) {
      if (j*j == i) {
        num++;
      }
      else if (i%j == 0) {
        num += 2;
      }
    }
  }
  
  cout << num << endl;

return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>

typedef struct {
  double x, y;
} Point;

void print(Point p){ printf("%.8f %.8f\n", p.x, p.y); }

void plot(int n, Point p1, Point p2){
  Point s, t, u;
  double th = 60.0*(acos(-1)/180.0);
  if ( n == 0 ) return;
  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y ) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y ) * cos(th) + s.y;
  
  plot(n-1, p1, s);
  print(s);
  plot(n-1, s, u);
  print(u);
  plot(n-1, u, t);
  print(t);
  plot(n-1, t, p2);
}

main(){
  Point p1, p2;
  int n,a=0;
  a=kansu(a);
  if(a == 0){
  scanf("%d", &n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  print(p1);
  plot(n, p1, p2);
  print(p2);

  return 0;
}
}
void kansu(int a){
 int b=0,c=1;
 if(b == 0);
  if(c == 1);
   return a;
}


Measured memory_bytes: 2040
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;



int main() {
    int n,m,r,ans=inf,cnt; cin>>n>>m>>r;
    int s,cost;
    vector<int> v(r,0);
    vector<vector<pp>> path(n); 
    vector<vector<int>> dis(n,vector<int>(n,inf));
    rep(i,r){
        cin>>v[i]; v[i]--;
    }
    sort(al(v));
    rep(i,m){
        int a,b,c; cin>>a>>b>>c;
        a--; b--;
        path[a].push_back(mk(b,c));
        path[b].push_back(mk(a,c));
    }
    rep(i,n){
        priority_queue<pp, vector<pp>, greater<pp>> pq;
        pq.push(mk(0,i)); dis[i][i]=0;
        while(!(pq.empty())){
            tie(cost,s)=pq.top(); pq.pop();
            if(cost!=dis[i][s]) continue;
            for(auto p : path[s]){
                if(dis[i][p.first]>cost+p.second){
                    dis[i][p.first]=cost+p.second;
                    pq.push(mk(dis[i][p.first],p.first));
                }
            }
        }

    }

    do{
        cnt=0;
        rep(i,r-1){
            cnt+=dis[v[i]][v[i+1]];
        }
        ans=min(ans,cnt);
    }while(next_permutation(al(v)));
    cout<<ans<<endl;
}

Measured memory_bytes: 896
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,k;
	int nsum = 0;
	scanf("%d",&n);
	k = n;
	for (int i = 0; i < 12; ++i)
	{
		nsum += k % 10;
		k /= 10;
	}
	if(n % nsum)	puts("No");
	else puts("Yes");
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Ma = sc.nextInt();
		int Mb = sc.nextInt();
		int a[] = new int[N];
		int b[] = new int[N];
		int c[] = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		int[][][] dp = new int[N + 1][500][500];
		for(int i = 0; i < N + 1; i++) {
			for(int j = 0; j < 499; j++) {
				for(int k = 0; k < 499; k++) {
					dp[i][j][k] = Integer.MAX_VALUE / 2;
				}
			}
		}
		dp[0][0][0] = 0;
		
		int ans = Integer.MAX_VALUE / 2;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 400; j++) {
				for(int k = 0; k < 400; k++) {
					//if(j + a[i] < 10 * N + 1 && k + b[i] < 10 * N + 1) {
						dp[i + 1][j + a[i]][k + b[i]] = Math.min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
						dp[i + 1][j][k] = Math.min(dp[i + 1][j][k], dp[i][j][k]);
					//}
				}
			}
		}
		
		for(int j = 1; j <= 400; j++) {
			for(int k = 1; k <= 400; k++) {
				if(k * Ma == j * Mb && dp[N][j][k] != Integer.MAX_VALUE) {
					ans = Math.min(ans, dp[N][j][k]);
				}
			}
		}
		
		if(ans == Integer.MAX_VALUE / 2) {
			System.out.println(-1);
		} else {
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 84052
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int AC=0,WA=0,TLE=0,RE=0,N;
	string S;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>S;
		if(S=="AC")AC++;
		else if(S=="WA")WA++;
		else if(S=="TLE")TLE++;
		else if(S=="RE")RE++;
	}
	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <set>
using namespace std;
int main() {
    int n, k, d, tmp;
    set<int> a;
    cin >> n >> k;
    while(cin >> d) {
        for (int i=0; i < d; i++) {
        cin >> tmp;
        a.insert(tmp);
        }
    }
    cout << n - a.size() << endl;
}   

Measured memory_bytes: 3624
var
	sum:longint;
	s:string[10];
begin
	readln(s);
    sum:=0;
    if s[1]='2' then inc(sum);
    if s[2]='2' then inc(sum);
    if s[3]='2' then inc(sum);
    if s[4]='2' then inc(sum);
    writeln(sum);
end.

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int ans = min(B,D)-max(A,C);
    ans = max(ans,0);
    fin(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		//long k = sc.nextLong();
		//long l = sc.nextLong();
		//String buff="Christmas";
		long count=0;
		long[] array=new long[3];

		/*for(long i=n;i<25;i++) {
			buff+=" Eve";
		}*/
		Arrays.sort(array);
		if(m%n==0) {
			System.out.println(m+n);
		}else {
			System.out.println(m-n);
		}
		//System.out.println(1.0*n/m);
		//System.out.println(Math.abs(array[2]-array[1])+Math.abs(array[1]-array[0]));
	}
}




Measured memory_bytes: 23764
n = int(input())
a = [0]+list(map(int,input().split()))
dp = [[0]*(n+2) for _ in range(n+2)]
for l in range(1,n+2):
  for i in range(1,n-l+2):
    j = l+i
    if (n-l)%2 == 1:
      dp[i][j] = min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1])
    else:
      dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1])
print(dp[1][n+1])

Measured memory_bytes: 113444
public class Main {

  private static void solve() {
    int h = ni();
    int w = ni();
    int a = ni();
    int b = ni();


    StringBuilder sb = new StringBuilder();
    if (a != 0 && b != 0) {
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          sb.append(i < b && j < a || i >= b && j >= a ? 1 : 0);
        }
        sb.append("\n");
      }

    } else if (a == 0) {
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          sb.append(i < b ? 1 : 0);
        }
        sb.append("\n");
      }
    } else {
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          sb.append(j < a ? 1 : 0);
        }
        sb.append("\n");
      }
    }
    System.out.println(sb);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 29524
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb push_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;

using namespace std;

const int N = 500, mod = 1e9 + 7, inf = 1e18 + 7, logn = 23;
const double pi = acos(-1);

int a[N], dp[N][N], n, vis[N][N], pref[N];

inline int cost(int l, int r) {
	return pref[r] - pref[l - 1];
}

void solve() {
	//soln
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		pref[i] += pref[i - 1] + a[i];
	}

	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			dp[i][j] = inf;
		}
	}

	for(int l = n; l >= 1; l--) {
		for(int r = l; r <= n; r++) {
			if(l == r) {
				dp[l][r] = 0;
			} else {
				for(int k = l; k <= r; k++) {
					dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + cost(l, r));
				}
			}
		}
	}
	cout << dp[1][n] << endl;;
}
main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}
	

Measured memory_bytes: 5208
program leaping_tak
  implicit none
  integer(8), parameter :: modu = 998244353
  integer :: n, k, l(10) = 0, r(10) = 0, i, j, p, q
  integer(8) :: dp(200000) = 0, s(0:200000) = 0
  read(*,*) n, k
  do i = 1, k
    read(*,*) l(i), r(i)
  end do
  dp(1) = 1
  s(1) = 1
  do i = 2, n
    do j = 1, k
      p = max(i - l(j), 0)
      q = max(i - r(j) - 1, 0)
      dp(i) = modulo(dp(i) + s(p) - s(q), modu)
    end do
    s(i) = s(i - 1) + dp(i)
  end do
  write(*,'(i0)') dp(n)
end program leaping_tak

Measured memory_bytes: 5996
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    #各コマについて「行って引き返して」とやることは完全に無駄であることから、
    #各コマは一度動いたらその方向にしか動かないものと思うことが出来る
    #さらに進む方向はX軸方向の正の向きとしていい
    #そう考えると各こまは
    #・数直線上の区間(長さが0であってもよい)
    #と同一視してよいことが分かる。
    #つまり、N個の区間によって、M個の座標を完全に被覆する問題
    #ここで、これらの区間の両端点は、M個の座標として指定されているチェックポイント部分
    #のみに限定してよいことが分かる
    #https://drken1215.hatenablog.com/entry/2019/02/03/224100
    #さらに、これは補集合をとると、
    #・N-1箇所の覆われていない「隣り合う2点」
    #に対応していることが分かる。
    #これを最大にすればいいことが分かる
    #よって問題は、「隣り合う2点」の距離を表すM-1個の数値を大きい順にソートして
    #大きい順にN-1個を足す(M-1個に達したら終了)
    n,m = readInts()
    X = readInts()
    #昇順に
    X = sorted(X)
    d = [0] * (m-1)
    for i in range(len(X)-1):
        d[i] = X[i+1] - X[i]
    d = sorted(d,reverse=True)
    #print(d)
    print(sum(d[n-1:]))
if __name__ == '__main__':
  main()


Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
set<int> S;
 
int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        S.insert(a);
    }
    auto it = S.end();
    it--;
    int mid = *it / 2;
    int lo = -1, hi = -1, ans = 0;
    if(S.count(mid)) ans = mid;
    else {
        S.insert(mid);
        auto pos = S.find(mid);
        if(pos != S.begin()) {
            pos--;
            lo = *pos;
            if(lo == *it) lo = -1;
            pos++;
        }
        if(pos != it) {
            pos++;
            hi = *pos;
            if(hi == *it) hi = -1;
        }
        if(lo != -1 && hi == -1) {
            ans = lo;
        }
        else if(lo == -1 && hi != -1) {
            ans = hi;
        }
        else {
            if(mid - lo < hi - mid) {
                ans = lo;
            }
            else ans = hi;
        }
    }
    cout << *it << " " << ans << endl;
}

Measured memory_bytes: 4992
N=int(input())
a=[list(map(int,input().split())) for _ in range(N)]
dp=[[0,0] for _ in range(N+1)]
dp[0][0]=1
f=True
for i in range(1,N+1):
  t=a[i-1][0]-dp[i-1][1]
  x=a[i-1][1]
  y=a[i-1][2]
  if t>=x+y-dp[i-1][0] and t%2==(x+y+dp[i-1][1])%2:
    dp[i][0]=x+y
    dp[i][1]=a[i-1][0]
  else:
    f=False
    break
if f:print("Yes")
else:print("No")

Measured memory_bytes: 37816
#include<iostream>

using namespace std;

unsigned long long int gcd(unsigned long long a,unsigned long long b){
    if(b==0)return a;
    return gcd(b, a%b);
}

int main(){
    unsigned long long n, t, ans=1, lgcd;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> t;
        if(t%ans==0)ans=t;
        else{
            lgcd = gcd(ans, t);
            ans = ans/lgcd*t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int main(){
  int i, N ;
  cin >> N;
  double x[N];
  string u[N];
  
  //
  for(i = 0 ; i < N ; i++){
    cin >> x[i]; 
    cin >> u[i];
  }
  
  // BTCをJPYに
  for(i = 0 ; i < N ; i++){
    if (u[i] == "BTC"){
      x[i] = x[i] * 380000.0;
      u[i] = "JPY";
    }
  }
  
  //sum
  double sum = 0.0;
  for(i = 0 ; i < N ; i++){
    sum += x[i];
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
from math import factorial, ceil, floor # 階乗/切り上げ/切り捨て
from operator import itemgetter as ig
from collections import defaultdict as dd
# 定数
INF = float("inf")
MOD = int(1e9 + 7)

def main():
    N = int(input())
    D = tuple(map(int, input().split()))

    d = tuple(sorted(D))
    print(d[N // 2] - d[N // 2 - 1])

main()


Measured memory_bytes: 14336
#include<cstdio>
#include<cmath>
int N,z,c,i;
int main(){
    for (scanf("%d",&N),c=0;scanf("%d",&z),[](int n){if(n==1)return 0;if(n==2)return 1;for(int i=2;i<=sqrt((double)n);++i)if(n%i==0)return 0;return 1;}(z)?++c:0,--N;);
    printf("%d\n",c);
}

Measured memory_bytes: 1024
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,cnt=0;
  cin >> a >> b >> c >> d;
  while(a>0&&c>0) {
    if(cnt%2==0) {
      c-=b;
    }
    else {
      a-=d;
    }
    cnt++;
  }
  if(a<=0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3652
#include <stdio.h>

int n; long long c[100100], s;

int main()
{
  scanf ("%d",&n);
  for (int i=0,x;i<n;i++){
    scanf ("%d",&x); c[x]++;
    s += x;
  }
  int q; scanf ("%d",&q); while (q--){
int x,y; scanf ("%d %d",&x,&y);
    s -= x * c[x];
    s += y * c[x];
    c[y] += c[x];
    c[x] = 0;
    printf ("%lld\n",s);
  }
	return 0;
}

Measured memory_bytes: 3952
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> SC(M);
    for (int i = 0; i < M; i++)
    {
        cin >> SC[i].first >> SC[i].second;
    }
    for (int i = 0; i < 1000; i++)
    {
        int keta = 1;
        int nx = i / 10;
        vector<int> d(1, i % 10);
        while (nx)
        {
            keta++;
            d.push_back(nx % 10);
            nx /= 10;
        }
        if (keta != N)
            continue;
        bool isOK = true;
        reverse(d.begin(), d.end());
        for (int j = 0; j < M; j++)
        {
            if (d[SC[j].first - 1] != SC[j].second)
                isOK = false;
        }
        if (isOK)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;

#define rep(i,n) for (int i = 0; i < int(n); ++i)

int n,r,p,c,a[50];

int main() {
  while (cin >> n >> r && n != 0 && r != 0) {
    rep (i,n) a[i] = n-i;
    rep (i,r) {
      cin >> p >> c;
      rotate(a, a+p-1, a+p-1+c);
    }
    cout << a[0] << endl;
  }
}

Measured memory_bytes: 1184
n = int(input())
s = input()
R = 0
G = 0
B = 0

for i in range(n):
    if s[i] == "R":
        R+=1
    elif s[i] == "G":
        G+=1
    else:
        B+=1

ans = R*G*B
for i in range(n-2):
    for j in range(1, (n-i-1)//2+1):
        if s[i]!=s[i+j] and s[i]!=s[i+2*j] and s[i+j]!=s[i+2*j]:
            ans -= 1

print(ans)

Measured memory_bytes: 9072
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v;
    unordered_map<int, int> um;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        v.push_back(t);
        um[t]++;
    }
    int q;
    cin >> q;
    long long int res = 0;
    for (int i = 0; i < n; i++) {
        res += v[i];
    }
    for (int i = 0; i < q; i++) {
        int b, c;
        cin >> b >> c;
        res += (c - b) * (long long int)um[b];
        um[c] += um[b];
        um[b] = 0;
        cout << res << endl;
    }

}


Measured memory_bytes: 7336
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int a, b, c;
    while(cin>>a>>b>>c){
        if(a+b==c||a+c==b||b+c==a)
            cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int64_t i = 0;i < n;i++)

template<class T> bool chmin(T& a,T b){
    if(a > b){ a = b; return true; }else return false;
}
template<class T> bool chmax(T& a,T b){
    if(a < b){ a = b; return true; }else return false;
}


class BMultiplication2 {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        int64_t n;cin >> n;
        vector<int64_t> a(n);
        int64_t ans = 1;
        rep(i,n){
            cin >> a[i];
            if(a[i] == 0){
                cout << 0 << '\n';
                return;
            }
        }
        sort(a.rbegin(),a.rend());
        rep(i,n){
            int64_t x = a[i];
            if(x == 0){
                cout << 0 << '\n';
                return;
            }
            if(x !=0  && ans > (int64_t)(1e18) / x){
                cout << -1 << '\n';
                return;
            }else{
                ans *= x;
            }
        }
        cout << ans << '\n';
	}
	void main2(istream& cin,ostream& cout){

	}
};


int main() {
	BMultiplication2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define pb push_back
#define MOD 1000000007
#define sz5 100005
#define sz6 1000005
#define UP upper_bound
#define LB lower_bound
#define F first
#define S second
#define PI pair<int,int>
#define PL pair<ll,ll>
#define VI vector<int>
#define VL vector<ll>

int main() {
    FAST
    string a, b;
    cin>>a>>b;
    int n=a.length(), m=b.length();
    int dp[n+4][m+4], la, lb;
    memset(dp, 0, sizeof(dp));

    for(la=1;la<=n;la++){
        for(lb=1;lb<=m;lb++){
            dp[la][lb]=max(dp[la][lb-1], dp[la-1][lb]);
            if(a[la-1]==b[lb-1])
                dp[la][lb]=max(dp[la][lb], 1+dp[la-1][lb-1]);
        }
    }

    string ans;
    int x=n, y=m;
    while(dp[x][y]!=0){
        if(dp[x][y]==dp[x-1][y])
            x--;
        else
        if(dp[x][y]==dp[x][y-1])
            y--;
        else{
            ans.pb(a[x-1]);
            x--;    y--;
        }
    }

    reverse(ALL(ans));
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 38756
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

string shuffle(string str, int h){
    string head = str.substr(0,h);
    string tail = str.substr(h, str.size()-h);
    return tail + head;
}

int main(){
    string cards;
    int m,h;
    
    while(1){
        cin>> cards;
        if(cards =="-")break;
        
        cin>> m;
        for(int i=0; i<m; i++){
            cin>>h;
            cards=shuffle(cards,h);
        }
        cout << cards << endl;
    
    }
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  int count1 = 0;
  int count2 = 0;
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if(a % 2 == 0) {
      count1++;
      if(a % 3 == 0 || a % 5 == 0) {
        count2++;
      }
    }
  }
  if(count1 == count2){
    cout << "APPROVED" << endl;
    return 0;
  } else {
    cout << "DENIED" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
n, c, k = gets.split.map(&:to_i)
ts = n.times.map { gets.to_i }.sort!

ans = 1
base = ts.last
passengers = 1

(n - 2).downto(0) do |i|
  if ts[i] + k < base || (ts[i] + k <= base + k && passengers == c)
    ans += 1
    passengers = 0
    base = ts[i]
  end

  passengers += 1
end

puts ans


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;

int gcd(int x, int y) {
  while (y != 0) {
    if (x < y)
      swap(x, y);
    int tmp = x;
    x = y;
    y = tmp % y;
  }
  return x;
}
    

int main() {
  int x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
  ll n;cin>>n;
  vector<ll> v(n);
  vector<ll> w(n,0);
  rep(i,n) cin>>v[i];
  for(ll i=n-1;i>=0;i--){
      ll tmp=0;
      rep(j,n/(i+1)){
        if(j==0) tmp+=v[(i+1)*(j+1)-1];
        else tmp+=w[(i+1)*(j+1)-1];
      }
        if(tmp%2==0) w[i]=0;
        if(tmp%2==1) w[i]=1;
  }
  ll ans=0;
  rep(i,n) if(w[i]==1) ans++;
  cout<<ans<<endl;
  rep(i,n) if(w[i]==1) cout<<i+1<<' ';
  cout<<endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  string s;
  cin >> s;
  
  int n = s.size();
  if (s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }

  int cnt = 0;
  FOR(i, 1, n) {
    if (s[i] == 'C' && i != 1 && i != n - 1) {
      cnt++;
    }
    else {
      int t = s[i] - 'A';
      if (t <= 25) {
        cout << "WA" << endl;
        return 0;
      }
    }
  }

  cout << (cnt == 1 ? "AC" : "WA") << endl;

  

  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  vector<vector<int>> ans(h, vector<int>(w, 0));

  rep(i, 0, h) rep(j, 0, w) cin >> s[i][j];
  rep(i, 0, h) {
    rep(j, 0, w) {
      rep(k, 0, 8) {
        int y = i + dy[k];
        int x = j + dx[k];
        if (y < 0 || y >= h || x < 0 || x >= w)
          continue;

        if (s[i][j] == '#') {
          ans[i][j] = -1;
          if (s[y][x] == '.')
            ans[y][x]++;
        }
        
      }
    }
  }

  rep(i, 0, h) {
    rep(j, 0, w) {
      if (ans[i][j] == -1)
        cout << "#";
      else
        cout << ans[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (int)1e9;
ll CaseN=1;
ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


ll nCr(ll n ,ll r)
{
ll p= n;
r = min(r,n-r);
ll a =1;
ll b=1;	
while(r)
{
	a = a*p;
	b = b*r;
	
	ll g = __gcd(a,b);
	
	a = a/g;
	b = b/g;
	
	p--;
	r--;	
}	
return a;
	
}

ll dif(ll a,ll b)
{
ll ans=0ll;	
  while(a>0 || b>0)
  {
	  ll r1 = (a&1);
	  ll r2 = (b&1);
	  if(r1!=r2)
	  {
		ans++;  
	   }
	  a = a>>1;
	  b = b>>1;
  }
	
	
	return ans;
}



ll calc(ll n)
{
if(n==0)
{
return 0;	
}
if(n==1)
{
return 1;	
}	
ll p = n/2;
ll ans = calc(p) + n;

return ans;	
}


void solve()
{
  ll x,n,ans=0;
  cin>>x>>n;
  ll a[n+3];
  ll p[10001];
  for(ll i=0;i<=1000;i++)
  {
	 p[i]=0; 
	 }
  for(ll i=1;i<=n;i++)
  {
	 cin>>a[i];
	 p[a[i]]=1; 
	 }
  ll d = 10000000001;
  for(ll i=0;i<=102;i++)
  {
	  ll df = abs(i-x);
	  if(df<d && p[i]==0)
	  {
		 ans = i;
		 d = df; 
	  }
  }
  if(d==10000000001)
  {
	 ans =-1; 
	 }
  
  //cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
  cout<<ans<<endl;
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{	
	solve();	
	}
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
    public static void main(String[] args){
        ABC159B();
    }
    private static void ABC159B() {
        // no comment, no error check
        final int INPUT_LINES_CNT = 1;

        ArrayList<String> inputLines = getStdInMultiLines(INPUT_LINES_CNT);

        if (inputLines.size() == 0) {
            System.out.println(0);
            return;
        }

        String outputStr;
        try {
            List<String> inputLineList = Arrays.asList((inputLines.get(0)));
            String kaibun = inputLineList.get(0);
            int len = kaibun.length();
            String sSHarfKaibun = inputLineList.get(0).substring(0,len / 2);
            String sRHarfKaibun = new StringBuilder(sSHarfKaibun).reverse().toString();
            String rSHarfKaibun = inputLineList.get(0).substring(len / 2 + len % 2, len);
            String rRHarfKaibun = new StringBuilder(rSHarfKaibun).reverse().toString();

            outputStr = len >= 3 && len <= 99 && sSHarfKaibun.equals(rRHarfKaibun) 
                && sSHarfKaibun.equals(sRHarfKaibun) && rSHarfKaibun.equals(rRHarfKaibun)
                ? "Yes" : "No";
        }
        catch (Exception ex) {
            outputStr = "No";
        }

        System.out.println(outputStr);
        return;
    }

private static int getStdInNum() {
        String line1 = getStdInSingleLine();
        if (isNumber(line1)) {
            return Integer.parseInt(line1);
        }
        return 0;
    }

    private static ArrayList<String> getStdInMultiLines() {
        int cnt = 0; 
        int max = 0;

        Scanner cin = new Scanner(System.in);
        ArrayList<String> list = new ArrayList<String>();
        for (;cin.hasNext();) {
            list.add(cin.nextLine());
            if (cnt++ == 0) {
                max = Integer.parseInt((list.get(0)).split(" ")[0]);
            }
            else if (cnt == max + 1) {
                break;
            }
        }
        cin.close();
        return list;
    }
    private static ArrayList<String> getStdInMultiLines(int inputLinesCnt) {
        int cnt = 0; 

        Scanner cin = new Scanner(System.in);
        ArrayList<String> list = new ArrayList<String>();
        for (;cin.hasNext();) {
            list.add(cin.nextLine());
            if (++cnt == inputLinesCnt) {
                break;
            }
        }
        cin.close();
        return list;
    }

    private static String getStdInSingleLine() {
        Scanner cin = new Scanner(System.in);

        for (;cin.hasNext();) {
            cin.close();
            return cin.nextLine();
        }

        cin.close();
        return "";
    }

    private static boolean isNumber(String val) {
        try {
            Integer.parseInt(val);
            return true;
        }
        catch (NumberFormatException nfex) {
            return false;
        }
    }

}


Measured memory_bytes: 21972
#include<stdio.h>
#include<stdlib.h>

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};

typedef struct node *NodePointer;

NodePointer r,NIL;

NodePointer find(NodePointer x,int k)
{
  while(x != NIL && k != x->key)
    {
      if(k < x->key)
	{
      
	  x = x->l;
	}
      else
	{
	  x = x->r;
	}
    }
  return x;
}

void insert(int k)
{
  NodePointer y = NIL;
  NodePointer x = r;

  NodePointer z = (NodePointer)malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL)
    {
      y = x;
      if(z->key < x->key)
	{
	  x = x->l;
	}
      else
	{
	  x = x->r;
	}
    }
  z->p = y;

  if(y == NIL)
    {
      r = z;
    }else if(z->key < y->key)
    {
      y->l = z;
    }
  else
    {
      y->r = z;
    }
}

void inorder(NodePointer u)
{
  if(u == NIL)
    {
      return;
    }
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(NodePointer u)
{
  if(u == NIL)
    {
      return;
    }
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

void print()
{
  inorder(r);
  puts("");
  preorder(r);
  puts("");
}

int main()
{
  int n,i,j,z,x;
  char s[10];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s",s);
      if(s[0] == 'f')
	{
	  scanf("%d",&x);
	  NodePointer t = find(r,x);
	  if(t == NIL)printf("no\n");
	  else printf("yes\n");

	}
      else if(s[0] == 'i')
	{
      
	  scanf("%d",&z);
	  insert(z);
	}
      else
	{
	  print();
	}
    }

  return 0;
}



Measured memory_bytes: 25168