akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
struct edge { int to, cap, rev, cost; };

typedef vector<vector<edge>> Graph;
constexpr int MAX_V = 2002;

int level[MAX_V];
int iter[MAX_V];

void add_edge(Graph& G,int from, int to, int cap, int cost = 0) {
	G[from].push_back(edge{ to, cap, (int)G[to].size(),cost });
	G[to].push_back(edge{ from,0,(int)G[from].size() - 1,-cost });
}

void bfs(Graph &G,int s) {
	fill_n(level, MAX_V, -1);
	queue<int> q;
	level[s] = 0;
	q.push(s);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				q.push(e.to);
			}
		}
	}
}
ll dfs(Graph &G,int v, int t, int f) {
	if (v == t)return f;
	for (int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			int d = dfs(G,e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
ll max_flow(Graph &G,int s, int t) {
	int flow = 0;
	for (;;) {
		bfs(G,s);
		if (level[t] < 0)return flow;
		fill_n(iter, MAX_V, 0);
		ll f;
		while ((f = dfs(G,s, t, INF)) > 0) {
			flow += f;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, l;
	while (cin >> n >> m >> l, n) {
		Graph g(2*l+2);
		vvi v(n, vi(n, INF));
		REP(i, m) {
			int a, b, c;
			cin >> a >> b >> c;
			v[a][b] = c;
			v[b][a] = c;
		}
		REP(i, n)v[i][i] = 0;
		REP(k, n) {
			REP(i, n) {
				REP(j, n) {
					v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
				}
			}
		}
		vi p(l), t(l);
		REP(i, l) {
			cin >> p[i] >> t[i];
		}
		REP(i, l) {
			REP(j, l) {
				if (i == j)continue;
				if (t[i] + v[p[i]][p[j]] <= t[j])add_edge(g,i + 1, j + l + 1, 1);
			}
		}
		REP(i, l)add_edge(g,0, i + 1, 1);
		REP(i, l)add_edge(g,i + l + 1, 2 * l + 1, 1);
		cout << l - max_flow(g,0, 2 * l + 1) << endl;

	}

}

Measured memory_bytes: 23324
#include <stdio.h>
int main(){
  int a[11],i,sum=0;
  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<10;i++){
    sum=sum+a[i];
  }
  printf("%d\n",sum);
  return 0;
}
  

Measured memory_bytes: 600
class UnionFind():
    def __init__(self, n):
        self.parents = [-1 for _ in range(n)]  # 各要素の親 自分が根の場合は -1 * (木の要素数)

    def root(self, x):  # xが属する木の根を返す
        if self.parents[x] < 0:  # 自分が根の場合
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def merge(self, x, y):  # xが属する木とyが属する木を合体する
        x_root = self.root(x)  # xの根
        y_root = self.root(y)  # yの根

        if x_root == y_root:  # 同じ木に属する
            return

        if abs(self.parents[x_root]) >= abs(self.parents[y_root]):  # 要素数の比較
            self.parents[x_root] += self.parents[y_root]
            self.parents[y_root] = x_root
        else:
            self.parents[y_root] += self.parents[x_root]
            self.parents[x_root] = y_root

    def size(self, x):  # xが属する木の要素数
        return -self.parents[self.root(x)]

    def same(self, x, y):  # xとyが同じ木に属するか判定
        return self.root(x) == self.root(y)

    def roots(self):  # すべての根を求める
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # 木が何個あるか
        return len(self.roots())


def main():
    n, m = map(int, input().split())
    ab_list = [list(map(int, input().split())) for _ in range(m)]
    ans = 0

    for i in range(m):
        uf = UnionFind(n)
        for j in range(m):
            if i == j:
                continue
            uf.merge(ab_list[j][0] - 1, ab_list[j][1] - 1)
        if uf.group_count() != 1:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74160
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int dp[8][1001];
	int i,j,n,m,a[8],b[8],g,suu[11],k,x,maisu;
	while(1) {
		scanf("%d",&m);
		if(m==0) break;
		for(i=0;i<m;i++) scanf("%d %d",&a[i],&b[i]);
		scanf("%d",&g);
		for(i=0;i<g;i++) scanf("%d",&suu[i]);
		for(i=0;i<=m;i++) {
			for(j=0;j<=1000;j++) {
				dp[i][j]=0;
			}
		}
		dp[0][0]=1;
		for(i=0;i<m;i++) {
			maisu=b[i];
			x=a[i];
			for(j=0;j<=1000;j++) {
				for(k=0;k<=maisu;k++) {
					if(j+x*k<=1000) {
						dp[i+1][j+x*k]+=dp[i][j];
					}
				}
			}
		}
//		for(i=0;i<=m;i++) {
//			for(j=0;j<=168;j++) {
//				printf("%8d",dp[i][j]);
//			}
//			printf("\n");
//		}
		for(i=0;i<g;i++) printf("%d\n",dp[m][suu[i]]);
	}
	return 0;
}
		

Measured memory_bytes: 1060
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
struct MaxFlow {
    vector<vector<int>> G, cap;
    MaxFlow(int n) {
        G.resize(n);
        cap.resize(n, vector<int>(n));
    }
    void add_edge(int i, int j, int c) {
        cap[i][j] += c;
        G[i].push_back(j);
        G[j].push_back(i);
    }
    int max_flow(int i, int j) {
        vector<int> visited(G.size());
        int timestamp = 1;
        auto dfs = [&](auto&& dfs, int node, int fl) -> int {
            if (node == j) return fl;
            visited[node] = timestamp;
            for (int next : G[node]) {
                if (visited[next] != timestamp && cap[node][next] > 0) {
                    int f = dfs(dfs, next, min(fl, cap[node][next]));
                    if (f > 0) {
                        cap[node][next] -= f;
                        cap[next][node] += f;
                        return f;
                    }
                }
            }
            return 0;
        };
        int ans = 0;
        for (;;) {
            int f = dfs(dfs, i, INT_MAX);
            if (f == 0) break;
            ans += f, timestamp++;
        }
        return ans;
    }
};
const int DY[] = { 0, 0, -1, +1 };
const int DX[] = { -1, +1, 0, 0 };
const char ARROW[] = "<>^v";
int main() {
    int N, M; cin >> N >> M;
    vector<string> S(N); for (auto &s : S) cin >> s;
    MaxFlow mf(N * M + 2);
    int odd = N * M, even = N * M + 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (S[i][j] != '.') continue;
            if ((i + j) % 2) {
                mf.add_edge(odd, i * M + j, 1);
                for (int k = 0; k < 4; k++) {
                    int ni = i + DY[k];
                    int nj = j + DX[k];
                    if (0 <= ni && ni < N && 0 <= nj && nj < M) {
                        mf.add_edge(i * M + j, ni * M + nj, 1);
                    }
                }
            } else {
                mf.add_edge(i * M + j, even, 1);
            }
        }
    }
    cout << mf.max_flow(odd, even) << '\n';
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if ((i + j) % 2) {
                for (int k = 0; k < 4; k++) {
                    int ni = i + DY[k];
                    int nj = j + DX[k];
                    if (0 <= ni && ni < N && 0 <= nj && nj < M) {
                        int o = i * M + j;
                        int e = ni * M + nj;
                        if (mf.cap[e][o] == 1) {
                            S[i][j] = ARROW[k];
                            S[ni][nj] = ARROW[k ^ 1];
                        }
                    }
                }
            }
        }
    }
    for (auto &s : S) cout << s << '\n';
    return 0;
}


Measured memory_bytes: 396012
/**
 * Boris Sokolov
 * Software Engineer at Ring Labs
 * Kiev, Ukraine | Los Angeles, CA
 */
 
#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = static_cast<int>(2e9);
const int MOD = static_cast<int>(1e9) + 7;


int main() {
    //freopen("in.txt", "rt", stdin);
    //freopen("out.txt", "wt", stdout);
    ll q, h, s, d, n;
    scanf("%lld %lld %lld %lld %lld", &q, &h, &s, &d, &n);
    h = min(h, 2 * q);
    s = min(s, h * 2);
    d = min(d, s * 2);
    if (n % 2 == 0) {
        printf("%lld\n", n / 2 * d);
    } else {
        printf("%lld\n", n / 2 * d + s);
    }
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		int a[] = { 0, 0, 0 };
		Scanner scan = new Scanner(System.in);
		a[0] = scan.nextInt();
		a[1] = scan.nextInt();
		a[2] = scan.nextInt();

		Arrays.sort(a);
		System.out.printf("%d %d %d\n", a[0], a[1], a[2]);
	}

}



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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	ll n;
	cin >> n;
	ll ans = 0;
	ll t = n / 11;
	ans += t * 2;
	n -= t * 11;
	if(n == 10){
		ans += 2;
	}
	if(n == 9){
		ans += 2;
	}
	if(n == 8){
		ans += 2;
	}
	if(n == 7){
		ans += 2;
	}
	if(n < 7 && n > 0){
		ans += 1;
	}
	die(ans);
	


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	map<string ,long long int> m;
	while(n--){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		m[s]++;
	}
	long long ans=0;
	for(auto i:m){
		ans+=(i.second)*(i.second-1)/2;
	}
	cout<<ans;
}

Measured memory_bytes: 11136
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()

    if (n % 2 == 0) {
        println(0.5)
    } else {
        println(((n / 2) + 1).toFloat() / n.toFloat())
    }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

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

int main(){
	string S;
  	
  	cin >> S;
  	int flag=0;
  	string ans ="None";
  	for(char j='a'; j <= 'z'; j++){	
      	//cout <<j<<endl;
  		for(int i = 0; i < S.length();i++){
    		if(S[i] == j){
              	//cout << S[i] <<":" << j <<endl;
              	flag = 1; 
            }
        

        }
        if(flag != 1){
          	//cout <<"break"<<endl;
        	ans = j;
        	break;
        }
      	flag = 0;
          	
    
    }
  	cout << ans << endl;
  	
  	



}

Measured memory_bytes: 512
import sys

d={}
mode=0

while True:
  n = sys.stdin.readline()
  if not n: break
  n = int(n)
  if d.has_key(n):
    d[n] = d[n]+1
  else:
    d[n] = 1
  if mode < d[n]:
    mode = d[n]

for k in d.keys():
  if d[k] == mode:
    print(k) 

Measured memory_bytes: 6348
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if 0==x%y:
        return y
    else:
        while not 0==x%y:
            z = x%y
            x = y
            y = z
        return z

def lcm(x, y):
    return (x*y)//gcd(x,y)

A, B = [int(i) for i in input().split(" ")]

print(lcm(A, B))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
//#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


int main()
{
	int n;
	scanf("%d", &n);
	long long sum = 0;
	for (int i = 1 ; i <= n ; i++) {
		if (i % 3 == 0)
			continue;
		if (i % 5 == 0)
			continue;
			
		sum = sum + i;
	}
	
	printf("%lld\n", sum);
	
	
	return 0;
}

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

int main(int argc, char const *argv[])
{
    string sequence;
    cin >> sequence;

    bool flag_right = true, flag_left = true;
    for (int i = 0; i < sequence.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (sequence.at(i) == 'L')
            {
                flag_right = false;
                break;
            }
        }
        else
        {
            if (sequence.at(i) == 'R')
            {
                flag_left = false;
                break;
            }
        }
    }

    if (flag_right == true && flag_left == true)
        cout << "Yes" << endl;
    else if (flag_right == false || flag_left == false)
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define MOD 1000000007
#define REP(i,n) for(i=1;i<=n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vl vector<LL>
#define itr ::iterator it
#define lb lower_bound
#define ub upper_bound
#define LL long long
#define ULL unsigned long long
LL n,i,j,ans = 0,sz = 1e6+2;
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    // Don't Panic
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL n,m ; 
    cin>>n>>m ; 
    if(max(n,m)<=8)  cout<<"Yay!" ; 
    else cout<<":(" ; 

}
// Check for 1,0, and other corner cases.


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

vector<int>v[100001];
int dp[100001];

int fun(int src){
       
       if(dp[src] != -1)
          return dp[src];

          bool leaf = true;
          int bestchild = -1;
        for(int nbr : v[src]){
            leaf = false;
            bestchild =  max(bestchild,fun(nbr));
        }
       return dp[src] = leaf? 0 : 1+bestchild;
}

void solve(){
  int n,m;
  cin >> n >> m;
  for(int i=0; i<m; i++){
      int x , y;
      cin >> x >> y;
      v[x].push_back(y);
  } 
   memset(dp,-1,sizeof(dp));
       int ans = 0;
   for(int i=1; i<=n; i++)
       { ans = max(ans,fun(i));}
    cout << ans;

}
int main(){
//  #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif 

solve();
return 0;
}

Measured memory_bytes: 8192
N = int(input())
S = list()
for i in range(N):
    S.append(input())

c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in S:
  if i == "AC":
    c0 += 1
    
  if i == "WA":
    c1 += 1

  if i == "TLE":
    c2 += 1
    
  if i == "RE":
    c3 += 1
  
  
print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))


Measured memory_bytes: 16336
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
       int N, K;
       cin >> N >> K;
       map<int, int> mp;
       while (N--) {
          int a;
          cin >> a;
          mp[a]++;
       }
       vector<int> v;
       for (auto x : mp) {
          v.push_back(x.second);
       }
       sort(v.begin(), v.end());
     
       int cnt = max(0, (int)mp.size()-K);
       cout << accumulate(v.begin(), v.begin()+cnt, 0) << endl;
     
       return 0;
    }

Measured memory_bytes: 10748
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()


int main() {
	ll a, b;
	cin >> a >> b;
	cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << endl;
	
}

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

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

using namespace std;

const int64_t INF = INT64_C(100000000000000);

int main() {
  int n;
  cin>>n;
  vector<int64_t> a(n);
  REP(i,n)cin>>a[i];
  vector<map<int64_t, pair<int,int>>> dp(n+1);
  dp[0][-INF] = make_pair(0,0);
  REP(i,n){
    int64_t sum = 0;
    for (int j=i;j>=0;--j) {
      sum += a[j];
      auto itr = dp[j].lower_bound(sum);
      if (itr != begin(dp[j])) {
        --itr;
        int l = itr->second.first + 1;
        auto itr2 = dp[i+1].upper_bound(sum);
        while(itr2 != end(dp[i+1]) && itr2->second.first <= l) itr2 = dp[i+1].erase(itr2);
        if (itr2 != begin(dp[i+1])) {
          --itr2;
          if (itr2 == end(dp[i+1]) || l > itr2->second.first)
            dp[i+1][sum] = make_pair(l,j);
        } else {
          dp[i+1][sum] = make_pair(l,j);
        }
      }
    }
  }
  cout << dp.back().rbegin()->second.first << endl;
  vector<int> pos;
  int j = n;
  while(j){
    j = dp[j].rbegin()->second.second;
    pos.push_back(j);
  }
  reverse(begin(pos),end(pos));
  REP(i,pos.size()-1){
    if(i)cout<<' ';
    cout<<(pos[i]+1);
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 9208
#include<stdio.h>
long N, M, result;

int main() {
  scanf("%ld %ld", &N, &M);
  if (N == 1 && M == 1) {
    result = 1;
  } else if (N == 1) {
    result = M - 2;
  } else if (M == 1) {
    result = N - 2;
  } else {
    result = N * M + 4 - 2 * (N + M);
  }
  printf("%ld", result);
  return 0;
}

Measured memory_bytes: 128
def can_be_yymm(s):
    mm = int(s[2:])
    return 1 <= mm <= 12


def can_be_mmyy(s):
    mm = int(s[0:2])
    return 1 <= mm <= 12


def judge(s):
    yymm = can_be_yymm(s)
    mmyy = can_be_mmyy(s)
    if yymm and mmyy:
        return "AMBIGUOUS"
    elif yymm:
        return "YYMM"
    elif mmyy:
        return "MMYY"
    else:
        return "NA"


def main():
    s = input()
    print(judge(s))


if __name__ == "__main__":
    main()

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

#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug4(a,b,c,d) cout<<a<<" "<< b <<" "<<c<<" "<<d<<"\n";

ll mod = 1000000007;

using namespace std;

ll pow(ll a,ll b)
{
    ll ans =1;
    for (int i = 0; i < b; ++i)
    {
        ans *= a;
    }
    return ans;
}


std::map<ll, ll> mp;

void primeFactors(ll n) 
{ 

    while (n%2 == 0) 
    { 
        mp[2]++; 
        n = n/2; 
    } 

    for (ll i = 3; i <= sqrt(n); i = i+2) 
    { 
        while (n%i == 0) 
        { 
            mp[i]++;
            n = n/i; 
        } 
    } 
  
    if (n > 2) 
        mp[n]++; 
} 
  

int main() 
{ 
    
     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    ll n,k;
    cin>>n>>k; 
    primeFactors(k); 
    ll ans = 1;
    for (auto i = mp.begin(); i != mp.end(); ++i)
    {
       // cout<<i->first<<" "<<i->second<<"\n"; 
        if(i->second/n >= 1)
            ans = ans*pow(i->first,(i->second/n));
    }

    cout<<ans<<"\n";
    return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)

int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if((a+b)>=10){
    printf("error\n");
  }else{
    printf("%d\n",a+b);
  }
  return 0;
}


Measured memory_bytes: 1676
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    string s;
    cin>>s;
    if(s=="ABC")putout("ARC");
    else putout("ABC");
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int m,c,n;
  while(cin>>m>>c>>n,m||c||n){
    int k[n];
    int b[111][55];
    for(int i=0;i<n;i++){
      cin>>k[i];
      for(int j=0;j<k[i];j++) cin>>b[i][j];
    }
    list<int> l[m];
    queue<P> q;
    for(int i=0;i<n;i++) q.push(P(i,0));
    int ans=0;
    while(!q.empty()){
      P p=q.front();q.pop();
      int w=p.first,x=p.second;
      int pos=m;
      for(int i=0;i<m;i++){
	auto latte=find(l[i].begin(),l[i].end(),b[w][x]);
	if(latte!=l[i].end()){
	  pos=i;
	  l[i].erase(latte);
	  break;
	}
      }
      ans+=pos+1;
      if((int)l[0].size()<c){
	l[0].push_front(b[w][x]);
	ans+=1;
      }else{
	int tmp=m;
	for(int i=1;i<m;i++){
	  if((int)l[i].size()<c){
	    tmp=i;
	    l[tmp].push_back(b[w][x]);
	    break;
	  }
	}
	ans+=tmp+1;
	//cout<<ans<<endl;
	int le=l[0].back();
	l[0].pop_back();
	ans+=1;
	int pos=m;
	for(int i=1;i<m;i++){
	  if((int)l[i].size()<c){
	    pos=i;
	    l[pos].push_front(le);
	    break;
	  }
	}
	ans+=pos+1;
	//cout<<ans<<endl;
	if(tmp<m) l[tmp].pop_back();
	ans+=tmp+1;
	//cout<<ans<<endl;
	l[0].push_front(b[w][x]);
	ans+=1;
	//cout<<ans<<endl;
      }
      if(x+1<k[w]) q.push(P(w,x+1));
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>

int main(){   
	int a,b,sum=0,num=0,kaz=0;
	while(~scanf("%d,%d",&a,&b)){
		sum+=a*b;
		num+=b;
		kaz++;
	}
	printf("%d\n%d\n",sum,(int)(num/(double)kaz+0.5));
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
    int n,k;
    scanf("%d%d",&n,&k);
    int d[k],a[k][n],pe[n],ans=0;
    for(int i=0;k>i;++i){
        scanf("%d",&d[i]);
        for(int j=0;d[i]>j;++j){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=0;n>i;++i)
    pe[i]=0;
    for(int i=0;k>i;++i){
        for(int j=0;d[i]>j;++j){
            ++pe[a[i][j]-1];
        }
    }
    for(int i=0;n>i;++i){
        if(pe[i]==0)
        ++ans;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1752
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;
using namespace std;

int main(){
    int X, Y;
    cin >> X >> Y;
    int z = Y - 2 * X;
    int t = 4 * X - Y;
    if((z % 2 == 0 && z >= 0) && (t % 2 == 0 && t >= 0)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N+1), B(N);
    rep(i, 0, N+1) cin >> A[i];
    rep(i, 0, N) cin >> B[i];
    ll ans = 0;
    rep(i, 0, N){
        ans += min(A[i], B[i]);
        B[i] -= min(A[i], B[i]);
        A[i] -= min(A[i], B[i]);
        ans += min(B[i], A[i+1]);
        A[i+1] -= min(B[i], A[i+1]);
        B[i] -= min(B[i], A[i+1]);
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

ll op(ll x, ll y){
    return max(x, y);
}

ll e(){
    return -INF;
}

int main(){

    ll N, K;
    cin >> N >> K;
    V<ll> A(N);
    REP(i, N) cin >> A[i];
    ll MA = 303030;
    V<ll> B(MA, -INF);

    segtree<ll, op, e> seg(B);

    REP(i, N){
        ll lb = max(A[i]-K, 0ll);
        ll ub = min(A[i]+K+1, MA);
        ll val = seg.prod(lb, ub);
        seg.set(A[i], (val==-INF ? 1 : val+1));
    }

    cout << seg.all_prod() << "\n";


    return 0;
}

Measured memory_bytes: 16148
alp = 'abcdefghijklmnopqrstuvwxyz'

def f(s):
  new_s = ''
  i = 0
  is_used = [-1]*26
  for si in s:
    idx = ord(si) - 97
    if is_used[idx] < 0:
      is_used[idx] = i
      new_s += alp[i]
      i += 1
    else:
      new_s += alp[is_used[idx]]
  return new_s


S = f(input())
T = f(input())
if S == T:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 4016
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,k;

int main(){
	while(cin>>n>>k&&n){
		n--;
		int cur=1,d=1,p=10;
		while(1){
			if(n-d<0)break;
			n-=d;
			cur++;
			if(cur==p)d++,p*=10;
		}
		string a;
		while(a.sz<k){
			sst ss;
			ss<<cur++;
			a+=ss.str().substr(n);
			n=0;
		}
		cout<<a.substr(0,k)<<endl;
	}
}

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

int main ( void )
{
	int n; // ツ青板療アツづ個陳キツつウ
	while ( cin >> n && n != 0 )
	{
		vector <int> S(n);
		for ( int i = 0; i < n; i++ )
			cin >> S[i];

		vector <int> V(n);
		vector <int> V_next(n);
		V = S;

		int cnt = 0;
		while ( 1 )
		{
			for ( int i = 0; i < n; i++ )
			{
				V_next[i] = count( V.begin(), V.end(), V[i] );
			}
			cnt++;

			if ( V == V_next )
			{
				cnt--;
				break;
			}

			V = V_next;

		}

		cout << cnt << endl;
		for ( int i = 0; i < n; i++ )
		{
			cout << V[i];
			if ( i < n-1 )
				cout << " ";
		}
		cout << endl;

	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main() {
    int l, r;
    int width;
    int min = 2019;

    scanf("%d %d", &l, &r);
    width = r - l;
    r %= 2019;
    l %= 2019;
    if (l +width >= 2019) printf("0");
    else {
        for (int i = l; i < r; i++) {
            for (int j = i+1; j <= r; j++) {
                if (min > i* j % 2019)min = i * j % 2019;
            }
        }
        printf("%d", min);
    }   
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>

using namespace std;
int main()
{
    int a;
    cin>>a;
    switch(a % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout<<"hon";break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout<<"pon";
        break;
    case 3:
        cout<<"bon";
    }

    return 0;
}


Measured memory_bytes: 3640
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int a, b;
    
    cin>>a>>b;
    
    cout<<(a * b)<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
using namespace std;
int main() {
  unsigned long long a;
  string s;
  cin>>a>>s; s.erase(1,1);
  unsigned long long bb=stoi(s);
  unsigned long long c=a*bb;
  cout<<(unsigned long long)(c/100)<<endl;
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    ll A[N+1], B[N];
    for(int i = 0; i < N+1; ++i) cin >> A[i];
    for(int i = 0; i < N; ++i) cin >> B[i];

    ll cnt = 0;

    for(int i = 0; i < N; ++i) {
        ll sub = min(A[i], B[i]);
        cnt += sub;
        ll sub1 = min(A[i+1], B[i] - sub);
        A[i+1] -= sub1;
        cnt += sub1;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)


int main(){
	int l, r, d;
	cin >> l >> r >> d;
	int p = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0)p++;
	}
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 3628
a,b,k=gets.split.map &:to_i
resa=a
resb=b
if a <= k
  resb=b+(a-k)
  resa=0
  resb=0 if resb < 0
elsif a+1 > k
  resa=a-k
end
puts [resa,resb].join(' ')


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

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }


void solve(long long N, std::vector<std::string> s, std::vector<long long> t, std::string X){
    ll a=0,sum=0;;
    rep(i,N){
        if(X==s[i])a=i;
    }
    rep(i,N){
        if(i>a)sum+=t[i];
    }
    cout<<sum<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
      cout << fixed << setprecision(6);
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
        scanf("%lld",&t[i]);
    }
    std::string X;
    std::cin >> X;
    solve(N, std::move(s), std::move(t), X);
    return 0;
}


Measured memory_bytes: 256
# a+b-2
# N = a*b  よってNの約数を求める
import numpy as np

N = int(input())
U = 10**6+100
x = np.arange(1, U, dtype=np.int64)
div = x[N%x==0]
ans = (div + N//div).min() - 2
print(ans)

Measured memory_bytes: 29000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll k;
	string s;
	cin >> k >> s;
	if (s.size() <= k) cout << s << endl;
	else cout << s.substr(0, k) << "..." << endl;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=2019;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int dep[MAX];
int vis[MAX];
int par[MAX];
void dfs(int u){
	queue<pair<int, int> > q;
	q.push(mp(u,0));
	while(!q.empty()){
		pair<int,int> from=q.front();
		q.pop();
		if(vis[from.first])
			continue;
		vis[from.first]=1;
		
		for(auto v:adj[from.first]){
			if(dep[v]>=dep[from.first]+1)
			{
				par[v]=from.first;
				dep[v]=dep[from.first]+1;
			}
			if(!vis[v])
				q.push(mp(v, dep[v]));
		}
	}
}
int main() 
{
	int n , m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x, y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
		dep[i]=INT_MAX;
	dep[1]=0;
	int cp=0;
	dfs(1);
	bool flag=true;
	for(int i=1;i<=n;i++){
		if(!vis[i])
			flag=false;
	}
	if(!flag)
		cout<<"No";
	else{
		cout<<"Yes"<<"\n";
		for(int i=2;i<=n;i++)
			cout<<par[i]<<"\n";
	}

}

Measured memory_bytes: 32884
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    int n; cin>>n; 
    vi a(n+1),res(n+1,0); 
    for (int i=1;i<=n;i++) cin>>a[i]; 
    for(int i=n;i>0;i--){
        int sum=0;
        for (int j=i+i;j<=n;j+=i){
            sum += res[j];
        }
        if (sum%2 != a[i]) res[i]=1;
    }
    int c=0;
    for (int i=1;i<=n;i++) c+=res[i];
    cout << c << endl;
    for (int i=1;i<=n;i++) if(res[i]) cout<< i <<endl;
    cout << endl;
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 6388
# B
import numpy as np
H, W = map(int, input().split())

input_mat = np.zeros((H, W), dtype='int')
res_wide = np.zeros((H+2, W+2), dtype='int')

for i in range(H):
    line = list(input())
    for j in range(W):
        if line[j] == '#':
            res_wide[i  , j] += 1
            res_wide[i+1, j] += 1
            res_wide[i+2, j] += 1
            res_wide[i  , j+1] += 1
            input_mat[i, j] = 1
            res_wide[i+2, j+1] += 1
            res_wide[i  , j+2] += 1
            res_wide[i+1, j+2] += 1
            res_wide[i+2, j+2] += 1

for i in range(H):
    res_line = []
    for j in range(W):
        if input_mat[i, j] == 1:
            res_line.append('#')
        else:
            res_line.append(str(res_wide[i+1, j+1]))
    print("".join(res_line))


Measured memory_bytes: 13764
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const vector<bitset<7> > digit =
{
    bitset<7>("1110111"),
    bitset<7>("0100100"),
    bitset<7>("1011101"),
    bitset<7>("1101101"),
    bitset<7>("0101110"),
    bitset<7>("1101011"),
    bitset<7>("1111011"),
    bitset<7>("0100101"),
    bitset<7>("1111111"),
    bitset<7>("1101111")
};

int getLightNum(int x, int n, vector<bitset<7> >::const_iterator trouble)
{
    int ans = 0;
    for(int i=0; i<n; ++i){

        ans += (digit[x%10] & ~trouble[n-1-i]).count();
        x /= 10;
    }
    return ans;
}

int main()
{

    int n, k;
    cin >> n >> k;
    vector<bitset<7> > trouble(14, 0);
    for(int i=0; i<k; ++i){
        int p, q;
        cin >> p >> q;
        trouble[p][q] = true;
    }

    vector<int> cnt(99);
    for(int h=0; h<24; ++h){
        for(int m=0; m<60; ++m){
            for(int s=0; s<60; ++s){
                int i = getLightNum(h, 2, trouble.begin() + 8 ) +
                        getLightNum(m, 2, trouble.begin() + 10) +
                        getLightNum(s, 2, trouble.begin() + 12);
                ++ cnt[i];
            }
        }
    }

    long long ans = 0;
    for(int y=0; y<10000; ++y){
        vector<int> days = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        if(y % 400 == 0 || (y % 100 != 0 && y % 4 == 0))
            ++ days[2];
        for(int m=1; m<=12; ++m){
            for(int d=1; d<=days[m]; ++d){
                int i = getLightNum(y, 4, trouble.begin()    ) + 
                        getLightNum(m, 2, trouble.begin() + 4) +
                        getLightNum(d, 2, trouble.begin() + 6);
                if(i <= n)
                    ans += cnt[n-i];
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1200
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MAXM=100000;

int n,m;
int ghead[MAXN],gnxt[2*MAXM],gto[2*MAXM];

bool been[MAXN];
int after[MAXN],nafter;
int before[MAXN],nbefore;
int ret[MAXN],nret;

void run() {
	scanf("%d%d",&n,&m);
	REP(i,n) ghead[i]=-1;
	REP(i,m) {
		int a,b; scanf("%d%d",&a,&b); --a,--b;
		gnxt[2*i+0]=ghead[a],ghead[a]=2*i+0,gto[2*i+0]=b;
		gnxt[2*i+1]=ghead[b],ghead[b]=2*i+1,gto[2*i+1]=a;
	}
	REP(i,n) been[i]=false;
	{
		int at=0; been[at]=true; nafter=0;
		while(true) {
			int to=-1; for(int x=ghead[at];x!=-1;x=gnxt[x]) if(!been[gto[x]]) { to=gto[x]; break; } if(to==-1) break;
			after[nafter++]=to; at=to; been[to]=true;
		}
	}
	{
		int at=0; nbefore=0;
		while(true) {
			int to=-1; for(int x=ghead[at];x!=-1;x=gnxt[x]) if(!been[gto[x]]) { to=gto[x]; break; } if(to==-1) break;
			before[nbefore++]=to; at=to; been[to]=true;
		}
	}
	nret=0;
	for(int i=nbefore-1;i>=0;--i) ret[nret++]=before[i];
	ret[nret++]=0;
	REP(i,nafter) ret[nret++]=after[i];
	printf("%d\n",nret);
	REP(i,nret) { if(i!=0) printf(" "); printf("%d",ret[i]+1); } puts("");
}

int main() {
	run();
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r; cin>>r;
    cout<<setp(12);
    cout<<r*r*M_PI<<" "<<r*2*M_PI<<endl;
    return 0;
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int h, w;
vector<int> G[1010];

int idx(int x, int y){
    return x*w + y;
}

void add_edge(int a, int b){
    G[a].push_back(b);
    G[b].push_back(a);
}

int bfs(){
    vector<int> d(h*w, MAX);
    queue<pii> que;
    que.emplace(0, 1);
    d[0] = 1;
    while(!que.empty()){
        int v, td;
        tie(v, td) = que.front();
        que.pop();
        if(td > d[v]) continue;
        for(int nv: G[v]){
            if(chmin(d[nv], td+1)) que.emplace(nv, d[nv]);
        }
    }
    return d[idx(h-1, w-1)] < MAX ? d[idx(h-1, w-1)] : 0;
}

int main(){
    while(scanf("%d%d", &w, &h) && h){
        rep(i, 1010) G[i].clear();
        rep(i, 2*h-1){
            int b;
            if(i%2 == 0){
                rep(j, w-1){
                    scanf("%d", &b);
                    if(!b) add_edge(idx(i/2, j), idx(i/2, j+1));
                }
            }
            else{
                rep(j, w){
                    scanf("%d", &b);
                    if(!b) add_edge(idx(i/2, j), idx(i/2+1, j));
                }
            }
        }
        printf("%d\n", bfs());
    }
}


Measured memory_bytes: 3300