akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		String t = sc.next();
		StringBuilder res = new StringBuilder();
		
		int sPos = 0;
		int tPos = 0;
		
		while (sPos < s.length() || tPos < t.length()) {
			if (sPos < s.length()) {
				res.append(s.charAt(sPos));
				sPos++;
			}
			if (tPos < t.length()) {
				res.append(t.charAt(tPos));
				tPos++;
			}
		}
		System.out.println(res.toString());
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21204
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

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

    int ai,zi;
    for(int i=0 ; i<s.size() ; i++){
        string tmp=s.substr(i,1);
        if(tmp=="A"){ai=i;break;}
    }
    for(int i=s.size()-1 ; i>=0 ; i--){
        string tmp=s.substr(i,1);
        if(tmp=="Z"){zi=i;break;} 
    }
    cout << (zi-ai+1) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n,k;
	scanf(" %d %d", &n , &k);
	vector<int> a;
	for(int i=0;i<n;i++){
		int h;
		scanf(" %d", &h);
		a.push_back(h);
	}
	
	int low=0,high=1e9,mid;
	for(int _=0;_<100;_++){
		mid = (low+high)/2;
		int count=0, bef=0;
		bool f = true;
		while(1){
			if(bef == n) break;
			if(count >= k){
				f = false;
				break;
			}
			int bag = mid;
			int p;
			for(p=bef;p<n;p++){
				if(bag >= a[p]) bag-=a[p];
				else break;
			}
			bef = p;
			count++;
		}
		if(f) high = mid;
		else low = mid;
	}
	
	printf("%d\n", high);	
	
	return 0;
}

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

using namespace std;

#define ll long long

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	vector<int> c(n);
	for (int i = 0; i < n; i++) cin >> c[i];
	ll ans = 0;
	for (int i = 0; i < n; i++)
		ans += v[i] > c[i] ? v[i] - c[i] : 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
    using namespace std;
    long long s, t;
    int main(void){
        // Your code here!
        cin >> s >> t;
        long long test = t / s, a = 1;
        int res = 0;
        while (test >= a) {
            a *= 2;
            res++;
        }
        cout << res << endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define BE(x) x.begin(), x.end()

int main() {
    int n, m, a, b;
    cin >> n >> m;
    dsu d(n);
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        int c = d.merge(a-1, b-1);
    }
    vector<vector<int>> v;
    v = d.groups();
    int ans = v.size()-1;
    cout << ans << endl;
}

Measured memory_bytes: 8912
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

bool prime[300000];
Vi num;

void Prime(){
	rep(i,300000){
		if(i%7 == 1 || i%7 == 6) prime[i] = true;
		else prime[i] = false;
	}
	prime[1] = false;
	for(int i = 6; i < 1000; i++){
		if(prime[i] == false) continue;
		for(int j = 2*i; j < 300000; j += i) prime[j] = false;
	}
	rep(i,300000){
		if(prime[i]) num.pb(i);
	}
}

int main(){
	Prime();
	int n;
	while(scanf("%d",&n)){
		if(n == 1) break;
		printf("%d:", n);
		rep(i,num.size()){
			if(num[i] > n) break;
			if(n%num[i] == 0) printf(" %d", num[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1632
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,m = f()
    if n == 1 and m == 1:
        print(1)
    elif n==2 or m==2:
        print(0)
    elif n==1:
        print(max(0,m -2))
    elif m==1:
        print(max(0, n-2))
    else:
        print(max((n-2),1)*max(1,(m-2)))

solve()


Measured memory_bytes: 3060
import sys
input = sys.stdin.buffer.readline
from collections import Counter

def main():
    N,M = map(int,input().split())
    x = list(map(int,input().split()))
    
    ml = [[] for _ in range(M)]
    for num in x:
        ml[num%M].append(num)

    cl = [[0,0] for _ in range(M)]
    for i in range(M):
        y = ml[i]
        c = tuple(Counter(y).values())
        for num in c:
            cl[i][0] += num//2*2
            cl[i][1] += num%2

    ans = (cl[0][0]+cl[0][1])//2
    for i in range(1,-(-M//2)):
        da,oa = cl[i]
        db,ob = cl[M-i]
        num = 0
        if oa >= ob:
            num += (ob+min(oa-ob,db)+max(0,db-(oa-ob))//2+da//2)
        else:
            num += (oa+min(ob-oa,da)+max(0,da-(ob-oa))//2+db//2)
        ans += num
    
    if M%2 == 0:
        m = M//2
        ans += (cl[m][0]+cl[m][1])//2
        
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 29768
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		for(int i = 0 ; i < M ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for(int i = 1 ; i <= N ; i++) {
			int cnt = 0;
			for(int j = 0 ; j < M ; j++) {
				if(a[j] == i || b[j] == i) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 21972
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	auto n = readln.chomp.to!int;
	foreach (_; 0..n) {
		auto str = readln.chomp;
		char[] res;
		res ~= str[0];
		char pre = res[0];
		for (int p = 1; p < str.length; p += 3) {
			if (str[p..p+2] == "->" && res[$-1] == pre) {
				res ~= str[p+2];
			} else if (str[p..p+2] == "<-" && res[0] == pre) {
				res = str[p+2] ~ res;
			}
			pre = str[p+2];
		}
		res.writeln;

	}
}

Measured memory_bytes: 1068
S = input()

f_s = [s in ["A", "C", "G", "T"] for s in S]

c = 0
max_c = 0
for f in f_s:
    if f:
        c += 1
        max_c = max(max_c, c)
    else:
        c = 0

print(max_c)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int num=INT32_MAX;
    int ec=count(s.begin(),s.end(),'E');
    int wc=s.size()-ec;
    int tmp1[s.size()]={};
    int tmp2[s.size()]={};
    vector<int> ans;    
    for(int i=1;i<=s.size();i++){
        if(s[i-1]=='W'){
            tmp1[i]=tmp1[i-1]+1;
            tmp2[i]=tmp2[i-1];
        }
        if(s[i-1]=='E'){
            tmp2[i]=tmp2[i-1]+1;
            tmp1[i]=tmp1[i-1];
        }
        ans.push_back(tmp1[i-1]+ec-tmp2[i]);
    }
    // for(int i=0;i<s.size();i++){
    //     cout<<ans[i]<<endl;
    // } 
    sort(ans.begin(),ans.end());
    cout<<ans[0]<<endl;
    return 0;
}


Measured memory_bytes: 5244
# C - Tax Increase
A,B = map(int,input().split())
a = (A*100+8-1)//8
b = (B*100+10-1)//10

aa = a*8//100
ab = a*10//100
ba = b*8//100
bb = b*10//100

if aa==A and ab==B: print(min(a,b) if ba==A and bb==B else a)
else: print(b if ba==A and bb==B else -1)


Measured memory_bytes: 3064
#include<stdio.h>
#include<ctype.h>

int main(void){
	char C1[3], C2[3];
	int i, x = 0;

	do{
		scanf("%s", C1);
		scanf("%s", C2);
		for(i = 0; i < 3; i++){
			if(islower(C1[i]) != 0)
				x++;
			}
		for(i = 0; i < 3; i++){
			if(islower(C2[i]) != 0)
				x++;
		}
	}while(x != 6);

	if(C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0])
		printf("YES\n");
	else	printf("NO\n");

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
 int a, b, c;
 
 scanf("%d", &a);
 scanf("%d", &b);
 scanf("%d", &c);
 
 int max = a;
 if (b > max) max = b;
 if (c > max) max = c;
 
 printf("%d\n", a + b+ c- max);
 
 return 0;
 
}

Measured memory_bytes: 128
def a(q)
puts"? "+q.join(" ")
$>.flush
gets
end
N=gets.to_i
s="! "
I=(1..2*N).to_a
f=a I[0,N]
l,r=0,N
9.times{
m=(l+r)/2
f==a(I[m,N])?l=m:r=m
}
x=I[r,N-1]
y=I-I[l,N+1]
I.map{|i|
s+=a([i]+(x.index(i)?y:x))[0]
}
puts s

Measured memory_bytes: 2380
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

int N;

bool check(int X){
  int n = N;
  vi v;
  v.resize(0);
  while(n > 0 && X > 0){
    if(n-X >= 0){
      n -= X;
      v.pb(X);
    }
    X--;
  }

  return (n == 0);
}

int main(){
  cin >> N;

  ll ok = N, ng = 0;
  while (abs(ng-ok)>1){
    ll mid = (ok+ng)/2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  vi ans;
  while(N > 0){
    if(N-ok >= 0){
      N -= ok;
      ans.pb(ok);
    }
    ok--;
  }

  for(auto num : ans) {
    cout << num << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
//#include <string.h>

using namespace std;


int main(){
    int K,N,A[2],max=0,tmp,start;
    scanf("%d",&K);
    scanf("%d",&N);

    for(int i=0; i<N; ++i){
        if(i==0){
            scanf("%d",A);
            start = A[0];
            continue;
        }
        scanf("%d",A+1);
        tmp = A[1]-A[0];
        max = max>tmp? max : tmp;

        if(i==N-1){
            tmp = start + K-A[1];
            max = max>tmp? max : tmp;
        }
        A[0]=A[1];
    }
    cout << K - max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}
ll MAX(ll a,ll b){return a>b?a:b;}
ll MAX(ll a,ll b,ll c){return max(max(a,b),c);}
ll MIN(ll x,ll  y){return x+y-max(x,y);}
ll MIN(ll x,ll y,ll z){return min(min(x,y),z);}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll pmod(ll a, ll b)//a^b%mod1
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod1;
        b/=2;
        a=(a*a)%mod1;
    }
    return ans;
}



vll adj[100001];
ll vis[100001];
ll sssp[100001];






void solve(){
string s;
cin>>s;
if(s=="ARC")cout<<"ABC";
else cout<<"ARC";


    

}




int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

    ll t;
      t=1;
    //cin>>t;
    while(t--){

        solve();
    }

    return 0;


}

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

int abs(int a, int b) {
  if (a >= b) return a - b;
  else return b - a;
}

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<int> d(n);
  d[0] = 0;
  d[1] = abs(h[0], h[1]);
  rep(i,n-2) {
    d[i+2] = min(d[i+1] + abs(h[i+1], h[i+2]),
                 d[i] + abs(h[i], h[i+2]));
  }
  cout << d[n-1];
}


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

int main()
{
  string str;
  int s, g;

  cin >> str;

  int i = 0;
  while ( str[i] != 'A' && i < str.size() ) {
    i++;
  }

  int j = str.size() - 1;
  while ( str[j] != 'Z' && j >= 0) {
    j--;
  }

  cout << j - i + 1 << endl;

  return (0);
}

Measured memory_bytes: 640
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (A, B, C): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    // A, B, C のいずれかが偶数ならば二等分可能
    // そうでなければ小さい辺二つからなる長方形の面積が最小値
    let ans = if A % 2 == 0 || B % 2 == 0 || C % 2 == 0 {
        0
    } else {
        *vec![A * B, B * C, C * A].iter().min().unwrap()
    };

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


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for(int x = 0; x <= K; x++){
    for(int y = 0; y <= K; y++){
      int z = S - x - y;
      if(0 <= z && z <= K ){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
    int l,k = 0,t = 0;

    cin>>l;
    
    k += l/500; 
    l -= k*500;
    k = k*1000;
    t += l/5;
    k+= t*5;
    cout<<k<<"\n";
}   

Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List

solve:: String -> String
solve = map (\x -> if x == ',' then ' ' else x)

main :: IO ()
main = do
    s <- BS.unpack <$> BS.getLine
    putStrLn $ solve s


Measured memory_bytes: 380
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
#define def 0
template<class V, int NV> struct SegTree { //[l,r)
    V comp(V& l, V& r) { return max(l, r); };

    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int x, int y, int l = 0, int r = NV, int k = 1) {
        if (r <= x || y <= l)return def; if (x <= l && r <= y)return val[k];
        auto a = get(x, y, l, (l + r) / 2, k * 2);
        auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
        return comp(a, b);
    }
    void update(int i, V v) {
        i += NV; val[i] = v;
        while (i > 1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
    }
    void add(int i, V v) { update(i, val[i + NV] + v); }
    V operator[](int x) { return get(x, x + 1); }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K, A[301010];
SegTree<int, 1 << 19> st;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N) {
        int ma = st.get(max(0, A[i] - K), min(301010, A[i] + K + 1));
        st.update(A[i], ma + 1);
    }

    int ans = st.get(0, 301010);
    cout << ans << endl;
}







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

long long cnt;
int l;
int a[1000000];
int N;
vector<int> G;

void trace(int a[], int N) {
	for (int i = 0; i < N; i++) {
		printf("%d", a[i]);
		if (i < N - 1) printf(" ");
	}
	printf("\n");
	return;
}
//間隔gのinsertionsort
void insertionsort(int a[], int N, int g) {
	for(int i = g; i < N; i++) {
		int x = a[i];
		int j = i - g;
		while (j >= 0 && a[j] > x) {
			a[j + g] = a[j];
			j -= g;
			cnt++;
		}
		a[j + g] = x;
	}
	return;
}

void Shellsort(int a[], int N) {
	//数列{3h+1}を生成
	for (int h = 1;;) {
		if (h > N) break;
		G.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = G.size() - 1; i >= 0; i--) {
		insertionsort(a, N, G[i]);
	}
	return;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	cnt = 0;
	Shellsort(a, N);
	printf("%d\n", G.size());
	for (int i = G.size() - 1; i >= 0; i--) {
		printf("%d", G[i]);
		if (i) printf(" ");
	}
	printf("\n%d\n", cnt);
	trace(a, N);
	return 0;
}


Measured memory_bytes: 7064
#include "bits/stdc++.h"
using namespace std;

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

	string dist = "NG";
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			dist = "OK";
			break ;
		}
	}
	cout << dist << endl;
	return 0;
}

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

int a[209][209], b[209][209], H, W, N, maxn;

void ruisekiwa() {
	for (int i = 0; i < 209 * 209; i++) b[i / 209][i % 209] = 0;
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) b[i][j] = a[i][j]; }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { b[i][j] += b[i - 1][j]; } }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { b[i][j] += b[i][j - 1]; } }
}

void hanten() {
	for (int i = 1; i <= max(H, W); i++) {
		for (int j = 1; j <= max(H, W); j++) { if (i < j) swap(a[i][j], a[j][i]); }
	}
	swap(H, W);
}

int ranged(int px, int py, int qx, int qy) {
	return b[px - 1][py - 1] + b[qx][qy] - b[px - 1][qy] - b[qx][py - 1];
}

int P[209][209];

int calc(vector<int>G, int R) {
	for (int i = 0; i < 209 * 209; i++) P[i / 209][i % 209] = 0;
	for (int i = 0; i < G.size(); i++) {
		int sum = 0;
		for (int j = i; j < G.size(); j++) {
			sum += G[j]; P[i][j] = sum;
		}
	}
	int ret = 0;
	if (R == 1) return P[0][G.size() - 1];
	if (R == 2) {
		for (int i = 1; i < G.size(); i++) ret = max(ret, min(P[0][i - 1], P[i][G.size() - 1]));
		return ret;
	}
	if (R == 3) {
		for (int i = 1; i < G.size(); i++) {
			for (int j = i + 1; j < G.size(); j++) {
				ret = max(ret, min({ P[0][i - 1], P[i][j - 1], P[j][G.size() - 1] }));
			}
		}
		return ret;
	}
	if (R == 4) {
		for (int i = 1; i < G.size(); i++) {
			for (int j = i + 1; j < G.size(); j++) {
				for (int k = j + 1; k < G.size(); k++) {
					ret = max(ret, min({ P[0][i - 1], P[i][j - 1], P[j][k - 1], P[k][G.size() - 1] }));
				}
			}
		}
		return ret;
	}
}

int dfs(int px, int py, int qx, int qy, int life) {
	if (life == 1) return ranged(px, py, qx, qy);
	else {
		int rem = 0;
		for (int t = 1; t < life; t++) {
			for (int i = px + 1; i <= qx; i++) {
				int V1 = dfs(px, py, i - 1, qy, t);
				int V2 = dfs(i, py, qx, qy, life - t);
				rem = max(rem, min(V1, V2));
			}
			for (int j = py + 1; j <= qy; j++) {
				int V1 = dfs(px, py, qx, j - 1, t);
				int V2 = dfs(px, j, qx, qy, life - t);
				rem = max(rem, min(V1, V2));
			}
		}
		return rem;
	}
}

void solve() {
	int Z = dfs(1, 1, H, W, N);
	maxn = max(maxn, Z);

	if (N == 4) {
		for (int i = 2; i <= H - 1; i++) {
			for (int j = 2; j <= W - 1; j++) {
				for (int k = i; k <= H - 1; k++) {
					for (int l = j; l <= W - 1; l++) {
						int V1 = ranged(1, 1, k, j - 1);
						int V2 = ranged(k + 1, 1, H, l);
						int V3 = ranged(i, l + 1, H, W);
						int V4 = ranged(1, j, i - 1, W);
						maxn = max(maxn, min({ V1, V2, V3, V4 }));
					}
				}
			}
		}
	}
}

int main() {
	cin >> H >> W >> N;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) cin >> a[i][j];
	}
	ruisekiwa();
	solve();
	hanten(); ruisekiwa();
	solve();
	cout << maxn << endl;
	return 0;
}



Measured memory_bytes: 3448
let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let roads = Array.make n 0 in
  for i = 1 to m do
    Scanf.scanf "%d %d\n" (fun a b ->
      roads.(a - 1) <- roads.(a - 1) + 1;
      roads.(b - 1) <- roads.(b - 1) + 1)
  done;
  Array.iter (Printf.printf "%d\n") roads


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(){
	string words;
	cin >> words;
	int len = words.size();
	for (int i = 1; i < len; ++i)
	{
		if(words[i-1] == 'S' && words[i] == 'T'){
			words.erase(words.begin() + i);
			words.erase(words.begin() + i - 1);
			i -= 2;
			len -= 2;
		}
	}
	cout << words.size() << endl;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

  int ans = 0, cnt = 0;
  rep(i, 0, s.size()){
    if(s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C'){
      cnt++;
      chmax(ans, cnt);
    }else cnt = 0;
  }
  chmax(ans, cnt);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<ll> V;

vector<ll> g[200005],g1[200005];
ll comp=1,n,val[200005]={0},vis[200005]={0};

void dfs(ll node)
{
    if(vis[node]==1)return;
    vis[node]=1;
    val[node]=comp;
    for(auto y:g[node])dfs(y);
}

int main()
{
    ios;
    ll m,k,i,j,l,o,p;
    cin>>n>>m>>k;
    rep(i,0,m-1)cin>>j>>l,g[j].pb(l),g[l].pb(j);
    rep(i,0,k-1)cin>>j>>l,g1[j].pb(l),g1[l].pb(j);
    rep(i,1,n)
    {
        if(!vis[i])
        {
            dfs(i);
            comp++;
        }
    }
    ll c[comp+2]={0};
    rep(i,1,n)c[val[i]]++;
    rep(i,1,n)
    {
        ll ans=c[val[i]];
        ans-=g[i].size();
        for(auto y:g1[i])
        {
            if(val[y]==val[i])
                ans--;
        }cout<<ans-1<<" ";
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;

    vector<int> numbers(N);
    for (int i = 0; i < N; i++){
        cin >> numbers.at(i);
    }

    int count = 0;
    bool evenFlg = true;
    while (evenFlg) {
        for (int i = 0; i < N; i++) {
            if (numbers.at(i) % 2 != 0) {
                evenFlg = false;
            }
            numbers.at(i) /= 2;        
        }
        if(evenFlg){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  string s;
  int m = 0;
  bool flg[30];
  bool flg2[30];

  cin >> n >> s;
  for(int i = 1; i < (n-1); i++){
    string w1, w2;
    for(int k = 0; k < 30; k++){
      flg[k] = false;
      flg2[k] = false;
    }
    w1 = s.substr(0, i);
    w2 = s.substr(i);
    // cout << "w1:" << w1 << " w2:" << w2 << endl;
    int len = w1.length();
    for(int k = 0; k < len; k++){
      flg[w1[k] - 'a'] = true;
    }
    len = w2.length();
    for(int k = 0; k < len; k++){
      flg2[w2[k] - 'a'] = true;
    }
    int cnt = 0;
    for(int k = 0; k < 26; k++){
      if(flg[k] && flg2[k]) cnt++;
    }
    // cout << " cnt:" << cnt << endl;
    m = max(m, cnt);
  }
  cout << m << endl;

  return 0;
}


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

using namespace std;

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}
 
template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

int main(){
    const size_t N = read<size_t>();
    const auto a = reads<size_t>(N);
    
    
    size_t count_odd = 0;
    size_t count_4times = 0;
    for(size_t i : a){
        if(i % 4 == 0) count_4times++;
        else if(i % 2 != 0) count_odd++;
    }
    
    if(count_odd <= count_4times || 
       (count_odd == count_4times + 1 && (count_odd + count_4times) == a.size() ))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}

int main(){
	//ios::sync_with_stdio(0);cin.tie(0);
	int n,a;
	cin>>n;
	map<ll,int>m;
	rep(i,n){
		cin>>a;
		m[a]++;
	}
	ll d=-1;
	for(auto it=m.rbegin();it!=m.rend();it++){
		if(it->yy>=4){
			if(d==-1){
				cout<<it->xx * it->xx ; 
				return 0;
			}
			else{
				cout<<d*it->xx;
				return 0;
			}
		}
		if(it->yy>=2){
			if(d==-1){
				d=it->xx;
			}
			else{
				cout<<d*it->xx;
				return 0;
			}
		}
	}
	cout<<0;
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;
  ll ans = 0;
  ll T = 1;
  REP(i,s.length()-1) T *= 2;
  REP(i,T){
    ll t = 1;
    ll cn = 1;
    FORR(j,1,s.length()){
      ans += (s[j]-'0') * cn;
      if(i&t){
        cn = 1;
      }else{
        cn *= 10;
      }
      t *= 2;
    }
    ans += (s[0]-'0') * cn;
  }

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


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 105
void matrixChainOrder(int n,int *p){
  int i,j,k,q,l,m[MAX][MAX];
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){

    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=200000;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j]>q)m[i][j]=q;
	
}
}
}
  printf("%d\n",m[1][n]);
}
int main(){

  int i,j,n,r[MAX],c[MAX],p[210];

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&r[i],&c[i]);
    p[i-1]=r[i],
      p[i]=c[i];
}

  matrixChainOrder(n,p);


  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <cmath>

using namespace std;

#define MOD 1000000007

long long N,M;
long long count;

int main(){
    cin >> N >> M;
    if(abs(N-M)>1){
        cout << 0 << endl;
        return 0;
    }
    long long O = min(N,M);
    long long n,m;
    n = m = 1;
    for(long long i=2;i<=O;i++){
        n *= i;
        n %= MOD;
    }
    if(N == M) m = n;
    else m = n * max(N,M);
    m %= MOD;
    long long ans;
    if(N == M){
        ans = (n * m * 2) % MOD;
    }else{
        ans = (n * m) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main( void ){
   long int i,j,n,a,b;
   long int min;
   scanf("%ld", &n);
   
   min = n;
   for(i = 1; i <= sqrt(n); i++){
      if((n%i) == 0){
         a = n/i;
         b = i + a - 2;
      }
      if(min > b){
         min = b;
      }
   }
   printf("%ld\n", min);
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;
    int count = 1; 
    for(int i=0;i<S.size();i++){
        if(i % 2 == 0){
            if(S[i] == 'L'){
                cout << "No";
                count = 0;
                break;
            }
        }else{
            if(S[i] == 'R'){
                cout << "No";
                count = 0;
                break;
            }
        }
        }
    if(count == 1){
        cout << "Yes";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
        int n,i,h[100],x=1,j,f;
 
        scanf("%d",&n);
 
        for(i=0;i<n;i++){
                scanf("%d",&h[i]);
        }
 
        for(i=1;i<n;i++){
                f=1;
                for(j=0;j<i;j++){
                        if(h[i]<h[j])
                                f=0;
                }
                if(f==1)x++;
        }
 
        printf("%d\n",x);
 
        return 0;
}
 
                                                                    
               

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

int main (void)
{
    char week[][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    char S[4];
    size_t ans = 0;
    
    gets(S);

    while (strcmp(&week[ans][0], S)) ans++; 

    ans = 7 - ans;

    printf("%jd\n", ans);

    return 0;
}



Measured memory_bytes: 128
import os
import sys

import numpy as np


def solve(inp):
    def bitree_sum(bit, t, i):
        s = 0
        while i > 0:
            s += bit[t, i]
            i ^= i & -i
        return s

    def bitree_add(bit, n, t, i, x):
        while i <= n:
            bit[t, i] += x
            i += i & -i

    def bitree_lower_bound(bit, n, d, t, x):
        sum_ = 0
        pos = 0
        for i in range(d, -1, -1):
            k = pos + (1 << i)
            if k <= n and sum_ + bit[t, k] < x:
                sum_ += bit[t, k]
                pos += 1 << i
        return pos + 1

    def initial_score(d, ccc, sss, ttt):
        bit_n = d + 3
        bit = np.zeros((26, bit_n), dtype=np.int64)
        INF = 10 ** 18
        for t in range(26):
            bitree_add(bit, bit_n, t, bit_n - 1, INF)

        last = np.full(26, -1, dtype=np.int64)
        score = 0

        for i in range(d):
            t = ttt[i]
            score += sss[i, t]
            for u in range(26):
                if u == t:
                    continue
                score -= ccc[u] * (i - last[u])
            last[t] = i
            bitree_add(bit, bit_n, t, i + 2, 1)

        return bit, score

    def update_score(bit, bit_n, bit_d, ccc, sss, ttt, d, q):
        diff = 0
        t = ttt[d]
        k = bitree_sum(bit, t, d + 2)
        c = bitree_lower_bound(bit, bit_n, bit_d, t, k - 1) - 2
        e = bitree_lower_bound(bit, bit_n, bit_d, t, k + 1) - 2
        b = ccc[t]
        diff -= b * (d - c) * (e - d)
        diff -= sss[d, t]

        k = bitree_sum(bit, q, d + 2)
        c = bitree_lower_bound(bit, bit_n, bit_d, q, k) - 2
        e = bitree_lower_bound(bit, bit_n, bit_d, q, k + 1) - 2
        b = ccc[q]
        diff += b * (d - c) * (e - d)
        diff += sss[d, q]

        return diff

    d = inp[0]
    ccc = inp[1:27]
    sss = np.zeros((d, 26), dtype=np.int64)
    for r in range(d):
        sss[r] = inp[27 + r * 26:27 + (r + 1) * 26]

    ttt = np.random.choice(26, d)

    bit, score = initial_score(d, ccc, sss, ttt)
    bit_n = d + 3
    bit_d = int(np.log2(bit_n))

    for _ in range(10 ** 6):
        cd = np.random.randint(0, d)
        ct = np.random.randint(0, 26)
        diff = update_score(bit, bit_n, bit_d, ccc, sss, ttt, cd, ct)
        if diff > 0:
            score += diff
            bitree_add(bit, bit_n, ttt[cd], cd + 2, -1)
            bitree_add(bit, bit_n, ct, cd + 2, 1)
            ttt[cd] = ct

    return ttt + 1


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))


Measured memory_bytes: 27584
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def conb(n,r): 
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = inp()
s = []
for i in range(n):
    tmp = list(input())
    s.append(sorted(tmp))
s.sort()
# print(s)
cnt = []
tmp = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        tmp += 1
    elif tmp != 0:
        cnt.append(tmp)
        tmp = 0
if tmp != 0:
    cnt.append(tmp)
# print(cnt)
res = 0
for i in cnt:
    res += conb(i+1, 2)
print(res)

Measured memory_bytes: 105940
import 'dart:io';

void main() async {
  List<String> inputs = stdin.readLineSync().split(' ');

  int x = int.parse(inputs[0]);
  int y = int.parse(inputs[1]);

  if ((x * 2) == y || (x * 4) == y) {
    print('Yes');
    return;
  }

  for (int i = 0; i < x; i++) {
    if (i * 2 + (x - i) * 4 == y) {
      print('Yes');
      return;
    }
  }
  print('No');
}


Measured memory_bytes: 13168
import collections
b = False
s = raw_input()
for i in range(len(s)-1):
    if not b and s[i] == s[i+1]:
        print i+1, i+2
        b = True
if not b:
    for i in range(len(s)-2):
        if not b and s[i] == s[i+2]:
            print i+1, i+3
            b = True
if not b:
    print "-1 -1"


Measured memory_bytes: 6008
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
  
#define mp make_pair

#define ll long long
#define pb push_back
  
using namespace std;
/*
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  */
const int inf = 2e9+7, mod=1e9+7;
const int N = 2e6;

int ans=0;

int used[N];
 
int xx[8]={1, 1, -1, -1, 2, 2, -2, -2};
int yy[8]={2, -2, 2, -2, 1, -1, 1, -1};

int a[N], d[N];


int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i=0; i<n; i++){
    	cin >> a[i];	
    }
   	
	for(int i=0; i<=k; i++){
		for(int j=0; j<n; j++){
			if(i-a[j]>=0 && d[i-a[j]]==0)
				d[i]=1;		
		}
    }
    
    if(d[k])
    	cout << "First";
    else
    	cout << "Second";

	return 0;
}



Measured memory_bytes: 2688
#include<stdio.h>

#define Max 100000
#define NIL -1

typedef struct Node{
  int p, l, r;
}Node;

Node T[Max];
int n, D[Max];

void print(int u){
  int i, c;

  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL) printf("root, [");
  else if(T[u].l == NIL) printf("leaf, [");
  else printf("internal node, [");

  c = T[u].l;
  
  for(i = 0 ; c != NIL ; i++){  
    if(i) printf(", ");
    printf("%d", c);
    c = T[c].r;
  }
  printf("]\n");
}

int rec(int u, int p){
  D[u] = p;

  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p + 1);
}

int main(){
  int i, j, d, v, c, l, r;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d %d", &v, &d);
    for(j = 0 ; j < d ; j++){
      scanf("%d", &c);
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for(i = 0 ; i < n ; i++){
    if(T[i].p == NIL) r = i;
  }

  rec(r, 0);

  for(i = 0 ; i < n ; i++) print(i);

  return 0;
}


Measured memory_bytes: 6536
#include<iostream>
#include <string>

int main() {
    int n;
    std::string s;
    std::string::iterator itr;
    
    std::cin >> n;
    std::cin >> s;
    
    int max_count = 0;
    int x = 0;
    
    for (auto itr = s.begin(); itr < s.end(); itr++)
    {
        if(*itr == 'I')
        {
            x += 1;
            max_count = std::max(x,max_count);
        }
        else
        {
            x -= 1;
        }
    }
    
    std::cout << max_count << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node T[MAX];
int n,D[MAX];

void print(int u){
  int c;
  cout<<"node "<<u<<": ";
  cout<<"parent = "<<T[u].parent<<", ";
  cout<<"depth = "<<D[u]<<", ";

  if(T[u].parent==NIL)cout<<"root, ";
  else if(T[u].left==NIL)cout<<"leaf, ";
  else cout<<"internal node, ";

  cout<<"[";

  for(int i=0,c=T[u].left;c!=NIL;i++,c=T[c].right){
    if(i)cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}

void rec(int u,int p){
  D[u]=p;
  if(T[u].right!=NIL)rec(T[u].right,p);
  if(T[u].left!=NIL)rec(T[u].left,p+1);
}

int main(){
  int n,id,k,c,l,r;

  cin>>n;
  for(int i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].left=NIL;
    T[i].right=NIL;
  }
  
  for(int i=0;i<n;i++){
    cin>>id>>k;
    for(int j=0;j<k;j++){
      cin>>c;
      if(j==0)T[id].left=c;
      else T[l].right=c;
      l=c;
      T[c].parent=id;
    }
  }
  
  for(int i=0;i<n;i++){
    if(T[i].parent==NIL)r=i;
  }

  rec(r,0);

  for(int i=0;i<n;i++) print(i);

  return 0;
}

Measured memory_bytes: 5840
#include <iostream>

using namespace std;

int main () {
  int n; cin >> n;
  int min = 1000, max = 0;

  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (a < min) min = a;
    if (a > max) max = a;
  }

  cout << max - min << endl;

  return 0;
}


Measured memory_bytes: 256
/*
USER: caoash3
LANG: JAVA
TASK: 
*/

import java.io.*;
import java.util.*;

public class Main {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			
			int N = br.nextInt();
			int W = br.nextInt();
			
			int[] w = new int[N];
			int[] v = new int[N];
			
			for(int i = 0; i < N; i++) {
				w[i] = br.nextInt();
				v[i] = br.nextInt();
			}
			
			long[][] dp = new long[N+1][W+1];
			
			for(int i = 0; i < W+1; i++) {
				dp[0][i] = -1 * Integer.MAX_VALUE;
			}
			
			dp[0][0] = 0;
			
			for(int i = 1; i <= N; i++) {
				for(int j = 0; j <= W; j++) {
					if(j - w[i-1] >= 0) {
						dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
					}
					else {
						dp[i][j] = dp[i-1][j];
					}
				}
			}
			
			long ans = 0;
			
			for(int i = 0; i <= W; i++) {
				ans = Math.max(ans, dp[N][i]);
			}
			
			pw.println(ans);
			
			
			
			pw.close();
		}

	}

	//fastscanner class
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}
 



Measured memory_bytes: 125652
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n, q;
   cin >> n;
   vector<int> v;
   for(int i = 0; i < n; i++){
	   int x;
	   cin >> x;
	   v.push_back(x);  
	 }
   cin >> q;
   for(int i = 0; i < q; i++){
	    int start, end, k;
	    cin >> start >> end >> k;
	    int ret = count(v.begin() + start, v.begin() + end, k);
	    cout << ret << endl;
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3212
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int n;
		double ave,d;
		while((n=scan.nextInt())!=0){
			int[] point=new int[n];
			ave=0;
			for(int i=0;i<n;i++){
				point[i]=scan.nextInt();
				ave+=point[i];
			}
			ave/=(double)n;
			d=0;
			for(int i=0;i<n;i++){
				d+=(Math.pow((ave-point[i]),2));
			}
			d/=(double)n;
			d=Math.sqrt(d);
			System.out.printf("%.8f\n",d);
		}
		scan.close();
	}
}

Measured memory_bytes: 23964
#include <bits/stdc++.h>
using namespace std;
#define QOEINDIEDIS freesteed
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int N, M, K, p[20][1010];
char s[15][1005];
inline int sum(int L1,int R1,int L2,int R2){
    return  p[L2][R2] + p[L1 - 1][R1 - 1] - p[L1 - 1][R2] - p[L2][R1 - 1] ;
}
inline void solve(){
	scanf("%d%d%d",&N,&M,&K);
	rep(i,0,N){
		scanf("%s",&s[i]);
		rep(j,0,M){
			if(s[i][j]=='1')p[i+1][j+1] = 1;
		}
	}
	for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) p[i][j] += p[i][j - 1]; }
    for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) p[i][j] += p[i - 1][j]; }
    int res = 1E9;
    
	for(int bits = 0 ;bits<(1<<(N-1));bits++){
		if(__builtin_popcount(bits)>=res)continue;//剪枝 7ms ~ 3ms 
		VI cut;
		for(int i=0;i<N-1;i++){
			if((bits>>i)&1){
				cut.pb(i+1);
			}
		}
		cut.pb(N);
		int  pcol = 1,ans=sz(cut)-1;
		int ok = 1;
		for(int i=1;i<=M;i++){
			int f=1,prow=1;
			for(int j=0;j<sz(cut);j++){
				if(sum(prow,pcol,cut[j],i)>K){
					f = 0;
					break;
				}
				prow = cut[j]+1;
			}
			if(!f){
				ans++;
				if(ans>=res){//剪枝 
					ok = 0;
					break;
				}
				if(pcol==i){//Impossible
					ok = 0;
					break;
				}
				pcol = i;
			}
		}
		if(ok)res = min(res,ans);
	}
	printf("%d\n",res);
}
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}

Measured memory_bytes: 256