akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

void solve(){

}

#else

const int MAXN = 222;
int fld[MAXN][MAXN];
int d[MAXN][MAXN];
bool usd[MAXN][MAXN];
bool n_usd[MAXN][MAXN];

void solve() {

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            char ch;

            cin >> ch;
            fld[i][j] = ch == '#';
            d[i][j] = n + m + 2;
        }
    }

    queue<pair<int, int>> q;
    queue<pair<int, int>> n_q;

    q.push({0, 0});
    int answr = 0;

    int cr_col = fld[0][0];

    while (!usd[n - 1][m - 1]) {
        if (cr_col == 1)
            ++answr;

        while (!q.empty()) {

            auto cr = q.front();
            q.pop();

            int x = cr.first;
            int y = cr.second;

            usd[x][y] = true;

            for (int dx = 0; x + dx < n && dx <= 1; ++dx) {
                for (int dy = 0; y + dy < m && dy <= 1; ++dy) {
                    if (dx * dx + dy * dy == 1) {
                        int n_x = x + dx;
                        int n_y = y + dy;


                        if (fld[n_x][n_y] == cr_col) {
                            if (!usd[n_x][n_y]) {
                                usd[n_x][n_y] = true;
                                q.push({n_x, n_y});
                            }
                        } else {
                            if (!n_usd[n_x][n_y]) {
                                n_usd[n_x][n_y] = true;
                                n_q.push({n_x, n_y});
                            }
                        }
                    }
                }
            }
        }
        swap(q, n_q);
        cr_col = 1 - cr_col;
    }

    cout << answr;
}

#endif

void multisolve() {
    int t;
    cin >> t;

    while (t--)
        solve();
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

#ifdef LOCAL
    //cout << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 512
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  n, k = get_ints
  h_arr = get_ints
  c = 0
  h_arr.each do |h|
    if h >= k
      c += 1
    end
  end
  puts c
end

if __FILE__ == $0
  main
end

Measured memory_bytes: 8196
n =  int(input())
aa = list(map(int, input().split()))

x = sum(aa) // len(aa)
cost1 = 0
cost2 = 0
for i in range(n):
  cost1 += (x - aa[i])**2
  cost2 += (x + 1 - aa[i])**2
print(min(cost1, cost2))
  

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

int main(){
  int A,B,C,K;cin>>A>>B>>C>>K;
  int cnt=0;
  while(A>=B){
    B *= 2;
    cnt++;
  }
  while(B>=C){
    C *= 2;
    cnt++;
  }
  if(K>=cnt) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

void search(int a, int b);

char wh[22][22];
bool judge[22][22];

int ans = 0;

int main(void){

while(1) {
	int x;
	int y;
	cin >> x >> y;
	if(x == 0 && y == 0) return 0;

	int i;
	int j;

	// 初期化
	for(i = 0; i < 22; i++){
		for(j = 0; j < 22; j++){
			wh[j][i] = '#';
			judge[j][i] = false;
		}
	}

// 入力
	int xs, ys;
	for(i = 1; i < y+1; i++){
		for(j = 1; j < x+1; j++){
			cin >> wh[j][i];
			if(wh[j][i] == '@') {
				xs = j;
			 	ys = i;
			}
		}
	}


	// for(i = 0; i < 22; i++){
	// 	for(j = 0; j < 22; j++){
	// 		printf("%c",wh[j][i]);
	// 	}
	// 	printf("\n");
	// }

	search(xs, ys);

	cout << ans << endl;
	ans = 0;
}

	return 0;
}

void search(int a,int b) {
	if(wh[a][b] == '#' || judge[a][b] == true) return;

	ans++;
	judge[a][b] = true;
	// 左
	search(a-1,b);
	// 右
	search(a+1,b);
	// 上
	search(a,b+1);
	// 下
	search(a,b-1);
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct BIT
{
	//[0,mn]
	vector<int> node;
	int mn;

	BIT(int mn)
	{
		this->mn = mn;
		node.resize(mn + 1, 0);
	}

	void add(int i, int x)
	{
		i++;
		while (i <= mn)
		{
			node[i] += x;
			i += (i&-i);
		}
	}

	int sum(int i)
	{
		i++;
		int res = 0;
		while (i > 0)
		{
			res += node[i];
			i -= (i&-i);
		}
		return res;
	}
};

const int MOD = 998244353;

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int N;
int X[200010], Y[200010];
vector<int> vx, vy;
int link[200010];
BIT lbit(200010), rbit(200010);

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

	cin >> N;
	rep(i, 0, N)
	{
		cin >> X[i] >> Y[i];
		vx.push_back(X[i]);
		vy.push_back(Y[i]);
	}

	sort(all(vx));
	sort(all(vy));

	rep(i, 0, N)
	{
		int px = lower_bound(all(vx), X[i]) - vx.begin();
		int py = lower_bound(all(vy), Y[i]) - vy.begin();
		link[px] = py;
		rbit.add(py, 1);
	}

	int ans = 0;
	rep(i, 0, N)
	{
		rbit.add(link[i], -1);
		rep(tl, 0, 2)rep(bl, 0, 2)rep(tr, 0, 2)rep(br, 0, 2)
		{
			int tln = tl == 1 ? modpow(2, lbit.sum(N) - lbit.sum(link[i]), MOD) - 1 : 1;
			int bln = bl == 1 ? modpow(2, lbit.sum(link[i]), MOD) - 1 : 1;
			int trn = tr == 1 ? modpow(2, rbit.sum(N) - rbit.sum(link[i]), MOD) - 1 : 1;
			int brn = br == 1 ? modpow(2, rbit.sum(link[i]), MOD) - 1 : 1;
			int fac = 1;
			if (tl&&br || bl && tr)fac = 2;
			fac = (fac*tln) % MOD;
			fac = (fac*bln) % MOD;
			fac = (fac*trn) % MOD;
			fac = (fac*brn) % MOD;
			ans = (ans + fac) % MOD;
		}
		lbit.add(link[i], 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11364
#import math
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    n=int(input())
    a = list(map(int,input().split()))
    x={}
    for i in range(n):
        if a[i] not in x:
            x[a[i]]=1
        else:
            x[a[i]]+=1
    y=[]
    for i in x:
        if x[i]>=2:
            y.append(i)
            if x[i]>=4:
                y.append(i)
    y.sort(reverse=True)
    if len(y)>=2:
        print(y[0]*y[1])
    else:
        print(0)

main()

Measured memory_bytes: 67608
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {            //ABC 162 A
            var N = cin.Read.ToCharArray();
            if (N[0] == '7' || N[1] == '7' || N[2] == '7')
            {
                WriteLine("Yes");
            }
            else 
            {
                WriteLine("No");
            }
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

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

string ff(int n, int m){
  string ans="";
  for(int i=0;i<m;i++){
    ans+=(n%4)+'0';
    n/=4;
  }
  return ans;
}

int main(){
  int n,a,b,c;
  cin >> n >> a >> b >> c;
  int l[n];
  for(int i=0;i<8;i++){
    cin >> l[i];
  }
  int t=1;
  for(int i=0;i<n;i++){
    t*=4;
  }
  int ans=1e9+7;
  for(int i=1;i<t;i++){
    int k[n];
    for(int j=0;j<n;j++){
      k[j]=ff(i,n).at(j)-'0';
    }
    int x=0;
    int y=0;
    int z=0;
    int xx=0;
    int yy=0;
    int zz=0;
    for(int j=0;j<n;j++){
      if(k[j]==1){
        x+=l[j];
        xx++;
      }
      else if(k[j]==2){
        y+=l[j];
        yy++;
      }
      else if(k[j]==3){
        z+=l[j];
        zz++;
      }
    }
    if(xx>0&&yy>0&&zz>0){
      int count=abs(a-x)+abs(b-y)+abs(c-z)+10*(xx-1)+10*(yy-1)+10*(zz-1);
      ans=min(ans,count);
    }
  }
  cout << ans  << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
int max(int a, int b){return a>b?a:b;}
int min(int a, int b){return a<b?a:b;}
int gcd(int a, int b){return min(a,b)==0?max(a,b):gcd(min(a,b),max(a,b)%min(a,b));}
long long llmax(long long a, long long b){return a>b?a:b;}
long long llmin(long long a, long long b){return a<b?a:b;}
long long llgcd(long long a, long long b){return min(a,b)==0 ?llmax(a,b):llgcd(llmin(a,b),llmax(a,b)%llmin(a,b));}
int assort(const void *a, const void *b){return *(int*)a-*(int*)b;}
int dessort(const void *a, const void *b){return *(int*)b-*(int*)a;}
int llassort(const void *a, const void *b){return *(long long*)a-*(long long*)b;}
int lldessort(const void *a, const void *b){return *(long long*)b-*(long long*)a;}
int charassort(const void *a, const void *b){return strcmp((char*)a ,(char*)b);}
int chardessort(const void *a, const void *b){return strcmp((char*)b ,(char*)a);}
char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int ntoi(char c){return c-'0';}
int ltoi(char c){return c-'a';}
int utoi(char c){return c-'A';}
long long mod=1000000007;

int main(void){
    int n,ans=0,count1[100001],count2[100001];
    for (int i=0; i<100001; i++){
        count1[i]=0;
        count2[i]=0;
    }
    scanf("%d",&n);
    int v[n];
    for (int i=0; i<n; i++){
        scanf("%d",&v[i]);
        if (i%2!=0){
            count1[v[i]]++;
        } else {
            count2[v[i]]++;
        }
    }
    
    int tmpans11,tmpans12,tmpans21,tmpans22;
    int tmp=-1,tmpi11=-1,tmpi12=-1,tmpi21=-1,tmpi22=1;
    
    for (int i=0; i<100001; i++){
        if (tmp<count1[i]){
            tmp=count1[i];
            tmpi11=i;
        }
    }    
    tmpans11=(n/2)-tmp;
    tmp=-1;
    count1[tmpi11]=-1;
    for (int i=0; i<100001; i++){
        if (tmp<count1[i]){
            tmp=count1[i];
            tmpi12=i;
        }
    }        
    tmpans12=(n/2)-tmp;
    
    tmp=-1;
    for (int i=0; i<100001; i++){
        if (tmp<count2[i]){
            tmp=count2[i];
            tmpi21=i;
        }
    }    
    tmpans21=(n/2)-tmp;
    tmp=-1;
    count2[tmpi21]=-1;
    for (int i=0; i<100001; i++){
        if (tmp<count2[i]){
            tmp=count2[i];
            tmpi22=i;
        }
    }        
    tmpans22=(n/2)-tmp;
    
    if (tmpi11!=tmpi21){
        ans=tmpans11+tmpans21;
    } else {
        ans=min(tmpans12+tmpans21,tmpans11+tmpans22);
    }
    printf("%d\n",ans);
    
    
    
	return 0 ;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define N 500009
#define M (L+R)/2
#define inf 999999999999
#define mod 1000000007
#define pb push_back
#define ll long long

ll n,ans=inf,sum,x;
string s;

int main() {
    
    ios::sync_with_stdio(0);
    
    cin>>s;
    for(int i=2;i<s.size();i++){
        x=(s[i-2]-'0')*100+(s[i-1]-'0')*10+(s[i]-'0');
        if(abs(753-x)<ans){
            ans=abs(753-x);
        }
    }
    
    cout<<ans<<endl;



return 0;
}

Measured memory_bytes: 256
#A,B,Kをそれぞれint型で取得する
a,b,k = map(int,input().split())

#AもBも割り切る数字を保管する用のListを用意する。
l = []
for i in range(1,101)[::-1]:    #大きい方から順に(問題設定から、有り得る最大値は100)調べていく。
    if(a % i == 0 and b % i == 0):  #AもBも割り切れたら
        l.append(i) #Listに追加する
#大きい順に保管しているので、前からK番目のものを出力すれば良い。(0-indexと1-indexに注意)
print(l[k-1])


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

using namespace std;

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


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

    int fib[50];
    fib[0] = 1;
    fib[1] = 1;

    for (int i = 2; i <= n; ++i) {
        fib[i] = fib[i-2] + fib[i-1];
    }


    cout << fib[n] << "\n";

    return 0;
}


Measured memory_bytes: 3120
n = int(input())
p = list(map(int,input().split())) 
cnt = 0
for i in range(1,n-1):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        cnt += 1
    elif p[i-1]>p[i] and p[i]>p[i+1]:
        cnt += 1
    else:
        cnt = cnt
print(cnt)

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

int main(){
  string s,t;
  cin >> s >> t;
  
  if(t.size()>s.size()){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  for(int i=s.size()-t.size();i>=0;i--){
    int count = 0;
      
    rep(j,t.size()){
      if(s[i+j]==t[j] || s[i+j]=='?'){
        count++;
      }
    }
    if(count==t.size()){
      rep(j,t.size()){
        s[i+j]=t[j];
      }
      rep(i,s.size()){
        if(s[i]=='?'){
          s[i]='a';
        }
      }
      cout << s << endl;
      return 0;
    }
    
  }
  
  cout << "UNRESTORABLE" << endl;
  return 0;
}

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

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

int main(){
	int n;
	while( cin >> n, n ){
		long long emp[4001];
		vector<int> nums;
		bool exist = false;
		memset( emp, 0, sizeof(emp) );
		rep(i,n){
			int num;
			long long val, am;
			cin >> num >> val >> am;
			emp[num] += val*am;
			if( find(nums.begin(), nums.end(), num) == nums.end() ){
				nums.push_back(num);
			}
		}
		rep(i,nums.size()){
			if( emp[nums[i]] >= 1000000 ){
				exist = true;
				cout << nums[i] << endl;
			}
		}
		if(!exist){
			cout << "NA" << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1268
/* Depth First Search */
#include <stdio.h>

int n, G[101][101];
int d[101];
int T = 0;
int F[101] = {0};
int k = 0;

void visit(int u)
{
    int i, j, v;
    T++;
    d[u] = T;

    for(v=0; v<n; v++){
        if(G[u][v] == 1 && d[v] == 0){
            visit(v);
        }
    }

    T++;
    F[u] = T;
}

int main()
{
    int i, j, k, l, u, a, t;
    
    for(i=0; i<n; i++){
        d[i] = 0;
    }

    scanf("%d", &n);
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            G[i][j] = 0;
        }
    }

    for(i=0; i<n; i++){
        scanf("%d %d", &k, &u);
        for(j=0; j<u; j++){
            scanf("%d", &a);
            G[k-1][a-1] = 1;
        }
    }

    for(i=0; i<n; i++){
        if(d[i] == 0){
            visit (i);
        }
    }

    for(i=0; i<n; i++){
        printf("%d %d %d\n", i+1, d[i], F[i]);
    }
    return 0;
}


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

int main() {
    int w, h;

    stack<pair<int, int>> s;
    
    vector<int> anss(0);
    while(true) {
        cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }
        vector<vector<int>> map(h, vector<int>(w));
        vector<vector<bool>> reached(h, vector<bool>(w));
        rep(i, h) rep(j, w) cin >> map[i][j];

        int ans = 0;
        rep(i, h) rep(j, w) {
            s.push(pair<int, int>(i, j));
            bool hasi = false;
            while(!s.empty()) {
                pair<int, int> p = s.top(); s.pop();
                int ph = p.first;
                int pw = p.second;
                if (ph < 0 || ph >= h || pw < 0 || pw >= w) {
                    continue;
                }
                if (map[ph][pw] == 0) {
                    continue;
                }
                if (reached[ph][pw]) {
                    continue;
                }
                hasi = true;
                reached[p.first][p.second] = true;
                s.push(pair<int, int>(ph - 1, pw - 1));
                s.push(pair<int, int>(ph - 1, pw));
                s.push(pair<int, int>(ph - 1, pw + 1));
                s.push(pair<int, int>(ph, pw - 1));
                s.push(pair<int, int>(ph, pw + 1));
                s.push(pair<int, int>(ph + 1, pw - 1));
                s.push(pair<int, int>(ph + 1, pw));
                s.push(pair<int, int>(ph + 1, pw + 1));
            }
            if (hasi) ans++;
        }
        anss.push_back(ans);
    }
    
    for(int i = 0; i < anss.size(); i++ ) {
        cout << anss[i] << endl;
    } 
    return 0;
}




Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int N, K, a[55];
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a, a + N);
	reverse(a, a + N);
	int ret = 0;
	for (int i = 0; i < K; i++) ret += a[i];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
using namespace std;
struct Node{
    int key;
    Node *right;
    Node *left;
    Node *parent;
};

Node *root, *NIL;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node* treeSearch(Node *u, int k){
    while (u != NIL && k != u->key){
        if (k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}
Node nodeSearch(Node u, int k){
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
    Node y; // node to be deleted
    Node x; // child of y



}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL){
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if (y == NIL) root = z;
    else{
        if (z->key < y->key) y->left = z;
        else y->right = z;
    }
}

void inorder(Node *u){
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
    int n, i, x;
    string cmd;
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        cin >> cmd;
        if (cmd == "find"){
            scanf("%d", &x);
            Node *t = treeSearch(root, x);
            if ( t != NIL ) printf("yes\n");
            else printf("no\n");
        } else if (cmd == "insert"){
            // insert
            scanf("%d", &x);
            insert(x);
        } else if (cmd == "print"){
            // print
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (cmd == "delete"){
            // delete
            //scanf("%d", &x);
            //treeDelete(treeSearch(root, x));
        }
    }

    return 0;
}



Measured memory_bytes: 22064
class Question:
    def __init__(self, num, result):
        self.num = int(num)
        self.result = result


n, m = map(int, input().split())
p_list = [input().split() for _ in range(m)]
questions = [Question(num, result) for num, result in p_list]

# 高速化のためにsetを使う
ac_list = set()
wa_dict = {}
wa_count = 0

for q in questions:
    if not(q.num in ac_list):
        if q.result == 'AC':
            ac_list.add(q.num)
            wa_count += wa_dict[q.num] if q.num in wa_dict else 0
        elif q.num in wa_dict:
            wa_dict[q.num] += 1
        else:
            wa_dict[q.num] = 1
print('{} {}'.format(len(ac_list), wa_count))


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

#define in freopen("input.txt", "r" ,stdin)
#define out freopen("fenceplan.out", "w" ,stdout)
#define ll long long
#define pb push_back
#define fr first
#define sc second
const int mod = 1e9+7;
using namespace std;
ll a , b;
map<ll ,ll> m;
int main (){
    //in;
    //out;
    //ios_base::sync_with_stdio(0);
    cin >> a >> b;
    m[a]++;
    m[b]++;

    for (int i = 1; i <= 3; i++) {
        if (!m[i]) {
            cout << i;
            return 0;
        }
    }
}


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

using namespace std;


int main() {
    string A, B, C;
    cin >> A >> B >> C;

    string ans;
    int a = 0, b = 0, c = 0;
    char t = 'a';
    while (a <= A.size() && b <= B.size() && c <= C.size()) {
        switch (t) {
            case 'a':
                if (a < A.size())t = A[a];
                else ans = 'A';
                a++;
                break;
            case 'b':
                if (b < B.size())t = B[b];
                else ans = 'B';
                b++;
                break;
            case 'c':
                if (c < C.size())t = C[c];
                else ans = 'C';
                c++;
                break;
        }
    }

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

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

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

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

bool canMonth(char fst, char snd) {
  return ((fst - '0') == 0 && (snd - '0') != 0) || ((fst - '0') == 1 && (snd - '0') < 3);
}

int main() {
  string s;
  cin >> s;
  bool canFirstMonth = canMonth(s[0], s[1]);
  bool canSecondMonth = canMonth(s[2], s[3]);

  if (canFirstMonth && canSecondMonth) {
    cout << "AMBIGUOUS" << endl;
  } else if (canFirstMonth) {
    cout << "MMYY" << endl;
  } else if (canSecondMonth) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-ff;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n;
long long bin[5],ans;
long long a[405][4],A[4],B[4];
unordered_map<long long,long long>mp;
long long gao(long long aa,long long bb)
{
	long long qwq=0;
	for(long long j=0;j<4;++j) qwq+=bin[j]*a[aa][(bb+j)%4];
	return qwq;
}
long long md(long long aa,long long bb,long long cc)
{
	a[n+1][0]=A[aa];a[n+1][1]=B[aa];
	a[n+1][2]=B[bb];a[n+1][3]=A[bb];
	long long tmp=gao(n+1,0);
	if(!mp.count(tmp)) return 0;tmp=mp[tmp];
	for(long long i=0;i<4;++i) mp[gao(n+1,i)]-=cc;
	return tmp;
}
void getans()
{
	ans+=1ll*md(0,1,1)*md(1,2,1)*md(2,3,1)*md(3,0,1);
	md(0,1,-1);md(1,2,-1);md(2,3,-1);md(3,0,-1);
	return;
}
int main()
{
	n=read();bin[0]=1;
	for(long long i=1;i<4;++i) bin[i]=bin[i-1]*1000;
	for(long long i=1;i<=n;++i) 
	{
		for(long long j=0;j<4;++j) a[i][j]=read();
		for(long long j=0;j<4;++j) mp[gao(i,j)]++;
	}
	for(long long i=1;i<=n;++i)
	{
		for(long long j=0;j<4;++j) mp[gao(i,j)]--,A[j]=a[i][j];
		for(long long j=i+1;j<=n;++j)
		{
			for(long long l=0;l<4;++l) mp[gao(j,l)]--;
			swap(a[j][0],a[j][1]);swap(a[j][2],a[j][3]);
			for(long long l=0;l<4;++l)
			{
				for(long long k=0;k<4;++k) B[k]=a[j][(k+l)%4];
				getans();
			}
			swap(a[j][0],a[j][1]);swap(a[j][2],a[j][3]);
			for(long long l=0;l<4;++l) mp[gao(j,l)]++;
		}
		for(long long j=0;j<4;++j) mp[gao(i,j)]++;
	}
	write(ans/3);
	return 0;
}

Measured memory_bytes: 384
h,w=map(int,input().split())
x=[]
for i in range(1,w):
    x1=[h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)]
    x1.sort()
    x.append(x1[-1]-x1[0])
    x2=[h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)]
    x2.sort()
    x.append(x2[-1]-x2[0])
for i in range(1,h):
    x1=[w*i,w*((h-i)//2),w*(h-i)-w*((h-i)//2)]
    x1.sort()
    x.append(x1[-1]-x1[0])
    x2=[w*i,(h-i)*(w//2),w*(h-i)-(h-i)*(w//2)]
    x2.sort()
    x.append(x2[-1]-x2[0])
print(min(x))


Measured memory_bytes: 18968
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n,k;
  cin >> n >> k;
  ll p[n],c[n];
  for(ll i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  for(ll i=0;i<n;i++)cin >> c[i];

  ll m=-inf;
  for(ll i=0;i<n;i++){
    vec v;
    ll q=p[i];
    while(q!=i){
      v.push_back(q);
      q=p[q];
    }
    v.push_back(i);
    ll l=v.size();
    ll s=0;
    if(l>k){
      for(ll j=0;j<k;j++){
        s+=c[v[j]];
        m=max(m,s);
      }
    }
    else{
      for(ll j=0;j<l;j++){
        s+=c[v[j]];
        m=max(m,s);
      }
      if(s>0){
        ll r=k%l;
        s=(k/l-1)*s;
        m=max(s,m);
        for(ll j=0;j<l;j++){
          s+=c[v[j]];
          m=max(s,m);
        }
        for(ll j=0;j<r;j++){
          s+=c[v[j]];
          m=max(s,m);
        }
      }
      //cout << l << endl;
    }
    

  }

  cout << m << endl;

}

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

using namespace std;

typedef long long ll;

int main(){
    int n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll cnt = 0;
    for (int i = 0; i < n - 1; ++i) {
        ll sum = a[i] + a[i + 1];
        if (sum > x){
            if (a[i+1] >= sum - x){
                a[i+1] -= sum - x;
            }else{
                a[i+1] = 0;
                a[i] -= sum - x - a[i+1];
            }

            cnt += sum - x;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>

using namespace std;

typedef	complex<double> P;

double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
int main(){

	double xp,yp,x1,x2,x3,y1,y2,y3;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
		P tp1(x1,y1);
		P tp2(x2,y2);
		P tp3(x3,y3);
		P p(xp,yp);
		P p1 = tp1 - p;
		P p2 = tp2 - p;
		P p3 = tp3 - p;

		double v1 = cross(p1,p2);
		double v2 = cross(p2,p3);
		double v3 = cross(p3,p1);

		if((v1>=0&&v2>=0&&v3>=0)||(v1<0&&v2<0&&v3<0))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

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

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

int main()
{
    string s,ans = "a";
    bool sb[26];
    rep(i, 26)sb[i]  = false;
    cin >> s;
    rep(i, s.size())sb[s[i] - 97] = true;
    rep(i, 26){
        if (!sb[i]) {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  for(int i = 0;i < s.size();i++){
    char a;
    if(s[i]-'A'+1+n > 26) a = s[i]+n-26;
    else a = s[i]+n;
    if(i != s.size()-1){
      cout << a;
    }
    else{
      cout << a << endl;
    }
  }
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

typedef vector<vector<int>> graph;

// -1,0,1のいずれか. 0は未着色
bool isbipartite(int v, int par, int color, vector<int> &data, const graph &g) {
  if (data[v] != 0)
    if (data[v] != color) {
      return false;
    } else {
      return true;
    }
  data[v] = color;
  for (auto u : g[v]) {
    if (u == par)
      continue;
    if (!isbipartite(u, v, -color, data, g))
      return false;
  }
  return true;
}

int main() {
  ll n;
  ll m;
  cin >> n >> m;
  graph g(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vi d(n, 0);
  auto isnibu = isbipartite(0, -1, 1, d, g);
  if (isnibu) {
    ll white = 0;
    ll black = 0;
    REP(i, n) {
      if (d[i] == 1) {
        white++;
      } else {
        black++;
      }
    }
    cout << white * black - m << endl;
  } else {
    cout << n * (n - 1) / 2 - m << endl;
  }
}


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

using namespace std;

int main(){
  int n, l;
  std::cin >> n >> l;

  vector<int> taists;
  int all_eat_val = 0;
  for(int i=1; i<=n; i++){
     taists.push_back(l + i - 1);
     all_eat_val += (l + i - 1);
  }

  sort(taists.begin(), taists.end());

  int eat = INT_MAX;
  int ans;
  for(int i=0; i<taists.size(); i++){
    int temp = all_eat_val - taists[i];
    if( eat > abs(temp - all_eat_val) ){
      eat = abs(temp - all_eat_val);
      ans = temp;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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



namespace CSharpSample01
{

    
    class Program
    {

        const long MOD = 1000000007;

        //O(√N)
        //Nの素因数をリストで返す
        static List<int> Prime(int N)
        {

            List<int> p = new List<int>();

            for (int i = 2; i <= Math.Sqrt(N); i++)
            {

                while (N % i == 0)
                {
                    p.Add(i);
                    N /= i;
                }

            }

            if (N != 1) p.Add(N);

            return p;
        }

        //コンビネーションの計算
        //(N)C(K)を計算
        static long Conb(int N, int K)
        {
            long[,] c = new long[N + 1, K + 1];

            for (int i = 0; i <= N; i++)
            {
                c[i, 0] = 1;
                if(i <= K) c[i, i] = 1;
            }

            for (int n = 1; n <= N; n++)
            {
                for (int k = 1; k <= K; k++)
                {
                    c[n, k] = c[n - 1, k] + c[n - 1, k - 1];
                    c[n, k] %= MOD;  //64bitを超えないように1000000007で割る
                }
            }

            return c[N, K];
        }

        static void Solve(int N, int M)
        {
            //素因数のリスト(prime_list)
            List<int> prime_list = Prime(M);

            //M = 1の時、1は素数ではないのでprime_listに要素(素数)はない
            //1 * ... * 1 = M と N回 1を掛ける1通り
            if (prime_list.Count == 0)
            {
                Console.WriteLine("1");
                return;
            }

            //Console.WriteLine("prime_list:" + string.Join(" ", prime_list));

            //prime_list内の各素因数の指数を計算(exp)
            List<int> exp = new List<int>();
            int cur = prime_list[0];
            //素因数curの数(指数)をカウント
            int cnt = 0;
            foreach(int val in prime_list)
            {
                if(cur == val)
                {
                    cnt++;
                }
                else
                {
                    exp.Add(cnt);
                    cnt = 1;
                    cur = val;
                }
            }

            exp.Add(cnt);

            //Console.WriteLine("exp:" + string.Join(" ", exp));

            //答えans
            //(exp[i] + N - 1)C(exp[i])を各exp[i]について行う
            long ans = 1;
            for(int i = 0; i < exp.Count; i++)
            {
                ans = (ans * Conb(exp[i] + N - 1, exp[i])) % MOD;                
            }

            Console.WriteLine(ans);
        }

        static void Main(string[] args)
        {
            //入力1(S)
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            Solve(N, M);
        }
    }

}

Measured memory_bytes: 34400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  ll N,K;
  cin >> N >> K;
  ll c1 = N/K;
  if(K % 2 == 0){
    ll c2 = (N + (K/2)) / K;
    cout << c1 * c1 * c1 + c2 * c2 * c2 << endl;
  }else{
    cout << c1 * c1 * c1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    double a,b;
    cin>>a>>b;
    cout<<ceil(a/b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,k,h[200005],ans;
int main(void){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	sort(h,h+n);
	for(int i=0;i<n;i++){
		if(i<n-k){
			ans+=h[i];
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */

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


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>



int getTheAnswer() {
    return 42;
}

template< class InputIt>
void incAll(const InputIt &first, const InputIt &last){
  for(auto it = first; it != last; ++it){
    ++*it;
  }
}

template <class InputIt>
void printAll(const InputIt &first, const InputIt &last, std::ostream& out){
  for(InputIt it = first; it != last; ++it){
    out << *it << " ";
  }
}

// only for positive integers
int gcd(int a, int b){
  int tmp;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  while(b != 0){
    tmp = a;
    a = b;
    b = tmp % b;
  }
  return a;
}

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


using namespace std;

class TaskC {
public:
  void solve(std::istream &in, std::ostream &out) {
    ios::sync_with_stdio(false);
    long long int x, res;
    res = 0;
    in >> x;
    if (x >= 11) {
      res = 2 * (x / 11);
      x -= 11 * res / 2;
      if (x > 0) {
        if (x <= 6) {
          res += 1;
        } else {
          res += 2;
        }
      }
    }else if (x <= 6) {
      res += 1;
    } else {
      res += 2;
    }


    out << res << endl;
  }
};


int main() {
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using i64=long long int;

int main() {
    i64 n, p;
    cin >> n >> p;
    if (n == 1) {
        cout << p << endl;
        return 0;
    } 

    i64 ans = 1;
    i64 l = 1;
    int dgt = 1;
    while (p > l) {
        l <<= 1;
        ++dgt;
    }
    i64 limit = 1;
    limit <<= dgt/n+1;

    for (i64 i = 2; i <= limit; ++i) {
        i64 c = 0;
        while (p % i == 0) {
            p /= i;
            ++c;
            if (c == n) {
                ans *= i;
                c = 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pri 1000000007
using namespace std;
ll x[2][2097152];
int main() {
	ll n;
	cin>>n;
	ll a[n+1][n+1];
     for(ll i=1;i<=n;i++){
     	 for(ll j=1;j<=n;j++){
     	 cin>>a[i][j];	
     	 }
     }
     ll z=pow(2,n);
     
     ll y[z]={0};
     for(ll j=0;j<2;j++)
     for(ll i=0;i<z;i++)x[j][i]=0;
     x[0][0]=1;
     for(ll i=1;i<=n;i++){
     	ll e=1;
     	for(ll j=1;j<=n;j++){
     		
     		if(a[i][j]==1){
     		
     		for(ll k=0;k<z;k++){
     		  // cout<<k<<e<<endl;
     			ll v=x[(i-1)%2][k];
     			
     		    if((k&e)==0){
     		    	ll ka=k|e;
     		    	
     		    	if(y[ka]==i)
     		    	x[i%2][ka]=(x[i%2][ka]+v)%pri;
     		    	else 
     		    	x[i%2][ka]=v%pri;
     		    	
     		        y[ka]=i;
     		    	 //  cout<<x[i%2][ka]<<"d"<<endl;
     		    }
     		 
     		}
     			
     		}
     		e*=2;
     	}
    }
    cout<<x[(n)%2][z-1]%pri;
	return 0;
}

Measured memory_bytes: 49408
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    int N,i;
    cin >> N >> i;
    
    cout << (N-1)*(i-1) << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	int W,H,N;
	cin >> W >> H >> N;

	int lx = 0, rx = W;
	int ly = 0, ry = H;

	while(N--){
		int x,y,t;
		cin >> x >> y >> t;

		if(t == 1) lx = max(lx,x);
		if(t == 2) rx = min(rx,x);
		if(t == 3) ly = max(ly,y);
		if(t == 4) ry = min(ry,y);

	}
	
	int ans = (rx - lx) * (ry - ly); 
	if(rx - lx < 0) ans = 0;
	if(ry - ly < 0) ans = 0;

	cout << ans << endl;

	return 0;
}



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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcount(n)
typedef long long int  ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = 2 * acos((ld) 0);
ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> void setmin(T& a, T val) {if (a > val) a = val;}
template<class T> void setmax(T& a, T val) {if (a < val) a = val;}
void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}


const int MAXN = 1 << 20;

int main() {
	int n;
	scanf("%d",&n);
	ll a[n+1],b[n+1];
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	for(int i=0;i<n;i++)scanf("%lld",b+i);
	
	for(int i=1;i<n;i++)
		a[i]+=a[i-1];
	for(int i=n-2;i>=0;i--)
		b[i]+=b[i+1];
	ll mx=0;	
	for(int i=0;i<n;i++)
	{
		mx=max(mx,(a[i]+b[i]));
	}
	printf("%lld",mx);	
	
	return 0;
}


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

using namespace std;

int main(void)
{
	char c[5];
	int i, j;
	int sum[14];
	int max, max2;
	
	while (scanf("%d, %d, %d, %d, %d", &c[0], &c[1], &c[2], &c[3], &c[4]) != EOF){
		
		for (i = 0; i < 14; i++){
			sum[i] = 0;
		}
		
		
		for (i = 0; i < 5; i++){
			sum[c[i]-1]++;
		}
		
		max = 0;
		max2 = 0;
		
		for (i = 0; i < 14; i++){
			if (max < sum[i]){
				max = sum[i];
			}
			else if (max2 < sum[i]){
				max2 = sum[i];
			}
		}
		
		int ch;
		
		for (i = 0; i < 10; i++){
			
			ch = 0;
			
			for (j = 0; j < 5; j++){
				
				if (sum[(i + j) % 13] == 1){
					ch++;
				}
			}
			if (ch == 5){
				break;
			}
		}
		
		if (max == 4){
			printf("four card\n");
		}
		else if (max == 3 && max2 == 2){
			printf("full house\n");
		}
		
		
		else if (ch == 5){
			printf("straight\n");
		}
		
		else if (max == 3){
			printf("three card\n");
		}
		else if (max == 2 && max2 == 2){
			printf("two pair\n");
		}
		else if (max == 2){
			printf("one pair\n");
		}
		else {
			printf("null\n");
		}
	}
	return (0);
}

Measured memory_bytes: 1008
while (True):
    s = list(map(int, input().strip().split(' ')))

    if s[0] == 0 and s[1] == 0:
        break
    else:
        for i in range(s[0]):
            for j in range(s[1]):
                if i == 0 or i == s[0] - 1:
                    print("#", end="")
                elif j == 0 or j == s[1] - 1:
                    print("#", end="")
                else:
                    print(".",end="")
            print()
    print()


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int i;
  rep(i,n)cin>>a[i];
  map<int,int> m;
  ll ans=0;
  rep(i,n)
  {
    if(i>=1)
    {
      if(m.find(i+1-a[i])!=m.end())
      {
        ans+=m.at(i+1-a[i]);
      }
    }
    if(m.find(a[i]+i+1)==m.end())
    {
      m.insert(make_pair(a[i]+i+1,1));
    }
    else
    {
      int num=m.at(a[i]+i+1);
      m.erase(a[i]+i+1);
      m.insert(make_pair(a[i]+i+1,num+1));
    }
  }
  cout<<ans<<endl;
}



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

int main()
{
  int n;
  cin >> n;
  
  if( n%2 == 0 )
  {
    cout << 0.5 << endl;
  }
  else
  {
    double c = n / 2 + 1;
    double d;
    d = c / n;
    printf( "%f\n", d );
  }
  
  return 0;
}

Measured memory_bytes: 384
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<LL, LL> LLLL;

int main(int argc, char* argv[]) {
	LL t, n, a, b, c, d, ans;
	cin >> t;
	for (LL tt = 0; tt < t; ++tt) {
		cin >> n >> a >> b >> c >> d;
		ans = 1LL << 60;
		priority_queue<LLLL, vector<LLLL>, greater<>> q;
		q.emplace(make_pair(0, n));
		map<LL, LL> memo;
		const LL divs[3] = { 2, 3, 5 };
		const LL costs[3] = { a, b, c };
		while (!q.empty()) {
			LLLL top = q.top();
			q.pop();
			LL cost = top.first;
			LL x = top.second;
			if (cost > memo[x]) continue;
			memo[x] = cost;
			if ((x >> 32) * d < (1LL << 30)) {
				ans = min(ans, cost + x * d);
			}
			for (LL i = 0; i < 3; ++i) {
				LL y = x / divs[i];
				LL c = cost + costs[i] + (x - y * divs[i]) * d;
				if (memo.find(y) == memo.end() || memo[y] > c) {
					memo[y] = c;
					q.emplace(make_pair(c, y));
				}
				if (x != y * divs[i]) {
					++y;
					c = cost + costs[i] + (y * divs[i] - x) * d;
					if (memo.find(y) == memo.end() || memo[y] > c) {
						memo[y] = c;
						q.emplace(make_pair(c, y));
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	string s[2];
	cin >> s[0] >> s[1];
	int pre = s[0][0] != s[1][0];
	int64_t ans = 3 * (pre + 1), mod = 1e9 + 7;
	for(int i = 1 + pre, now; i < n; i += now + 1, pre = now){
		now = s[0][i] != s[1][i];
		if(pre && now) ans *= 3;
		else if(pre) ans *= 1;
		else if(now) ans *= 2;
		else ans *= 2;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a;
    vector<ll>n(5);
    map<int,int>m;
    REP(i,5){
        n[i] = 0;
    }
    REP(i,6){
        cin >> a;
        n[a]++;
    }
    REP(i,5){
        m[n[i]]++;
    }
    if(m[1]==2 && m[2] == 2)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		//指定した範囲内に円があるかどうかを判定する
		//指定した範囲：座標(0,0)から(W,H)
		//円：中心点(x,y)、半径r
		Scanner sc=new Scanner(System.in);
		int W=sc.nextInt();
		int H=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
		int r=sc.nextInt();
		if(r<=x && x<=W-r && r<=y && y<=H-r){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}



Measured memory_bytes: 26324