akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int l,r,mi = INF;
	cin >> l >> r;
	for(int i = l;i <= min(r,l + 2019);i++){
		for(int j = i + 1;j <= min(r,l + 2019);j++){
			chmin(mi,i * j % 2019);
		}
	}
	cout << mi << endl;
}

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

using namespace std;

const int maxn = 2005;
const int mod = 1e9 + 7;

int a[maxn], b[maxn];
int dp[maxn][maxn];


int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
    for (int i = 1; i <= m; ++i) scanf("%d", b + i);


    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]);
            dp[i][j] %= mod;
            if (dp[i][j] < 0) dp[i][j] += mod;

            if (a[i] == b[j]) {
                dp[i][j] += 1 + dp[i - 1][j - 1];
                dp[i][j] %= mod;
            }
        }
    }    

    dp[n][m] += 1;
    dp[n][m] %= mod;
    
    printf("%d\n", dp[n][m]);
}

Measured memory_bytes: 16000
from itertools import*
n, k = map(int, input().split())
s = input()
d = [len(list(t)) for _, t in groupby(s)]
if s[0] == "0":
    d = [0] + d
a = [0] + list(accumulate(d))
m = l = 0
while True:
  try:
    m = max(m, a[l+2*k+1] - a[l])
    l += 2
  except IndexError:
    m = max(m, a[-1] - a[l])
    break
print(m)

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

using namespace std;

struct pp {
	int man;
	bool honest;
};

int n;
int res = 0;
vector < pp > a[16];

bool hon[16];

void Rec(int ind, int cnt) {
	if (ind > n) {
		bool f = true;
		for (int i = 1; i <= n && f; i++) {
			if (!hon[i]) continue;
			for (int j = 0; j < a[i].size() && f; j++)
				if (hon[a[i][j].man] != a[i][j].honest) f = false;
		}
		if (f) res = max(res, cnt);
		return;	
	}
	hon[ind] = 1;
	Rec(ind + 1, cnt + 1);
	hon[ind] = 0;
	Rec(ind + 1, cnt);
}

int main() {
	cin>>n;
	for (int i = 1; i <= n; i++) {
		int k;
		cin>>k;
		for (int j = 0; j < k; j++) {
			int x, y;
			cin>>x>>y;
			a[i].push_back({x, y});
		}
	}
	Rec(1, 0);
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Circle(void) {

	int r; cin >> r;
	cout << r * r << flush;
	return;
}

void B_Echo(void) {

	int N; string S; cin >> N >> S;

	cout << ((N % 2 == 0 && S.substr(0, N / 2) == S.substr(N / 2, N / 2)) ? "Yes" : "No") << flush;
	return;
}

void C_Average_Length(void) {

	int N; cin >> N;
	struct Town { int x, y; };
	vector<struct Town> town(N);
	for (struct Town& here :town) cin >> here.x >> here.y;

	vector<int> perm(N);
	double length = 0;
	int counter = 0;
	for (int loop = 0; loop < N; loop++) perm[loop] = loop;
	do {
		for (int loop = 1; loop < N; loop++) {
			length += pow(pow(town[perm[loop]].x - town[perm[loop - 1]].x, 2) + pow(town[perm[loop]].y - town[perm[loop - 1]].y, 2), 0.50);
		}
		counter++;
	} while (next_permutation(perm.begin(), perm.end()));
	cout << setprecision(20) << length / counter << flush;
	return;
}

int main(void) {
	
	//A_Circle();
	//B_Echo();
	C_Average_Length();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int x,y,s;cin>>x>>y>>s;
        if(x==0&&y==0&&s==0) return 0;
        int ans=0;
        for(int i=1;i<s;i++){
            for(int j=i;i+j<=s;j++){
                if(i*(100+x)/100+j*(100+x)/100==s){
                    ans=max(ans,i*(100+y)/100+j*(100+y)/100);
                }
            }
        }
        
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3140
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#define N (998244353)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> Q;

int p[200010];



int main(void){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        p[a[i]]=i;
    }
    int len = 0;
    for(int i=1;i<=n;){
        int tmp=1;
        while(true){
            if(i==n){
                i++;
                break;
            }
            if(p[i]<p[i+1])i++,tmp++;
            else{
                i++;
                break;
            }
        }
        len = max(len,tmp);
    }
    cout<<n-len<<endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
# # import re
# import math
# import collections
# # import decimal
# import bisect
# import itertools
# import fractions
# # import functools
# import copy
# # import heapq
# import decimal
# # import statistics
# import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    dp = [False] * (k + 1)

    for i in range(k + 1):
        for ai in a:
            if i + ai < k + 1:
                dp[i + ai] |= not dp[i]
            else:
                break

    print("First" if dp[k] else "Second")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9632
import java.util.*;
class Main{
 
    public static void main(String[] args)
          {
	Scanner sc=new Scanner(System.in);
      String str =sc.next();
      String str1 =sc.next();
      int count=0;
	  
        for(int i=0;i<str.length();i++){
          if(str.charAt(i)!=str1.charAt(i)){
          count++;
          }
        }
      
      System.out.println(count);
    }
}

 

Measured memory_bytes: 41120
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

map<long long, long long> prime_factor(long long n) {
    map<long long, long long> res;
    for (long long i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main(){
    long long N, P;
    cin >> N >> P;

    auto mp = prime_factor(P);
    long long ans = 1;
    for(auto x : mp){
        long long cnt = x.second / N;
        long long fac = 1;
        for(int i=0; i<cnt; i++)
            fac *= x.first;
        ans *= fac;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
const int inf=1<<30;

ll n,A,B,C;
#include<string>
char cho[100005];
string s[100005];
int main()
{
	cin>>n>>A>>B>>C;
	F(i,1,n) cin>>s[i];
	bool flg=1;
	if(s[1]=="AB"&&A==0&&B==0) flg=0;
	if(s[1]=="BC"&&C==0&&B==0) flg=0;
	if(s[1]=="AC"&&A==0&&C==0) flg=0;
	if(flg){
	if(A+B+C>=3)
	{
		F(i,1,n)
		{
			if(s[i]=="AB"){if(A>B) cho[i]='B',--A,++B;else cho[i]='A',--B,++A;}
			if(s[i]=="AC"){if(A>C) cho[i]='C',--A,++C;else cho[i]='A',--C,++A;}
			if(s[i]=="BC"){if(C>B) cho[i]='B',--C,++B;else cho[i]='C',--B,++C;}
		}
	}
	else if(A+B+C==2)
	{
		if(flg) 
		F(i,1,n)
		{
			if(s[i]=="AB")
			{
				if(A<B) cho[i]='A',--B,++A;
				else if(A>B) cho[i]='B',--A,++B;
				else if(A==B)
				{
					int x=n+1;
					F(j,i+1,n) if(s[j]!="AB") {x=j;break;}
					int t=1;if(s[x]=="AC") t=0;
					F(j,i,x-1) {if(t) cho[j]='B',--A,++B;else cho[j]='A',--B,++A;t^=1;}
					i=x-1;
				}
			}
			else if(s[i]=="BC")
			{
				if(B<C) cho[i]='B',--C,++B;
				else if(B>C) cho[i]='C',--B,++C;
				else if(B==C)
				{
					int x=n+1;
					F(j,i+1,n) if(s[j]!="BC") {x=j;break;}
					int t=0;if(s[x]=="AB") t=1;
					F(j,i,x-1) {if(t) cho[j]='B',--C,++B;else cho[j]='C',--B,++C;t^=1;}
					i=x-1;
				}
			}
			else
			{
				if(A<C) cho[i]='A',--C,++A;
				else if(A>C) cho[i]='C',--A,++C;
				else if(A==C)
				{
					int x=n+1;
					F(j,i+1,n) if(s[j]!="AC") {x=j;break;}
					int t=0;if(s[x]=="AB") t=1;
					F(j,i,x-1) {if(t) cho[j]='A',--C,++A;else cho[j]='C',--A,++C;t^=1;}
					i=x-1;
				}
			}
			//printf("after step %d,A=%d,B=%d,C=%d\n",i,A,B,C);
		}
	}
	else if(A+B+C==1)
	{
		F(i,1,n)
		{
			if(s[i]=="AB") {if(A==0&&B==0){flg=0;break;}if(A>B) cho[i]='B',--A,++B;else cho[i]='A',--B,++A;}
			if(s[i]=="AC") {if(A==0&&C==0){flg=0;break;}if(A>C) cho[i]='C',--A,++C;else cho[i]='A',--C,++A;}
			if(s[i]=="BC") {if(C==0&&B==0){flg=0;break;}if(C>B) cho[i]='B',--C,++B;else cho[i]='C',--B,++C;}
		}
	}
	else flg=(n==0);}
	if(!flg) puts("No");
	else
	{
		puts("Yes");
		F(i,1,n) printf("%c\n",cho[i]);
	}
	return 0;
}
/*
4 1 0 1
AC
AC
AC
BC

*/

Measured memory_bytes: 6984
#include <iostream>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
        ll i,N,K,first=0,last=0,ans=0;
        cin >> N >> K;
        for(i=0;i<K-1;++i){first += i; last += N-i;}
        for(i=K-1;i<N+1;++i){
                first += i;
                last += N-i;
                ans += last - first + 1;
                ans %= MOD;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3576
import heapq
n = int(input())

a = list(map(int, input().split( )))
a.append(0)
lrg =10**13
dp= [[lrg]*n for _ in range(n)]

for i in range(n):
    dp[i][i] = 0 #
    #dp[i][i+1] = a[i]+a[i+1]
#dp[n-1][n-1] = 0
s = [[0]*(n+1) for i in range(n+1)]
for i in range(n+1):
    for j in range(i,n):
        s[i][j] = sum(a[i:j+1])
#for i in range(n+1):
#  	print(*s[i])
for d in range(n):#n-1ではない
    for i in range(n-d):
        for k in range(d):
            dp[i][i+d] = min(dp[i][i+d],dp[i][i+k]+dp[i+k+1][i+d]+s[i][i+d])###
#for i in range(n):
#  	print(*dp[i])
print(dp[0][n-1])


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

int main(){
  int n;
  cin >> n;
  
  string ans = "No";
  for(auto i=1; i<=9; i++){
    if(n%i == 0 and n/i <= 9)
      ans = "Yes";
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
Y,N = gets.split.map(&:to_i) #入力
a = 0 #一万円の枚数
while a * 10000 <= N
  b = 0 #5000円の枚数
  while b * 5000 + a * 10000 <= N
    c = (N - (a * 10000 + b * 5000)) / 1000 #1万円の枚数と5000円の枚数が決まれば、考えられる千円札の枚数は一意に決まる。
    if(a+b+c==Y&&a*10000+b*5000+c*1000==N) #枚数がYかつ合計金額がNなら出力して終了
      puts "#{a} #{b} #{c}"
      exit
    end
    b += 1
  end
  a += 1
end
puts "-1 -1 -1" #ここまでプログラムが動いてるってことは当てはまらなかったってこと

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

template <class T> int getbit(T s, int i) { return (s >> i) & 1; }
template <class T> T onbit(T s, int i) { return s | (T(1) << i); }
template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template <class T> ll cntbit(T s) { return __builtin_popcntll(s); }

#define all(a) (a).begin(), (a).end()
#define ms(a, x) memset(a, x, sizeof(a))
#define sz(a) ((ll)(a).size())
#define bot(i, n) for (int i = 0; i < (n); ++i)
#define top(i, n) for (int i = (n)-1; i >= 0; --i)
#define bot_(i, a, b) for (int i = (a); i <= (b); ++i)
#define top_(i, a, b) for (int i = (a); i >= (b); --i)
#define forv(v, it) for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); it++)
#define print(x) cout << __LINE__ << #x << " = " << x << endl
#define clear(x) v.clear(); vector<T>(v).swap(v)

#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define eps 1e-12

#define div ___div
#define next ___next
#define prev ___prev
#define left ___left
#define right ___right
#define y0 ___y0
#define y1 ___y1

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

  char a, b;
  cin >> a >> b;

  if(a > b) {
    cout << ">" << endl;
  } else if (a < b) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }

  return 0;
}

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

#define rep(i, n) for(int i=0; i<n; i++)
#define erep(i, m, n) for(int i=m; i<=n; i++)

static const int dx[] = {-1, 0, 1, 0};
static const int dy[] = {0, -1, 0, 1};
int n;
int h, w;
int X1[1111], Y1[1111];
int X2[1111], Y2[1111];
bool maze[6666][6666];

inline bool check(int hx, int hy){ return 0 <= hx && hx < h - 1 && 0 <= hy && hy < w - 1;}

int main(int argc, char *argv[])
{
  while(cin >> w >> h, w){
    cin >> n;
    rep(i, n) cin >> Y1[i] >> X1[i] >> Y2[i] >> X2[i];

    vector<int> x, y;
    rep(i, n) erep(dz, -1, 1){
      int nx1 = X1[i] + dz;
      int nx2 = X2[i] + dz;
      int ny1 = Y1[i] + dz;
      int ny2 = Y2[i] + dz;

      if(0 <= nx1 && nx1 <= h) x.push_back(nx1);
      if(0 <= nx2 && nx2 <= h) x.push_back(nx2);
      if(0 <= ny1 && ny1 <= w) y.push_back(ny1);
      if(0 <= ny2 && ny2 <= w) y.push_back(ny2);
    }
    x.push_back(0);
    x.push_back(h);
    y.push_back(0);
    y.push_back(w);
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    y.erase(unique(y.begin(), y.end()), y.end());
    rep(i, n){
      X1[i] = find(x.begin(), x.end(), X1[i]) - x.begin();
      X2[i] = find(x.begin(), x.end(), X2[i]) - x.begin();
      Y1[i] = find(y.begin(), y.end(), Y1[i]) - y.begin();
      Y2[i] = find(y.begin(), y.end(), Y2[i]) - y.begin();
    }
    h = x.size();
    w = y.size();
    
    rep(i, h) rep(j, w) maze[i][j] = false;
    rep(i, h) maze[i][w - 1] = true;
    rep(j, w) maze[h - 1][j] = true;
    rep(k, n) erep(i, X1[k], X2[k] - 1) erep(j, Y1[k], Y2[k] - 1) maze[i][j] = true;

    int res = 0;
    rep(i, h) rep(j, w) if(!maze[i][j]) {
      res += 1;
      maze[i][j] = true;
      queue<pair<int, int> > que;
      que.push(make_pair(i, j));
      while(!que.empty()){
        pair<int, int> here = que.front();  que.pop();
        int hx = here.first;
        int hy = here.second;
        rep(k, 4){
          int nx = hx + dx[k];
          int ny = hy + dy[k];
          if(!check(nx, ny)) continue;
          if(!maze[nx][ny]){
            maze[nx][ny] = true;
            que.push(make_pair(nx, ny));
          }
        }
      }
    }

    cout << res << endl;
  }
  
  return 0;
}

Measured memory_bytes: 11128
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    int v[1000][3]={0};
    vvi hoge(n,vi(3));
    rep(i,n){
        rep(j,3){
            int temp; cin>>temp;
            hoge[i][j]=temp;
            v[temp][j]++;
        }
    }
    rep(i,n){
        int ans=0;
        rep(j,3)if(v[hoge[i][j]][j]==1)ans+=hoge[i][j];
        cout<<ans<<endl;
                    
    }
}

Measured memory_bytes: 3180
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    double sum = 0;
    REP(i, N) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") { sum += x; }
        else { sum += x * 380000; }
    }
    print(sum);
}


Measured memory_bytes: 256
#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 main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  vector<int> b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >>b[i];
  
  ll t = 0;
  rep(i,m) t += b[i];
  
  int j = m;
  int ans = 0;
  rep(i, n+1) {
    while(j > 0 && t > k) {
      --j;
      t -= b[j];
    }
    if(t > k) break;
    ans = max(ans, i+j);
    if(i == n) break;
    t += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4740
while True:
    N=input()
    if N==0:break
    L=[set(map(int,raw_input().split())[1:]) for i in range(N)]
    K=set(map(int,raw_input().split())[1:])
    ans=[i+1 for i in range(N) if K.issubset(L[i])]
    print -1 if len(ans)!=1 else ans[0]

Measured memory_bytes: 5628
fun main(args: Array<String>) {
    val A = readLine()!!
    val B = readLine()!!
    if (A == B) {
        println("EQUAL")
        return
    }
    if (A.length > B.length) {
        println("GREATER")
        return
    } else if (A.length < B.length) {
        println("LESS")
        return
    }

    for (i in A.indices) {
        if (A[i] == B[i]) {
            continue
        }
        if (A[i] > B[i]) {
            println("GREATER")
            return
        } else {
            println("LESS")
            return
        }
    }
}



Measured memory_bytes: 31812
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    vector<P> v;
    int ans = 0;

    rep(i,n){
        int l,r;
        cin >> l >> r;
        ans = max(ans, r - l + 1);
        v.push_back(P(l,r));
    }
    sort(v.begin(), v.end());
    int mi1[n];
    int mi2[n];
    rep(i,n){
        if(i == 0){
            mi1[i] = v[i].second;
        }else{
            mi1[i] = min(mi1[i-1], v[i].second);
        }
    }
    drep(i,n){
        if(i == n-1){
            mi2[i] = v[i].second;
        }else{
            mi2[i] = min(mi2[i+1], v[i].second);
        }
    }

    rep(i,n-1){
        int l1 = v[i].first;
        int l2 = v[n-1].first;
        int r1 = v[i].second;
        int r2 = mi2[i+1];
        if(i != 0){
            if(r1 <= r2){
                r1 = min(r1, mi1[i-1]);
            }else{
                r2 = min(r2, mi1[i-1]);
            }
        }
        if(l1 <= r1 && l2 <= r2){
            int tmp = r1 - l1 + 1 + r2 - l2 + 1;
            ans = max(ans, tmp);
        }
    }

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


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*y/gcd(x,y);
}

int main(){
	ll N; cin>>N;
    printf("%lld",3*N*N);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
	string s;

	cin >> s;

	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for i in range(1,n):
        E[i].append((i-1,0))
    for _ in range(m):
        l,r,c=map(int,input().split())
        l-=1; r-=1
        E[l].append((r,c))

    # Dijkstra with heap
    from heapq import heappop,heappush
    Q=[(0,0)]
    dist=[INF]*n
    dist[0]=0
    while(Q):
        d,v=heappop(Q)
        if(dist[v]<d): continue
        for nv,w in E[v]:
            if(dist[nv]>dist[v]+w):
                dist[nv]=dist[v]+w
                heappush(Q,(dist[nv],nv))
    ans=dist[-1]
    if(ans==INF): ans=-1
    print(ans)
resolve()

Measured memory_bytes: 78624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const int PI = acos(-1);
int main(){
	ll h,w;
	cin>>h>>w;
	if(h%3==0||w%3==0){
		cout<<0<<endl;
		return 0 ;
	}
	ll ans =INFL;
	rep(i,h-1){
		ll a = (i+1)*w;
		ll b =  (h-i-1)*((w+1)/2);
		ll c = (h-i-1)*(w/2);
		ll ma = max(a,max(b,c));
		ll mi = min(a,min(b,c));
		ans=min(ans,ma-mi);
	}
	rep(i,w-1){
		ll a = (i+1)*h;
		ll b = (w-i-1)*((h+1)/2);
		ll c = (w-i-1)*(h/2);
		ll ma = max(a,max(b,c));
		ll mi = min(a,min(b,c));
		ans=min(ans,ma-mi);
	}
	ans = min(ans, h);
    ans = min(ans, w);
	cout<<ans<<endl;
	
}

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


int main(){
  string s;
  int n,i;
  cin >> n;
  cin >> s;
  for(i=0;i<s.size();++i){
    if(s[i]+n>90){
      s[i]=s[i]-26+n;
    }else{
    s[i]=s[i]+n;
  }
  }

  cout << s << endl;
  return 0;

}


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

long int h,w;
long long int h_half1, h_half2;
long long int w_half1, w_half2;
long long int ans;

int main() {
  cin >> h >> w;
  if (h == 1 or w == 1) {
    ans = 1;
  }else{
    h_half2 = h / 2;
    h_half1 = h - h_half2;
    w_half2 = w / 2;
    w_half1 = w - w_half2;
    ans = h_half1 * w_half1 + h_half2 * w_half2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int c=-1;
  for(int i=0;i<n-1;i++){
    if(a[i]+a[i+1]>=l){
      c=i;
      break;
    }
  }
  if(c==-1){
    cout << "Impossible" << endl;
  }
  else{
    cout << "Possible" << endl;
    for(int i=0;i<c;i++){
      cout << i+1 << endl;
    }
    for(int i=n-1;i>c+1;i--){
      cout << i << endl;
    }
    cout << c+1 << endl;
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if ((a+b) % 2 == 0) cout << (a+b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    int n, W;
    cin >> n >> W;
    vector<int> v(n), w(n);
    rep(i, n) cin >> v[i] >> w[i];

    vector<int> dp(W+1, -1);
    dp[0] = 0;
    rep(i, n){
        rep(j, W+1){
            if(j < w[i] || dp[j-w[i]] == -1){
                continue;
            }
            dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
        }
    }
    int ans = 0;
    rep(i, W+1){
        if(ans < dp[i]){
            ans = dp[i];
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    string s,t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    
    string u;
    cin >> u;
    if(u == s) { a--;} 
    else       { b--;}

    cout << a << " " << b << endl;
    
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,d,a,ans;
bool s[111];
int main()
{
	cin>>n>>k;
	for(int i=0;i<k;i++){
		cin>>d;
		for(int j=0;j<d;j++){
			cin>>a;
			s[a]=1;
		}
	}
	for(int i=1;i<=n;i++){
		if(!s[i])ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3624
def main(argv)
  n = gets.chomp.to_i
  
  m = Math.sqrt(n).ceil
  
  k = 1e+19.to_i
  m.downto(1) do |a|
    if n % a == 0 then
      b = n / a
      k = [k, a + b - 2].min
    end
  end
  puts k.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int used[100010];

int main ()
{
    ll N,X,M;
    cin >> N >> X >> M;

    ll A = X;
    map<ll,ll> table;
    for (int i = 0; i < N; i++) {
        if (used[A] == 2) {
            N = N - i;
            break;
        }
        used[A]++;
        if (used[A] == 2) {
            table[table.size()] = A;
        }

        A = (A * A) % M;

        if (i == N - 1) {
            ll ans = 0;
            REP(j,100010) {
                ans += used[j] * j;
            }
            cout << ans << endl;
            return 0;
        }
    }

    ll sum = 0;
    ll ans_a = 0;
    REP(i,100010) {
        if (used[i] == 2) {
            sum += i;
        }
        ans_a += used[i] * i;
    }

    ll ans = (N / (ll)table.size()) * sum + ans_a;
    N = N - ((N / (ll)table.size()) * (ll)table.size());

    for (int i = 0; i < N; i++) {
        ans += table[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7048
N=int(input())
X=input()
Y=int(X,2)
Z=Y
C=X.count('1')
if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()
Y,Z=Y%(C+1),Z%(C-1)
def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))

for i in range(N):
  if X[i]=='1':
    print(1+f((Z-pow(2,N-i-1,C-1))%(C-1)))
  else:
    print(1+f((Y+pow(2,N-i-1,C+1))%(C+1)))


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

#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pqMax priority_queue<int>
#define pqMin priority_queue<int, vector<int>, greater<int>>
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie()
int n, t, i, j, k;

void dfs(int i, unordered_map<int, vi>& graph, vector<bool>& vis, vi& dp) {
    vis[i] = true;
    for (int child : graph[i]) {
        if (!vis[child]) {
            dfs(child, graph, vis, dp);
        }
        dp[i] = max(dp[child] + 1, dp[i]);
    }
}

void solve() {
    int n, m;
    cin >> n >> m;

    unordered_map<int, vi> graph;
    vi dp(n + 1);
    vector<bool> vis(n + 1);

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
    }

    for (int i = 1; i <= n; i++) {
        if (!vis[i])
            dfs(i, graph, vis, dp);
    }
    int ans = *max_element(dp.begin(), dp.end());
    cout << ans << '\n';
}

int32_t main() {
    FAST;
    solve();
}

Measured memory_bytes: 13220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)


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

	ll N;
	cin >> N;
	map<ll, set<ll> > M; // (Ai - i, {i})
	vector<ll> A(N + 1, 0);
	for (ll i = 1; i <= N; i++) {
		ll a;
		cin >> a;
		M[a - i].insert(i);
		A[i] = a;
	}
	ll c = 0;
	for (ll i = 1; i <= N; i++) {
		ll d = -A[i] - i;
		c += M[d].size();
	}
	cout << c << endl;


	return(0);
}


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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N,K=0;
    cin>>N;
    vector<int>A(N),B;
    rep(i,N)cin>>A[i];

    B.pb(A[0]);
    if(N%2==1){
        K=1;
    }
    REP(i,1,N){
        if(i%2==K){
            B.pb(A[i]);
        }else{
            B.insert(B.begin(),A[i]);
        }
    }

    rep(i,N-1)cout<<B[i]<<" ";
    cout<<B[N-1];

    return 0;
}

//a=97,z=122

Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');

        var dict = new Dictionary<string, int>();

        dict.Add(input[0], 0);
        dict.Add(input[1], 0);

        var input2 = Console.ReadLine().Split(' ');

        dict[input[0]] += int.Parse(input2[0]);
        dict[input[1]] += int.Parse(input2[1]);

        var input3 = Console.ReadLine();

        dict[input3] -= 1;

        Console.WriteLine($"{dict[input[0]]} {dict[input[1]]}");
        Console.ReadLine();

    }
}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<int, lli> il;
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;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))

int main() {
	int N;
	scanf("%d", &N);
	int a[300100];
	for (int i = 0; i < 3*N; i++) {
		scanf("%d", &a[i]);
	}

	priority_queue<int, vector<int>, greater<int> > queA;
	priority_queue<int> queB;
	lli sum = 0;
	lli suma[100100];
	SET_ZERO(suma);
	for (int i = 0; i < N; i++) {
		queA.push(a[i]);
		sum += a[i];
	}
	suma[0] = sum;

	for (int i = N; i < 2 * N; i++) {
		queA.push(a[i]);
		sum += a[i];
		sum -= queA.top();
		queA.pop();
		suma[i-N+1] = sum;
	}

	sum = 0;
	for (int i = 2 * N; i < 3 * N; i++) {
		queB.push(a[i]);
		sum += a[i];
	}
	suma[N] -= sum;

	for (int i = 2 * N - 1; i >= N; i--) {
		queB.push(a[i]);
		sum += a[i];
		sum -= queB.top();
		queB.pop();
		suma[i-N] -= sum;
	}

	lli ans = -1001001001001001;
	for (int i = 0; i <= N; i++) {
		chmax<lli>(ans, suma[i]);
	}
	printf("%lld\n", ans);
	return 0;
}																


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define dep(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n=in();
  vi x(n);
  EACH(i,x) cin>>i;
  
  vi y=x;
  sort(ALL(y));
  
  rep(i,n)
  {
    if(x[i]<y[n/2]) print(y[n/2]);
    else print(y[n/2-1]);
  }

  return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<bitset>
#include<deque>
#include<cstring>
#include<cassert>
#include<climits>

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

using namespace std;

int n,m,b[510][510];
int pc[1<<24],dp[2][1<<24],bits[510];

void compute() {
  int maxi = 0;
  if( n <= m ) {
    rep(i,(1<<n)) {
      if( maxi >= pc[i] ) continue;
      bool ok = true;
      rep(x,m) {
	int cnt = 0;
	rep(y,n) if( ( (i>>y) & 1 ) && b[y][x] ) ++cnt;
	if( cnt & 1 ) {
	  ok = false;
	  break;
	}
      }
      if( ok ) maxi = max(maxi,pc[i]);
    }
  } else { // n > m
    rep(y,n) {
      bits[y] = 0;
      rep(x,m) if( b[y][x] ) bits[y] = bits[y] | (1<<x);
    }
    memset(dp,-1,sizeof dp);
    dp[0][0] = 0;
    rep(y,n) {
      rep(i,(1<<m)) dp[(y+1)&1][i] = -1;
      rep(state,(1<<m)) if( dp[y&1][state] != -1 ) {
	dp[(y+1)&1][state] = max(dp[(y+1)&1][state],dp[y&1][state]);
	dp[(y+1)&1][state^bits[y]] = max(dp[(y+1)&1][state^bits[y]],dp[y&1][state]+1);
      }
    }
    if( dp[n&1][0] != -1 ) maxi = dp[n&1][0];
  }
  cout << maxi << endl;
}

int main() {
  rep(i,(1<<23)) pc[i] = __builtin_popcount(i);
  while( cin >> n >> m, n|m ) {
    rep(i,n) {
      string s;
      cin >> s;
      rep(j,m) b[i][j] = ( s[j] == '1' );
    }
    compute();
  }
  return 0;
}

Measured memory_bytes: 167888
#include <cstdio>
#include <cstdlib>
int bit[100001],n,m;
int sum(int x) {
	int s=0;
	while(x>0) {s+=bit[x]; x-=x&-x;}
	return s;
}
void add(int x,int y) {
	while(x<=n) {bit[x]+=y; x+=x&-x;}
}
int main() {
	scanf("%d %d",&n,&m);
	for(int i=2;i<=n;i++) {
		int si; scanf("%d",&si); add(i,si);
	}
	int ans=0,now=1;
	for(int i=0;i<m;i++) {
		int ai;
		scanf("%d",&ai);
		ans=(ans+abs(sum(now+ai)-sum(now)))%100000;
		now+=ai;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), ans(n);
    rep(i,n) {
        cin >> a[i];
        ans[a[i]-1] = i+1;
    }
    rep(i,n)
        cout << ans[i] << " ";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 4012
S = gets.chomp

L = S.length
@ma = ->(a, b){a > b ? a : b}
@mi = ->(a, b){a > b ? b : a}
s = 0; as = [s]
S.each_char{|c| s += c == '1' ? 1 : -1; as << s}
@bs = Array.new(L + 1)
@bs[-1] = as[-1]
(0 ... L).reverse_each{|i| @bs[i] = @ma[as[i], @bs[i + 1]]}
z = @bs[0]

def f(m)
  s, ad, ret = 0, 0, 0
  S.each_char.with_index do |c, i|
    case c
    when '1'
      s += 1
    when '0'
      s -= 1
      ret = @mi[ret, s]
    else
      if ad + @bs[i + 1] + 2 <= m
        s += 1
        ad += 2
      else
        s -= 1
        ret = @mi[ret, s]
      end
    end
  end
  ret
end

puts @mi[z - f(z), z + 1 - f(z + 1)]

Measured memory_bytes: 40080
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    int A[n];
    
    int s=0;
    int fr[100000+5]={0};

    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        s+=A[i];
        fr[A[i]]++;
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        int x,y;
        cin>>x>>y;
        s-=fr[x]*x;

        s+=fr[x]*y;
        
        fr[y]+=fr[x];
        fr[x]=0;
        cout<<s<<'\n';
    }

    

return 0;
}

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

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

   for(int i=0;i<n;i++){
    while(a[i]%2==0){
      c++;a[i]=a[i]/2;
     
    }
   }     
     
     cout<<c<<endl;
 }


Measured memory_bytes: 384
n, M = map(int, input().split())

friends_set = [set() for i in range(n+1)]

for m in range(M):
    a, b = map(int, input().split())
    friends_set[a].add(b)
    friends_set[b].add(a)

graphs = [False]*(n+1)
maxC = 0
from collections import deque

for current in range(1, n+1):
    if graphs[current]:
        continue
    graphs[current] = True

    count = 0
    candidate = deque(friends_set[current])
    while len(candidate) > 0:
        f = candidate.popleft()

        if graphs[f]:
            continue
        count += 1
        graphs[f] = True
        candidate += list(friends_set[f])
    maxC = max(maxC , count)

print(maxC + 1)

Measured memory_bytes: 73040