akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;

typedef long long ll;

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

    int n;
    cin >> n;

    int sum = 0;
    int biggest = -1;
    REP(i, n) {
        int v;
        cin >> v;
        sum += v;

        if (v > biggest) {
            biggest = v;
        }
    };

    if (biggest < (sum - biggest)) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
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 c = sc.nextInt();
		int divisorNum = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0)
				divisorNum++;
		}

		System.out.println(divisorNum);
	}

}

Measured memory_bytes: 26396
#include<bits/stdc++.h>
using namespace std;
int countx[200005];
int n,k,a;
int ans=0;
int ejud=0,fjud=0;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        countx[i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        if(countx[a]==0)
            fjud++;
        countx[a]++;
    }
    sort(countx+1,countx+n+1);
    for(int i=1;i<=n;i++)
    {
        if(countx[i]>0)
            ejud++;
        ans+=countx[i];
        if(ejud+k==fjud)
            break;
    }
    if(k<=fjud)
        cout<<ans<<endl;
    else
        cout<<0<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
  int i,j,n,w,l; 
  char com[15];

  /* dire
    1
   4 2
    3
  */

  while(1){
    //   cout<<"aa"<<endl;;
    cin>> j>> i;
    if(i==0&&j==0){
      break;
    }
    
   int dire=1;
   w=1;
   l=1;
   
   while(1){

     //  cout<<w<<" "<<l<<" d:"<<dire<<endl;//

     cin>> com;
     //cout<< com<<"  "<< n<< endl;
     if(strcmp(com,"FORWARD")==0){
       cin>>n;
       if(dire==1){
	 l+=n;
	 if(l>i){
	   l=i;
	 }
       }
       if(dire==2){
	 w+=n;
	 if(w>j){
	   w=j;
	 }
       }
       if(dire==3){
	 l-=n;
	 if(l<1){
	   l=1;
	 }
       }
       if(dire==4){
	 w-=n;
	 if(w<1){
	   w=1;
	 }
       }
     } else if(strcmp(com,"BACKWARD")==0){
       cin>>n;
       if(dire==3){
	 l+=n;
	 if(l>i){
	   l=i;
	 }
       }
       if(dire==4){
	 w+=n;
	 if(w>j){
	   w=j;
	 }
       }
       if(dire==1){
	 l-=n;
	 if(l<1){
	   l=1;
	 }
       }
       if(dire==2){
	 w-=n;
	 if(w<1){
	   w=1;
	 }
       }
     }else if(strcmp(com,"STOP")==0){
       break;
     }else if(strcmp(com,"RIGHT")==0){
       if(dire!=4){
	 dire++;
       }else if(dire==4){
	 dire=1;
       }else{
	 cout<<"???\n";
       }
     }else if(strcmp(com,"LEFT")==0){
       if(dire!=1){
	 dire--;
       }else if(dire==1){
	 dire=4;
       }else{
	 cout<<"???\n";
       }
     }
   }
   cout<<w<<" "<<l<<endl;
   
  }
  
  return 0;
}

Measured memory_bytes: 0
n,x = map(int,input().split())
a = list(map(int,input().split()))
tmp = [0]*n
tmp[0] = a[0] if a[0] < x else x
val = a[0]
for i in range(n-1):
    if a[i+1] + val > x:
        tmp[i+1] = max(0,x-val)
    else:tmp[i+1] = a[i+1]
    val = tmp[i+1]

ans = 0
for i in range(n):
    ans += a[i] - tmp[i]
print(ans)

        
    

Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

int A[25][25];
ll DP[1<<21];
ll mod = 1e9+7;
int n;

ll solve(ll mask)
{
    if(mask == (1<<n)-1)return 1;
    bitset<32>M(mask);
    int man = M.count();
    if(man >= n)return 0;
    if(DP[mask]!=-1)return DP[mask];

    DP[mask]=0;

    for(int i=0; i<n; i++)
        if(!M[i] && A[man][i])
            {
                DP[mask]+=solve(mask|(1<<i));
                DP[mask]%=mod;
            }

    return DP[mask];
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    memset(DP, -1, sizeof DP);
    cin>>n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        cin>>A[i][j];

    cout<<solve(0);
}


Measured memory_bytes: 16768
import heapq

N,M = list(map(int,input().split()))
jobs = [[] for _ in range(M)]
for _ in range(N):
  delay,reward = list(map(int,input().split()))
  if delay-1 < M:
    jobs[delay-1].append(-reward)

res = 0
heap = []

for i in range(M):
  [heapq.heappush(heap,r) for r in jobs[i]]
  if len(heap) >0:
    res += -(heapq.heappop(heap))

print(res)


Measured memory_bytes: 23752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,sum;
  sum=0;
  cin >> N>>K;
  
  for (int i =0;i<N;i++){
 int x;
    cin>>x;
    if(x>K/2){
    sum+=2*(K-x);
    }
 else{
 sum+=2*x;
 }
    
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

int main() {
  int N; cin >> N;
  string S; cin >> S;

  vector<int> d1(10,0);
  vector<int> d2(100,0);
  set<int> ans;

  d1[S[N-1]-'0'] = 1;
  d1[S[N-2]-'0'] = 1;
  d2[10*(S[N-2]-'0')+S[N-1]-'0'] = 1;

  for (int i = N-3; i >= 0; i--) {
    int tmp = S[i] - '0';

    rep(j,100) {
      if (d2[j] == 1) {
        ans.insert(tmp*100+j);
      }
    }

    rep(j,10) {
      if (d1[j] == 1) {
        d2[tmp*10+j] = 1;
      }
    } 

    d1[tmp] = 1;
  }

  cout << ans.size() << endl;

  return 0;
}


Measured memory_bytes: 384
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 2e5 + 10;

ll a[N], b[N];
multiset < ll > s;

int main() {
    fast_io();
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll ans = 1;
    s.insert(a[1]);
    for (ll i = 2; i <= n; i++) {
        auto it = s.lower_bound(a[i]);
        if (it == s.begin()) {
            s.insert(a[i]);
        } else {
            it--;
            s.erase(it);
            s.insert(a[i]);
        }
    }
    cout << s.size() << "\n";
    return 0;
}


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

int N, x[105], y[105];
long long int h[105];

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}

	int CX, CY;
	long long int H,ans_H;
	bool sign = true;
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			sign = true;
			
			//======
			int K;
			long long int max_h = -1;
			for (int k = 1; k <= N; k++) {
				if (h[k] > max_h) { max_h = h[k]; K = k; }
			}

			//======
			H = h[K] + abs(i - x[K]) + abs(j - y[K]);
			if (H < 1) { continue; }
			for (int k = 1; k <= N; k++) {
				if (max((long long int) (H - (long long int) abs(i - x[k]) - (long long int) abs(j - y[k])), (long long int) 0) != h[k]) { sign = false; break; }
			}
			if (sign) { CX = i; CY = j; ans_H = H; }
		}
	}

	cout << CX << " " << CY << " " << ans_H << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int r = 0, c = 0;

		r = scane.nextInt();
		c = scane.nextInt();

		int[][] rc = new int[r][c];

		int[] r1 = new int[r];
		int[] c1 = new int[c];

		for(int i=0; i<rc.length; i++){
			for(int j=0; j<rc[0].length; j++){

				rc[i][j] = scane.nextInt();
			}
		}
		int nums =0;

		for(int i=0; i<rc.length; i++){
			for(int j=0; j<rc[0].length; j++){

				r1[i] += rc[i][j];
			}
		}
		for(int i=0; i<rc[0].length; i++){
			for(int j=0; j<rc.length; j++){

				c1[i] += rc[j][i];
			}
			nums += c1[i];
		}


		for(int i=0; i<rc.length; i++){
			for(int j=0; j<rc[0].length; j++){

				System.out.print(rc[i][j]+" ");
			}
			System.out.println(r1[i]+"");
		}
		for(int num : c1){
			System.out.print(num+" ");
		}
		System.out.print(nums+"\n");

	}
}

Measured memory_bytes: 41168
#include <iostream>
#include <vector>
#define llint long long

using namespace std;

llint n, mod;
llint a, b, c, t;
llint s[55];

struct Matrix{
  int h, w;
  vector<llint> mat;
  Matrix(){
    h = w = 0;
  }
  Matrix(int h, int w){
    this->h = h, this->w = w;
    mat.resize(h*w);
  }
  llint& at(int i, int j){
    return mat[w*(i-1)+(j-1)];
  }
  static Matrix ident(int size){
    Matrix ret(size, size);
    for(int i = 1; i <= size; i++) ret.at(i, i) = 1;
    return ret;
  }
  Matrix operator*(Matrix& ope){
    Matrix ret(h, ope.w);
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= ope.w; j++){
        for(int k = 1; k <= w; k++){
          ret.at(i, j) += at(i, k) * ope.at(k, j) % mod;
          ret.at(i, j) %= mod;
        }
      }
    }
    return ret;
  }
  /*Matrix operator=(const Matrix& ope){
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
        at(i, j) = ope.mat[w*(i-1)+(j-1)];
      }
    }
    return *this;
  }*/
  Matrix pow(llint n){
    //cout << n << endl;
    if(n == 0) return ident(h);
    if(n%2){
      return pow(n-1)*(*this);
    }
    else{
      Matrix tmp = pow(n/2);
      return tmp * tmp;
    }
  }
};

llint ans[55];

int main(void)
{
  while(1){
    cin >> n >> mod >> a >> b >> c >> t;
    if(n == 0 && mod == 0 && a == 0 && b == 0 && c == 0 && t == 0) break;
    //cout << n << " " << mod << " " << a << " " << b << " " << c << " " << t << endl;

    for(int i = 1; i <= n; i++) cin >> s[i];

    //cout << n << " " << mod << " " << a << " " << b << " " << c << " " << t << endl;

    Matrix mat = Matrix(n, n);

    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
        if(i == j) mat.at(i, j) = b;
        else if(i-1 == j) mat.at(i, j) = a;
        else if(i+1 == j) mat.at(i, j) = c;
        else mat.at(i, j) = 0;
      }
    }

    Matrix pmat = mat.pow(t);

    for(int i = 1; i <= n; i++){
      ans[i] = 0;
      for(int j = 1; j <= n; j++){
        ans[i] += pmat.at(i, j) * s[j] % mod;
        ans[i] %= mod;
      }
    }
    for(int i = 1; i <= n; i++){
      cout << ans[i];
      if(i < n)  cout << " ";
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a>b){
int oki=a;
a=b;
b=oki;


}

if(b>c){
int oki=b;
b=c;
c=oki;


}
if(a>b){
int oki=a;
a=b;
b=oki;


}
cout<<a<<' '<<b<<' '<<c<<'\n';
return 0;
}

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

long long n, m, a, b;

int main() {
    cin>>n>>m;
    if(n < m) {
        a = n;
        b = m;
    }
    else {
        a = m;
        b = n;
    }
    if(a == 1) {
        cout<<abs(b-2);
    }
    else {
        cout<<(a-2)*(b-2);
    }
}

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

int LCS[MAXN][MAXN];
char L[MAXN];

int main(){
	string s1,s2;
	cin>>s1>>s2;
	int x = s1.size();
	int y = s2.size();
	int i,j;
	for(i=0;i<=x;i++)
		for(j=0;j<=y;j++){
			if(i==0 || j==0)LCS[i][j]=0;
			else if(s1[i-1]==s2[j-1]){
				LCS[i][j]=1+LCS[i-1][j-1];
			}else{
				LCS[i][j]=max(LCS[i-1][j],LCS[i][j-1]);
			}
		}

	int index = LCS[x][y];
	L[index+1]='\0';
	
	while(i>0 && j>0){
		if(s1[i-1]==s2[j-1]){
			L[index]=s1[i-1];
			i--;j--;index--;
		}else{
			if(LCS[i][j-1]>LCS[i-1][j]){
				j--;
			}else i--;
			
		}
		
	}
	cout<<L<<endl;
}

Measured memory_bytes: 43264
package main

import (
        "fmt"
)

func solution(n, k int, x []int) int {
        sum := 0
        for i := 0; i < n; i++ {
                a := x[i] * 2
                b := (k - x[i]) * 2
                sum += min(a, b)
        }
        return sum
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func main() {
        var n, k int
        fmt.Scan(&n, &k)

        x := make([]int, n)

        for i := range x {
                t := 0
                fmt.Scan(&t)
                x[i] = t
        }
        fmt.Println(solution(n, k, x))
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    int q;
    list<int>L;
    list<int>::iterator it=L.begin();
    cin>>q;
    while(q--){
        int a,b;
        cin>>a;
        if(a<2)cin>>b;
        if(!a)it=L.insert(it,b);
        else if(a==1){
            r(i,abs(b)){
                if(b<0)it--;
                else it++;
            }
        }
        else it=L.erase(it);
    }
    it=L.begin();
    for(;it!=L.end();it++){
        cout<<*it<<endl;
    }
}


Measured memory_bytes: 18624
#include<iostream>
#include<cstdio>
#include<ctype.h>
#include<algorithm>
#include<map>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int f[200007],ff[200007];
map<pair<int,int>,int>m;
int find(int x,int *f){
	return f[x]==x?x:f[x]=find(f[x],f);
}
int main(){
	int n=read(),k=read(),l=read();
	for(int i=1;i<=n;i++)f[i]=ff[i]=i;
	for(int i=1;i<=k;++i){
		int x=find(read(),f),y=find(read(),f);
		if(x!=y)f[y]=x;
	}
	for(int i=1;i<=l;++i){
		int x=find(read(),ff),y=find(read(),ff);
		if(x!=y)ff[y]=x;
	}
	for(int i=1;i<=n;++i)find(i,f),find(i,ff);
	for(int i=1;i<=n;++i)m[make_pair(f[i],ff[i])]++;
	for(int i=1;i<=n;i++)printf("%d ",m[make_pair(f[i],ff[i])]);
	return 0;
}

Measured memory_bytes: 13568
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	if (N == 1) {
		printf("YES\n");
		return 0;
	}

	int saisho = getint();
	ll goukei = saisho;

	int saidai = 0;
	int mae = saisho;
	int tugi = getint();
	goukei += tugi;
	int sa = tugi - mae;
	chmax(saidai, sa);
	int amari = sa % N;
	mae = tugi;
	rep1(i, N - 2) {
		tugi = getint();
		goukei += tugi;
		sa = tugi - mae;
		chmax(saidai, sa);
		if ((sa - amari) % N) {
			printf("NO\n");
			return 0;
		}
		mae = tugi;
	}
	sa = saisho - mae;
	chmax(saidai, sa);
	if ((sa - amari) % N) {
		printf("NO\n");
		return 0;
	}
	
	ll n = ll(N) * (N + 1) / 2;
	if (goukei % n) {
		printf("NO\n");
		return 0;
	}
	int k = goukei / n;
	if (saidai > k) { 
		printf("NO\n");
		return 0;
	}
	if ((amari - k) % N) {
		printf("NO\n");
		return 0;
	}

	printf("YES\n");


	Would you please return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    long  H = sc.nextLong();
    long W = sc.nextLong();
    long S = (long)H * W;
    //縦に切ってから横
    long S1a = H * W - H * (W/3) - div2(H,W - W/3) - H * (W/3);
    long S1b = H * (W/3 + 1) - div2(H,W - (W/3 + 1)); 
    long S1 = Math.min(S1a, S1b); 
    //横に切ってから縦
    long S2a = H * W - (H/3) * W - div2(W,H - H/3) - (H/3) * W;
    long S2b = (H/3 + 1) * W - div2(W,H - (H/3 + 1));
    long S2 = Math.min(S2a, S2b);
    
    if (S % 3 ==0) {
      System.out.println(0);
    } else {
      System.out.println(Math.min(S1,S2));
    }
  }
  
  static long div2(long a, long b) {
    if (a * b % 2 == 0) {
      return  (long)(a * b)/2;
    }else {
      long c1 = (long)(a/2) * b;
      long c2 = (long)(b/2) * a;
      return Math.max(c1,c2);
    }
  }
}

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

const int M=2*1e5+5;

int n,m;
int A[M];
int cnt[M];
long long sum[M];

long long calc(int p) {
	long long res=0;
	res+=sum[p];
	res-=1LL*cnt[p]*(p-1);
	return res;
}

int main() {
	cin>>n>>m;
	for (int i=1;i<=n;++i) scanf("%d",&A[i]);
	
	long long mx=0,res;
	
	for (int i=1;i<n;++i) {
		int l=A[i],r=A[i+1];
		if (r<l) r+=m;
		mx+=r-l;
		sum[l+1]+=l,sum[r+1]-=l;
		cnt[l+1]++,cnt[r+1]--;
	}
	for (int i=1;i<=m*2;++i) {
		sum[i]+=sum[i-1];
		cnt[i]+=cnt[i-1];
	}

	res=mx;
	for (int i=1;i<=m;++i) {
		res=min(res,mx+calc(i)+calc(i+m));
	}
	cout<<res<<endl;
}

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

    using namespace std;

    typedef long long int ll;
    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin>>t;while(t--)
    #define forn(i,a,n) for (int i = a; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()

    void __print(int x) {cerr << x;}
    void __print(long x) {cerr << x;}
    void __print(long long x) {cerr << x;}
    void __print(unsigned x) {cerr << x;}
    void __print(unsigned long x) {cerr << x;}
    void __print(unsigned long long x) {cerr << x;}
    void __print(float x) {cerr << x;}
    void __print(double x) {cerr << x;}
    void __print(long double x) {cerr << x;}
    void __print(char x) {cerr << '\'' << x << '\'';}
    void __print(const char *x) {cerr << '\"' << x << '\"';}
    void __print(const string &x) {cerr << '\"' << x << '\"';}
    void __print(bool x) {cerr << (x ? "true" : "false");}

    template<typename T, typename V>
    void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
    template<typename T>
    void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
    void _print() {cerr << "]\n";}
    template <typename T, typename... V>
    void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
    #ifndef ONLINE_JUDGE
    #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
    #else
    #define debug(x...)
    #endif
    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }

  
  

    /*CHECK FOR CORNER CASES FOR GOD'S SAKE*/
    int main()
    {
      //freopen("input.txt", "r", stdin);
      //freopen("output.txt", "w", stdout);
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      double d,t,s;
      cin>>d>>t>>s;
      if(d/s <= t)
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;


  } 


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define int long long
using namespace std;
const int oo = 1e18;

pair <int, int> a[105];

int n,m,ans;
int dp[100005];

signed main()
{
    //freopen("file.inp","r",stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].fi >> a[i].se;
    }
    int N = 100000;
    for (int i = 1; i <= N; i++)
    {
        dp[i] = oo;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = N - a[i].se; j >= 0; j--)
        {
            int k = j + a[i].se;
            dp[k] = min(dp[k], dp[j] + a[i].fi);
        }
    }
    for (int i = N; i >= 0; i--)
    {
        if (dp[i] <= m) return cout << i, 0;
    }
    return 0;
}


Measured memory_bytes: 4416
n,k=map(int,input().split())
MOD=10**9+7

def S(a,MOD):
    x=[0]*(n+1)
    s=0
    for i in range(1,n+1):
        s+=i
        s%=MOD
        x[i]=s
    return x

ans=0
X=S(n,MOD)
for i in range(k,n+2):
    if i<n+1:
        m=X[n]-X[n-i]
        if m<0:
            m+=MOD
        ans+=(m+1-(X[i-1]-1+1))
    else:
        ans+=1
    ans%=MOD
print(ans)

Measured memory_bytes: 73456
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >>d;
  while(true){
    c-=b;
    if(c<=0) {
      puts("Yes");
      return 0;
    }

    a-=d;
    if(a<=0){
      puts("No");
      return 0;
    }
  }
}


Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(){
  int x;
  cin >> x;
  if(400 <= x && x <= 599){
    cout << 8;
  }
  else if(600 <= x && x <= 799){
    cout << 7;
  }
  else if(800 <= x && x <= 999){
    cout << 6;
  }
  else if(1000 <= x && x <= 1199){
    cout << 5;
  }
  else if(1200 <= x && x <= 1399){
    cout << 4;
  }
  else if(1400<=x && x <= 1599){
    cout << 3;
  }
  else if(1600 <= x && x <= 1799){
    cout << 2;
  }
  else{
    cout << 1;
  }
  return 0;
}

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

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        par = vector<int>(N, -1);
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
        //再帰的に根を調べる際に、xを根に直接つなぎ直す
    }

    bool unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); // xの根をrx
        int ry = root(y); // yの根をry
        if (rx == ry) return false; // xとyの根が同じ(=同じ木にある)時はそのまま
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

int main()
{
    int N, M;
    cin >> N >> M;

    UnionFind tree(N);

    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        tree.unite(x - 1, y - 1);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) ans = max(ans, tree.size(i));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4844
n=int(input())
s=[str(input()) for _ in range(n)]
import collections
cnt=collections.Counter(s)
cntt=cnt.most_common()
maxn=cntt[0][1]
ansl=[]
for c in cntt:
  if c[1]==maxn:
    ansl.append(c[0])
  else:
    break
ansl.sort()
for i in ansl:
  print(i)

Measured memory_bytes: 50444
import java.util.*;

public class Main {


    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        if (c<=a && c<=b) {
            System.out.print("No");
//            System.out.print("N");
            return;
        }

        if ((c-a-b)*(c-a-b)-4*a*b>0) {
            if (c-a-b>0) {
                System.out.print("Yes");
            } else {
                System.out.print("No");
            }
        }else {
            System.out.println("No");
        }

//        System.out.println((c-a-b)*(c-a-b));
//        System.out.println(4*a*b);

    }
}



Measured memory_bytes: 21972
package main

import "fmt"

func main() {
	var a, b, n int
	fmt.Scanf("%d %d %d", &a, &b, &n)

	//for x := 0; x <= n; x++ {
	//	fmt.Println((a*x)/b - a*(x/b))
	//}
	max := 0
	temp := 0
	flag := 0
	if b > n {
		flag = n
	} else {
		flag = b
	}
	for i := flag - 5; i <= flag; i++ {
		temp = (a*i)/b - a*(i/b)
		if max < temp {
			max = temp
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


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


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1,0,2,0,-2,0};
int dy[]={1,0,-1,0,2,0,-2,0,0};
int f(vp in){
	int a=0;
	for(int i=5;i>=0;i--){
		a*=9;
		a+=in[i].first*3+in[i].second;
	}
	return a;
}
vp F(int a){
	vp out;
	rep(i,6){
		int b=a%9;
		out.pb(pii(b/3,b%3));
		a/=9;
	}
	return out;
}
vi dp;
int main(){
	int n;
	while(cin>>n,n){
		vvi in(n,vi(16));
		rep(i,n)rep(j,16)cin>>in[i][j];
		int N=531441;
		dp=vi(N);
		vp qwr(6,pii(1,1));
		dp[f(qwr)]=1;
		rep(i,n){
			vi ndp(N);
			rep(j,N)if(dp[j])rep(k,9){
				if(i==0&&k!=8)continue;
				vp ka=F(j);
				pii now=ka[5];
				now.first+=dx[k];
				now.second+=dy[k];
				if(now.first<0||now.first>=3||now.second<0||now.second>=3)continue;
				ka.pb(now);
				bool h=true;
				if(in[i][now.first*4+now.second])continue;
				if(in[i][now.first*4+now.second+1])continue;
				if(in[i][now.first*4+now.second+4])continue;
				if(in[i][now.first*4+now.second+5])continue;
				rep(l,16){
					bool H=false;
					rep(x,7){
						if(ka[x].first*4+ka[x].second==l)H=true;
						if(ka[x].first*4+ka[x].second+1==l)H=true;
						if(ka[x].first*4+ka[x].second+4==l)H=true;
						if(ka[x].first*4+ka[x].second+5==l)H=true;
					}
					if(!H)h=false;
				}
				ka.erase(ka.begin());
				if(i<6||h)ndp[f(ka)]=true;
			}
			dp=ndp;
//			rep(j,N)if(dp[j]){
//				vp tmp=F(j);
//				rep(k,tmp.size())cout<<tmp[k].first<<" "<<tmp[k].second<<endl;
//				cout<<endl;
//			}
		}
		bool h=false;
		rep(i,N)if(dp[i])h=true;
		cout<<h<<endl;
	}
}

Measured memory_bytes: 7084
X = gets.to_i

found = false
candidate = X
while found == false do
  prime = true
  for i in 2..candidate do
    if candidate % i == 0 and candidate != i then
      prime = false
      break
    end
  end
  if prime then
    print candidate
    found = true
  else
    candidate += 1
  end
end

Measured memory_bytes: 1916
//fck light 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
void solve()
{
    ll n;
    cin >> n;
    ll ans = n*(n-1)/2;
    cout << ans;

}

int main()
{
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		ll t = 1;
	//	cin >> t
		while(t--)
		{
			solve();
		}
	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	vector<pair<pair<int, int>,int>> Pv(2*N);
	multiset<int> BPv;
	rep(i, 0, 2*N)
	{
		cin >> Pv[i].first.first >> Pv[i].first.second;
		Pv[i].second = i / N;
	}

	sort(all(Pv));

	int ans = 0;
	for (auto p : Pv)
	{
		if (p.second == 0)
		{
			BPv.insert(p.first.second);
		}
		else
		{
			auto itr = BPv.lower_bound(p.first.second);
			if (itr == BPv.begin())continue;
			itr--;
			ans++;
			BPv.erase(itr);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;

bool cm(int x)
{
	if (x >=1 && x <= 12)
		return true;
	return false;
}

bool cy(int x)
{
	if (x >= 0 && x <= 99)
		return true;
	return false;
}

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

   string st; cin >> st;

   int f = 10 * (st[0] - '0') + (st[1] - '0');
   int s = 10 * (st[2] - '0') + (st[3] - '0');
   bool flag = cm(f);
   bool flag2 = cm(s);
   bool flag3 = cy(f);
   bool flag4 = cy(s);

   if (flag && flag4 && flag3 && flag2){
   	cout << "AMBIGUOUS\n";
   	return 0;
   }

   if (flag && flag4){
   	cout << "MMYY\n";
   } else if (flag2 && flag3){
   	cout << "YYMM\n";
   } else {
   		cout << "NA\n";
   }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 111;
int n,m;
queue<pii> q;
char s[N][N];
int dp[N][N],vis[N][N];

int main() {
	scanf("%d%d", &n, &m);
	REP(i,1,n) scanf("%s",s[i]+1);
	memset(dp,0x3f,sizeof dp);
	dp[0][1] = 0;
	REP(i,1,n) REP(j,1,m) {
		if (s[i][j]=='.') dp[i][j] = min(dp[i-1][j],dp[i][j-1]);
		else {
			memset(vis,0,sizeof vis);
			q.push(pii(i,j));
			while (q.size()) {
				pii u(q.front()); q.pop();
				if (vis[u.x][u.y]) continue;
				vis[u.x][u.y] = 1;
				dp[i][j] = min(dp[i][j], min(dp[u.x-1][u.y],dp[u.x][u.y-1])+1);
				if (s[u.x-1][u.y]=='#') q.push(pii(u.x-1,u.y));
				if (s[u.x][u.y-1]=='#') q.push(pii(u.x,u.y-1));
			}
		}
	}
	printf("%d\n", dp[n][m]);
}








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

int main() {
	int n, i;
	char c;
	
	cin >> n;
	cin >> c;
	for (i = 0; i < n - 1; i++) {
		char x;
		cin >> x;
		if (c == 'T' && x == 'F') c = 'F';
		else c = 'T';
	}
	cout << c << endl;
	return 0;
}


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

multiset<lint> decomp(lint N){
    multiset<lint> res;
    for(int i=2;i<=1100000;i++){
        while(N%i==0) N/=i,res.insert(i);
        if(N==1) break;
        if(i==1100000) res.insert(N);
    }
    return res; 
}

int main(void){
    lint N,P;
    cin >> N >> P;
    multiset<lint> mul=decomp(P);
    lint ans=1;
    while(!mul.empty()){
        auto itr=mul.begin();
        lint cnt=mul.count(*itr)/N;
        ans*=pow(*itr,cnt);
        mul.erase(*itr);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <long long MOD = 1000000007> //MODを適宜設定すること
struct Mint
{
   using M = Mint;
   ll a;
   Mint(ll x=0){a=x%MOD;if(a<0) a+=MOD;}//Mintで

   M pow(ll n){
      M b=*this,r=1;

      while(n){
         if(n&1)r*=b;
         b*=b;
         n>>=1;
      }

      return r;
   }

   M inv(){return pow(MOD-2);}

   M& operator+=(M r){a+=r.a;if(a>=MOD)a-=MOD;return *this;}
   M& operator-=(M r){a+=MOD-r.a;if(a>=MOD)a-=MOD;return *this;}
   M& operator*=(M r){a=1LL*a*r.a%MOD;return *this;}
   M& operator/=(M r){return (*this)*=r.inv();}
   M operator+(M r) const{return M(a)+=r;};
   M operator-(M r) const{return M(a)-=r;};
   M operator*(M r) const{return M(a)*=r;};
   M operator/(M r) const{return M(a)/=r;};//const いる？

   friend ostream& operator<<(ostream& os,const M& r){return os<<r.a;}
};

using M = Mint<mod>;

const int MAX=100010;

M fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i;
        inv[i] = M{mod}-inv[mod%i] * (mod / i);//＊１
        finv[i] = finv[i - 1] * inv[i];
    }
}

M COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k] ;
}

/*
using M = Mint<mod>
M xとint iの演算はx.a+=i またはx+=M{i} */

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  COMinit();
  ll n,k;cin>>n>>k;
  M ans=0;
  V<ll> u(n);
  rep(i,0,n)cin>>u[i];
  sort(all(u));

  V<M> v(n);
  rep(i,0,n)v[i].a=u[i];

  rep(i,0,n){
    if(i>=k-1){
      ans+=v[i]*COM(i,k-1);
    }

    if(k-1<=n-1-i){
      ans+=(M{mod}-v[i])*COM(n-1-i,k-1);
    }
  }
  cout<<ans<<ENDL;


}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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

#define	NASI	2000000001

typedef struct{
	int key;
	int parent;
	int left, right;
} TREE_T;

TREE_T *TREE;

int main()
{
	int n;
	int key;
	int i;

	scanf("%d", &n);

	TREE = (TREE_T *)malloc(sizeof(TREE_T) * (n + 1));

	for(i = 1; i <= n; i++){
		scanf("%d", &key);
		TREE[i].key = key;
	}

	for(i = 1; i <= n; i++)
		TREE[i].parent = TREE[i].left = TREE[i].right = NASI;

	// parent, left, right key の情報を不可する
	for(i = 1; i <= n; i++){
		// parent
		if(i / 2 > 0)
			TREE[i].parent = TREE[i / 2].key;
		// left
		if(i * 2 <= n)
			TREE[i].left = TREE[i * 2].key;
		// right
		if(i * 2 + 1 <= n)
			TREE[i].right = TREE[i * 2 + 1].key;
	}

	// 表示
	for(i = 1; i <= n; i++){
		printf("node %d: key = %d, ", i, TREE[i].key);
		if(TREE[i].parent != NASI)
			printf("parent key = %d, ", TREE[i].parent);
		if(TREE[i].left != NASI)
			printf("left key = %d, ", TREE[i].left);
		if(TREE[i].right != NASI)
			printf("right key = %d, ", TREE[i].right);
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2060
#include <stdio.h>

int main(){
    int i, n, count=0;    

    scanf("%d", &n);
    int a[100];

    for(i=0;i<n;i++){
        scanf("%d", &a[i]);
    }
    for(i=0;i<n;i++){
        if(a[i] != i+1){
            count++;
        }
    }   

    if(count<=2){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

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

#define INF 0x3f3f3f3f
#define int long long
#define pii pair<int, int>

const int N = 100005;

int dp[105][N];
vector<pii> items;

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

    memset(dp, 0, sizeof(dp));
    int n, w, i, j, w_, v_;
    cin >> n >> w;
    for(i = 0 ; i < n ; i++) {
        cin >> w_ >> v_;
        items.push_back(make_pair(w_, v_));
    }
    for(i = 1 ; i <= n ; i++) {
        for(j = 1; j <= w ; j++) {
            dp[i][j] = dp[i-1][j];
            if(j >= items[i-1].first)
                dp[i][j] = max(dp[i][j], dp[i-1][j-items[i-1].first] + items[i-1].second);
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 82304
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 
using namespace std;

#define _int64 long long

char s[600000];
int dp[600000][3];
vector<int> a;

int main()
{
  int i,j,n,cnt,tmp;
  cin >> n >> s;
  cnt=0;
  a.clear();
  for (i=0;i<n;i++)
  {
    if (s[i]=='1') cnt++;
    else
    {
      if (cnt>0) a.push_back(cnt);
      a.push_back(0);
      cnt=0;
    }
  }
  if (cnt>0) a.push_back(cnt);
  memset(dp,-1,sizeof(dp));
  dp[0][0]=0;
  for (i=0;i<a.size();i++)
  {
    for (j=0;j<3;j++)
      if (dp[i][j]!=-1)
      {
        if (dp[i+1][0]<dp[i][j])
          dp[i+1][0]=dp[i][j];
        if ((i+2<a.size())&&(a[i]>0)&&(a[i+1]==0)&&(a[i+2]>0))
        {
          if (j==0)
          {
            tmp=dp[i][j]+a[i]+1-1;
            if (a[i+2]>1)
            {
              if (tmp>dp[i+2][1]) dp[i+2][1]=tmp;
            }
            else
            {
              if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            }
            tmp=dp[i][j]+1+a[i+2]-1;
            if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            if (a[i+2]>1)
            {
              tmp=dp[i][j]+1+a[i+2]-1-1;
              if (tmp>dp[i+2][2]) dp[i+2][2]=tmp;
            }
          }
          if (j==1)
          {
            tmp=dp[i][j]+a[i]-1+1-1;
            if (a[i+2]>1)
            {
              if (tmp>dp[i+2][1]) dp[i+2][1]=tmp;
            }
            else
            {
              if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            }
            tmp=dp[i][j]+1+a[i+2]-1;
            if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            if (a[i+2]>1)
            {
              tmp=dp[i][j]+1+a[i+2]-1-1;
              if (tmp>dp[i+2][2]) dp[i+2][2]=tmp;
            }
          }
          if (j==2)
          {
            tmp=dp[i][j]+1+1-1;
            if (a[i+2]>1)
            {
              if (tmp>dp[i+2][1]) dp[i+2][1]=tmp;
            }
            else
            {
              if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            }
            tmp=dp[i][j]+1+a[i+2]-1;
            if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            if (a[i+2]>1)
            {
              tmp=dp[i][j]+1+a[i+2]-1-1;
              if (tmp>dp[i+2][2]) dp[i+2][2]=tmp;
            }
          }
        }
      }
  }
  printf("%d\n",dp[a.size()][0]);
  return 0;
}

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

int main(){
    int arr[5];
    for(int i = 0 ; i < 5 ; i++){
        cin >> arr[i];
        if(arr[i] == 0)
            cout<<i+1;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std ;
 
int main() {
  
 int n ; 
 cin >> n ; 
 long long sum = 0 ; 
 for( int i = 1 ; i <=n ; i ++ )  {
	 for (int j = 1 ; j <= n ; j ++ )  {
		for (int k = 1 ; k<=n ; k ++ )  {
			int x= __gcd(i,j) ; 
			x = __gcd(x,k); 
			sum+= x; 
		}
	}
}
	 cout << sum << endl ; 
  
}
  



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  string S;
  cin>>S;
  int N=S.size();

  bool ok=true;
  for(int i=0;i<N;i++){
    if((i+1)%2){
      if(S[i]=='L') ok=false;
    }else{
      if(S[i]=='R') ok=false;
    }
  }

  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
MOD = 998244353
def main():
    input = sys.stdin.readline
    N, S = map(int, input().split())
    *A, = map(int, input().split())
    # dp[i][j]=i番目まで見て合計がjになる組み合わせの数
    dp = [[0] * (S + 1) for _ in range(N + 1)]
    dp[0][0] = 1
    for i in range(1, N + 1):
        a = A[i - 1]
        for k in range(S + 1):
            # i番目を使わない
            dp[i][k] = (dp[i][k] + dp[i - 1][k] * 2) % MOD
            # i番目を使う
            if k >= a:
                dp[i][k] = (dp[i][k] + dp[i - 1][k - a]) % MOD
    print(dp[N][S])

if __name__ == '__main__':
    main()


Measured memory_bytes: 132336
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	long long N, D; cin >> N >> D;
	long long A, B;
	long long ans = 0;
	for (long long i = 0; i < N; i++) {
		cin >> A >> B;
		if ((A + B) * (A + B) - 2 * A *B <= D * D) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include<cmath>
#include<cstdio>

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

using namespace std;

const double PI=acos(-1);

template<class T>
struct point3{
	T x,y,z;
	point3 operator+(const point3 &a)const{ return (point3){x+a.x,y+a.y,z+a.z}; }
};

template<class T>
point3<T> operator*(T c,const point3<T> &a){
	return (point3<T>){c*a.x,c*a.y,c*a.z};
}

template<class T>
T dot(const point3<T> &a,const point3<T> &b){ return a.x*b.x+a.y*b.y+a.z*b.z; }

template<class T>
point3<T> cross(const point3<T> &a,const point3<T> &b){
	return (point3<T>){a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};
}

// 2012 N 1  1 ú 0:00 ©ç 2012 N mon  day ú hh:mm ÜÅÌoßÔ
double calc_hours(int mon,int day,int hh,int mm){
	const int a[]={-1,31,29,31,30,31,30,31,31,30,31,30,31};
	int d=day-1;
	for(int i=1;i<mon;i++) d+=a[i];
	return 24*d+hh+mm/60.0;
}

// xNg p ð² a ÜíèÉ t [rad] ¾¯ñ]µ½xNgðßé
point3<double> rot(const point3<double> &p,const point3<double> &a,double t){
	return cos(t)*p+(1-cos(t))*dot(p,a)*a+sin(t)*cross(a,p);
}

int n; // ¯Ì
double lat[1000],lon[1000]; // Üx, ox

bool check(double h){
	// x ²³Ìûü 43.2 xÉkÉ¯ª éÆµÄ¢é
	point3<double> a={cos(43.2*PI/180),0,sin(43.2*PI/180)}; // ñ]²
	rep(i,n){
		// ¯ i ÌûüxNg
		point3<double> p={cos(lon[i])*cos(lat[i]),sin(lon[i])*cos(lat[i]),sin(lat[i])};
		if(rot(p,a,(1+1/365.24)*2*PI*h/24).z<0) return false;
	}
	return true;
}

int main(){
	int T; scanf("%d",&T);
	while(T--){
		int mon,day,hh,mm;
		scanf("%d/%d%d:%d",&mon,&day,&hh,&mm);
		double h=calc_hours(mon,day,hh,mm);

		int q; scanf("%d",&q);
		while(q--){
			char name[64];
			scanf("%s%d",name,&n);
			rep(i,n){
				scanf("%lf%lf",lon+i,lat+i);
				lon[i]*=PI/180;
				lat[i]*=PI/180;
			}
			if(check(h)) puts(name);
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int before[100005];
int after[100005];
int counter[100005];

int main(){
	string ss;
	cin>>ss;
	int n = ss.length();
	for(int i=0; ss[i]; i++) s[i+1] = ss[i];
	for(int i=1; i<n; i++){
		if(s[i]=='R' && s[i+1]=='L'){
			before[i] = i;
			after[i] = i;
			before[i+1] = i+1;
			after[i+1] = i+1;
		}
	}
	after[n+1] = n+1;
	for(int i=1; i<=n; i++){
		if(!before[i]) before[i] = before[i-1];
	}
	for(int i=n; i>=1; i--){
		if(!after[i]) after[i] = after[i+1];
	}
	for(int i=1; i<=n; i++){
		if(s[i]=='R'){
			int go = after[i];
			if(go==n+1){
				counter[n]++;
				continue;
			}
			if((go-i)%2) counter[go+1]++;
			else counter[go]++;
		}
		else{
			int go = before[i];
			if(go==0){
				counter[1]++;
				continue;
			}
			if((i-go)%2) counter[go-1]++;
			else counter[go]++;
		}
	}
	for(int i=1; i<=n; i++) cout<<counter[i]<<" ";
}

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

using namespace std;

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

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

using namespace std;

namespace {
constexpr long kMod = 1e9+7;
}

long DFS(vector<vector<long>>& graph, long K, long now, long from) {
  if (K < graph[now].size()) return 0;

  long options = 1;
  long enable_color = K -2;
  if (from == -1) {
    enable_color = K - 1;
  }
  for (long v : graph[now]) {
    if (v == from) continue;
    options *= enable_color--;
    options %= kMod;
  }
  for (long v : graph[now]) {
    if (v == from) continue;
    options *= DFS(graph, K, v, now);
    options %= kMod;
  }
  return options;
}

int main() {
  long N, K;
  cin >> N >> K;
  
  vector<vector<long>> graph(N);
  for (size_t n = 0; n < N - 1; ++n) {
    long v1, v2;
    cin >> v1 >> v2;
    --v1; --v2;
    graph[v1].push_back(v2);
    graph[v2].push_back(v1);
  }
  long res = K * DFS(graph, K, 0, -1);
  
  cout << (res % kMod) << endl;
  
  return 0;
}

Measured memory_bytes: 11520