akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
using namespace std;
const int w=20003;
char s[10005];
int x,y,_x,len,p,sum,q,now=1;
bool ws[2][2][40009];
int main(void){
    register int i;
    scanf("%s%d%d",s+1,&x,&y),len=strlen(s+1),x+=w,y+=w;
    while(now<=len&&s[now]=='F')++now,++_x;
    ws[0][0][w+_x]=1,ws[1][0][w]=1;
    while(now<=len){
        ++now,sum=0,p^=1,q^=p;
        while(now<=len&&s[now]=='F')++sum,++now;
        for(int i=w-len;i<=w+len;++i)
            ws[p][q][i]=ws[p][q^1][i+sum]|ws[p][q^1][i-sum];
    }
    if(p==1&&ws[0][q^1][x]&&ws[1][q][y]||p==0&&ws[0][q][x]&&ws[1][q][y])puts("Yes");
    else puts("No"); 
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
now = 0
d = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a in d.keys():
        d[a] += b
    else:
        d[a] = b

d = sorted(d.items())

for key, value in d:
    now += value
    if now >= K:
        print(key)
        exit()


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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;

void solve(){
   int n;
   cin >> n;
   vi v(n);
   for(int i=0;i<n;i++)cin >> v[i];
   sort(all(v));
   ll ans=INT_MAX;
   for(int i=v[0];i<=v[n-1];i++){
     ll tmp=0;
       for(int j=0;j<n;j++){
          tmp+=(i-v[j])*(i-v[j]);
       }
       ans=min(ans,tmp);
   }
   cout << ans;
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R){
    cout << "Left" << endl;
  }
  else if (L == R){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

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

vector<int> Graph[200010];
int Score[200010];
bool flag[200010];

void dfs(int s){
    if(flag[s]) return;
    flag[s] = true;
    for(int v : Graph[s]){
        if(flag[v]) continue;
        Score[v] += Score[s]; 
        dfs(v);
    }
}


int main(){
    int n,q;
    cin >> n >> q;
    int a,b;
    rep(i,n-1){
        cin >> a >> b;
        a--; b--;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
        Score[i] = 0;
    }
    Score[n-1]=0;
    int p,x;
    rep(i,q){
        cin >> p >> x;
        p--;
        Score[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout << Score[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 20608
import java.util.Scanner;

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

		int N = sc.nextInt();
		long K = sc.nextLong();
		int Q = sc.nextInt();
		
		long[] seikai = new long[N];
		for (int i=0; i<Q; i++) {
			int A = sc.nextInt();
			seikai[A-1]++;
		}

		StringBuilder sb = new StringBuilder();
		for (int i=0; i<N; i++) {
			sb.append((K - (Q - seikai[i]) <= 0 ? "No" : "Yes") + "\n");
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 61596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n,l;
    cin >> n >> l;
    int taste=0;
    for(int i=1; i<=n; i++){
        taste += l+i-1;
    }

    int eat=10000;
    for(int i=1; i<=n; i++){
        if(abs(eat)>abs(l+i-1)){
            eat = l+i-1;
        }
    }

    cout << taste-eat << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pri(a) cout<<a<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    string a,li[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    cin>>a;
    rep(i,7){
        if(a==li[i])cout<<(7-i)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        if (s.equals("A")) System.out.println("T");
        else if (s.equals("T")) System.out.println("A");
        else if (s.equals("C")) System.out.println("G");
        else System.out.println("C");
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    vector <ll> row(3);
    vector <vector <ll>  > dp;
    dp.resize(n,row);
    dp[0][0]=1;
    dp[0][1]=s[0]-48;
    dp[0][2]=s[0]-48;

    for(int i=1;i<n;i++)
    {
        dp[i][0]=2*dp[i-1][0];
        dp[i][1]=2*dp[i-1][0]*(s[i]-48)+dp[i-1][1]*10;
        dp[i][2]=2*dp[i-1][2]+dp[i-1][0]*(s[i]-48)-dp[i-1][1]+dp[i-1][1]*10+dp[i-1][0]*(s[i]-48);
    }
    cout<<dp[n-1][2]<<endl;
    

    
    return 0;   
}


 
 


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
a.sort!
a.reverse!

ans = a[0]

current = 1
used = 0

2.upto(a.size-1) do |_|
  if used > 1
    current += 1
    used = 0
  end
  ans += a[current]
  used += 1
end

puts ans



Measured memory_bytes: 29732
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N, M;
	cin >> N >> M;
	int l = 1, r = N;
	int in1, in2;
	for(int i = 0; i < M; i ++){
		cin >> in1 >> in2;
		l = max(l, in1);
		r = min(r, in2);
	}
	cout << max(0, r - l + 1) << endl;

	return 0;
}

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

typedef long long ll;

const int MAX_N = 8000 + 3;
ll n, x, y, ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> x >> y;
	while (x * 2 <= y) {
		x *= 2;
		ans++;
	}

	cout << ans + 1 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    int a, b, c, tmp;
    scanf("%d %d %d", &a, &b, &c);
    while(1){
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    else if (b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }
    else if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    else break;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}



Measured memory_bytes: 2100
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  string s; in(s);
  int n = s.size();
  loop(len,2,4) {
    if (len > n) break;
    loop(l,0,n-len+1) {
      map<char, int> M;
      int max_ = 0;
      loop(i,l,l+len) {
        M[s[i]]++;
        max_ = max(max_, M[s[i]]);
      }
      if (max_ > len/2) {
        cout << l+1 << " " << l+len << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1" << endl;
  return 0;
}


Measured memory_bytes: 3756
N,K=map(int,input().split())
X=list(map(int,input().split()))
if X[0]>=0:
    b=X[K-1]
elif X[-1]<=0:
    b=abs(X[-K])
elif 0 in X:
    a=0
    b=10**9
    for i in range(N):
        if X[i]==0:
            a=i
            break
    for j in range(max(0,K-1-a),min(K,N-a)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
else:
    a=0
    b=10**9
    for i in range(N):
        if X[i]>0:
            a=i
            break
    for j in range(max(-1,K-a-1),min(K,N-a)):
        if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):
            b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))
print(b)

Measured memory_bytes: 14252
#ifndef _WIN32
#include<iostream>
#endif
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
typedef vector<string> VS;
VS wrap(VS v,char c) {
	int R = v.size(), C = v[0].size();
	VS ret(R + 2, string(C + 2, c));
	REP(i, R)REP(j, C)ret[i + 1][j + 1] = v[i][j];
	return ret;
}
const int dr[] = { 0,0,1,-1 };
const int dc[] = { 1,-1,0,0 };

void w(int r, int c,VS&x) {
	if (x[r][c] != '.')return;
	x[r][c] = 'w';
	REP(i, 4) {
		w(r + dr[i], c + dc[i], x);
	}
}
void b(int r, int c, VS&x) {
	if (x[r][c] != '.')return;
	x[r][c] = 'b';
	REP(i, 4) {
		b(r + dr[i], c + dc[i], x);
	}
}

int main() {
	int R, C;
	while (cin >> C >> R, R + C) {
		VS in(R);
		REP(i, R)cin >> in[i];
		in = wrap(in, '#');
		auto ww = in;
		auto bb = in;
		REP(i, R + 2)REP(j, C + 2)if (in[i][j] == 'W') {
			REP(k,4)w(i+dr[k], j+dc[k], ww);
		}
		REP(i, R + 2)REP(j, C + 2)if (in[i][j] == 'B') {
			REP(k,4)b(i+dr[k], j+dc[k], bb);
		}
		int wwww = 0, bbbb = 0;
		REP(i, R + 2)REP(j, C + 2)if (in[i][j] == '.') {
			if (ww[i][j] == 'w'&&bb[i][j] != 'b')wwww++;
			if (bb[i][j] == 'b'&&ww[i][j] != 'w')bbbb++;

		}
		cout << bbbb << " " << wwww << endl;
	}
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<long long, int>> k(n);
  rep(i,n){
    long long y;
    int q;
    cin >> y >> q;
    pair<long long, int> s;
    s=make_pair(y,q);
    k[i]=s;
  }
  sort(k.begin(),k.end());
  long long ans=0;
  int c=0;
  while(m>0){
    int z=k[c].second;
    long long x=k[c].first;
    //cout << z << " " << m << " " << x << endl;
    if(z<=m){
      m-=z;
      ans+=x*z;
    }
    else{
      z=m;
      m=0;
      ans+=z*x;
    }
    c++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
long long int aa[100050];
long long int bb[100050];
long long int cc[100050];
bool cmp(long long int a,long long int b)
{
    return a>b;
}
int main()
{
    long long int x,y,a,b,c,i,j,k,ci=0;
    scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
    for(i=1;i<=a;i++)
        scanf("%lld",&aa[i]);
    for(i=1;i<=b;i++)
        scanf("%lld",&bb[i]);
    for(i=1;i<=c;i++)
        scanf("%lld",&cc[i]);
    sort(&aa[1],&aa[a+1],cmp);
    sort(&bb[1],&bb[b+1],cmp);
    sort(&cc[1],&cc[c+1],cmp);
    /*
    for(i=1;i<=a;i++)
        printf("%lld ",aa[i]);
    printf("\n");
    for(i=1;i<=b;i++)
        printf("%lld ",bb[i]);
    printf("\n");
    for(i=1;i<=c;i++)
        printf("%lld ",cc[i]);
    printf("\n");*/
    for(i=1;i<=x;i++)
    {
        ci+=aa[i];
    }
    for(i=1;i<=y;i++)
    {
        ci+=bb[i];
    }
    for(i=x,j=y,k=1;;)
    {
        if(k>c)
            break;
        if(i==0&&j==0)
        {
            break;
        }
        else if(i==0)
        {
            if(cc[k]>bb[j])
            {
                ci+=cc[k]-bb[j];
                k++;
                j--;
            }
            else 
                break;
        }
        else if(j==0)
        {
            if(cc[k]>aa[i])
            {
                ci+=cc[k]-aa[i];
                k++;
                i--;
            }
            else 
                break;
        }
        else if(cc[k]>aa[i]||cc[k]>bb[j])
        {
            if(aa[i]<bb[j])
            {
                ci+=cc[k]-aa[i];
                k++;
                i--;
            }
            else
            {
                ci+=cc[k]-bb[j];
                k++;
                j--;
            }
        }
        else
            break;
    }
    printf("%lld\n",ci);
}


Measured memory_bytes: 2560
// O(F|E|)

#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

const int INF = 1e9 + 10;

class MaxFlow {
private:

#define MAX_V 10001
  struct Edge {
    int to, cap, rev;
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) { }
  };

  vector<Edge> G[MAX_V];
  bool used[MAX_V];

  int Dfs(int v, int t, int f) {
    if (v == t) {
      return f;
    }
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
      Edge& e = G[v][i];
      if (!used[e.to] && e.cap > 0) {
        int d = Dfs(e.to, t, min(f, e.cap));
        if (d > 0) {
          e.cap -= d;
          G[e.to][e.rev].cap += d;

          return d;
        }
      }
    }

    return 0;
  }

public:

  void AddEdge(int from, int to, int cap) {
    G[from].push_back(Edge(to, cap, G[to].size()));
    G[to].push_back(Edge(from, 0, G[from].size() - 1));
  }

  int Solve(int s, int t) {
    int flow = 0;

    while (true) {
      memset(used, 0, MAX_V);
      int f = Dfs(s, t, INF);
      if (f == 0) {
        break;
      }
      flow += f;
    }

    return flow;
  }
};

#include <iostream>
#include <string>

int main() {
  int h, w;
  cin >> h >> w;

  MaxFlow mf;
  int s = 0, t =  h + w + 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char str;
      cin >> str;
      if (str == 'S') {
        mf.AddEdge(s, 1 + i, INF);
        mf.AddEdge(1 + i, s, INF);
        mf.AddEdge(s, h + j + 1, INF);
        mf.AddEdge(h + j + 1, s, INF);
      } else if (str == 'T') {
        mf.AddEdge(t, 1 + i, INF);
        mf.AddEdge(1 + i, t, INF);
        mf.AddEdge(t, h + j + 1, INF);
        mf.AddEdge(h + j + 1, t, INF);
      } else if (str == 'o') {
        mf.AddEdge(1 + i, h + j + 1, 1);
        mf.AddEdge(h + j + 1, 1 + i, 1);
      }
    }
  }

  int ans = mf.Solve(s, t);
  if (ans >= INF) {
    ans = -1;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1152
n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: -x[2])

for cx in range(101):
    for cy in range(101):
        h = l[0][2] + abs(l[0][0] - cx) + abs(l[0][1] - cy)
        for i in l[1:]:
            if max(h - abs(i[0] - cx) - abs(i[1] - cy), 0) != i[2]:
                break
        else:
            print(cx, cy, h)
            exit()

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

int main() { 
    ll N;
    cin >> N;
    map<string, ll> memo;
    for (int i = 0; i < N; i++){
      string s;
      cin >> s;
      memo[s] += 1;
    }
    ll maxv = 0;
    for(auto a: memo){
      ll v = a.second;
      if (v > maxv) maxv = v;
    }
    for (auto it = memo.begin(); it != memo.end(); it++){
      if (it->second == maxv) cout << it->first << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> r(n), b(n);
	for (auto&& p : r) cin >> p.first >> p.second;
	for (auto&& p : b) cin >> p.second >> p.first;
	sort(r.begin(), r.end(), greater<pair<int, int>>());
	sort(b.begin(), b.end());
	int count = 0;
	for (auto&& ri : r)
		for (auto&& bi : b)
		{
			if (ri.first < bi.second && ri.second < bi.first)
			{
				count++;
				bi.first = bi.second = -1;
				break;
			}
		}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
import sys,math,random
#sys.setrecursionlimit(100000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

a,b,c,k=invr()

ans=0
if k:
	ans+=min(a,k)
	k-=min(a,k)
if k:
	ans+=0*(min(b,k))
	k-=min(k,b)
if k:
	ans-=min(c,k)
	k-=c

print(ans)


Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],b[maxn],c[maxn];
int main(){
    scanf("%d",&n);
    for (int i=1; i<=n; i++) scanf("%d",&a[i]);
    for (int i=1; i<=n; i++) scanf("%d",&b[i]);
    for (int i=1; i<=n; i++) scanf("%d",&c[i]);
    sort(a+1,a+1+n);
    sort(c+1,c+1+n);

    long long  p1,p2,ans=0;
    for (int now,i=1; i<=n; i++){
        now=lower_bound(a+1,a+1+n,b[i])-a;
        p1=(now-1);
        now=upper_bound(c+1,c+1+n,b[i])-c;
        p2=(n-now+1);
        ans+=1ll*p1*p2;
//        printf("%d %d %d\n",i,p1[i],p2[i]);
    }


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


Measured memory_bytes: 1408
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np
#import sympy

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split())
    ans = 0
    for a in range(1,n):
        z = n//a
        if n%a == 0:
            ans += z-1
        else:
            ans += z
    print(ans)





if __name__ == '__main__':
    solve()


Measured memory_bytes: 9188
import fractions

def main():
    n, a, b = map(int, input().split())
    diff = b - a
    if diff%2 == 0:
        print(diff//2)
        return
    d1 = a + b - 1
    d2 = n - a + n - b + 1
    print(min(d1, d2)//2)

if __name__ == '__main__':
    main()

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

int simulate(string s, char c) {
  int ans = 0;
  while (s.length() > 0 && s != string(s.length(), c)) {
    string tmp = "";
    for (int i = 0; i < s.length() - 1; i++) {
      tmp += (s[i] == c || s[i + 1] == c ? c : s[i]);
    }
    s = tmp;
    ans++;
  }
  return ans;
}

int main(void) {
  string s;
  cin >> s;
  set<char> se;
  for (int i = 0; i < s.length(); i++) {
    se.insert(s[i]);
  }

  int ans = 10000;
  for (auto c : se) {
    ans = min(simulate(s, c), ans);
  }
  cout << ans << endl;
  return 0;
}

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

int main(void){
  //  int x2,h2;
  double x,h;
  double s;
  double h2;

  while(1){
    scanf("%lf%lf",&x,&h);
    if(x==0&&h==0)
      break;

    //    x=x2;
    //    h=h2;
    s=0;
    s+=x*x;
    h2=(double)sqrt((x/2)*(x/2)+(h*h));
    s+=2*x*h2;
    printf("%.6f\n",s);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<queue>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int n;
vector <vector<pair<int, int>>>vp;//長さと相手の頂点
vector<int>color;

void dfs(int v, int p,int c) {
	color[v] = c;
	for (auto x:vp[v]) {
		if (x.first == p)continue;//戻らないように
		if (x.second == 0)dfs(x.first, v, c);
		else dfs(x.first, v, 1-c);
	}
}
int main() {
	cin >> n;
	vp.assign(n, vector<pair<int, int>>());//縦の大きさだけ決める
	color.resize(n, 0);
	int u, v, w;
	for (int i = 0; i < n - 1; ++i) {
		cin >> u >> v >> w;
		u--; v--;
		vp[u].push_back(make_pair(v,w%2));
		vp[v].push_back(make_pair(u,w%2));//隣接リスト
	}
	dfs(0,0,0);//無理矢理根と決める
	for (auto e :color)cout << e << endl;
	return 0;
}


Measured memory_bytes: 8960
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int		main(void)
{
	int	N;
	int	A[200000];
	int	i;
	int	j;

	i = -1;
	scanf("%d", &N);
	while (++i < N)
		scanf("%d", &A[i]);
	qsort(A, N, sizeof(int), asc);
	i = -1;
	j = 0;
	while (j < N)
	{
		if (A[i] == A[j])
		{
			printf("NO\n");
			return (0);
		}
		i++;
		j++;
	}
	printf("YES\n");
	return (0);
}


Measured memory_bytes: 1788
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String answer="";
		answer+=change(sc.next());
		while(sc.hasNext()){
			answer+=" "+change(sc.next());
		}
		System.out.println(answer);
	}
	static String change(String str){
		char[] apple={'a','p','p','l','e'};
		char[] peach={'p','e','a','c','h'};
		char[] c=str.toCharArray();
		if(str.length()>=apple.length){
			for(int i=0;i<str.length()-apple.length+1;i++){
				boolean appleFlag=true;
				boolean peachFlag=true;
				for(int j=0;j<5;j++){
					if(c[j+i]!=apple[j]){
						appleFlag=false;
					}
					if(c[j+i]!=peach[j]){
						peachFlag=false;
					}
				}
				if(appleFlag){
					for(int j=0;j<5;j++){
						c[i+j]=peach[j];
					}
					i+=4;
				}
				if(peachFlag){
					for(int j=0;j<5;j++){
						c[i+j]=apple[j];
					}
					i+=4;
				}
			}
			str=String.valueOf(c);
		}
		return str;
	}
}

Measured memory_bytes: 17296
from math import factorial

N, K = map(int, input().split())

modulo = 10 ** 9 + 7

def C(n, m):
    return factorial(n) // factorial(m) // factorial(n - m)

for i in range(1, K + 1):
    if N - K + 1 >= i:
        # 赤玉と赤玉の間 N - K + 1 箇所からi個選ぶ
        s = C(N - K + 1, i) % modulo

        # 青玉 K個をi箇所に分ける (仕切りの置き方)
        t = C(K - 1, i - 1) % modulo
        print(s * t % modulo)
    else:
        print(0)


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};

int main(void){
    int n;
    while(cin >> n, n){
        int map[501][501];
        rep(i,0,501){
            rep(j,0,501){
                map[i][j] = 0;
            }
        }
        vector<pair<int,int>> tile_place(n);
        rep(i,0,n) tile_place[i] = {-1,-1};
        
        map[501/2][501/2] = 1;
        tile_place[0] = {501/2, 501/2};

        rep(i,1,n){
            int pid,dir; cin >> pid >> dir;

            int nx = tile_place[pid].first + dx[dir];
            int ny = tile_place[pid].second + dy[dir];
            map[ny][nx] = 1;
            tile_place[i] = {nx, ny};
        }

        int lx = 250, ly = 250;
        int rx = 250, ry = 250;
        rep(i,0,n){
            if(tile_place[i].first != -1){
                lx = min(lx,tile_place[i].first);
                rx = max(rx, tile_place[i].first);
                ly = min(ly,tile_place[i].second);
                ry = max(ry, tile_place[i].second);
            }
        }

        cout << rx-lx+1 << " " << ry-ly+1 << "\n";
    }
}


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

int main(){
    int n, c;
    c = 0;
    bool bl=true;
    cin >> n;
    unsigned a[n];
    for(int i=0; i<n; ++i){
        cin >> a[i];
    }
    while(bl){
        for(int i=0; i<n; ++i){
            if(a[i]%2==0){
                a[i] = a[i]/2;
            }else{
                bl=false;
            }
        }
        if(bl) c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll ndat;
vector<ll> dat;

void rmg_init(ll n_) {
  ndat = 1;
  while (ndat < n_) ndat *= 2;
  dat.resize(2 * ndat - 1, INF);
}

void update(ll k, ll a) {
  k += ndat - 1;
  dat[k] = a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}

ll query(ll a, ll b, ll k, ll l, ll r) {
  if (r <= a || b <= l) return INF;
  if (a <= l && r <= b) return dat[k];
  else {
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
}

int main() {
  ll n, m;
  cin >> n >> m;
  string s;
  cin >> s;

  rmg_init(n + 1);
  update(0, 0);
  reverse(s.begin(), s.end());
  FOR(i, 1, n + 1) {
    if (s[i] == '1') continue;
    ll cnt = query(i - m, i, 0, 0, ndat);
    if (cnt != INF) {
      update(i, cnt + 1);
    }
  }
  if (dat[ndat + n - 1] == INF) {
    cout << -1 << endl;
    return 0;
  }
  else {
    map<ll, ll> idx;
    rep(i, n + 1) {
      idx[dat[i + ndat - 1]] = i;
    }
    repr(i, dat[ndat + n - 1] - 1) {
      cout << idx[i + 1] - idx[i] << " ";
    }
    cout << endl;
  }

  


  
  return 0;
}

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

int main(){
    
    long long int n;
    cin >> n;
    long long int num;

    for(long long int i=sqrt(n); i>0; i--){
        if(n%i==0){
            num=n/i;
            break;
        }
    }
//    cout << num << endl;

    int ans=0;
    while(num>0){
        ans++;
        num/=10;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long
#define MOD 1000000007


int main() {
	int n, s[20],a = 0,sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		a = max(a, s[i]);
		sum += s[i];
	}
	if (sum - a > a)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#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 REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )

class DisjointSet {
public:
    DisjointSet(){};
    DisjointSet(int size) {
        p_.resize(size, 0);
        rank_.resize(size, 0);
    };

    void makeSet(int x) {
        p_[x] = x;
        rank_[x] = 0;
    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }
    int findSet(int x) {
        if (x != p_[x]) {
            p_[x] = findSet(p_[x]);
        }
        return p_[x];
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if (rank_[x] > rank_[y]) {
            p_[y] = x;
        }else{
            p_[x] = y;
            if (rank_[x] == rank_[y]) {
                rank_[y]++;
            }
        }
    }

private:
    vector<int> p_, rank_;
};


int P[100001];
int main() {
    int N, M;
    cin >> N >> M;
    auto d = DisjointSet(N);
    rep(i, 0, N) {
        cin >> P[i];
        d.makeSet(i);
    }
    rep(i, 0, M) {
        int x, y;
        cin >> x >> y;
        d.unite(P[x-1]-1, P[y-1]-1);
    }
    std::vector<int> s;
    s.resize(N, 0);
    int cnt = 0;
    rep(i, 0, N) {
        if (d.same(i, P[i]-1)) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

using namespace std;
#define int long long
int n,m;int ans;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
struct str {
	int x,y;
};
string mp[666];
int vis[66][66];
void bfs(int x,int y){
	for(int i=0;i<33;i++)
		for(int j=0;j<33;j++)	
			vis[i][j]=-1;
	vis[x][y]=0;
	queue<str> q;
	q.push((str){x,y});
	while(!q.empty()){
		struct str t;
		t=q.front();
		q.pop();
		for(int i=0;i<4;i++){
			int tx=t.x+dx[i];
			int ty=t.y+dy[i];
			if(tx>=0&&ty>=0&&tx<n&&ty<m&&vis[tx][ty]==-1&&mp[tx][ty]!='#'){
				vis[tx][ty]=vis[t.x][t.y]+1;
				ans=max(ans,vis[tx][ty]);
				q.push((str){tx,ty});
			}
		}
	}
}
signed main(){
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>mp[i];
	ans=0;
	for(int i=0;i<n;i++){
	    for(int j=0;j<m;j++){
			if(mp[i][j]=='.'){
				bfs(i,j);
			}
		}
	}cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define jai_shree_ram  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, a, b, d) for (int i = a; i <= b; i += d)
#define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
#define pb push_back
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define endl '\n'
const int MAX = 1e5 + 5;
const int MOD = 1e9 + 7;
////////////////////////////////

pair <int, pii> dp[3005][3005];

int32_t main(){
    jai_shree_ram
    string s, t;
    cin >> s >> t;
    int l1 = s.length(), l2 = t.length();

    rep(i,1,l1,1){
        rep(j,1,l2,1){
            if(dp[i-1][j].first >= dp[i][j-1].first){
                dp[i][j] = dp[i-1][j];
            }
            else dp[i][j] = dp[i][j-1];
            
            if(s[i-1] == t[j-1]){
                dp[i][j] = {dp[i-1][j-1].first + 1, {i, j}};
            }
        }
    }
    string ans = "";
    int i = l1, j = l2;
    while(1){
        int i1 = (dp[i][j].second).first;
        int j1 = (dp[i][j].second).second;
        if(i1 == 0) break;
        ans += s[i1 - 1];
        if(i1 == 1) break;
        i = i1 - 1;
        j = j1 - 1;
    }   
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 211584
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, m, dp[1001][1001], M = 1e9+7;
char arr[1001][1001];
int main()
{
    IOS
    //bfreopen("balalance.in", "r", stdin);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
                if (arr[i][j]=='#') {
                    continue;
                }
            if (i+1 < n) {
                dp[i+1][j] += dp[i][j];
                if (dp[i+1][j] >= M) {
                    dp[i+1][j] -= M;
                }
            }
            if (j+1 < m) {
                dp[i][j+1] += dp[i][j];
                if (dp[i][j+1] >= M) {
                    dp[i][j+1] -= M;
                }
            }
        }
    }
    cout << dp[n-1][m-1] << endl;

    return 0;
}


Measured memory_bytes: 5120
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func sum(a ...int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	x, y, z := make([]int, n), make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		x[i], y[i], z[i] = nextInt(), nextInt(), nextInt()
	}

	ans := 0
	sums := make([]int, n)
	for bit := 0; bit < (1 << 3); bit++ {
		for i := 0; i < n; i++ {
			sum := 0
			sum += x[i] * (1 - 2*((bit>>0)&1))
			sum += y[i] * (1 - 2*((bit>>1)&1))
			sum += z[i] * (1 - 2*((bit>>2)&1))
			sums[i] = sum
		}
		sort.Sort(sort.Reverse(sort.IntSlice(sums)))
		ans = max(ans, sum(sums[:m]...))
	}

	puts(ans)
}


Measured memory_bytes: 768
<?php
$n = trim(fgets(STDIN));
$a = explode(' ',trim(fgets(STDIN)));
$ans = 1;

if (in_array("0",$a)) {
    echo "0".PHP_EOL;
    exit;
}
foreach ($a as $num) {
    $ans *= $num;
    if ($ans > 10 ** 18) {
        echo "-1".PHP_EOL;
        exit;
    }
}

echo $ans.PHP_EOL;


Measured memory_bytes: 25772
use std::io::Read;

fn main() {
    let (a, p) = {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let a: usize = iter.next().unwrap().parse().unwrap();
        let p: usize = iter.next().unwrap().parse().unwrap();
        (a, p)
    };
    
    print!("{}", (a * 3 + p) / 2);
}

Measured memory_bytes: 4352
N = int( input())
A_1 = list(map(int,input().split()))
A_2 = list(map(int,input().split()))

max_num= 0
for i in range(N):
    sum_1 = sum(A_1[0:i+1])
    sum_2 = sum(A_2[i:N])
    sum_all = sum_1 + sum_2
    if max_num < sum_all:
        max_num = sum_all
print(max_num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int pj(string a,string b)
{
	int la=a.size();
	int lb=b.size();
	if(la>lb) return 2;
	if(la<lb) return 3;
	for(register int i=0;i<la;i++)
	{
		if(a[i]>b[i]) return 2;
		if(a[i]<b[i]) return 3;
	}
	return 1;
}
string st_read()
{
	string st;
	char c=getchar();
	while(c!='\n')
	{
		st+=c;
		c=getchar();
	}
	return st;
}
int main()
{
	string a,b;
	a=st_read();
	b=st_read();
	int f=pj(a,b);
	if(f==1) puts("EQUAL");
	else if(f==2) puts("GREATER");
	else if(f==3) puts("LESS");
	return 0;
}


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

int main() {
    int s;
    cin >> s;
    set<int> st;
    int x = s;
    while (st.count(x) == 0) {
        st.insert(x);
        if (x % 2 == 0) x /= 2;
        else x = 3 * x + 1;
    }
    cout << st.size() + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  scanf("%d%d",&a,&b);

  if(a>0) printf("Positive\n");
  else if(a<=0 && b>=0) printf("Zero\n");
  else{
    if((b-a+1)%2==1) printf("Negative\n");
    else printf("Positive\n");

  }
  return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [ [] for i in range(N) ], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp[i] = ls[1:]
for i in range(1 << N):
    price_combi, exp_combi, exp_sum, ls_cnt = [], [], [0] * M, []
    for j in range(N):
        if i >> j & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in exp_combi:
        for t in range(M):
            exp_sum[t] += s[t]
    [ ls_cnt.append(x) for x in exp_sum if x >= X ]
    if len(ls_cnt) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)

Measured memory_bytes: 9244
n, m = gets.split.map(&:to_i)
x = gets.split.map(&:to_i).sort

if n >= m
  puts 0
  exit
end

diff = []
1.upto(x.size - 1) do |i|
  diff << x[i] - x[i - 1]
end
diff.sort!

ans = 0
0.upto(diff.size - 1 - (n - 1)) { |i| ans += diff[i] }
puts ans



Measured memory_bytes: 10736
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
	os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
	is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		os << vec[i];
		if(i+1<vec.size())os << ' ';
	}
	return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
	for(int i=0;i<vec.size();i++)is >> vec[i];
	return is;
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
int H,W;
int main(){
  cin >> H >> W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      string s;
      cin >> s;
      if(s=="snuke"){
        cout << (char)(j+'A') << i+1 << endl;
        return 0;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
int bi[40];

int main()
{
	ll n;
	int keta=0;
	cin>>n;
	if(n==0)
	{
		cout<<0<<endl;
	}else{
		while(n!=0)
		{
			cerr<<n<<endl;
			ll t=pow(-2,keta+1);
			if(n%t==0)
			{
				bi[keta]=0;
			}else{
				bi[keta]=1;
				n-=pow(-2,keta);
			}
			keta++;
		}
	}
	reverse(bi,bi+40);
	bool f=false;
	for(int i=0;i<40;i++)
	{
		if(bi[i]==1)
			f=true;
		if(f)
			cout<<bi[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(){
  int a,b,ans;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?')break;
    if(op=='+'){
      ans=a+b;
    }else if(op=='-'){
      ans=a-b;
    }else if(op=='*'){
      ans=a*b;
    }else if(op=='/'){
      ans=a/b;
    }
    printf("%d\n",ans);
  }
  return 0;
}

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

int main() {
  string b;
  cin >> b;
  if (b == "A" ) 
    cout << "T" << endl;
  if (b == "C") 
    cout << "G" << endl;
  if (b == "G") 
    cout << "C" << endl;
  if (b == "T") 
    cout << "A" << endl;
  return 0;
}
  
  

Measured memory_bytes: 256
n = input()
st1 = raw_input()
st2 = raw_input()
m = 1
mod = 1000000007
pat = 0 # or 1,2
bl = False
for i in range(n):
  #print m
  if pat == 2 and bl:
    bl = False
    continue
  if st1[i] == st2[i] and pat == 0:
    m = m*3%mod
    pat = 1
  elif st1[i] == st2[i] and pat == 1:
    m = m*2%mod
    pat = 1
  elif st1[i] == st2[i] and pat == 2:
    pat = 1
  elif st1[i] != st2[i] and pat == 0:
    m = m*6%mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat == 1:
    m = m*2%mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat == 2:
    m = m*3%mod
    pat = 2
    bl = True
print m

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

int main() {
  //入力M
  int a ,b ,c ,d ,e ,f;	//s1s2s3

  
  cin >> a;
  
  b = a / 100;
  c = a % 100;
  d = c / 10;
  e = c % 10;
  f = e / 1;
  
  cout << b + d + f << endl; 
}

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

int main() {
  char x, y;
  cin >> x >> y;
  char res;
  if (x > y) {
    res = '>';
  } else if (x == y) {
    res = '=';
  } else {
    res = '<';
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n; double x[100000], y[100000];
    
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++)
    {
        scanf("%lf", &x[i]);
        scanf("%lf", &y[i]);
    }
    
    pair<double, double> p1[100000], p2[100000];
    
    for(int i = 0; i < n; i++)
    {
        p1[i] = make_pair(x[i], y[i]);
    }
    
    for(int i = 0; i < n; i++)
    {
        p2[i] = make_pair(y[i], x[i]);
    }
    
    sort(p1, p1 + n);
    sort(p2, p2 + n);
    
    double sqr_ans = 100000000.0;
    
    const int loops = 125;
    
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(loops, n - i - 1);
        
        for(int j = 1; j <= r; j++)
        {
            double distance_ = (p1[i + j].first - p1[i].first) * (p1[i + j].first - p1[i].first) + (p1[i + j].second - p1[i].second) * (p1[i + j].second - p1[i].second);
        
            sqr_ans = min(distance_, sqr_ans);
        }
    }
    
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(loops, n - i - 1);
        
        for(int j = 1; j <= r; j++)
        {
            double distance_ = (p2[i + j].first - p2[i].first) * (p2[i + j].first - p2[i].first) + (p2[i + j].second - p2[i].second) * (p2[i + j].second - p2[i].second);
        
            sqr_ans = min(distance_, sqr_ans);
        }
    }
    
    printf("%.15f\n", sqrt(sqr_ans));
    
    return 0;
}

Measured memory_bytes: 7440
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

// > (8+1)*2
#define BUF_SIZE 30

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

struct time {
    int hh;
    int mm;
    int ss;
};

int to_ss(struct time *t) {
    return t->hh * 3600 + t->mm * 60 + t->ss;
}

#define HHMMSS_FMT "%02d:%02d:%02d"
#define LIMIT_TIME (3600*24)

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  struct time t1, t2;
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, HHMMSS_FMT " " HHMMSS_FMT,
    &t1.hh, &t1.mm, &t1.ss,
    &t2.hh, &t2.mm, &t2.ss
  );
  *a1 = to_ss(&t1);
  *a2 = to_ss(&t2);
#else
#error
#endif
  return 0;
}

#define ANS_MAX 10000
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int main(void) {
    int ans[ANS_MAX];
    int ans_idx = 0;
    int i, j;
    static int diff[LIMIT_TIME] = {0};
    while(1) {
        int num = get_int();
        if(!num) break;
        int ulimit = 0;
        memset(diff, 0, sizeof(int)*LIMIT_TIME);
        int llimit = LIMIT_TIME;
        for(i = 0; i < num; i++) {
            int start, end;
            get_int2(&start, &end);
#ifdef DEBUG
            printf("%d -> %d\n", start, end);
#endif
            diff[start]++;
            diff[end]--;
            ulimit = max(ulimit, end);
            llimit = min(llimit, start);
        }
        int cum = 0;
        int res = 0;
        for(i = llimit; i <= ulimit; i++) {
            cum += diff[i];
            res = max(res, cum);
        }
        ans[ans_idx++] = res;
    }
    for(i = 0; i < ans_idx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2052
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(a: chars, b: chars);
    puts!("{}\n", (0..3).filter(|&i| a[i] == b[i]).count());
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572