akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[][] nums=new int[n][2];
        for(int i=0;i<n;i++){
            nums[i][0]=sc.nextInt();
            nums[i][1]=sc.nextInt();
        }
        
        Comp comp=new Comp();
        comp.setIndex(0);
        Arrays.sort(nums,comp);
        long[][] nums2=new long[n][2];
        for(int i=0;i<n;i++){
            nums2[i][0]=nums[i][0];
            nums2[i][1]=nums[i][1];
        }
        long output=0;
        long tmp;
        for(int i=0;i<n;i++){
            tmp=Math.min(nums[i][1],m);
            m-=tmp;
            output+=nums[i][0]*tmp;
            if(m==0)break;
            
        }
        System.out.println(output);

    }
    

}
class Comp implements Comparator{
    int index=0;
    void setIndex(int i){
        index=i;
    }
    public int compare (Object a, Object b) {
        int[] int_a = (int[]) a;
        int[] int_b = (int[]) b;
        return (int_a[index] - int_b[index]);
    }
}  

Measured memory_bytes: 96500
#include<stdio.h>

int main(){
    
    int m,n,i,j;
    int a[100][100]={0}, b[100]={0}, c[100]={0};

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

    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
	          c[i] += (a[i][j]*b[j]);
	       }
    }
    for(i=0;i<m;i++){
    	printf("%d\n",c[i]);
    }
    return 0;
}



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

const int INF = 1000000000;
const int MAX_V = 10000;

int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];

int V;

int prim() {
  for ( int i = 0; i < V; ++i ) {
    mincost[i] = INF;
    used[i] = false;
  }

  mincost[0] = 0;
  int res = 0;

  while(true) {
    int v = -1;
    for ( int u = 0; u < V; u++ ) {
      if ( !used[u] && ( v == -1 || mincost[u] < mincost[v])) v = u;
    }
     
    if ( v == -1 ) break;
    used[v] = true;
    res += mincost[v];

    for ( int u = 0; u < V; u++ ) {
      mincost[u] = min(mincost[u], cost[v][u]);
    }
  }
  return res;
}


int main() {
  int m;
  while( cin >> V >> m,V ) {
    for ( int i = 0; i < V; i++ ) {
      for ( int j = 0; j < m; j++ ) {
	cost[i][j] = INF;
      }
    }
    for ( int i = 0; i < m; i++ ) {
      char ch; int a,b,c;
      cin >> a >> ch >> b >> ch >> c;
      cost[a][b] = c;
      cost[b][a] = c;
    }
    int ans = prim();
    cout << (ans/100) - (V-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define _GLIBCXX_DEBUG
const int INF=1e18;
const int MAX_V=50;
const int MAX_S=50*MAX_V+3;

struct Edge{
    int to,a,b;
    Edge(int to,int a,int b):to(to),a(a),b(b) {}
};

struct Data{
    int v,s,x;
    Data(int v,int s,int x):v(v),s(s),x(x) {}
    bool operator<(const Data& a) const{
        return x >a.x;
    }
};

vector<Edge> G[MAX_V];
int dp[MAX_V][MAX_S+5];

signed main(){
  	int N,M,S;
    cin>>N>>M>>S;
    REP(i,M){
        int u,v,a,b;
        cin>>u>>v>>a>>b;u--;v--;
        G[u].eb(v,a,b);
        G[v].eb(u,a,b);
    }
    vector<int> c(N),d(N);
    REP(i,N)cin>>c[i]>>d[i];
    REP(i,MAX_V)REP(j,MAX_S+5)dp[i][j]=INF;
    S=min(S,MAX_S);
    priority_queue<Data> q;
    auto push =[&](int v,int s, int x){
        if(s<0)return;
        if(dp[v][s] <= x)return;
        dp[v][s]=x;
        q.emplace(v,s,x);
    };
    push(0,S,0);
    while(!q.empty()){
        Data hoge=q.top();q.pop();
        int v=hoge.v, s=hoge.s, x=hoge.x;
        if(dp[v][s]!=x) continue;
        {
            int ns=min(s+c[v],MAX_S);
            push(v,ns,x+d[v]);
        }
        for(Edge e:G[v]){
            push(e.to,s-e.a,x+e.b);
        }
    }
    for(int i=1;i<N;i++){
        int ans=INF;
        REP(j,MAX_S+5){
            ans=min(ans,dp[i][j]);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 7400
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main()
{
    string Num;
    cin >> Num;

    int wa = 0;

    REP(i, Num.size())
    {
        wa += Num[i] - '0';
    }


    int num = atoi(Num.c_str());

    if (num % wa == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N, D = map(int, input().split())
X = [[int(j) for j in input().split()] for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        acum = 0.0
        for k in range(D):
            acum += (X[j][k] - X[i][k]) ** 2
        if float.is_integer(acum ** 0.5):
            ans += 1
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

string t[2] = {"..##", ".#.#"};

signed main(){
    int n;
    cin >> n;
    bool f = false;
    string s[2] = {"", ""};
    rep(i, 0, 420){
        int cnt = 0;
        if(!f){
            rep(j, 0, 4){
                rep(k, 0, 2){
                    cout << s[k] << t[k][j] << endl;
                }
                fflush(stdout);
                string in;
                cin >> in;
                if(in == "end") return 0;
                else if(in == "T"){
                    rep(k, 0, 2){
                        s[k] += t[k][j];
                    }
                    break;
                }else if(in == "F"){
                    cnt++;
                    if(cnt == 4) f = true;
                }
            }
        }else{
            rep(j, 0, 4){
                rep(k, 0, 2){
                    cout << t[k][j] << s[k] << endl;
                }
                fflush(stdout);
                string in;
                cin >> in;
                if(in == "end") return 0;
                else if(in == "T"){
                    rep(k, 0, 2){
                        s[k] = t[k][j] + s[k];
                    }
                    break;
                }else if(in == "F"){
                    cnt++;
                    if(cnt == 4) f = true;
                }
            }
        }
    }
}

Measured memory_bytes: 596
S  = input()
n = len(S)-1

def sum_s(s):
    return sum(list(map(int,s.split("+"))))

def dfs(i,s,m): 
    #
    #
    # m: これまでに何回
    ans = 0
    if i==n:
        return sum_s(s)

    ans += dfs(i+1,s,m) # i番目に+を入れない場合
    ans += dfs(i+1,s[:i+1+m]+"+"+s[i+1+m:],m+1) # i番目に+を入れる場合

    return ans


print(dfs(0,S,0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n, a[100010];
#define pc putchar_unlocked
#define getchar getchar_unlocked
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t)) t = getchar();
	while (isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar(); 
	}
}

int main()
{
	_read(n);
	for(int i = 1; i <= n; ++i) _read(a[i]); 
	sort(a + 1, a + n + 1, greater<int>());
	for(int i = 1; i <= n; ++i)
	{
		if(i + 1 > a[i + 1])
		{
			int ans = 0;
			for(int j = i + 1; a[j] == i; ++j)ans ^= 1;
			ans |= (a[i] - i) & 1;
			if(ans) pc('F'), pc('i'), pc('r'), pc('s'), pc('t'), pc('\n');
			else pc('S'), pc('e'), pc('c'), pc('o'), pc('n'),  pc('d'), pc('\n');
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 640
n = input()
ans = 0

if(len(n)%2 == 0):
    for i in range(0, len(n), 2):
        ans += (10**i)*9
else:
    for i in range(0, len(n)-1, 2):
        ans += (10**i)*9
    ans += int(n)-(10**(len(n)-1)-1)

print(ans)

Measured memory_bytes: 3060
s = input()
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                tmp = "A"[:i] + "KIH" + "A"[:j] + "B" + "A"[:k]+ "R" + "A"[:l]
                if tmp == s:
                    print("YES")
                    exit()
print("NO")

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;


void solve() {
	int i,j,k,l,r,x,y; string s;
	int a, b;
	cin>>a>>b;

        if(a>b){
            cout<< a-1<<endl;
        }else{
            cout<< a<<endl;
        }
        
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
d=[0]+[-1]*n
s=0
for i in range(k):
  s=a[s]-1
  if(j:=d[s])>-1:
    exec((k-j)%(i+1-j)*'s=a[s]-1;')
    exit(print(s+1))
  d[s]=i+1
print(s+1)

Measured memory_bytes: 218904
#include <stdio.h>
int main(void){
    // Your code here!
    char s[100];
    int i,n;
    
    scanf("%s",s);
    
    n=strlen(s);
    
    for(i=0;i<n;i++){
        printf("x");
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> T = new ArrayList<Integer>();
		List<Integer> S = new ArrayList<Integer>();
		
		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			int val = in.nextInt();
			S.add(val);
		}
		int q = in.nextInt();
		for (int i = 0; i < q; i++) {
			int val = in.nextInt();
			T.add(val);
		}
		
		int cnt = 0;
		for (int i = 0; i < T.size(); i++) {
			if (binarySearch(T.get(i), S)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
	
	static boolean binarySearch(int val, List<Integer> S) {
		int left, right;
		
		left = 0;
		right = S.size();
		while (left < right) {
			int mid = (right + left)/2;
			if (S.get(mid) == val) {
				return true;
			}
			if (val < S.get(mid)) {
				right = mid;
			} else {
				left = mid+1;
			}
		}
		return false;
	}
}



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



int main(){
  string d="AIDUNYAN";
  string z="AIZUNYAN";
  string str;
  cin>>str;

  for(int i=0;i<str.size();i++){
    int cnt[1<<8]={};
    for(int j=0;j<8;j++) cnt[str[i+j]]++;
    int check=0;
    for(int j=0;j<8;j++) if(cnt[d[j]]) cnt[d[j]]--,check++;
    if(check==8){
      for(int j=0;j<8;j++) str[i+j]=z[j];
      i+=7;
    }
  }
  cout <<str<<endl;

}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>

using namespace std;

#define li long long int
#define FOR(i, a, b) for (li (i) = (a) ; (i) < (b) ; ++(i))
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    li N;
    cin >> N;
    li x[N], y[N], h[N];
    FOR(i, 0, N) {
        cin >> x[i] >> y[i] >> h[i];
    }

    FOR(cx, 0, 101) {
        FOR(cy, 0, 101) {
            li criteria = -1;
            bool isAnswer = true;
            FOR(i, 0, N) {
                if (h[i] != 0) {
                    criteria = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                }
            }
            FOR(i, 0, N) {
                if (h[i] == 0) { 
                    if (criteria - abs(cx - x[i]) - abs(cy - y[i]) > 0) {
                        isAnswer = false;
                        break;
                    }
                    continue;
                 }
                li H = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                if (criteria != H) { 
                    isAnswer = false;
                    break;
                }
            }
            if (isAnswer) {
                cout << cx << " " << cy << " " << criteria << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys


def main():
    h = int(input().replace('\n','').split()[0])
    tmp = input().replace('\n','').split()
    a=0
    for i in tmp:
        a+=int(i)
    if a >= h:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    input = sys.stdin.readline
    main()


Measured memory_bytes: 10132
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("output.txt", "w", stdout);
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);

    int a,b;
    cin >> a >> b;
    if (max(a,b) > 8)
        cout << ":(\n";
    else
        cout << "Yay!\n";
}


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

int main() {
	int a1,a2,a3;cin>>a1>>a2>>a3;
	int ans=300;
	if(a1>a2){
		if(a1>a3){
			if(a2>a3){
				cout<<a1-a3<<endl;
			}else{
				cout<<a1-a2<<endl;
			}
		}else{
			cout<<a3-a2<<endl;
		}
	}else{
		if(a2>a3){
			if(a1>a3){
				cout<<a2-a3<<endl;
			}else{
				cout<<a2-a1<<endl;
			}
		}else{
			cout<<a3-a1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int ama[101];
int main(){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()){puts("GREATER");}
    else if(a.size()<b.size()){puts("LESS");}
    else{
        
        for(ll i=0;i<a.size();i++){
            if(a[i]>b[i]){puts("GREATER");return 0;}
            else if(b[i]>a[i]){puts("LESS");return 0;}
        }
        
        puts("EQUAL");
        
        
    }
    
    
  
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char S[3];
	scanf("%s",S);
	if(S[2]=='T'){
		printf("1");
	}
	if(S[0]=='F'){
		printf("2");
	}
		if(S[1]=='H'){
		printf("3");
	}	if(S[0]=='W'){
		printf("4");
	}	if(S[2]=='E'){
		printf("5");
	}	if(S[1]=='O'){
		printf("6");
	}	if(S[0]=='S' && S[2]=='N'){
		printf("7");
	}
	return 0;
}


Measured memory_bytes: 128
N = int(input())
nums = [int(input()) for i in range(N)]

_nums = sorted(nums, reverse=True)
max1 = _nums[0]
max2 = _nums[1]
for i in range(0, N):
    if nums[i] == max1:
        print(max2)
    else:
        print(max1)


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

using S = long long;
using F = long long;

const S INF = 8e18;
const F ID = 8e18;

S op(S a, S b) { return std::max(a, b); }
S e() { return -INF; }
S mapping(F f, S x) { return (f == ID ? x : f); }
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }

const long long SZ = 300000 + 2;
void solve() {
    int n, k;
    cin >> n >> k;
    std::vector<S> v(SZ);
    // 1点更新、区間最大値なので遅延ではないセグ木で十分だが、
    // 勉強のため遅延セグ木を用いる。
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);

    while (n--) {
        long long x;
        cin >> x;
        // 過去に存在した x±k の座標に対する点の数の最大値を求める
        long long me = seg.prod(max(0LL, x - k), min(SZ, x + k + 1));
        // 現在のx座標に対して上記+1をセット（区間更新）
        seg.apply(x, x + 1, me + 1);
    }
    cout << seg.all_prod() << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}

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

typedef struct {
    int x;
    int y;
} POINT;

int main(void)
{
    POINT data[3000];
    static char exist[5001][5001];
    int i, j;
    int n;
    int max;
    int dx, dy;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        memset(exist, 0, sizeof(exist));
        for (i = 0; i < n; i++){
            scanf("%d%d", &data[i].x, &data[i].y);
            exist[data[i].x][data[i].y] = 1;
        }
        
        max = 0;
        for (i = 0; i < n; i++){
            for (j = i + 1; j < n; j++){
                if (i == j){
                    continue;
                }
                dx = data[j].x - data[i].x;
                dy = data[j].y - data[i].y;
                if (dx < 0){
                    dx *= -1;
                }
                if (dy < 0){
                    dy *= -1;
                }
                
                if (data[i].x + dy <= 5000 && data[i].y + dx <= 5000 &&
                        data[j].x + dy <= 5000 && data[i].y + dx <= 5000 &&
                            exist[data[i].x + dy][data[i].y + dx] && exist[data[j].x + dy][data[j].y + dx] && dx * dx + dy * dy > max){
                    max = dx * dx + dy * dy;
                }
            }
        }
        
        printf("%d\n", max);
    }
    
    return (0);
}

Measured memory_bytes: 24000
#include <iostream>
#include <cmath>
using namespace std;
    
int main(){
    int A[5][4][11] = {};
    int n;
    
    for(int i = 1;i <=4;i++)
        for(int j = 1;j <=3;j++)
            for(int k = 1;k <= 10;k++) A[i][j][k] = 0;
    
    cin >> n;
    for(int i = 0;i<n;i++){
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
    }
    for(int f = 1;f <=4;f++){
        if(f > 1)cout << "####################\n";
        for(int b = 1;b <=3;b++){
            for(int r = 1;r <=10;r++){
                cout << " " << A[f][b][r];
            }
            cout << endl;
        }
    }
}



Measured memory_bytes: 3088
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >

const int maxn = 1000* 100 + 5;
int a[maxn], b[maxn];
vector <int> v;

int32_t main(){
    ios_base::sync_with_stdio;
    ll n, ans = 0, sum = 0;
    cin >>n;
    for(int i = 0; i < n; i ++)
        cin >>a[i];
    for(int i = 0; i < n; i ++)
        cin >>b[i];
    for(int i = 0; i < n; i ++){
        if(a[i] < b[i]){
            ans ++;
            sum += b[i] - a[i];
        }
        else
            v.pb(a[i] - b[i]);
    }
    sort(v.begin(), v.end());
    while(SZ(v) and sum > 0){
        sum -= v[SZ(v) - 1];
        v.pop_back();
        ans ++;
    }
    if(sum > 0)
        cout <<-1 <<endl;
    else
        cout <<ans <<endl;
    return false;
}


Measured memory_bytes: 2808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W, a, b;
		W = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();

		if(a <= b && b <= a + W || b <= a && a <= b + W) System.out.print(0);
		if(b > a + W) System.out.print(b - (a + W));
		if(a > b + W) System.out.print(a - (b + W));
	}
}

Measured memory_bytes: 23764
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)



int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int x = a * 100 + b * 10 + c;
	if (x % 4 == 0) {
		cout << "YES";
	}
	else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	char c[3][3];

	REP(i,3)
		REP(j,3)
			cin>>c[i][j];


	REP(i,3)
		printf("%c",c[i][i]);
	print();

	return 0;
}




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

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

  vector<pair<int, int>> adj[n * m];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (j + 1 < m) {
        if (a[i][j] == '.' && a[i][j + 1] == '#') {
          adj[i * m + j].emplace_back(i * m + (j + 1), 1);
        } else {
          adj[i * m + j].emplace_back(i * m + (j + 1), 0);
        }
      }
      if (i + 1 < n) {
        if (a[i][j] == '.' && a[i + 1][j] == '#') {
          adj[i * m + j].emplace_back((i + 1) * m + j, 1);
        } else {
          adj[i * m + j].emplace_back((i + 1) * m + j, 0);
        }
      }
    }
  }

  deque<int> dq;
  dq.emplace_back(0);

  vector<int> dist(n * m, -1);
  dist[0] = a[0][0] == '#' ? 1 : 0;

  while (!dq.empty()) {
    int u = dq.front();
    dq.pop_front();
    for (auto &i : adj[u]) {
      int v = i.first;
      int w = i.second;
      if (dist[v] == -1 || dist[v] > dist[u] + w) {
        dist[v] = dist[u] + w;
        if (w == 0) {
          dq.emplace_front(v);
        } else if (w == 1) {
          dq.emplace_back(v);
        }
      }
    }
  }

  // for (int i = 0; i < n; i++) {
  //   for (int j = 0; j < m; j++) {
  //     cout << dist[i * m + j] << " \n"[j == m - 1];
  //   }
  // }

  cout << dist[n * m - 1] << "\n";
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  long h;
  read h;
  int n = 0;
  while (h != 0) {
    h = h / 2;
    n++;
  }
  // cout << n << endl;
  long ans = 1;
  REP(i, n) { ans = 2 * ans; }
  cout << ans - 1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a[3];
	int i,j,temp;
	
	for (i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	for (i=0;i<2;i++){
		for (j=i+1;j<3;j++){
				if (a[i]>a[j]){
					temp=a[i];
					a[i]=a[j];
					a[j]=temp;
				}
		}
	}
	for(i=0;i<2;i++){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[2]);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
	int i, j, n=0, max;
	char s[4];
	scanf("%s", s);
	for (i = 0; i < 3; i++)
	{
		if (s[i] == 'R')
		{
			n++;
		}
	}
	if (n == 0)
	{
		printf("0");
	}
	else if (n == 1)
	{
		printf("1");
	}
	else if (n == 3)
	{
		printf("3");
	}
	else if (n == 2 && s[1] != 'S')
	{
		printf("2");
	}
	else
	{
		printf("1");
	}
	return 0;
}

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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

const int INF = 1 << 29;

signed main() {
	int n;
	while (cin >> n && n) {
		int m, k; cin >> m >> k;
		vector<vector<double>> dp(n + 1, vector<double>(n * m + 1));
		dp[0][0] = 1;
		rep(k, n) rep(i, n * m) rep(j, m) if (i + j + 1 <= n * m) {
			dp[k + 1][i + j + 1] += dp[k][i] / m;
		}
		double ans = 0;
		rep(i, k + 1) ans += dp[n][i] * 1;
		rep(i, k + 1, n * m + 1) ans += dp[n][i] * (i - k);
		printf("%.8f\n", ans);
	}
}

Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    for(int i = 0; i < n; ++i) cin >> x[i];
    for(int i = 0; i < n; ++i) cin >> y[i];
    double p1=0.0, p2=0.0, p3=0.0, pinf=0.0, t=0.0;
    for(int i = 0; i < n; ++i) {
        p1 += fabs(x[i]-y[i]);
        p2 += pow(x[i]-y[i],2);
        p3 += pow(fabs(x[i]-y[i]),3);
        t = fabs(x[i]-y[i]);
        if(pinf < t) pinf = t;
    }
    printf("%lf\n%lf\n%lf\n%lf\n", p1, sqrt(p2), cbrt(p3), pinf);
    return 0;
}


Measured memory_bytes: 3340
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string t;
  bool ok=true; 
  cin >> n;
  VL c(n),s(n),f(n);
  rep(i,n-1){
    cin >> c[i] >> s[i] >> f[i];
  }
  rep(i,n-1){
    ans = 0;
    ans = s[i] + c[i];
    for(int j=i+1; j<n-1; j++){
      if(ans < s[j]){
        ans = s[j];
      }
      else if(ans % f[j] == 0){
      }
      else{
        ans = ans+f[j] - ans%f[j];
      }
      ans += c[j];
    }
    pri(ans);
  }
  pri(0);
  return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for(int i=0; i<n; i++)
    cin >> l.at(i);
  
  int count = 1;
  int d = 0;
  
  for(int i=0; i<n; i++) {
    d += l.at(i);
    if(d <= x)
      count++;
    else
      break;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
#define INF 100000000000000000
using namespace std;

typedef vector<vector<ll> > graph;
graph dist;
int flag = 1;

void warshall_floyd(int n){
  for(int i = 0; i < n; i++){ //?????±????????????
    for(int j = 0; j < n; j++){ //????§???????
      for(int k = 0; k < n; k++){ //??????
        if(dist[j][i] != INF && dist[i][k] != INF) dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
      if(dist[j][j] < 0) flag = 0; //dist[j][j]?????? = ?????????????????????
    }
  }
}

int main(){

  int v, e;
  cin >> v >> e;
  dist = graph(v, vector<ll>(v, INF));
  for(int i = 0; i < v; i++) dist[i][i] = 0;

  int from, to;
  ll cost;
  for(int i = 0; i < e; i++){
    cin >> from >> to >> cost;
    dist[from][to] = cost;
  }
  warshall_floyd(v);
  if(flag){
    for(int i = 0; i < v; i++){
      for(int j = 0; j < v; j++){
        if(dist[i][j] == INF) cout << "INF" << ((j == v-1) ? "\n" : " ");
        else cout << dist[i][j] << ((j == v-1) ? "\n" : " ");
      }
    }
  }else{
    cout << "NEGATIVE CYCLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 3288
package main

import (
        "fmt"
)

// seen: https://atcoder.jp/contests/sumitrust2019/submissions/8717655
func solution(n int, s string) int {
        var dp [30009][4][1009]bool
        dp[0][0][0] = true

        for i := 0; i < n; i++ {
                for j := 0; j <= 3; j++ {
                        for k := 0; k < 1000; k++ {
                                if !dp[i][j][k] {
                                        continue
                                }

                                dp[i+1][j][k] = true
                                if j <= 2 {
                                        dp[i+1][j+1][k*10+int(s[i]-'0')] = true
                                }
                        }
                }
        }

        out := 0
        for i := 0; i < 1000; i++ {
                if dp[n][3][i] {
                        out++
                }
        }
        return out
}

func main() {
        var n int
        var s string
        fmt.Scan(&n, &s)
        fmt.Println(solution(n, s))
}

Measured memory_bytes: 124248
#include<iostream>
using namespace std;
int m,n;
bool a[100][100]={{0}};
bool b[100][100]={{0}};
bool f[100][100]={{0}};
int cnt=0,ans=0;
int p=0,q=0;
void check(int x,int y);
int main(void){
    for(;;){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                b[i][j]=0;
                a[i][j]=0;
            }
        }
        ans=0;
        cin>>m>>n;
        if(m==0&&n==0)break;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cin>>a[i][j];
                b[i][j]=a[i][j];
            }
        }
        //in
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cnt=0;
                if(b[i][j]==1){
                    //cout<<".."<<i<<"."<<j<<endl;
                    check(i,j);
                }
                        for(int i=1;i<=n;i++){
                            for(int j=1;j<=m;j++){
                                b[i][j]=a[i][j];
                            }
                        }

            }
        }
        cout<<ans<<endl;

    }
    return 0;
}
void check(int x,int y){
    b[x][y]=0;
    //p++,cout<<p<<"+"<<x<<","<<y<<endl;
    cnt++;
    int flag=0;
    if(b[x+1][y]==1){
        flag=1;
        check(x+1,y);
        b[x+1][y]=1;
        cnt--;
        //p--,cout<<"-"<<x<<","<<y<<endl;
    }

    if(b[x][y+1]==1){
        flag=1;
        check(x,y+1);
        b[x][y+1]=1;
        cnt--;
        //p--,cout<<"-"<<x<<","<<y<<endl;
    }
    if(b[x-1][y]==1){
        flag=1;
        check(x-1,y);
        b[x-1][y]=1;
        cnt--;
        //p--,cout<<"-"<<x<<","<<y<<endl;
    }

    if(b[x][y-1]==1){
        flag=1;
        check(x,y-1);
        b[x][y-1]=1;
        cnt--;
        //p--,cout<<"-"<<x<<","<<y<<endl;
    }



    if(flag==0){
        ans=max(ans,cnt);
        //p--,cout<<"-"<<x<<","<<y<<endl;


        return;
    }

}

Measured memory_bytes: 1180
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

f (xa1,ya1) (xa2,ya2) (xb1,yb1) (xb2,yb2) = xi && yi
  where
    [x1,x2,x3,x4] = sort [xa1,xa2,xb1,xb2]
    [y1,y2,y3,y4] = sort [ya1,ya2,yb1,yb2]
    xi = if x1==xa1 then x2==xb1 else x2==xa1
    yi = if y1==ya1 then y2==yb1 else y2==ya1


main = map (map (apply2 (,)) . splitRec 2 . map readDouble . words) . lines <$> getContents >>= mapM_ (putStrLn . cond "YES" "NO" . apply4 f)


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;

int main() {
  int ans=0;
  vector<int> S;
  for(int i=0;i<5;i++){
    int a;
    cin>>a;
    if(a%10!=0){
       S.push_back(a%10);
      a+=10-(a%10);
    }
    ans+=a;
    a%=10;
  }
  if(S.size()!=0){
  sort(S.begin(),S.end());
  cout<<ans-10+S.at(0);
  }
  else cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
          #define int long long
            #define mod  1000000007
            #define pa pair<int,int>
    #define ll long long
            #define pal pair<double,int>
            #define ppa pair<int,pa>
             #define ssa pair<string,int>
            #define  mp make_pair
            #define  pb push_back
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
int gcd(int v,int b){
	if(v>b) return gcd(b,v);
	if(v==b) return b;
	if(b%v==0) return v;
	return gcd(v,b%v);
}
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
            //----------------kokomade tenpure------------
int n,k;


int veki (int z, int r){
	if (r==1) return z%mod;
	if(r==0) return 1ll;
	if(r%2==1) return (z*veki(z,r-1))%mod;
	int y=veki(z,r/2);
	return (y*y)%mod;
}
    signed  main(){
string a,b,c;
    	cin>>a>>b>>c;
    	cout<<a[0]<<b[0]<<c[0]<<endl;
    //	printf("%.10f\n",ky[n+1]);
    	return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	for(int i=0;i<20001;i++){
	int a=0,b=0,c=0;
	char op=0;
	cin >> a >> op >> b;
	if(op =='+'){
		c=a+b;
	}else if(op =='-'){
		c=a-b;
	}else if(op =='*'){
		c=a*b;
	}else if(op =='/'){
		c=a/b;
	}else if(op =='?'||a==0&&b==0){
		break;
	}
	cout<<c<<endl;
	}
	return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0,h,w;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >>n;
vLL(A,n);
REP(i,n)REP(j,n)ans=max(ans,abs(A[i]-A[j]));
cout << ans;
}

Measured memory_bytes: 3660
#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, k;
  cin >> n >> k;
  int ans = 0;
  rep(i, n) {
    int h;
    cin >> h;
    if (h >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
N=int(input())

ans=N
for i in range(N+1):
	cnt=0
	t=i
	while t>0:
		cnt+=t%6
		t//=6
	j=N-i
	while j>0:
		cnt+=j%9
		j//=9
	ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#define mod 1000000007
#define ll long long
#define pi acos(-1)
using namespace std;

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






Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };





signed main() {
	int n, q;
	vector<int>slist;
	vector<int>tlist;


	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		slist.push_back(num);
	}

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

	slist.erase(unique(slist.begin(), slist.end()), slist.end());

	cin >> q;



	for (int i = 0; i < q; i++) {
		int num;
		cin >> num;
		tlist.push_back(num);
	}


	sort(tlist.begin(), tlist.end());
	int cnt = 0;
	int mem = 0;

	for (int i = 0; i < tlist.size(); i++) {
	
		for (int j = 0; j < slist.size(); j++) {
			if (slist[j] == tlist[i]) {
				cnt++;
				//mem = j;
			}
			if (slist[j] > tlist[i]) {
				break;
			}

		}

	}

	cout << cnt << endl;




	return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <string>
#include <set>
#include <cmath>
// #include <unordered_set>
// #include <map>
#define REP(i,a,b) for(int i = a; i < b;++i) 
#define FOR(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define inp1(a) scanf("%d",&a)
#define inp2(a,b) scanf("%d%d",&a,&b)
#define inp3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
// #define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int> > piii;
typedef queue<int> QU;

const int MOD = 1000000007;
const int INF = 0x3c3c3c3c;
const long long INFL = 0x3c3c3c3c3c3c3c3c;
const int MAX_N = 2002;

int N,K;
vi adj[MAX_N];
int dist[MAX_N];
int cnt;
void dfs(int here){
	for(int there : adj[here]){
		if(dist[there]!=-1) continue;
		dist[there] = dist[here]+1;
		if(dist[there] > K/2) ++cnt;
		dfs(there);
	}
}
int main() {
	inp2(N,K);
	FOR(i,N-1){
		int a,b;
		inp2(a,b);
		--a;--b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	int ans=INF;
	if(K%2){
		FOR(a,N){
			for(int b : adj[a]){
				memset(dist,-1,sizeof(dist));
				cnt=0;
				dist[a]=dist[b]=0;
				dfs(a);
				dfs(b);
				ans=min(ans,cnt);
			}
		}
	}
	else {
		FOR(c,N){
			memset(dist,-1,sizeof(dist));
			cnt=0;
			dist[c]=0;
			dfs(c);
			ans=min(ans,cnt);
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Node
    {
        public List <Edge> Edges;
        public int Dist;
        public int No;
        public bool Visited;
        public int Start;
        public int End;

        public Node(int no)
        {
            this.No = no;
            Dist = int.MaxValue;
            Edges = new List<Edge>();
            Visited = false;
        }
    }

    internal class Edge
    {
        public int From;
        public int To;
        public int Cost;
       

        public Edge(int fr, int to, int cost = 0)
        {
            From = fr;
            To = to;
            Cost = cost;
        }

    }

    internal class Graph
    {
        public List<Node> Nodes;

        public Node this[int i]
        {
            set { Nodes[i] = value; }
            get { return Nodes[i]; }
        }

        public Graph(int N)
        {
            Nodes = new List<Node>();
            for (int i = 0; i < N; i++)
            {
                Nodes.Add(new Node(i));
            }
        }

    }

    internal class Solution
    {
        public int N;
        public Graph G;
        public int T;

        public void Run()
        {
            N = Input.ReadInt();
            G = new Graph(N);
            
            for (int i = 0; i < N; i++)
            {
                var line = Input.ReadIntArray();
                var o = line[1];
                for (int j = 0; j < o; j++)
                {
                    int fr = i;
                    int to = line[2 + j] - 1;
                    G[i].Edges.Add(new Edge(fr, to));
                }
            }

            RunGraph();
            for (int i = 0; i < N; i++)
            {
                Console.WriteLine("{0} {1} {2}", i+1, G[i].Start, G[i].End);
            }
        }

        public void RunGraph()
        {
            T = 0;
            for (int i = 0; i < N; i++)
                DFS(i);

        }

        public void DFS(int i)
        {
            if (G[i].Visited) return;
            T++;
            G[i].Start = T;
            G[i].Visited = true;
            foreach (var e in G[i].Edges)
            {
                DFS(e.To);
            }

            T++;
            G[i].End = T;
        }

    }

    
    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}


Measured memory_bytes: 9660
#include <iostream>
#include <vector>
#include <limits>
using namespace std;

int maximum_sub_sequense(vector<int> &s)
{
    int max = numeric_limits<int>::min();

    for (auto i = s.begin(); i != s.end(); i++) {
        int sum = 0;
        for (auto j = i; j != s.end(); j++) {
            sum += *j;
            if (sum > max)
                max = sum;
        }
    }

    return max;
}

int main()
{
    for (int n; cin >> n && n;) {
        vector<int> sequence(n);
        for (int x, i = 0; i < n && cin >> x; i++)
            sequence[i] = x;
        cout << maximum_sub_sequense(sequence) << endl;
    }

    return 0;
}

Measured memory_bytes: 1200
def test(W):
    c=[0 for i in range(26)]
    for i in W:
        c[ord(i)-97]+=1
    for i in range(26):
        if c[i]%2==1:
            return False
    return True
w=input()
if test(w):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



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

const int inf = 100000000;

typedef long long ll;

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

  // vector<int> hoge(1e7);        // 39296 KB
  // vector<bool> hoge(1e7);        // 1536 KB KB
  // vector<int> hoge(5*1e7);        // 195584 KB
  vector<int> hoge(6*1e7);        // 195584 KB

  char a, b;
  cin >> a >> b;
  if(a==b) {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }


  return 0;
}


Measured memory_bytes: 234624