akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, D; cin >> N >> D;
    vector<vector<int>> v(N);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < D; ++j){
            int x; cin >> x;
            v[i].push_back(x);
        }
    }
    int res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (i ==j) continue;
            float R = 0;
            for (int k = 0; k < D; ++k) R += abs(v[i][k]-v[j][k]) * abs(v[i][k]-v[j][k]);
            if (floor(sqrt(R)) == sqrt(R)) ++res;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int par[101010];
int find(int x){
  if(par[x]==x)return x;
  else return par[x]=find(par[x]);
  }
  
void unite(int x,int y){
  x=find(x);
  y=find(y);
  par[y]=x;
  }

int main(){
  int n;cin>>n;
  int m;cin>>m;
  rep(i,n)par[i]=i;
  int a[n];
  rep(i,n){
    cin>>a[i];
    a[i]--;
    }
  rep(i,m){
    int x,y;
    cin>>x>>y;
    unite(x-1,y-1);
    }
  int ans=0;
  rep(i,n)if(find(i)==find(a[i]))ans++;
  cout<<ans<<endl;
  
  
  return 0;
  }

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

using namespace std;

int main(void) {
  int R;
  cin >> R;

  if(R < 1200) {
    cout << "ABC" << endl;
  }
  else if(1200 <= R && R < 2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321
#define PI 3.14159265358979323846264
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
ll MOD = 1999;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

int a[2005], sum[2005], chk[2005];
int n, k, q;
bool cnt(int l, int r)
{
	fup(i, 1, n, 1)
	{
		if (l <= a[i] && a[i] <= r)chk[i] = 1;
		else if (a[i] < l)chk[i] = -3000;
		else chk[i] = 0;
		sum[i] = sum[i - 1] + chk[i];
	}
	int res = 0, ll = 0, temp = 0;
	fup(i, 1, n, 1)
	{
		if (sum[i] - sum[ll] < 0)
		{
			ll = i;
			temp = 0;
		}
		if (i - ll >= k)
		{
			if (sum[i] - sum[ll] > temp)
			{
				res++;
				temp++;
			}
			else if (sum[i] - sum[ll] < 0)
			{
				ll = i;
				temp = 0;
			}
		}
	}
	return res >= q;
}
bool ok(int m)
{
	fup(ii, 1, n, 1)
	{
		int l = a[ii], r = a[ii] + m;
		if (cnt(l, r))return 1;
	}
	return 0;
}
int main() {
	scanf("%d%d%d", &n, &k, &q);
	fup(i, 1, n, 1)scanf("%d", a + i);
	int l = 0, r = (int)1e9;
	while (l <= r)
	{
		int m = (l + r) >> 1;
		if (ok(m))r = m - 1;
		else l = m + 1;
	}
	printf("%d", l);
}

Measured memory_bytes: 256
# coding: utf-8

import codecs
import sys

sys.stdout = codecs.getwriter("shift_jis")(sys.stdout) # ??????
sys.stdin = codecs.getreader("shift_jis")(sys.stdin) # ??\???

# ??\??¬?????????print??????????????´?????? print(u'?????????') ??¨??????
# ??\??¬?????????input??? input(u'?????????') ??§OK
# ??°?¢???????????????????????????´??????6,7???????????????????????¢??????

"""
DEBUG = 0

if DEBUG == 0:
	a = []
	for i in range(200):
		deglist=[int(x) for x in input().split(" ")]
		a.append(deglist)
else:
	a = [[5,7],[1,99],[1000,999]]

for i in range(len(a)):
	wa = a[i][0] + a[i][1]
	print len(str(wa))
"""

while True:
	try:
		a,b = map(int, raw_input().split())
		print len(str(a+b))
	except EOFError:
		break

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
int t;
long long n,m;
long long a[200005],f[200005];
bool cmp(int a,int b)
{
    return a>b;
}
bool check(long long mid)
{
    long long res=m;
        for(int i=1;i<=n;i++)
        {
            if(mid/f[i]<a[i])
            {
                long long x=a[i]-mid/f[i];
                if(x>res)
                    return 0;
                res-=x;
            }
        }
        return 1;
}

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>f[i];
    sort(a+1,a+1+n);
    sort(f+1,f+1+n,cmp);
    long long right=-1;
    for(int i=1;i<=n;i++)
        right= max(right,a[i]*f[i]);
    long long left=0;
    long long ans=0;
    while(left<=right)
    {
        long long mid=(left+right)/2;
        if(check(mid)) right=mid-1,ans=mid;
        else left=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        String str=scan.next();
        int[] flag=new int[n];
        int does=0;
        for(int i=0;i<n;i++){
            if((str.substring(i,i+1)).equals("(")) {
                flag[i]=1;
                does++;
            }
            else {
                flag[i]=2;
                if(does>0){
                    for(int j=i-1;0<=j;j--){
                        if(flag[j]==1){
                            flag[j]=0;
                            flag[i]=0;
                            does--;
                            break;
                        }
                    }
                }
            }
        }

        //for(int i=0;i<n;i++) System.out.printf("%d ",flag[i]);
        //System.out.println();

        for(int i=0;i<n;i++){
            if(flag[i]==2) str="("+str;
            else if(flag[i]==1) str=str+")";
        }

        System.out.println(str);
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int main(){
    char number[1001];
    int i, sum;
    while(1){
        scanf("%s", number);
        if(number[0]=='0')break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n", sum);
    }

    return 0;
}


Measured memory_bytes: 2600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class ANextAlphabet
    {
        static void Main(string[] args)
        {
            var c = Console.ReadLine();
                        
            var bytesUTF8 = System.Text.Encoding.Default.GetBytes(c);
            bytesUTF8[0]++;
            Console.WriteLine(System.Text.Encoding.UTF8.GetString(bytesUTF8));
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b,k;
  cin>>a>>b>>k;
  if (k<=a){
cout<<a-k<<" "<<b;
  }
  else if(a<k&&k<a+b){
 cout<<0<<" "<<a+b-k;
  }
 else if(a+b<=k){
   cout<<0<<" "<<0;
 }
  return 0;
}
  

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

#define MAX_N 21

int main() {
	int n;
	int p[MAX_N] = {};
	int s[3] = {};

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	int cnt = 0;
	for (int i = 1; i < n-1; i++) {
		s[0] = p[i-1];
		s[1] = p[i];
		s[2] = p[i+1];
		sort(s, s+3);
		if (s[1] == p[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

int main(){	
	string S;
	long long N;
	long long M;
	scanf("%lld",&N);
	scanf("%lld",&M);
	cin >> S;
	vector<ll> res;
	ll old = N, now = N;
	for (ll i = N; i >= 0; i--) {
		if (S[i] == '0') now = i;
		if (old - M == i) {
			if (old == now) {
				cout << "-1" << endl;
				return 0;
			}
			res.push_back(old-now);
			old = now;
		}
		if (i == 0 && old-now != 0) res.push_back(old-now);
	}
	for (ll i = res.size()-1; i >= 0; i--) {
		cout << res[i];
		if (i != 0) cout << " "; else cout << endl;
	}
	return 0;
}



Measured memory_bytes: 1528
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *P = map(int, read().split())
P = np.array(P)

acc = P[0]
cnt = 0
for p in P:
    if acc >= p:
        cnt += 1
    acc = min(acc, p)

print(cnt)


Measured memory_bytes: 29420
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a,b; cin >> a >> b;
    bool jud = false;

    if(a %3 == 0 || b %3 == 0 || (a+b) %3 == 0){
        jud = true;
    }

    if(jud) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
ll INF=1e18+5;
//cout << std::fixed << std::setprecision(15) << y << endl;

int main(){
    ll X, K, D;
    cin >> X >> K >> D;
    ll sta = abs(X);
    ll go_zero = sta/D;
    if(K < go_zero){
        cout << abs(sta - D*K) << endl;
        return 0;
    }

    ll now = sta - D*go_zero;
    K -= go_zero;
    if(K % 2 == 1) cout << abs(now - D) << endl;    
    if(K % 2 == 0) cout << abs(now) << endl;    
    return 0;
}

Measured memory_bytes: 3616
n, t = map(int, input().split())
a = list(map(int, input().split()))
a_min = a[0]
d = 0
x = 0
for i in range(1, n):
    di = a[i] - a_min
    if d < di:
        d = di
        x = 1
    elif d == di:
        x += 1
    a_min = min(a_min, a[i])
print(x)


Measured memory_bytes: 15020
n = int(input())
li = list(map(int, input().split()))



ret = 0
li = [0] + li + [0]
for i in range(len(li) - 1):
    ret += abs(li[i] - li[i + 1])




for i in range(1, len(li)-1):
    if li[i-1] <= li[i] <= li[i+1] or li[i-1] >= li[i] >= li[i+1]:
        print(ret)
    elif li[i] < li[i-1] < li[i+1] or li[i] > li[i-1] > li[i+1]:
        print(ret - abs(li[i] - li[i-1]) * 2)
    else:
        print(ret - abs(li[i+1] - li[i]) * 2)

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

int main()
{
	int h,w;
	int dx[4]={ 0, 1,  0, -1},dy[4]={ 1, 0, -1,  0};
	char a[55][55];
	cin>>h>>w;
	for(int i=0;i<=h+1;i++)
	{
		for(int j=0;j<=w+1;j++)
		{
			if(i==0||i==h+1||j==0||j==w+1)a[i][j]='.';
			else cin>>a[i][j];
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(a[i][j]=='#')
			{
				bool flag=false;
				for(int k=0;k<4;k++)
				{
					if(a[i+dx[k]][j+dy[k]]=='#')flag=true;
				}
				if(!flag)
				{
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
line = input().rstrip().split()
W = int(line[0])
H = int(line[1])
x = int(line[2])
y = int(line[3])
r = int(line[4])
if (x-r<0 or y-r<0 or x+r > W or y+r > H):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5600
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL MaxN = 1 + 1e6, INF = 1e12;

LL n, a[MaxN], d[MaxN], m, x, y, t, kq[MaxN], s;

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    fill(kq + 1, kq + (1 << n) + 1, INF);
    for(int i = 0 ; i < m ; ++i){
        cin >> a[i] >> y;
        LL k = 0;
        for(int j = 0 ; j < y ; ++j){
            cin >> x;
            x--;
            k |= (1 << x);
        }
        d[i] = k;
        // cout << k << endl;
    }
    for(int i = 0 ; i <= (1 << n) - 1 ; ++i)
    for(int j = 0 ; j < m ; ++j) 
    kq[i | d[j]] = min(kq[i | d[j]], kq[i] + a[j]);
    // for(int i = 1 ; i <= (1 << n) - 1 ; ++i) cout << kq[i] << " ";
    // cout << endl;
    if(kq[(1 << n) - 1] == INF) cout << -1 << endl;
    else cout << kq[(1 << n) - 1] << endl;

    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

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

int main() {
	int n;
	
	double avg = 0;
	
	vector<double> vd;
	
	cin >> n;
	
	for (int i = 0; i < n; ++i) {
		double k;
		cin >> k;
		
		avg += k/(double)n;
		vd.pb(k);
	}
	
	//floor gang
	int bottom = (int)floor(avg);
	int top = (int)ceil(avg);
	
	int bottom_sum = 0;
	int top_sum = 0;
	
	for (double d : vd) {
		int i = (int) d;
		bottom_sum += (i-bottom)*(i-bottom);
		top_sum += (i-top)*(i-top);
	}
	
	cout << min(bottom_sum, top_sum) << endl;
  return 0;
}

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

int main(){
    int N,K;
    string S;
    cin>>N>>K>>S;

    if(S.at(K-1)=='A') S.at(K-1)='a';
    else if(S.at(K-1)=='B') S.at(K-1)='b';
    else S.at(K-1)='c';

    cout<<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  int ans = N * (N-1) / 2 + M * (M-1) / 2;
  cout << ans << '\n';
  return 0;
}

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

int main(){
    int N,sum,t;

    cin >> N;
    t=N;

    while(t>0){
        sum += t % 10 ;
        t /=10;
    }

    if(N%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
    using namespace std;
     
    /***********************************************/
    /* Dear online judge:
     * I've read the problem, and tried to solve it.
     * Even if you don't accept my solution, you should respect my effort.
     * I hope my code compiles and gets accepted.
     *  ___  __     _______    _______
     * |\  \|\  \  |\  ___ \  |\  ___ \
     * \ \  \/  /|_\ \   __/| \ \   __/|
     *  \ \   ___  \\ \  \_|/__\ \  \_|/__
     *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \
     *    \ \__\\ \__\\ \_______\\ \_______\
     *     \|__| \|__| \|_______| \|_______|
     */
    const long long mod = 1000000007;
     
    const int mxN = 100010;
     
    int main() {
    	ios_base::sync_with_stdio(false);
    	cin.tie(nullptr);
     
    	int N,K;
    	cin>>N>>K;
    	vector<int> a(N);
    	int ind = -1;
    	for(int i = 0;i < N;i++) cin>>a[i], ind = a[i] == 1?i:ind;
    	cout<<(N-1 + K - 2)/(K-1)<<'\n';
    	return 0;
    }

Measured memory_bytes: 640
// AOJ 1134: Name the Crossing
// 2017.11.13 bal4u@uu

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

#define HASHSIZ 503
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;			// Hash table

int insert(char *s, int w, int id)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

int lookup(char *s, int w)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	return -1;
}

char name[202][36]; int sz;
char rel[202][202], tmp[202][202];
int cross[202];

void found(int j, int k)
{
	int i;

	cross[j] = k;
	for (i = 0; i < sz; i++) {
		if (!cross[i] && (rel[i][j] || rel[j][i])) found(i, -k);
	}
}

int main()
{
	int n, m, w, i, j, k;
	char buf[36], *p, *q;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		memset(hash, 0, sizeof(hash));
		memset(rel, 0, sizeof(rel));

		n = atoi(buf), sz = 0;
		while (n--) {
			fgets(name[sz], 35, stdin);
			p = q = name[sz]; while (*p != '-') p++; w = p - q, *p++ = 0;
			if ((i = insert(q, w, sz)) < 0) i = sz++;
			q = p; while (*p > ' ') p++; w = p - q, *p = 0;
			if ((j = insert(q, w, sz)) < 0) j = sz++;
			rel[i][j] = 1;
		}
		printf("%d\n", sz);

		memset(cross, 0, sizeof(cross));
		for (k = 1, i = 0; i < sz; i++)	if (!cross[i]) found(i, k++);

		memset(tmp, 0, sizeof(tmp));
		for (i = 0; i < sz; i++) for (j = 0; j < sz; j++) {
			int comm = 0, strong = 1;
			for (k = 0; k < sz; k++) {
				if ((rel[i][k] || rel[k][i]) && (rel[j][k] || rel[k][j])) comm = 1;
				if ((rel[i][k] && rel[k][j]) || (rel[j][k] && rel[k][i])) strong = 0;
				if (comm && !strong) break;
			}
			if (comm && strong) tmp[i][j] = 1;
		}
		for (i = 0; i < sz; i++) for (j = 0; j < sz; j++) rel[i][j] |= tmp[i][j];

		for (k = 0; k < sz; k++) for (i = 0; i < sz; i++) for (j = 0; j < sz; j++)
			if (rel[i][k] && rel[k][j]) rel[i][j] = 1;

		fgets(buf, 10, stdin); m = atoi(buf);
		while (m--) {
			fgets(buf, 35, stdin);
			p = q = buf; while (*p != '-') p++;	w = p - q, *p++ = 0;
			if ((i = lookup(q, w)) < 0) goto no;
			q = p; while (*p > ' ') p++; w = p - q, *p = 0;
			if ((j = lookup(q, w)) < 0) goto no;
			if (cross[i] == -cross[j] && rel[i][j]) puts("YES");
			else {
no:				puts("NO");
			}
		}
	}
	return 0;

}

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

using namespace std;
#define int long long
 main()
{
ios::sync_with_stdio(false);
 cin.tie(0);
 string s;
 cin>>s;
int S=0;
int p=0;
for(int i=0;i<s.size();i++)
   {if(s[i]=='A')
        p++;
    else
        if(s[i]=='B' && s[i+1]=='C' && s.size()>i+1)
        {S+=p;
        i++;
        }
        else
            p=0;

   }
   cout<<S;
    return 0;
}


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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<pair<ll,ll>>> v(n);
    ll p,y;
    rep(i,m){
        cin>>p>>y;
        p--;
        v[p].push_back(make_pair(y,i));
    }
    rep(i,n) sort(all(v[i]));
    vector<pair<ll,ll>> mp(m);
    rep(i,n){
        rep(j,v[i].size()){
            mp[v[i][j].second]=make_pair(i+1,j+1);
        }
    }
    rep(i,m) printf("%06ld%06ld\n",mp[i].first,mp[i].second);
    return 0;
}

Measured memory_bytes: 10148
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    d = {}
    for s in S:
        if s in d:
            d[s] += 1
        else:
            d[s] = 1

    maxv = 0
    res = []
    for k, v in sorted(d.items(), key=lambda x: -x[1]):
        if v >= maxv:
            res.append(k)
            maxv = v

    for s in sorted(res):
        print(s)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	int a, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 != 0) {
			ans++;
		}
	}
	if (ans % 2 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()

int main() {
	int N;
	cin >> N;
	int A;
	bool isApprove = true;
	rep(i, N) {
		cin >> A;
		if(A % 2 == 0) {
			if(A % 3 == 0 || A % 5 == 0) {
				continue;
			} else {
				isApprove = false;
				break;
			}
		}
	}
	if (isApprove) {
		cout << "APPROVED" << endl;
	} else {
		cout << "DENIED" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
  
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;
 
       
     
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}




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

using namespace std;

const int mxn = 1e5;
int t[mxn + 11];
int x[mxn + 11];
int y[mxn + 11];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", t + i, x + i, y + i);
    }
    int a = 0;
    int b = 0;
    int rr = 0;
    for (int i = 0; i < n; i++) {
        int c = x[i] - a;
        int d = y[i] - b;
        if (c < 0) c = -c;
        if (d < 0) d = -d;
        c += d;
        if (i > 0)
                rr = t[i] - t[i - 1];
        else
                rr = t[i];
        if (rr % c != 0) {
            puts("No");
            return 0;
        }
        a = x[i];
        b = y[i];
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
int A[MAXN];

int main()
{
	int i, j, x;
	scanf("%d", &N);
	vector<int> vec, P, Q;
	for (i = 1; i <= N; ++i) vec.push_back(i);
	for (i = 1; i <= N; ++i) {
		scanf("%d", &x);
		Q.push_back(x);
	}
	for (i = 1; i <= N; ++i) {
		scanf("%d", &x);
		P.push_back(x);
	}
	int cnt = 1;
	int a, b;
	while (1) {
		if (P == vec) {
			a = cnt;
		}
		if (Q == vec) {
			b = cnt;
		}
		if (!next_permutation(vec.begin(), vec.end())) break;
		++cnt;
	}
	printf("%d", ABS(a - b));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
vector<int> G[N];
int n,m,fa[N],dfn[N],f[N],tot;
void dfs(int u,int pre)
{
	fa[u]=pre; dfn[u]=++tot;
	for(auto v:G[u]){
		if(v==pre) continue;
		if(fa[v] && dfn[v]<dfn[u]) f[u]^=1,printf("%d %d\n",u,v);
		else if(!fa[v]) dfs(v, u);
	}
}
void dfs2(int u)
{
	for(auto v:G[u]){
		if(v==fa[u] || fa[v]!=u) continue;
		dfs2(v);
	}
	if(u==1) return;
	if(!f[u]) printf("%d %d\n",fa[u],u),f[fa[u]]^=1;
	else printf("%d %d\n",u,fa[u]),f[u]^=1;
}
int main()
{
	n=read(); m=read();
	for(int i=1; i<=m; i++){
		int u=read(),v=read();
		G[u].push_back(v); G[v].push_back(u);
	}
	if(m&1) {puts("-1"); return 0;}
	dfs(1, -1);
	dfs2(1);
}

Measured memory_bytes: 12672
S = input()
result = 0

for i in range(1 << (len(S)-1)):
	k = 0
	T = 0
	for j in range(len(S)):
		if ((i >> j) & 1) == 1:
			T += int(S[k:j+1])
			k = j+1
	T += int(S[k:len(S)])
	result += T
print(result)

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
vector< pair<int, pair<int, int> > > edge;

void build(int n, int L)
{
	if(n==1) return;
	if(L==1)
	{
		edge.push_back(make_pair(0,make_pair(n-1,n)));
		build(n-1,L);
	}
	else if(L%2==0)
	{
		edge.push_back(make_pair(0,make_pair(n-1,n)));
		edge.push_back(make_pair(L/2,make_pair(n-1,n)));
		build(n-1,L/2);
	}
	else if(L%2==1)
	{
		edge.push_back(make_pair(0,make_pair(n-1,n)));
		edge.push_back(make_pair(L/2,make_pair(n-1,n)));
		edge.push_back(make_pair(L-1,make_pair(1,n)));
		build(n-1,L/2);
	}

}
int main(void)
{
	int i, u, v, w, L;
	cin>>L; build(20,L);
	cout<<20<<" "<<edge.size()<<"\n";
	for(i=0 ; i<edge.size() ; i++)
	{
		u=edge[i].second.first;
		v=edge[i].second.second;
		w=edge[i].first;
		cout<<u<<" "<<v<<" "<<w<<"\n";
	}
	return 0;
}

// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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

int main()
{
	ll n,ans;
	cin >> n;
	n -= 1;
	if(n & 1) ans = (n+1)/2*n;
	else ans = n/2*(n+1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define first ff
#define second ss
#define ll long long int
int main()
{
    int n;
    cin>>n;
    ll a[n+5],b[n+5];
    for(int i=1; i<n; i++)
        cin>>b[i];
    ll sum=b[1]+b[n-1];
    for(int i=1;i<n-1;i++){
      sum+=min(b[i],b[i+1]);
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3608
n=int(input())
a=list(input().split())
from collections import deque
d=deque()
for i in range(n):
  if i%2==0:
    d.append(a[i])
  else:
    d.appendleft(a[i])
if n%2==0:
  print(" ".join(d))
else:
  print(" ".join(reversed(d)))
  

Measured memory_bytes: 30672
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int tmp,tmp2,tmp3,ans=0;
	int a,b;
	cin>>a>>b;
	tmp = a+b;
	tmp2 = a-b;
	tmp3 = a*b;
	ans = max(tmp, tmp2);
	ans = max(tmp3, ans);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s, t, u; 
  cin >> s >> t >> u;

  cout << s[0] << t[0] << u[0] << "\n";

  return 0;
}

Measured memory_bytes: 256
k = 72
kk = k // 4
KK = 1<<k
nu = lambda L: int("".join([hex(KK+a)[3:] for a in L[::-1]]), 16)
st = lambda n: hex(n)[2:]
li = lambda s, l, r: [int(a, 16) % P if len(a) else 0 for a in [s[-(i+1)*kk:-i*kk] for i in range(l, r)]]

def grow(d, v, h):
    h += [0] * d
    f = [(-1 if (i+d) % 2 else 1) * fainv[i] * fainv[d-i] % P * h[i] % P for i in range(d+1)]
    nuf = nu(f)
    a = d * inv[v] % P
    t = [1] * (3*d+3)
    for i in range(1, 3*d+3): t[i] = t[i-1] * (a - d + i - 1) % P
    ti = [1] * (3*d+3)
    ti[-1] = pow(t[-1], P-2, P)
    for i in range(1, 3*d+3)[::-1]: ti[i-1] = ti[i] * (a - d + i - 1) % P
    iv = [1] * (3*d+3)
    for i in range(1, 3*d+3):
        iv[i] = ti[i] * t[i-1] % P

    ###
    g = [inv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = fg[i] * fa[d+i+1] % P * fainv[i] % P

    ###
    g = [iv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d+1):
        h[i] = h[i] * (fg[i] * t[d+i+1] % P * ti[i] % P) % P

    ###
    g = [iv[i] for i in range(d+2, 3*d+3)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = h[i+d+1] * (fg[i] * t[2*d+i+2] % P * ti[d+i+1] % P) % P

    return h

# Create a table of the factorial of the first v+2 multiples of v, i.e., [0!, v!, 2v!, ..., (v(v+1))!]
def create_table(v):
    s = 1
    X = [1, v+1]
    while s < v:
        X = grow(s, v, X)
        s *= 2

    table = [1]
    for x in X:
        table.append(table[-1] * x % P)
    return table

def fact(i, table):
    a = table[i//v]
    for j in range(i//v*v+1, i+1):
        a = a * j % P
    return a

H, W, K = map(int, input().split())
N = H + W
P = 10**9+7

v = 1 << (N.bit_length() + 1) // 2
fa = [1] * (2*v+2)
fainv = [1] * (2*v+2)
for i in range(2*v+1):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(2*v+1)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
inv = [0] * (2*v+2)
for i in range(1, 2*v+2):
    inv[i] = fainv[i] * fa[i-1] % P

T = create_table(v)

print((K*(K+3)//2 + K*(K+1)*(K-1)//3*H*W*pow(N * (N-1), P-2, P)) * fact(N, T) * pow(fact(N-K, T), P-2, P) % P)

Measured memory_bytes: 71384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;

int main() {
	int d, n; cin >> d >> n;
	if (n == 100) {
		cout << 101;
		for (int i = 0; i < d; i++) cout << "00";
		cout << endl;
		return 0;
	}
	
	cout << n;
	for (int i = 0; i < d; i++) cout << "00";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, minu, add, xpop;
string x;

ll qexp(ll a, ll b, ll m) {
    a %= m;
    ll res = 1, base = a;
    while (b) {
        if (b & 1) {
            res *= base;
            res %= m;
        }
        base *= base;
        base %= m;
        b >>= 1;
    }
    return res % m;
}

int main() {
	fastio; cin >> n >> x;
	for (auto it:x) if (it == '1') xpop++;
	FOR(i, 0, n-1) if (x[i] == '1') {
		if (xpop > 1) minu = (minu + qexp(2, n-1-i, xpop-1)) % (xpop - 1);
		add = (add + qexp(2, n-1-i, xpop+1)) % (xpop + 1);
	}
	FOR(i, 0, n-1) {
		ll y = 0, ans = 1;
		if (x[i] == '0') y = (add + qexp(2, n-1-i, xpop+1)) % (xpop + 1);
		else if (xpop > 1) y = (minu - qexp(2, n-1-i, xpop-1) + xpop-1) % (xpop-1);
		else {
			cout << "0\n";
			continue;
		}
		while (y != 0) {
			y %= __builtin_popcount(y);
			ans++;
		}
		cout << ans << "\n";
	}
}


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

int main(){
	int k, s, count = 0;
	cin >> k >> s;
	for(int i=0; i <= k; i++) {
		int j = s - i;
		if(j >= 0 && j <= k)
			count += j + 1;
		else if(j > k && j <= 2*k)
			count += 2*k - j + 1;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast_read ios::sync_with_stdio(0);cin.tie(0);
#define ll long long
using namespace std;
int main()
{
    fast_read;
    ll n;
    cin>>n;
    ll a[2][n];
    for (int i = 0;i<2;i++)
        for (int j = 0;j<n;j++)
            cin>>a[i][j];
    ll ans[2][n];
    ans[0][0] = a[0][0];
    for (int i = 0;i<2;i++) {
        for (int j = 0;j<n;j++) {
            if (i == 0 && j == 0)continue;
            else if (i == 0 && j != 0)ans[i][j] = a[i][j] + ans[i][j - 1];
            else if (i != 0 && j == 0)ans[i][j] = a[i][j] + ans[i - 1][j];
            else ans[i][j] = a[i][j] + max(ans[i-1][j],ans[i][j - 1]);
        }
    }
    cout<<ans[1][n-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
struct Node {
	T key;
	Node *next, *prev;
	Node() {}
};
template<typename T>
struct List {

	Node<T> *p;
	List() {
		p = (Node<T>*)malloc(sizeof(Node<T>));
		p->next = p->prev = p;
	}
	void insert(T x) {
		Node<T> *a = (Node<T>*)malloc(sizeof(Node<T>));
		a->key = x;
		a->next = p->next;
		p->next->prev = a;
		a->prev = p;
		p->next = a;
	}
	Node<T>* findkey(T x) {
		Node<T> *c;
		for (c = p->next; c->key != x&&c != p; c = c->next);
		return c;
	}
	void deletepointer(Node<T> *d) {
		if (d == p)return;
		d->prev->next = d->next;
		d->next->prev = d->prev;
		free(d);
	}
	void deletekey(T x) {
		deletepointer(findkey(x));
	}
	void deleteFirst() {
		deletepointer(p->next);
	}
	void deleteLast() {
		deletepointer(p->prev);
	}
	void print() {
		for (Node<T> *a = p->next; a != p; a = a->next) {
			cout << a->key << (a == p->prev ? '\n' : ' ');
		}
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	List<int> ls;
	int N; cin >> N;
	rep(i, 0, N) {
		string s; cin >> s;
		if (s[0] == 'i') {
			int x; cin >> x;
			ls.insert(x);
		}
		else if (s == "deleteFirst")ls.deleteFirst();
		else if (s == "deleteLast")ls.deleteLast();
		else {
			int x; cin >> x;
			ls.deletekey(x);
		}

	}
	ls.print();
	return 0;
}

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

int main(){
	int n , m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		n-=a;
	}
	if(n >= 0) cout << n;
	else cout << "-1";
}

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

int main(){
    int H, W;

    while(1){
        cin >> H >> W; 

        if (H == 0 && W == 0)break;   

        for (int i = 0; i < H; i++){
            if (i == 0 || i == H -1){
                for (int j = 0; j < W; j++){
                    cout << "#";
                }    
            } else {
                for (int k = 0; k < W; k++){
                    if (k == 0 || k == W - 1){
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3040
/*
                        ********************
			**  MANAN DIYORA  **
			**    DA-IICT     **
			**   diyora13     **
			********************
*/
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define inarr(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define outarr(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl
#define maxa(a,n) *max_element(a,a+n)
#define mina(a,n) *min_element(a,a+n)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(ll i=s;i<e;i++)
#define rf(i,s,e) for(ll i=s-1;i>=e;i--)
#define gcd(a,b) __gcd(a,b)
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define sz size()
#define len length()
#define all(v) v.begin(),v.end()

typedef long long int ll;
typedef long double ld;
typedef pair<long long, long long> pll;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) { return (a.second < b.second); }
#define PI 3.141592653589793
#define MOD 1000000007

bool flag=0,flag1=0,flag2=0;

int main()
{
	IOS
	ll t=1;
//		cin>>t;
	while(t--)
	{
		ll n,k; cin>>n>>k;
		ll a[n]; inarr(a,n);
		ll mul=1;
		fr(i,0,k) mul*=a[i];
		fr(i,k,n)
		{
			if(a[i]>a[i-k]) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 5204
N=int(input())
A=list(map(int,input().split()))
A.sort()
dp=[0]*(10**5+1)
bp=[]
for i in range(N):
  if dp[A[i]]!=0:
    bp.append(A[i])
  dp[A[i]]+=1
bp.sort()
p=len(bp)
q=p
o=0
for i in range(10**5):
  if p<3:
    break
  p-=2
if p==0:
  N-=q
elif p==1:
  N=N-q-1
else:
  N=N-q
print(N)

Measured memory_bytes: 20760
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<Integer, Integer> henMap = new HashMap<>();
        for(int i=0;i<N;i++){
            int len = sc.nextInt();
            henMap.putIfAbsent(len, 0);
            henMap.put(len, henMap.get(len)+1);
        }
        List<Integer> henLst = new ArrayList<>();
        henLst.addAll(henMap.keySet());
        Collections.sort(henLst);
        int cnt = 0;
        for(int i=0;i<henLst.size();i++){
            for(int j=i+1;j<henLst.size();j++){
                for(int k=j+1;k<henLst.size();k++){
                    if(henLst.get(i) + henLst.get(j) > henLst.get(k))
                        cnt += henMap.get(henLst.get(i))*henMap.get(henLst.get(j)) * henMap.get(henLst.get(k));

                }
            }
        }
        System.out.println(cnt);
    }

}


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

int main() {
  string S; cin >> S;
  int N = S.size();
  long long ans = 0;
  vector<int> A(N+1, 0);
  int ten = 1;
  for (int i = N-1; i >= 0; i--) {
    int tmp = (S.at(i) - '0') * ten % 2019;
    A.at(i) = (A.at(i+1) + tmp) % 2019;
    ten *= 10;
    ten %= 2019;
  }
  map<int, long long> M;
  for (int i = 0; i < N+1; i++) {
    if (M.count(A.at(i))) M[A.at(i)]++;
    else M[A.at(i)] = 1;
  }
  for (auto p : M) ans += (p.second * (p.second - 1)) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 4340
import numpy as np

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

X_lis = []
for i in range(N):
    x = list(map(int, input().split()))
    X_lis.append(x)

X_arr = np.array(X_lis)

count = 0

for i in range(N):
    for j in range(i+1, N):
        squared_d = np.sum((X_arr[i] - X_arr[j]) ** 2)
        if (squared_d)**(1/2) == int(squared_d**(1/2)):
            count += 1

print(count)

Measured memory_bytes: 12488
#include <stdio.h>

int main(void) {
	int a, b, ans;
	char op;
	
	while(1) {
	    scanf("%d %c %d", &a, &op, &b);
	    //足し算
	    if(op == '+') {
	        ans = a + b;
	        printf("%d\n", ans);
	    }
	    //引き算
	    else if(op == '-') {
	        ans = a - b;
	        printf("%d\n", ans);
	    }
	    //掛け算
	    else if(op == '*') {
	        ans = a * b;
	        printf("%d\n", ans);
	    }
	    //割り算
	    else if(op == '/') {
	        ans = a / b;
	        printf("%d\n", ans);
	    }
	    //opが"?"の時に処理を終了する
	    else {
	        break;
	    }
	}
	return 0;
}


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

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int x = (n % a == 0 ? (n / a) * b : (n / a + 1) * b);
  int y = (n % c == 0 ? (n / c) * d : (n / c + 1) * d);
  cout << min(x, y) << endl;
  return 0;
}



Measured memory_bytes: 3116
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int A[2][N];
   for(int i=0; i<2; ++i){
      for(int j=0; j<N; ++j){
	 std::cin >> A[i][j];
      }
   }

   
   int ans = 0;
   for(int i=0; i<N; ++i){
      int count = 0;
      for(int j=0; j<N; ++j){
	 if(j<i){
	    count += A[0][j];
	 }else if(j>i){
	    count += A[1][j];
	 }else{
	    count += A[0][j];
	    count += A[1][j];
	 }
      }
      if(count>ans) ans = count;
   }
   std::cout << ans << std::endl;

   return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 10000
int main()
{
 int b[MAX+1]={0},i,j;
 b[0]=b[1]=1;
 for(i=4;i<=MAX;i+=2)b[i]=1;
 for(i=3;i*i<=MAX;i+=2)
  if(!b[i])for(j=i+i;j<=MAX;j+=i)b[j]=1;
 
 int n,cnt;
 while(cin>>n){
  cnt=0;
  for(i=1;i<=n;i++){
   if(!b[i]&!b[n+1-i])cnt++;
  }
  cout<<cnt<<endl;
 }
}

Measured memory_bytes: 0
#ABC134_C

N=int(input())
A=[int(input()) for _ in range(N)]

Amax=max(A)
indmax=[i for i,v in enumerate(A) if v==Amax]

if len(indmax)>1:
    for _ in range(N):
        print(Amax)
else:
    Amax2=sorted(A)[-2]
    for i in range(N):
        if i!=indmax[0]:
            print(Amax)
        else:
            print(Amax2)

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

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > shortest_path_faster_algorithm(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);
  vector< int > pending(g.size(), 0), times(g.size(), 0);
  queue< int > que;

  que.emplace(s);
  pending[s] = true;
  ++times[s];
  dist[s] = 0;

  while(!que.empty()) {
    int p = que.front();
    que.pop();
    pending[p] = false;
    for(auto &e : g[p]) {
      T next_cost = dist[p] + e.cost;
      if(next_cost >= dist[e.to]) continue;
      dist[e.to] = next_cost;
      if(!pending[e.to]) {
        if(++times[e.to] >= g.size()) return vector< T >();
        pending[e.to] = true;
        que.emplace(e.to);
      }
    }
  }
  return dist;
}

int main() {
  int V, E, R;
  scanf("%d %d %d", &V, &E, &R);
  WeightedGraph< int > g(V);
  for(int i = 0; i < E; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    g[a].emplace_back(b, c);
  }
  auto dists = shortest_path_faster_algorithm(g, R);
  if(dists.empty()) puts("NEGATIVE CYCLE");
  for(auto &dist : dists) {
    if(dist == numeric_limits< int >::max()) puts("INF");
    else printf("%d\n", dist);
  }
}



Measured memory_bytes: 3336
s=list(map(int,input().split()))
t=[int(input()) for i in range(s[2])]
a=s[1]-s[2]
list=[]
for j in range(s[0]):
  list.append(a)
for l in range(s[2]):
  list[t[l]-1]=list[t[l]-1]+1
for n in range(s[0]):
  if list[n]>0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 10512
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	int i,j;
	int cnt;
	string s[101],t[101];
	int MAX;
	cin>>n;
	for(i=0;i<n;i++)	cin>>s[i];
	cin>>m;
	for(i=0;i<m;i++)	cin>>t[i];
	MAX=0;
	for(i=0;i<n;i++){
		cnt=0;
		for(j=0;j<n;j++)	if(s[i]==s[j])	cnt++;
		for(j=0;j<m;j++)	if(s[i]==t[j])	cnt--;
		MAX=max(MAX,cnt);
	}
	cout<<MAX<<endl;
	return 0;
}

Measured memory_bytes: 256