akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

template<typename T> class CHT
{
private:
    using ptt = pair<T, T>;
    bool check(ptt l1, ptt l2, ptt l3){
        return (l2.first-l1.first)*(l3.second-l2.second)>=(l2.second-l1.second)*(l3.first-l2.first);
    }
    T f(int i, T x){
        return lines[i].first * x + lines[i].second;
    }
public:
    vector<ptt> lines;
    int head;
    CHT(): head(0){};
    void add(T a, T b){
        ptt line(a, b);
        while((int)lines.size() - head >= 2 && check(*(lines.end()-2), lines.back(), line)){
            lines.pop_back();
        }
        lines.emplace_back(line);
    }
    T get(T x){
        while((int)lines.size() - head >= 2 && f(head, x) >= f(head + 1, x)){
            head++;
        }
        return f(head, x);
    }
};

ll dp[MAX_N], h[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll c;
    cin >> n >> c;
    rep(i,n){
        cin >> h[i];
    }
    dp[0] = 0;
    CHT<ll> cht;
    rep(i,n-1){
        cht.add(-2*h[i],dp[i]+h[i]*h[i]+c);
        dp[i+1] = cht.get(h[i+1]) + h[i+1]*h[i+1];
    }
    cout << dp[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 9328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		String abc = "abcdefghijklmnopqrstuvwxyz";
		int index = abc.indexOf(c);
		System.out.println(abc.charAt(index+1));
	}
}

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

int main(){
  string S;
  cin >> S;
  int ans=700;
  if(S[0]=='o')
    ans+=100;
  if(S[1]=='o')
    ans+=100;
  if(S[2]=='o')
    ans+=100;
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0
for i in range(n):
    if a[i] < 0:
        a[i] = 0
    if i == n-1:
        if  b[i] <= a[i]+a[i+1]:
            count += b[i]
        else:
            count += a[i]+a[i+1]
    else:
        if b[i] <= a[i]:
            count += b[i]
        else:
            count += a[i]
            if b[i]-a[i] > a[i+1]:
                count += a[i+1]
            else:
                count += b[i]-a[i]
            a[i+1] -= b[i]-a[i]
print(count)

Measured memory_bytes: 82020
// ※※※ 解答不能 ※※※
// square1001氏.
// https://atcoder.jp/contests/cf17-relay-open/submissions/1965243
#include<bits/stdc++.h>
using namespace std;
#define repex(i, a, b, n) for(int i = a; i < b; i += n)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int MOD = 1e9 + 7, n, m, a[109], b[109], pw[109], e[32777], t[32777], c[2][32777];
int main(){
    scanf("%d%d", &n, &m);
    pw[0] = 1;
    repx(i, 1, 106) pw[i] = 2 * pw[i - 1] % MOD;
    rep(i, m) scanf("%d%d", &a[i], &b[i]), a[i]--, b[i]--;
    rep(i, 1 << n){
        rep(j, m){
            if((i & (1 << a[j])) && (i & (1 << b[j]))) e[i]++;
            if((i & (1 << a[j]) ? 1 : 0) + (i & (1 << b[j]) ? 1 : 0) == 1) t[i]++;
        }
    }
    rep(i, 2){
        rep(j, 1 << n){
            if(!(j & (1 << i))) continue;
            for(int k = j; k > 0; k = (k - 1) & j){
                c[i][j] = (c[i][j] + 1LL * c[i][j - k] * pw[e[k]]) % MOD;
            }
            c[i][j] = (pw[e[j]] - c[i][j] + MOD) % MOD;
        }
    }
    int ret = 0;
    repex(i, 1, 1 << n, 2){
        int u = (1 << n) - i - 1;
        for(int j = u; j > 0; j = (j - 1) & u){
            if((j & 2) && e[i | j] == e[i] + e[j]){
                ret = (ret + 1LL * c[0][i] * c[1][j] % MOD * pw[m - e[i | j] - t[i | j]]) % MOD;
            }
        }
    }
    printf("%d\n", (pw[m] - ret + MOD) % MOD);
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
ll B[210000] = { 0, };
int main()
{
	
	int N;
	cin >> N;
	vec(A);
	map<int, ll> K;

	fx(N) {
		vecp(A);
		K[A[x]]++;
		B[A[x]]++;
	}
	ll sum = 0;
	bool flags[210000] = { false, };
	fx(N) {
		if (flags[A[x]]) {
			continue;
		}
		flags[A[x]] = true;
		ll a = K[A[x]];
		K[A[x]]= a * (a - 1) / 2;
		sum+= a * (a - 1) / 2;
	}
	fx(N) {
		ll a = K[A[x]];
		ce(sum - a + (B[A[x]]-1)*(B[A[x]] - 2)/2)
	}


    return 0;
}



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

int main(){
	int N;
	cin >> N;
	if (N<=3)
	{cout << "No" << endl;return 0;}
	for(int i=0; i<N; ++i){
		for (int n=0; n<=25; ++n){
			for (int m=0; m<=15; ++m){
				int sum = 4*n + 7*m;
				if (N == sum){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}	
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long
#define ull unsigned long long
using namespace std;

ull s(ull arg) {
    ull ret = 0;
    while(arg > 0) {
        ret += arg % 10;
        arg /= 10;
    }
    return ret;
}

int main(){
    ull k;
    cin >> k;

    ull base = 1;
    ull diff = 1;
    while(k > 0) {
        if(((double)base / s(base)) <= ((double)(base + diff) / s(base + diff))) {
            cout << base << endl;
            base += diff;
            k--;
        } 
        else {
            base -= diff;
            diff *= 10;
            base += diff;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    cin >> n;
    vector<P> v(n);
    rep(i, n)
    {
        int x, l;
        cin >> x >> l;
        v[i] = P(x + l, x - l);
    }
    sort(all(v));
    int now = -INF, ans = 0;
    rep(i, n)
    {
        if (now <= v[i].second)
        {
            ans++;
            now = v[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int maxm=2e5+5;
int l[maxm],r[maxm];
char s[maxm];
signed main(){
    int n,k,c;cin>>n>>k>>c;
    scanf("%s",s+1);
    int now=0;
    for(int i=1;i<=n;i++){
        if(s[i]=='o'){
            l[++now]=i;
            i+=c;
            if(now==k)break;
        }
    }
    now=k;
    for(int i=n;i>=1;i--){
        if(s[i]=='o'){
            r[now--]=i;
            i-=c;
            if(now==0)break;
        }
    }
    for(int i=1;i<=k;i++){
        if(l[i]==r[i]){
            cout<<l[i]<<endl;
        }
    }
    return 0;
}


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

int main() {
    int a,b,c;
    int x = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if ((c%i) == 0) {
            x++;
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3096
import math
A,B,H,M = map(int,input().split())
s = H * 60 + M
Md = (M/60) * 360
Hd = (s/(12 * 60)) * 360
a = abs(Md-Hd)
if a > 180:
    a = 360 - a
a = math.radians(a)
a2 = (A**2+B**2)-(2*B*A*math.cos(a))
print(math.sqrt(a2))

Measured memory_bytes: 9508
#include <bits/stdc++.h>
  
using namespace std;
typedef long long ll;
  
#define rep(i, n) for(int i=0; i<(n); ++i)
 
class team {
public:
    int id, solve, time, miss[11];
    bool operator<(const team & rhs) const{
        if(solve > rhs.solve) return true;
        else if(solve==rhs.solve && time < rhs.time) return true;
        else if(solve==rhs.solve && time == rhs.time && id > rhs.id) return true;
        return false;
    }
};
int main(void){
    int M, T, P, R;
    int m, t, p, j;
    team teams[51];
    while(cin >> M >> T >> P >> R && M) {
        rep(i, T) {
            teams[i].id = i+1;
            teams[i].solve = 0;
            teams[i].time = 0;
            rep(j, P+1) teams[i].miss[j] = 0;
        }
        rep(i, R) {
            cin >> m >> t >> p >> j;
            t--;
            if(j == 0) {
                teams[t].solve++;
                teams[t].time += m + teams[t].miss[p] * 20;
            } else {
                teams[t].miss[p]++;
            }
        }
        sort(teams, teams+T);
        rep(i, T-1) {
            cout << teams[i].id;
            if(teams[i].solve==teams[i+1].solve && teams[i].time==teams[i+1].time) {
                cout << "=";
            } else {
                cout << ",";
            }
        }
        cout << teams[T-1].id << endl;
    }
}

Measured memory_bytes: 1188
/*Infor {{{
 ******************************************************
 * > File Name: 1.cpp
 * > Author: samcompu
 * > Mail: admin@samcompu.com
 * > Created Time: 2018/7/7/周六 20:00:54
 ******************************************************
}}}*/

#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define cini(a) scanf("%d", &(a))
#define cinc(a) scanf("%c", &(a))
#define cinl(a) scanf("%lld", &(a))
#define cins(a) scanf("%s", (a))
#define cind(a) scanf("%lf", &(a))
#define coui(a) printf("%d", (a))
#define couc(a) printf("%c", (a))
#define coul(a) printf("%lld", (a))
#define cous(a) printf("%s", (a))
#define coud(a) printf("%f", (a))
#define SPA printf(" ")
#define LIN printf("\n")
#define ull unsigned long long int
/*}}}*/

/*Constant {{{*/
/*}}}*/

/*Struct {{{*/
/*}}}*/

/*Variable {{{*/
int a, b;
/*}}}*/

/*Function {{{*/
/*}}}*/

/*Main {{{*/
int main() {
  cin>>a>>b;
  if (a + b == 15) cout<<"+"<<endl;
  if (a * b == 15) cout<<"*"<<endl;
  if (a + b != 15 && a * b != 15) cout<<"x"<<endl;
  return 0;
}
/*}}}*/


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S; int n;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		S = "";
		while (S == "")
		{
			getline(cin, S);
		}
		if (S.size() >= 7) {
			for (int i = 0; i < S.size() - 6; i++) {
				if (S.substr(i, 7) == "Hoshino") {
					S[i + 6] = 'a';
				}
			}
		}
		cout << S << endl;
	}
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint operator()(int n) { return fact[n]; }
};

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

    // a+2b = X
    // b+2a = Y
    // (a+b)*3 = X+Y

    // b+2(X-2b) = X
    // b+2X-4b = X
    // b+2X-4b = X

    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    lint a = Y - (X + Y) / 3;
    lint b = X - (X + Y) / 3;

    if (a < 0 or b < 0) {
        cout << 0 << endl;
        return 0;
    }

    combination comb(10000000);

    cout << comb(a + b, a).x << endl;

    return 0;
}

Measured memory_bytes: 159488
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <vector>
using namespace std;
using ll = long long int;

int main() {
    ll n;
    cin >> n;
    map<ll, ll> mp;
    vector<ll> v;
    for (size_t i = 0; i < n; i++)
    {
        ll ai;
        cin >> ai;
        mp[ai]++;
        v.push_back(ai);
    }

    ll ans = 0;
    for (auto &&i : mp)
    {
        ans += i.second * (i.second -1) / 2;
    }

    for (int i =0; i< n; i++)
    {
        ll ai = v[i];
        if (mp[ai] == 0 || mp[ai] == 1){ 
            cout << ans << endl;
        } else {
            cout << (ans - (2 * mp[ai] - 1)/2) << endl;
        }
    }    
}

Measured memory_bytes: 11120
#include <stdio.h>

int main(){
	long long int n;
	scanf("%lld",&n);
	long long int num[n]={};
	long long int res=1;
	for (int i=0;i<n;i++){
		scanf("%lld",&num[i]);
	}
	for(int i=0;i<n;i++){
	
		if (num[i]==0){
			printf("0\n");
			return 0;
		}
		}
	for (int i=0;i<n;i++){
		if(num[i]<=1000000000000000000/res){
			res*=num[i];
		}
		else{
			printf("-1\n");
			return 0;
		}
	}	
		printf("%lld",res);
		return 0;
	}
	

Measured memory_bytes: 2484
#include <iostream>

int main(int argc, char *argv[]) {
  int N, Y;
  std::cin >> N >> Y;

  int x = -1, y = -1, z = -1;
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      int k = N - i - j;
      if (k >= 0 && Y == (10000 * i + 5000 * j + 1000 * k)) {
        x = i;
        y = j;
        z = k;
      }
    }
  }

  std::cout << x << " " << y << " " << z << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int ans,wx,wy,rem;
int tab[10][10];
inline void solve(int nx,int ny,int rem){
    int nowx,nowy;
    nowx=nx;nowy=ny;
LA:
   nowx++;
   if(nowx>=wx) goto LB;
   else if(tab[nowx][nowy]==2&&rem==0)ans++;
   else if(tab[nowx][nowy]==1){
       tab[nowx][nowy]=-1;
       solve(nowx,nowy,rem-1);
       tab[nowx][nowy]=1;
       goto LB;
   }
   goto LA;
LB:         

    nowx=nx,nowy=ny;
MA:
   nowx--;
   if(0>nowx) goto MB;
   else if(tab[nowx][nowy]==2&&rem==0)ans++;
   else if(tab[nowx][nowy]==1){
       tab[nowx][nowy]=-1;
       solve(nowx,nowy,rem-1);
       tab[nowx][nowy]=1;
       goto MB;
   }
   goto MA;
MB:         
    nowx=nx,nowy=ny;
NA:
   nowy++;
   if(nowy>=wy) goto NB;
   else if(tab[nowx][nowy]==2&&rem==0)ans++;
   else if(tab[nowx][nowy]==1){
       tab[nowx][nowy]=-1;
       solve(nowx,nowy,rem-1);
       tab[nowx][nowy]=1;
       goto NB;
   }
   goto NA;
NB:        
    nowx=nx,nowy=ny;
OA:
   nowy--;
   if(0>nowy) goto OB;
   else if(tab[nowx][nowy]==2&&rem==0)ans++;
   else if(tab[nowx][nowy]==1){
       tab[nowx][nowy]=-1;
       solve(nowx,nowy,rem-1);
       tab[nowx][nowy]=1;
       goto OB;
   }
   goto OA;
OB: ;
}
int main(){
    for(;;){
        int m,n;
        scanf("%d%d",&m,&n);
        if(m==0&&n==0)break;
        int stx,sty,homec=0;
        int i,j;
        for(i=0;i<n;i++)for(j=0;j<m;j++){
            scanf("%d",&tab[i][j]);
            if(tab[i][j]==1)homec++;
            else if(tab[i][j]==2){stx=i;sty=j;}
        }
        wx=n;wy=m;
        ans=0;
        solve(stx,sty,homec);
        printf("%d\n",ans);
    }
    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; vector<int> ht; cin >> n;
    for(int i = 0; i < n; i++){
        int x; cin >> x; ht.push_back(x);
    }
    int cost[100010]= {0};
    for(int i = 2; i <= n; i++){
        cost[i] = cost[i-1] + abs(ht[i-1] - ht[i-2]);
        if(i>2){
            cost[i] = min(cost[i], cost[i-2]+abs(ht[i-1]- ht[i-3]));
        }
    }
    cout << cost[n] << endl;
    return 0;
}

Measured memory_bytes: 1144
N,M=map(int, input().split())

sum = 1

s = []
c = []
n=0
for i in range(M):
  si,ci=map(int, input().split())
  sum = sum * ( (si-1)**2+ci**2 )
  if si in s:
    if(ci!=c[s.index(si)]):
      sum = 0
      n = n + ci * 10 ** (N-si)
  else:
    n = n + ci * 10 ** (N-si)
  s.append(si)
  c.append(ci)

if 1 not in s:
  n = n + 10 ** (N-1)
  
if sum == 0:
  if (N-1)**2+(M-1)**2+(si-1)**2+ci**2 == 0:
    print(0)
  else:
    print(-1)
else:
  if M == 0:
    if N == 1:
      print(0)
    else:
      print(10**(N-1))
  else: 
    print(n)

Measured memory_bytes: 3192
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  l=LI()

  for i in range(len(l)):
    if l[i]==0:
      return i+1

# main()
print(main())


Measured memory_bytes: 10600
module WeightedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  val prim :
    (* 頂点のリスト *)
    Vertex.t list ->
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) list) ->
    (* 最小全域木に含まれる辺のリスト *)
    (Vertex.t * Vertex.t * Weight.t) list
end =
struct
  module VSet = Set.Make (Vertex)
  module WMap = Map.Make (Weight)

  (*
   * プリム法のメインループ
   * es : 隣接リスト
   * vs : 未だ訪れていない頂点の集合
   * q : 訪れた頂点から伸びる辺が重み順に入ったヒープ
   * acc : 最小全域木に使うのが確定した辺を入れるやつ
   *)
  let rec prim_aux es acc vs q =
    match WMap.min_binding q with
    | exception Not_found -> acc
    | (w, []) -> prim_aux es acc vs (WMap.remove w q)
    | (w, (u, v) :: rest) ->
        if not (VSet.mem v vs) then
          (* vは既に訪れていた *)
          prim_aux es acc vs (WMap.add w rest q)
        else
          (* vはまだ訪れていなかった *)
          prim_aux es ((u, v, w) :: acc) (VSet.remove v vs) @@
            (* vから伸びる辺をキューに追加 *)
            List.fold_left (fun q (u, w) ->
              (* 現時点で既に訪れている頂点への辺は追加しない *)
              if not (VSet.mem u vs) then q
              else WMap.add w ((v, u) :: try WMap.find w q with Not_found -> []) q) (WMap.add w rest q) (es v)

  let prim vs es =
    match vs with
    | [] -> [] (* 念のため *)
    | v :: vs ->
        prim_aux es [] (VSet.of_list vs) @@
          (* 始点から伸びる辺をキューに入れておく *)
          List.fold_left (fun q (u, w) ->
            WMap.add w ((v, u) :: try WMap.find w q with Not_found -> []) q) WMap.empty (es v)
end

module Int = struct
  type t = int
  let compare = compare
end

module G = WeightedGraph (Int) (Int)

let () = Scanf.scanf "%d\n" (fun n ->
  let xys = Array.to_list @@ Array.init n (fun i -> Scanf.scanf "%d %d\n" (fun x y -> x, y, i)) in
  let es = Array.make n [] in
  begin match List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  begin match List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  G.prim (Array.to_list @@ Array.init n (fun i -> i)) (fun i -> es.(i))
  |> List.map (fun (_, _, w) -> w)
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n")

Measured memory_bytes: 58504
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    // Your code here!
 ll i,k,n,s;
 s=0;
 cin >> n >> k;
 int a[k]={0};
 for(i=1;i<=n;i++)
 a[i%k]++;
 s=(ll)pow(a[0],3);
 if(k%2==0)
 s+=(ll)pow(a[k/2],3);
 cout << s;
 return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] a = new long[N];
    long total =0;
    for (int i =0; i<N; i++) {
      a[i] = sc.nextLong();
      total += a[i];
    }
    long x =0 ,y = total, min = Math.abs(total - a[0] * 2);
    for (int i =0; i<N-1; i++) {
      x += a[i];
      y = total - x;
      min = Math.min(Math.abs(x-y),min);
    }
    System.out.print(min);
  }
}

Measured memory_bytes: 71384
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt

    (N * (N % 2 + 1)).toString
  }
}


Measured memory_bytes: 27336
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int N=1e5+55;
int dp[N][105];
int w[105];
int v[105];

main()
{
	int n,W;
	cin>>n>>W;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	int ans=0;
	for(int i=1;i<=W;i++)
	{
		for(int j=1;j<=n;j++)
		{
			dp[i][j]=dp[i][j-1];
			if(w[j]<=i)
				dp[i][j]=max(dp[i][j],dp[i-w[j]][j-1]+v[j]);
			ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans<<endl;
	
	return 0;
}


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

class D
{
	static void Main()
	{
		Console.ReadLine();
		var a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();

		int n = a.Last(), h = n / 2;
		var a1 = a.TakeWhile(x => x <= h).LastOrDefault();
		var a2 = a.SkipWhile(x => x <= h).TakeWhile(x => x < n).FirstOrDefault();

		var r = a2 == 0 ? a1 : a1 > n - a2 ? a1 : a2;
		Console.WriteLine($"{n} {r}");
	}
}


Measured memory_bytes: 23904
#include <iostream>




using namespace std;

int kolvo(int n)
{
  int kol=0;
  for(int i=1;i*i<=n;i++)
  {
    if(n%i==0)
    {
       if(n/i!=i)kol+=2;
       else kol++;
    }

  }
  return kol;
}


long long n,nechet,otvet=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if (i%2!=0)
        {
          int sd=kolvo(i);
          if(sd==8)otvet++;
        }

    }
    cout <<otvet<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <utility>
 
using namespace std;



int main() {

string s;
string t;

cin >>s;
cin >>t;

int l;
l=s.size();

int sc[200]={};
int tc[200]={};

for(int i=0; i<l;i++){
sc[s[i]-97]++;
tc[t[i]-97]++;
}

sort(sc,sc+26);
sort(tc,tc+26);

for(int i=0;i<26;i++){
if(sc[i]!=tc[i]){cout <<"No"; break;}
if(i==25){cout <<"Yes";}
}


}

//'a'==97,'z'=122



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

// cout << "hogehoge" << '\n';  // "endl" executes flush in addition to line break.
int main() {
  cin.tie(nullptr);               // Do not flush "cout" when processing "cin".
  // ios::sync_with_stdio(false); // Be careful when using both "cin/cout" and "scanf/printf".

  string s;
  cin >> s;

  int s_size = (int) s.size();
  cout << s;
  if (s.at(s_size-1) == 's') {
    cout << "es";
  } else {
    cout << "s";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	long double x[52],y[52];
	for(ll i=0;i<n;i++){
		ll X,Y;
		cin>>X>>Y;
		x[i]=X;y[i]=Y;
	}
	long double l=0,r=1002;
	ll cnt=0;
	while(cnt<100){
		cnt++;
		long double c1=(l*2+r)/3;
		long double c2=(l+r*2)/3;
		ll cnt2=0;
		long double ly=0,ry=1002;
		long double R1;
		while(cnt2<100){
			cnt2++;
			long double d1=(ly*2+ry)/3.0;
			long double d2=(ly+ry*2)/3.0;
			long double r1=0;
			for(ll i=0;i<n;i++){
				long double dx=(x[i]-c1)*(x[i]-c1)+(y[i]-d1)*(y[i]-d1);
				dx=sqrt(dx);
				r1=max(r1,dx);
			}
			long double r2=0;
			for(ll i=0;i<n;i++){
				long double dx=(x[i]-c1)*(x[i]-c1)+(y[i]-d2)*(y[i]-d2);
				dx=sqrt(dx);
				r2=max(r2,dx);
			}
			if(r2<r1){
				ly=d1;
			}
			else{
				ry=d2;
			}
			if(cnt2==99){
				R1=min(r1,r2);
			}
		}
		cnt2=0;
		ly=0,ry=1002;
		long double R2;
		while(cnt2<100){
			cnt2++;
			long double d1=(ly*2+ry)/3.0;
			long double d2=(ly+ry*2)/3.0;
			long double r1=0;
			for(ll i=0;i<n;i++){
				long double dx=(x[i]-c2)*(x[i]-c2)+(y[i]-d1)*(y[i]-d1);
				dx=sqrt(dx);
				r1=max(r1,dx);
			}
			long double r2=0;
			for(ll i=0;i<n;i++){
				long double dx=(x[i]-c2)*(x[i]-c2)+(y[i]-d2)*(y[i]-d2);
				dx=sqrt(dx);
				r2=max(r2,dx);
			}
			if(r2<r1){
				ly=d1;
			}
			else{
				ry=d2;
			}
			if(cnt2==99){
				R2=min(r1,r2);
			}
		}
		if(R2<R1){
			l=c1;
		}
		else{
			r=c2;
		}
		if(cnt==99){
			long double ans=min(R2,R1);
			printf("%.10Lf",ans);
		}
	}
//	cout << l<<" "<<r<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3820
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
   var Arr=(input.trim()).split("\n");
   for(var i=0;i<Arr.length;i=i+2){
      var n=Arr[i]-0;
      var str=Arr[i+1];
      for(var j=0;j<n;j++){
      str=str.replace(/0+|1+|2+|3+|4+|5+|6+|7+|8+|9+/g,function(s){
      return s.length+s[0];
      });
      }
      console.log(str);
      if(Arr[i+2]=="0")break;
}

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

string n;

int main() {
    cin >> n;

    for (int i = 0; i < 3; i++) {
        if (n[i] == '1') {
            n[i] = '9';
        } else if (n[i] == '9') {
            n[i] = '1';
        }
    }

    cout << n << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		var rc = 0;
		for (var i = 0; i < n; i++) {
			if (s.substring(i, i + 1).equals("R")) {
				rc++;
			}
		}

		var count = 0;
		for (var i = 0; i < rc; i++) {
			if (s.substring(i, i + 1).equals("W")) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 54816
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def dfs(current, matching, visited):
    for target in range(y_num):
        if not visited[target] and target in adj_table[current]:
            visited[target] = True
            ''' Matching[target] = -1: target not assigned to any of x.
            And dfs(matching[target], matching, visited) = True
            indicates that source in x has been already assigned
            to another target in y. '''
            if matching[target] == -1 or dfs(matching[target], matching, visited):
                matching[target] = current
                return True
    return False


def mbm():
    res = 0
    matching = [-1] * y_num
    for source in range(x_num):
        visited = [False] * y_num
        if dfs(source, matching, visited):
            res += 1
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    adj_table = tuple(set() for _ in range(x_num))
    for edge in edges:
        vx, vy = map(int, edge)
        adj_table[vx].add(vy)
    print(mbm())

Measured memory_bytes: 9188
def ev(n):
    return (n+1) / 2


N, K = map(int, input().split())
p = list(map(int, input().split()))
prev = ev(p[0])
ans = sum([ev(i) for i in p[:K]])
total = ans

for i in range(1, N-K+1):
    total -= prev
    total += ev(p[i+K-1])
    prev = ev(p[i])
    ans = max(ans, total)

print(ans)


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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    int64_t N;
    cin >> N;
    vector<int64_t> num(60);
    for(int i=0; i<N; i++) {
        int64_t A;
        cin >> A;
        for(int j=0; j<60; j++) {
            if(A & (1LL << j)) {
                ++num[j];
            }
        }
    }

    int64_t ans = 0;
    for(int j=0; j<60; j++) {
        ans += ((((1LL << j) % MOD * num[j]) % MOD) * (N-num[j])) % MOD;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int H, W;
const int Hmax = 1000;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
string A[Hmax];

int main(){
	int H, W;
	cin >> H >> W;
	for(int i=0; i<H; i++) cin >> A[i];

	vector<pair<int, int> > v;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(A[i][j]=='#') v.push_back({i, j});
		}
	}

	int ans = 0;
	while(!v.empty()){
		vector<pair<int, int>> v2;
		for(auto p: v){
			for(int k=0; k<4; k++){
				int x = p.first + dx[k];
				int y = p.second + dy[k];
				if(0<=x&&x<H&&0<=y&&y<W&&A[x][y]=='.'){
					//cout << x << " " << y << endl;
					v2.push_back({x, y});
					A[x][y] = '#';
				}
			}
		}
		v = v2;
		ans++;
	}

	cout << ans-1 << endl;

	return 0;
}


Measured memory_bytes: 14312
t = Array.new(180)
(180).times do |i|
    t[i] = (i*(i+1)*(i+2))/6
end
ot = t.select{|e| e.odd?}
dp = Array.new(10**6+1,Float::INFINITY)
dp[0] = 0
dp2 = Array.new(10**6+1,Float::INFINITY)
dp2[0] = 0

t.each do |tn|
    if tn % 2 == 0
        tn.upto(10**6) do |i|
            dp[i] = dp[i - tn] + 1 if dp[i - tn] + 1 < dp[i]
        end
    else
        tn.upto(10**6) do |i|
            dp[i] = dp[i - tn] + 1 if dp[i - tn] + 1 < dp[i]
            dp2[i] = dp2[i - tn] + 1 if dp2[i - tn] + 1 < dp2[i]
        end
    end
end
loop do
    n = gets.to_i
    break if n == 0
    puts "#{dp[n]} #{dp2[n]}"
end

Measured memory_bytes: 21744
#include <iostream>
#include    <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	string a, b;
	cin >> a >> b;
	char t;
	bool flg = false;

	for (int i = 0; i < a.size(); i++) {
		t = a[0];
		for (int j = 0; j < a.size(); j++) {
			a[j] = a[j + 1];
		}
		a[a.size() - 1] = t;
		if (a == b) {
			flg = true;
			break;
			
		}
	}

	if (flg) cout << "Yes" << endl;
	else cout << "No" << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    ve_vec s(N,vec(10)); rep(i,N) rep(j,10) cin >> s[i][j];

    rep(i,N) sort(all(s[i]));
    sort(all(s));

    ll cnt = 1;
    ll ans = 0;
    rep(i,N) {
        if(s[i] == s[i+1]) cnt++;
        else {
            ans += cnt*(cnt-1)/2;
            cnt = 1;
        }
    }

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



Measured memory_bytes: 5760
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 08/08/2017 12:15:17
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	vi vect(3);
	for(int i = 0; i < 3; i++) cin>>vect[i];
	sort(vect.begin(), vect.end());
	cout<<vect[0]+vect[1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int a,b,c;
    cin >> a >> b >> c;
    if (a+b>=c) cout << "Yes"  << endl;
    else cout << "No" << endl;

    return 0; 
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d;
    for (int i = 0;i < n;i++) {
        int a; cin >> a;
        d.push_back(a);
    }
    sort(d.begin(), d.end());

    if (d[n/2-1] == d[n/2]) cout << 0 << endl;
    else cout << d[n/2] - d[n/2-1] << endl;
}


Measured memory_bytes: 892
<?php

$s=new Scanner();

$n=$s->nextInt();

$score=0;
$exclus=0;

for($i=0;$i<$n;$i++){
  $scoring[$i]=$s->nextInt();
  $score+=$scoring[$i];
}

sort($scoring);

if($score%10==0){
  for($i=0;$i<$n;$i++){

    if($scoring[$i]%10!=0){
      $score-=$scoring[$i];
      break;
    }
    if($i==$n-1){
      $score=0;

    }
  }
}


echo $score.PHP_EOL;





class Scanner{
  private $arr = [];
  private $count = 0;
  private $pointer = 0;
 
  public function next() {
    if ($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext(){
    return $this->pointer < $this->count;
  }
  public function nextInt(){
    return (int)$this->next();
  }
  public function nextDouble(){
    return (double)$this->next();
  }
}

#$B2~9T$"$j$NI8=`=PNO%/%i%9(B
class out{
  public static function println($str = ""){
    echo ($str . PHP_EOL);
  }

  #$BH>3Q6h@Z$j$G$NJQ?t$N=PNO(B
  public static function print_v(){
    $params = func_get_args();
    foreach ($params as $param) {
      echo ($param." ");
    }
    echo PHP_EOL;
  }
}


Measured memory_bytes: 4728
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();

        char[] s = S.toCharArray();
        char[] t = T.toCharArray();

        for(int i = 0; i < N; i++) {
            System.out.print(s[i]);
            System.out.print(t[i]);
        }
    }
}

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

int main(){
  int r,c;cin >> r >> c;
  int a[r+2][c+2];rep(i,r)rep(j,c)cin >> a[i][j];
  for(int i=0;i<r;++i){
    int sum = 0;
    for(int j=0;j<c;++j){
      sum += a[i][j];
    }
    a[i][c] = sum;
  }
  for(int i=0;i<=c;++i){
    int sum = 0;
    for(int j=0;j<r;++j){
      sum += a[j][i];
    }
    a[r][i] = sum;
  }
  for(int i=0;i<=r;++i){
    for(int j=0;j<c;++j){
      cout << a[i][j] << " ";
    }
    cout << a[i][c] << endl;
  }
  return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    string S;
    cin >>S;
    N=S.size();
    map<char,ll>m;
    ll cnt=0;
    rep(i,N){
        if(m[S[i]]==0){
            cnt++;
        }
        m[S[i]]=1;
    }
    if(cnt==2){
        cout<<"Second"<<endl;
    }else{
        if(S[0]==S[N-1]){
            if(N%2==0){
                cout<<"First"<<endl;
            }else{
                cout<<"Second"<<endl;
            }
        }else{
            if(N%2==1){
                cout<<"First"<<endl;
            }else{
                cout<<"Second"<<endl;
            }
        }
    }
    


    return 0;
    

}

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

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef queue<ii> qii;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FORE(x, xs) for (auto &x: xs)
#define PB push_back
#define MP make_pair

const int MAX = 2e5+10;
int N, M, S, T;
int dist[MAX][3];
vi path[MAX];
qii q;

int main() {
    cin >> N >> M;
    REP (i, N) REP (j, 3) {
        dist[i][j] = -1;
    }
    REP (i, M) {
        int u, v;
        cin >> u >> v; u--; v--;
        path[u].PB(v);
    }
    cin >> S >> T;
    S--; T--;
    q.push(MP(S, 0));
    while(!q.empty()) {
        int n = q.front().first;
        int d = q.front().second;
        q.pop();
        if (n == T && d%3 == 0) {
            cout << d/3 << endl;
            return 0;
        }
        if (dist[n][d%3] != -1) {
            continue;
        }
        dist[n][d%3] = d;
        FORE (p, path[n]) {
            q.push(MP(p, d+1));
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 9472
#include <iostream>

using namespace std;

int main() {
    int a,b,i,OP;
    char op;
    
    for(i=1;i<=20000;i++){
    cin >> a >>op>>b;
    OP=op;
    if(OP==37) break;
    else if(OP==43) 
    cout << a+b << endl;
    else if(OP==45) 
    cout << a-b << endl;
    else if(OP==42) 
    cout << a*b << endl;
    else if(OP==47) 
    cout << a/b << endl;
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                                                                \
  if (dbg) {                                                                   \
    cerr << #x << " = " << (x) << endl;                                        \
  }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  } else
    return 0;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  } else
    return 0;
}
void Yes(bool flag = true) {
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void No(bool flag = true) { Yes(!flag); }
void YES(bool flag = true) {
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void NO(bool flag = true) { YES(!flag); }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
bool dbg = false;
} // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int T;

void solve() {
  while (T--) {
    int N;
    vi A;
    string S;
    cin >> N;
    for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      A.emplace_back(a);
    }
    cin >> S;

    bool flag = true;
    vector<int> canuse(100);
    fill(all(canuse), -1);
    for (int i = N - 1; i >= 0; i--) {
      int a = A[i];
      if (S[i] == '0') {
        for (int j = 60; j >= 0; j--) {
          if (a == 0ll)
            break;
          if (a & (1ll << j)) {
            if (canuse[j] == -1) {
              canuse[j] = a;
              break;
            } else {
              a ^= canuse[j];
            }
          }
        }
      } else {
        for (int j = 60; j >= 0; j--) {
          if (a == 0ll)
            break;
          if (a & (1ll << j)) {
            if (canuse[j] != -1) {
              a ^= canuse[j];
            } else {
              flag = false;
              break;
            }
          }
        }
      }
    }

    if (flag) {
      cout << 0 << endl;
    } else
      cout << 1 << endl;
  }
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> T;

  solve();
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n, m;
  cin >> n >> m;
  vector<P> a;
  for(int i=0; i<n; i++){
    int A,B; cin >> A >> B;
    a.push_back(make_pair(A,B));
  }
  sort(a.begin(), a.end());
  ll ans = 0LL;
  for(int i=0; i<n; i++){
    if(m<=a[i].second){
      ans += m*a[i].first;
      break;
    }
    ans += a[i].first*a[i].second;
    m -= a[i].second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans=1;
    for(int i=1;i<s.size();i++){
        if(s[i-1]!=s[i]) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
import java.util.Scanner  ;
public class Main{
public static void main(String[]args){

Scanner sc = new Scanner(System.in);

while(true){
    int H = sc.nextInt();
    int W = sc.nextInt();
    if(H == 0 && W == 0){
        break;
    }
        for(int i= 0;i<W;i++){
            System.out.printf("#");
        }
        System.out.printf("\n");

        for(int j= 0;j<H-2;j++){
           System.out.printf("#");
           for(int k= 0;k<W-2;k++){
              System.out.printf(".");
                                }
            System.out.printf("#\n");
        
                                }

        for(int l= 0;l<W;l++){
            System.out.printf("#");
        }
        System.out.printf("\n\n");


    
}
}
}


Measured memory_bytes: 58784