akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define drep(i,n) for (int i = (n)-1; i >= 0; i--)
#define pb push_back
using namespace std;

// d: a+b+c
// dp[a][b][c] = (n-d)/n*dp[a][b][c] + a/n*... + b/n*... + c/n*... + 1
// d/n*dp[a][b][c] = ...
// dp[a][b][c] = a/d*... + b/d*... + c/d*...

double dp[310][310][310];
int n;
bool used[310][310][310];

double f(int a, int b, int c) {
  if (a < 0 || b < 0 || c < 0) return 0.0;
  if (used[a][b][c]) return dp[a][b][c];
  int d = a+b+c;
  double sm = double(a) / d * f(a-1,b,c) + double(b) / d * f(a+1,b-1,c) + double(c) / d * f(a,b+1,c-1) + double(n) / d;
  used[a][b][c] = true;
  return dp[a][b][c] = sm;
}

int main() {
  cin>>n;
  int c[4] = {0,0,0,0};
  rep(i,n) {
    int x;
    cin>>x;
    c[x]++;
  }
  used[0][0][0] = true;
  dp[0][0][0] = 0.0;
  cout<<fixed<<setprecision(20)<<f(c[1],c[2],c[3])<<endl;
  return 0;
}

Measured memory_bytes: 256256
#include<iostream>
using namespace std;
int main() {
    long int N, M, L, R;
    cin >> N >> M;
    long int small = 1, large = N, ans = 0;
    for(int i = 0; i < M; i++) {
        cin >> L >> R;
        if(small < L){
            small = L;
        } 
        if(R < large){
             large = R;
        }
        if(small <= large) {
            ans = large - small + 1;
        } else {
            ans = 0;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char s[101];
	char dance[2][3]={{'R','U','D'},{'L','U','D'}};
	int i=0,j,k=0;
	gets(s);
	while(s[i]!='\0' ){
		k=0;
		for(j=0;j<3;j++)
			if(dance[i%2][j]==s[i]){
				k=1;
				break;
			}
		if(!k)
			break;
		i++;
	}
	if(s[i]=='\0')
		printf("Yes");
	else
		printf("No");
	return 0;
} 

Measured memory_bytes: 128
def main():
    n = int(input())
    V = [int(v) for v in input().split()]
    even = dict()
    odd = dict()
    for i in range(n//2):
        even[V[2*i]] = even.get(V[2*i], 0) + 1
        odd[V[2*i+1]] = odd.get(V[2*i+1], 0) + 1
    max_count_even = max(even.values())
    max_count_odd = max(odd.values())
    max_v_even = [v for v in even if even[v] == max_count_even]
    max_v_odd = [v for v in odd if odd[v] == max_count_odd]

    if len(max_v_even) == len(max_v_odd) == 1 and max_v_even[0] == max_v_odd[0]:
        del even[max_v_even[0]]
        del odd[max_v_odd[0]]
        if even:
            max_count_even_nxt = max(even.values())
        else:
            max_count_even_nxt = 0
        if odd:
            max_count_odd_nxt = max(odd.values())
        else:
            max_count_odd_nxt = 0
        return min(n-max_count_even-max_count_odd_nxt, n-max_count_odd-max_count_even_nxt)
    else:
        return n - max_count_even - max_count_odd


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 17632
#!/usr/bin/env python3
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

ans = 0
for i in s:
    sc = s.count(i)
    tc = t.count(i)
    cnt = sc - tc
    if cnt > ans:
        ans = cnt

print(ans)

Measured memory_bytes: 8996
import java.util.Scanner;

public class Main{
    public static void main(String[]agrs){
        int a,b;
        String op;
        char op2;

        Scanner sc = new Scanner(System.in);

        while(true){
            a = sc.nextInt();
            op = sc.next();
            b = sc.nextInt();
            op2 = op.charAt(0);
            if(op2 == '?') break;
        
            if(op2 == '+'){
                System.out.println(a+b);
            }else if(op2 == '-'){
                System.out.println(a-b);
            }else if(op2 == '*'){
                System.out.println(a*b);
            }else if(op2 == '/'){
                System.out.println(a/b);
            }
        }
    }    
}


Measured memory_bytes: 26120
def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    T = []
    for a in A:
        for b in B:
            T.append(a + b)

    T = sorted(T, reverse=True)[:min(K, len(T))]

    res = []
    for t in T:
        for c in C:
            res.append(t + c)

    res = sorted(res, reverse=True)[:K]
    for r in res:
        print(r)

if __name__ == "__main__":
    main()

Measured memory_bytes: 186332
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){

	int a,b,c;
	char s1,s2;

	//scanf("%d,%d",&s1,&s2);

	a = 1;
	b = 0;
	c = 0;

	while(scanf("%c,%c",&s1,&s2) != EOF){

		//if(s1 == 'z' && s2 == 'z') break;

		if((s1 == 'A' && s2 == 'B' && a == 1 && b == 0) ||
		 (s1 == 'B' && s2 == 'A' && a == 1 && b == 0)){
			b = 1;
			a = 0;
		}else if((s1 == 'A' && s2 == 'C' && a == 1 && c == 0) ||
				(s1 == 'C' && s2 == 'A' && a == 1 && b == 0)){
			a = 0;
			c = 1;
		}else if((s1 == 'B' && s2 == 'C' && b == 1 && c == 0) ||
				(s1 == 'C' && s2 == 'B' && b == 1 && c == 0)){
			b = 0;
			c = 1;
		}else if((s1 == 'B' && s2 == 'C' && b == 0 && c == 1) ||
				(s1 == 'C' && s2 == 'B' && b == 0 && c == 1)){
			b = 1;
			c = 0;
		}else if((s1 == 'A' && s2 == 'B' && a == 0 && b == 1) ||
		 (s1 == 'B' && s2 == 'A' && a == 0 && b == 1)){
			a = 1;
			b = 0;
		}
	}

	if(a == 1){
		cout << 'A' << endl;
	}else if(b == 1){
		cout << 'B' << endl;
	}else if(c == 1){
		cout << 'C' << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int N;
int T,A;
int H[1100];
int main(){
  scanf("%d",&N);
  scanf("%d%d",&T,&A);
  int ans=0;
  double dif=1e9;
  repeat(i,N){
    scanf("%d",&H[i]);
    if(dif>abs(A-((double)T-0.006*H[i]))){
      dif=abs(A-((double)T-0.006*H[i]));
      ans=i+1;
    }
    //debug(dif);
  }
  printf("%d",ans);
  return 0;
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;


ll N, M, T, P;
ll field[1010][1010];
int main() {
	while (cin >> N >> M >> T >> P && N > 0) {
		REP(i,0,1010){
			REP(j,0,1010){
				field[i][j] = 0;
			}
		}
		REP(i,0,M){
			REP(j,0,N){
				field[i][j] = 1;
			}
		}
		ll nx = 0;
		ll ny = 0;
		REP(i, 0, T){
			ll d, c;
			cin >> d >> c;
			if(d == 1){
				REP(x,nx,nx+c){
					REP(y,ny,1000){
						field[y][nx+c+(nx+c-x-1)] += field[y][x];
						field[y][x] = 0;
					}
				}
				nx = nx+c;
			}else{
				REP(y,ny,ny+c){
					REP(x,nx,1000){
						field[ny+c+(ny+c-y-1)][x] += field[y][x];
						field[y][x] = 0;
					}
				}
				ny = ny+c;
			}
		}
		REP(i,0,P){
			ll x, y;
			cin >> x >> y;
			p(field[ny+y][nx+x]);
		}
	}

	return 0;
}


Measured memory_bytes: 11048
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, = gi()
ans = n // 10
cur = 50
while cur <= n:
	ans += n // cur
	cur *= 5
if n % 2:
	ans = 0
print(ans)

Measured memory_bytes: 3060
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    X,N = LMIIS()
    P = LMIIS()

    d = 0
    while True:
        if P.count(X-d) == 0:
            print(X-d)
            return
        elif P.count(X+d) == 0:
            print(X+d)
            return
        d += 1
        


    
main()

Measured memory_bytes: 65460
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

struct edge { ll to, cost; };
vector<edge>v[200010];

int main() {
	ll n, m, x[200010], y[200010], c[200010],ma = INF3, hyp = -1, mi = 1;
	P d[200010];
	bool visited[200010] = { 0 };
	cin >> n >> m;
	queue<PP>q;
	for (int i = 0;i < m;i++) {
		cin >> x[i] >> y[i] >> c[i];
		v[x[i]].pb(edge{ y[i],c[i] });
		v[y[i]].pb(edge{ x[i],c[i] });
	}
	q.push(PP(1, P(0, 1)));
	d[1] = P(0, 1);
	visited[1] = 1;
	while (!q.empty()) {
		PP pp = q.front();
		q.pop();
		int s = pp.fr, t = pp.sc.fr, r = pp.sc.sc;
		for (auto u : v[s]) {
			if (!visited[u.to]) {
				q.push(PP(u.to, P(u.cost-t, -r)));
				d[u.to] = P(u.cost-t, -r);
				visited[u.to] = 1;
				if (r == 1)ma = min(ma, u.cost - t-1);
				else mi = max(mi, -(u.cost - t)+1);
			}
			else if(r==d[u.to].sc){
				if (abs(u.cost - t - d[u.to].fr) % 2 == 1 && (u.cost - t - d[u.to].fr) / (r*2) <= 0) {
					cout << 0 << endl;
					return 0;
				}
				ll h = (u.cost - t - d[u.to].fr) / (r * 2);
				if (hyp == -1)hyp = h;
				else if (hyp != h) {
					cout << 0 << endl;
					return 0;
				}
			}
			else if (d[u.to].fr + t != u.cost) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	if (hyp != -1) {
		if (mi <= hyp&&hyp <= ma)cout << 1 << endl;
		else cout << 0 << endl;
	}
	else cout << max((ll)0, ma - mi+1) << endl;
	return 0;
}

Measured memory_bytes: 20080
/*
 *  *s.rbegin()=*(--s.end())
 *   sort(v.rbegin(),v.rend()) = negative of v[i] , sort(v.begin(),v.end())
 *   sort(v.begin()+l_index,v.begin()+r_index+1);
 * 
 *   for(auto &it:v)cin>>it; 
 *   n + n/2 + n/3 + n/4 + n/5 + ........n/n =>n*log(n)
 *   n + n/3 + n/5 + n/7 + n/11+.............=>n*log(log(n))
 *   1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 .......=>gcd( a[i] , a[i+1] , a[i+2] )=1;
 *   2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 ......=>upto 1e6 max diff a[i], a[i+1] ~ 150
 *   Every even integer greater than 2 can be expressed as the sum of two primes.[1]  : https://en.wikipedia.org/wiki/Goldbach%27s_conjecture
 *   printf("%03d\n",k);
 *   scanf("%d/%d/%d",&d,&m,&y);   
 */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
vector<int>dx={0,1,0,-1},dy={1,0,-1,0};
long long  gcd(long long  a,long long b)
{
     while (a&&b)a>b?a%=b:b%=a;
     return a+b;
}
const int N=1e5;
vi C(N+1);
vvi G(N+1),W(N+1);
vb B(N+1);
int n,u,v,w;
void dfs(int I,int clr)
{
	B[I]=true;C[I]=clr;
	for(int i=0;i<(int)G[I].size();i++)
	{
		if(!B[ G[I][i]])dfs(G[I][i],clr^W[I][i]);
	}
}
int32_t main()
{
	IOS
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		cin>>u>>v>>w;
		G[u].pb(v);
		G[v].pb(u);
		W[u].pb(w&1);
		W[v].pb(w&1);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
	cout<<C[i]<<" ";
	cout<<endl;
	
		
	
}
		


Measured memory_bytes: 14080
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    a = int(input())
    S = input()

    if a >= 3200:
        print(S)
    else:
        print("red")
    
if __name__ == "__main__":
    main()


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

int main() {
  vector<int> spot(5,0);
  for (int i = 0; i < 5; i++) {
	cin >> spot[i];
  }
  
  int check = 0;
  int maxS = 0;
  vector<int> left(5,0);
  int total = 0;

  for (int i = 0; i < 5; i++) {
	left.at(i) = spot.at(i) % 10;
	if (left.at(i) == 0) {
		left.at(i) = 0;
	} else {
		left.at(i) = 10 - left.at(i);
	}
  }

  maxS = *std::max_element(left.begin(), left.end());
  for (int i = 0; i < 5; i++) {
	if (maxS == left.at(i)) {
		check = i;
	}
  }

  
  for (int i = 0; i < 5; i++) {
	if (check == i) {
		total = total + spot.at(i);
	} else {
		total = total + spot.at(i) + left.at(i);
	}
  }

  cout << total << endl;
}

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

#define MAX 100

void work(char*, char*);

int main()
{
	char s[MAX];
	char output[MAX] = { '\0' };

	scanf("%s", s);

	work(s, output);

	printf("%s\n", output);

	return 0;
}

void work(char* s, char* output)
{
	int k = 0;
	int i=0;

	while (k < strlen(s)) {
		if (s[k] == 'B') {
			if (i != 0) {
				i--;
				output[i] = '\0';
			}
		}
		else {
			output[i] = s[k];
			i++;
		}

		k++;
	}
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (200006)
ll n, m;
vector<pi>A;
bitset<MAXN> in, vis, val;
vector<pi> v[MAXN];
int main(){
	FAST
	cin>>n>>m;
	A.resize(n);
	FOR(i,0,n-1)cin>>A[i].f>>A[i].s;
	sort(all(A));
	A.eb(1e9+1, 0);
	FOR(i,0,n) {
		val[i] = (A[i].s&1) ^ ((i ? A[i-1].s : 0)&1); // here when 2 elements are different the right one differs instead
	}
	FOR(i,0,m-1){
		ll l, r; cin>>l>>r;
		l = lbd(A, pi(l,0));
		r = ubd(A, pi(r,LLINF));
		if(l==r) continue;
		v[l].eb(r,i), v[r].eb(l,i);
	}
	bool can=1;
	function<bool(ll)> dfs=[&](ll x){
		bool ret = val[x];
		vis[x]=1;
		for(auto i:v[x]) if(!vis[i.f]) {
			bool res = dfs(i.f);
			in[i.s] = res;
			ret ^= res;
		}
		return ret;
	};
	FOR(i,0,n) if(!vis[i]) {
		can &= !dfs(i);
	}
	if(can){
		cout<<in.count()<<'\n';
		FOR(i,0,m-1) if(in[i]) cout<<i+1<<' ';
		cout<<'\n';
	}else{
		cout<<"-1\n";
	}
}


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

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

int main()
{
	int n, i;
	scanf("%d", &n);
	vector<int> a(n),b(n);
	//vector<int> cpp[11];
	r(i, n) scanf("%d", &a[i]),b[i]=a[i];

	if (prev_permutation(a.begin(),a.end()))r(i,n) printf(i < n - 1 ? "%d " : "%d\n", a[i]);
	r(i,n) printf(i < n - 1 ? "%d " : "%d\n", b[i]);
	if (next_permutation(b.begin(), b.end())) r(i,n) printf(i < n - 1 ? "%d " : "%d\n", b[i]);

	return 0;


}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
    string s;   cin >> s;
    ll n;   n = s.length();
    ll **dp = new ll *[n+1];
    for (ll i = 0; i <= n; i++) {
        dp[i] = new ll[13];
        for (ll j = 0; j < 13; j++)
            dp[i][j] = 0;
    }

    if (s[0] == '?') {
        for (ll i = 0; i < 10; i++)
            dp[1][i] = 1;
    }
    else {
        ll y = s[0] - '0';
        dp[1][y] = 1;
    }
    
    for (ll i = 1; i < n; i++) {
        if (s[i] == '?') {
            for (ll y = 0; y < 10; y++) {
                for (ll r = 0; r < 13; r++) {
                    dp[i+1][(10*r+y)%13] += dp[i][r];
                    dp[i+1][(10*r+y)%13] %= MOD;
                }
            }
        }
        else {
            ll y = s[i] - '0';
            for (ll r = 0; r < 13; r++) {
                dp[i+1][(10*r+y)%13] += dp[i][r];
                dp[i+1][(10*r+y)%13] %= MOD;
            }
        }
    }

    cout << dp[n][5] << endl;

    return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

pair<ll, ll> p[N] ;

int main() {
  ll n, k, sum = 0 ;
  scanf("%lld %lld", &n, &k) ;

  for(int i = 0 ;i<n ;i++)
    scanf("%lld %lld", &p[i].first , &p[i].second) ;

  sort(p, p+n) ;

  for(int i = 0 ;i<n ;i++){
    if(sum+p[i].second >= k){
      cout << p[i].first << endl ;
      return 0 ;
    }
    sum+=p[i].second ;
  }
	
  return 0 ;
}



Measured memory_bytes: 1792
import math
import itertools

N = int(input())

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

routes = list(itertools.permutations(lst))

def distance(a, b):
    return (((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)) ** 0.5

routes = [i for i in routes]
distancies = []
for i, r in enumerate(routes):
    for j, a in enumerate(r):
        if j >= len(r) - 1: break
        b = r[j + 1]
        ab_dist = distance(a, b)
        distancies.append(ab_dist)

print(sum(distancies) / len(routes))

Measured memory_bytes: 17208
// C++ implementation of the above approach 
#include <bits/stdc++.h> 
#define int long long
using namespace std; 
const int maxx = 200005; 
vector<int> graph[maxx]; 

// Function to perform the DFS calculating the 
// count of the elements in a connected component 
void dfs(int curr, int& cnt, int* 
			visited, vector<int>& duringdfs) 
{ 
	visited[curr] = 1; 

	// Number of nodes in this component 
	++cnt; 

	// Stores the nodes which belong 
	// to current component 
	duringdfs.push_back(curr); 
	for (auto& child : graph[curr]) { 

		// If the child is not visited 
		if (visited[child] == 0) { 
			dfs(child, cnt, visited, duringdfs); 
		} 
	} 
} 

// Function to return the desired 
// count for every node in the graph 
void MaximumVisit(int n, int k) 
{ 
	// To keep track of nodes we visit 
	int visited[maxx]; 

	// Mark every node unvisited 
	memset(visited, 0, sizeof visited); 
	int ans[maxx]; 

	// No of connected elements for each node 
	memset(ans, 0, sizeof ans); 
	vector<int> duringdfs; 
	for (int i = 1; i <= n; ++i) { 
		duringdfs.clear(); 
		int cnt = 0; 

		// If a node is not visited, perform a DFS as 
		// this node belongs to a different component 
		// which is not yet visited 
		if (visited[i] == 0) { 
			cnt = 0; 
			dfs(i, cnt, visited, duringdfs); 
		} 

		// Now store the count of all the visited 
		// nodes for any particular component. 
		for (auto& x : duringdfs) { 
			ans[x] = cnt; 
		} 
	} 
	
	// Print the result 

    int res = 0;
    for(int i=1; i<=n; i++){
        if(res < ans[i])
            res = ans[i];
    }
    cout << res ;
	return; 
} 

// Function to build the graph 
void MakeGraph(int n, int k){ 
	for(int i=1; i<=k; i++){
        int a,b;
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    } 
} 

// Driver code 
int32_t main() 
{ 
	int n,k;
    cin >> n >> k;
	
	// Build the graph 
	MakeGraph(n,k); 
	
	MaximumVisit(n,k); 
	return 0; 
} 


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (auto& e : p) cin >> e;
    for (auto& e : q) cin >> e;
    if (!lexicographical_compare(begin(p), end(p), begin(q), end(q))) swap(p, q);

    int ans = 0;
    while (lexicographical_compare(begin(p), end(p), begin(q), end(q))) {
        next_permutation(begin(p), end(p));
        ans++;
    }
    cout << ans << endl;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin >> d;
    if(d == 25)
    {
        cout << "Christmas" << endl;
    }
    else if(d == 24)
    {
        cout << "Christmas Eve" << endl;
    }
    else if(d == 23)
    {
        cout << "Christmas Eve Eve" << endl;
    }
    else if(d == 22)
    {
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,m=map(int,input().split())
a=[]
mod=1000000007
for _ in range(m):
    a.append(int(input()))
a=set(a)
ans=[1]+[0]*(n)
for i in range(1,n+1):
    if i in a:
        ans[i]=0
    else:
        ans[i]=(ans[i-1]+ans[i-2])%mod
print(ans[n])

Measured memory_bytes: 13216
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

    if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n)
{
    ll ans = 1 ;
    for(ll i = 1 ; i <= n ; ++i)
        ans *= i ;
    return ans ;
}
unsigned long long Factorial(int n)
{
    const unsigned int M = 1000000007;
    unsigned long long f = 1;
    for (int i = 1; i <= n; i++)
        f = (f*i) % M;

    return f;
}
int a[ N ], b[ N ];
int arr[ N ] , cm[ N ] ;
int n, k ;
int ans , ansL, ansR ;
bool can(int x)
{
    for(int i = 1, j = x ; j <= n ; ++j, ++i)
    {
        if(cm[ j ] - cm[i - 1] + k >= x)
        {
            ansL = i, ansR = j ;
            return true ;
        }
    }
    return false ;
}
int BS(int n)
{
    int low = 0, high = n ;
    while(low < high)
    {
        int mid = (low + high + 1) >> 1 ;
        if(can(mid))
            low = mid ;
        else
            high = mid - 1 ;
    }
    return low ;
}
int main()
{
    int c[ 3 ][ 3 ];
    FastInputOutput() ;
    for(int i = 0 ; i < 3 ; ++i)
        for(int j = 0 ; j < 3 ; ++j)
          cin >> c[ i ][ j ] ;

    if(c[0][0] - c[1][0] == c[0][1] - c[1][1] &&
       c[0][0] - c[2][0] == c[0][1] - c[2][1] &&
       c[0][0] - c[1][0] == c[0][2] - c[1][2] &&
       c[0][0] - c[2][0] == c[0][2] - c[2][2])
     cout << "Yes" <<endl;
     else
        cout << "No" << endl ;



}


Measured memory_bytes: 256
def is_good_grid(sft):
    for r in range(n):
        r_ = (r - sft) % n  # 減算に直した
        for c in range(r):
            c_ = (c - sft) % n  # 減算に直した
            if s[r][c_] != s[c][r_]:
                # kマス列シフトした後の(r,c)と(c,r)の一致を見るには、
                # (r,c)と(c,r)それぞれの列シフト前、つまり列-sftの座標を見る必要がある
                # r_を用意せず、c_だけで済むと勘違いした
                return False
    return True


n = int(input())
s = tuple(input() for _ in range(n))

# (0,0)==(1,1)==...==(n-1,n-1)
# colのオフセットだけ変化させる
# それぞれのループで、n個の状態(0,k)==(1,k+1)==...を扱う

ans = 0
for k in range(n):
    if is_good_grid(k):
        ans += n
print(ans)


Measured memory_bytes: 40816
package main
import (
  // "bufio"
  // "os"
  // "strconv"
  // "strings"
  "fmt"
  // "math"
  // "sort"
)

// 行単位で読み込む場合
// var sc = bufio.NewScanner(os.Stdin)

func main() {
  var A, B, C, X int
  fmt.Scan(&A, &B, &C, &X)

  count := 0

  for i := 0; i <= A; i++ {
    for j := 0; j <= B; j++ {
      for k := 0; k <= C; k++ {
        if 500 * i + 100 * j + 50 * k == X {
          count++
        }
      }
    }
  }

  fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    cout << (t.substr(0, s.size()) == s?"Yes":"No");
    return 0;
}

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

int main() {
  int N;
  string A, Hantei;
  Hantei= "Three";
  cin >> N;
  
   for (int i = 0; i < N; i++) {
  cin >>A;
     if(A == "Y") {
     Hantei = "Four";}
  }
  cout << Hantei << endl;
}


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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int C[N];
    int A[N][M];
    bool b;
    vector<int> prices;
    for(int i = 0; i < N; i++) {
        cin >> C[i];
        for(int j = 0; j < M; j++) {
            cin >> A[i][j]; 
        }
    }
    // ずべての本について買うか買わないかでbit全探索
    for(int bit = 0; bit < (1<<N); bit++) {
        int understand[M] = {0};
        bool b = true;
        int price = 0;
        // 理解度をあげる
        for(int i = 0; i < N; i++) {
            if(bit & (1<<i)) {
                // 買った本について
                for(int j = 0; j < M; j++) {
                    understand[j] += A[int(i)][j];
                }
                price += C[int(i)];
            }
        }
        // 目標を達成できたか
        for(int i = 0; i < M; i++) {
            if(understand[i] < X) {
                b = false;
            }
        }
        // 目標を達成していたら
        if(b) {
            prices.push_back(price);
        }
    }
    if(prices.size() == 0) {
        cout << "-1" << endl;
    } else {
        sort(prices.begin(), prices.end());
        cout << prices[0] << endl;
    }
    return 0;
}

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

int main(void){
	int A,B,C;
	int day=0;
	int now=0;

	scanf("%d %d %d",&A,&B,&C);
	

	while(1){
		now+=A;
		day++;
		if(day%7==0){
			now+=B;
		}
		if(now>=C){
			break;
		}
	}

	printf("%d\n",day);

    return 0;
}


Measured memory_bytes: 2108
# -*- coding: utf-8 -*-
"""
A Pair of Prizes
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0279

"""
import sys


def solve(K):
    if max(K) < 2:
        return 'NA'
    res = [k for k in K if k > 0]
    return len(res) + 1


def main(args):
    while True:
        N = int(input())
        if N == 0:
            break
        K = [int(k) for k in input().split()]
        ans = solve(K)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 7228
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//入力
ll n;
vector<ll>a;

int main(){
    cin >> n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    ll sum = 0;
    ll ans = 0;
    int right = 0;
    bool flag=false;
    for(int left=0;left<n;left++){
        while(right<n && ((sum+a[right])==(sum^a[right]))){
            sum += a[right];
            right++;
        }
        if(right==n){
            flag = true;
            ll j = right;
            ans += (left-j-1)*(left-j)/2;
        }
        if(flag)break;
        ans += right-left;
        sum ^= a[left];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4760
#include<stdio.h>
typedef long long LL;
const int e[40]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,
                 5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
LL IN(void)
{
  LL x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
LL BinaryModularPower(LL x,LL y,LL mod)
{LL p=x,v=1;while(y){if(y&1){v=(v*p)%mod;}p=(p*p)%mod;y>>=1;}return v;}
int Prime(LL a,LL b,LL x,LL mod)
{
  LL y=BinaryModularPower(a,b,x);
  if(y==1)return 1;
  while(x){if(y+1==mod){return 1;}y=(y*y)%mod;x--;}
  return 0;
}
int main(void)
{
  LL a=0,i=3,p=2,N=IN();
  if(N==1)return puts("0"),0;
  while(p*p<N)
  {
    int count=0;LL y=i>>1,loop=1;
    while(!(N%p)){count++,N/=p;}a+=e[count];
    if(i==3||i==5||i==7||i==11){p++;continue;}
    while(!(y&1)){y>>=1;loop++;}
    if(Prime(2,y,loop,i)&&Prime(3,y,loop,i)&&
       Prime(5,y,loop,i)&&Prime(7,y,loop,i)&&Prime(11,y,loop,i)){p++;}
    i+=2;
  }
  if(N>1){a++;}return printf("\n%lld\n",a),0;
}

Measured memory_bytes: 1580
public class Main {

  private static void solve() {
    int n = ni();
    System.out.println(n >= 30 ? "Yes" : "No");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 36788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct SegmentTree{
   private:
       int n;
       vector<ll> node;
   public:
       SegmentTree(int sz,ll init=0){
           n=1;
           while(n<sz)n*=2;
           node.resize(2*n-1,init);
       }
       void update(int k,ll x){
           k+=n-1;
           node[k]=x;
           while(k>0){
               k=(k-1)/2;
               node[k]=max(node[2*k+1],node[2*k+2]);
           }
       }
       //[a,b)でのmaxを返す
       ll get(int a,int b,int k=0,int l=0,int r=-1){
           if(r<0)r=n;
           if(r<=a||b<=l)return 0;
           if(a<=l&&r<=b)return node[k];
           ll xl=get(a,b,2*k+1,l,(l+r)/2);
           ll xr=get(a,b,2*k+2,(l+r)/2,r);
           return max(xl,xr);
       }
   };
int main(){
    int n;
    cin>>n;
    ll h[n],a[n];
    rep(i,n)cin>>h[i];
    rep(i,n)cin>>a[i];
    SegmentTree sg(n+5);
    rep(i,n){
        ll ret=sg.get(0,h[i])+a[i];
        sg.update(h[i], ret);
    }
    cout<<sg.get(0, n+1)<<endl;
    return 0;
}

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

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

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")

#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")

int main(void){
  int N;
  cin >> N;
  N=N%10;
  if(N==2||N==4||N==5||N==7||N==9) cout << "hon"<<endl;
  else if(N==0||N==1||N==6||N==8) cout << "pon"<<endl;
  else if(N==3) cout << "bon"<<endl;
  else cout << "error"<<endl;
  return 0;
}

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

int main(){
	int out = 0;
	array<int,3> a;

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

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

	while(a[1] < a[2]){
		a[0]++;
		a[1]++;
		out++;
	}

	while(a[0] < a[2]){
		a[0]+=2;
		out++;
	}

	if(a[0] > a[2]){
		out++;
	}

	cout << out << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrep1(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int r[100];
int c[100];
int cost[100][100];

int getMulMin(int from, int to)
{
	int ret = 100000000;
	int cand;
	int div = to - from;

	if (cost[from][to] != -1) return cost[from][to];
	else if (div == 0) {
		cost[from][to] = 0;
		return 0;
	}

	rep(i, div) {
		cand = getMulMin(from, from + i) + getMulMin(from + i + 1, to) + r[from] * c[from + i] * c[to];
		ret = min(ret, cand);
	}

	cost[from][to] = ret;

	return ret;
}

int main()
{
	int n;
	int ans;

	rep(i, 100) {
		rep(j, 100) cost[i][j] = -1;
	}

	cin >> n;
	rep(i, n) cin >> r[i] >> c[i];

	ans = getMulMin(0, n - 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3120
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	string s;
	cin >> s;
	if (s[0] == 'A') {
		if (s.find('C') != string::npos) {
			vll idx;
			for (ll i = 0; i < s.size(); ++i) {
				if (s[i] == 'C') {
					idx.pb(i+1);
				}
			}
			if (idx.size() > 1 || idx[0] < 3 || idx[0] == s.length()) {
				puts("WA");
			} else {
				bool valid = 1;
				for (ll i = 0; i < s.size() && valid; ++i) {
					if (s[i] != 'A' && s[i] != 'C') {
						valid = 'a' <= s[i] && s[i] <= 'z';
					}
				}
				puts(valid ? "AC" : "WA");
			}
		} else {
			puts("WA");			
		}
	} else {
		puts("WA");
	}
	return 0;
}

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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	a = (a + 13) % 15;
	b = (b + 13) % 15;
	if (a == b) {
		cout << "Draw" << endl;
	}
	else if (a < b) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            int ans = 0;

            Arrays.sort(a);

            ans = a[n - 1] - a[0];

            // 出力
            out.println(ans);

        }

    }
}



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

int main() {
  
  int n;
  string s, t;
  cin >> n >> s >> t;
  
  vector<char> u(2*n);
  REP(i,n) {
    u[2*i] = s[i];
    u[2*i+1] = t[i];
  }
  REP(i,2*n) {
    cout << u[i];
  }
    
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}

double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}

int main(){
	cout << fixed;
	cout << setprecision(1);
	int seq=1;
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		VP v(n);
		for(int i=0; i<n; i++){
			int x,y;
			cin >> x >> y;
			v[i] = P(x,y);
		}
		cout << seq++ << " " << abs(getarea(v)) << endl;
	}
	return 0;
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  int sum_max = 0;
  if (k <= a) {
    cout << k << endl;
  } else if (k <= a + b)
  {
    cout << a << endl;
  } else {
    int r = k - (a + b);
    cout << a - r << endl;
  }
}

Measured memory_bytes: 3580
import java.io.*;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String number = br.readLine();
		int n = Integer.parseInt(number);
		
		for(int i=0; i<n; i++){
			 String str = br.readLine();
		     str = str.replaceAll("Hoshino","Hoshina");
		     System.out.println(str);
		}
	}
}

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

    #define ll long long

    int main() {
      ll n,ws;
      cin>>n>>ws;
      ll dp[ws+1][n+1],w[n],i,j,v[n];
      for(i=0;i<n;i++)
        cin>>w[i]>>v[i];

      memset(dp,0,sizeof dp);
      for(j=1;j<=n;j++)
      {        
        for(i=1;i<=ws;i++)
        {
          if(w[j-1]<=i)
            dp[i][j]= max( dp[i][j-1] , dp[i-w[j-1]][j-1] + v[j-1] );
          else
            dp[i][j]=dp[i][j-1];
        
        }

      }
      cout<<dp[ws][n];

      return 0;
    } 

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

string s;

int main(void)
{
	int n, i;

	cin >> n >> s;

	if (s.size() > n)
	{
		for (i = 0; i < n; i++)
			cout << s[i];
		cout << "...";
	}
	else
		cout << s;
	return 0;
}

Measured memory_bytes: 3636
x,y,k = map(int,input().split(" "))
p=1
while(k!=0):
	k=k-1
	if(p==1):
		p=2
		if(x%2==0):
			y+=x//2
			x=x//2
		else:
			y+=(x-1)//2
			x=(x-1)//2
	else:
		p=1
		if(y%2==0):
			x+=y//2
			y=y//2
		else:
			x+=(y-1)//2
			y=(y-1)//2
print(x,y)

Measured memory_bytes: 3064
'use strict';
 
process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});
 
process.stdin.on('end', function() {
    inputString = inputString.split('\n');
    main();
});
 
function readline() {
    return inputString[currentLine++];
}
 
 
// main function .... code start ... ///
function main() {
 
 //var input = readline()

 var ar = readline().split(' ').map(x => parseInt(x));
 var a = ar[0], b = ar[1];
 if((a+b) % 2 == 0) console.log((a+b)/2);
 else console.log('IMPOSSIBLE');
}

Measured memory_bytes: 21192
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int cnt[26];

int main(){
	int h, w;
	cin>>h>>w;
	vector<string> s(h);
	rep(i, h) cin>>s[i];
	rep(i, h) rep(j, w) cnt[(int)(s[i][j]-'a')]++;
	rep(i, 26) cnt[i] %= 4;
	int c1 = 0, c2 = 0;
	if(h%2 ==1 && w%2 == 1) c1 = 1;
	if(h%2) c2 += w;
	if(w%2) c2 += h;
	c2 -= 2*c1;
	rep(i, 26){
		if(cnt[i]&1){
			c1--;
		}
		if(cnt[i]&2){
			c2 -= 2;
		}
	}
	if(c1>=0 && c2>=0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(a) int((a).size())
#define fr(i,n) for(int i=0;i<n;i++) 
#define rf(i,n) for(int i=1;i<=n;i++) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define MAX INT_MAX 
#define f first
#define s second
using namespace std;
#define M 1000000007
int main()
{
    int n;
    cin>>n;
    int v[3][n+1];
    fr(i,n)
        cin>>v[0][i]>>v[1][i]>>v[2][i];

    int dp[3][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=v[0][0];
    dp[1][0]=v[1][0];
    dp[2][0]=v[2][0];
    for(int i=1;i<n;i++)
    {
        dp[0][i] = max(v[0][i]+dp[1][i-1],v[0][i]+dp[2][i-1]);
        dp[1][i] = max(v[1][i]+dp[0][i-1],v[1][i]+dp[2][i-1]);
        dp[2][i] = max(v[2][i]+dp[0][i-1],v[2][i]+dp[1][i-1]);
    } 
    int ans = max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1])); 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5912
n,m=map(int,input().split())
l = [list(map(int,input().split())) for i in range(m)] 
for i in range(m):
    l[i].append(i)
    
#l.sort(key=lambda x: x[1])
l.sort(key=lambda x: (x[0], x[1]))

ken=""
for i in range(m):
    if ken != l[i][0]:
        x = 1
        ken = l[i][0]
    else:
        x += 1
    l[i].append(str(ken).zfill(6)+str(x).zfill(6))

l.sort(key=lambda x: x[2])
#print(l)
for i in range(m):
  print(l[i][3])





Measured memory_bytes: 38692
{-# LANGUAGE TypeApplications #-}
import Control.Monad
import Control.Applicative
import Data.Maybe
import qualified Data.List as List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set

getNList n = replicateM (fromIntegral n) BS.getLine

main :: IO ()
main = do
  n <- read @Int <$> getLine
  c <- getNList n
  print $ List.length $ ordNub c

ordNub :: Ord a => [a] -> [a]
ordNub xs = foldr (\x k s -> if Set.member x s
  then k s
  else x : k (Set.insert x s))
  (const []) xs Set.empty

Measured memory_bytes: 77660
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int r;cin>>r;
	cout<<r*r<<endl;
}
/*タスクを並列に行う 二分探索
x=(x ? true : false)
sorted
auto it=lower_bound(v.begin(),v.end(),w) v[it-v.begin()]>=w
auto it=upper_bound(v.begin(),v.end(),w) v[it-v.begin()]>w
void func(int* vec){}
puts(string) cout<<string<<endl;
1.*a/b int to double
(int)a-48 char to int
(char)(i+97) int to char
stoi(s) string to int
stoll(s)
cout.precision(16);
cout<<fixed<<a;
printf("%.6lf\n",a);
accumulate(a,a+n,0);
*/

Measured memory_bytes: 256