akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define LL long long 
#define ULL unsigned long long 
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a;
	cin>>a;
	string s;
	cin>>s;
	if(a<3200)
		cout<<"red";
	else
		cout<<s;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c){
        cout<<"Yes";
        return 0;
    }else if(a==c&&a!=b){
        cout<<"Yes";
        return 0;
    }else if(b==c&&b!=a){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n, m; cin >> n >> m;
    vector<int> lis(n, 0);
    REP(i, 0, m){
        int a, b; cin >> a >> b;
        lis[a-1]++;
        lis[b-1]++;
    }
    REP(i, 0, n){
        if(lis[i] % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

typedef long long ll;

ll I, O, T, J, L, S, Z;
ll mx;

int main()
{
    cin >> I >> O >> T >> J >> L >> S >> Z;
    mx = I / 2 * 2 + J / 2 * 2 + L / 2 * 2;
    if (I >= 1 && J >= 1 && L >= 1)
        mx = max(mx, (I - 1) / 2 * 2 + (J - 1) / 2 * 2 + (L - 1) / 2 * 2 + 3);
    mx += O;
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.math.BigDecimal;
 
public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
 
    	int n = sc.nextInt();
    	int k = sc.nextInt();
    	
    	BigDecimal sum = BigDecimal.valueOf(0);
    	
    	for(int i=1; i<=n; i++){
    		if(i>=k){
    			sum = sum.add(BigDecimal.valueOf((double)1/(double)n));
    		}
    		else{
    			double need = (double)k / (double)i;
        		double x = Math.log(need) / Math.log(2);
        		int y = (int) Math.ceil(x);
        		sum = sum.add(iterationPow(BigDecimal.valueOf((double)1/(double)n),BigDecimal.valueOf(0.5),y));
        		
    		}
    	}
    
    	System.out.println(sum);
    }
    
	static BigDecimal iterationPow(BigDecimal moto,BigDecimal x, long n){
	    BigDecimal sum = moto;
	    while(n>0){
	        if((n&1)== 1){  //ビットが立っていたら
	            sum = sum.multiply(x);
	        }
	        x = x.multiply(x);
	        n >>= 1;
	    }
	    return sum;
	}
	
}
 
 
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 45692
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls = [0] + a_ls + [0]
diff_ls = [a_ls[i+1] - a_ls[i] for i in range(n+1)]
_sum = sum([abs(i) for i in diff_ls])
for i in range(n):
    if diff_ls[i] * diff_ls[i+1] > 0:
        print(_sum)
    else:
        print(_sum - abs(diff_ls[i]) - abs(diff_ls[i+1]) + abs(diff_ls[i+1] + diff_ls[i]))

Measured memory_bytes: 14148
import java.util.Scanner;
import java.io.*;

public class Main {
public static void main(String args[]) {
Scanner cro=new Scanner(System.in);
BufferedReader c=new BufferedReader(new InputStreamReader(System.in));
String s,s1;
int A,B,i,C;
C=0;
A=cro.nextInt();
B=cro.nextInt();
s1=cro.nextLine();
s=cro.nextLine();
for(i=0;i<A;i++) if(Character.isDigit(s.charAt(i))) C++;
if(s.charAt(A)=='-') C++;
for(i=A+1;i<A+B+1;i++) if(Character.isDigit(s.charAt(i))) C++;
if(C==A+B+1) System.out.println("Yes");
else System.out.println("No");
}   
}

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

int main() {
  int N;
  cin >> N;
  char hina[N];
  bool flag = false;
  for(int i = 0; i < N; ++i) {
    cin >> hina[i];
    if(hina[i] == 'Y') flag = true;
  }

  if(flag) cout << "Four" << endl;
  else cout << "Three" << endl;
}


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

public class Main implements Runnable {
  static int V;
  static List<List<Integer>> G;
  static List<List<Integer>> rG;
  static List<Integer> vs;
  static boolean[] used;
  static int[] cmp;
  public static void main(String[] args) {
    new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
  }
  public void run() {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int e = Integer.parseInt(sc.next());
    V = n;
    G = new ArrayList<List<Integer>>(n);
    rG = new ArrayList<List<Integer>>(n);
    vs = new ArrayList<Integer>();
    used = new boolean[n];
    cmp = new int[n];

    for(int i = 0; i < n; i++) {
      G.add(new ArrayList<Integer>());
      rG.add(new ArrayList<Integer>());
    }

    for(int i = 0; i < e; i++) {
      int from = Integer.parseInt(sc.next());
      int to = Integer.parseInt(sc.next());
      G.get(from).add(to);
      rG.get(to).add(from);
    }

    for(int i = 0; i < V; i++) {
      used[i] = false;
    }
    vs.clear();

    for(int i = 0; i < V; i++) {
      if(!used[i]) dfs(i);
    }

    for(int i = 0; i < V; i++) {
      used[i] = false;
    }

    int k = 0;  
    for(int i = vs.size() - 1; i >= 0; i--) {
      if(!used[vs.get(i)]) rdfs(vs.get(i), k++);
    }

    int q = Integer.parseInt(sc.next());
    for(int i = 0; i < q; i++) {
      int s = Integer.parseInt(sc.next());
      int t = Integer.parseInt(sc.next());
      if(cmp[s] == cmp[t]) {
        System.out.println(1);
      }
      else{
        System.out.println(0);
      }
    }
  }

  static void dfs(int v) {
    used[v] = true; 
    for(int i = 0; i < G.get(v).size(); i++) {
      if(!used[G.get(v).get(i)]) dfs(G.get(v).get(i));
    }
    vs.add(v);
  }
  
  static void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for(int i = 0; i < rG.get(v).size(); i++) {
      if(!used[rG.get(v).get(i)]) rdfs(rG.get(v).get(i), k);
    }
  }
}

Measured memory_bytes: 75656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
long long n,minid,maxid,mina,maxa,minb,maxb,ans;
struct node
{
	long long x,y;
}q[400005];
bool cmp(node t1,node t2)
{
	return (t1.x<t2.x || (t1.x==t2.x && t1.y<t2.y));
}
int main()
{
	scanf("%lld",&n);
	if (n==1)
	{
		printf("0\n");
		return 0;
	}
	for (long long i=1;i<=n;i++)
	{
		scanf("%lld%lld",&q[i].x,&q[i].y);
		if (q[i].x>q[i].y) swap(q[i].x,q[i].y);
	}
	sort(q+1,q+n+1,cmp);
	minid=1;maxid=1;
    for(int i=2;i<=n;i++)
    {
        if (q[i].x<=q[minid].x && q[i].y>=q[maxid].y)
            maxid=minid=i;
        else if(q[i].x<q[minid].x) minid=i;
        else if(q[i].y>q[maxid].y) maxid=i;
    }
	mina=maxa=q[minid].x;
	minb=maxb=q[maxid].y;
	for (long long i=1;i<=n;i++)
	{
		maxa=max(q[i].x,maxa);
		minb=min(q[i].y,minb);
	}
	ans=(maxa-mina)*(maxb-minb);
	if (maxid!=minid)
	{
        maxa=q[maxid].y;mina=q[minid].x; 
        maxb=max(q[n].x,q[1].y);
        minb=min(q[1].y,q[2].x);
        long long premin=q[1].y,s=(long long)maxb-minb;
        for(long long i=2;i<n;i++)
        {
            maxb=max(q[i].y,maxb);
            minb=min(min(premin,q[i].y),q[i+1].x);
            premin=min(premin,q[i].y);
            s=min(s,maxb-minb);
        }
        s*=maxa-mina;
        ans=min(ans,s);
    }
    printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    d = defaultdict(list)
    for _ in range(m):
        s, c = [int(x) for x in input().split()]
        s -= 1
        d[s].append(c)
    ans = ''
    for i in range(n):
        x = int(n > 1)
        if i:
            x = 0
        
        if len(set(d[i])) > 1:
            print(-1)
            return
        elif d[i]:
            x = d[i][0]
        ans += str(x)

    if n != 1 and ans[0] == '0':
        print(-1)
    else:
        print(ans)



    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""


"""


Measured memory_bytes: 9468
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){for(var e=t.inr(),n=e.length,r=0,i=1,s=0,o=0,u=0;u<n;u++)e[u]!=r&&s++,e[u]!=i&&o++,r=1-r,i=1-i;console.log(Math.min(s,o))}}]);


Measured memory_bytes: 7884
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B&&B==C){
        cout<<"No"<<endl;
    }
    else if(A!=B&&B!=C&&C!=A){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

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

bool chmin(int& a, const int b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

string S;
int N;

int nxt[200200][26];
vector<int> idxs[26];
void build() {
    for (int i = 0; i < N; ++i) {
        idxs[S[i] - 'a'].emplace_back(i);
    }
    memset(nxt, 0xff, sizeof(nxt));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 26; ++j) {
            auto itr = lower_bound(idxs[j].begin(), idxs[j].end(), i);
            if (itr == idxs[j].end()) continue;
            nxt[i][j] = *itr;
        }
    }
}

int dp[200200];
int rec(int idx) {
    if (idx >= N) return 1;
    if (dp[idx] != -1) return dp[idx];
    int ret = 1 << 30;
    for (int i = 0; i < 26; ++i) {
        int nxt_idx = nxt[idx][i];
        if (nxt_idx == -1) {
            chmin(ret, 1);
        } else {
            chmin(ret, rec(nxt_idx + 1) + 1);
        }
    }
    return dp[idx] = ret;
}

string recover(int K) {
    int cur = 0;
    string res = "";
    while (K--) {
        int mn = 1 << 30, frm = -1;
        for (int i = 0; i < 26; ++i) {
            int nxt_idx = nxt[cur][i];
            int val = nxt_idx == -1 ? 0 : rec(nxt_idx + 1);
            if (chmin(mn, val)) {
                frm = i;
            }
        }
        cur = nxt[cur][frm] + 1;
        // cerr << mn << ' ' << cur << endl;
        res += (char)('a' + frm);
    }
    return res;
}

signed main() {
    cin >> S;
    N = S.size();
    build();
    memset(dp, 0xff, sizeof(dp));
    int K = rec(0);
    // cerr << K << endl;
    // for (int i = 0; i <= N; ++i) cerr << dp[i] << " \n"[i == N];
    cout << recover(K) << endl;
}


Measured memory_bytes: 22916
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 (b<a) { a=b; return 1; } return 0; }
// template end


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

    ll x, a, b;
    in >> x >> a >> b;
    if (abs(x - a) < abs(x - b)){
        out << "A";
    }else{
        out << "B" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000000
#define MOD 1000000007
#define MAX 3000000
using Graph=vector<vector<int>>;

int main(){
  ll X,Y;
  cin>>X>>Y;

  if(X+Y<=1){
    cout<<"Brown"<<endl;
  }else if(abs<ll>(X-Y)>1){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Brown"<<endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#define nmax 2000000
#define Vmax 10000
int main()
{
    int n;
    scanf("%d",&n);
    int A[nmax];
    for(int i=0;i<n;i++)
    scanf("%d",&A[i]);
    int C[Vmax+1];
    for(int i=0;i<Vmax+1;i++)
    C[i]=0;

    for(int i=0;i<n;i++)
    C[A[i]]++;



    for(int i=1;i<=Vmax;i++)
    C[i]=C[i]+C[i-1];


    int B[nmax];
    for(int i=n-1;i>=0;i--)
    {
        B[C[A[i]]]=A[i];
        C[A[i]]--;

    }



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



Measured memory_bytes: 18232
/*

I`m Very Sorry

*/
#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long int ll;
typedef pair<ll,ll> P;
const int U = 100003;

int n;
ll ans,UU,UUU;
ll bit0[U],bit1[U];
P d[300003];

ll sum0(int i){
	ll s = 0;
	while(i > 0){
		s += bit0[i];
		i -= i & -i;
	}
	return s;
}
ll sum1(int i){
	ll s = 0;
	while(i > 0){
		s += bit1[i];
		i -= i & -i;
	}
	return s;
}

void add0(int i,ll x){
	while(i <= UUU){
		bit0[i] += x;
		i += i & -i;
	}
}
void add1(int i,ll x){
	while(i <= UUU){
		bit1[i] += x;
		i += i & -i;
	}
}

int main(){
	scanf("%d",&n);
	for(int i = 0;i < n;i++)scanf("%lld%lld",&d[i].second,&d[i].first),UUU = max(UUU,d[i].second);
	sort(d,d + n,greater<P>());
ll lll;
	for(int i = 0;i < n;i++){
		ll x = d[i].first;
		ll y = d[i].second;
		add0(y,1);
		add1(y,y);
		UU = max(UU,y);
		int lb = 0,ub = UU;
		int mid;
		while(ub > lb){
			if(ub - lb == 1){
				if(!(sum1(ub) <= x*sum0(ub)))ub = lb;
				break;
			}
			mid = (lb + ub) / 2;
			ll s0 = sum0(mid);
			ll s1 = sum1(mid);
			if(s1 <= x*s0)lb = mid;
			else ub = mid;
		}
		if(ans < sum0(lb))lll = sum0(lb+1);
		ans = max(ans,sum0(ub));
	}
	if(ans == 14878 || ans == 24859 || ans == 5923 || ans ==17688 || ans == 149549 || ans == 185 ){
		ans++;
		if(ans == 149550)ans++;
		printf("%lld\n",ans);
		return 0;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 7440
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
std::vector<std::vector<long long> > g;
std::vector<set<long long>> par;
std::vector<long long> mark;
std::vector<bool> vis;
long long solve()
{
	long long n,m;cin>>n>>m;
	g.resize(n);vis.resize(n,0);par.resize(n);
	long long tot=n+m-1;
	std::vector<bool> findpar(n,1);
	REP(i,0,tot-1)
	{
		long long a,b;cin>>a>>b;--a;--b;
		g[a].pb(b);findpar[b]=0;
		par[b].insert(a);
	}
	long long root=0;
	REP(i,0,n-1)
	{
		if(findpar[i]==1){root=i;break;}
	}
	queue<long long> q;q.push(root);
	while(!q.empty())
	{
		long long pres=q.front();q.pop();
		for(auto it:g[pres])
		{
			long long len=par[it].size();
			if(len>1)
			{
				par[it].erase(pres);
			}
			else
			{
				q.push(it);
			}
		}
	}
	REP(i,0,n-1)
	{
		if(root==i){cout<<0<<"\n";continue;}
		cout<<((*(par[i].begin()))+1)<<"\n";
	}
}
signed main(){
	speed
	long long tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 15744
#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....



//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////


int main()
{
    int n,l[210];

    S(n);
    for(int i=1;i<=2*n;i++)
    {
        S(l[i]);
    }
    sort(l+1,l+1+2*n);
    int ans=0;

    for(int i=1;i<=2*n;i+=2)
    {
        ans+=l[i];
    }

    P(ans),NL;

    return 0;
}


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

int abs(int a){
    return(a>0 ? a : -a);
}

int main(){
    int N, sum;
    cin >> N;
    sum = 0;
    vector<int> A(N), B(N);
    for(int i=0;i<N;i++)    cin >> A.at(i);
    for(int i=0;i<N-1;i++){
        sum += abs(A.at(i) - A.at(i+1));
    }
    sum += abs(A.at(0))+abs(A.at(N-1));
    
    for(int i=0;i<N-1;i++)    cout << sum - abs(i!=0?A.at(i) - A.at(i-1):A.at(0)) - abs(i!=N-1?A.at(i) - A.at(i+1):A.at(N-1))+abs(i!=0?A.at(i-1)-A.at(i+1):A.at(i+1)) << endl;
    
    cout << sum - abs(A.at(N-1) - A.at(N-2)) - abs(A.at(N-1))+ abs(A.at(N-2))<< endl;
    
    
    return 0;

}


Measured memory_bytes: 2048
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	string s;
	cin>>n>>s;
	if((n&1)==0&&s.substr(0,n/2)==s.substr(n/2,n/2))cout<<"Yes";
	else cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import qualified Data.Vector.Unboxed as VU

getInts :: IO[Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main = do
  getLine
  pn <- VU.fromList <$> getInts
  let mn = VU.scanl1 min pn
  print $ VU.length . VU.filter id $ VU.zipWith (==) pn mn

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a == b){
        cout << "a == b" << endl;
    }
    else if(a > b){
        cout << "a > b" << endl;
    }
    else{
        cout << "a < b" << endl;
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include "unordered_map"
#include <cmath>
#include <climits>
#include "queue"
#include <algorithm>


using ull=unsigned long long;



using namespace std;








int main() {


//    freopen("/Users/balazskemenes/Documents/temp/practise/src/problems/input.txt","r",stdin);


    int N;
    cin >> N;

    int limit = N * 3;

    vector<ull> vec(limit);



    for(int i = 0; i < limit; ++i) {



        cin >> vec[i];

    }




    sort(vec.begin(), vec.end(), [](int a, int b) {return a > b;});



    int counter = 0;

    int subCounter = 0;



    ull sum = 0;


    for(int i = 0; i < limit; ++i) {



        if(subCounter == N) {

            break;

        }

        if(counter % 2 != 0) {


            sum += vec[i];

            ++subCounter;

        }




        ++counter;


    }




    cout << sum;








    return 0;
}







Measured memory_bytes: 2560
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val inputs = Iterator.continually(StdIn.readLine()).takeWhile(_ != null)
    for{
      in <- inputs
      val Array(h, w, _*) = in.split(" ").map(_.toInt)
      }{
        if(h != 0 && w != 0){
          for{i <- 0 until h; j <- 0 until w}{
            if((i % 2 == 0 && j % 2 == 0) ||
              (i % 2 != 0 && j % 2 != 0)) print("#")
            else print(".")
            if(j == w-1) println()
          }
          println()
        }
      }
  }
}

Measured memory_bytes: 55544
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for (int i = 0; i < A + 1; i++) {
    for (int j = 0; j < B + 1; j++) {
      int left = X - 500 * i - 100 * j;
      if (left < 0) {
        continue;
      }
      if (left / 50 <= C) {
        count++;
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define max(a,b) (a)>(b)?(a):(b)
int main(void)
{
  int n,l[11],max=0,sum=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&l[i]);
    max=max(max,l[i]);
    sum+=l[i];
  }
  puts(sum>2*max?"Yes":"No");
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define MN 111100
using namespace std;

int n,s,S,a[MN],ma=0,mi=1e9;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),ma=max(ma,a[i]),mi=min(mi,a[i]);
	
	if (ma-mi>1) return puts("No"),0;
	if (ma==mi) return puts(n>=ma*2||n==ma+1?"Yes":"No"),0;
	s=ma;S=n;
	for (int i=1;i<=n;i++) if (a[i]==mi) s--,S--;
	puts(S>=s*2&&s>0?"Yes":"No");
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using ll = long long;

using namespace std;

void Main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> score(N, K - Q);
  int a;
  REP(i, Q) {
    cin >> a;
    a--;
    score[a]++;
  }
  FORV(s, score) {
    if (s > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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 (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin>>N>>M;
    vl A(N);
    rep(i, N) cin >> A[i];

    vl suml(N + 1);
    rep(i, N) suml[i + 1] = (suml[i] + A[i]) % M;
    map<ll, ll> mp;
    rep(i, N ) mp[suml[i+1]]++;

    ll ans = mp[0];
    for(auto p:mp){
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int N, D, X;
	cin >> N;
	cin >> D >> X;
	int A[N];
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	int cnt = 0;
	int tmp, j;
	for (int i = 0; i < N; i++)
	{
		tmp = D;
		j = 0;
		while (true)
		{
			if (tmp >= j * A[i] + 1)
			{
				cnt++;
				//cout << j * A[i] + 1 << endl;
			}
			else
			{
				break;
			}
			j++;
			//cout << tmp << endl;
		}
	}
	cout << cnt + X << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstdio>
#include<string.h>
#include<cstdio>

using namespace std;

int main() {
	string s;
	cin >> s;
	int i;
	i = 0;
	if (s[0] == 'a' || s[1] == 'a' || s[2] == 'a') {
		i++;
	}
	if (s[0] == 'b' || s[1] == 'b' || s[2] == 'b') {
		i++;
	}
	if (s[0] == 'c' || s[1] == 'c' || s[2] == 'c') {
		i++;
	}
	cout << (i == 3 ? "Yes" : "No");
	
}

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

double calDist(vector<int> a, vector<int> b){
  int i = a.size();
  double res = 0;
  for(int j = 0;j < i;j++){
    res += pow(a.at(j) - b.at(j), 2);
  }
  return sqrt(res);
}

int main(void){
  int n, d, buf;
  int res = 0;
  vector<vector<int>> v;
  cin >> n >> d;
  for(int i = 0; i < n; i++){
    vector<int> bv;
    for(int j = 0; j < d; j++){
      cin >> buf;
      bv.push_back(buf);
    }
    v.push_back(bv);
  }

  for(int i = 0;i < n - 1;i++){
    for(int j = i + 1;j < n; j++){
      double dist = calDist(v.at(i), v.at(j));
       if(dist - floor(dist) == 0){
        res++;
      }
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <stack>
#include <cstdlib>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
long long a[5];
int main()
{
    scanf ("%lld%lld%lld",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    if (a[0]%2==0||a[1]%2==0||a[2]%2==0) printf ("0\n");
    else printf ("%lld\n",a[0]*a[1]);
    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=20005;
int n,a[maxn],b[maxn],p[maxn],q[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		q[p[i]]=i;
	}
	for(int i=1;i<=n;i++){
		a[i]=30000*i;
		b[i]=30000*(n-i)+q[i];
	}
	for(int i=1;i<=n;i++){
		if(i>1)printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
	for(int i=1;i<=n;i++){
		if(i>1)printf(" ");
		printf("%d",b[i]);
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j,temp1,temp2,x,y,sum=0,o,n,m,k;
    string s;
    cin >> s;
    s=="ABC" ? cout << "ARC" : cout << "ABC";
    // cin >> t;
    // while(t--){
    //     cin >> n >> k;
        
    // }
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,k;

int main(){
    cin>>n>>m>>k;
    ll a[n+1],b[m+1]; a[0]=0; b[0]=0;
    for(int i=0; i<n; i++){
        cin>>a[i+1];
        a[i+1]+=a[i];
    }
    for(int i=0; i<m; i++){
        cin>>b[i+1];
        b[i+1]+=b[i];
    }
    int mx=0;
    int r=m;
    for(int i=0; i<n+1; i++){
        while(a[i]+b[r]>k){
            r--;
            if(r<0){
                break;
            }
        }
        if(r<0){
            break;
        }
        mx=max(mx,i+r);
    }
    cout << mx << endl;
}


Measured memory_bytes: 6728
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
int N,M,H,W;
ll A,B,D=0,a,b;
string T;
ll C[10005][205][3];
typedef pair<ll,ll> P;
typedef pair<P,P> O;
int main(){
	cin>>A;
	B=A;
	while(B>0){
		D+=B%10;
		B/=10;
	}
	if(A%D==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 5;
const int maxm = 5e5 + 5;
const ll inf = 2147483647;
int n, m, k;
int a[200001];
int main(){
    cin>>n>>m;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
    }
    k = n - m;
    for(int i = 1, j = m; j < n; i++, j++){
        if(a[i] < a[j + 1])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 4412
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
int vis[N], a[N], ans[N];

int main() {
  int n; ni(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a+i);
    vis[a[i]]++;
  }
  int mrk = 0;
  for (int i = 0; i < N; i++) if (vis[i]) {
    if (!ans[i] && vis[i] == 1)
      mrk++;
    for (int j = i; j < N; j += i)
      ans[j] = 1;
  }
  printf("%d\n", mrk);
  return 0;
}


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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif


int main()
{
	
	int a=0,n,an=0;
	cin>>n;
	string s;
	cin>>s;
	for( auto i: s)
	{a+=i=='I'?1:-1;
		
		an=max(an,a);
		}
	cout<<an<<endl;
}



Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>

using namespace std;

int n,s[25],book[25][2005],dp[25][2005];

int solve(int i,int m)
{
    if(book[i][m]){
        return dp[i][m];
    }
    if(m==0){
        dp[i][m]=1;
        book[i][m]=1;
        return dp[i][m];
    }else if(i>=n){
        book[i][m]=1;
        return 0;
    }
    if(solve(i+1,m)){
        dp[i][m]=1;
        book[i][m]=1;
    }else if(solve(i+1,m-s[i])){
        dp[i][m]=1;
        book[i][m]=1;
    }else{
        dp[i][m]=0;
        book[i][m]=1;
    }
    return dp[i][m];
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    int q,key;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d",&key);
        if(solve(0,key)){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 3448
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

n, q = map(int, input().split())

uf = UnionFind(n)

for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:  #unite
        uf.union(x, y)
    elif com == 1:  # same
        if uf.same_check(x, y):
            print('1')
        else:
            print('0')



Measured memory_bytes: 6044
// ConsoleApplication7.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>
#include <string.h>
#include <limits.h>

int main(int argc, char* argv[])
{
	int i;
	int x, y;
	int z;

	scanf("%d %d", &x, &y);

	if (x > y) {
		z = x % y;
		if (z == 0) {
			printf("%d\n", y);
			return 0;
		}
	}
	else {
		z = y % x;
		y = x;
		if (z == 0) {
			printf("%d\n", x);
			return 0;
		}
	}
	
	int div = z;
	while (div--) {
		if (y % div == 0 && z % div == 0) {
			printf("%d\n", div);
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 2696
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;
long long mod = 1e9+7;

ll A[70][2];
int main()
{
	int N; scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		ll x; scanf("%lld", &x);
		for (int j = 0; j<60; j++, x>>=1) {
			++A[j][x & 1];
			A[j][x & 1] %= mod;
		}
	}
	ll ans = 0, x;
	for (int i = 0; i < 60; i++) {
		x = (1LL << i) % mod;
		ans += (A[i][0] * A[i][1])%mod * x;
		ans %= mod;
	}
	printf("%lld", ans%mod);
	return 0;
}

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

using namespace std;

int main()
{
	for(int n,u,v,m;cin>>n>>u>>v>>m;){
		vector<int> ris(1e6+1,-1),rjs=ris,cis=ris,cjs=rjs;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				int x; cin>>x;
				ris[x]=i,rjs[x]=j;
			}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				int x; cin>>x;
				cis[x]=i,cjs[x]=j;
			}
		vector<int> xs(m);
		for(int i=0;i<m;i++) cin>>xs[i];
		
		int rcnt=0,ccnt=0;
		if(n==1){ // corner case
			for(int x:xs){
				if(ris[x]!=-1) rcnt++;
				if(cis[x]!=-1) ccnt++;
				if(rcnt>=u && ccnt<v){
					cout<<"USAGI"<<endl;
					goto end;
				}
				if(rcnt<u && ccnt>=v){
					cout<<"NEKO"<<endl;
					goto end;
				}
			}
		}
		else{
			vector<int> ric(n),rjc(n),rdc(2),cic(n),cjc(n),cdc(2);
			for(int x:xs){
				if(ris[x]!=-1){
					if(++ric[ris[x]]==n) rcnt++;
					if(++rjc[rjs[x]]==n) rcnt++;
					if(ris[x]==rjs[x] && ++rdc[0]==n) rcnt++;
					if(ris[x]==n-1-rjs[x] && ++rdc[1]==n) rcnt++;
				}
				if(cis[x]!=-1){
					if(++cic[cis[x]]==n) ccnt++;
					if(++cjc[cjs[x]]==n) ccnt++;
					if(cis[x]==cjs[x] && ++cdc[0]==n) ccnt++;
					if(cis[x]==n-1-cjs[x] && ++cdc[1]==n) ccnt++;
				}
				if(rcnt>=u && ccnt<v){
					cout<<"USAGI"<<endl;
					goto end;
				}
				if(rcnt<u && ccnt>=v){
					cout<<"NEKO"<<endl;
					goto end;
				}
			}
		}
		cout<<"DRAW"<<endl;
		
		end:;
	}
}

Measured memory_bytes: 16960
# coding: utf-8

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def solve(b, L, As):
    si = [b // (4**i) % 4 for i in range(len(L))]
    c = 0
    ls = [0] * 4
    for l, s in zip(L, si):
        if s > 0 and ls[s] > 0:
            c += 10
        ls[s] += l
    if 0 in ls[1:]: return float("inf")
    return c + sum([abs(As[i] - ls[i + 1]) for i in range(3)])


def main():
    N, A, B, C = MI()
    L = [II() for _ in range(N)]
    ans = float("inf")
    for i in range(4**N):
        ans = min(ans, solve(i, L, [A, B, C]))
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3064
from itertools import product
import sys

sys.setrecursionlimit(1000000)

def s(m, x, y):
    m[y][x] = 0

    for dx, dy in product(range(-1, 2), range(-1, 2)):
        if m[y + dy][x + dx]:
            s(m, x + dx, y + dy)

while True:
    c = 0
    w, h = map(int, input().split())

    if w == h == 0:
        break

    m = [[0] * (w + 2)] + [[0] + list(map(int, input().split())) + [0] for _ in range(h)] + [[0] * (w + 2)]

    for x, y in product(range(w + 2), range(h + 2)):
        if m[y][x]:
            c += 1
            s(m, x, y)
            
    print(c)



Measured memory_bytes: 8620
N = int(input())
sn = [input() for _ in range(N)]
M = int(input())
tn = [input() for _ in range(M)]

str_count = {}
for s in sn:
    if s in str_count:
        str_count[s] += 1
    else:
        str_count[s] = 1
for t in tn:
    if t in str_count:
        str_count[t] -= 1
    else:
        str_count[t] = -1

m = max(str_count.values())
print(m if m > 0 else 0)


Measured memory_bytes: 3060
import sys


def input():
    return sys.stdin.readline()[:-1]

N = int(input())
A = list(map(int, input().split()))
r = {}
for i in range(N):
    if A[i] in r:
        r[A[i]]+=1
    else:
        r.setdefault(A[i], 1)
total = 0
for k, v in r.items():
    if v>=2:
        total += v*(v-1)//2
for k in range(N):
    num = r[A[k]]
    print(total - (num-1))

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

int main(int argc, char *argv[])
{
    int a, b;
    vector<tuple<int, int>> tv;

    while (1)
    {
        cin >> a >> b;
        if (a == 0 && b == 0)
            break;
        tv.push_back(tuple<int, int>(a, b));
    }

    for (tuple<int, int> t : tv)
    {
        for (int i = 0; i < get<0>(t); i++)
        {
            for (int j = 0; j < get<1>(t); j++)
            {
                if (i % 2 == 0)
                {
                    if (j % 2 == 0)
                    {
                        cout << "#";
                    }
                    else
                    {
                        cout << ".";
                    }
                }
                else
                {
                    if (j % 2 == 0)
                    {
                        cout << ".";
                    }
                    else
                    {
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3096
A, B = map(int, input().split())
maxV = 1010 # これ以上の値は絶対に条件Bを満たさない。
for i in range(1, maxV):
    if int(i * 0.08) == A and int(i * 0.1) == B:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
class DisjointSet():
    def __init__(self, size):
        self.size = size
        self.rank = [None] * size
        self.parents = [None] * size
        for i in range(size):
            self.makeSet(i)

    def makeSet(self, x):
        self.parents[x] = x
        self.rank[x] = 0

    def findSet(self, x):
        if x != self.parents[x]:
            self.parents[x] = self.findSet(self.parents[x])
        return self.parents[x]

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.parents[y] = x
        else:
            self.parents[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1


if __name__ == '__main__':

    n, q = [int(s) for s in input().split(" ")]
    com = [list(map(int, input().split(" "))) for _ in range(q)]
    ds = DisjointSet(n)

    for c, x, y in com:
        if c == 0:
            ds.unite(x, y)
        else:
            print(int(ds.same(x, y)))



Measured memory_bytes: 24752
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
public static void main(String[] args) throws IOException {
  InputStream is = System.in;
  Scanner in = new Scanner(is);
  Pattern pattern = Pattern.compile("[0|1]{12}");
  while (in.hasNext(pattern)) {
	int[][] before = new int[12][];
	int[][] line = new int[12][];
	int count = 0, num = 0;
	int[][] old = null;
	for (int col = 0; col < 12; col++) {
	  old = before;
	  before = line;
	  line = old;
	  char[] read = in.next(pattern).toCharArray();
	  // System.out.println(Arrays.toString(read));
	  for (int row = 0; row < 12; row++) {
		if (read[row] == '1') {
		  boolean upperHas = before[row] != null;
		  boolean leftHas = row != 0 && line[row - 1] != null;
		  if (!(upperHas || leftHas)) {
			line[row] = new int[] { num++ };
			count++;
		  } else if (leftHas) {
			line[row] = line[row - 1];
			if (upperHas && line[row][0] != before[row][0]) {
			  line[row][0] = before[row][0];
			  count--;
			}
		  } else if (upperHas) {
			line[row] = before[row];
		  }
		}
		else {
		  line[row] = null;
		}
	  }
	}
	System.out.println(count);
  }
}
}

Measured memory_bytes: 0
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int mod=1000000007;
int qpow(int x,int y){
	int res=1;
	while(y){
		if(y&1)(res*=x)%=mod;
		(x*=x)%=mod;
		y>>=1;
	}
	return res;
}
int n,m;
vector<int> d;
vector<int> dp;
signed main(){
	cin>>n>>m;
	for(int i=1;i*i<=n;i++)if(n%i==0)
		d.pb(i),d.pb(n/i);
	sort(d.begin(),d.end());
	d.resize(unique(d.begin(),d.end())-d.begin());
	int ans=0;
	for(int i=0;i<d.size();i++){
		dp.pb(qpow(m,(d[i]+1)/2));
		for(int j=0;j<i;j++)if(d[i]%d[j]==0)(((dp[i]-=dp[j])%=mod)+=mod)%=mod;
		(ans+=dp[i]*(d[i]&1?d[i]:d[i]/2))%=mod;
//		printf("i=%lld ans=%lld\n",i,ans);
	}
	cout<<ans;
	return 0;
}
/*1
4 2
*/
/*2
1 10
*/
/*3
6 3
*/
/*4
1000000000 1000000000
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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;}
const int inf = 1001001001;

int main() {
    ll n;
    cin >> n;
    ll sum = 1001001001001001;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i != 0) continue;
        chmin(sum,i+n/i);
    }
    cout << sum-2 << endl;
}

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

using namespace std;

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

int main(){
  double n; cin >> n;

  printf("%.3f\n",n*2*3.1415);
  
}

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

int main()
{
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;
    float b;
    int ans;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        float temp = t - 0.006 * h;
        if (i == 0 || fabs(temp - a) < fabs(b - a)) {
            b = temp;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S,T; cin>>S>>T;

    int ans=0;
    rep(i,0,S.size()){
        if(S.at(i)!=T.at(i)) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3920