akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define NOT_FOUND -1

int binarySearch(int array[], int length, int key) {
    int left = 0;
    int right = length;
    int mid;
    
    while (left < right) {
        mid = (left + right)/2;
        
        if (key == array[mid])
            return mid;
        if (key > array[mid])
            left = mid +1;
        else
            right = mid;
    }
    
    return NOT_FOUND;
}

int main(int argc, char** argv) {
    int nNumbers;
    
    // set S
    scanf("%d", &nNumbers);
    
    const int nS = nNumbers;
    int S[nS];
    
    for (int iS = 0; iS < nS; iS++)
        scanf("%d", &S[iS]);
    
    // set T
    scanf("%d", &nNumbers);
    
    const int nT = nNumbers;
    int T[nT];
    
    for (int iT = 0; iT < nT; iT++)
        scanf("%d", &T[iT]);
    
    // do the magic
    int nIntersect = 0;
    for (int iT = 0; iT < nT; iT++)
        if (binarySearch(S, nS, T[iT]) != NOT_FOUND) 
            nIntersect++;
    
    printf("%d\n", nIntersect);

    return (EXIT_SUCCESS);
}




Measured memory_bytes: 2332
N, M = map(int, input().split())
cla = [i for i in range(N)]
count = set()
def root(a):
    change = []
    while cla[a] != a:
        change.append(a)
        a = cla[a]
    for i in change:
        cla[i] = a
    return a
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if root(a) != root(b):
        cla[root(b)] = root(a)
for i in range(N):
    count |= {root(i)}
print(len(count) - 1)

Measured memory_bytes: 76432
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>
#define all(n) n.begin(),n.end()
#define forr(i,a,b) for(i=a;i<b;i++)
#define forrr(i,a,b) for(i=b-1;i>=a;i--)


 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll t;
    t=1;
    while(t--){
      string s;
      cin>>s;
      if(s[s.length()-1]=='s') cout<<s<<"es";
      else cout<<s<<"s"<<endl;


        }
   
return 0;    
 }  

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 1e18;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> y(n);
    rep(i, n) cin >> x[i] >> y[i];

    vector<ll> cx(n);
    vector<ll> cy(n);
    rep(i, n) {
        cx[i] = x[i] - y[i];
        cy[i] = x[i] + y[i];
    }

    sort(cx.begin(), cx.end());
    sort(cy.begin(), cy.end());
    ll ans = max(cx[n - 1] - cx[0], cy[n - 1] - cy[0]);
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N; cin >> N;
    vector<int> C(N-1), S(N-1), F(N-1);
    for(int i = 0; i < N - 1; i++) cin >> C[i] >> S[i] >> F[i] ;

    for(int i = 0; i < N - 1; i++){
        int t = 0;
        for(int j = i; j < N - 1; j++){
            if(S[j] >= t){
                t += (S[j] - t) + C[j];
            }else{
                int k = (t - S[j]) / F[j];
                if((t - S[j]) % F[j] == 0){
                    t += C[j];
                }else{
                    t += C[j] + ((k + 1) * F[j] + S[j] - t);
                }
            }
        }
        cout << t << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A[100000], B[200000];
int main(){
  int M, N, Q5VJL1cS, e98WHCEY;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<2*M;Lj4PdHRW++){
      rd(B[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<(2*M-1) + 1;KL2GvlyY++){
      A[B[KL2GvlyY]-1]^=1;
    }
  }
  if(N==0){
    e98WHCEY = 0;
  }
  else{
    e98WHCEY = A[0];
    for(Q5VJL1cS=1;Q5VJL1cS<N;Q5VJL1cS++){
      e98WHCEY += A[Q5VJL1cS];
    }
  }
  if(e98WHCEY==0){
    wt_L("YES");
    putchar_unlocked('\n');
  }
  else{
    wt_L("NO");
    putchar_unlocked('\n');
  }
  return 0;
}
// cLay varsion 20170506-1 [beta]

// --- original code ---
// int A[100000], B[200000];
// {
//   int N, M;
//   rd(N,M,B(2*M));
//   A[B[0..2*M-1]-1]^=1;
//   if(sum(A(N))==0) wt("YES"); else wt("NO");
// }


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

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

  int a, b, c, cnt=0;
  cin >> a >> b >> c;

  if(a%2==b%2&&a%2!=c%2){
    a+=1;
    b+=1;
    cnt++;
  }
  else if(b%2==c%2&&a%2!=b%2){
    b+=1;
    c+=1;
    cnt++;
  }
  else if(c%2==a%2&&b%2!=c%2){
    c+=1;
    a+=1;
    cnt++;
  }

  int m=a;
  m=max(m, b);
  m=max(m, c);
  if(m==a){
    cnt+=(2*a-c-b)/2;
  }
  else if(m==b){
    cnt+=(2*b-c-a)/2;
  }
  else cnt+=(2*c-a-b)/2;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
	string s1,s2;
	cin>>s1>>s2;
	int l1=s1.length();
	int l2=s2.length();
	int arr[l1+1][l2+1];
	for(int i=0;i<=l1;i++)
	{
		for(int j=0;j<=l2;j++)
		{
			arr[i][j]=0;
		}
	}
	for(int i=1;i<=l1;i++)
	{
		for(int j=1;j<=l2;j++)
		{
			if(s1[i-1]==s2[j-1])
			{
				arr[i][j]=arr[i-1][j-1]+1;
			}
			else
			{
				arr[i][j]=max(arr[i][j-1],arr[i-1][j]);
			}
		}
	}
	// for(int i=0;i<=l1;i++)
	// {
	// 	for(int j=0;j<=l2;j++)
	// 	{
	// 		cout<<arr[i][j]<<' ';
	// 	}
	// 	cout<<endl;
	// }
	string ans;
	int i,j;
	for(i=l1,j=l2;i>0&&j>0;)
	{
		if(s1[i-1]==s2[j-1])
		{
			ans+=s1[i-1];
			i--;
			j--;
		}
		else
		{
			if(arr[i-1][j]>arr[i][j-1])
			{
				i--;
			}
			else
			{
				j--;
			}
		}
	}
	for(i=0;i<ans.length()/2;i++)
	{
		swap(ans[i],ans[ans.length()-i-1]);
	}
	cout<<ans<<endl;
}

int main()
{
	int t;
	t=1;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 35456
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100005
#define LL long long
int n,k;
LL s[MAXN],sum[MAXN];
#define INF 0x7fffffffffffffff
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		s[i]=s[i-1]+x;
		if(x>0) sum[i]=sum[i-1]+x;
			else sum[i]=sum[i-1];
	}
	LL ans=-INF;
	for(int i=1;i<=(n-k+1);i++)
	{
		LL res=0;
		int j=i+k-1;
		if(s[j]-s[i-1]>0/*注意有值和大于0是有区别的*/) res+=s[j]-s[i-1];
		res+=sum[i-1]-s[0];
		res+=sum[n]-sum[j];
		ans=max(ans,res);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	
	
	public static void main(String[] args) {
	int n=sc.nextInt();
	String s=""+n;
	int t=s.length();
	int nn[][]=new int[9][9];
	long ans=0;
	//t-1桁までは固定
	//1桁の時9
	//2桁の時81
	//3桁の時729
	//4桁の時656
	String tmp;
	for(int i=1;i<=n;i++) {
		if(i%10==0)continue;
		tmp=Integer.toString(i);
		//p(i);
		int a=tmp.charAt(0)-49;
		int b=tmp.charAt(tmp.length()-1)-49;
		nn[a][b]++;
	}
	//1 0(2 1)
	for(int a=0;a<9;a++) {
		for(int b=0;b<9;b++) {
			int ttt=0;
			//p(a+"      "+b);
			//p("nn"+nn[a][b]);
			ans+=nn[a][b]*nn[b][a];
			ttt+=nn[a][b]*nn[b][a];
			//p(a+"       "+b+"        "+ttt);
		}
	}
	p(ans);
	//2桁=2つ
	//３桁=18こ
	
	
	/*for(int a=1;a<=n;a++) {
		tmp1=""+a;
		for(int b=1;b<=n;b++) {
			tmp2=""+b;
			if(tmp1.charAt(0)==tmp2.charAt(tmp2.length()-1)) {
				if(tmp2.charAt(0)==tmp1.charAt(tmp1.length()-1)) {
					p(a+"     "+b);
					ans++;
				}
			}
		}
	}*/
	
 }
	static int dfs(int n) {
		int sss[]= {1,1,9,81,729};
		n--;
		if(n==0) {
			return 1;
		}
		
		
		return sss[n]+dfs(n);
	}
	static int Nc2(int v) {
		if(v-1<=0)return 0;
		return v*(v-1)/2;
	}
}


Measured memory_bytes: 31168
// https://atcoder.jp/contests/abc084/tasks/abc084_d

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

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
ll lcm(long a, long b) { return a * b / gcd(a, b); }

int dp[100001];
bool isPrime(int 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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    REP(i, n) cin >> l[i] >> r[i];
    for (int i = 1; i <= 100000; i++) {
        dp[i] = dp[i - 1] + (isPrime(i) & isPrime((i + 1) / 2));
    }

    for (int i = 0; i < n; i++) {
        cout << dp[r[i]] - dp[l[i] - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll A,B,C;
  cin>>A>>B>>C;
  if(A-B==C||B-A==C) printf("Yes\n");
  else if(C-A==B||A-C==B) printf("Yes\n");
  else if(C-B==A||B-C==A) printf("Yes\n");
  else cout<<"No"<<endl;
  return 0;
}
	

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main() {
    ll a, b, n;
    cin >> n;
    ll p = 1;
    REP(i, n) {
        p *= (i+1);
        p %= MOD;
    }
    cout << p << endl;

}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=100000000000000007;
const int MOD=998244353;
signed main(){
  int n,s;cin>>n>>s;
  vector<vector<vector<int>>> dp(3,vector<vector<int>>(3005,vector<int>(3005,0)));
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  dp[1][0][a[0]]=1;
  dp[1][0][0]=1;
  rep1(i,n-1){
    dp[1][i-1][0]++;
    rep(j,3005){
      dp[1][i][j]=dp[1][i-1][j];
      dp[2][i][j]=dp[2][i-1][j];
      if(j>=a[i]){
        dp[1][i][j]+=dp[1][i-1][j-a[i]];
        dp[1][i][j]%=MOD;
        dp[2][i][j]+=dp[1][i-1][j-a[i]]*(n-i);
        dp[2][i][j]%=MOD;
      }
    }
  }
  cout<<dp[2][n-1][s]<<"\n";
  return 0;
}


Measured memory_bytes: 282880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

void solve(){
    int a; cin >> a;
    cout << a + a*a + a*a*a << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3644
package main

import (
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	if false {
		test()
	} else {
		fmt.Println(solve(os.Stdin))
	}
}

func solve(r io.Reader) string {
	var h int
	var w int
	fmt.Fscanln(r, &h, &w)

	for i := 1; i <= h; i++ {
		for j := 0; j < w; j++ {
			var s string
			fmt.Fscan(r, &s)
			if s == "snuke" {
				return fmt.Sprintf("%s%d", string([]byte{byte(65 + j)}), i)
			}
		}
	}

	return ""
}

func test() {
	tests := []struct {
		in   string
		want string
	}{
		{
			in: `15 10
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snuke snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake
snake snake snake snake snake snake snake snake snake snake`,
			want: "H6",
		},
		{
			in: `1 1
snuke`,
			want: "A1",
		},
	}
	for i, tt := range tests {
		if got := solve(strings.NewReader(tt.in)); got != tt.want {
			fmt.Printf("%d: got %v, want %v\n", i, got, tt.want)
		}
	}
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        if (h >= k)
            ans++;
    }
    cout << ans << "\n";
    return 0;
}

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

int main(void) {
    int N,M,X; cin >> N >> M >> X;
    int A[15][15] = {};
    int C[15] = {};
    ll ans = 1e9;

    for(int i=0; i<N; i++) {
        cin >> C[i];
        for(int j=0; j<M; j++) {
            cin >> A[i][j];
        }
    }

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<N); ++bit) {
        int alg[15] = {};
        ll value = 0;
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }

        for (int i = 0; i < (int)S.size(); ++i) {
            bool judge = true;
            value += C[S[i]];
            for(int j=0; j<M; j++) {
                alg[j] += A[S[i]][j];
                if(alg[j]<X) judge = false;
            }
            if(judge) {
                if(ans > value) ans = value;
            }
        }
    }
    if(ans == 1e9) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string N;
  cin >> N;

  for(int i=0;i<sz(N);i++){
    if(N.at(i)=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define M 20000

int main(void){
    int tx,ty;
    string s;
    cin>>s>>tx>>ty;
    s += "T";
    int init = s.find("T",0);
    tx -= init;
    s = string(s.begin()+init, s.end());
    bitset<M*2> dp[2];
    dp[0][M] = dp[1][M] = 1;
    int cnt = 0, mode = 0;
    for(char c : s){
        if(c=='F') cnt++;
        else{
            dp[mode] = (dp[mode]<<cnt) | (dp[mode]>>cnt);
            cnt = 0;
            mode = !mode;
        }
    }
    cout<<((dp[0][M+tx] && dp[1][M+ty]) ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 256
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp.split.map{|v| v.to_i }
end

N = attrs.shift[0]
A = attrs.shift

h = Hash.new

has_same_num = false

for i in 0...N do
  has_same_num = true if ! h[A[i]].nil?
  h[A[i]] = i if h[A[i]].nil?
end
  
if has_same_num then
  puts "NO"
else
  puts "YES"
end

Measured memory_bytes: 30852
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string str,kaku[3]={"the","this","that"};
    while(getline(cin,str)){
        while(1){
            for(int i=0;i<str.size();i++){
                if('A'<=str[i]&&str[i]<='Y')str[i]++;
                else if(str[i]=='Z')str[i]-=25;
                else if('a'<=str[i]&&str[i]<='y')str[i]++;
                else if(str[i]=='z')str[i]-=25;
            }
            for(int i=0;i<3;i++){
                if(str.find(kaku[i])!=string::npos)goto exit;
            }
        }
    exit:
        cout<<str<<endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//素因数分解
map<ll, ll> prime_factor(ll n)
{
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++)
	{
		while (n % i == 0)
		{
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1)
		ret[n] = 1;
	return ret;
}

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2 != 0)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << (s.substr(0,n / 2) == s.substr(n / 2, n / 2) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
\
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;


int main() {
    int n,m,a,b;
    int ans[51];
    cin >> n >> m;

    REP(i,51) ans[i] = 0;

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

    for(int i = 1; i <=  n; i ++){
        cout << ans[i] << endl;
    }
}







Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    vector<char> res(10);
    int cur = 0;
    rep(i, s.size()) {
        if(s[i] == '0') {
            res[cur] = '0';
            cur++;
        } else if(s[i] == '1') {
            res[cur] = '1';
            cur++;
        } else {
            cur = max(0, cur - 1);
        }
    }
    rep(i, cur) { cout << res[i]; }
    cout << endl;
    return 0;
}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const ll N = (ll)1e5+7;
const ll inf = (ll) 1e9+7;
const ll mod = (ll) 998244353;
const ld pi = acos(-1);

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

ll pick(ll x, ll a, ll b) {
    return max(abs(x - a), abs(x - b));
}

int main() {
    fast;
    ll n, m, a[N];
    cin >> n;
    for1(i, n) cin >> a[i];
    sort(a + 1, a + n + 1);
    ll ans = a[n] - a[1];
    ll l = 2, r = n - 1;
    ll x = a[1], y = a[n];
    while (l <= r) {
        if (pick(x, a[l], a[r]) >= pick(y, a[l], a[r])) {
            if (abs(x - a[l]) >= abs(x - a[r])) {
                ans += abs(x - a[l]);
                x = a[l];
                l++;
            } else {
                ans += abs(x - a[r]);
                x = a[r];
                r--;
            }
        } else {
            if (abs(y - a[l]) >= abs(y - a[r])) {
                ans += abs(y - a[l]);
                y = a[l];
                l++;
            } else {
                ans += abs(y - a[r]);
                y = a[r];
                r--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int M[N][N];
int color[N];
int d[N];
int f[N];
int tt;

//再帰関数によるDFS
void dfs_visit(int u)
{
    int v;
    color[u]=GRAY;
    d[u]=++tt;//最初の訪問

    for(v=0;v<n;v++)
    {
        if(M[u][v]==0) continue;
        if(color[v]==WHITE)
        {
            dfs_visit(v);
        }
    }

    //探索終了の記録
    //再帰初期のuほど遅く探索が終了する
    color[u]=BLACK;
    f[u]=++tt;
}

void dfs()
{
    int u;
    //初期化
    for(u=0;u<n;u++) color[u]=WHITE;
    tt=0;

    for(u=0;u<n;u++)
    {
        //未訪問のuを始点としてとしてDFS
        if(color[u]==WHITE) dfs_visit(u);
    }
    for(u=0;u<n;u++)
    {
        printf("%d %d %d\n",u+1,d[u],f[u]);
    }
}


int main()
{
    int u,v,k,i,j;

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

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

    dfs();
    return 0;
}


Measured memory_bytes: 3224
#include <iostream>

int c50(int x, int C){
    if(x % 50 == 0 && x / 50 <= C)
        return 1;
    else
        return 0;
}

int b100(int x, int B, int C){
    int cnt = 0;
    cnt = c50(x, C); // no 100yen coin
    int n = x/100;
    n = n > B ? B : n;
    for(int i = 0; i < n; i++){
        cnt += c50(x - ((i+1)*100), C);
    }
    return cnt;
}

int a500(int x, int A, int B, int C){
    int cnt = 0;
    cnt = b100(x, B, C); // no 500yen coin
    int n = x/500;
    n = n > A ? A : n;
    for(int i = 0; i < n; i++){
        cnt += b100(x - ((i+1)*500), B, C);
    }
    return cnt;
}

int main(int argc, char **argv)
{
    int A, B, C, X;
    std::cin >> A >> B >> C >> X;

    int cnt = a500(X, A, B, C);

    std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
import math as np
K=int(input())
s3=0
s2=0
s1=0
s0=0
for a in range(1,K-1):
    for b in range(a+1,K):
        d=np.gcd(a,b)
        for c in range(b+1,K+1):
            s0+=np.gcd(c,d)
for a in range(1,K):
    for c in range(a+1,K+1):
        s1+=np.gcd(a,c)
for a in range(1,K):
    for b in range(a+1,K+1):
        s3+=np.gcd(a,b)
for k in range(K+1):
    s2+=k
print(s0*6+s1*3+s3*3+s2)
        

            

Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}



signed main() {
	cout << "square1001" << endl;
}


Measured memory_bytes: 2940
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
		String str = in.nextLine();
		char[] charArray = str.toCharArray();
		for (int i = 0; i < charArray.length; i+=2) {
			System.out.print(charArray[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 30400
#include<iostream>
#include <string>
#include <algorithm>
#include<functional>
#include<vector>
using namespace std;


int main() {
	int sum[1000];
	int  n, count=0,x;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> sum[i];
		sort(sum, sum+n);
		reverse(sum,sum+n);
	}
	for (int j = 1;j < n;j++) {
		x = sum[0];
		count += sum[j];
	}
	if (x < count)
		cout << "Yes" << endl;
	else
	    cout << "No" << endl;
}

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

int main() {
	int n,d,i,j,k,ans=0,cur,res;
	cin >> n >> d;
	vector<vector<int>> x(n,vector<int>(d));
	for(i=0; i<n; i++){
		for(j=0; j<d; j++){
			cin >> x[i][j];
		}
	}
	for(i=0; i<n-1; i++){
		for(k=i+1; k<n; k++){
			cur=0;
			for(j=0; j<d; j++){
				cur+=(x[i][j]-x[k][j])*(x[i][j]-x[k][j]);
			}
			res=1;
			while(res*res<=cur){
				if(res*res==cur){
					ans++;
				}
				res++;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define int long long
#define endl '\n'
#define x first
#define y second
const int N = 1001;

vector<pair<int,int> > vp[2][2];
int n;
pair<int,int> po[N];
int ds(int x, int y){
	return x*x + y*y;
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0 ; i < n ; i ++){
		cin >> po[i].x >> po[i].y;
		vp[po[i].x <= 0][po[i].y <= 0].push_back(po[i]);
	}
	pair<int,int> rec = {0, 0};
	for(int i = 0 ; i < 2 ; i ++)
		for(int j = 0 ; j < 2 ; j ++){
			int _x = 0, _y = 0;
			for(pair<int,int> px: vp[i][j])
				_x += px.x, _y += px.y;
			if(ds(_x, _y) > ds(rec.x, rec.y)) rec = {_x, _y};
		}
	srand(time(NULL));
	int test = 10000;
	while(test --){
		random_shuffle(po, po + n);
		int _x = 0, _y = 0;
		for(int i = 0 ; i < n ; i ++)
			if(ds(_x + po[i].x, _y + po[i].y) > ds(_x, _y))
				_x += po[i].x, _y += po[i].y;
		if(ds(_x, _y) > ds(rec.x, rec.y)) rec = {_x, _y};
	}
	cout << setprecision(14) << sqrt(rec.x*rec.x + rec.y*rec.y) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	if (A <= C && C <= B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 2e3 + 10;
inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
namespace FastIO {
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
};
using namespace FastIO;
int N, K, dp[maxn][maxn], fac[maxn * maxn], ifac[maxn * maxn];
inline int exgcd(int a, int b, int& x, int& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    int d = exgcd(b, a % b, x, y);
    int tmp = y;
    y = x - a / b * y;
    x = tmp;
    return d;
}
inline int inv(int a, int b)
{
    int x, y;
    exgcd(a, b, x, y);
    return (x + MOD) % MOD;
}
inline int C(int m, int n)
{
    int tmp = (fac[m] * ifac[n] % MOD) * ifac[m - n] % MOD;
    return tmp;
}
signed main()
{
    //freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    N = read(), K = read();
    if (K == 1) {
        puts("1");
        return 0;
    }
    fac[0] = 1, ifac[0] = inv(1, MOD);
    for (ri i = 1; i <= N * K; ++i) {
        fac[i] = fac[i - 1] * i % MOD;
        ifac[i] = inv(fac[i], MOD);
    }
    dp[0][1] = 1;
    for (ri j = 2; j <= N; ++j) {
        dp[0][j] = dp[0][j - 1] * C(j * (K - 1) - 1, K - 2) % MOD;
    }
    for (ri i = 1; i <= N; ++i) {
        for (ri j = i; j <= N; ++j) {
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] * C(j * (K - 1) + i - 1, K - 2)) % MOD;
        }
    }
    dp[N][N] = (dp[N][N] * fac[N] % MOD);
    writeln(dp[N][N]);
    return 0;
}

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

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

using f32 = double;
using f64 = long double;

template <typename T> using Vec = vector<T>;
template <typename K, typename V> using HashMap = unordered_map<K, V>;
template <typename T> using HashSet = unordered_set<T>;

using StrView = string_view;

auto solve(i64 const K, StrView S) -> void {
  if (S.size() <= K) {
    cout << S << endl;
    return;
  }
  cout << S.substr(0, K) << "..." << endl;
}

auto main() -> int {
  i64 K;
  scanf("%lld", &K);
  string S;
  cin >> S;
  solve(K, S);
  return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, string>> a(m);
    set<int> ac;
    vector<int> wa(n);
    for(auto p : a ) {
        cin >> p.first >> p.second;
        if(p.second == "AC") ac.insert(p.first);
        else if (!ac.count(p.first)) wa[p.first - 1]++;
        else continue;
    } 
    int pena = 0;
    rep(i, n) {
        if(ac.count(i + 1)) pena += wa[i];
    }
    cout << ac.size() << ' ' << pena << endl;
}


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

const long double PI = 3.141592653589793;

int main(){
    long double a,b,x;
    cin >> a >> b >> x;
    long double S = x/a;
    if(a*b>=2*S){
        cout << fixed << setprecision(10) << atan2(b,2*S/b)*180/PI << endl;
    }else{
        cout << fixed << setprecision(10) << 90-atan2(a,2*(a*b-S)/a)*180/PI << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    string A, B, C;
    cin >> A >> B >> C;

    if(A.back() == B.front() && B.back() == C.front()) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
typedef long long int LL;
LL power(LL a, LL p){
	if(p==0) return 1;
	LL ret=power(a,p/2);
	ret*=ret;
	ret%=M;
	if(p%2) ret*=a;
	return ret%M;
}
int main(){
	int s;
	cin>>s;
	LL fact[s+1];
	fact[0]=1;
	for(LL i=1;i<=s;i++) fact[i]=fact[i-1]*i%M;
	LL ans=0;
	for(LL i=1;i<=s/3;i++){
		LL k=s-i*3;
		LL den=(fact[k]*fact[i-1])%M;
		LL nom=(fact[k+i-1]*power(den,M-2))%M;
		ans=(ans+nom)%M;
	}
	cout<<ans<<"\n";
}



Measured memory_bytes: 3500
times = gets.chomp.to_i
for t in 0..times-1
	nk = gets.chomp.split()
	n = nk[0].to_i
	k = nk[1].to_i

	ary = gets.chomp.split()

	margin = Array.new
	ary[0] = ary[0].to_i
	for i in 0..n-2
		ary[i+1] = ary[i+1].to_i
		margin.push(ary[i+1] - ary[i])
	end
	margin.sort!
	#p ary,margin,n,k
	sum = 0
	for j in 0..n-1-k
		sum += margin[j]
	end
	puts sum
end

Measured memory_bytes: 24620
#include <iostream>
using namespace std;
typedef long long ll;
ll h, w, n, c[200][200], a[21000];

void func(ll x, ll y, ll z){
    if (z == n + 1) return;
    
    if (a[z] == 0) {
        func(x, y, z + 1);
    } else if (x % 2 == 0) {
        if (y == w) {
            func(x + 1, w - 1, z);
        } else {
            c[x][y] = z;
            a[z]--;
            func(x, y + 1, z);
        }
    } else {
        if (y < 0) {
            func(x + 1, 0, z);
        } else {
            c[x][y] = z;
            a[z]--;
            func(x, y - 1, z);
        }
    }
    return;
}

int main(void){
    // Your code here!
    cin >> h >> w >> n;
    for (ll i = 1; i <= n; i++) cin >> a[i];
    func(0, 0, 1);
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            cout << c[i][j];
            if (j != w - 1) cout << ' ';
            else cout << endl;
        }
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5, INF = 0x3f3f3f3f, M = 1e9 + 7;

ll dp[64][2][2][2], L, R;
ll dfs(int now, bool l, bool r, bool bf) {
  if (now == -1) return 1;
  ll& ans = dp[now][l][r][bf];
  if (ans >= 0) return ans;
  ans = 0;
  bool ll = (L >> now) & 1, rr = (R >> now) & 1;
  for (int i = 0; i <= 1; i++) {
    for (int j = 0; j <= 1; j++) {
      if (l && i == 0 && ll) continue;
      if (r && j == 1 && !rr) continue;
      if (i > j) continue;
      if (!bf && (i != j)) continue;
      ans += dfs(now - 1, l & (i == ll), r & (j == rr), bf || i);
    }
  }
  ans %= M;
  return ans;
}

ll solve() {
  for (int i = 0; i <= 63; i++) for (int j = 0; j <= 1; j++) dp[i][j][0][0] = dp[i][j][0][1] = dp[i][j][1][0] = dp[i][j][1][1] = -1;
  return dfs(62, 1, 1, 0);
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> L >> R;
  cout << solve() << '\n';
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(String x,y="black blue lime aqua red fuchsia yellow white",r=y;(x=s.next()).length()>1;System.out.println(r))for(int i=8,j,v,m=1<<23,k;i-->0;){for(j=v=0;j<3;)v+=(k=(java.awt.Color.decode(x).getRGB()>>j*8&255)-((i>>j++&1)>0?255:0))*k;if(m>v){m=v;r=y.split(" ")[i];}}}}

Measured memory_bytes: 13000
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        mut k: usize,
    }
    if k % 7 == 0 {
        k /= 7;
    }

    let mut set = HashSet::new();

    let mut rem = 1;
    for i in 1..=k {
        if rem % k == 0 {
            println!("{}", i);
            return;
        } else if set.contains(&rem) {
            println!("-1");
            return;
        }
        set.insert(rem);
        rem = rem * 10 + 1;
        rem %= k;
    }

}


Measured memory_bytes: 29648
import java.util.*
import kotlin.math.acos
import kotlin.math.cos
import kotlin.math.round
import kotlin.math.sin

fun main(args: Array<String>) {
    val n = readInt()
    val a = readLongList()

    println(a.fold(a.first()) { b, value -> gcd(b, value) })
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

// 最大公約数
fun gcd(p: Long, q: Long): Long = if (p % q == 0L) q else gcd(q, p % q)

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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long


class AStillTBD {
public:
    void solve(std::istream &in, std::ostream &out) {
      string s;
      in >> s;
      int y = stoll(s.substr(0, 4));
      int m = stoll(s.substr(5, 2));
      int d = stoll(s.substr(8, 2));
      if (y < 2019) {
        out << "Heisei" << endl;
      } else if (y == 2019) {
        if (m <= 4) {
          out << "Heisei" << endl;
        } else {
          out << "TBD" << endl;
        }
      } else {
        out << "TBD" << endl;
      }
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  AStillTBD solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#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>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
string a, b, c;
int main(void) {
    cin >> a >> b >> c;
    cout << (char)(a[0] - 32) << (char)(b[0] - 32) << (char)(c[0] - 32) << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>          // printf(), putchar(), scanf()

int
main(int argc, char **argv)
{
	short puzzle[9][9];
	char check[9][9];
	int n;
	enum {none, done, dupli} state[9];

	scanf("%d", &n);
	for (int u = 0; u < n; ++u)
	{
		for (int y = 0; y < 9; ++y)
		{
			for (int x = 0; x < 9; ++x)
				scanf("%hd", &puzzle[y][x]);
		}

		for (int y = 0; y < 9; ++y)
		{
			for (int x = 0; x < 9; ++x)
				check[y][x] = ' ';
		}

		for (int x = 0; x < 9; ++x)
		{
			for (int i = 0; i < 9; ++i)
				state[i] = none;

			for (int y = 0; y < 9; ++y)
			{
				int t = puzzle[y][x] - 1;
				if (state[t] == none)
					state[t] = done;
				else
					state[t] = dupli;
			}

			for (int i = 0; i < 9; ++i)
			{
				if (state[i] == dupli)
				{
					for (int y = 0; y < 9; ++y)
					{
						if (puzzle[y][x] == i + 1)
							check[y][x] = '*';
					}
				}
			}
		}

		for (int y = 0; y < 9; ++y)
		{
			for (int i = 0; i < 9; ++i)
				state[i] = none;

			for (int x = 0; x < 9; ++x)
			{
				int t = puzzle[y][x] - 1;
				if (state[t] == none)
					state[t] = done;
				else
					state[t] = dupli;
			}

			for (int i = 0; i < 9; ++i)
			{
				if (state[i] == dupli)
				{
					for (int x = 0; x < 9; ++x)
					{
						if (puzzle[y][x] == i + 1)
							check[y][x] = '*';
					}
				}
			}
		}

		for (int y = 0; y < 9; y += 3)
		{
			for (int x = 0; x < 9; x += 3)
			{
				for (int i = 0; i < 9; ++i)
					state[i] = none;

				for (int i = 0; i < 9; ++i)
				{
					int tx = x + i % 3, ty = y + i / 3;
					int t = puzzle[ty][tx] - 1;
					if (state[t] == none)
						state[t] = done;
					else
						state[t] = dupli;
				}

				for (int i = 0; i < 9; ++i)
				{
					if (state[i] == dupli)
					{
						for (int j = 0; j < 9; ++j)
						{
							int tx = x + j % 3, ty = y + j / 3;
							if (puzzle[ty][tx] == i + 1)
								check[ty][tx] = '*';
						}
					}
				}
			}
		}

		if (u != 0)
			putchar('\n');

		for (int y = 0; y < 9; ++y)
		{
			for (int x = 0; x < 9; ++x)
				printf("%c%hd", check[y][x], puzzle[y][x]);

			putchar('\n');
		}
	}

	return 0;
}

Measured memory_bytes: 1736
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int H, W;
  while (cin >> H >> W){
    if (H == 0 && W == 0) return 0;
    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        if ((i + j) % 2 == 0) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }   

  return 0;
}



Measured memory_bytes: 3112
import java.util.*;

class Main{

	static void f(int i,int ex,ArrayList<HashMap<Integer,Integer>>l,int[]r){
		int c=1;
		for(Map.Entry<Integer,Integer> e: l.get(i).entrySet()){
			if(r[e.getKey()]>0)
				continue;
			if(c==ex)
				++c;
			r[e.getKey()]=c;
			f(e.getValue(),c++,l,r);
		}
	}

	public static void main(String[] $){
		final Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		ArrayList<HashMap<Integer,Integer>>l=new ArrayList<>();
		for(int i=0;i<n;++i)
			l.add(new HashMap<>());
		for(int i=0;i<n-1;++i){
			int a=s.nextInt()-1,b=s.nextInt()-1;
			l.get(a).put(i,b);
			l.get(b).put(i,a);
		}
		int[]r=new int[n-1];
		f(0,-1,l,r);
		System.out.println(Arrays.stream(r).max().getAsInt());
		for(int i:r)
			System.out.println(i);
	}
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long h = sc.nextLong();

		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}

		Arrays.sort(a);
		Arrays.sort(b);

		long answer = 0;
		int bi = n - 1;
		while (h > 0 && bi >= 0 && b[bi] > a[n - 1]) {
			h -= b[bi];
			bi--;
			answer++;
		}

		if (h > 0) {
			answer += h / a[n - 1];
			answer += (h % a[n - 1] > 0) ? 1 : 0;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 93588