akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<ll>a(n);for(int i=0;i<n;i++)cin>>a[i];
    ll ans=INF;
    for(int i=0;i<n;i++){
        int m=0;
        while(a[i]%2==0){
            a[i]/=2;
            m++;
        }
        chmin(ans,m);
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

using namespace std;

int main() {
  string s;
  cin >> s;
  bool ok[4] = {};
  for (int i = 0; i < s.size(); ++i) {
    ok[0] |= s[i] == 'E';
    ok[1] |= s[i] == 'W';
    ok[2] |= s[i] == 'N';
    ok[3] |= s[i] == 'S';
  }
  string ret[2] = {"Yes", "No"};
  cout << ret[(ok[0] xor ok[1]) or (ok[2] xor ok[3])];
  return 0;
}


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

typedef pair<int, pair<int, pair<int, int> > > pp;

const int U_MAX = 1000;
int us[U_MAX];

int main() {
    int n;
    while (cin >> n, n) {
        map<pp, int> ts;
        for (int i = 0; i < n; i++) {
            int id, u, a, p;
            cin >> id >> u >> a >> p;
            ts[make_pair(-a, make_pair(p, make_pair(id, u)))] = id;
        }
        int e = 0;
        fill_n(us, U_MAX, 0);
        for (map<pp, int>::iterator it = ts.begin(); it != ts.end(); it++) {
            int j = it->first.second.second.second - 1;
            if ((e < 10 && us[j] < 3) || (e < 20 && us[j] < 2) || (e < 26 && !us[j])) {
                cout << it->second << endl;
                us[j]++;
                e++;
            }
        }
    }
}

Measured memory_bytes: 1212
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	ans := 1
	for i := 0; i < n; i++ {
		ans *= k - b2i(i != 0)
	}
	fmt.Println(ans)
}

func b2i(ok bool) int {
	if ok {
		return 1
	}
	return 0
}


Measured memory_bytes: 512
#include<iostream>
int main(){
  int A=0,B=0;
  std::cin >> A >> B;
  if (A<1||B<1) return 0;
  else if (3<A||3<B) return 0;
  else ((A*B)%2 != 0) ? std::cout << "Yes" : std::cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n; cin>>n;
    string s; cin>>s;
    s.insert(0,"0");
    vector<string> c={"SS","WW","SW","WS"};
    for(auto x:c){
        string a(n+1,0);
        a[0]=x[0],a[1]=x[1];
        for(int i=1;i<=n;i++){
                long nx=(i+1)%(n+1);
                if(i==n){
                        if(a[i]!=a[nx]){
                                a[0]='0';
                                break;
                        }
                }
                if(a[i]=='S'){
                        if(s[i]=='o')
                                a[nx]=a[i-1];
                        else{
                                if(a[i-1]=='S')
                                        a[nx]='W';
                                else
                                        a[nx]='S';
                        }
                }
                else{
                        if(s[i]=='x')
                                a[nx]=a[i-1];
                        else{
                                if(a[i-1]=='S')
                                        a[nx]='W';
                                else
                                        a[nx]='S';
                        }
                }
        }
        if(a[0]==a[1]){
                        for(int j=1;j<=n;j++)
                                cout<<a[j];
                        return 0;
        }
    }
    cout<<-1;
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		C_LexicographicConstraints solver = new C_LexicographicConstraints();
		solver.solve(1, in, out);
		out.close();
	}

	static class C_LexicographicConstraints {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}

			int[] incs = new int[n];
			int numIncs = 0;
			for (int i = 0; i + 1 < n; i++) {
				if (a[i] >= a[i + 1]) {
					incs[numIncs++] = a[i + 1];
				}
			}
			incs[numIncs++] = 0;
			incs = Arrays.copyOf(incs, numIncs);

			int l = 0;
			int r = n;
			int[] stack = new int[n];
			int[] carry = new int[n];
			int p;
			while (r - l > 1) {
				int m = (l + r) / 2;
				p = 0;
				for (int x : incs) {
					if (p == 0 || stack[p - 1] <= x) {
						carry[p] = 1;
						stack[p++] = x;
						continue;
					}
					int c = carry[p - 1];
					while (p >= 2 && stack[p - 2] > x) {
						int between = stack[p - 1] - stack[p - 2];
						while (between > 0 && c > 0 && m > 1) {
							c /= m;
							--between;
						}
						c += carry[p - 2];
						carry[p - 1] = 0;
						--p;
					}

					int between = stack[p - 1] - x;
					while (between > 0 && c > 0 && m > 1) {
						c /= m;
						--between;
					}
					c += 1;
					carry[p - 1] = 0;
					--p;

					carry[p] = c;
					stack[p++] = x;
				}
				if (carry[0] == 1) {
					r = m;
				} else {
					l = m;
				}
			}
			out.println(r);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 50204
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;



typedef pair < long long, long long > pll;
typedef unsigned long long ull;
typedef pair < int, int > pii;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 511;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 466;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int a, b, x, y;

main () {
	cin >> x >> y;
	if (y % 2 == 1 || y < 2*x) {
		cout << "No";
	} else {
		b = (y - 2*x) / 2;
		if (b > x)
			cout << "No";
		else
			cout << "Yes";
	}
}



Measured memory_bytes: 3620
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    int c = 0;
    for (int i = 0; i < 2; i++)
    {
        if (A > B) {
            c += A;
            A--;
        } else {
            c += B;
            B--;
        }
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n t ->
    let ct = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun c t -> c, t )) in

    let rec loop i c =
        if i = n then (if c = max_int then "TLE" else string_of_int c) else
            let c = if snd ct.(i) <= t then min c (fst ct.(i)) else c in
            loop (i + 1) c
    in
    loop 0 max_int |> print_endline
)

Measured memory_bytes: 3856
#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;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    while(cin>>n>>x, n!=0){
        vector<vll> dp(x+1,vll(4));
        dp[0][0] = 1;
        rep(i,n)RFOR(j,x,i+1)FOR(k,1,3){
            dp[j][k]+=dp[j-(i+1)][k-1];
        }
        cout<<dp[x][3]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3140
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let a = v[1];
	let b = v[2];
	let mut ret = 0;
	for i in 1..(n+1) {
		let s = i.to_string();
		let mut sum:i32 = 0;
		let v:Vec<char> = s.chars().collect();
		for i in 0..v.len() {
			sum += ((v[i] as u8) - ('0' as u8)) as i32;
		}
		if sum <= b && sum >= a {
			ret += i;
		}
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
using namespace std;
typedef long long int ll; typedef pair <int, int> P;
const double INF = 1000000000; const double EPS = 10e-9;
int x1[100], y[100], x2[100], z[100];
double width(int *X, int *Y, int n, double x) {
	double lb = -INF, ub = INF;
	for (int i = 0; i < n; i++)
	{
		double x1 = X[i], x2 = X[(i + 1) % n], y1 = Y[i], y2 = Y[(i + 1) % n];
		if ((x1 - x) * (x2 - x) > 0 || x1 == x2) continue;
		double y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
		lb = max(lb, y);
		ub = min(ub, y);
	}
	return lb - ub;
}
int main()
{
	while (true)
	{
		vector <int> x;
		int m, n; cin >> m >> n;
		if (m == 0 && n == 0) break;
		for (int i = 0; i < m; i++) {
			cin >> x1[i] >> y[i];
			x.push_back(x1[i]);
		}
		for (int i = 0; i < n; i++) {
			cin >> x2[i] >> z[i];
			x.push_back(x2[i]);
		}
		int minx1 = *min_element(x1, x1 + m), maxx1 = *max_element(x1, x1 + m);
		int minx2 = *min_element(x2, x2 + n), maxx2 = *max_element(x2, x2 + n);
		sort(x.begin(), x.end());
		double res = 0.0;
		for (int i = 0; i + 1 < m + n; i++)
		{
			double a = x[i], b = x[i + 1], c = (a + b) / 2;
			if (minx1 < c && c < maxx1 && minx2 < c && c < maxx2)
			{
				double sa = width(x1, y, m, a) * width(x2, z, n, a);
				double sb = width(x1, y, m, b) * width(x2, z, n, b);
				double sc = width(x1, y, m, c) * width(x2, z, n, c);
				res += (b - a) / 6 * (sa + sb + 4 * sc);
			}
		}
		printf("%.10f\n", res);
	}
	return 0;
}

Measured memory_bytes: 3184
import sys
import collections

thre = 1000000
while 1:
    n = int(raw_input())
    if(n==0):break;
    dic1 = collections.OrderedDict()
    exceed = False
    for i in range(n):
        (a,b,c) = map(int , raw_input().split())
        pre = 0
        if(a in dic1): pre =dic1[a]
        dic1[a] = pre + b * c
        if(dic1[a]>=thre):exceed = True
    if(exceed==False):print "NA"; continue 
    for k in dic1.keys():
        if(dic1[k]>=thre):print k

Measured memory_bytes: 6872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	int n;

	cin >> n;

	rep(loop, n) {
		int p, q;

		cin >> p >> q;

		int count = 0;

		for (int m = 0; m <= p*p + q*q; m++) {
			for (int n = 0; n <= p*p + q*q; n++) {
				if (m*m + n*n < 1) {
					continue;
				}

				if (m*m + n*n > p*p + q*q) {
					break;
				}

				if ((m*p + n*q) % (m*m + n*n) == 0 && (m*q - n*p) % (m*m + n*n) == 0) {
					count += 2;
				}

			}
		}

		if (count <= 8) {
			cout << 'P' << endl;
		}
		else {
			cout << 'C' << endl;
		}
	}

	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<int, int> pii;

const ll Mod = 1000000007LL;
const int N = 5e2 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

int a[N][N], dis[N][N], mk[N][N];
deque<pair<int, int>> dq;


pii adj[] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			//cin >> a[i][j];
			dis[i][j] = min({i, j, n - 1 - i, n - 1 - j});
		}
	}
	//debug(dis[1][1]);
	int v, x, y, nx, ny, w;
	ll ans = 0;
	for(int i = 0; i < n*n; i++){
		cin >> v;
		v--;
		ans += dis[v/n][v%n];
		mk[v/n][v%n] = 1;
		dq.clear();
		dq.pb({v/n, v%n});
		//debug(v);
		while(dq.size()){
			x = dq.front().F;
			y = dq.front().S;
			dq.pop_front();
			w = 1 - mk[x][y];
			for(auto &del : adj){
				nx = x + del.F;
				ny = y + del.S;
				if(min(nx, ny) < 0 || n <= max(nx, ny)) continue;
				if(dis[nx][ny] > dis[x][y] + w){
			//		debug(nx); debug(ny);
					dis[nx][ny] = dis[x][y] + w;
					if(w) dq.pb({nx, ny});
					else dq.push_front({nx, ny});
				}
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 6376
n = int(input())
s_dic = {}
count = 0
for i in range(n):
    tmp = input()
    s_dic.setdefault(tmp, 0)
    s_dic[tmp] += 1
    if count < s_dic[tmp]:
        count = s_dic[tmp]
ans = [k for k, v in s_dic.items() if v == count]
ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 97752
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <vector>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
typedef long long int ll;
using namespace std;
const int MAX=5000+10;
const double eps=1e-9;
const double PI=acos(-1.0);

int sgn(double x)
{
    if (fabs(x)<eps) {
        return 0;
    }
    if (x<0) {
        return -1;
    }
    else return 1;
}
struct point
{
    double x,y;
    point(){}
    point(double _x,double _y)
    {
        x=_x;y=_y;
    }
    point operator +(const point &b)const
    {
        return point(x+b.x,y+b.y);
    }
    point operator -(const point &b)const
    {
        return point(x-b.x,y-b.y);
    }
    double operator ^(const point &b)const
    {
        return x*b.y-y*b.x;
    }
    double operator *(const point &b)const
    {
        return x*b.x+y*b.y;
    }
    point operator *(const double k)const
    {
        point kk;kk.x=k*x;kk.y=k*y;return kk;
    }
    double len(void)
    {
        return sqrt(x*x+y*y);
    }
};

struct line
{
    point s,e;
    line(){}
    line(point _s,point _e)
    {
        s=_s;e=_e;
    }
    pair<int, point> operator &(const line &b)const
    {
        point res=s;
        if(sgn((s-e)^(b.s-b.e))==0){
            if(sgn((s-b.e)^(b.s-b.e))==0){
                return make_pair(0, res);
            }
            else{
                return make_pair(1,res);
            }
        }
        double t=((s-b.s)^(b.s-b.e))/((s-e)^(b.s-b.e));
        res.x+=(e.x-s.x)*t;
        res.y+=(e.y-s.y)*t;
        return make_pair(2, res);
    }
};

bool inter(line l1,line l2)
{
    return max(l1.s.x,l1.e.x) >= min(l2.s.x,l2.e.x) &&
    max(l2.s.x,l2.e.x) >= min(l1.s.x,l1.e.x) &&
    max(l1.s.y,l1.e.y) >= min(l2.s.y,l2.e.y) &&
    max(l2.s.y,l2.e.y) >= min(l1.s.y,l1.e.y) &&
    sgn((l2.s-l1.e)^(l1.s-l1.e))*sgn((l2.e-l1.e)^(l1.s-l1.e)) <= 0 &&
    sgn((l1.s-l2.e)^(l2.s-l2.e))*sgn((l1.e-l2.e)^(l2.s-l2.e)) <= 0;
}

int main(){
    //freopen("/Users/mac/Desktop/C++?¨????/test/test.txt", "r", stdin);
    int q;
    scanf("%d",&q);
    while(q--){
        line l1,l2;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&l1.s.x,&l1.s.y,&l1.e.x,&l1.e.y,&l2.s.x,&l2.s.y,&l2.e.x,&l2.e.y);
        printf("%d\n",inter(l1, l2)?1:0);
    }
    return 0;
}

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

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

void solve() {
    int N, x; cin >> N >> x;
    vector<int> a(N); rep(i, N) cin >> a[i];

    sort(a.begin(), a.end());

    int res = x;
    int i = 0;
    for (; i < N && res > 0; ++i){
        res -= a[i];
    }
    
    if (res == 0){
        cout << i << "\n";
        return;
    }

    if(res < 0){
        cout << i-1 << "\n";
        return;
    }

    if(res > 0){
        cout << N - 1 << "\n";
        return;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>

int main()
{
	long long n,sum=0,ans=0;
	std::map<long long,int> cnt;
	std::cin >> n;
	cnt[0]++;
	for(int i=0;i<n;i++){
		long long tmp;
		std::cin >> tmp;
		sum+=tmp;
		ans+=cnt[sum];
		cnt[sum]++;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 12800
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<u64>()[0]%500;
    let a = read_as_vec::<u64>()[0];

    if n <= a{
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
program ccc
implicit none

integer(8) :: n, i, p, q
integer(8),allocatable,dimension(:) :: a

read*, n
allocate(a(n))
read*, a

p=minval(a)
q=maxval(a)
do while(p/=q)
p=minval(a)
do i=1,n
if(mod(a(i),p)==0) then
a(i)=p
else
a(i)=mod(a(i),p)
end if
end do
q=minval(a)
end do

write(*,'(i0)') q

end program

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String str = fs.next();
		
		String keyence = "keyence";
		
		for(int i = 1; i < keyence.length(); i++) {
			String prefix = keyence.substring(0, i);
			String postfix = keyence.substring(i);
			
//			System.out.println(prefix);
//			System.out.println(postfix);
			
			int preIndex = str.indexOf(prefix);
			int postIndex = str.lastIndexOf(postfix);
			
			if(preIndex == 0 && postIndex+postfix.length() == str.length()) {
				System.out.println("YES");
				return;
			}
		}
		
		System.out.println("NO");
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21204
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int n;
vector<int> a;
vector<bool> check;
int cnt;
bool reach;

void rec(int pos){
  cnt++;
  if(check[pos]) return;
  if(pos == 1){
    reach = true;
    return;
  }
  check[pos] = true;
  rec(a[pos]);
  
}

int main(){
  cin >> n;
  a.resize(n);
  cnt = 0;
  reach = false;
  
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  
  check.resize(n,false);
  
  rec(a[0]);
  
  if(reach){
    cout << cnt;
  }else{
    cout << -1;
  }
  
  
  return 0;
}

Measured memory_bytes: 640
N = int(input())
h = list(map(int, input().split()))
dp = [float('inf') for i in range(N)]

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
  dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])


Measured memory_bytes: 13928
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=500010, inf=1e9;
struct edge{int too, pre;}e[maxn<<1];
int n, m, x, y, tot, top;
char s[maxn];
int a[maxn], last[maxn], cnt[2][maxn], st[maxn];
bool v[maxn];

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;
}

inline void add(int x, int y){e[++tot]=(edge){y, last[x]}; last[x]=tot;}

int main()
{
	read(n); read(m);
	scanf("%s", s+1);
	for(int i=1;i<=n;i++) a[i]=(s[i]=='A');
	for(int i=1;i<=m;i++)
	{
		read(x); read(y); 
		add(x, y); add(y, x);
		cnt[a[y]][x]++; cnt[a[x]][y]++;
	}
	int top=0;
	for(int i=1;i<=n;i++)
	if(!cnt[0][i] || !cnt[1][i]) st[++top]=i, v[i]=1;
	while(top)
	{
		int now=st[top--];
		for(int i=last[now], too;i;i=e[i].pre)
		if(!v[too=e[i].too])
		{
			cnt[a[now]][too]--;
			if(!cnt[a[now]][too])
			{
				v[too]=1;
				st[++top]=too;
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) ans|=(!v[i]);
	puts(ans?"Yes":"No");
}

Measured memory_bytes: 13184
#include<stdio.h>
#include<string.h>

int main(void)
{
	char s[20];
	char s2[20];
	int i, j;
	int n;
	
	scanf("%s", s);
	
	n = strlen(s);
	j = strlen(s);
	
	for (i = 0; i < n; i++) {
		s2[i] = s[j - 1];
		
		j--;
	}
	
	s2[i] = '\0';
	
	printf("%s\n", s2);
	
	return (0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define repeat(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, C;
    cin >> N >> M >> C;
    int B[M], A[M];
    int ans = 0;
    
    rep(i, M) cin >> B[i];
    rep(i, N){
        int g = 0;
        rep(j, M){
            cin >> A[j];
            g += A[j] * B[j];
        }
        g += C;
        
        if(g > 0) ans ++;
        
    }
    cout << ans << endl;

    
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n,a,b = m()

print(min(n*a,b))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int a)
{
    int m = a/2;
    for(int i = 2 ; i <= m ; i++)
    {
        if(a % i == 0)
            return false;
    }
    return true;
}
    int main() {
        int n;
        cin >> n;

        bool flag = false;
        while(!flag)
        {
            if(isPrime(n))
                {cout <<n;
                break;
            }
            else
                n++;
        }
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;

struct RSQ_RAQ{
    int n;
    vector<ll> node,lazy;

    RSQ_RAQ(int sz){
        n=1;
        while(n < sz) n*=2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);
    }

    void eval(int k,int l, int r){
        if(lazy[k] != 0){
            node[k] += lazy[k];
            if(r-l>0){
                lazy[2*k+1] += lazy[k]/2;
                lazy[2*k+2] += lazy[k]/2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a,int b, ll x,int k = 0, int l = 0,int r = -1){
        
        if(r < 0) r = n-1;
        eval(k,l,r);
        if(b < l || r < a) return ;
        if(a <= l && r <= b){
            lazy[k] += (r - l + 1) * x;
            eval(k,l,r);
        }else{
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2+1,r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a,int b,int k = 0,int l = 0, int r = -1){
        
        if(r < 0)r = n-1;
        
        eval(k,l,r);
        if(b < l || r < a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1,         l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2+1,       r);
        return vl + vr;
    }
};

int main(){
    int n,d,a;
    cin >> n >> d >> a;
    vector<pll> vec;
    vector<ll> v_pos(n+1);
    int x,h;
    RSQ_RAQ seg(n);
    rep(i,n){
        cin >> x >> h;
        vec.push_back(make_pair(x,h));
    }

    v_pos[n] = 2e9+10;

    sort(vec.begin(),vec.end());
    rep(i,n){
        seg.add(i,i,vec[i].second);
        v_pos[i] = vec[i].first;
    }

    ll ans = 0;
    ll pos = 0;
    ll dmg = 0;
    
    rep(i,n){
        if(seg.getsum(i,i) > 0){
            auto pos = upper_bound(v_pos.begin(),v_pos.end(),vec[i].first + 2*d);
            int r = pos - v_pos.begin() - 1;
            ll bom = (seg.getsum(i,i) + a - 1 )/a;
            ans += bom;

            seg.add(i,r,-bom*a);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 16112
def main():
	s = input()
	aa = int(s[:2])
	bb = int(s[2:])
	ans = ""
	if (aa <= 12) and (aa > 0):
		if (bb <= 12) and (bb > 0):
			ans = "AMBIGUOUS"
		else:
			ans = "MMYY"
	else:
		if (bb <= 12) and (bb > 0):
			ans = "YYMM"
		else:
			ans = "NA"
	print(ans)

main()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

  int H, W;
  cin >> H >> W;
  char c;
  int n = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> c;
      if (c == '#') ++n;
    }
  }
  if (n == H + W - 1)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

n,l = list(map(int,input().split()))
D = []
C = [0]

for i in range(n):
    d,c = list(map(int,input().split()))
    D.append(d)
    C.append(C[i]+c)

#時計周りに歩く場合を考える
L = [0]
for i in range(n):
    L.append(max(L[i],C[i+1]-D[i]))

#反時計周りに歩く場合を考える
R = [0]
for i in range(n):
    R.append(max(R[i],C[n]-C[n-i-1]-(l-D[-i-1])))

#時計周りに歩いた後、反時計周りに歩く場合を考える
LR = 0
for i in range(n-1):
    LR = max(LR, C[i+1]-D[i]*2+R[n-i-1])

# #時計周りに歩いた後、反時計周りに歩く場合を考える
RL = 0
for i in range(n-1):
    RL = max(RL, C[n]-C[n-i-1]-(l-D[-i-1])*2+L[n-i-1])

print(max(L+R+list([LR,RL])))

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

const int MAXS = 100000;
const int Mod = 1e9+7;
string S;
int P[MAXS][13];        // P[i][j] : i文字目まで見た時にj(mod13)であるバターンの総数
const int mod[6] = {1, 10, 9, 12, 3, 4};


int main() {
  cin >> S;
  reverse(S.begin(), S.end());
  int n = S.length();
  
  if (S[0] == '?') for (int i = 0; i <= 9; ++i) P[0][i] = 1;
  else P[0][(int)(S[0]-'0')] = 1;
  
  for (int i = 1; i < n; ++i) {   // i文字目
    int s = mod[i % 6];
    if (S[i] == '?') {
      for (int j = 0; j <= 9; ++j) {    // i文字目がjの場合
        int t = s * j % 13;
        for (int k = 0; k <= 12; ++k) {
          P[i][k] += P[i-1][(k-t+13) % 13];
          P[i][k] %= Mod;
        }
      }
    }
    else {
      int t = s * (int)(S[i] - '0') % 13;
      for (int k = 0; k <= 12; ++k) {
        P[i][k] += P[i-1][(k-t+13) % 13];
        P[i][k] %= Mod;
      }
    }
  }
  cout << P[n-1][5] << endl;
  return 0;
}

Measured memory_bytes: 5504
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int H,W;

	while(1){
		cin>>H>>W;
		if (H==0 && W==0)break;
		for (int i=0; i<H; i++){
			for (int j=0; j<W; j++){
				cout<<"#";
			}
			cout<<"\n";
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%2lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

#define MOD 1000000007

using namespace std;

typedef long long ll;

ll A, B;

ll solve(){
  if (A==B) return A;
  if (A+1==B) return A ^ B;
  
  ll n = B-A+1;
  
  if (A%2==0){
    if (B%2==1) {
      if ((n/2)%2==0) return 0;
      else return 1;
    } else {
      if (((n-1)/2)%2==0) return B;
      else return B^1;
    }
  
  } else { //奇数開始
     if (B%2==1) {
      if (((n-1)/2)%2==0) return A;
      else return A^1;
    } else {
      if (((n-2)/2)%2==0) return A^B;
      else return A^B^1;
    }
    
  
  }
  
  return -1;

}

int main(void) {
    scanf("%lld %lld", &A, &B);
    
 
    

  
    printf("%lld\n", solve());
    return 0;
}


Measured memory_bytes: 256
n = int(input())
li = [0] * 5
for i in range(n):
    name = input()
    if name[0] == 'M':
        li[0] += 1
    if name[0] == 'A':
        li[1] += 1
    if name[0] == 'R':
        li[2] += 1
    if name[0] == 'C':
        li[3] += 1
    if name[0] == 'H':
        li[4] += 1
ans = 0
for i in range(3):
    for j in range(5-i-1):
        if 5-i-j-2 >= 1:
            for k in range(5-i-j-2):
                ans += li[i]*li[i+j+1]*li[i+j+k+2]
print(ans)

Measured memory_bytes: 3064
import itertools
import numpy as np
import copy

h, w, k = map(int, input().split())
ans = 0
c = [list(input()) for _ in range(h)]
for i in range(1<<h):
    for j in range(1<<w):
        black = 0
        for l in range(h):
            for m in range(w):
                if c[l][m] == '#' and (i>>l & 1 == 0 and j>>m & 1 == 0):
                    black += 1
        if black == k:
            ans += 1
print(ans)


Measured memory_bytes: 27164
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<string> st;
void saiki(string,int,int);
int main(){
  cin >> n >> m;
  saiki("",0,0);
  sort(st.begin(),st.end());
  for(int i=0;i<st.size();i++){
    cout << st[i] << endl;
  }
  
  return 0;
}
void saiki(string s,int a,int b){
  // cout << s << endl;
  if(a==n&&b==m){
    st.push_back(s);
  }
  if((a<5&&b<5)||(a>=4&&b>=4&&a+b<10))
    saiki(s+'A',a+1,b);
  if((a<5&&b<5)||(a>=4&&b>=4&&a+b<10))
    saiki(s+'B',a,b+1);
}
  

Measured memory_bytes: 3136
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

void numToAB(lli num,lli &a,lli &b){
	a=num%10;
	while(num>9)num/=10;
	b=num%10;
}

map<pair<lli,lli>,lli> cnt;

signed main(){

	lli n;
	cin>>n;

	REP(i,1,n+1){
		lli a,b;
		numToAB(i,a,b);
		cnt[mp(a,b)]++;
	}

	lli ans=0;

	REP(i,1,n+1){
		lli a,b;
		numToAB(i,a,b);
		ans += (cnt[mp(b,a)]);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn main() {
    let mut input_str = String::new();
    std::io::stdin().read_to_string(&mut input_str).unwrap();

    let input_parts = input_str.split_whitespace().collect::<Vec<_>>();
    let mut input_parts_it = input_parts.iter().cloned();
    let mut next = || input_parts_it.next().unwrap();

    let n: usize = next().parse().unwrap();

    struct Pr {
        and_mask: u16,
        bitmap: u16,
    }

    let prs = (0..n)
        .map(|_| {
            let a: usize = next().parse().unwrap();
            let mut and_mask: u16 = 0;
            let mut bitmap: u16 = 0;

            for _ in 0..a {
                let x: u32 = next().parse().unwrap();
                let y: u8 = next().parse().unwrap();
                and_mask |= 1u16 << x;
                if y != 0 {
                    bitmap |= 1u16 << x;
                }
            }

            Pr {
                and_mask: and_mask >> 1,
                bitmap: bitmap >> 1,
            }
        })
        .collect::<Vec<_>>();

    let best = (0..(1u16 << n))
        .filter(|&bitmap| {
            prs.iter().enumerate().all(|(i, pr)| {
                if (bitmap & (1 << i)) != 0 {
                    // validate his/her assertion
                    (bitmap & pr.and_mask) == pr.bitmap
                } else {
                    true
                }
            })
        })
        .map(|bitmap| bitmap.count_ones())
        .max()
        .unwrap();

    println!("{}", best);
}


Measured memory_bytes: 4352
import math

for n in range(int(input()),100003+1):
    fact = True
    if n % 2 == 0 and n != 2:
        continue

    for div in range(2,math.floor(math.sqrt(n))+1):
        if n % div == 0:
            fact = False
            break

    if fact:
        print(n)
        break

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int solve(vector<vector<int>> &b){
  
  int hantei = 0;
  
  for ( int i = 0; i < 3; i++){
    if ( b[i][0] == 1 && b[i][1] == 1 && b[i][2] == 1 ){
      return 1;
    }
  }
  
  for ( int i = 0; i < 3; i++){
    if ( b[0][i] == 1 && b[1][i] == 1 && b[2][i] == 1 ){
      return 1;
    }
  }
  
  if ( b[0][0] == 1 && b[1][1] == 1 && b[2][2] == 1 ){
    return 1;
  }
  
  
  if ( b[0][2] == 1 && b[1][1] == 1 && b[2][0] == 1 ){
    return 1;
  }
  
  return 0; 
  
}


int main() {
  
  vector<vector<int>> a(3,vector<int>(3));
  for ( int i = 0; i < 3; i++){
    for ( int j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }
  
  vector<vector<int>> b(3,vector<int>(3,0));
  
  int n,x;
  cin >> n;
  for ( int k = 0; k < n; k++){
    cin >> x;
    for ( int i = 0; i < 3; i++){
      for ( int j = 0; j < 3; j++){
        if ( x == a[i][j] ){
          b[i][j] = 1;
        }
      }
    }
  }
  
  int ans = solve(b);
  
  if (ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
def dfs(graph, start):
    stack = [(start, 0)]
    visited = set()
    li = [0] * N
    while stack:
        d = stack.pop()
        li[d[0] - 1] = d[1] % 2
        for node, w in graph[d[0]]:
            if node not in visited:
                visited.add(node)
                stack.append((node, d[1] + w))
    return li


N = int(input())
g = {i: []for i in range(1, N + 1)}
for i in range(N - 1):
    u, v, w = map(int, input().split())
    w %= 2
    g[u].append((v, w))
    g[v].append((u, w))
for c in dfs(g, 1):
    print(c)

Measured memory_bytes: 80100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,m;cin>>n>>m;
    bool res[n];
    fill(res,res+n,false);
    vector<ll> WA(n,0);
    ll AC=0;
    rep(i,m){
        int p;string s;cin>>p>>s;
        p--;
        if(res[p]==false){
            if(s=="AC"){
                res[p]=true;
                AC++;
            }else{
                WA[p]++;
            }
        }
    }
    int WAsum=0;
    rep(i,n){
        if(res[i])WAsum+=WA[i];
    }
    cout<<AC<<" "<<WAsum<<endl;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    map<int,int> num;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        if(num.find(tmp)==num.end()){
            num[tmp]=1;
        }else{
            num[tmp]+=1;
        }
    }
    int ans=0;
    for(auto i:num){
        if(i.second%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4864
N, L = map(int, input().split())
if(L+1-1<=0 and L+N-1>=0):
    print(sum(range(L,L+N)))
else:
    if(N+L<=0):
        print(sum(range(L,N+L))-(L+N-1))
    else:
        print(sum(range(L,N+L))-L)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };

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

    int a;
  	cin >> a;
    if (a % 2 == 0) {
        cout << a / 2;
    }
    else {
        cout << ceil(a / 2) + 1;
    }

    return 0;
}

Measured memory_bytes: 256
char ch[2][3]={"RG","BY"};i,j,n,m;main(k){for(scanf("%d%d%d",&n,&m,&k);n/++i;puts(""))for(j=0;m/++j;)putchar(ch[(i+j+2000)/k%2][(i-j+2000)/k%2]);}

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

#define rep(i,n) for(int i=0;i<(int)(n);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)

#define lf 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);
    int n, m; cin>>n>>m;
    vector<vi> adj(n+1);
    rep(i, m){
        int s, t; cin>>s>>t;
        adj[s].pb(t);
    }

    double ans = n;
    rep(i, n){
        vector<double> dp(n+1, 0.0);
        for(int j=n-1; j>=1; j--){
            double maxi = 0.0;
            for(auto v:adj[j]){
                dp[j] += dp[v]+1.0;
                maxi = max(maxi, dp[v]+1.0);
            }
            if (j == i+1 && adj[j].size() >= 2){
                dp[j] -= maxi;
                dp[j] /= adj[j].size()-1;
            }else{
                dp[j] /= adj[j].size();
            }
        }
        ans = min(ans, dp[1]);
    }
    cout << setp(12) << ans << "\n";
	return 0;
}


Measured memory_bytes: 1408
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>ret;
	while (N) {
		vector<vector<int>>v(N + 1, vector<int>(40));
		for (int i = 0; i < N; i++) {
			int a;
			cin >> a;
			for (int j = 0; j < a; j++) {
				int b;
				cin >> b;
				v[i][b] = 1;
			}
		}
		int ans = MOD;
		vector<vector<vector<int>>>dp(N, vector<vector<int>>(N, vector<int>(31)));
		for (int i = 0; i < N; i++) {
			dp[i][i][0] = 1;
		}
		for (int j = 1; j <= 30; j++) {
			for (int k = 0; k < N; k++) {
				for (int l = 0; l < N; l++) {
					dp[k][l][j] = dp[k][l][j - 1];
				}
			}
			for (int k = 0; k < N; k++) {
				for (int l = 0; l < N; l++) {
					if (v[k][j] && v[l][j]) {
						for (int m = 0; m < N; m++) {
							dp[m][k][j] |= dp[m][l][j];
							dp[m][l][j] |= dp[m][k][j];
						}
					}
				}
			}
			for (int k = 0; k < N; k++) {
				int num = 0;
				for (int l = 0; l < N; l++) {
					num += dp[l][k][j];
				}
				//cout << num << endl;
				if (num == N) {
					ans = min(ans, j);
				}
			}
		}
		if (ans == MOD)ans = -1;
		ret.push_back(ans);
		cin >> N;
	}
	for (auto i : ret) {
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 3372
from collections import deque
deq=deque()
s=input()
n=len(s)
for i in s:
    if len(deq)==0:
        deq.append(i)
        continue
    x=deq.pop()
    if x==i:
        deq.append(x)
        deq.append(i)
print(n-len(deq))

Measured memory_bytes: 44016
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

class MyClass {};

int main() {
  int n;
  cin >> n;
  vector<int> v1(n / 2), v2(n / 2);

  pair<int, int> a1[100010], a2[100010];
  for (int i = 0; i < 100010; i++) a2[i].second = a1[i].second = i;
  for (int i = 0; i < n; i += 2) {
    cin >> v1[i / 2] >> v2[i / 2 + 1];
    a1[v1[i / 2]].first++;
    a2[v2[i / 2 + 1]].first++;
  }

  sort(a1, a1 + 100010);
  reverse(a1, a1 + 100010);
  sort(a2, a2 + 100010);
  reverse(a2, a2 + 100010);

  int ans = 0;
  if (a1[0].second == a2[0].second)
    ans = min(n - a1[1].first - a2[0].first, n - a1[0].first - a2[1].first);
  else
    ans = n - a1[0].first - a2[0].first;

  cout << ans << endl;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int i,sum=0;
  for(i=0;i<s.size();i++)
    sum+=s[i]-48;
  if(sum%9==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3712