akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

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

	int n;
	cin >> n;
	for(int i = 0; 4*i <= n; ++i)
		if ((n - 4 * i) % 7 == 0) {
			cout << "Yes\n";
			return 0;
		}
	cout << "No\n";
	return 0;
}

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

/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 */

public class Main {
	
	public static void printlnYN(boolean b){
		if(b) System.out.println("Yes");
		else System.out.println("No");
	}

	public static void main(String[] args) throws IOException {
		
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
    	int S = sc.nextInt();
    	
    	int h = S / 3600;
    	int m = (S % 3600) / 60;
    	int s = S % 60;
    	
    	System.out.println(h+":"+m+":"+s);
    	
	}

}


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

typedef long long ll;

int main(){
    int k;
    cin >> k;
    ll ret = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            int g = gcd(i, j);
            for(int x = 1; x <= k; x++){
                ret += gcd(g, x);
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3624
//grading.cpp
#include<iostream>
using namespace std;

int main()
{
    int i,m,f,r;
    for ( i = 0; i < 50; i++)
    {
        cin>>m>>f>>r;
        if (m==-1 && f==-1 && r==-1) break;
        else if (m==-1 || f==-1) cout<<"F"<<endl;
        else if (m+f>=80) cout<<"A"<<endl;
        else if (m+f>=65) cout<<"B"<<endl;
        else if (m+f>=50) cout<<"C"<<endl;
        else if (m+f>=30)
        {
            if (r>=50) cout<<"C"<<endl;
            else cout<<"D"<<endl;
        }
        else cout<<"F"<<endl;
    }
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();

		String[] list = {"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"};

		String ans = "";

		while(n>0) {
			long m = n%26L;
			if(m==0) {
				m = 26L;
			}
			ans = list[(int) (m-1)]+ans;
			n = (n-m)/26L;
		}
		System.out.println(ans);



	}
}


Measured memory_bytes: 39440
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, k = map(int, input().split())
    s = 0
    while 2 ** s < k:
        s += 1

    ans = 0
    for i in range(1, n+1):
        c = 0
        while i < k:
            i *= 2
            c += 1
        ans += 2 ** (s - c)
    print(ans / ((2 ** s) * n))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<queue>

using namespace std;

#define max_n 3000
#define INF (max_n+100)*(1000+1000)

struct edge{
	int to,cost[2]; ///cost[0] 最少金額 cost[1] 最短距離
};

typedef pair<int,int> P;

int main(void){
	int n,m,k;
	int p,q,r;
	int a,b,c,t;
	vector<edge> N[max_n];
	edge e;
	int d[max_n];
	priority_queue<P,vector<P>,greater<P> > que;
	int v;
	P pi;

	while(1){

		cin>>n>>m;
		if(n==0&&m==0) break;

		for(int i=0;i<max_n;i++) N[i].clear();

		for(int i=0;i<n;i++){
			cin>>a>>b>>c>>t;
			e.to=b,e.cost[0]=c,e.cost[1]=t;
			N[a].push_back(e);
			e.to=a;
			N[b].push_back(e);
		}
	
		cin>>k;

		for(int i=0;i<k;i++){

			cin>>p>>q>>r;

			fill(d,d+n,INF);
			d[p]=0;
			que.push(P(0,p));
			while(!que.empty()){
				pi=que.top();
				que.pop();
				v=pi.second;
				if(d[v]<pi.first) continue;
				for(int j=0;j<N[v].size();j++){
					e=N[v][j];
					if(d[e.to]>d[v]+e.cost[r]){
						d[e.to]=d[v]+e.cost[r];
						que.push(P(d[e.to],e.to));
					}
				}
			}

			cout<<d[q]<<endl;;

		}

	}

	return 0;
}

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

int main(){
	int A,B;
	string S;
	int count = 0;
	cin >> A >> B;
	cin >> S;
	for(int i = 0;i < S.size();i++){
		if(S[i] == '-'){
			count++;
		}
	}

	if(count == 1 && S[A] == '-'){
		if(S.size()==A+B+1)cout << "Yes" << endl;
		else cout << "No" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
long long A,B,K;
cin >> A >> B >> K;
  if(A >= K) cout << A - K << " " << B << endl;
  else if( A + B > K ) cout << 0 << " " << B - (K-A) << endl;
  else  cout << 0 << " " << 0 << endl;
    
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if((max(b,c)-min(c,b))%2==0)cout<<"Alice"<<endl;
  else if((max(c,b)-min(c,b))%2==1)cout<<"Borys"<<endl;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford
from scipy.sparse.csgraph import connected_components

N,M = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in range(M)]

row, col, val = zip(*ABC)
# -1倍しておいて最短路問題にする
val = [-(x) for x in val]
graph = csr_matrix((val,(row,col)),(N+1,N+1))

# 強連結成分に制限。ここに負閉路があればinf～
find_component_graph = csr_matrix(([1]*(M+1),(row+(N,),col+(1,))),(N+1,N+1))
# n = 個数、label=各頂点が属する連結成分のラベル[0,0,1,1,1]
n, labels = connected_components(find_component_graph,connection = 'strong')
idx = (labels == labels[1]) # [False, False, True~]
graph = graph[idx,:][:,idx]

try:
  dist = bellman_ford(graph,indices = [0])[0].astype(int)
  answer = -dist[-1]
except:
  answer = 'inf'

print(answer)

Measured memory_bytes: 14516
N,K=gets.chomp.split(" ").map(&:to_i)
array=gets.chomp.split(" ").map(&:to_i).sort
if K > array[-1]
    puts "IMPOSSIBLE"
    exit
end
all_gcd=array[0]
if all_gcd == K
    puts "POSSIBLE"
    exit
end
(1..(N-1)).each do |i|
    all_gcd = all_gcd.gcd(array[i])
    if K%all_gcd==0
        puts "POSSIBLE"
        exit
    end
end
puts "IMPOSSIBLE"


Measured memory_bytes: 23272
#include<bits/stdc++.h> 
using namespace std;  
#define ll long long  
int main (){  
    ios_base::sync_with_stdio(false);  
    int t;cin>>t;  
    while(t--){  
        ll a,b,ans=0;cin>>a>>b;  
        if(a==b) ans=2*a-2;  
        else {  
            ll tmp=sqrt(a*b);  
            if(tmp*tmp==a*b) tmp--;  
            if(tmp*(tmp+1)>=a*b) ans=2*tmp-2;  
            else ans=2*tmp-1;  
        }  
        cout<<ans<<endl;  
    }  
    return 0;  
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
vector<vector<bool>> visit(30,vector<bool> (30,false));
int graph[30][30][30][30];


int bfs(int a,int b)
{
    int dis[30][30];
    bool visit[30][30];
    FOR(i,0,30) FOR(j,0,30)
    {
        visit[i][j]=false;
        dis[i][j]=-1;
    }
    dis[0][0]=0;
    visit[0][0]=true;
    queue<pair<int,int>> que;
    que.push(mp(0,0));
    int u,v,x,y;
    while (!que.empty())
    {
        u=que.front().fi;
        v=que.front().se;
        que.pop();
        vector<pair<int,int>> around={mp(u-1,v),mp(u+1,v),mp(u,v-1),mp(u,v+1)};
        for (int i=0;i<4;i++)
        {
            x=around[i].fi;
            y=around[i].se;
            if (0<=x && x<=a && 0<= y&& y <= b)
            {
                //cout << x << " " << y << endl;
                //cout <<graph[u][v][x][y] <<!visit[x][y]<< endl;
                if (graph[u][v][x][y] && !visit[x][y])
                {
                    dis[x][y]=dis[u][v]+1;
                    visit[x][y]=true;
                    que.push(mp(x,y));
                    //cout << x << " "<<y << endl;
                }
            }
        }
    }
    return dis[a][b]+1;
}

int main()
{
    vector<int> ans;
    int h,w;
    while (true)
    {
        cin >> h >> w;
        if (h==0 && w==0) break;
        int a;
        FOR(i,0,30) FOR(j,0,30) FOR(k,0,30) FOR (l,0,30) graph[i][j][k][l]=0;
        for (int i=0;i<2*w-1;i++)
        {
            if (i%2==0)
            {
                for (int j=0;j<h-1;j++)
                {
                    cin >> a;
                    if (a==0) 
                    {
                        graph[i/2][j][i/2][j+1]=1;
                        graph[i/2][j+1][i/2][j]=1;
                    }
                    else 
                    {
                        graph[i/2][j][i/2][j+1]=0;
                        graph[i/2][j+1][i/2][j]=0;
                    }
                }
            }
            else
            {
                for (int j=0;j<h;j++)
                {
                    cin >> a;
                    if (a==0)
                    {
                        graph[i/2][j][i/2+1][j]=1;
                        graph[i/2+1][j][i/2][j]=1;
                    } 
                    else 
                    {
                        graph[i/2][j][i/2+1][j]=0;
                        graph[i/2+1][j][i/2][j]=0;
                    }
                }
            }
        }
        ans.push_back(bfs(w-1,h-1));
    }
    for (int i=0;i<ans.size();i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 6248
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
//--------------------
#define MOD 1000000007 
using namespace std;
//--------------------

int main() {

	long res[1000] = {};
	long N; cin >> N;
	long b[1000]; for (int i = 0; i <= N - 1; i++) cin >> b[i];
	long copyb[1000]; for (int i = 0; i <= N - 1; i++) copyb[i] = b[i]; //res代入用。
	
	long turn = 0; //操作順の記述
restart:
	for (int i = N - 1; i >= 0; i--) { //後ろから走査。

		if (b[i] == i + 1) {
			res[turn] = copyb[i]; turn++; 
			for (int j = i + 1; j <= N - 1; j++) if (b[j] != 0) b[j]++;  
			b[i] = 0;
			goto restart;
		}
	}
	for (int i = 0; i <= N - 1; i++) if (b[i] != 0) { cout << "-1" << endl; return 0; }

	for (int i = N - 1; i >= 0; i--) cout << res[i] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll x;
  cin >> x;
  ll p = 100;
  for (int i = 1;; i++) {
    p += p * 0.01;
    if (p >= x) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>

void funcA() {
	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	std::cin >> k;
	std::cout << a[k-1];
}


int main(void) {
	funcA();
	return 0;
}

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

#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define infl 1e18+9
#define sz(a) ((int)a.size())

const int nax=305;
double dp[nax][nax][nax]; 
void solve(){
  int n; cin>>n; 
  vector<int> cnt(4); 
  for(int i=0;i<n;i++) {
    int sushi; cin>>sushi; 
    cnt[sushi]++; 
  }
  //dp[1][0][0]=1; 
  for(int k=0;k<=n;k++){
    for(int j=0;j<=n;j++){
      for(int i=0;i<=n;i++){
        if(i+j+k==0) continue; 
        dp[i][j][k]=1; 
        if(i>0)
        dp[i][j][k]+=(double)i/(n)*dp[i-1][j][k];
        if(j>0)
        dp[i][j][k]+=(double)j/(n)*dp[i+1][j-1][k];
        if(k>0)
        dp[i][j][k]+=(double)k/(n)*dp[i][j+1][k-1]; 
        dp[i][j][k]=n*dp[i][j][k]/(i+j+k); 
      }
    }
  }
  printf("%.10lf\n",dp[cnt[1]][cnt[2]][cnt[3]]); 
}

int main()
{
	fast_io;
	clock_t beg=clock(); 
	solve(); 
	clock_t end=clock(); 
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
	return 0;
}

Measured memory_bytes: 219392
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
ll t,m,k,a[26]={0};
//cin>>t;
//while(t--){
//ll j,k=-1;
ll c=101;
string n;
cin>>n;
for(ll i=0;i<4;i++)
a[n[i]-'A']++;
sort(a,a+26);
if(a[25]==a[24]&&a[25]==2)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}


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


int main(){
  string S;
  cin >> S;
 
 
 int ans = 0;
 int sum = 0;
 int hantei = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C'){ sum += 1; }
    else{ sum = 0; }

    if(sum > ans){ ans = sum; }
    
  }

  cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) {} };
typedef vector<edge> edges;

edges G[3010];
int d[100010];

void dijkstra(int s)
{
    priority_queue<pii, vpii, greater<pii> > pq;
    d[s] = 0;
    pq.push(pii(0, s));
    
    while (pq.size()) {
        pii p = pq.top(); pq.pop();

        int v = p.scd;

        if (d[v] < p.fst) continue;

        rep(i, G[v].size()) {
            edge &e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(pii(d[e.to], e.to));
            }
        }
    }
}

signed main()
{
    omajinai;

    int N, M, K; cin >> N >> M >> K;

    fill_n(d, N + 1, inf);

    rep(i, M) {
        int a, b, l; cin >> a >> b >> l;
        a--, b--;

        G[a].PB(edge(b, l));
        G[b].PB(edge(a, l));
    }

    rep(i, K) {
        int s; cin >> s;
        s--;
        dijkstra(s);
    }

    int ma = -1;

    rep(i, N) {
        rep(j, G[i].size()) {
            edge &e = G[i][j];
            ma = max(ma, (int)(d[i] + round(1. * (d[e.to] - d[i] + e.cost) / 2)));
        }
    }

    cout << ma << endl;
}

Measured memory_bytes: 6092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M,C;
    cin>>N>>M>>C;
    vector<int> B(M);
    rep(m,0,M) cin>>B.at(m);

    int ans=0;
    rep(n,0,N){
        int64_t sum=0;
        rep(m,0,M){
            int a;
            cin>>a;
            sum+=a*B.at(m);
        }
        sum+=C;
        if(sum>0) ans++;        
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define int long long
using namespace std;
int n,A[li],B[li],cev;
main(){
	scanf("%lld",&n);
	for(int i=1;i<=n+1;i++) scanf("%lld",&A[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&B[i]);
	for(int i=1;i<=n;i++){
		if(A[i]<=B[i]){
			cev+=A[i];
			B[i]-=A[i];
			int t=min(B[i],A[i+1]);
			cev+=t;
			A[i+1]-=t;
		}
		else{
			cev+=B[i];
		}
	}
	printf("%lld\n",cev);
	return 0;
}




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

int main()
{
    int a,b,c;
    while(~scanf("%d %d %d",&a,&b,&c))
    {
        if(c>=a&&c<=b)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
 
int main(){
   long k,a,b,c;
   long long bi;
    
   scanf("%ld %ld %ld",&k,&a,&b);
   if (a+1>=b) {
      bi=k+1;
   } else {
      if (k<=a) bi=k+1;
      else {
        k-=a+1;
        bi=b+(k/2)*(b-a)+(k%2);
      }
   }
   printf("%lld\n",bi);
   return 0;
}


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

using namespace std;
using ll = long long;

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

int main() {
  int in(D); ll in(G);

  int ans = 0;
  vector<int> p(D), c(D);
  rep(i, D) {
    cin >> p[i] >> c[i];
    ans += p[i];
  }

  rep(bit, 1 << D) {
    ll score = 0;
    int count = 0, max_i = -1;
    rep(i, D) {
      if (bit & (1 << i)) {
        score += p[i] * 100 * (i+1) + c[i];
        count += p[i];
      } else
        max_i = i;
    }
    if (score < G) {
      if (max_i == -1) continue;
      int tmp = (G - score + 100 * (max_i+1) - 1) / (100 * (max_i+1));
      if (tmp >= p[max_i]) continue;
      count += tmp;
    }
    chmin(ans, count);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }

int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
    double n,m;
    cin>>n;
    cout<<ceil(n/2)/n;
}
 
 








 



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

	int H, R;
	cin>>H>>R;
	if(H>=0) cout<<"1";
	if(H<0 && R + H > 0) cout<<"1";
	if(H<0 && R + H == 0) cout<<"0";
	if(H<0 && R + H < 0) cout<<"-1";
	cout<<endl;
	
	return 0;
}
	



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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s; cin>>s;
    ll ans=INF;
    rep(i,s.size()){
        ll x=stoll(s.substr(i,3));
        ll tmp=abs(753-x);
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N);
	for (int i=0;i<N;i++) {cin >> A[i];}
	for (int i=0;i<N;i++) {cin >> B[i];}
	for (int i=0;i<N;i++) {cin >> C[i];}
	sort(A.rbegin(), A.rend());
	sort(B.rbegin(), B.rend());
	sort(C.rbegin(), C.rend());

	vector<long long> val(N);
	for (int i=0;i<N;i++) {
		val[i] = C.rend()-upper_bound(C.rbegin(), C.rend(), B[i]);
	}

	vector<long long> ruiseki(N+1, 0LL);
	for (int i=0;i<N;i++) {
		ruiseki[i+1] = ruiseki[i]+val[i];
	}
	long long ans = 0LL;
	for (int i=0;i<N;i++) {
		int ind = B.rend()-upper_bound(B.rbegin(), B.rend(), A[i])-1;
		ans += ruiseki[ind+1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 5884
#include <stdio.h>
#include <vector>

using namespace std;

struct Node{
	Node(){
		brother = parent = -1;
		height = depth = num_of_children = 0;
	}
	int parent,brother,depth,num_of_children,height;
	vector<int> children;
};

void calcDepth(Node nodes[],int root_id){
	for(int i = 0;i < nodes[root_id].num_of_children;i++){
		nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
		calcDepth(nodes,nodes[root_id].children[i]);
	}
}

void calcHeight(Node nodes[],int height,int parent){
	nodes[parent].height = max(nodes[parent].height,height+1);
	if(nodes[parent].parent != -1) calcHeight(nodes,height+1,nodes[parent].parent);
}

int main(){
	int n,id,left_id,right_id,root_id;
	scanf("%d",&n);
	Node nodes[n];

	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&id,&left_id,&right_id);
		if(left_id != -1){
			nodes[id].children.push_back(left_id);
			nodes[id].num_of_children++;
			nodes[left_id].parent = id;
		}
		if(right_id != -1){
			nodes[id].children.push_back(right_id);
			nodes[id].num_of_children++;
			nodes[right_id].parent = id;
		}
		if(left_id != -1 && right_id != -1){
			nodes[left_id].brother = right_id;
			nodes[right_id].brother = left_id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(nodes[root_id].parent == -1) break;
	}

	if(n > 1){
		calcDepth(nodes,root_id);

		for(int i = 0; i < n; i++){
			if(nodes[i].num_of_children == 0) calcHeight(nodes,0,nodes[i].parent);
		}
	}

	for(int i = 0; i < n; i++){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
				,i,nodes[i].parent,nodes[i].brother,nodes[i].num_of_children,nodes[i].depth,nodes[i].height);
		if(nodes[i].parent == -1){
			printf(" root\n");
		}else if(nodes[i].num_of_children == 0){
			printf(" leaf\n");
		}else{
			printf(" internal node\n");
		}

	}
}



Measured memory_bytes: 2748
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <vector>

using namespace std;

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

int main()
{
    int64_t n, a, b;
    cin >> n >> a >> b;
   
    if (a > b)
        cout << 0 << endl;
    else if (n == 1 && a != b)
        cout << 0 << endl;
    else
        cout << b * (n - 1) + a - (b + a * (n - 1)) + 1 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	ll N, A, B;
	cin >> N >> A >> B;
	ll X[N];
	rep(i, 0, N) cin >> X[i];
	ll dp[N];
	fill(dp, dp + N, INF);

	dp[0] = 0;
	rep(i, 0, N - 1) {
		dp[i + 1] = min(dp[i + 1], min(dp[i] + (X[i + 1] - X[i]) * A, dp[i] + B));
	}

	cout << dp[N - 1] << endl;
	
}


Measured memory_bytes: 1792
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n;
    std::cin >> n;

    long long pon = n % 10;
    if (pon == 3) {
        std::cout << "bon" << std::endl;
    } else if (pon == 0 || pon == 1 || pon == 6 || pon == 8) {
        std::cout << "pon" << std::endl;
    } else {
        std::cout << "hon" << std::endl;
    }
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>

int main() {
	long long int n;
	scanf("%lld", &n);
	for (long long int i = -1000; i <= 1000; i++) {
		for (long long int j = -1000; j <= 1000; j++) {
			//printf("%lld", i * i * i * i * i - j * j * j * j * j);
			if (i * i * i * i * i - j * j * j * j * j == n) {
				printf("%lld %lld", i, j);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1736
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

class Main {
    static Scanner sc;

    private static void nextArr(int[] h) {
        for(int i = 0; i < h.length; i++) h[i] = sc.nextInt();
    }

    private static int nextInt() {
        return sc.nextInt();
    }

    private static void print(Object... vals) {
        for(int i = 0; i < vals.length; i++) {
            if (i != vals.length - 1) {
                System.out.print(vals[i] + ",");
            } else {
                System.out.print(vals[i]);
            }
        }
        System.out.println();
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        nextArr(h);

        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for(int i = 1; i < n; i++) {
            for(int j = 1; j <= k; j++) {
                if (i - j >= 0 && dp[i - j] != Integer.MAX_VALUE) {
                    dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
                }
            }
        }
        print(dp[n - 1]);
    }
}


Measured memory_bytes: 50596
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
int main()
{
	RI(n);
	priority_queue<ll> pq;
	DO(n) {
		ll a;
		RD(a);
		pq.push(a);
	}
	ll k = 0;
	while (pq.top() + k >= n) {
		ll v = pq.top() + k;
		pq.pop();
		ll q = v / n, r = v % n;
		k += q;
		pq.push(r - k);
	}
	PL(k);
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn= new Scanner(System.in);
        int A = stdIn.nextInt();
        int B = stdIn.nextInt();
        int C = stdIn.nextInt();
        int X=A;
        A=B;
        B=X;
        X=A;
        A=C;
        C=X;
        
        System.out.println(A+" "+B+" "+C);
    }
}

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

ll r, g, b;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;


  /*
  for(int i=0; i<n; ++i)
		s[i]=='R'? r++: s[i]=='G'? g++: b++;

  ll ans = r*g*b;
  */
  
  ll cntR = 0, cntG = 0, cntB = 0;
  rep(i, n) {
    if (s[i] == 'R') cntR++;
    else if (s[i] == 'G') cntG++;
    else if (s[i] == 'B') cntB++;
  }

  ll ans = cntR * cntG * cntB;
  

  rep(i, n) {
    repI(j, i+1, n) {
      int k = 2*j - i;
      if (k >= n) break;
      if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,a,b;
  string str;
  while(1){
    getline(cin,str);
    if(str[0] == '0') break;

    a = 0;
    b = 0;
    for(i=1;i<str.size();i++){
      /*     if(a >= 11 && b < 10 || a >= 10 && b >= 10 && a-b >=2){
	  a++;
	  break;
	}
	else if(b >= 11 && a < 10 || a >= 10 && b >= 10 && b-a >=2){
	  b++;
	  break;
	  }*/
	 if(str[i] == 'A') a++;
	 else if(str[i] == 'B') b++;
	}

    if(a>b) a++;
    else b++;

      cout << a << " " << b << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long cols,rows,total;
  total = 0;
  cin >> rows;
  cin >> cols;
  if(cols == 1 || rows == 1){
    cout << 1;
  }
  else if(cols%2 !=0){
    total = rows * (cols/2+1) - rows/2;
    cout << total;
  }else{
    total = rows * (cols/2);
    cout << total;
  }
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int main() {
	string s;
	cin >> s;
	bool c[265];

	REP(i, s.size())c[s[i] - 'a'] = true;
	cout << (c[0] && c[1] && c[2] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
package main

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

func answer(reader io.Reader, writer io.Writer) {
	var a,b,c int
	_, _ = fmt.Fscan(reader, &a, &b, &c)
	for i:=0; i<10; i++ {
		c = a * c - b
		_, _ = fmt.Fprintf(writer, "%d", c)
		if i != 9 {
			_, _ = fmt.Fprint(writer,"\n")
		}
	}
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MAXN = 2160;
int pfac[MAXN]; // pfac[i] = largest prime factor of i
int main() {
	vector<ll> primes;
	for (int i = 2; i < MAXN; ++i) pfac[i] = i;
	for (int i = 2; i < MAXN; ++i)
		if (pfac[i] == i) {
			primes.push_back((ll)i * i * i);
			for (int j = i + i; j < MAXN; j += i)
				pfac[j] = i;
		}
	int n;
	scanf("%d", &n);
	int ans = 0;
	map<ll, int> amt;
	for (int i = 0; i < n; ++i) {
		ll s;
		scanf("%lld", &s);
		for (ll p : primes) {
			while (s % p == 0) s /= p;
		}
		amt[s]++;
	}
	set<ll> used;
	for (auto& v : amt) {
		if (v.first == 1) {
			++ans;
			continue;
		}
		// Find the complement.
		__int128 x = v.first;
		x *= x;
		for (ll p : primes) {
			while (x % p == 0) x /= p;
		}
		if (x <= (ll)1e10 && amt.count(x) && !used.count(x)) {
			ans += max(v.second, amt[x]);
			used.insert(v.first);
			used.insert(x);
		}
	}
	for (auto& v : amt) {
		if (v.first != 1 && !used.count(v.first)) ans += v.second;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int r=0;
int l=0;
string S;
int main(){
	cin>>N>>S;
	REP(i,N){
		if(S[i]=='W'){
			r++;
		}else{
			l++;
		}
	}
	int tr=0;
	int tl=0;
	int ans=N+10;
	REP(i,N){
		if(S[i]=='W'){
			r--;
			ans=min(ans,l+tr);
			tr++;
		}else{
			l--;
			ans=min(ans,l+tr);
			tl++;
		}
	}
	cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 900
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();

		int ans = Math.min(B/A, C);
		System.out.println(ans);

	}

}

Measured memory_bytes: 22868
#include"bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
 
using namespace std;
 
#define MAX 4002
 
 
long long int dp[MAX][2002][2];
 
int A;
int B;
 
bool use[MAX][2002][2];
#define MOD 1000000007
 
long long int C[2002][2002];
long long int su[2002][2002];
 
inline long long int dfs(int a, int b, int c) {
	if (a == A + B) {
		return 1;
	}
	if (use[a][b][c]) {
		return dp[a][b][c];
	}
	use[a][b][c] = true;
	dp[a][b][c] = 0;
	if (c == 0) {
		if (a + 1 <= A) {
			//choose A
			dp[a][b][c] += dfs(a + 1, b, c);
		}
		//choose B
		if (B) {
			int resta = A - a;
			int restb = B;
			int rng = B;
			rng--;
			for (int i = 0; i <= rng; i++) {
				int placeA = rng - i;
				if (placeA <= resta) {
					dp[a][b][c] += dfs(a + B, B - i-1, 1)*C[rng][placeA];
					if (dp[a][b][c] >= MOD) {
						dp[a][b][c] %= MOD;
					}
				}
			}
		}
	}
	if (c == 1) {
		int selb = B - b;
		int sela = a - selb;
		int resta = A - sela;
		if (resta) {
			dp[a][b][c] += dfs(a + 1, b, c);
		}
		//choose B
		int restb = b;
		if (restb) {
			int rng = restb;
			rng--;
			int mint = min(resta, rng);
			dp[a][b][c] += su[rng][mint];
			if (dp[a][b][c] >= MOD)dp[a][b][c] %= MOD;
		}
	}
	return dp[a][b][c];
}
 
int main() {
	C[0][0] = 1;
	for (int i = 0; i < 2000; i++) {
		for (int j = 0; j <= i; j++) {
			C[i + 1][j] += C[i][j];
			C[i + 1][j + 1] += C[i][j];
			C[i + 1][j] %= MOD;
			C[i + 1][j + 1] %= MOD;
		}
	}
	for (int i = 0; i < 2000; i++) {
		for (int j = 0; j < 2000; j++) {
			su[i][j] = C[i][j];
			if (j) {
				su[i][j] += su[i][j - 1];
				su[i][j] %= MOD;
			}
		}
	}
	cin >> A >> B;
	long long int ans = dfs(0, 0, 0);
	ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 203264
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 987654321
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

double r;
int main() {
	cin >> r;
	cout <<  M_PI * 2 * r;
}

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

long long n, x, s, d, a[100005];
int main() {
	int i;
	cin >> n >> x >> a[0];
	for(i=1; i<n; i++) {
		scanf("%d", &a[i]);
		d = a[i] + a[i-1] - x;
		if(d > 0) {
			a[i] = max(a[i]-d, 0LL);
			s += d;
		}
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll osum[100050];
ll sum[100050];
ll getans(int N) {
	ll rv = 0, del = 0, i;
	for (i = 1; i <= N; i++) {
		ll t = sum[i] + del;
		if (i % 2 == 0 && t >= 0) {
			del -= 1 + t;
			rv += 1 + t;
		}
		if (i % 2 == 1 && t <= 0) {
			del += 1 - t;
			rv += 1 - t;
		}
	}
	return rv;
}
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		ll t;
		scanf("%lld", &t);
		osum[i] = osum[i - 1] + t;
	}
	for (i = 1; i <= N; i++) sum[i] = osum[i];
	ll ans = getans(N);
	for (i = 1; i <= N; i++) sum[i] = -osum[i];
	return !printf("%lld\n", min(ans, getans(N)));
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main()
{
	int n, x;
	cin >> n >> x;

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	sort(all(a));

	cout << n + ((x - accumulate(all(a), 0)) / a.front()) << endl;
}


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

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

    vector<int> h(N);
    for (auto& x : h) cin >> x;

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

    int ans = 1 << 30;
    for (int i = 0; i < N - K + 1; i++) {
        ans = min(ans, h[i + K - 1] - h[i]);
        //cerr << i << " " << h[i] << " " << h[i + K - 1] << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pdd = pair<double, double>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int N, K;
double x[60], y[60], c[60], r[60];

double dist(const pdd &a, const pdd &b) {
	double xx = a.X - b.X;
	double yy = a.Y - b.Y;
	return sqrt(xx * xx + yy * yy);
}
vector<pair<double, double>> inter(int a, int b) {
	vector<pair<double, double>> ret;
	double d = dist(pdd(x[a], y[a]), pdd(x[b], y[b]));

	if (r[a] + r[b] < d) return ret;
	if (x[a] == x[b] && y[a] == y[b] || d < abs(r[a] - r[b])) return { { x[a], y[a] } };

	double tmp = (r[a] * r[a] - r[b] * r[b] + d * d) / (2 * d);
	double h = sqrt(r[a] * r[a] - tmp * tmp);

	double xx = x[a] + tmp / d * (x[b] - x[a]);
	double yy = y[a] + tmp / d * (y[b] - y[a]);

	ret.emplace_back(xx + h * (y[b] - y[a]) / d, yy - h * (x[b] - x[a]) / d);
	ret.emplace_back(xx - h * (y[b] - y[a]) / d, yy + h * (x[b] - x[a]) / d);

	return ret;
}
int check(double t) {
	for (int i = 0; i < N; ++i) r[i] = t / c[i];

	int ret = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			auto pts = inter(i, j);
			for (auto &p : pts) {
				int cnt = 0;
				for (int k = 0; k < N; ++k)
					if (dist(p, pdd(x[k], y[k])) <= r[k] + 1e-9) ++cnt;
				ret = max(ret, cnt);
			}
		}
	}

	return ret;
}
int main() {
	fastio;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) cin >> x[i] >> y[i] >> c[i];

	double s = 0, e = 282850;
	while (s < e - 1e-9) {
		double m = (s + e) / 2.0;
		
		if (check(m) < K) s = m;
		else e = m;
	}

	cout << fixed << setprecision(9) << (s + e) / 2.0;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------

ll d = pow(10,9)+7;


long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}




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

	string in;
	cin >> in;
	if (in == s) a--;
	if (in == t) b--;

	cout << a << " " << b << endl;

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b;
  for(int i=0; i<a; i++){
    int d;
    cin>>d;
    if(d>b-d){
      c+=2*(b-d);
    }
    else{
      c+=d*2;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
    int key;
    Node* parent;
    Node* left;
    Node* right;
};

Node* root, *NIL;

void insert(int _key){

    Node* y = NIL;
    Node* x = root;
    Node* z;

    z = new Node;
    z->key = _key;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }

    }
}

Node* find(Node* _root, int _key){
    while((_root!=NIL)&&(_key!=_root->key)){
        if(_key < _root->key){
            _root = _root->left;
        }else{
            _root = _root->right;
        }
    }
    return _root;
}

void inParse(Node* u){
    if(u==NIL) return;
    inParse(u->left);
    printf(" %d", u->key);
    inParse(u->right);
}

void preParse(Node* u){
    if(u==NIL) return;
    printf(" %d", u->key);
    preParse(u->left);
    preParse(u->right);
}

int main(){

    int n;
    scanf("%d", &n);

    for(int i=0; i<n; i++){
        string str;
        cin >> str;
        if(str == "insert"){
            int key;
            scanf("%d", &key);
            insert(key);
        }else if(str == "find"){
            int key;
            scanf("%d", &key);
            Node* t = find(root, key);
            if(t ==NIL) printf("no\n");
            else printf("yes\n");
        }else if(str == "print"){
            inParse(root);
            printf("\n");
            preParse(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 22016