akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    char c = 'x';
    s.at(i)= c;
    cout<<s.at(i);
  }



}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N;
	cin >> N;
	vector <int> A(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
	}
	sort(A.begin(), A.end());

	int ans = 0;
	map<int, int> m;
	for (int ii = 0; ii < N; ++ii){
		vector <int> div;
	    for (int jj = 1; jj*jj <= A[ii]; ++jj){
	        if (A[ii] % jj == 0){
	            div.push_back(jj);
	            if (A[ii] / jj != jj){
	                div.push_back(A[ii] / jj);   //重複しないなら相方も追加
	            }
	        }
	    }

	    if (m[A[ii]] == 0){
		    bool ok = true;
		    for (int ii = 0; ii < div.size(); ++ii){
		    	if (m[div[ii]] != 0){
		    		ok = false;
		    		break;
		    	}
		    }
		    if (ok){
		    	m[A[ii]] = 1;
		    	ans++;
		    }
	    } else {
	    	if (m[A[ii]] == 1){
	    		m[A[ii]] = 2;
	    		ans--;
	    	}
	    }
	}

	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 33004
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> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      map.put(a, map.getOrDefault(a, 0)+1);
    }
    int ans = 0;
    for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
      int a = entry.getKey();
      int count = entry.getValue();
      if (count < a) {
        ans += count;
      } else if (count > a) {
        ans += count - a;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 61552
S = input()
op_cnt = len(S) - 1
ResSum = 0

for i in range(2**op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"

    formula = ""
    for p_S, p_o in zip(S, op + [""]):
        formula += (p_S + p_o)

    ResSum += eval(formula)

print(ResSum)

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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;

int n;
int cnt;
int a[N];

 main () {
        cin >> n;

        for (int i = 1; i <= n; i ++) {
                cin >> a[i];
        }
        for (int i = 1; i <= n;) {
                if (a[i] == i) {
                        cnt ++;
                        if (a[i + 1] == i + 1)
                                i += 2;
                        else
                                i ++;
                }
                else
                        i ++;
        }
        cout << cnt << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int N, K;
    cin >> N >> K;
    if ((N + 1) / 2 >= K){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using ld = long double;
using ui = unsigned int;
using ull = unsigned long long;
using ui128 = __uint128_t;
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define lc ind<<1
#define rc ind<<1|1
const int MN = 1e5 + 2, LOG = 17, INF = 1e8;
ll ans[MN];
int main () { 
	int n; 
	scanf ("%d",&n);
	vector<pii> a(n);
	for (int i = 0; i < n; i++) {
		scanf ("%d",&a[i].first); a[i].second = i; 
	}
	sort(all(a),[&](pii b, pii c){return b.first > c.first || (b.first == c.first && b.second < c.second);});
	a.push_back({0,0});
	int lst = n + 1;ll cursum = 0; int cnt = 0, done = 0, lstVal = 0;
	for (int i = 0; i <= n; i++) {
		if (a[i].second > lst) {cnt++; cursum += a[i].first; continue;}
		if (lst == n+1) {lstVal = a[i].first; lst = a[i].second; ++done; continue;}
		ans[lst] = (ll)done * (lstVal - a[i].first) + cursum - (ll)a[i].first * cnt;
		done += cnt + 1; cnt = 0; cursum = 0; lst = a[i].second; lstVal = a[i].first;
	}
	for (int i = 0; i < n; i++) printf ("%lld\n",ans[i]);
    return 0;
}
//1 2 1 3 2 4 2 5 8 1
//1 2 1 2 2 2 2 2 2 1

//1 2 1 2 2 2 2 2 2 1
//9 9 9 8 8 6 6 6 4 4 4 4


Measured memory_bytes: 5028
#include<stdio.h>
#define GOAT 3
int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  if((a%GOAT==0)||(b%GOAT==0)||((a+b)%GOAT==0)) printf("Possible\n");
  else printf("Impossible\n");
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

typedef struct List{
	int cnt;
	char s[210];
}LIST;
struct comp{
	bool operator() (const List& a, const List& b) const{  //free
		if(a.cnt!=b.cnt)
			return a.cnt>b.cnt ? true : false;
		for(int i=0;i<a.cnt;i++)
			if(a.s[i]!=b.s[i])
				return a.s[i]>b.s[i] ? true : false;
		return false;
	}
};
LIST now,ans;
map <List,int,comp> MAP;

char ss[15][25];
int visit[15][25],op[8][2] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	int N,n,M,m,i,j,mark,maxi,nx,ny,now_cnt;
	while(~scanf(" %d %d",&N,&M) && (N+M)){
		gets(ss[0]);
		for(n=0;n<N;n++)
			gets(ss[n]);
		MAP.clear();
		ans.cnt = 0;
		now_cnt = 0;
		memset(visit,0,sizeof(visit));
		mark = 0;
		for(n=0;n<N;n++){
			for(m=0;m<M;m++){
				for(i=0;i<8;i++){
					mark++;
					now.cnt = 1;
					now.s[0] = ss[n][m];
					visit[n][m] = mark;
					nx = (n+op[i][0]+N)%N;
					ny = (m+op[i][1]+M)%M;
					while(visit[nx][ny]!=mark){
						visit[nx][ny] = mark;
						now.s[now.cnt++] = ss[nx][ny];
						nx = (nx+op[i][0]+N)%N;
						ny = (ny+op[i][1]+M)%M;
						if(now.cnt>1 && now.cnt>=ans.cnt){
							if(MAP.find(now)==MAP.end()){
								MAP[now] = n*M+m;
							}
							else{
								if(now.cnt>ans.cnt){
									ans = now;
								}
								else if(now.cnt==ans.cnt){
									int which = 1;
									for(j=0;j<now.cnt;j++){
										if(ans.s[j]==now.s[j])
											continue;
										else{
											if(ans.s[j]<now.s[j])
												which = 1;
											else
												which = 2;
										}
									}
									if(which==2)
										ans = now;
								}
							}
						}
					}
				}
			}
		}
		//printf("==============================================\n");
		if(ans.cnt>1){
			int re = 0;
			for(i=0,j=ans.cnt-1;i<=j;i++,j--){
				if(ans.s[i]!=ans.s[j]){
					re = ans.s[i]>ans.s[j] ? 1 : 2;
					break;
				}
			}
			if(re==2 || re==0)
				for(i=0;i<ans.cnt;i++)
					printf("%c",ans.s[i]);
			else
				for(i=ans.cnt-1;i>=0;i--)
					printf("%c",ans.s[i]);
			printf("\n");
		}
		else
			printf("0\n");
	}
	
	return 0;
}

Measured memory_bytes: 35176
import java.util.*;
class Main {
    static boolean isDoubletPresent(int[] A, int[] B) {
        int count = 0;
        for(int i = 0; i < A.length; i++) {
            if(A[i] == B[i]) {
                count++;
            }
            else {
                count = 0;
            }
            
            if(count >= 3) {
                return true;
            } 
        }
        
        return false;
    }
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int A[] = new int[N];
      int B[] = new int[N];
      
      for(int i = 0; i < N; i++) {
          A[i] = sc.nextInt();
          B[i] = sc.nextInt();
      }
      
      System.out.print(isDoubletPresent(A, B) ? "Yes" : "No");
    }
}

Measured memory_bytes: 36012
#include<iostream>
#include<algorithm>
using namespace std;
struct res{
	string city;
	int p;
	int num;
}re[105];
bool com(res a, res b){
	if(a.city!=b.city){
		return a.city<b.city;
	}

		return a.p>b.p;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>re[i].city>>re[i].p;
		re[i].num=i+1;
	}	
	sort(re,re+n,com);
	for(int i=0;i<n;i++){
		cout<<re[i].num<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
import math
x, y = 0, 0
angle = math.pi / 2
while True:
  d, a = map(int, input().split(","))
  if (d, a) == (0, 0):
    break
  x += math.cos(angle) * d
  y += math.sin(angle) * d
  angle -= a * math.pi / 180
print(int(x), int(y), sep="\n")


Measured memory_bytes: 5720
def main():
    q=int(input())
    aa=0
    bb=0
    a=[]
    b=[]
    ac=[]
    bc=[]
    for _ in range(q):
        aa,bb=map(int,input().split())
        a.append(aa)
        b.append(bb)
        # ac.append(aa)
        # bc.append(bb)

    # sorted(a)
    # sorted(b)
    bm=max(b)
    ans=[0]*100001
    flg=[0]*100001
    flg[0]=1
    flg[1]=1
    ans[2]=1
    ii=int((bm+1)**0.5)
    for i in range(2,100001):

        if flg[i]==0:
            flg[i]=1
            ans[i]=1
            for j in range(i,100001,i):
                flg[j]=1
    ans2=[]
    cnt=0
    for i in range(0,100001):
        if ans[i]==1 and ans[(i+1)//2]==1:
            cnt+=1
        ans2.append(cnt)
    # print(ans[:11])
    # print(ans2[:11])
    for i in range(0,q):
        print(ans2[b[i]]-ans2[a[i]-1])
    # print(ans[:8])
if __name__=='__main__':
    main()


Measured memory_bytes: 14140
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import deque

n = int(readline())
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, readline().split())
    graph[a].append((b, i))
    graph[b].append((a, i))
color = [-1] * (n + 1)
color[1] = -2
ans = [0] * (n - 1)

def bfs(s):
    stack = deque([s])
    while stack:
        num = 1
        now = stack.pop()
        for next, idx in graph[now]:
            if color[next] != -1:
                continue
            if color[now] == num:
                num += 1
            color[next] = num
            ans[idx] = num
            num += 1
            stack.append(next)


bfs(1)
print(max(ans))
print('\n'.join(map(str, ans)))


Measured memory_bytes: 45704
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int a = in.nextInt();
        int b = in.nextInt();

        System.out.println(a*b);

        }









    }





Measured memory_bytes: 36152
#include <stdio.h>
int ABC42(void);

int main(void){
    ABC42();
    return 0;
}

int ABC42(void){
    int a,b,c,n=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==7||b==7||c==7){
        if((a==5&&b==5)||(b==5&&c==5)||(c==5&&a==5)){
            printf("YES");
            n++;
    }}
    if(n==0)printf("NO");
    return 0;
}

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

using namespace std;

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

  int first = -1;
  int second = -1;

  vector<int> list(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &list[i]);

    int a = list[i];
    if (a >= first) {
      second = first;
      first = a;
    } else if (a > second) {
      second = a;
    }
  }

  for (int i = 0; i < n; i++) {
    int a = list[i];
    if (a == first) {
      cout << second << endl;
    } else {
      cout << first << endl;
    }
  }
}


Measured memory_bytes: 2432
#include <iostream>
using namespace std;
#define ll long long int

int main() {
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans=(n/x)*t;
    if(n%x!=0)
    {
        ans=ans+t;
    }
    cout<<ans<<"\n";
    return 0;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

int c[10][10];

void chmin(int &a, int b) {
  if (a > b) a = b;
}

void MAIN() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i <= 9; i++)
  for (int j = 0; j <= 9; j++) {
    cin >> c[i][j];
  }
  for (int k = 0; k <= 9; k++)
  for (int i = 0; i <= 9; i++)
  for (int j = 0; j <= 9; j++) {
    chmin(c[i][j], c[i][k] + c[k][j]);
  }
  int ans = 0;
  for (int i = 1; i <= h; i++)
  for (int j = 1; j <= w; j++) {
    int t; cin >> t;
    if (t != -1) ans += c[t][1];
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int h=n/3600;
    int m=(n-h*3600)/60;
    int s=n-h*3600-m*60;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
    for(int i=1;i<=3;i++)
        cin>>a[i];
    sort(a+1,a+4);
    int n = unique(a+1,a+4) - a-1;
    cout<<n<<endl;
}

Measured memory_bytes: 256
# 重複組み合わせの全列挙

import itertools

# n+m-1個からn個を選ぶ組み合わせ
n, m, q = map(int, input().split())
seq = list(range(n+m-1))
p = list(itertools.combinations(seq, n))

a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

res = 0
for i in p:
    t = [0] * n
    pp = sorted(i)
    idx = 0
    for e in pp:
        t[idx] = 1 + e - idx
        idx += 1
    
    tmp = 0
    for j in range(q):
        if t[b[j]-1] - t[a[j]-1] == c[j]:
            tmp += d[j]
    
    res = max(res, tmp)

print(res)

Measured memory_bytes: 85008
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
//#define bint int1024_t
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define F first
#define pll pair<ll,ll>
#define S second
#define pi 3.1415926536
#define mod int(1e9+7)
//ios_base::sync_with_stdio(false);cin.tie(NULL);
#define testcases ll t; cin>>t; while(t--)

using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

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

    ll a,b,c,k,s=0;
    cin>>a>>b>>c>>k;

    s+=min(a,k);
    k-=min(a,k);
    k-=min(k,b);
    s-=min(k,c);
    cout<<s;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
/*
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
 
using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")
 
 
 
#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------
 
int n,k;
 
int fac[5000];
int expo(int x,int y)
{
	int res=1;
	while(y>0)
	{
		if (y&1)res=(res*x)%MOD;
		x = (x*x)%MOD;y/=2;
	}
	return res;
}
int Inv(int r)
{
	return expo(r,MOD-2);
}
int ncr(int n,int r)
{
	if (r>n || n<0||r<0)return 0;
	if (r==0||r==n)return 1;
	if (r==1||r==n-1)return n;
	return (((fac[n]*Inv(fac[n-r]))%MOD)*Inv(fac[r]))%MOD;
}
void solve()
{
 
 
	fac[0]=1;
	rep(i,1,5000)fac[i]=(fac[i-1]*i)%MOD;
	
 
    cin>>n>>k;
    if (n==k)
    {
    	cout<<"1\n";
    	rep(i,0,k-1)cout<<0<<"\n";return;
    }
    
    rep(i,1,k+1)
    {
    	cout<<(ncr(n-k+1,i)*ncr(k-1,i-1))%MOD<<"\n";
    }
}
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
 
    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 
    int t=1;
    //cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 256
N, K = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(N)]
ans = 10**20
xy.sort()
for l in range(N-K+1):
    for r in range(l+K, N+1):
        y = sorted(xy[l:r], key = lambda v: v[1])
        for i in range(r-l-K+1):
            sq = (xy[r-1][0] - xy[l][0]) * (y[i+K-1][1] - y[i][1])
            ans = min(ans, sq)
print(ans)


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

int main()
{
  int n,w,v,maxh,maxn,h[100];
  double ans;
  while(1){
    cin>>n>>w;
    if(n==0 && w==0)break;
    maxh=0;maxn=0;ans=0.0;
    for(int i=0;i<100;i++)h[i]=0;
    for(int i=0;i<n;i++){
      cin>>v;
      h[v/w]++;
      maxh=max(maxh,h[v/w]);
      maxn=max(maxn,v/w);
    }
    for(int i=0;i<maxn;i++){
      ans+=((double)h[i]/maxh)*((double)(maxn-i)/maxn);
    }
    printf("%.8f\n",ans+0.01);
  }
  return 0;
}

Measured memory_bytes: 1188
N = int(input())
# 200以下で正の約数をちょうど8個持つ数
have_8divisors = [105, 135, 165, 189, 195]
# リストの何番にNを挿入できるか。そのインデックスが解
for k, v in enumerate(have_8divisors):
    if N < v:
        ans = k
        break
else:
    ans = len(have_8divisors)
print(ans)

Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int tmp =1;
    int answer = 0;
    while(tmp<B){
      tmp=tmp+A-1;
      answer=answer+1;
    }
    System.out.print(answer);
  }
}

Measured memory_bytes: 23124
//
// [proof]
// when p(n) != 2 && p(n) != 5 , that is n != 0 && n != 2 , Fermat's little theorem
//   10^{p(n)-1} # 1 (mod p(n)) (# represents congruence relation)
//   10^{p(n)-1} - 1 = 999...9 (p(n)-1 digits) # 0 (mod p(n))
// In this time, we assume 111...1 # c (mod (p(n))) (c != 0), and then
//   999...9 # c*9 # 0 (mod p(n))
// This means c is multiple of p(n), or p(n) = 3 (n = 1) because p(n) is prime number.
// (i) when c is multiple of p(n), c # 0 (mod p(n)). So,
//   111...1 # 0 (mod p(n))  (n != 0 && n != 2)
// (ii) when n = 1, 111...1 # 2 (mod p(1)).
//
// when n == 0 || n == 2, the answer is 1.
//

#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    if(n == 0 || n == 2) {
        cout << 1 << endl;
    } else if(n == 1) {
        cout << 2 << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3096
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = lin()
	aal=[i-v for i,v in enumerate(al)]
	ccl = collections.Counter(aal)
	ret = 0
	
	for i, v in enumerate(al):
		ccl[i-v] -= 1
		if i+v in ccl:
			ret += ccl[i+v]
		
	print(ret)
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 136092
#include <iostream>
#include <string>

int main(){
    int n;
    std::string str;
    std::string fr = "Hoshino";
    std::string to = "Hoshina";
    std::string::size_type pos;
    std::cin >> n;
    std::cin.get();
    
  
        //文字列の読み込み
    while(n > 0 && std::getline(std::cin, str)){
        //"Hoshino"を"Hoshina"に変換
        pos = str.find(fr);
        while(pos != std::string::npos){
            str.replace(pos, fr.size(), to);
            pos = str.find(fr, pos+to.size());
        }
        //表示
        std::cout << str << std::endl;
        str = "";
        std::cin.clear();
        --n;
    }
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
struct tp{string ct;int sc,ord;};

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<tp>v(n);
	for(int i=0;i<n;++i){
		cin>>v.at(i).ct>>v.at(i).sc;
		v.at(i).ord=i+1;
	}
	auto pred=[](auto&&x,auto&&y){
		if(x.ct==y.ct)return x.sc>y.sc;
		return x.ct<y.ct;
	};
	sort(v.begin(),v.end(),pred);
	for(auto&&i:v)cout<<i.ord<<"\n"s;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    # n = int(input())
    a, b = map(int, input().split())
    # l = [list(map(int, input().split())) for _ in range(n)]
    print(a * b)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 5"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100 100"""
        output = """10000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16208
N = int(input())
A = [int(i) for i in input().split()]
count = 1
data = [0 for i in range(len(A))]

for i in A:
  if i == 0:
    count *= 3-data[i]
  else:
    count *= data[i-1]-data[i]
  data[i]+=1
  count%=1000000007
print(count%1000000007)

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

int main() {
  int n;
  cin >> n;
  set<int> below_3200;
  int over_or_eqaul_to_3200 = 0;
  for (int i = 0; i < n; ++i) {
    int rate;
    cin >> rate;
    if (rate >= 3200)
      over_or_eqaul_to_3200++;
    else
      below_3200.insert(rate / 400);
  }
  const int ans_min = max(1, (int)below_3200.size());
  const int ans_max = over_or_eqaul_to_3200 + (int)below_3200.size();
  cout << ans_min << " " << ans_max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int achaCustoMinimo(int qtdPedras, int alturaDasPedras[], int *custos, int limiteDoSalto, int pedra){
    int menorCusto = -1;

    for (int i = 1; i <= limiteDoSalto; i++)
    {
        if (pedra + i < qtdPedras) {
            int custo = abs(alturaDasPedras[pedra] - alturaDasPedras[pedra+i]) + custos[pedra+i];
            // cout << alturaDasPedras[pedra] << " -> " << alturaDasPedras[pedra+i]<< " CUSTO: " << custo << endl;  
            if (menorCusto > custo || menorCusto == -1){
                menorCusto = custo;
            }
        }
    }
    custos[pedra] = menorCusto;
    // cout << "PEDRA: " << alturaDasPedras[pedra] << " CUSTO TOTAL: " << custos[pedra] << endl;  

    if(pedra > 0){
        achaCustoMinimo(qtdPedras, alturaDasPedras, custos, limiteDoSalto, pedra-1);
    }

}

int main() {

	int qtdPedras, limiteDoSalto, custoMinimo = 0;
    cin >> qtdPedras >> limiteDoSalto;
    int alturaDasPedras[qtdPedras], custos[qtdPedras];

    for (int i = 0; i < qtdPedras; i++){
        cin >> alturaDasPedras[i];
        custos[i] = 0;
    }
    
    achaCustoMinimo(qtdPedras, alturaDasPedras, custos, limiteDoSalto, qtdPedras-2);
    cout  << custos[0] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
       ios::sync_with_stdio(false);
       int a, b, c, d, e, ans=1;
       for (int i=1; i<=5; i++)
       {
             int temp;
             cin >> temp;
             if (temp==0)ans=i;
       }cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	
	public static char[][] code = 
		{
			{'a' , 'f' , 'k' , 'p' , 'u' , 'z'},
			{'b' , 'g' , 'l' , 'q' , 'v' , '.'},
			{'c' , 'h' , 'm' , 'r' , 'w' , '?'},
			{'d' , 'i' , 'n' , 's' , 'x' , '!'},
			{'e' , 'j' , 'o' , 't' , 'y' , ' '}
		};
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			
			String  str = sc.nextLine();
			
			if(str.length() % 2 == 1){
				System.out.println("NA");
				continue;
			}
			
			char[] array = new char[str.length()/2];
			
			try{
				boolean ok = true;
				
				for (int i = 0; i < str.length() / 2; i++) {
					int first = Integer.parseInt(str.charAt(2*i) + "");
					int second = Integer.parseInt(str.charAt(2*i + 1) + "");
					
					if(0 < first && first < 7 && 0 < second && second < 6){
						array[i] = code[second-1][first-1];
					}else{
						System.out.println("NA");
						ok = false;
						break;
					}
				}
				
				if(ok){
					System.out.println(String.valueOf(array));
				}
			}catch(NumberFormatException e){
				System.out.println("NA");
			}
			
		}
		
	}
	
}

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

typedef long long ll;

int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll a,b,c,k;
    while(cin >> a >> b >> c >> k)
        cout << (k%2==0? a-b : b-a) << '\n';
    return 0;
}

Measured memory_bytes: 256
n = int(input())
m = list(map(int, input().split()))
ans = 1
if min(m) == 0:
    print(0)
else:
    m.sort(reverse=True)
    for i in m:
        ans *= i
        if ans > 1000000000000000000:
            ans = -1
            break
    print(ans) 

Measured memory_bytes: 21788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
	int n;
	cin>>n;
	vector<pair<ll,pair<ll,ll>>>p;
	ll sum=0;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		p.eb(a+b,make_pair(a,b));
	}
	sort(p.rbegin(),p.rend());
	rep(i,n){
		if(i%2==0)sum+=p[i].second.first;
		else sum-=p[i].second.second;
	}
	cout<<sum<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 4980
#include <iostream> 

using namespace std;

int main()
{
	int n ; cin >> n ;
    if ( n % 10 == 3 ) cout << "bon\n" ;
    else if ( n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8 ) cout << "pon\n" ;
    else cout << "hon\n" ;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long
#define MOD ((int)1e9 + 7)

using namespace std;

vector<vector<int>> arr;
vector<vector<int>> vis;

void dfs(int i, int j, int &ans, int curr)
{

    queue<pair<pair<int, int>, int>> q;
    q.push({{i, j}, 0});

    while (!q.empty())
    {
        auto p = q.front();
        q.pop();
        i = p.first.first;
        j = p.first.second;
        curr = p.second;

        if (i < 0 or i >= arr.size() or j < 0 or j > arr[0].size() or arr[i][j] == 0)
            continue;
        if (vis[i][j] == 1)
            continue;

        vis[i][j] = 1;

        q.push({{i - 1, j}, curr + 1});
        q.push({{i, j - 1}, curr + 1});
        q.push({{i + 1, j}, curr + 1});
        q.push({{i, j + 1}, curr + 1});

        ans = max(ans, curr);
    }
}

int main()
{
    int n, m;
    cin >> n >> m;

    arr.assign(n, vector<int>(m));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            char a;
            cin >> a;

            if (a == '.')
                arr[i][j] = 1;
        }
    }

    int out = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            int ans = 0;
            vis.assign(n, vector<int>(m, 0));
            dfs(i, j, ans, 0);
            out = max(out, ans);
        }
    }

    cout << out << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  int n;
  int i;
  double a,average;
   while(1){

  cin >> n;
  a = 0;
  average = 0;

  if(n == 0){
    break;
  }

  int score[n];

  for(i = 0;i < n;i++){
    cin >> score[i];
    average += score[i];
  }
  average /= n;

  //?????£?????¨??????
  for(i = 0;i < n;i++){
    a += pow(score[i] - average,2);
  }
  a /= n;

  //?¨??????????
  a = sqrt(a);

  cout << fixed << a << endl;
}
return 0;

}

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

int main() {
	int N;
	cin >> N;
	int digit = 1;
	while (digit <= N) digit *= 10;
	digit /= 10;
	int M = N / digit * digit;
	int ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			int num_ij = 0;
			int num_ji = 0;
			if (digit * i < M) num_ij += (digit - 1) / 9;
			else {
				if (digit * i == M) {
					num_ij += (N - digit * i) / 10;
					if (N % 10 >= j) num_ij++;
				}
				num_ij += (digit / 10 - 1) / 9;
			}
			
			if (digit * j < M) num_ji += (digit - 1) / 9;
			else {
				if (digit * j == M) {
					num_ji += (N - digit * j) / 10;
					if (N % 10 >= i) num_ji++;
				}
				num_ji += (digit / 10 - 1) / 9;
			}
			if (i == j && i < N) {
				num_ij++;
				num_ji++;
			}
			ans += num_ij * num_ji;
		}
	}
	cout << ans << endl;
}


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

int main()
{
  static char s[1000001];
  scanf("%s", s);
  int ans = 0;
  for (const char *p = s; *p != 0;) {
    static const char joi[] = "JOI";
    int cs[3];
    for (int i = 0; i < 3; i++) {
      cs[i] = 0;
      while (*p != 0 && *p == joi[i]) {
        ++cs[i];
        ++p;
      }
    }
    if (cs[0] >= cs[1] && cs[2] >= cs[1]) {
      ans = max(ans, cs[1]);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int i, len, Char[26], temp;
bool cond;
string s;
int main()
{
    cin >> s;
    cond = true;
    len = s.size();
    for(i=0;i<len;i++)
    {
        temp = s[i]-'a';
        Char[temp]++;
    }
    for(i=0;i<26;i++)
    {
        len = Char[i];
        if(len%2)
            {
                cond = false;
                break;
            }
    }
    if(cond)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    char c;
    cin >> c;
    string s = "aeiou";
    if (s.find(c) != string::npos) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int n,a,i,per=0,cnt=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a);
    if(a%4==0){
      per++;
    }
    if(a%2==0 && a%4!=0){
      cnt++;
    }
  }
  if(per>=n/2 || cnt==n || cnt>=n-per*2){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
using P = pair<int, int>;
int main() {
    const int INF = 1e8;
    int N, M;
    cin >> N >> M;
    // i -> (j, A)
    vector<set<P>> s(N);
    // (i, A) -> j
    vector2d<int> v(N, vector<int>(M));

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            int a;
            cin >> a;
            a--;
            s[i].insert({j, a});
            v[i][a] = j;
        }
    }
    int ans = INF;
    // (j, i, A)
    for(int m = 0; m < M; m++) {
        // 
        vector<int> cnt(M, 0);
        for(int n = 0; n < N; n++) {
            cnt[s[n].begin()->second]++;
        }
        int a = 0;
        for(int b = 0; b < M; b++) {
            if(cnt[a] < cnt[b]) a = b;
        }
        ans = min(ans, cnt[a]);
        for(int i = 0; i < N; i++) {
            s[i].erase({v[i][a], a});
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
const int mx = 200005;
int n;
long long a, b, t = 1e9+7;
bool ok = true;
pair<long long , long long> pr[mx];
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%lld%lld", &a, &b);
        pr[i] = make_pair(b, a);
    }
    sort(pr, pr+n, greater<pair<long long, long long>>());
    for(int i = 0; i < n; i++){
        t = min(pr[i].first, t) - pr[i].second;
        if(t < 0){
            ok = false;
            break;
        }
    }
    puts(ok ? "Yes" : "No");
}

Measured memory_bytes: 3328
#include<cstdio>
#include<algorithm>
using namespace std;
int a[3];
int main()
{
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	if(a[0]==a[1]&&a[1]==a[2]) printf("Yes");else printf("No");
	return 0;
}

Measured memory_bytes: 128
function main(input) {
   input = input.trim();
  const a = input.split(" ").map(Number);
 console.log(Math.max(a[0]+a[1]+0,Math.max(a[0]-a[1]+0,a[0]*a[1]+0)));

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

 
int main()
{ int n,k;
long int minn;
cin>>n>>k;
int dp[n],h[n];
dp[0]=0;
  for( int i=0;i<n;i++)
    { cin>>h[i];}
    for(int i=1;i<n;i++)
    { minn= 2147483647;
    for( int j=1; j<=k ; j++)
    {  if(i-j>=0) {
       if(dp[i-j]+abs(h[i]-h[i-j])<minn)
          minn= dp[i-j]+abs(h[i]-h[i-j]); }
       else break; }
       dp[i] = minn ;}
       cout<<dp[n-1];
      return 0; }

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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

int n, m, q;
vi a;
vector<pair<ii, ii>> l;
int ans = 0;
void solve(int pos, int mn) {
	if (pos == n) {
		int c = 0;
		for (int i = 0; i < q; i++) {
			if (a[l[i].first.second]-a[l[i].first.first] == l[i].second.first) {
				c += l[i].second.second;
			}
		}
		ans = max(ans, c);
		return;
	}
	
	for (int i = mn; i <= m; i++) {
		a[pos] = i;
		solve(pos+1, i);
	}
}

int32_t main() {
	FAST_IO;
	
//	freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);

	
	cin >> n >> m >> q;
	
	for (int i = 0; i < q; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		--a; --b;
		l.push_back({{a, b}, {c, d}});
	}
	
	a.resize(n, 1);
	
	
	solve(0, 1);
	
	cout << ans << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 3664
from fractions import Fraction

n, k = map(int, input().split())

def toss(j, k):
    cnt = 0
    while j <= k-1:
        j *= 2
        cnt +=1
    return cnt

ans = 0
for i in range(1, n+1):#サイコロの目ごとに場合分け
    ans += Fraction(1, 2**toss(i,k))
    
ans = Fraction(ans, n)
print(float(ans))

Measured memory_bytes: 74212
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/

long long n;

int main(){
    cin>>n;
    long long ans=n-1;
    for(long long i=1;i*i<=n;i++){
        if(n%i)continue;
        ans=min(ans,i+n/i-2);
    }
    cout<<ans;
    return 0;
}


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

int main()
{
    int c,i,j,flag;

    flag = 0;

    scanf("%d",&c);

    for(i = 1;i < 10;i++)
        for(j = 1;j < 10;j++)
            if(i * j == c)
            {
                flag = 1;
                break;
            }

    printf("%s",flag == 1?"Yes":"No");

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
 
typedef struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
} Node;
 
typedef Node *NodePointer;
NodePointer root = NULL;
 
NodePointer createNode(){
  NodePointer z = malloc(sizeof(Node));
  z->l = NULL;
  z->r = NULL;
  z->p = NULL;
  z->key = 0;
  return z;
}
 
void insert(int key){
   
  NodePointer z = createNode();
  NodePointer y = NULL;
  NodePointer x = root;
  z->key = key;
   
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  z->p = y;
  if(y == NULL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}
   
void inorder(NodePointer p){
     
  if(p != NULL){
    inorder(p->l);
    printf(" %d",p->key);
    inorder(p->r);
  }
}
 
void preorder(NodePointer p){
  if(p != NULL){
    printf(" %d",p->key);
    preorder(p->l);
    preorder(p->r);
  }
}

NodePointer minimum(NodePointer p){
  while(p->l != NULL){
    p = p->l;
  }
  return p;
}

NodePointer successor(NodePointer p){

  NodePointer x;

  if(p->r != NULL) return minimum(p->r);
  x = p->p;
  while(x != NULL && p == x->r){
    p = x;
    x = x->p;
  }
  return x;
}

void Delete(NodePointer p){

  NodePointer x;
  NodePointer y;

  if(p->l == NULL || p->r == NULL)
    x = p;
  else
    x = successor(p);
  if(x->l != NULL)
    y = x->l;
  else
    y = x->r;
  if(y != NULL)
    y->p = x->p;
  if(x->p == NULL)
    root = y;
  else if(x == x->p->l)
    x->p->l = y;
  else
    x->p->r = y;
  if(y != p)
    p->key = x->key;
}


NodePointer find(NodePointer p, int key){

  if(p == NULL) return p;
  else if(p->key == key) return p;
  if(key < p->key)  return find(p->l,key);
  else  return find(p->r,key);
}
 
int main(void){
 
  int i,key,n;
  char str[20];
  NodePointer x;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s",str);
 
    if(str[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(str[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(str[0] == 'f'){
      scanf("%d",&key);
	x = find(root,key);
	if(x != NULL) printf("yes\n");
	else printf("no\n");
    }
    else{
      scanf("%d",&key);
      Delete(find(root,key));

    }
  }
  return 0;
}

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

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    vector<ll> x(N);
    vector<ll> y(N);
    vector<vector<ll>> dx(N, vector<ll>(N));
    vector<vector<ll>> dy(N, vector<ll>(N));

    for (int i = 0; i < N; i++) {
        ll tempX, tempY;
        cin >> tempX >> tempY;
        x[i] = tempX;
        y[i] = tempY;
    }

    if ( N == 1 ) {
        cout << "1\n";
        return 0;
    }

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            dx[i][j] = x[j] - x[i];
            dy[i][j] = y[j] - y[i];
        }
    }

    int ans = 100;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int temp = N;
            for (int k = 0; k < N; k++) {
                for (int l = k + 1; l < N; l++) {
                    if ( (dx[i][j] == dx[k][l] && dy[i][j] == dy[k][l]) || (dx[i][j] == -dx[k][l] && dy[i][j] == -dy[k][l]) ) {
                        temp--;
                    }
                }
            }
            ans = min(ans, temp);
        }
    }

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

Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	h, n := nextInt(), nextInt()
	a := 0

	for i := 0; i < n; i++ {
		a += nextInt()
	}

	if h > a {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

int main(void){
    int N;
    cin >> N;
    string S[N];
    rep(i,N) cin >> S[i];
    lint cnt[5]={};
    rep(i,N){
        if(S[i][0]=='M') cnt[0]++;
        if(S[i][0]=='A') cnt[1]++;
        if(S[i][0]=='R') cnt[2]++;
        if(S[i][0]=='C') cnt[3]++;
        if(S[i][0]=='H') cnt[4]++;
    }
    lint ans=0;
    for(int i=0;i<5;i++) for(int j=i+1;j<5;j++) for(int k=j+1;k<5;k++){
        ans+=cnt[i]*cnt[j]*cnt[k];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > 2*b) {
		cout << a - 2 * b << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int A, B;
  cin >> A >> B;
  A += B;
  if(A>=24) A -= 24;
  cout << A << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] val = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int ans = val[1] / val[0];
            if (val[1] % val[0] != 0)
                ans++;

            Console.WriteLine(ans);
        }
    }
}


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

int main() {
    //
    string a, b;
    int Max = 0;

    cin >> a >> b;

    for (int i = 0; i <= a.size() - b.size(); i++) {
        int cnt = 0;
        for (int j = 0; j < b.size(); j++) {
            if (a.at(i + j) == b.at(j)) cnt++;
        }
        Max = max(Max, cnt);
    }
    cout << b.size() - Max;
    //
}

Measured memory_bytes: 3624
def expect(n):
    return (int(n)+1)/2
N, K = map(int,input().split()) 
P = list(map(expect,input().split()))
sumlist = [sum(P[0:K])]
sumnumber = sum(P[0:K])
for i in range(N-K):
    sumnumber -=P[i]
    sumnumber +=P[i+K]
    sumlist.append(sumnumber)
print(max(sumlist))

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

int main() {
  ll X;
  cin >> X;

  ll ans = (X/500) * 1000;
  ll re = X%500;
  ans += (re/5) * 5;

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


Measured memory_bytes: 256