akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,n,b;
  int a[3][3];
  int r[3]={0,0,0};
  int c[3]={0,0,0};
  int d1=0,d2=0;
  int f=0;
  for(i=0;i<3;i++)
  {
  	for(j=0;j<3;j++) cin>>a[i][j];
  }
  cin>>n;
  while(n--)
  {
  	cin>>b;
  	if(f) continue;
  	for(i=0;i<3;i++)
	 {
  	for(j=0;j<3;j++) 
  	{
  		if(a[i][j]==b)
  		{
  			r[i]++;
  			c[j]++;
  			if(i==j) d1++;
  			if(i+j==2) d2++;
  			if(r[i]==3 || c[j]==3 || d1==3|| d2==3) f=1;
  		}
  	}
  }}
  if(f) cout<<"Yes\n";
  else cout<<"No\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll x, a, b;
  cin >> x >> a >> b;

  if(a >= b) cout << "delicious" << endl;
  else if(x >= b - a) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int )= (a); i<(b); i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
typedef long long ll;

signed main () {
    while (true){
        int n,x;scanf("%d %d",&n,&x);
        if(n==0&&x==0)break;
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x)ans++;
                }
            }
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 3168
#include <cstdio>
#include <iostream>
using namespace std;
long long num[55];
long long work(int n,long long x){
	if(x<=0){
		return 0;
	}
	if(n==0){
		return 1;
	}
	if(x==num[n]){
		return 1+(work(n-1,num[n-1])<<1);
	}
	if(x>=num[n-1]+2){
		return 1+work(n-1,num[n-1])+work(n-1,x-num[n-1]-2);
	}
	return work(n-1,x-1);
}
int main(){
	num[0]=1;
	for(int i=1;i<=50;i++){
		num[i]=(num[i-1]<<1)+3;
	}
	int n;
	long long x;
	scanf("%d",&n);
	cin>>x;
	cout<<work(n,x)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool check_prime(long long n);

int main(void) {
    int N, tmp, count = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        if (check_prime(tmp)) count++;
    }
    cout << count << endl;
    return 0;
}

bool check_prime(long long n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	int n, T;
	cin >> n >> T;
	int c, t;
	int max = 10000;
	for (int i = 0;i < n;i++) {
		cin >> c >> t;
		if (t <= T) {
			if (c < max) {
				max = c;
			}
		}
	}
	if (max == 10000) {
		cout << "TLE" << endl;
	}
	else {
		cout << max << endl;
	}
	return 0;
}

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

using namespace std;

int main(void)
{
  string s,t; cin>>s>>t;
  int size=s.length();
  int count=0;
  
  for(int i=0;i<size;i++){
    if(s[i]!=t[i]){count++;}
  }
  
  cout<<count<<endl;
  
  return 0;
}

Measured memory_bytes: 3912
alps = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
n = int(input())
s = input()

ans = ''
for i in range(len(s)):
    idx = alps.index(s[i])
    idx += n
    if 25 < idx:
        idx = idx - 26
    x = alps[idx]
    ans += x
print(ans)
  

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

using namespace std;
const int mod = 924844033;
const int maxn = 4000 + 10;
typedef long long int lli;

int link[maxn];
lli x[maxn];
lli dp[maxn][maxn][2];

int main() {
    int n, k, tot = 0;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= k; i++) {//i枚举链的起点,最大是k,因为比k大的都能转化过来
        for (int p = 0; p < 2; p++) {//因为p=0时,起点为第i个点,p=1时,为第i个坑
            for (int j = i; j <= n; j += k) {
                tot++;
                if (j != i) link[tot] = 1;//link[i]代表第i条边是否与上一条边相连
            }
        }
    }
    x[1] = 1;
    x[0] = 1;
    for (int i = 2; i <= n; i++) {
        x[i] = x[i - 1] * i % mod;
    }
    dp[0][0][0] = 1;
    for (int i = 0; i < n * 2; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i + 1][j][0] = (dp[i][j][0] + dp[i][j][1]) % mod;
            if (link[i + 1]) dp[i + 1][j + 1][1] = dp[i][j][0];
        }
    }
    lli sum = 0, t = 1;
    for (int i = 0; i <= n; i++) {
        sum += ((dp[n * 2][i][0] + dp[n * 2][i][1]) % mod * x[n - i] % mod * t + mod) % mod;
        sum %= mod;
//        lli tmp = (dp[n * 2][i][0] + dp[n * 2][i][1]) % mod * x[n - i] % mod;
//        sum = (sum + (tmp * t + mod) % mod) % mod;
        t *= -1;
    }
    printf("%lld\n", sum);
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int numberofodd=0;
  for(int i=1;i<=n;i++){
    if(i&1==1){
    numberofodd++;
    }
  }
  printf("%.10f",(numberofodd*1.0000000000)/n);
 return 0;
}

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

using namespace std;

using ll = long long;

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

const ll INF = 1LL << 60;

typedef pair<ll, double> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.second < secondElof.second;
}

bool IsPrime(ll num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

signed main() {
	ll ans = INF;

	ll n;
	cin >> n;
	vector<ll>x(n + 1);
	rep(i, n)cin >> x[i];
	for (ll i = 1; i < 120; i++) {
		ll a = 0;
		for (ll j = 0; j < n; j++) {
			a += pow(x[j] - i, 2);
		}
		if (ans > a) {
			ans = a;
		}
	}
	

	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() 
{
 ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll T;
cin>>T;
if(T>=30)
cout<<"Yes"<<endl;
else
{
    cout<<"No"<<endl;
}

return(0);
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;



int main(){
    while(true){
        int a,b,c;
        cin >> a >> b >>c;
        
        if(a == -1 and b == -1 and c == -1) break;
        
        if(a == -1 or b == -1 or a+b<30) cout << "F" << endl;
        else if(a+b >= 80) cout << "A" << endl;
        else if(a+b >= 65) cout << "B" << endl;
        else if((a+b >= 50)or(50>a+b and a+b >= 30 and c>=50)) cout << "C" << endl;
        else if(a+b >=30 and c<50) cout << "D" << endl;
        else cout << "F" << endl;
    }
}









Measured memory_bytes: 3100
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] tris = new int[4];
	public static void main(String[] args) {

			judgeTypes();
			dispResult();

	}

	private static void dispResult() {
		System.out.printf("%d %d %d %d\n", tris[0], tris[1], tris[2], tris[3]);
	}

	private static void judgeTypes() {
		int[] s = new int[3];

			do {
						for (int i = 0; i < 3; i++) {
							s[i] = sc.nextInt();
						}

					Arrays.sort(s);

						if (s[2] >= s[0] + s[1]) {
							break;
						} else if (Math.pow(s[0], 2) + Math.pow(s[1], 2) - Math.pow(s[2], 2) == 0) {
							tris[0]++;
							tris[1]++;

						} else if (Math.pow(s[0], 2) + Math.pow(s[1], 2) - Math.pow(s[2], 2) > 0) {
							tris[0]++;
							tris[2]++;

						} else if (Math.pow(s[0], 2) + Math.pow(s[1], 2) - Math.pow(s[2], 2) < 0) {
							tris[0]++;
							tris[3]++;
						}

			}while(true);

	}

}


Measured memory_bytes: 26752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

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

		int d=a/b;
		int r=a%b;
		double f=1.0*a/b;

		System.out.print(d+" "+r+" ");
		System.out.printf("%f\n",f);
	}
}

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

#define MAX 100010

using namespace std;

vector<vector<int> > g;

int color[MAX];

bool Check(int v,int c)
{
    color[v] = c;

    int vs = g[v].size();
    for(int i = 0;i < vs;i++)
    {
        int next = g[v][i];
        if(color[next] == c)
            return false;
        if(color[next] == 0 && !Check(next,-c))
            return false;
    }

    return true;
}

int main(void)
{
    long long int n,m;

    cin>>n>>m;
    
    memset(color,0,n);
    g.resize(n);

    for(int i = 0;i < m;i++)
    {
        long long a,b;
        cin>>a>>b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    if(Check(0,1))
    {
        long long b,w;
        b = w = 0;
        for(int i = 0;i < n;i++)
        {
            if(color[i] == 1)
                b++;
            else
                w++;
        }
        cout<<b*w-m<<endl;
    } else {
        cout<<n*(n-1)/2 - m<<endl;
    }
   
    return 0;
}


Measured memory_bytes: 7680
#include<stdio.h>

#define Max 500000
#define Sen 1000000000

int count;
int l[Max / 2 + 2], r[Max / 2 + 2];

void merge(int a[], int n, int left, int mid, int right){
  int n1, n2, i, j, k;
  n1 = mid - left;
  n2 = right - mid;

  for(i = 0 ; i < n1 ; i++) l[i] = a[left + i];
  for(i = 0 ; i < n2 ; i++) r[i] = a[mid + i];
  l[n1] = r[n2] = Sen;

  i = 0;
  j = 0;
  for(k = left ; k < right ; k++){
    count++;
    if(l[i] <= r[j]){
      a[k] = l[i++];
    }
    else{
      a[k] = r[j++];
    }
  }
}

void mergeSort(int a[], int n, int left, int right){
  if(left + 1 < right){
    int mid;

    mid = (left + right) / 2;
    mergeSort(a, n, left, mid);
    mergeSort(a, n, mid, right);
    merge(a, n, left, mid, right);
  }
}


int main(){
  int a[Max], n, i;
  count = 0;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++) scanf("%d", &a[i]);

  mergeSort(a, n, 0 , n);

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

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

  return 0;
}


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

int main() {
  int N;
  cin>>N;
  int A[N];
  for (int i=0; i<N; i++) {
    cin>>A[i];
  }
  for (int i=0; i<N; i++) {
    cout<<(i==0?"":" ")<<A[i]<<flush;
  }
  cout<<endl;
  for (int i=1; i<N; i++) {
    int v=A[i];
    int j=i-1;
    while (j>=0 && A[j]>v) {
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for (int k=0; k<N; k++) {
      cout<<(k==0?"":" ")<<A[k]<<flush;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3084
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve():
    N, X = list(map(int, input().split()))
    L = list(map(int, input().split()))
    count = 1
    bounding = 0
    for l in L:
        bounding += l
        if bounding > X:
            break
        count += 1
    return count


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int K = sc.nextInt();

        if(K%2!=0){
            long x = 0;
            for(int i=1; i<=N; i++){
                if(i%K==0){
                    x += 1;
                }
            }
            System.out.println(x * x * x);
        }
        else{
            long x = 0;
            long y = 0;
            for(int i=1; i<=N; i++){
                if(i%K==0){
                    x += 1;
                }
                else if(i%K==K/2){
                    y += 1;
                }
            }
            System.out.println(x * x * x + y * y * y);
        }
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

const lint INF = 1ll << 60;
const int mod = 1000000007;
const int inf = INT_MAX;
void speed() {
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	return;
}



int main(void) {
	speed();
	int n; cin >> n;
	vector<lint> d(n);
	for (int i = 0; i < n; i++) cin >> d[i];
	map<lint, lint> m;
	map<lint, lint> mp;
	for (int i = 0; i < n; i++) {
		m[i - d[i]]++;
		mp[i + d[i]]++;
	}
	lint ans = 0;
	for (int i = 0; i < n; i++) {
		ans += m[i] * mp[i];
	}
	cout << ans << endl;

	return 0;
}

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


string s;
int x, y;
vector<int> v[2];
int dp[8005][16005];
int l ;
int rec(int pos, int sum){
    if(pos==v[l].size()){
        return sum==x;
    }
    int& ans = dp[pos][sum+8000];
    if(ans!=-1) return ans;
    return ans = max(rec(pos+1,sum+v[l][pos]), rec(pos+1,sum - v[l][pos]));
}




int main() {
    cin >> s >> x >> y;
    int id = 0, f = 1, cnt = 0;

    while(s[id]!='T' && id<s.size()) id++;
    for(int i=id+1;i<s.size();i++){
        if(s[i]=='T'){
            v[f].push_back(cnt);
            cnt = 0 , f ^= 1;
        } else cnt++;
    }
    v[f].push_back(cnt);
    memset(dp, -1, sizeof dp);
    int ok1 = rec(0,id);
    l = 1, x = y;
    memset(dp, -1, sizeof dp);
    int ok2 = rec(0,0);
    if(ok1 && ok2){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}


Measured memory_bytes: 500992
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
	int i,j,k,n,tmp,flag,length;
	int yosan[20];
	char str[81],str2[1024],ans[5];

	scanf("%d",&n);

	for(i = 0;i < n;i++){
		memset(yosan,0,sizeof(yosan));
		flag = 0;
		for(j = 0;j < 2;j++){
			scanf("%s",str2);
			length = strlen(str2);
			if(length >= 81){
				flag = 1;
			}else{
				memset(str,'0',sizeof(str));
				for(k = 0;k < 80;k++){
					if(k >= 80-length){
						str[k] = str2[k-80+length];
					}else{
						str[k] = '0';
					}
				}
				str[80] = '\0';
				tmp = 0;
				for(k = 0;k < 80;k++){
					tmp *= 10;
					tmp += (str[k] - '0');
					if(k % 4 == 3){
						yosan[k/4] += tmp;
						tmp = 0;
					}
				}
				for(k = 19;k > 0;k--){
					if(yosan[k] >= 10000){
						yosan[k-1]++;
						yosan[k] %= 10000;
					}
				}
			}
		}
		if(yosan[0] >= 10000){
				flag = 1;
		}
		if(!flag){
			tmp = 0;
			while(tmp < 20 && yosan[tmp] == 0){
				tmp++;
			}
			if(tmp == 20){
				printf("0\n");
			}else{
				sprintf(ans,"%d",yosan[tmp]);
				printf("%s",ans);
				tmp++;
				for(j = tmp;j < 20;j++){
					sprintf(ans,"%04d",yosan[j]);
					printf("%s",ans);
				}
				printf("\n");
			}
		}else{
			printf("overflow\n");
		}
	}

	return 0;
}

Measured memory_bytes: 628
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    total = sum(a)
    count = 0
    length = 0
    while True:
        length += a[count]
        if length >= total // 2:
            break
        count += 1

    ans = abs(total - length * 2)
    if abs(total - (length - a[count]) * 2) < ans:
        ans = abs(total - (length - a[count]) * 2)

    print(ans)


Measured memory_bytes: 26024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(void)
{
	char b[11]; 
	int i = 0,max = 0,coun = 0;
	scanf("%s",&b);
	for(i = 0;i < strlen(b) + 1;i++)
	{
		if(b[i] == 'A'|| b[i] == 'C'|| b[i] == 'G'|| b[i] == 'T')
		coun++;
		else{
			if(coun >= max){
				max = coun;
				coun = 0;
			}
			}
		}
		printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            x, y, s = map(int, raw_input().split())
            if x == 0 and y == 0 and s == 0:
                break
            before = [None] * 1001
            after = [None] * 1001
            for i in range(1, 1001):
                before[i] = i * (100 + x) / 100
                after[i] = i * (100 + y) / 100
            ans = -1
            for i in range(1, s):
                for j in range(i, s):
                    if before[i] + before[j] == s and ans < after[i] + after[j]:
                        ans = after[i] + after[j]
            
            # for a in range(1, 1001):
            #     b = 1001 - a
            #     if before[a] + before[b] == s and ans < after[a] + after[b]:
            #         ans = after[a] + after[b]
            print ans
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

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

int main() {
  
  int n;
  cin >> n;
  
  double x;
  string u;
  double goukei = 0;
  
  for ( int i = 0; i < n ; i++){
    cin >> x >> u;
    if ( u == "JPY" ){
      goukei += x;
    }else{
      goukei += x * 380000;
    }
  }
  
  cout << fixed << setprecision(7) << goukei << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll double
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
 
ll dp[301][301][301];
ll solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;
 
    if(dp[one][two][three] > 0)
        return dp[one][two][three];
 
    int remaining = one + two + three;
    ll exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                    three*solve(one,two+1,three-1,n);
 
    return dp[one][two][three] = exp_val/remaining;
}
 
int main(){
    int i,j,t,n,m,p,k;
    //fast_io;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        int one=0,two=0,three=0;
 
        fr(0,n){
            int x;
            cin >> x;
            if(x == 1)one++;
            else if(x == 2)two++;
            else three++;
        }
 
        memset(dp, -1, sizeof dp);
        cout<<fixed<<setprecision(9)<<solve(one,two,three,n);
    }
    return 0;
}

Measured memory_bytes: 216868
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S,T; cin >> S >> T;
    int A,B; cin >> A >> B;
    string U; cin >> U;
    if(S==U) cout << A-1 << " " << B << endl;
    else cout << A << " " << B-1 << endl;
}

Measured memory_bytes: 256
N = int(input())
A = input().split()

def bubble_sort(A):
    for i in range(0, N):
        for j in range(i+1, N)[::-1]:
            if int(A[j][1]) < int(A[j-1][1]):
                A[j], A[j-1] = A[j-1], A[j]
    return A

def selection_sort(A):
    for i in range(0, N):
        min_i = i
        for j in range(i+1, N):
            if int(A[j][1]) < int(A[min_i][1]):
                min_i = j
        A[i], A[min_i] = A[min_i], A[i]
    return A

BA = bubble_sort(A[:])
SA = selection_sort(A[:])

print(' '.join([str(i) for i in BA]))
print('Stable')
print(' '.join([str(i) for i in SA]))
print('Stable' if SA == BA else 'Not stable')

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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

// ***************************************



int main()
{
	int sign = 1;

	string tmp;
	
	cin >> tmp;
	deque<char> S;
	for (auto c : tmp) {
		S.push_back(c);
	}
	int Q;
	cin >> Q;
	
	REP(i, Q) {
		int T;
		cin >> T;
		if (T == 1) {
			sign *= -1;
			continue;
		}
		else {
			int F;
			char C;
			cin >> F >> C;
			F = (F == 1) ? 1 : -1;
			
			if (F * sign == 1) {
				S.push_front(C);
			}
			else {
				S.push_back(C);
			}
		}
	}

	if (sign == -1) {
		reverse(ALL(S));
	}
	for (auto& c : S) {
		cout << c;
	}
	cout << endl;

	return 0;
}

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

using namespace std;

int main(void)
{
	int n; cin>>n;
	int a[n]; 
	long long kosuu[n];
	for(int i = 0; i < n; i++){
		cin>>a[i];
		kosuu[i] = 0;
	}
	for(int i = 0; i < n; i++){
		kosuu[a[i]-1]++;
	}
	unsigned long long ans = 0;
	for(int i = 0; i < n; i++){
		if(kosuu[i] > 1){
			ans += (kosuu[i] * (kosuu[i]-1) / 2);
		}
	}
	
	unsigned long long w;
	//cout<<"ans = "<<ans<<endl;
	for(int i = 0; i < n; i++){
		w = ans;
		if(kosuu[a[i]-1] > 1){
			w-=(kosuu[a[i]-1] * (kosuu[a[i]-1]-1) /2);
			w+=((kosuu[a[i]-1]-1)*(kosuu[a[i]-1]-2)/2);
		}
		cout<<w<<endl;
	}
	return 0;
}



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

int main(int argc,char *argv[]){
	int count;
long int max,min,sum = 0;
	long int n;
	cin >> count;
	if (count--){
		cin >> n;
		sum += n;
		max = n;
		min = n;	
	} 
	while(count--){
		cin >> n;
		sum += n;
		if (max < n) {
			max = n;
		}
		if (min > n) {
			min = n;
		}	
	}
	cout << min << " " << max << " " << sum << "\n";
	return 0;
}

Measured memory_bytes: 3080
// finish date: 2018/01/22
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    int a;
    rep(i, N) {
        cin >> a;
        mp[min(8, a / 400)]++;
    }
    int mi, ma;
    mi = mp.size() - ((mp.count(8)) ? 1 : 0);
    ma = mi + mp[8];
    if (mi == 0) mi = 1;

    cout << mi << " " << ma << endl;

    return 0;
}



Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]
total = [0] * N
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        total[i] = total[i-1] + 1
    else:
        total[i] = total[i-1]
for i in range(Q):
    print(total[lr[i][1]-1] - total[lr[i][0]-1])


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

int main(int argc, const char * argv[])
{
  
    int num;
    char blood[3];
    int suma = 0, sumb = 0, sumab = 0, sumo = 0;
    
    while (scanf("%d, %s", &num ,blood) != EOF) {
        if (!strcmp(blood, "A")) {
            suma++;
        } else if (!strcmp(blood, "B")) {
            sumb++;
        } else if (!strcmp(blood, "O")) {
            sumo++;
        } else if (!strcmp(blood, "AB")) {
            sumab++;
        }
    }
    
    printf("%d\n%d\n%d\n%d\n", suma, sumb, sumab, sumo);
    
    return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define LL long long
#define mod 1000000007
#define G() Cr=getchar()
LL Xr;char Cr;
inline LL rd(){   //读入优化
    Xr=0,G();
    while(Cr<'0'||Cr>'9')G();
    while(Cr>='0'&&Cr<='9')Xr=(Xr<<3)+(Xr<<1)+Cr-'0',G();
    return Xr;
}
#define MAX_N 100005
int X,Y,A,B,C;
LL a[MAX_N],b[MAX_N],c[MAX_N];
LL ans;
int la,lb;
bool comp(int x,int y){
	return x>y;
}
int main(){
	scanf("%d%d%d%d%d",&X,&Y,&A,&B,&C);
	for(int i=1;i<=A;i++)a[i]=rd();
	for(int i=1;i<=B;i++)b[i]=rd();
	for(int i=1;i<=C;i++)c[i]=rd();
	sort(a+1,a+1+A,comp);
	sort(b+1,b+1+B,comp);
	sort(c+1,c+1+C,comp);
	la=X,lb=Y;
	for(int i=1;i<=C;i++){
		if(la>=1){
			if(a[la]<c[i]&&(a[la]<=b[lb]||lb<1)){
				a[la--]=c[i];
				continue;
			}
		}
		if(lb>=1){
			if((b[lb]<a[la]||la<1)&&b[lb]<c[i])b[lb--]=c[i];
		}
	}
	for(int i=1;i<=X;i++)ans+=a[i];
	for(int i=1;i<=Y;i++)ans+=b[i];
	cout<<ans;
}

Measured memory_bytes: 2560
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
typedef long long int64;

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


int N, M;
int a[1050], b[1050], c[1050][20];

void input() {
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        cin >> a[i] >> b[i];
        for(int j = 1; j <= b[i]; j++) cin >> c[i][j];
    }
}

int main() {
    input();
    const int INF = 1e9;
    vector<int> dp(5000, INF);
    dp[0] = 0;
    for(int item = 1; item <= M; item++) {
        int now = 0;
        for(int j = 1; j <= b[item]; j++) {
            now |= (1 << (c[item][j] - 1));
        }
        for(int bits = 0; bits < (1 << N); bits++) {
            int tmp = min(dp[bits | now], dp[bits] + a[item]);
            dp[bits | now] = tmp;
            //chmin(dp[bits | now], dp[bits] + a[item]);
        }
    }
    if(dp[(1 << N) - 1] == INF) dp[(1 << N) - 1] = -1;
    cout << dp[(1 << N) - 1] << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>

#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

using namespace std;


int main(int argc, char const *argv[]){
    int n,ans=0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if((int(log10(i))%2)==0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
    using namespace std;
    #define el "\n"
    #define ll long long
    #define ull unsigned long long long
    #define pb push_back
    #define mp make_pair
    #define X first
    #define Y second
    #define M 1000000007
    #define all(v) v.begin(), v.end()
    ll _lcm(ll a,ll b){
        return (a*b)/(__gcd(a,b));
    }
    int main() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll n;
      cin>>n;
      ll a[n]={0},lcm=1;
      for(int i=0;i<n;i++){
          cin>>a[i];
          lcm=_lcm(lcm,a[i]);
      }
      long double ans=0,tmp=0;
      for(int i=0;i<n;i++){
          tmp+=(lcm/a[i]);
      }
      cout<<setprecision(15)<<lcm/tmp<<el; 
      return 0;
    }


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**5)

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

def func(x, n):
    if n == 0:
        return 1
    if x <= 1:
        return 0
    elif 2 <= x <= 2**(n+1)-2:
        return func(x-1, n-1)
    elif x == 2**(n+1)-1:
        return 2**n-1+1
    elif 2**(n+1) <= x:
        return 2**n-1+1+func(x-(2**(n+1)-1), n-1)

print(func(x, n))


Measured memory_bytes: 38384
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

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


const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

const int ALPHABET = 26;

int main() {
	string s, t;
	cin >> s >> t;

	int cnt = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			cnt++;
		}
	}

	cout << cnt << endl;

}

Measured memory_bytes: 3908
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int k,n,m=0,i;cin>>k>>n;
int  a[n];for(i=0;i<n;i++) cin>>a[i];
for(i=0;i<n;i++)
{
	if(i==n-1) m=max(m,k-a[i]+a[0]);
	else m=max(m,a[i+1]-a[i]);
}
cout<<k-m;

return 0;
}

Measured memory_bytes: 1024
n = int(input())
t,a = map(int,input().split())
lst = list(map(int,input().split()))

ans = 0
for i in range(n):
    tmp = t - lst[i]*0.006
    dst = abs(a-tmp)
    if i == 0:
        val = dst
    elif dst < val:
        ans = i
        val = dst
print(ans+1)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>

using namespace std;


int main()
{
  double a, b, c, h, s, l;
  cin >> a >> b	>> c;
  h = sin(c / 360.0 * 2 * M_PI) * b;
  s = a	* h / 2.0;
  l = a	+ b + sqrt(pow(h, 2) + pow(a - cos(c / 360 * 2 * M_PI) * b, 2));
  printf("%lf\n%lf\n%lf\n", s, l, h);
  return 0;
}

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

int main(void){
   string s;
   cin>>s;
   set<char> dict;
   for(int i=0;i<s.size();i++){
      dict.insert(s[i]);
   }
   if(dict.size()==s.size()) cout<<"yes"<<endl;
   else cout<<"no"<<endl;
}



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

long long n, k, M=1e9+7, c[2005][2005];
int main() {
	cin >> n >> k;
	int i, j;
	for(i=0; i<=n; i++) {
		c[i][0] = 1;
		for(j=1; j<=i; j++) c[i][j] = (c[i-1][j-1] + c[i-1][j]) % M;
	}
	for(i=1; i<=k; i++) cout << c[n-k+1][i] * c[k-1][i-1] % M << endl;
	return 0;
}

Measured memory_bytes: 30208
#include<stdio.h>
int main(){
  int x,y,d,n;
  scanf("%d %d",&x,&y);
  if(x<y){
    n=x;
    x=y;
    y=n;
  }
  d = x%y;
  while(d!=0){
    x=y;
    y=d;
    d=x%y;
  }
  printf("%d\n",y);
  return 0;
}



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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

using namespace std;

void InpAr(int *array, int n){
    REP(i,n) cin >> array[i];
}

int main(void){
    ll A, B, K;
    cin >> A >> B >> K;
    if(A <= K){
        cout << "0" << " ";
        if(B >= K - A) cout << B - K + A;
        else cout << "0";
    } else{
        cout << A - K << " " << B;
    }
    
    return 0;
}

Measured memory_bytes: 256
a, b, c, d = input()
kigou = ["+", "-"]
for i in range(8):
    bin_str = str(format(i, 'b').rjust(10, '0'))
    soeji_01 = int(bin_str[-1])
    soeji_02 = int(bin_str[-2])
    soeji_03 = int(bin_str[-3])
    shiki = "" + a + kigou[soeji_01] + b + \
        kigou[soeji_02] + c + kigou[soeji_03] + d
    if eval(shiki) == 7:
        print(shiki+"=7")
        exit()

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

N = int(input())

SP = [input().split() for i in range(N)]
SP = [[sp[0], int(sp[1]), i+1] for i, sp in enumerate(SP)]
SP.sort(key=lambda x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])
for sp in SP:
    print(sp[2])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string S;
        cin >> S;
            if(S == "SAT"){
                cout << 1 << endl;
            }else if(S == "FRI"){
                cout << 2 << endl;
            }else if(S == "THU"){
                cout << 3 << endl;
            }else if(S == "WED"){
                cout << 4 << endl;
            }else if(S == "TUE"){
                cout << 5 << endl;
            }else if(S == "MON"){
                cout << 6 << endl;
            }else if(S == "SUN"){
                cout << 7 << endl;
            }
        return 0;
    }

Measured memory_bytes: 768
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!ptrdiff_t;
  auto a = readln.split.to!(int[]);

  if (n == 1) {
    write(a[0]);
  } else if (n % 2 == 0) {
    for (auto i = n-1; i >= 1; i -= 2) write(a[i], " ");
    for (auto i = 0; i <= n-2; i += 2) write(a[i], i == n-2 ? "" : " ");
  } else {
    for (auto i = n-1; i >= 0; i -= 2) write(a[i], " ");
    for (auto i = 1; i <= n-2; i += 2) write(a[i], i == n-2 ? "" : " ");
  }

  writeln;
}


Measured memory_bytes: 12144
N = int(input())
A = map(int, input().split())
D = [[0, 0] for _ in range(60)]

for a in A:
    for i in range(60):
        if (a >> i) & 1:
            D[i][1] += 1
        else:
            D[i][0] += 1

ans = 0
mod = 10 ** 9 + 7

for idx, d in enumerate(D):
    ans = (ans + (d[0] * d[1] * (1 << idx))) % mod

print(ans)

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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  int j=1;
  for(int i=0;i<N;i++){
    cin>>a[i];
    if(a[i]==j)
      j++;
  }
  if(j==1)
    cout<<-1;
  else
    cout<<N-j+1<<endl;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		List<Integer> sums = new ArrayList<Integer>();
		for(;;){
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		}

		for(int m : sums){
			System.out.println(m);
		}
	}
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class CSuccessiveSubtraction {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<int> a(n, 0);
        vector<int> neg, pos;
        rep(i, n){
            in >> a[i];
            if(a[i] >= 0) pos.push_back(a[i]);
            else neg.push_back(a[i]);
        }

        if(pos.size() == 0){
            sort(all(neg));
            pos.push_back(neg[neg.size()-1]);
            neg.erase(neg.begin() + neg.size() - 1);
        }
        if(neg.size() == 0){
            sort(all(pos));
            neg.push_back(pos[0]);
            pos.erase(pos.begin());
        }

        ll res = neg[0];
        vector<pair<int, int>> resv;
        rep(i, pos.size() - 1){
            resv.push_back(make_pair(res, pos[i]));
            res = res - pos[i];
        }
        resv.push_back(make_pair(pos[pos.size()-1], res));
        res = pos[pos.size()-1] - res;
        reps(i, 1, neg.size()-1){
            resv.push_back(make_pair(res, neg[i]));
            res = res - neg[i];
        }

        out << res << endl;
        for(auto const& e : resv){
            out << e.first sp e.second << endl;
        }
    }
};


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


Measured memory_bytes: 3828
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N, M;

	cin >> N >> M;

	int A[M];

	for(int i=0; i<M;i++){
		A[i] = 0;
	}

	for(int i=0; i<N;i++){
		int k;
		cin >> k;
		for(int j=0; j<k; j++){
			int x;
			cin >> x;
			A[x-1]++;
		}
	}

	int ans = 0;

	for(int i=0; i<M; i++){
		if(A[i] == N) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#if _MSC_VER
#include <iostream>
#else
#include <bits/stdc++.h>
#endif

// Wrong answer...

int main()
{
	uint64_t A;
	double B;

	std::cin >> A >> B;

	uint64_t temp = std::round(B * 100);
	uint64_t ans = (A * temp) / 100;
	std::cout << ans;
	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main(){
    int H,W;
    while (cin >> H >>W){
        if (H==0 && W==0)
            break;
        for (int i=0 ;i<W; i++)
            cout << "#" ;
        cout << endl;
        for (int i=0 ;i<H-2; i++){
            cout << "#" ;
            for (int j=0; j<W-2; j++)
                cout << "." ;
            cout << "#" << endl ;
        }
        for (int i=0 ;i<W; i++)
            cout << "#" ;
        cout << endl << endl;
    }
}

Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

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

	string s, t;
	cin >> s >> t;
	int n = s.size();
	for (int i=0;i<n;++i) {
		if (s[i] != t[i]) {
			cout << "No\n";
			return 0;
		}
	}
	if (t.size() == n + 1) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!
    val b = readLine()!!
    val c = readLine()!!
    val count = checkDiff(a, b, c)

    print(count)
}

fun checkDiff(a: String, b: String, c: String): Int {
    var count = 0

    a.forEachIndexed { index: Int, char: Char ->
        val matchAB = char == b[index]
        val matchAC = char == c[index]
        val matchBC = b[index] == c[index]

        val abc = matchAB && matchAC && matchBC
        val ab = matchAB && !matchAC && !matchBC
        val ac = !matchAB && !matchAC && matchBC
        val bc = !matchAB && matchAC && !matchBC

        count += when {
            abc -> 0
            ab -> 1
            ac -> 1
            bc -> 1
            else -> 2
        }
    }

    return count
}

Measured memory_bytes: 33680
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

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

bool cmp(ii a, ii b) {
  if(a.second == b.second) return (a.first < b.first);
  else return (a.second < b.second);
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
  int N,A,B;
  vii jobs;
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d %d", &A, &B);
    jobs.pb(mp(A, B));
  }
  sort(jobs.begin(), jobs.end(), cmp);
  ll curTime = 0;
  bool can = true;
  for(int i = 0; i < N; i++) {
    curTime += (ll) jobs[i].first;
    if(curTime > (ll) jobs[i].second) can = false;
  }
  cout <<(can ? "Yes" : "No") <<endl;
  return 0;
}


Measured memory_bytes: 2420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni();
            int[][] a = new int[n][3];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 3; j++) {
                    a[i][j] = in.ni();
                }
            }
            int[][] dp = new int[n + 1][3];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        if (j != k) {
                            dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][k] + a[i][j]);
                        }
                    }
                }
            }
            int max = 0;
            for (int i = 0; i < 3; i++) {
                max = Math.max(max, dp[n][i]);
            }
            out.println(max);

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

    }
}



Measured memory_bytes: 50272
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define rrep(i,a) for(int i=a; i>=0; --i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    rep(i,N) cin>>a[i];
    vector<int> cnt(9,0);
    rep(i,N){
        if(a[i]<400){
            cnt[0]++;
        }else if(400<=a[i]&&a[i]<800){
            cnt[1]++;
        }else if(800<=a[i]&&a[i]<1200){
            cnt[2]++;
        }else if(1200<=a[i]&&a[i]<1600){
            cnt[3]++;
        }else if(1600<=a[i]&&a[i]<2000){
            cnt[4]++;
        }else if(2000<=a[i]&&a[i]<2400){
            cnt[5]++;
        }else if(2400<=a[i]&&a[i]<2800){
            cnt[6]++;
        }else if(2800<=a[i]&&a[i]<3200){
            cnt[7]++;
        }else{
            cnt[8]++;
        }
    }
    int ans=0;
    rep(i,8){
        if(cnt[i]) ans++;
    }
    if(ans==0) cout<<"1 "<<cnt[8]<<endl;
    else cout<<ans<<" "<<ans+cnt[8]<<endl;
}

Measured memory_bytes: 256
# 入力
N = int(input())
[T,A] = list(map(int, input().split()))
H = list(map(int, input().split()))

# 処理
ans_idx = -1  # 答えとなる地点のインデックス
ans_t   = -1  # 答えとなる地点の気温
for i in range(N):
  t = T - H[i]*0.006  # i番目の地点の気温
  if ans_idx < 0 or abs(t-A) < abs(ans_t-A):
    ans_idx = i
    ans_t = t

# 答え
print(ans_idx+1)

Measured memory_bytes: 3064