akhauriyash/Code-Regression huggingface dataset:
data = int(input())

counter = 50
q = data // counter
r = data % counter

a = (counter - 1 + q) + counter - (r - 1)
b = (counter - 1 + q) - r

answer = [a] * r + [b] * (counter - r)
print(counter)
print(' '.join(list(map(str, answer))))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
bool isPrime(ll n) 
{ 
   
   if (n <= 1)  return false; 
   if (n <= 3)  return true; 
 
   if (n%2 == 0 || n%3 == 0) return false; 
 
   for (ll i=5; i*i<=n; i=i+6) 
       if (n%i == 0 || n%(i+2) == 0) 
          return false; 
 
   return true; 
} 
ll minthis(ll a, ll b){
if(a < b){
return a;
}
return b;
}
ll maxthis(ll a, ll b){
if(a > b){
return a;
}
return b;
}
int gcd(int a, int b){
   if( a<0 ) a = -a;
   if( b<0 ) b = -b;
   while( b!=0 ){
       a %= b;
       if( a==0 ) return b;
       b %= a;
   }
   return a;
}
 
int findLargestDivisor(int n) 
{ 
int max = 1;
   for (int i = 2; i < n; i++) {        
       if(n %(i) == 0) { 
           max = i;
       } 
    }
   return max;     
} 
 
 
ll power(ll x, ll y)  
{  
   ll temp;  
   if(y == 0)  
       return 1;  
   temp = power(x, y / 2);  
   if (y % 2 == 0)  
       return temp * temp;  
   else
   {  
       if(y > 0)  
           return x * temp * temp;  
       else
           return (temp * temp) / x;  
   }  
} 
bool sortbysec(const pair<int, int>& a, 
               const pair<int, int>& b) 
{ 
   return (a.second < b.second); 
} 
void solve(){
    int n;
    cin >> n;
    set<int> s;
    map<int,int> mp;
    vector<int> v;
    for(int i = 0 ; i < n ; i++){
        int x;
        cin >> x;
        mp[x]++;
        s.insert(x);
    }
    for(auto x : s){
        v.pb(x);
    }
    int ans = 0;
    sort(v.begin(),v.end());
    for(int i = 0 ; i < (int)v.size() ;i++){
        for(int j = i+1 ; j < (int)v.size() ; j++){
            int sum = v[i]+v[j]; 
            for(int k = j+1 ; k < (int)v.size() ; k++){
                if(v[k] < sum){
                    ans += mp[v[i]]*mp[v[j]]*mp[v[k]];
                }
                else{
                    break;
                }
            }
        }
        
    }
    cout << ans << "\n";
}
int main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
    solve();
    }
  return 0; 
}



  



Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		boolean f=false;;
		while(sc.hasNext()){
			if(f){
				System.out.println();
			}
			abacus(sc.nextInt());
			f=true;
		}
	}
	static void abacus(int n){
		//System.out.println(n);
		char ch[][]=new char[5][8];
		int m[]=new int[5];
		if(n>=10000){
			m[0]=n/10000;
			n%=10000;
		}
		if(n>=1000){
			m[1]=n/1000;
			n%=1000;
		}
		if(n>=100){
			m[2]=n/100;
			n%=100;
		}
		if(n>=10){
			m[3]=n/10;
			n%=10;
		}
		m[4]=n;
		for(int i=0;i<5;i++){
			//System.out.println(m[i]);
			switch(m[i]){
			case 0:{
				ch[i]="* = ****".toCharArray();
				break;
			}
			case 1:{
				ch[i]="* =* ***".toCharArray();
				break;
			}
			case 2:{
				ch[i]="* =** **".toCharArray();
				break;
			}			
			case 3:{
				ch[i]="* =*** *".toCharArray();
				break;
			}			
			case 4:{
				ch[i]="* =**** ".toCharArray();
				break;
			}			
			case 5:{
				ch[i]=" *= ****".toCharArray();
				break;
			}			
			case 6:{
				ch[i]=" *=* ***".toCharArray();
				break;
			}			
			case 7:{
				ch[i]=" *=** **".toCharArray();
				break;
			}			
			case 8:{
				ch[i]=" *=*** *".toCharArray();
				break;
			}			
			case 9:{
				ch[i]=" *=**** ".toCharArray();
				break;
			}
			}
		}
		for(int i=0;i<8;i++){
			for(int j=0;j<5;j++){
				System.out.print(ch[j][i]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
int IM = 1e16;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n) {for (int i = 0 ; i < n ; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void PTN(int n = 1, int a = 0, int b = 0, int c = 0) { if (n--)cout << a << " "; if (n--)cout << b << " "; if (n--)cout << c << " "; cout << endl; }
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <-------------------------------------------------------------------------------------------------------------------------------------------------------------------------> Ignore This--> memset substr pop_back  insert tuple first second push_back string continue make_pair break deque stack queue sort reverse accumulate  count lower_bound upper_bound next_permutation copy_n __builtin_popcount make_tuple
// <========================================================================================================================================================================

signed  main() {
    SPD_emergency
    
    int i, j, k, x, y, u;
    //int t; cin >> t; while (t--)
    {
        int a, b, c, k;
        cin >> a >> b >> c >> k;
        int ans = min(k,a);
        k = k-ans;
        if(k){
            j = min(k,b);
            k = k - j;
        }
        if(k){
            j = min(k,c);
            ans = ans - j;
        }
        cout << ans << endl;

    }
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>

using namespace std;

#define S_MOD 1000000007

void main_body( void )
{
	int N;
	long long A[ 200000 ];
	long long total = 0;
	long long ans = 0;

	cin >> N;

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

		total += A[ i ];
	}

	for ( int i = 0; i < ( N - 1 ); i++ )
	{
		total -= A[ i ];

		ans += (total % S_MOD) * A[ i ];
		ans %= S_MOD;
	}

	cout << ans << endl;

	return;
}

int main( int argc, char *argv[] )
{
	int c;

	if ( argc > 1 )
	{
		c = atoi( argv[ 1 ] );
	}
	else
	{
		c = 1;
	}

	for ( int i = 0; i < c; i++ )
	{
		main_body();
	}

	return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    int ans = b / 2;
    if(a <= 5) ans = 0;
    if(a > 12) ans = b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;

int n,a[N];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i];
	}
	int pt=n;
	for (int i=1;i<=n;i++){
		cout << a[pt] <<
		(i==n?"\n":" ");
		if ((pt&1)==(n&1)){
			if (pt==1){
				pt++;
			}else if (pt==2){
				pt--;
			}else{
				pt-=2;
			}
		}else{
			pt+=2;
		}
	}
}

Measured memory_bytes: 2944
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,x;
inline int read(){
	int k=0,f=1; char c=getchar();
	while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while('0'<=c&&c<='9')k=k*10+c-'0',c=getchar();
	return k*f;
}
int main(){
	a=read(); b=read(); x=read();
	if(x>=a&&x<=a+b) puts("YES");
	else puts("NO");
	return 0;
} 

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

int main(){
  int N,count = 0;
  long long D,p,q;
  cin >> N >> D;

  for(int i = 0;i < N;i++){
    cin >> p >> q;
    if(p*p+q*q <= D*D){
      count += 1;
      // cout << "OK: "<< p*p+q*q << "<="<< D*D << endl;
    }

  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3480
#include <iostream>
#include <cstdio>
using namespace std;
double dp[2][3001]={},ar[3001],to=0;
int main()
{
	int n;cin>>n;
	for (int i=0;i<n;i++) {cin>>ar[i];}
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			dp[i%2][j] = (dp[(i-1)%2][j-1] * ar[i-1]) + (dp[(i-1)%2][j] * (1-ar[i-1])); 
		}
	}
	for (int j=n/2+1;j<=n;j++)
	{
		to+=dp[n%2][j];
	}
	printf("%.9lf\n",to);
	return 0;
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
C=[list(map(int,input().split())) for d in range(N)]

money=[]
for i in range(2**N):
    K=[]
    for l in range(M):
        K.append(0)
    total=0
    for k in range(N):
        if (i>>k)&1==1:
            for j in range(1,M+1):
                K[j-1]+=C[k][j]
            total+=C[k][0]
    if min(K)>=X:
        money.append(total)
try:
    print(min(money))
except:
    print(-1)

Measured memory_bytes: 68720
s = input()
n = len(s)
sp1 = s[:int((n - 1) / 2)]
sp2 = s[int((n + 3) / 2 - 1):]
if s == s[::-1] and sp1 == sp1[::-1] and sp2 == sp2[::-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using ll = long long;
using namespace std;

#define MX 100001

int N, C;
bool arr[30][MX] = {};
int ans[MX] = {};

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

    cin >> N >> C;
    for (int i = 0; i < N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        for (int j = s; j <= t; j++) {
            arr[c - 1][j - 1] = true;
        }
    }
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < MX; j++) {
            if (arr[i][j]) {
                ans[j]++;
            }
        }
    }
    int mx = 0;
    for (int i = 0; i < MX; i++) {
        if (mx < ans[i]) {
            mx = ans[i];
        }
    }
    cout << mx << endl;
    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}
// DO NOT USE ロリﾊッ!
int main() {
  int n;
  string s,t;
  cin >> n >> s >> t;
  int ans = n;
  rep(i,n) {
    bool ok = true;
    REP(j,i,n) if( s[j] != t[j-i] ) { ok = false; break; }
    if( ok ) break;
    ++ans;
  }
  cout << ans << endl;
  compute();
  return 0;
}


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

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

typedef long long LL;
typedef unsigned long long ULL;

LL dp[1010][1010];
char M[1010][1010];
int n, m;

vector<pii> dir = {{1,0},{0,1}};

bool isSafe(int i, int j)
{
	return i >= 0 && i < n && j >= 0 && j < m && M[i][j] == '.';
}

int numberOfPaths()
{
	dp[0][0] = 1;
	queue<pii> Q;
	Q.push(mp(0,0));

	while(!Q.empty())
	{
		pii cur = Q.front();
		Q.pop();
		for(auto d : dir){
			int i = d.fi+cur.fi;
			int j = d.se+cur.se;
			if(!isSafe(i,j)) continue;
			pii adj = {i, j};
			if(dp[i][j] == 0)
				Q.push(adj);
			
			dp[i][j] += dp[cur.fi][cur.se];
			dp[i][j] %= 1000000007;

			
		}
	}

	return dp[n-1][m-1];
}

int main(void)
{
	fastIO();
	
	cin >> n >> m;
	
	FOR(i,0,n)
		FOR(j,0,m)
			cin >> M[i][j];

	cout << numberOfPaths() << endl;

}

Measured memory_bytes: 9088
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void countingSort(int *A, int *B, int k, int n){
  int i, j, C[VMAX];
  for (i = 0; i <= k; i++){
    C[i] = 0;
  }
   /* C[i] に i の出現数を記録する */
   for (j = 1; j <= n; j++){
     C[A[j]]++;
   }
   for (i = 1; i <= k; i++){
     C[i] = C[i] + C[i - 1];
   }
   for (j = n; j >= 1; j--){
     B[C[A[j]]] = A[j];
     C[A[j]]--;
   }
   return;
}

int main(){
  int *A, *B;
  int C[VMAX+1];
  int n, i, j, k = 0;

  scanf("%d", &n);

  A = (int *)malloc(sizeof(int)*n);
  B = (int *)malloc(sizeof(int)*n);

  for(i = 1; i <= n; i++){
    scanf("%hu", &A[i]);
    if (k <= A[i]) {k = A[i];}
  }

  countingSort(A, B, k, n);

  printf("%hu", B[1]);
  for (i = 2; i <= n; i++){
    printf(" %hu", B[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 17448
n=int(input())
a=list(map(int,input().split()))
m=min(a)
M=max(a)
ans=10**8
cnt=0
if m-M==0:
    ans=0
for i in range(m,M):
    for j in range(n):
        cnt+=(a[j]-i)**2
    ans=min(ans,cnt)
    cnt=0
print(ans)

Measured memory_bytes: 3064
n = int(input())
h = [int(v) for v in input().split()]

h[0] -= 1
for i in range(1, len(h)):
    if h[i] < h[i - 1]:
        print('No')
        break
    if h[i] - 1 >= h[i - 1]:
        h[i] -= 1
else:
    print('Yes')


Measured memory_bytes: 63984
def D_GatheringChildren():
    S = input()
    N = len(S)
    ans = [1] * N
    for x in range(N-2):
        # 左から順番にRL境界まで移動する
        if ("R" == S[x]) and ("R" == S[x+1]):
            # 偶奇は交わらない
            ans[x+2] += ans[x]
            ans[x] = 0
    for x in range(N-2):
        # 右から順番にRL境界まで移動する
        if ("L" == S[-x-1]) and ("L" == S[-x-2]):
            # 偶奇は交わらない
            ans[-x-3] += ans[-x-1]
            ans[-x-1] = 0
    print(*ans)

if __name__ == "__main__":
    D_GatheringChildren()

Measured memory_bytes: 6400
#include <iostream>

using namespace std;

bool isprime(int n) {
	for (int i = 2; i * i <= n; i++)
		if (n % i == 0)
			return false;
	return n != 1;
}

int main() {
	int n;
	bool prime[50000];
	for (int i = 2; i < 50000; i++)
		if (isprime(i))
			prime[i] = true;
		else
			prime[i] = false;
	while (cin >> n && n) {
		int ans = 0;
		for (int i = 2; i * 2 <= n; i++)
			if (prime[i] && prime[n-i])
				ans++;
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 1204
import java.util.*;

class Main {

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		for(;;){
			int n = in.nextInt(), m = in.nextInt();
			if(n==0 && m==0) break;
			int dict[] = new int[1500*1000 + 2];
			int hs[] = new int[n+1];
			int ws[] = new int[m+1];
			for(int i=1; i<=n; i++) hs[i] = in.nextInt() + hs[i-1];
			for(int i=1; i<=m; i++) ws[i] = in.nextInt() + ws[i-1];
			for(int i=0; i<=n; i++){
				for(int j=i+1; j<=n; j++){
					dict[hs[j]-hs[i]]++;
				}
			}
			int ans = 0;
			for(int i=0; i<=m; i++){
				for(int j=i+1; j<=m; j++){
					ans += dict[ws[j]-ws[i]];
				}
			}
			System.out.println(ans);
		}
	}

}

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

int main(){
	long long int A, B, N, i, x;
	cin >> A >> B >> N;
/*//	long long int end = N/(B-1)+1;
	long long int max = (A*N/B) - A*(N/B);
	
//	for(i=1; i<=end; i++){
		x = (B-1)*i;
//		if(x<=N){
			int floor = (A*x/B) - A*(x/B);
//			if(floor > max)	max = floor;
//		}
//	}
	if(floor>max)	max = floor;
	
	cout << max << endl;
*/	
	
	long long int f1 = A*N/B;
	long long int f2 = A*(B-1)/B;
	
	cout << min(f1,f2) << endl;
	
	return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

const int mod = 1000000007; // 998244353;
struct mint {
  long long x;
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    return mint(*this) += a;
  }
  mint operator-(const mint& a) const {
    return mint(*this) -= a;
  }
  mint operator*(const mint& a) const {
    return mint(*this) *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint& a) { return *this *= a.inv(); }
  mint operator/(const mint& a) const {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

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

  vector<mint>sx(n+1);
  vector<mint>sy(m+1);
  for(int i=n-1;i>=0;i--){
    sx[i]=sx[i+1]+x[i];
  }
  for(int i=m-1;i>=0;i--){
    sy[i]=sy[i+1]+y[i];
  }

  mint lx=0,ly=0;
  rep(i,n){
    lx+=sx[i]-(mint)x[i]*(n-i);
  }
  rep(i,m){
    ly+=sy[i]-(mint)y[i]*(m-i);
  }

  cout<<lx*ly<<endl;

  return(0);
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define li long long 
using namespace std ; 
int main(){
	int n ; 
	cin>> n ; 
	vector<int> a(n) ; 
	int p = 0 ; 
	for(int i = 0 ; i < n; ++i){
		int x ; 
		cin>> x ; 
		if(x%2 == 0){
			if(x%3 != 0 && x%5 != 0){
			      p = 1; 
			}
		}
	}
	if(p == 1)
	cout<<"DENIED"<<endl;
	else 
	cout<<"APPROVED"<<endl;
	
 


}


Measured memory_bytes: 256
import math
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A +1):
    Y = X -i*500
    
    for j in range(B + 1):
        Z = Y - j*100
        if Z >= 0 and Z/50 <= C:
            count += 1

print(str(count))

Measured memory_bytes: 9148
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;

int main() {
	
	long long int n;
	cin >> n;
	cout << (n - 1)*n / 2 << endl;


	return 0;


}

Measured memory_bytes: 256
// AOJ 2952 Hokkaido University Easy
// 2019.8.8 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	do *s = gc();
	while (*s++ > ' ');
	*(s-1) = 0;
}

#define ABS(x)    ((x)>=0?(x):-(x))

int H, W;
char a[32][32];

int main()
{
	int r, c, r2, c2, dr, dc, ans;
	
	H = in(), W = in();
	for (r = 0; r < H; r++) ins(a[r]);
	ans = 0;
	for (r = 0; r < H; r++) for (c = 0; c < W; c++) if (a[r][c] == 'B') {
		for (r2 = H-1; r2 >= r; r2--) {
			dr = ABS(r2 - r);
			if (dr+W <= ans) goto next;
			for (c2 = W-1; c2 >= 0; c2--) if (a[r2][c2] == 'B') {
				dc = ABS(c2-c);
				if (dr + dc > ans) ans = dr + dc;
			}
		}
	next:;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const ll N = 5e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

int main()
{   
    ll n;
    cin >> n;
    ll a[n+1],b[n+1],c[n+1];
    FOR(i,1,n)cin >> a[i] >> b[i] >> c[i];
    ll dp[n+1][3] = {0};
    dp[1][0] = a[1]; dp[1][1] = b[1]; dp[1][2] = c[1];
    FOR(i,2,n){
        dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2]));

    return 0;
}

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

vector<int> cont(int n, vector<int> a)
{
    vector<int> b(n, 0);

    rep(i, n)
    {
        int l = max(0, i - a.at(i));
        int r = min(n - 1, i + a.at(i));
        b.at(l)++;
        if (r + 1 < n)
            b.at(r + 1)--;
    }

    for (int i = 1; i < n; ++i)
        b.at(i) += b.at(i - 1);

    return b;
}

int main(void)
{
    int n, k;
    cin >> n >> k;

    vector<int> a(n), b(n, 0);

    rep(i, n)
    {
        cin >> a.at(i);
    }


    int rp = min(k, 41);

    rep(i, rp)
    {
        a = cont(n, a);
    }

    rep(i, n)
    {
        cout << a.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 6392
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n, s;
  cin >> n >> s;
  auto dp = make_nd_vector(3005, 3005, 0ll);
  auto a = make_nd_vector(3005, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= s; j++) {
      dp[i][j] += dp[i - 1][j] * 2;
      dp[i][j] %= 998244353;
      if (j - a[i] >= 0) {
        dp[i][j] += dp[i - 1][j - a[i]];
        dp[i][j] %= 998244353;
      }
    }
  }
  cout << dp[n][s] << endl;
}


Measured memory_bytes: 73728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


ll search(ll pos, ll nd, ll k, ll num){
    if(pos == nd){
        if(k == 1){
            cout << num << endl;
            exit(0);
        }else{
            return 1;
        }
    }

    ll start, end;
    if(pos == 0){
        start = 1;
        end = 9;
    }else{
        start = max(0LL, num % 10 - 1);
        end = min(9LL, num % 10 + 1);
    }
    ll ret = 0;
    for(ll x = start; x <= end; ++x){
        ret += search(pos + 1, nd, k - ret, 10 * num + x);
        if(ret >= k){ return ret; }
    }
    return ret;
}

void solve(long long K){
    ll count = 0;
    for(ll nd = 1; nd <= 10; ++nd){
        count += search(0, nd, K - count, 0);
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;


vec a(18), b(18);
class BIT{
        ll n;
  		vector<ll> bitree;
    public:
    	BIT(unsigned long _n) : bitree(_n + 1, 0){
          n = _n;
        }
    	void add(ll id, ll x){
          while(id <= n){
            bitree[id] += x;
            id += id & -id;
          }
          return;
        }
    	ll sum(ll id){
          ll temp = 0;
          while(id > 0){
            temp += bitree[id];
            id -= id & -id;
          }
          return temp;
        }
  };
ll solve(ll s){
    vec na(0), nb(0);
    rep(i,N){
        if((((s>>i)&1) ^ i) & 1)nb.push_back(i);
        else na.push_back(i);
    }
    /*if(s == INF){
        cout<<na[0]<<' '<<na[1]<<' '<<na[2]<<endl;
        cout<<nb[0]<<' '<<nb[1]<<endl;
    }*/
    if(nb.size() != N/2) return INF;
    sort(ALL(na), [&](int x, int y){
        if(a[x] == a[y]) return x < y;
        return a[x] < a[y];
    });
    sort(ALL(nb), [&](int x, int y){
        if(b[x] == b[y]) return x < y;
        return b[x] < b[y];
    });
    /*cout<<s<<endl;
    cout<<na[0]<<' '<<na[1]<<endl;
    cout<<nb[0]<<endl;*/
    ll last = a[na[0]], res = 0;
    BIT bit(20);
    rep(i,N){
        int id = (i&1 ? nb[i/2] : na[i/2]);
        int ele = (i&1 ? b[id] : a[id]);
        //if(s == 3) cout<<id<<' '<<ele<<endl;
        if(last > ele) return INF;
        res += i - bit.sum(id + 1);
        bit.add(id + 1, 1);
        last = ele;
    }
    return res;
}

int main(){
    cin>>N;
    rep(i,N) cin>>a[i];
    rep(i,N) cin>>b[i];
    rep(i,N){
        if(i&1) swap(a[i], b[i]);
    }
    ll ans = INF;
    rep(s,(1LL<<N)){
        ans = min(ans, solve(s));
    }
    cout<<(ans == INF ? -1 : ans)<<endl;
}

Measured memory_bytes: 256
A = input().split()
A = [int(i) for i in A]
res_list = []
def listExcludedIndices(data, indices=[]):
    return [x for i, x in enumerate(data) if i not in indices]
for i in range(len(A)):
    for j in range(len(A) -1 ):
        for k in range(len(A) - 2):
            jData = listExcludedIndices(A, [i])
            kData = listExcludedIndices(jData, [j])
            A1 = A[i]
            A2 = jData[j]
            A3 = kData[k]
            res_list.append(abs(A1-A2)+abs(A2-A3))
print(min(res_list))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] d = S.toCharArray();
        int ans = 0;
        for (int position = 0; position < N; position++) {
            String sub = S.substring(position);
            int[] Z = Z(sub);
            for (int i = 0; i < Z.length; i++) {
                ans = Math.max(ans, Math.min(i, Z[i]));
            }
        }
        System.out.println(ans);
    }
    private int[] Z(String S) {
        int N = S.length();
        char[] d = S.toCharArray();
        int[] Z = new int[N];
        int i = 1;
        int j = 0;
        Z[0] = N;
        while (i < N) {
            while (i + j < N && d[j] == d[i + j]) {
                j += 1;
            }
            Z[i] = j;
            if (j == 0) {
                i += 1;
                continue;
            }
            int k = 1;
            while (k < j && k + Z[k] < j) {
                Z[i + k] = Z[k];
                k += 1;
            }
            i += k;
            j -= k;
        }
        return Z;
    }
}


Measured memory_bytes: 61384
// Always have fun - aNONYMOUS //

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define mod 1e9+7
#define inf 1e18
#define pb push_back
#define mp make_pair
#define vll vector<ll>

int main(){
	IOS;
	ll t,n,i,j,k,ans;
	t=1;//cin >> t;
	while(t--){
		ans=0;
		string s;
		cin >> s;
		n=s.length();
		for(i=0;i<n;i++)
			ans+=s[i]-'0';
		if(ans%9==0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}

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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

long long H, W;
vector<vector<long long>> cost_map(1000+1, vector<long long>(1000+1, 0));

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

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

  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  sort(A.rbegin(), A.rend());

  long long W = 0, H = 0;
  for(int i = 1; i < N; i++) {
    if(A[i-1] == A[i]) {
      if(!W) {
        W = A[i];
        // cout << "W: " << W << endl;
        i+=1;
      }
      else if(!H) {
        H = A[i];
        // cout << "H: " << H << endl;
        break;
      }
    }
  }

  if(W && H) {
    cout << W * H << endl;
  }
  else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 11924
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,a,b;
	scanf("%d",&n);
	if(n - 1 == 0){
		printf("Hello World\n");
	}
	else{
		scanf(" %d %d",&a,&b);
		printf("%d\n",a + b);
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	public int decodeMCXI(String str){
		int val=0;
		int pre=1;
		for(int i=0;i<str.length();i++){
			switch(str.charAt(i)){
			case 'm':
				val+=pre*1000;
				pre=1;
				break;
			case 'c':
				val+=pre*100;
				pre=1;
				break;
			case 'x':
				val+=pre*10;
				pre=1;
				break;
			case 'i':
				val+=pre;
				pre=1;
				break;
			default:
				pre=str.charAt(i)-'0';
				break;
			}
		}
		return val;
	}

	public String encodeMCXI(int val){
		StringBuilder sb=new StringBuilder();
		int m=val/1000;
		if(m>=2)sb.append(m);
		if(m>=1)sb.append("m");
		val%=1000;

		int c=val/100;
		if(c>=2)sb.append(c);
		if(c>=1)sb.append("c");
		val%=100;

		int x=val/10;
		if(x>=2)sb.append(x);
		if(x>=1)sb.append("x");
		val%=10;


		int i=val;
		if(i>=2)sb.append(i);
		if(i>=1)sb.append("i");

		return sb.toString();
	}

	public void run() {
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			int l=decodeMCXI(sc.next()),r=decodeMCXI(sc.next());
			ln(encodeMCXI(l+r));
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

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

using namespace std;

int main(void) {
	int H,W;
	cin >> H >> W;
	char c;
	for (int i = 0; i < H+2; ++i) {
		for (int j = 0; j < W+2; ++j) {
			if (i == 0 || i == H+1 || j == 0 || j == W+1) {
				cout << "#";
			}
			else {
				cin >> c;
				cout << c;
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;
int a[100], b[100];
int n;
int flag[10];
int l[10];
int x, y, count=0;

int isValid(int s) {
    for (int i=0;i<n;i++) {
        if (s) {
            if (l[i]!=a[i]) return 0;
        }
        else {
            if (l[i]!=b[i]) return 0;
        }
    }
    return 1;
}

int r(int depth) {
    if (depth==n) {
        count++;
        if (isValid(1)) x=count;
        if (isValid(0)) y=count;
    }
    else {
        for (int i=0;i<n;i++) {
            if (flag[i]==0) {
                flag[i]=1;
                l[depth]=i+1;
                r(depth+1);
                flag[i]=0;
            }
        }
    }
}

int main() {
    for (int i=0;i<10;i++) flag[i]=0;
    scanf("%d", &n);
    for (int i=0;i<n;i++) scanf("%d", &a[i]);
    for (int i=0;i<n;i++) scanf("%d", &b[i]);
    r(0);
    printf("%d\n", abs(x-y));
}


Measured memory_bytes: 256
dicN={}
for i in range(int(input())):
  x=input()
  if x in dicN:
    dicN[x]+=1
  else:
    dicN[x]=1
dicM={}
for i in range(int(input())):
  x=input()
  if x in dicM:
    dicM[x]+=1
  else:
    dicM[x]=1
ls=[0]
for k,v in dicN.items():
  if k in dicM:
    ls.append(v-dicM[k])
  else:
    ls.append(v)
print(max(ls))

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll k; cin >> k;
	ll cur = 7 % k;
	for(ll i = 1; i <= k + 30; i++) {
		if(cur == 0) {
			cout << i << '\n';
			return 0;
		} else {
			cur = (cur * 10 + 7) % k;
		}
	}
	cout << -1 << '\n';
}


Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; string s; cin >> N >> s;
    if(N%2 != 0) {cout << "No" << endl; return 0;}
    int j = N/2;
    for(int i = 0; i < N/2; i++, j++){
        if(s[i] != s[j]) {cout << "No" << endl; return 0;}
    }
    cout << "Yes" << endl; return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
   	  
  if(a > b) swap(a,b);
  if(b > c) swap(b,c);
  if(a > b) swap(a,b);

  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	set<int> S;
	rpz(i,N){
		int d; cin>>d;
		S.insert(d);
	}
	ote(S.size());
}


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

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

    map<long long,int> cnt;
    set<long long> as;
    for(int i=0;i<N;i++){
        long long a;
        cin >> a;
        cnt[a]++;
        as.insert(a);
    }

    long long r=0;
    for(long long a : as){
        if(cnt[a]<a) r+=cnt[a];
        else r+=(cnt[a]-a);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 10752
#include <iostream>

using namespace std;

int main(){
    int a,b,c; 
    cin >> a >> b >> c;

    int ans = 0;
    if (a <= b){
        if (b <= c){
            ans = c*10 + (a + b);
        }else{
            ans = b*10 + (a + c);
        }
    }else{
        if (a <= c){
            ans = c*10 + (a + b);
        }else{
            ans = a*10 + (b + c);
        }
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int a, b, k,n=0;
    cin >> a >> b >> k;
    for (int i = min(a,b); i >= 1;i--) {
        if (a % i == 0 && b % i == 0) {
            ++n;
            if (n == k) {
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main()
{

	long long int n, a[110000];

    cin >> n;

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

    sort(a, a + n, greater<int>());

    if(n == 2){
        if(a[0] > a[1]) cout << a[0] << " " << a[1] << endl;
        else cout << a[1] << " " << a[0] << endl;
    }

    else{
        for(int i = 1; i < n; i++){
        if(a[i] >= a[0]/2 && a[0]/2 >= a[i + 1]){
            if(a[i] - a[0]/2 > a[0]/2 - a[i + 1]){
                cout << a[0] << " " << a[i + 1] << endl;
                break;
            }
            else {
                cout << a[0] << " " << a[i] << endl;
                break;
            }
        }
        }
    }

    


	return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2)

map<ll,int> m;

//素因数分解しながら因数の個数も答える関数
ll countPrimes(ll n)
{
  for (ll i=2;i*i<=n;i++)
  {
    while (n%i==0)
    {
      m[i]++;
      n /= i;
    }
  }
  if (n!=1) m[n]++;
  return (m.size());
}

//累積和
ll cum[1000010];
void cum_init(){
  cum[1]=1;
  for (int i=2;i<1000010;i++){
	cum[i]=cum[i-1]+i;
  }
}

//N=10^12なので一番小さい因数の2でも
//10^12 < 16^12=(2^4)^12=2^48
//高々48個しか持たないので配列は50とかで良い
//1,2->1  [1,1+2)
//3,4,5->2  [1+2,1+2+3)
//6,7,8,9->3   [1+2+3,1+2+3+4)
//10,11,12,13,14->4   [1+2+3+4,1+2+3+4+5)
//みたいな配列作りたい
ll b[50];
void init(){
  for (int i=1;i<1000;i++){
     for (int n=1;n<=48;n++){
       if (cum[i]<=n && n<cum[i+1])
         b[n]=i;
     }
  }
}

int main()
{
  ll n;cin>>n;  
  countPrimes(n);
  
  cum_init();
  init();
  /*
  for (int i=1;i<=10;i++)
    cout<<"cum["<<i<<"]="<<cum[i]<<endl;
  for (int i=1;i<=10;i++)
    cout<<"b["<<i<<"]="<<b[i]<<endl;
  */  
  int ans=0;
  for (auto i=m.begin();i != m.end();i++){
    ans += b[i->second];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11424
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int result = ((n - m) * 100 + m * 1900) * ((1<<m));
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)


int main() {
  string s,s1;
  int cnt=0;

  cin>>s;
  s1=s;
  reverse(s1.begin(),s1.end());
  r(i,s.size()/2){
    if(s.at(i)!=s1.at(i))cnt++;
  }

  cout<<cnt<<endl;



return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int N, V[1 << 18], W[1 << 18];
int dptable[512][100001];
int dp(int i, int j) {
	if (i < 512) return dptable[i][j];
	if (j < W[i]) return dp(i / 2, j);
	return max(dp(i / 2, j - W[i]) + V[i], dp(i / 2, j));
}
int main() {
	int Q, v, L;
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d %d", &V[i], &W[i]);
	fill_n(dptable[0], 100001, 0);
	for (int i = 1; i < 512; ++i) {
		for (int j = 0; j <= 100000; ++j) {
			if (j < W[i]) dptable[i][j] = dptable[i >> 1][j];
			else dptable[i][j] = max(dptable[i >> 1][j], dptable[i >> 1][j - W[i]] + V[i]);
		}
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; ++i) {
		scanf("%d %d", &v, &L);
		printf("%d\n", dp(v, L));
	}
	return 0;
}

Measured memory_bytes: 203780
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

ll powmod(ll x, ll y) {
  ll res = 1;
  for (ll i = 0; i < y; i++) {
    res = res * x % mod;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
  ans %= mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
}


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

using namespace std;

int main(){
    int a,b,c;

    cin>>a>>b>>c;

    if(a==5){
        if(b==5){
            if(c==7)
                cout<<"YES";
            else
                cout<<"NO";
        }
        else if(b==7){
            if(c==5)
                cout<<"YES";
            else
                cout<<"NO";
        }
        else
            cout<<"NO";
    }
    else if(a==7){
        if(b==5){
            if(c==5)
                cout<<"YES";
            else
                cout<<"NO";
        }
        else
            cout<<"NO";
    }
    else
        cout<<"NO";

    return 0;
}


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

using namespace std;

int main() {
    int n; cin >> n;
    vector<string> vc;
    char c;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
        string str; cin >> str;

        if (!ok) continue;

        if (i > 0 && c != str[0]){
            ok = false;
            continue;
        } 

        for (auto e: vc) {
            if (str == e) {
                ok = false;
                continue;
            }
        }

        vc.push_back(str);
        c = str[str.size() - 1];
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    std::string s;
    std::cin >> s;

    if ( s == "A" ) {
        cout << "T" << endl;
    }
    else if ( s == "T" ) {
        cout << "A" << endl;
    }
    else if ( s == "C" ) {
        cout << "G" << endl;
    }
    else {
        cout << "C" << endl;
    }



    return 0;
}

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

int main()
{
    int sec;
    cin>>sec;
    int h,m,s;
    h=sec/3600;
    m=(sec-h*3600)/60;
    s=(sec-h*3600-m*60);
    cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int mod=1e9+7;
ll fac[2020];

ll qpow(ll a,ll b)
{
    ll res=1;
    for(;b;b>>=1)
    {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
    }
    return res;
}
ll C(ll a,ll b)
{
    ll res=fac[a];
    res=(res*qpow(fac[b],mod-2))%mod;
    res=(res*qpow(fac[a-b],mod-2))%mod;
    return res;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int i,j,n,k;
    //cerr<<"Hello world"<<endl;
    for(fac[0]=1,i=1;i<=2005;i++)
        fac[i]=(fac[i-1]*i)%mod;

    cin>>n>>k;
    for(i=1;i<=k;i++)
    {
        if(n-k-i+1<0)
            cout<<0<<endl;
        else
        {
            //ll cnt[2];
            //cnt[0]=C(k-1,i-1);
            //cnt[1]=C(n-k+1,i);
            //cout<<cnt[0]<<' '<<cnt[1]<<' '<<cnt[0]*cnt[1]<<endl;
            cout<<(C(k-1,i-1)*C(n-k+1,i) )%mod<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;

	public static final int SIZE = 21;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String pattern = br.readLine();
			int N = Integer.parseInt(br.readLine());

			int ans = 0;
			boolean FLG;

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

				String T = br.readLine();

				for(int start = 0; start < T.length(); start++){
					FLG = true;
					for(int k = 0; k < pattern.length(); k++){
						if(T.charAt((start+k)%T.length()) != pattern.charAt(k)){
							FLG = false;
							break;
						}
					}
					if(FLG){
						ans += 1;
						break;
					}
				}
			}

			System.out.println(ans);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
    }
}


class UTIL{

    //String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


Measured memory_bytes: 24204
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
//string s;
char ch;
ll i,arr[30]={0};
set<char>s;
for(i=0;i<4;i++)
{
    cin>>ch;
    s.insert(ch);
    arr[ch-65]++;
}
if(s.size()==2 && arr[*s.begin()-65]==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 a=0, b=0;
    for(int i = 0; i < (int)s.size(); i++)
    {
        if(s[i] == '0') a++;
        else if(s[i] == '1') b++;
    }
    
    cout << min(a, b)*2 << endl;
    
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    char[][] map;
    char[][] round; // "":テヲツ慊ェ, B:テゥツサツ? W:テァツ卍ス, x:テゥツサツ津」ツ?ァテ」ツつづァツ卍ステ」ツ?ァテ」ツつづ」ツ?ェテ」ツ??n:テヲツ敖ュ
    int w, h;
    int B, W;


    void run(){
	while(sc.hasNext()){
	    w = sc.nextInt();
	    h = sc.nextInt();
	    if(w==0 && h==0) break;
	    
	    map = new char[h][w];
	    round = new char[h][w];
	    
	    for(int i=0; i<h; i++){
		String s = sc.next();
		Arrays.fill(round[i], 'o');
		for(int k=0; k<w; k++)
		    map[i] = s.toCharArray();
	    }
	    
	    for(int i=0; i<h; i++)
		for(int k=0; k<w; k++){
		    solve(i, k, map[i][k]);
		}
	    
	    count();
	    //show();
	    System.out.println(B+" "+W);
	}
    }

    void solve(int a, int b, char c){
	if(a<0 || a>=h || b<0 || b>=w) return;
	if(round[a][b]=='x' || round[a][b]=='n' || c=='.') return;
	
	if(map[a][b]=='B' || map[a][b]=='W'){
	    c = map[a][b];
	    round[a][b] = 'n';
	    solve(a+1, b, c);
	    solve(a-1, b, c);
	    solve(a, b+1, c);
	    solve(a, b-1, c);
	}
	else if(round[a][b]=='o'){
	    round[a][b] = c;
	    solve(a+1, b, c);
	    solve(a-1, b, c);
	    solve(a, b+1, c);
	    solve(a, b-1, c);
	}
	else if( (round[a][b]=='B' && c=='W') || (round[a][b]=='W' && c=='B')){
	    round[a][b] = 'x';
	    solve(a+1, b, c);
	    solve(a-1, b, c);
	    solve(a, b+1, c);
	    solve(a, b-1, c);
	}
    }

    void count(){
	B = 0;
	W = 0;
	for(int i=0; i<h; i++)
	    for(int k=0; k<w; k++)
		if(round[i][k]=='B') B++;
		else if(round[i][k]=='W') W++;
    }

    void show(){
	for(int i=0; i<h; i++){
	    for(int k=0; k<w; k++)
		System.out.print(round[i][k]+" ");
	    System.out.println();
	}
	System.out.println("-------------------");
    }
}

Measured memory_bytes: 61900