akhauriyash/Code-Regression huggingface dataset:
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cins(S);
    int ans = 0;
    rep(i,S.length()/2){
        if(S[i]!=S[S.length()-1-i])ans++;
    }
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256
S=input()
T=input()
S1=list(S)
ans='No'
def f(S1,i):
    return S1[i:]+S1[:i]
for j in range(-1,len(S)-1):
    S2=''.join(f(S1,j))
    if S2==T:
        ans='Yes'
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = input()
if n == n[::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38380
S = input()
N = len(S)
mid = N//2
pal = True
part1 = []

for i in range(0, mid):
    part1.append(S[i])
for i in range(N-1, mid, -1):
    if(S[i] != part1[N-i-1]):
        pal = False

if not(pal):
    print('No')
    exit()

if len(part1) == 1:
    print('Yes')
    exit()
elif len(part1) == 2:
    if part1[0] == part1[1]:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

if len(part1) % 2 == 1:
    S = part1    
    N = len(S)
    mid = N//2
    pal = True
    part1 = []

    for i in range(0, mid):
        part1.append(S[i])
    for i in range(N-1, mid, -1):
        if(S[i] != part1[N-i-1]):
            pal = False
    if(not(pal)):
        print('No')
        exit()
    else:
        print('Yes')
        exit()
else:
    S = part1    
    N = len(S)
    mid = N//2
    pal = True
    part1 = []

    for i in range(0, mid):
        part1.append(S[i])
    for i in range(N-1, mid-1, -1):
        if(S[i] != part1[N-i-1]):
            pal = False
    if(not(pal)):
        print('No')
        exit()
    else:
        print('Yes')



Measured memory_bytes: 3064
mod=10**9+7
def nCr(n, r):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
n,a,b=map(int,input().split())
f=pow(2, n, mod)-1-nCr(n,a)-nCr(n,b)

while f<0:
    f+=mod
print(f)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int sumd(int n){
    int a=0;
    while(n>0){
        a += n%10;
        n /= 10;
    }
    return a;
}
int main(){
    int n,a,b,i,c,ans=0;
    cin >> n >> a >> b;
    for(i=1;i<n+1;i++){
        c=sumd(i);
        if(c>=a && c<=b) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using ll = long long;

ll N, M;

void solve() {
    ll n=N, m=M;
    ll ans = 0, rest = 0;
    if (m < 2) {
        std::cout << 0 << std::endl;
        return;
    }
    if (n*2 <= m) {
        rest = m - 2*n;
        m   -= 2*n;
        ans += n;
        ans += m / 4;
    } else {
        // n*2 > m
        ans += m/2;
    }
    std::cout << ans << std::endl;
}

int main() {
    std::cin >> N >> M;
    solve();
    return 0;
}

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

uint64_t ssearch(int D, int G, int cur, bool *pr,
	int *p, int *c)
{
	if(cur == D){
		uint64_t score = 0, count = 0, remmax = -1;
		for(int d=0; d<D; d++){
			if(pr[d]){
				score += 100 * (d+1) * p[d] + c[d];
				count += p[d];
			} else{
				remmax = d;
			}
		}
		if(remmax == -1){
			return count;
		} else {
			if(G >= score){
				int req;
				if((G-score) % (100 * (remmax+1)) == 0){
					req = (G - score)
						/ (100 * (remmax+1));
				} else {
					req = (G - score)
						/ (100 * (remmax+1)) + 1;
				}
				if(0<=req && req<=p[remmax]){
					count += req;
				} else {
					return 10000;
				}
			}
			return count;
		}
	} else {
		pr[cur] = true;
		uint64_t tr = ssearch(D, G, cur+1, pr, p, c);
		pr[cur] = false;
		uint64_t fr = ssearch(D, G, cur+1, pr, p, c);
		return min(tr, fr);
	}
}

int main()
{
	int D, G;
	cin >> D >> G;
	bool *pr = new bool[D];
	int *p = new int[D], *c = new int[D];
	for(int d=0; d<D; d++){
		cin >> p[d] >> c[d];
	}
	cout << ssearch(D, G, 0, pr, p, c) << endl;
	return 0;
}


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

int main(void)
{
	int n;						
	int *number;
	int i, j;		
	int count;	
	int total;		
	
	while (scanf("%d",&n) != EOF) {
	
		count = 0;
		
		number=(int*)malloc(sizeof(int)*(n + 1));
		
		for (i = 0; i < (n + 1); i++) {
			number[i] = i;
		}
		
		
		for (i = 2; i < (n + 1); i++) {
			if (number[i] != 0) {	
				for (j = 2 * i; j < (n + 1); j += i) {
					if (number[j] != 0) {
						number[j] = 0;
						count++;	
					}
				}
			}
		}
		
		total = n - (count + 1);
		
		printf("%d\n", total);
		
		free(number);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    char a,b,c,d,e,f;
    cin >> a >> b >> c;
    cin >> d >> e >> f;
    if(b == e && a == f && c == d){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
 
  return 0;
}


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

ll INF = 1e12;
ll dp[2][100010];
ll weight[110];
int value[110];

int main()
{

    int n,maxv=INT_MIN;
    ll w;
    cin>>n>>w;

    for(int i=1;i<=n;i++)
    {
        cin>>weight[i]>>value[i];
        maxv=max(maxv,value[i]);
    }
    maxv=n*maxv;

    for(int j=0;j<=maxv;j++)
        dp[0][j]=dp[1][j]=INF;



    int flag=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=maxv;j++)
        {
            dp[flag][j]=dp[1-flag][j];
            if(value[i]==j)
                dp[flag][j]=min(dp[flag][j],weight[i]);
            else if(value[i]<j)
            {
                ll temp=dp[1-flag][j-value[i]];
                if(temp!=INF)
                {
                    dp[flag][j]=min(dp[flag][j],weight[i]+temp);
                    if(dp[flag][j]>w)
                        dp[flag][j]=INF;
                }
            }
        }
        flag=1-flag;
    }


    int ans=0;
    for(int j=maxv;j>=0;j--)
    {
        if(dp[1-flag][j]!=INF)
        {
            ans=j;
            break;
        }
    }
    cout<<ans;
    return 0;
}



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

long long n,v[500005][2],ans,mini;
string s;


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

	cin>>s;
	
	v[0][0]=0;
	
	for(int i=0;i<s.size();i++){
		if(s[i]=='<')v[i+1][0]=v[i][0]+1;
		else v[i+1][0]=0;
		//cout<<v[i+1][0]<<"-"<<endl;
	}
	
	
	v[s.size()][1]=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='>')v[i][1]=v[i+1][1]+1;
		else v[i][1]=0;
		
		//cout<<v[i][1]<<"+"<<endl;
	}
	
	for(int i=0;i<(s.size()+1);i++){
		ans+=max(v[i][0],v[i][1]);
		
		//cout<<v[i][0]<<" e "<<v[i][1]<<endl;
	}
	
	cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 8732
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000


int main(){
	
	int N,x;
	cin>>N>>x;
	
	N=2*N-1;
	
	vector<int> A(N);
	
	for(int i=0;i<N;i++){
		A[i]=i+1;
	}
	
	if(x==N||x==1){
		cout<<"No"<<endl;
		return 0;
	}
	
	vector<int> ans(N,-1);
	
	int l = N/2;
	int r = N/2;
	set<int> S;
	int cnt = 0;
	
	while(true){
		if(l<0)break;
		if(r>=N)break;
		if(x-cnt<=0)break;
		if(x+cnt>N)break;
		ans[l] = x-cnt;
		ans[r] = x+cnt;
		S.insert(x-cnt);
		S.insert(x+cnt);
		l--;r++;
		cnt++;
	}
	
	int k = 1;
	
	for(int i=0;i<N;i++){
		if(ans[i]!=-1)continue;
		while(S.count(k)){
			k++;
		}
		S.insert(k);
		ans[i]=k;
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<N;i++){
		cout<<ans[i]<<endl;
	}
	
	return 0;
}


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

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

    const string ABC = "ABC";
    string s;
    cin >> s;
    while (1) {
        if (s == ABC) {
            cout << "Yes" << endl;
            return 0;
        }
        vector<int> cnt(3);
        int n = s.size();
        REP(i, n) { cnt[s[i] - 'A']++; }
        int mi = min({cnt[0], cnt[1], cnt[2]});
        int id = -1;
        REP(c, 3) {
            if (cnt[c] == mi) {
                if (id != -1) {
                    cout << "No" << endl;
                    return 0;
                }
                id = c;
            }
        }
        string t;
        REP(i, n) {
            if (i < n - 2 && s.substr(i, 3) == ABC) {
                t.push_back('A' + id);
                i += 2;
            } else {
                t.push_back(s[i]);
            }
        }
        if (s.size() == t.size()) {
            cout << "No" << endl;
            return 0;
        }
        s = move(t);
    }
}



Measured memory_bytes: 3232
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
using namespace std;
int main(){
  int a;
  string s;
  cin>>a;
  cin>>s;

  if(a>=3200)cout<<s;
  else cout<<"red";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    ll s = K;
    REP(i,s){
        if(B > A){
            break;
        }else{
            B *= 2;
            K--;
        }
    }
    s = K;
    REP(i,s){
        if(C > B){
            break;
        }else{
            C *= 2;
            K--;
        }
    }
    if(C > B&&B > A){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 3644
import itertools

H, W = map(int, input().split())
s = []
for i in range(H):
  s.append(input())
  
for i in range(H):
  for j in range(W):
    if s[i][j] == "#":
      flag = False
      for x, y in [[1, 0],[-1, 0],[0, 1],[0, -1]]:
        if i + x >= 0 and i + x <= H - 1 and j + y >= 0 and j + y <= W - 1 and s[i + x][j + y] == '#':
          flag = True
      if not flag:
        print('No')
        exit(0)
print('Yes')



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 10;

signed main() {
	// ios::sync_with_stdio(false);
	ll a, b, c;
	scanf("%lld %lld.%lld", &a, &b, &c);
	b = b * 100 + c;
	printf("%lld\n", a * b / 100);
	return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> map(H);
    for (int i = 0; i < H; ++i) {
        cin >> map[i];
    }

    for (int i = 0; i < H-1; ++i) {
        for (int j = 1; j < W; ++j) {
            if (map[i][j] == '#' && map[i+1][j-1] == '#') {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }

    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
long a[200000];
int main(int argc, char const *argv[]){
	long n,i;
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf("%ld",&a[i]);
	}
	if(n%2==0){
		for(i=n-1;i>0;i-=2){
			printf("%ld ",a[i]);
		}
		printf("%ld",a[0]);
		for(i=2;i<n;i+=2){
			printf(" %ld",a[i]);
		}
	}else{
		for(i=n-1;i>0;i-=2){
			printf("%ld ",a[i]);
		}
		printf("%ld",a[0]);
		for(i=1;i<n;i+=2){
			printf(" %ld",a[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 4e6 + 5;

bitset<N> dp;
				
int32_t main() {
	fast_cin();  
	int n; cin >> n;
	dp.set(0);
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		sum += a;
		dp |= (dp << a);
	}
	sum = (sum + 1) / 2;
	for (int i = sum; ; ++i) {
		if (dp[i]) {
			cout << i << endl;
			break;
		}
	}
	return 0;	
}

Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << " >> " << #x << " "<<x<<endl;
void Solve_Case()
{
    int N;
    cin >> N;
    vector<int> v(N);
    for(int &i : v)  cin >> i;
    int sum = 0;
    for(int i=0;i<N;i++)
        for(int j=i+1;j<N;j++)
    sum += v[i]*v[j];
    cout << sum;
}
int main()
{
    int TestCases=1;
   // cin >> TestCases;
    while(TestCases--)
    {
        Solve_Case();
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  long long int k, n;
  cin>>k>>n;
  vector<long long int> a(n);
  for(int i=0; i<n; i++){
    cin>>a.at(i);
  }

  vector<long long int> aida(n);
  long long int longest=0;
  long long int sum=0;
  for(int i=0; i<n; i++){
    if(i!=n-1){
      aida.at(i)=a.at(i+1)-a.at(i);
    }else{
      aida.at(i)=k-a.at(i)+a.at(0);
    }
    sum+=aida.at(i);
    longest=max(longest, aida.at(i));
  }
  cout<<sum-longest<<endl;
}

Measured memory_bytes: 3328
def input_from_console():
    n = int(input())
    return n


def solve(n):

    return int(180 * (n-2))


def main():
    n = input_from_console()
    print(solve(n))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 2940
// 2018/01/22 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int h, w;
		cin >> h >> w;

		if(h==0 && w==0)
			break;

		int d = h*h+w*w;

		int H = 150;
		int W = 150;
		int D = 150*150+150*150;

		for(int y=1; y<=150; y++){
			for(int x=y+1; x<=150; x++){
				int z = y*y+x*x;

				if(z<=d){
					continue;
				}
				else{
					if(z<D){
						H = y;
						W = x;
						D = z;
					}
					break;
				}
			}
		}

		for(int y=h+1; y<150; y++){
			bool flg = false;

			for(int x=y+1; x<=150; x++){
				int z = y*y+x*x;

				if(z==d){
					H = y;
					W = x;
					D = z;

					flg = true;
				}

				if(z>=d)
					break;
			}

			if(flg)
				break;
		}

		cout << H << ' ' << W << endl;
	}

	return 0;
}



Measured memory_bytes: 3028
#include <iostream>
using namespace std;
char c;
int main()
{ cin>>c;
  if(c=='1')
     cout<<'9';
  else if(c=='9')
     cout<<'1';
  else cout<<c;
  cin>>c;
  if(c=='1')
     cout<<'9';
  else if(c=='9')
     cout<<'1';
  else cout<<c;
  cin>>c;
  if(c=='1')
     cout<<'9';
  else if(c=='9')
     cout<<'1';
  else cout<<c;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int d[100000],dp[100000];
int dist(int x,int y){
  return (x<y)?(y-x):(x-y);
}
int min(int x,int y){
  return (x<y)?x:y;
}
int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&d[i]);
  dp[0]=0;
  dp[1]=dist(d[0],d[1]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-2]+dist(d[i-2],d[i]),dp[i-1]+dist(d[i-1],d[i]));
  }
  printf("%d",dp[n-1]);
  return 0;
}


Measured memory_bytes: 896
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    X = int(input())

    for a in range(-120,120):
        for b in range(-120,120):
            test = a ** 5 - b ** 5
            if test == X:
                print(a,b)
                sys.exit()




main()


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

//https://atcoder.jp/contests/abc054/tasks/abc054_d

const int sm = 2e3;

int n, ma, mb, ans = 1e9;
bool flag = 0;
vector<pair<int, int>> as, bs;
int adp[sm + 1], bdp[sm + 1];

int main() {
	cin >> n >> ma >> mb;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a *= mb;
		b *= ma;
		if (a > b)
			as.emplace_back(a - b, c);
		else if (b > a)
			bs.emplace_back(b - a, c);
		else {
			ans = min(ans, c);
			flag = 1;
		}
	}

	fill(adp + 1, adp + sm + 1, 1e9);
	fill(bdp + 1, bdp + sm + 1, 1e9);

	for (auto a : as)
		for (int i = sm; i >= a.first; i--)
			adp[i] = min(adp[i], adp[i - a.first] + a.second);
	for (auto b : bs)
		for (int i = sm; i >= b.first; i--)
			bdp[i] = min(bdp[i], bdp[i - b.first] + b.second);
	for (int i = 1; i <= sm; i++)
		if (adp[i] + bdp[i] < ans) {
			ans = adp[i] + bdp[i];
			flag = 1;
		}

	cout << (flag ? ans : -1) << endl;
}


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

int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  int sum=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      sum+=a[i]*a[j];
    }
  }
  cout<<sum<<endl;
}
      

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 3007;

int a[MX];
ll dp[MX][MX];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int len = 1; len <= n; len++) {
        for (int l = 1; l + len - 1 <= n; l++) {
            int r = l + len - 1;
            if (len % 2 == n % 2) {
                dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r]);
            } else {
                dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r]);
            }
        }
    }

    cout << dp[1][n] << "\n";
    return 0;
}



Measured memory_bytes: 70016
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

void make_tree(int now, int parent, vector<int> &parent_vec, vector<vector<int>> &edges){
    parent_vec[now] = parent;
    for(auto t: edges[now]){
        if(t == parent)
            continue;
        make_tree(t, now, parent_vec, edges);
    }
}

int calc_counter(int now, int parent, int parent_counter, vector<vector<int>> &edges, vector<int> &counter, vector<int> &ans){
    int sumx = 0;
    for(auto t: edges[now]){
        if(t == parent)
            continue;
        sumx += calc_counter(t, now, parent_counter+counter[now], edges, counter, ans);
    }
    ans[now] = sumx + parent_counter + counter[now];
    return sumx;
}



int main() {
    int n, q;
    cin >> n >> q;
    vector<vector<int>> edges(n);
    vector<int> parent(n);
    REP(i, n-1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    make_tree(0, -1, parent, edges);
    vector<int> counter(n, 0);
    vector<int> ans(n, 0);
    REP(i, q){
        int p, x;
        cin >> p >> x;
        p--;
        counter[p] += x;
    }
    calc_counter(0, -1, 0, edges, counter, ans);

    print_container(ans);

    return 0;
}

Measured memory_bytes: 34432
#include<stdio.h>
#include<algorithm>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <functional>
using namespace std;
int dp[101][10001] = { 0 };
int c[101][2] = { 0 };//c[i][0]..v, c[i][1]...w 
int n, w;
int main() {
	scanf("%d %d", &n, &w);
	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &c[i + 1][0], &c[i + 1][1]);
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= w; ++j) {
			if (j < c[i][1]) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = max(dp[i - 1][j - c[i][1]] + c[i][0], dp[i - 1][j]);
			}
		}
	}
	printf("%d\n", dp[n][w]);
}

Measured memory_bytes: 7112
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	a = list(map(int,input().split()))
	print(gcd(a))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 150888
#include<stdio.h>
int main (void)
{
    int tate=0,yoko=0,i,j;

    while(1){
        scanf("%d %d",&tate,&yoko);
        if(tate==0&&yoko==0){
            break;
        }
        for(i=0;i<tate;i++){
            for(j=0;j<yoko;j++){
                if(i%2==0){
                    if(j%2==0){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }else{
                    if(j%2==1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
                
            }
            printf("\n");
        }
        printf("\n");
        
        
    }

    return 0;    
    
}


Measured memory_bytes: 2588
#include <bits/stdc++.h>
#define rep(i, n)     for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n)    for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n)    for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n)   for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v)  for (auto &&V : v)
#define all(x)        (x).begin(), (x).end()
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = 1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n;
  cin >> n;
  vector<deque<int>> a(n);
  rep (i, n) {
    rep (j, n - 1) {
      int x;
      cin >> x;
      --x;
      a[i].push_back(x);
    }
  }
  int cnt = 0, finish_cnt = 0;
  vector<bool> finish(n);
  vector<int>  now(n);
  rep (i, n) now[i] = i;
  while (1) {
    bool ok = false;
    vector<int>  next;
    vector<bool> alr(n);
    allrep (i, now) {
      if (finish[i] || alr[i]) continue;
      int opp = a[i].front();
      if (alr[opp]) continue;
      if (i == a[opp].front()) {
        a[i].pop_front();
        a[opp].pop_front();
        if (a[i].empty()) {
          finish[i] = true;
          ++finish_cnt;
        }
        if (a[opp].empty()) {
          finish[opp] = true;
          ++finish_cnt;
        }
        alr[i]   = true;
        alr[opp] = true;
        next.push_back(i);
        next.push_back(opp);
        ok = true;
      }
    }
    now = next;
    ++cnt;
    if (!ok) {
      cout << -1 << endl;
      return 0;
    }
    if (finish_cnt == n) break;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4736
import sys
N,M=map(int,input().split())
tmp=(['1']+['0' for _ in range(N-1)])
if M==0:
  if N!=1:
    print(''.join(tmp))
    sys.exit()
  else:
    print(0)
    sys.exit()
changed={}
for i in range(M):
  s,c=map(int,input().split())
  if N==1 and M==1 and s==1 and c==0:
    print(0)
    sys.exit()
  if s==1 and c==0:
    print(-1)
    sys.exit()
  if s not in changed.keys():
    tmp[s-1]=str(c)
    changed[s]=c
  else:
    if c==changed[s]:
      pass
    else:
      print(-1)
      sys.exit()
print(''.join(tmp))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll x(n), y(n), p(n);
    rep(i, n) cin >> x[i] >> y[i] >> p[i];

    vvll distx(n, vll(1 << n, INFL)), disty(n, vll(1 << n, INFL));
    for(ll mask = 0; mask < (1 << n); mask++) {
        for(ll i = 0; i < n; i++) {
            chmin(distx[i][mask], abs(x[i]));
            chmin(disty[i][mask], abs(y[i]));
            for(ll j = 0; j < n; j++) {
                if(mask & (1 << j)) {
                    chmin(distx[i][mask], abs(x[i] - x[j]));
                    chmin(disty[i][mask], abs(y[i] - y[j]));
                }
            }
        }
    }

    ll pow3 = 1;
    rep(i, n) pow3 *= 3;
    vll ans(n + 1, INFL);
    for(ll i = 0; i < pow3; i++) {
        ll cnt_road = 0;
        ll mask = i;
        ll maskx = 0, masky = 0;
        for(ll town = 0; town < n; town++) {
            if(mask % 3 == 1) {
                cnt_road++;
                maskx |= (1 << town);
            }
            else if(mask % 3 == 2) {
                cnt_road++;
                masky |= (1 << town);
            }
            mask /= 3;
        }
        ll sum = 0;
        for(ll town = 0; town < n; town++) {
            ll path = min(distx[town][maskx], disty[town][masky]);
            sum += path * p[town];
        }
        chmin(ans[cnt_road], sum);
    }
    for(auto& i : ans) cout << i << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

/*
templates for competitive programming
type long long -> type ll 
define constants : EPS, INF, MOD, PI
define macros : REP, FOR, ALL, SORT, REVERSE
define number theory functions: qp(a, b), qp(a, b, mo), gcd(a, b)
define dx, dy
*/
   typedef long  ll;

   const double EPS = (1e-7);
   const int INF =(1e9);
   const double PI = (acos(-1));
   const int MOD = (int(1e9) + 7);

   #define REP(i, n) for(int i = 0; i < (int)(n); i++)
   #define FOR(i, a, b) for (int i = (a); i < (b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((int)(x).size())


   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};
   ll power(ll a, ll b){
       if (b == 0) return 1;
       else if (b % 2 == 0) return power(a * a, b / 2);
       else return a * power(a, b - 1);
   }

   int dx[4]={1,0,-1,0};
   int dy[4]={0,1,0,-1};


void solve() {
}

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, a;
   cin >> n >> a;
   vector<int> x(n);
   REP(i, n){
       int xi;
       cin >> xi;
       x[i] = xi - a;
   }
   vector<int> x_plus;
   vector<int> x_minus;
   int x_zero = 0;
   REP(i, n){
       if (x[i] > 0){
           x_plus.push_back(x[i]);
       }
       else if (x[i] < 0){
           x_minus.push_back(- x[i]);
       }
       else{
           x_zero ++;
       }
   }
   const int MAX_S = 50 * 50;
   vector<ll> s_plus(MAX_S);
   vector<ll> s_minus(MAX_S);
   s_plus[0] = s_minus[0] = 1;

   REP(i, x_plus.size()){
       for(int j = MAX_S; j > 0; j--){
           if (j >= x_plus[i]){
               s_plus[j] += s_plus[j - x_plus[i]];
           }
       }
   }
    REP(i, x_minus.size()){
        for(int j = MAX_S; j > 0; j--){
            if (j >= x_minus[i]){
                s_minus[j] += s_minus[j - x_minus[i]];
            }
        }
    }
    ll ans = 0;
    REP(i, MAX_S){
        ans += s_plus[i] * s_minus[i];
    }
    ans *= pow(2, x_zero);
    cout << ans - 1 << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
    int N, M, ans=987654321;
    cin >> N >> M;
    for (int i=0;i<N;i++){
        int a, b;
        cin >> a >> b;
        if (b<=M)
            ans=min(ans,a);
    }
    ans!=987654321 ? cout << ans : cout << "TLE";
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	ar := make([]bool, 26)
	for _, v := range s {
		ar[v-'a'] = true
	}
	for i, v := range ar {
		if !v {
			fmt.Println(string('a' + i))
			return
		}
	}
	fmt.Println("None")
}


Measured memory_bytes: 1280
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


ans_list = make_divisors(N)

_len = len(ans_list)

# print(ans_list)
# print(_len)

if _len % 2 == 0:
    print(ans_list[-1]+ans_list[-2]-2)
else:
    print(ans_list[-1]*2-2)

Measured memory_bytes: 39152
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        eratos(N);
        int ans = 0;
        for (int i = 1; i <= N; i += 2)
        {
            int j = i;
            int yaku = 1;
            foreach (var item in prime)
            {
                int cnt = 1;
                while(j % item == 0)
                {
                    j /= item;
                    cnt++;
                }
                yaku *= cnt;
            }
            if (yaku == 8)
            {
                ans++;
            }
        }
        WriteLine(ans);
    }

    List<int> prime;
    bool[] is_prime;
    void eratos(int n)
    {
        prime = new List<int>();
        is_prime = new bool[n + 1];
        for (int i = 0; i <= n; i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for (int i = 0; i <= n; i++)
        {
            if (is_prime[i])
            {
                prime.Add(i);
                for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
            }
        }
    }
    int[] P;
    void phi(int n)
    {
        P = new int[n + 1];
        for (int i = 0; i <= n; i++) P[i] = i;
        for (int i = 2; i <= n; i++)
        {
            if (is_prime[i])
            {
                P[i] -= P[i] / i;
                for (int j = 2 * i; j <= n; j += i) P[j] -= P[j] / i;
            }
        }
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(void){
    int N,T;
    cin >> N >> T;
    
    int c[N],t[N];
    int ans = 10000;
    for(int i = 0;i < N;i++){
        
        cin >> c[i] >> t[i];
        if(t[i] <= T){
            if(c[i] < ans){
                ans = c[i];
            }
        }
    }
    if(ans == 10000){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
}


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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    lli x, ans, l, r, m, curr ;
    bool check=true ;
    cin>> x ;
    l=1 ;
    ans=r=1e15 ;
    while(l<=r)
      {
        m=(l+r)/2 ;
        curr=6*(ceil(m/2.0))+5*(m/2) ;
        if(curr>=x)
          {
            r=m-1 ;
            ans=min(ans, m) ;
          }
        else l=m+1 ;
      }
    cout<< ans ;
  }


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

h, w, m = map(int, input().split())

hw = []
hcount = [0] * h
wcount = [0] * w
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  hcount[a] += 1
  wcount[b] += 1
  hw.append([a, b])

hmax = max(hcount)
wmax = max(wcount)

x = hcount.count(hmax) * wcount.count(wmax)
for a, b in hw:
  if hcount[a] == hmax and wcount[b] == wmax:
    x -= 1

if x == 0:
  print(hmax + wmax - 1)
else:
  print(hmax + wmax)


Measured memory_bytes: 58776
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


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

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt() % 10
	f := [][]int{[]int{2, 4, 5, 7, 9}, []int{0, 1, 6, 8}, []int{3}}
	s := []string{"hon", "pon", "bon"}

	var ans string
	for i, v := range f {
		for _, k := range v {
			if n == k {
				ans = s[i]
				break
			}
		}
	}
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 1740
import java.util.Scanner;

class Main{
	static public void main(String args[]){
		Scanner sc = new Scanner(System.in);
		/*StringBuilder:??????????????????????????±?????????*/
		StringBuilder sb = new StringBuilder();
		int idx = 0;
		int i = 0;

		while(true){
			idx = sc.nextInt();
			if(idx == 0)
				break;
			i++;
			/*append:????????????????????????*/
			sb.append("Case " + i + ":" + " " + idx + "\n");
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 42388
H, W = map(int, input().split())
A = [input() for _ in range(H)]

dp = [[0]*W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if h == 0 and w == 0:
            dp[h][w] = 1
        elif A[h][w] == "#":
            dp[h][w] = 0
        elif h == 0:
            dp[h][w] = dp[h][w-1]
        elif w == 0:
            dp[h][w] = dp[h-1][w]
        elif A[h][w] == ".":
            dp[h][w] = dp[h][w-1] + dp[h-1][w]

print(dp[H-1][W-1] % 1000000007)


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> h(n);
    
    for(int i = 0; i < n; i++)
    {
        cin>>h[i];
    }
    sort(all(h));
    ll ans = h[n-1] -h[0];
    
    for(int i = 0; i < n+1-k; i++)
    {
        ll tmp = h[i+k-1]-h[i];
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    ans = 0
    S = SI()
    bit_len = len(S)-1
    for i in range(2**bit_len):
        ls = ["" for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                ls[j] = "+"
                
        calc = []
        for n in range(len(S)):
            calc.append(S[n])
            if n != len(S)-1:
                calc.append(ls[n])
        ans += eval("".join(calc))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, m;
vector<vector<ll> > g;
ll dp[100100];

ll rec(ll i){
    if(dp[i] != -1) return dp[i];

    ll res = 0;
    for(auto j : g[i]){
        res = max(res, rec(j) + 1);
    }

    return dp[i] = res;
}

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

    for(int i = 0; i < 100100; i++) dp[i] = -1;

    ll res = 0;
    for(int i = 0; i < n; i++){
        res = max(res, rec(i));
    }

    cout << res << endl;
}

Measured memory_bytes: 8576