akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < (int)s.size(); i++) {
		ans += (s[i] != t[i]);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3564
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int[] b = new int[26];

        for (int i = 0; i < s.length(); ++i) {
            b[s.charAt(i)-'a'] += 1;
        }

        for (int i = 0; i < 26; ++i) {
            if (b[i] > 1) {
                System.out.println("no");
                return;
            }
        }

        System.out.println("yes");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin >> n >> x;
    vector<int> L(n);
    for(int i=0; i<n; i++){
        cin >> L.at(i);
    }

    int zahyou=0;
    int cnt=1;

    for(int i=0; i<n; i++){
        zahyou += L.at(i);
        if(zahyou > x) break;
        cnt++;

    }
    cout << cnt << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
  string s;
  cin >> s;

  int ans = 0;
  rep(i, s.size()){
    if(i%2 == 0){
      if(s[i] == 'p') ans--;
    }else{
      if(s[i] == 'g') ans++;
    }
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    private static int[] calcPrimes(int n) {
        boolean[] table = new boolean[n + 1];
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (!table[i]) {
                for (int j = i + i; j <= n; j += i) {
                    table[j] = true;
                }
            }
        }
        int counter = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                counter++;
            }
        }
        int[] result = new int[counter];
        int index = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                result[index++] = i;
            }
        }
        return result;
    }

    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int[] primes = calcPrimes(999983);
        while (true) {
            int n = scanner.nextInt();
            if (n == 0) {
                break;
            }
            int[][] range = new int[n][2];
            for (int i = 0; i < n; i++) {
                int p = scanner.nextInt();
                int m = scanner.nextInt();
                range[i][0] = Math.max(p - m, 2);
                range[i][1] = Math.min(p + m, 999983);
            }
            Arrays.sort(range, new Comparator<int[]>() {
                @Override
                public int compare(int[] o1, int[] o2) {
                    return (o1[0] < o2[0]) ? -1 : ((o1[0] == o2[0]) ? 0 : 1);
                }
            });
            int counter = 0;
            int index = 0;
            for (int i = 0; i < n; i++) {
                int start = range[i][0];
                int end = range[i][1];
                for (; primes[index] < start; index++);
                for (int j = index; j < primes.length && primes[j] <= end; j++) {
                    counter++;
                }
            }
            System.out.println(counter - n);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 14000
function updateChildren(cid, pid) {
	var node = T.filter(function(c){return c.id == cid;})[0];
	node.parent = pid;

	if (node.left != -1) {
		updateChildren(node.left, node.id);
	}
	if (node.right != -1) {
		updateChildren(node.right, node.id);
	}
}
function preorder(id, arr) {
	if (id == -1)
		return;
	var node = T.filter(function(c){return c.id == id;})[0];
	arr.push(id);
	preorder(node.left, arr);
	preorder(node.right, arr);
}
function inorder(id, arr) {
	if (id == -1)
		return;
	var node = T.filter(function(c){return c.id == id;})[0];
	inorder(node.left, arr);
	arr.push(id);
	inorder(node.right, arr);
}
function postorder(id, arr) {
	if (id == -1)
		return;
	var node = T.filter(function(c){return c.id == id;})[0];
	postorder(node.left, arr);
	postorder(node.right, arr);
	arr.push(id);
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.trim().split('\n');

var n = +lines.shift()

var T = [];
for (var i = 0; i < n; i++) {
	var u = lines.shift().split(' ');
	var id = +u[0];
	var left = +u[1];
	var right = +u[2];

	T.push({id: id, left: left, right: right, parent: -1});
}

T.sort(function(a, b){return a.id - b.id;});

T.forEach(function(node) {
	if (node.left != -1) {
		updateChildren(node.left, node.id);
	}
	if (node.right != -1) {
		updateChildren(node.right, node.id);
	}
});

var root = T.filter(function(node){return node.parent == -1;})[0];

var ret = [];
preorder(root.id, ret);
console.log('Preorder');
console.log(' ' + ret.join(' '));

ret = [];
inorder(root.id, ret);
console.log('Inorder');
console.log(' ' + ret.join(' '));

ret = [];
postorder(root.id, ret);
console.log('Postorder');
console.log(' ' + ret.join(' '));

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

int main(void) {
    double n,s[10000];
    while(cin>>n) {
        if(n==0) return 0;
        double ans=0.0,sum=0.0,ave=0.0;
        for(int i=0;i<n;i++) {
            cin>>s[i];
            sum+=s[i];
        }
        ave=sum/n;
        double cal=0.0;
        for(int i=0;i<n;i++) {
            cal+=(s[i]-ave)*(s[i]-ave);
        }
        ans=sqrt(cal/n);
        printf("%.8f\n",ans);
    }
    return 0;
}

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

int main() {
    // 整数の入力
    int N, i;
    vector<int> a;
    int retval = 0;

    cin >> N;
    a = vector<int>(N, 0);
    for(i = 0; i < N; ++i) cin >> a[i];
    for(i = 0; i < N; ++i) {
        while(a[i] % 2 == 0) {
            a[i] /= 2;
            retval++;
        }
    }

    cout << retval;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream> 
#include <algorithm>
#include <bits/stdc++.h>
 
using namespace std; 
typedef long long ll;
 
#define umap unordered_map
#define f first
#define s second
 
#define for0(i, a, b) for (int i = (a); i < (b); i++)
#define for1(i, a) for (int i = 0; i < (a); i++)
#define ford(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define fored(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define rep(i,a,b) for (int i = a; i < b; i++)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sstr substr
typedef vector<int> vi;
typedef vector<string> vis;
typedef unordered_map<string, int> umap; 

 
int main()
{   
    vector<vector<int>> vec;
    int row;
    cin >> row;
    int temp ;
    vi tmpvec;

    for0(i,0, row){
        vi tmpvec;
        for0(j ,0, 3){
            cin >> temp;
            tmpvec.pb(temp);
        }
        vec.pb(tmpvec);
    }
    
    if ( row == 1 ){
        // cout<<"hello";
        vector<int> temp1 = vec[row - 1];

        cout<< *max_element(temp1.begin(), temp1.end() );
        return 0;
    }
    
    // for (auto x : vec){
    //     for(auto y : x){
    //         cout<<y<< " ";
    //     }
    //     cout<<endl;
    // }
    // cout<<"ned"<<endl;
    
    for0(i, 1, row ){
        for0(j , 0,  3){
            if (j == 0 ){
                vec[i][j] = vec[i][j] +   max( vec[i - 1][j + 1], vec[i - 1][j + 2] );
                continue;
            }
            if (j == 1 ){
                vec[i][j] = vec[i][j] +  max( vec[i - 1][0], vec[i - 1][2] );
                continue;
            }
            
            if (j == 2 ){
                vec[i][j] = vec[i][j]  +   max( vec[i - 1][0], vec[i - 1][1] );
                continue;
            }

        }
    }
    
    vector<int> temp1 = vec[row - 1];
    // for (auto x : vec){
    //     for(auto y : x){
    //         cout<<y<< " ";
    //     }
    //     cout<<endl;
    // }
    cout << *max_element(temp1.begin(), temp1.end() );
    
    
    return 0;
}

Measured memory_bytes: 6836
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int cnt1=0,cnt2=0;
  string s;
  cin >> s;
  for(int i=2; i<s.length()-1; i++) {
    if(s[i]=='C') {
      cnt1++;
    }
  }
  for(int i=0; i<s.length(); i++) {
    if(isupper(s[i])) {
      cnt2++;
    }
  }
  if(s[0]=='A'&&cnt1==1&&cnt2==2) {
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl;
  }
}

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

const int MOD=1e9+7;
const int MAXN=3005;

int n,m,ans;
int f[MAXN][MAXN][2];

int main(){
	scanf("%d%d",&n,&m);
	f[0][0][1]=1;
	for(int i=1;i<=n;i++) f[0][i][0]=1;
	for(int i=0;i<m;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<2;k++){
				if(j) (f[i+1][j-1][k|(j-1==0)]+=f[i][j][k])%=MOD;
				if(j) (f[i+1][j][k|(j==1)]+=f[i][j][k])%=MOD;
				if(j<n) (f[i+1][j][k]+=f[i][j][k])%=MOD,(f[i+1][j+1][k]+=f[i][j][k])%=MOD;
			}
	for(int i=0;i<=n;i++) (ans+=f[m][i][1])%=MOD;
	printf("%d\n",ans);
}


Measured memory_bytes: 70656
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in range(n):
    if 1<=a[i]<=399:
        b[0]+=1
    elif 400<=a[i]<=799:
        b[1]+=1
    elif 800<=a[i]<=1199:
        b[2]+=1
    elif 1200<=a[i]<=1599:
        b[3]+=1
    elif 1600<=a[i]<=1999:
        b[4]+=1
    elif 2000<=a[i]<=2399:
        b[5]+=1
    elif 2400<=a[i]<=2799:
        b[6]+=1
    elif 2800<=a[i]<=3199:
        b[7]+=1
    else:
        b[8]+=1
ans=0
for i in range(8):
    if b[i]!=0:
        ans+=1
if ans==0:
    ans+=1
    b[8]-=1
print(ans,ans+b[8])

Measured memory_bytes: 3064
// ------------------------------------
// Date:2018/ 3/ 4
// Problem:ABC 089 _ a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  cout << N / 3 << endl;
  
  return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <pair <int, int>> vii;

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    int n;
    cin >> n;
    vii a(n);
    re(n) cin >> a[i].fi >> a[i].se;
    vi p;
    re(n) p.push_back(i);
    ld ans = 0;
    int cnt = 0;
    cout << setprecision(15) << fixed;
    do {
        ++cnt;
        ld cur = 0;
        for (int i = 1; i < n; ++i) {
            cur += sqrt((a[p[i]].se - a[p[i-1]].se) * (a[p[i]].se - a[p[i-1]].se) +
                (a[p[i]].fi - a[p[i-1]].fi) * (a[p[i]].fi - a[p[i-1]].fi));
            // cout << cur << " ";
        }
        ans += cur;
    } while (next_permutation(all(p)));
    ans /= cnt;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int a = sc.nextInt();

        if (h%a == 0)
            System.out.println(h/a);
        else
            System.out.println((h/a)+1);

    }
}


Measured memory_bytes: 35412
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const double INF = 1e18;
const int MAX = 1000004;

int N,M;

int main()
{

    char a[4];
    cin>>a;
    N = 1;
    for(int i = 0;i<=1;i++)
    {
        for(int j = 1;j<=2;j++)
        {
            if(a[i]==a[i+j])
                N++;
            else
                N=1;
        }
        if(N==3)
        {
            cout<<"Yes"<<endl;
            return 0;
        }

    }
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
import collections
N,K,Q = list(map(int,input().split()))
A = [ int(input()) for i in range(Q)]
cnt = collections.Counter(A)
ini_po = [K]*N
fi_po =[]
for i in range(N):
    t_po = ini_po[i]
    if i+1 in cnt:
        t_po += -Q + cnt[i+1]
    else:
        t_po -= Q
    if t_po >0:
        print('Yes')
    else:
        print('No')


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    Graph g(n);
    REP(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        add_edge(g, a, b, 1, true, 1);
    }

    vvec<bool> used(n, vec<bool>(2, 0));
    vec<bool> dp(n, false);
    auto dfs = [&](auto &&self, int v, int t) -> bool {
        used[v][t] = true;
        for(auto e : g[v]) {
            if(dp[e.to])
                continue;
            if(t) {
                if(s[v] != s[e.to]) {
                    if(used[e.to][!t]) {
                        return true;
                    }
                    if(self(self, e.to, !t))
                        return true;
                }
            } else {
                if(s[v] == s[e.to]) {
                    if(used[e.to][!t]) {
                        return true;
                    }
                    if(self(self, e.to, !t))
                        return true;
                }
            }
        }
        dp[v] = true;
        return false;
    };

    REP(i, n) {
        if(used[i][0])
            continue;
        if(dfs(dfs, i, 0)) {
            cout << "Yes" << en;
            return;
        }
    }
    cout << "No" << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 37088
N = int(input())
S1 = input()
S2 = input()
S1 += "0"
old_shape = ""

if S1[0] == S1[1]:
    ans = 6
    old_shape = "yoko"
    i = 2
else:
    ans = 3
    old_shape = "tate"
    i = 1

while i < N:
    if S1[i] == S1[i+1]:
        if old_shape == "tate":
            ans = (ans*2)%1000000007
            
        else:
            ans = (ans*3)%1000000007
            
        i += 2
        old_shape = "yoko"
    
    else:
        if old_shape == "tate":
            ans = (ans*2)%1000000007
        
        i += 1
        old_shape = "tate"

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)(1e9+7)

main(){

	int h,n;
	cin>>h>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
	int dp[h+1];
	memset(dp,mod,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=h;i++)
		for(int j=0;j<n;j++){
			if(i-a[j]>=0)
				dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
			else
				dp[i]=min(dp[i],b[j]);
		}
	cout<<dp[h]<<endl;

}	


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 100000000000000000LL
#define MOD 1000000007

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

int main(){
	
	ll d,g;cin >> d >> g;
	vector<pair<ll,ll>> v;
	REP(i,d){
		ll a,b;cin >> a >> b;
		v.PB(MP(a,b));
	}
	
	vector<int> par(d);
	REP(i,d)par[i] = i;
	ll ans = LLINF;
		
	do{
		ll tmp = 0;
		ll ret = 0;
		REP(i,d){
			auto now = v[par[i]];
			int kake = par[i] + 1;
			if(tmp + 100 * now.FI * kake >= g){
				ll seica = (g - tmp + (kake*100) - 1) / (kake*100);
				tmp += seica * 100 * kake;
				ret += seica;
				break;
			}
			tmp += 100 * now.FI * kake + now.SE;
			ret += now.FI;
			if(tmp >= g)break;
			DBG(cout << "     " << tmp << endl;)
		}
		if(tmp >= g)ans = min(ans,ret);
	}while(next_permutation(ALL(par)));
	
	cout << ans << endl;
			
	
	return 0;
}


Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10, M = 2e5 + 10;

int d[N], u[M], v[M];
vector<int> g[N];

void dfs(int u, int wt, string& colors, char c);

int main() {
	fast_cin();
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> d[i];
	}
	for (int i = 1; i <= m; ++i) {
		cin >> u[i] >> v[i];
		g[u[i]].pb(v[i]);
		g[v[i]].pb(u[i]);
	}
	vector<int> ids(n);
	iota(ids.begin(), ids.end(), 1);
	sort(ids.begin(), ids.end(), [&] (int i, int j) {
		return tie(d[i], i) < tie(d[j], j);
	});
	for (int i = 1; i <= n; ++i) {
		sort(g[i].begin(), g[i].end(), [&] (int x, int y) {
			return tie(d[x], x) < tie(d[y], y);
		});
	}
	string colors(n, 'A');
	for (auto& i : ids) {
		if (d[g[i][0]] > d[i]) {
			cout << -1 << endl;
			return 0;
		} else if (d[g[i][0]] < d[i]) {
			continue;
		} else if (colors[i - 1] == 'A') {
			dfs(i, d[i], colors, 'B');
		}
	}
	for (int i = 0; i < n; ++i) {
		if (colors[i] == 'A') {
			colors[i] = 'B';
		}
	}
	cout << colors << '\n';
	for (int i = 1; i <= m; ++i) {
		if (colors[u[i] - 1] == colors[v[i] - 1]) {
			cout << max(1, abs(d[u[i]] - d[v[i]])) << '\n';
		} else {
			cout << max(d[u[i]], d[v[i]]) << '\n';
		}
	}
}

void dfs(int u, int wt, string& colors, char c) {
	colors[u - 1] = 'B' ^ 'W' ^ c;
	for (auto& v : g[u]) {
		if (d[v] > wt) {
			break;
		} else if (colors[v - 1] == 'A') {
			dfs(v, wt, colors, colors[u - 1]);
		}
	}
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int N; cin >>N;
  vector<int> L(N);
  rep(i,0,N) cin >>L[i];
  sort(L.begin(),L.end());
  int ans=0;
  rep(i,0,N) {
    rep(j,i+1,N) {
      rep(k,j+1,N) {
        set<int> s{L[i],L[j],L[k]};
        if ( (s.size()==3) and (L[i]+L[j]>L[k]) ) ans++;
      }
    }
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

int N,M;
cin>>N>>M;
tuple<int,int,int> data[M];
for(int i=0;i<M;i++){
    int p,y;
    cin>>p>>y;
    data[i]=make_tuple(y,p,i);
}
sort(data,data+M);
int cnt[N+1];
fill(cnt,cnt+N+1,0);
pair<int,int> id[M];
for(int i=0;i<M;i++){
    int y,p,idx;
    tie(y,p,idx)=data[i];
    cnt[p]++;
    id[idx]=make_pair(p,cnt[p]);
}
for(int i=0;i<M;i++){
    cout<<setw(6)<<setfill('0')<<id[i].first;
    cout<<setw(6)<<setfill('0')<<id[i].second<<endl;
}


    return 0;
}

Measured memory_bytes: 3840
a, b = [int(i) for i in input().split()]

z = 0

def gcd(x,y):
    if x<y:
        z=x
        x=y
        y=z

    while x%y !=0:
        z=x%y
        x=y
        y=z
        gcd(x,y)
    return y

print(gcd(a,b))

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

int d[1000005];

void Eratosthenes(int arr[], int n) {
	for(int i = 0; i <= n; i++){
		arr[i] = 1;
	}
	double sqrtNum = sqrt(n);
	for( int i = 2; i < sqrtNum; i++ ) {
		if ( arr[i] == 1 ) {
			for( int j = 0; i * (j + 2) <= n; j++ ) {
				arr[i *(j + 2)] = i;
			}
		}
	}
}

int gcd(int a, int b) {
  int tmp;
  while ( a%b != 0 ) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

int main() {
  Eratosthenes(d, 1000001);
  int n;
  cin >> n;
  int a[n];
  for ( int i = 0; i < n; i++ ) { cin >> a[i]; }
  
  string ans = "not coprime";
  //-- check "setwise coprime"
  int all_gcd = a[0];
  for ( int i = 1; i < n; i++ ) {
    all_gcd = gcd(all_gcd, a[i]);
  }
  if ( all_gcd == 1 ) { ans = "setwise coprime"; }
  //-- check "pairwise coprime"
  bool ok = true;
  for ( int i = 0; i < n; i++ ) {
    if ( a[i] == 1 ) { continue; }
    int now = a[i];
    while ( ok ) {
      if ( d[now] <= 0 && !(d[now] == -i) ) { ok = false; break; }
      if ( d[now] == 1 ) { d[now] = -i; break; }
      now /= d[now];
    }
  }
  if ( ok ) { ans = "pairwise coprime"; }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11380
from collections import deque
s=list(input())
K=int(input())
#max(K)=5でaaaaaはa,aa,aaa,aaaa,aaaaaの順
#よって5文字まで取れば良い
d=deque()
for i in range(len(s)):
    d.append(s[i])
comp=[]
#print(d)
for i in range(len(s)):
    buf=deque()
    for j in range(len(d)):
        v=d.popleft()
        buf.append(v)
        if j<5:
            comp.append("".join(buf))
    d=deque()
    for j in range(len(buf)):
        d.append(buf[j])
    d.popleft()
comp=list(set(comp))
comp.sort()
print(comp[K-1])

Measured memory_bytes: 51548
// A - Payment
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    while(n > 1000){
        n-=1000;
    }
    cout << 1000-n << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s=sc.nextLine();
for(int i=0; i<s.length(); i++){
	char c = s.charAt(i);
	if(Character.isLowerCase(c)){
		System.out.print(Character.toUpperCase(c));
	}else{
		System.out.print(Character.toLowerCase(c));
	}
}System.out.println();
}
}

Measured memory_bytes: 17320
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int> ans;
void atch(int n,int a,int b,int c,int d){
    pair<int,int> p1(a,b),p2(b,c),p3(c,d),p4(d,a);
    ans[p1]=ans[p2]=ans[p3]=ans[p4]=n;
}
void prp(int q[]){
    atch(q[1],q[5],q[4],q[2],q[3]);
    atch(q[2],q[4],q[6],q[3],q[1]);
    atch(q[3],q[1],q[2],q[6],q[5]);
    atch(q[4],q[5],q[6],q[2],q[1]);
    atch(q[5],q[1],q[3],q[6],q[4]);
    atch(q[6],q[3],q[2],q[4],q[5]);
}
int main()
{   
    int q[7],n,a,b;
    for(int i=1;i<=6;i++)
        cin>>q[i];
    prp(q);
    cin>>n;
    pair<int,int> p;
    while(n--){
        cin>>p.first>>p.second;
        cout<<ans[p]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[1000],n;
int main()
{
	int p,q,r,min1,min2;
	scanf("%d%d%d",&p,&q,&r);
	printf("%d\n",min(p+q,min(q+r,p+r)));
	return 0;
}

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

int main() {
	int n, m;
    cin >> n >> m;
    vector<int> v(m);
    
    int a;
    for(int i = 0; i < m; i++) {
    	cin >> a;
        v.at(i) = a;
    }
    
    for(int i = 0; i < m; i++) {
    	n -= v.at(i);
    }
    
    if(n < 0) {
    	cout << -1 << endl;
    }
    else {
    	cout << n << endl;
    }
}

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

int main(){
  int i,j,n,m,dp[1001][1001],d[1001],c[1001];

  cin >> n >> m;

  for(i = 0; i < n; i++){
    cin >> d[i];
  }

  for(j = 0; j < m; j++){
    cin >> c[j];
  }

  for(j = 0; j <=m; j++){
    dp[0][j]=0;
  }

  for(i =1; i <=n; i++){
    dp[i][0]=1000000000;
  }
  
  for(i = 1; i <= n; i++){
    for(j = 1; j <= m; j++){
      dp[i][j]=min(dp[i-1][j-1]+d[i-1]*c[j-1],dp[i][j-1]);
    }
  }
 
 
  cout << dp[n][m] << endl;
  
  return 0;
}

Measured memory_bytes: 4836
import sys
input = sys.stdin.readline

from operator import itemgetter

n = int(input())
work = []
for i in range(n):
	a, b = map(int, input().split())
	c = b-a
	work.append([a, b, c]) # [かかる時間, 終わらせる時間, 始めないといけない時間]
work.sort(key = itemgetter(1))
# print(work)

time = 0
for item in work:
	# print(item, time)
	if time <= item[2]:
		time += item[0]
	else:
		print("No")
		exit()
print("Yes")


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

using namespace std;

int a, b;

int main() {
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero";
        return 0;
    }
    if (b < 0) {
        if ((abs(a) - abs(b) + 1) % 2 == 0) {
            cout << "Positive";
        }
        else {
            cout << "Negative";
        }
    }
    else if (a > 0) {
        cout << "Positive";
    }
}


Measured memory_bytes: 256
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 305;

int32_t main(){
    FastIO;
    int n, k;cin >> n >> k;
    // dp[i] -> TRUE if the first player wins if there are i stones remaining
    // it isn't about who picked what stone but the current state is how many stones are remaining
    // and who is currently picking the stone.
    vc <ll> arr(n);
    for(int i=0; i<n; i++) {
        cin >> arr[i];
    }
    vc <int> dp(k+1, 0);
    for(int stones = 0; stones <=k; stones++) {
        for(auto i: arr) {
            if(stones >= i) {
                if(!dp[stones-i]) dp[stones]=1;
            }
        }
    }
    // cout << dp << endl;
    if (dp[k]) cout << "First\n";
    else cout << "Second\n";
    return 0;
}


Measured memory_bytes: 640
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int[] a = new int[n];

    int max = Integer.MIN_VALUE;
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      max = Math.max(max, a[i]);
    }

    int lTarget = max / 2;
    int gTarget = (max + 1) / 2;

    int diff = Integer.MAX_VALUE;
    int index = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] == max) continue;
      int d = Math.min(Math.abs(lTarget - a[i]), Math.abs(gTarget - a[i]));
      if (d < diff) {
        diff = d;
        index = i;
      }
    }

    os.println(max + " " + a[index]);
  }
}


Measured memory_bytes: 49568
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;
// typedef longlong ll;


int main() {
    double n,m;
    cin >> n >> m;
    vector<int> price(n);
    int total =0;
    for (int i=0;i<n;i++){
        cin >> price.at(i);  
        total+= price.at(i);
    }
    sort(price.begin(),price.end(),greater<int>());
    bool can = true;
    for (int i=0;i<m;i++){
        double a;
        a = double(total/4.f/m);
        if (price.at(i)<a){
            can = false;
        }
    }
    if (can)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	ll N, M, K;
	string S;
	ll A, B, C;

	cin >> A >> B >> C;


	if (A < C && C < B) {
		cout << "Yes" << endl;
	}
	else if (A > C && C > B) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}



	
	return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
	if(a==0):
		return b
	else:
		return gcd(b%a,a)

a,b,c,d=map(int,input().split())
ans1=b//c-(a//c)
if(a%c==0):
	ans1+=1
ans2=b//d-(a//d)
if(a%d==0):
	ans2+=1

lcm=(c*d)//(gcd(min(c,d),max(c,d)))
ans3=b//lcm-(a//lcm)
if(a%lcm==0):
	ans3+=1
print(b-a+1-(ans1+ans2-ans3))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ms(x, y) memset(x, y, sizeof(x))
#define pb push_back
#define pr make_pair
#define fi first
#define se second
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAX_N = 1e5 + 5;
int a[MAX_N], l[MAX_N], r[MAX_N];
int main() {
    int n, k, L = -1, R = -1, ans = 1e9;
    ms(l, -1), ms(r, -1);
    l[0] = 0, r[0] = 0;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if (a[i] < 0) L = i;
        else if (a[i] > 0) {
            if (R < 0) R = i;
        }
        else k--;
    }
    for (int i = 0; i < k; i++) {
        if (L >= 0 && L - i >= 0) l[i + 1] = -a[L - i];
        if (R >= 0 && R + i < n) r[i + 1] = a[R + i];
    }
    for (int i = 0; i <= k; i++) {
        if (l[i] < 0 || r[k - i] < 0) continue;
        ans = min(ans, l[i] + r[k - i] + min(l[i], r[k - i]));
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1408
import sys
input = sys.stdin.readline


def main():
    n_obss, n_roads = map(int, input().split())
    elevations = list(map(int, input().split()))

    is_good_obs = [True for _ in range(n_obss)]

    roads = (list(map(int, input().split())) for _ in range(n_roads))

    for road in roads:
        
        idx_a = road[0] - 1
        idx_b = road[1] - 1

        e_a = elevations[idx_a]
        e_b = elevations[idx_b]

        if e_a > e_b:
            is_good_obs[idx_b] = False
        elif e_a < e_b:
            is_good_obs[idx_a] = False
        else:
            is_good_obs[idx_a] = False
            is_good_obs[idx_b] = False

    print(sum(is_good_obs))


if __name__ == "__main__":
    main()


Measured memory_bytes: 20220
var
  x,y,z,a,b:longint;
begin
  read(x,a,b);
  if x>a then y:=x-a
  else y:=a-x;
  if x>b then z:=x-b
  else z:=b-x;
 if y>z then write('B')
 else write('A');
end.

Measured memory_bytes: 128
<?php
fscanf(STDIN,"%d",$n);
for($i = 1; $i <= $n; $i++){
    switch(true){
        case ($i % 2 !== 0):
        $oddNum[] = odd;
        break;
        case ($i % 2 === 0):
        $evenNum[] = even;
        break;
    }
}
$oddResult = count($oddNum);
$probability = (int)$oddResult/(int)$n;
echo $probability;
  ?>

Measured memory_bytes: 3828
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(Int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(Int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1LL<<50);

void solve(long long a, long long b, long long c, long long d){
  cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long a;
  scanf("%lld",&a);
  long long b;
  scanf("%lld",&b);
  long long c;
  scanf("%lld",&c);
  long long d;
  scanf("%lld",&d);
  solve(a, b, c, d);
  return 0;
}


Measured memory_bytes: 3760
#include <cstdio>
int pro[101];

int main(){
	int n;scanf("%d", &n);
	for(int i = 1;i <= n;i++){
		int x = i, f = 0;
		if(x % 10 == 3)f = 1;
		while(x>10){x /= 10;if(x % 10 == 3)f = 1;}
		if(i%3==0||f)printf(" %d", i);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 2668
A = 5.times.map{gets.to_i}

ans = 10**18
5.times do |i|
  c = 0
  5.times do |j|
    if i == j
      c += A[j]
    else
      c += (A[j] + 9) / 10 * 10
    end
  end
  ans = [ans, c].min
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a=0;
  int b=0;
  int N=0;
  cin>>a>>b;
  if(b>=100){
    a=1000*a;
  }
  else if(b>=10){
    a=100*a;
  }
  else{
    a=10*a;
  }
  N=a+b;
  bool judge=0;
  for(int i=0; i<1000; i++){
    if(N==i*i){
      judge=1;
      cout<<"Yes"<<endl;
    }
  }
  if(judge==0){
    cout<<"No"<<endl;
  }
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  for (int w,h; cin >> w >> h, w && h; ) {
    vector<vector<int>> f(h, vector<int>(w));
    rep (i, h) {
      rep (j, w) {
        cin >> f[i][j];
      }}
    int cx = 0;
    rep (i, h) {
      rep (j, w) {
        if (f[i][j] == 0) continue;
        ++cx;

    stack<pair<int, int>> s;
    s.push(cons(i, j));

    while (!s.empty()) {
      auto x = s.top(); s.pop();
      if (car(x) < 0) continue;
      if (car(x) >= h) continue;
      if (cdr(x) < 0) continue;
      if (cdr(x) >= w) continue;
      if (f[car(x)][cdr(x)] == 0) continue;

      f[car(x)][cdr(x)] = 0;

      s.push(cons(car(x) + 1, cdr(x)));
      s.push(cons(car(x) - 1, cdr(x)));
      s.push(cons(car(x), cdr(x) + 1));
      s.push(cons(car(x), cdr(x) - 1));
      s.push(cons(car(x) + 1, cdr(x) - 1));
      s.push(cons(car(x) - 1, cdr(x) + 1));
      s.push(cons(car(x) + 1, cdr(x) + 1));
      s.push(cons(car(x) - 1, cdr(x) - 1));
    }

      }}

    cout << cx << endl;

  }
  return 0;
}

Measured memory_bytes: 1292
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
# def yaku(m):
#         ans = []
#         i = 1
#         while i*i <= m:
#             if m % i == 0:
#                 j = m // i
#                 ans.append(i)
#                 if j != i:
#                     ans.append(j)
#             i += 1
#         ans = sorted(ans)
#         return ans
a,b = readInts()
# print(yaku(a))
# print(yaku(b))
g = gcd(a,b)
# print(g)
# print(yaku(g))
def soinsu(n):
    dic = defaultdict(int)
    i = 2
    while i*i <= n:
        if n%i == 0:
            dic[i] += 1
            n //= i
        else:
            i += 1
    if n!= 1:
        dic[n] += 1
    return dic
dic = soinsu(g)
cnt = 1 # 1
for k,v in dic.items():
    cnt += 1
print(cnt)
# a //= g
# b //= g
# print(a,b)


Measured memory_bytes: 5048
#include<stdio.h>

int main(){
  int t[201], h[201], tres, hres, n, num, i, j, order, tmp;

  while(1){
    scanf("%d", &n);
    if(n==0) break;
    
    for(i=1; i<2*n+1; i++){
      t[i]=0;
      h[i]=0;
    }
    for(i=0; i<n; i++){
      scanf("%d", &num);
      t[num]=1;
    }
    for(i=1; i<2*n+1; i++){
      if(t[i]==0){
	h[i]=1;
      }
    }
    
    tres=hres=n;
    order=0;
    tmp=0;
    while(1){
      if(tres==0 || hres==0) break;
      j=1;
      if(tmp!=0){
	if(order==0){
	  order=1;
	}else{
	  order=0;
	}
      }
      for(i=j; i<2*n+1; i++){
	if(tres==0 || hres==0) break;
	if(order==0){
	  if(t[i]==1){
	    t[i]=0;
	    tres--;
	    order=1;
	    j=i;
	    continue;
	  }
	}else{
	  if(h[i]==1){
	    h[i]=0;
	    hres--;
	    order=0;
	    j=i;
	    continue;
	  }
	}
	tmp=1;
      }
    }    
    printf("%d\n%d\n", hres, tres);
  }
  return 0;
}

Measured memory_bytes: 604
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        int[] num = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        Console.WriteLine("{0} {1}", num[0] * num[1], num[0] * 2 + num[1] * 2);
    }
}

Measured memory_bytes: 9536
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, p;  cin >> n >> p;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    vector<vector<long long> > dp(n+1, vector<long long>(2, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2; j++) {
            dp[i+1][(a[i] + j) % 2] += dp[i][j];
            dp[i+1][j] += dp[i][j];
        }
    }
    cout << dp[n][p] << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;

public class Main {
	static char[][] c;
	static int[][] d;
	static Queue<Long> que;
	static long m = 10000000L;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		sa = br.readLine().split(" ");
		int x1 = Integer.parseInt(sa[0]) - 1;
		int y1 = Integer.parseInt(sa[1]) - 1;
		int x2 = Integer.parseInt(sa[2]) - 1;
		int y2 = Integer.parseInt(sa[3]) - 1;
		c = new char[h][w];
		for (int i = 0; i < h; i++) {
			c[i] = br.readLine().toCharArray();
		}
		br.close();

		d = new int[h][w];
		for (int i = 0; i < h; i++) {
			Arrays.fill(d[i], Integer.MAX_VALUE);
		}
		que = new ArrayDeque<>();
		que.add(x1 * m + y1);
		d[x1][y1] = 0;
		while (!que.isEmpty()) {
			long cur = que.poll();
			int cx = (int) (cur / m);
			int cy = (int) (cur % m);
			int alt = d[cx][cy] + 1;

			int end = Math.max(cx - k, 0);
			for (int i = cx - 1; i >= end; i--) {
				if (exec(i, cy, alt)) {
					break;
				}
			}

			end = Math.min(cx + k, h - 1);
			for (int i = cx + 1; i <= end; i++) {
				if (exec(i, cy, alt)) {
					break;
				}
			}

			end = Math.max(cy - k, 0);
			for (int i = cy - 1; i >= end; i--) {
				if (exec(cx, i, alt)) {
					break;
				}
			}

			end = Math.min(cy + k, w - 1);
			for (int i = cy + 1; i <= end; i++) {
				if (exec(cx, i, alt)) {
					break;
				}
			}
		}

		if (d[x2][y2] == Integer.MAX_VALUE) {
			System.out.println(-1);
		} else {
			System.out.println(d[x2][y2]);
		}
	}

	static boolean exec(int x, int y, int alt) {
		if (c[x][y] == '@' || alt > d[x][y]) {
			return true;
		}
		if (alt == d[x][y]) {
			return false;
		}
		que.add(x * m + y);
		d[x][y] = alt;
		return false;
	}
}


Measured memory_bytes: 62332
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#define N 100005
using namespace std;
struct with {
	int w;
	long long d;
} dt[N];
map<long long, int> chk;
int n;
int parent[N],subn[N];
long long d[N];
long long sum[N];
bool cmp(with i, with j) {
	return i.d < j.d;
}
int main() {
	scanf("%d", &n);
	int i;
	for (i = 1; i <= n; i++) {
		scanf("%lld", &d[i]);
		dt[i].d = d[i]; dt[i].w = i;
		subn[i] = 1;
	}
	sort(dt + 1, dt + 1 + n, cmp);
	sort(d + 1, d + 1 + n);
	for (i = 1; i <= n; i++) chk[d[i]] = i;
	bool imp = false;
	for (i = n ; i >= 2; i--) {
		int adjacent=0;
		adjacent = chk[d[i] - n + 2 * subn[i]];
		parent[i] = adjacent;
		subn[adjacent]+=subn[i];
		if (parent[i] == 0 || parent[i]==i) {
			imp = true; break;
		}
	}
	for (i = n; i >= 2; i--) {
		int up = parent[i];
		sum[up] += sum[i] + subn[i];
	}
	if (sum[1] != d[1]) imp = true;
	if (imp) printf("-1");
	else {
		for (i = 2; i <= n; i++) {
			printf("%d %d\n", dt[parent[i]].w,dt[i].w);
		}
	}
	return 0;
}

Measured memory_bytes: 11520