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

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

#define REP(i  ,n) for(int i=0;i<n;i++)
#define FOR(i,s,g) for(int i=s;i<g;i++)

const ll INFL = 810000001919114514;
const int INF =         1919114514;

int main(){
	ios::sync_with_stdio(false);cin.tie();
	
	char A[50][50],T[50][50];
	int M,N;
	cin>>M>>N;
	

	REP(i, M){
		REP(j, M){
			cin>>A[i][j];
		}
	}
	REP(i, N){
		REP(j, N){
			cin>>T[i][j];
		}
	}

	bool b;
	for(int i=0;i<=M-N;i++){
		for(int j=0;j<=M-N;j++){
			b=true;
			for(int k=0;k<N;k++){
				for(int l=0;l<N;l++){
					//cout<<A[i+k][j+l]<<' '<<T[k][l]<<en;
					if(A[i+k][j+l]!=T[k][l]){
						b=false;
						break;
					}
				}
				if(!b) break;
			}
			if(b){
				cout<<"Yes"<<en;
				return 0;
			}
		}
	}
	cout<<"No"<<en;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)

def main():
    X = int(input())
    T = [i**5 for i in range(-1000, 1000)]
    for ai, a in enumerate(T):
        for bi, b in enumerate(T):
            if a - b == X:
                print(ai-1000, bi-1000)
                return

if __name__ == '__main__':
    main()


Measured memory_bytes: 65136
package main

import (
	"fmt"
	"sort"
	"strings"
)

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

	stringMap := map[string]int{}
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s", &s)

		slice := strings.Split(s, "")
		sort.Strings(slice)
		stringMap[strings.Join(slice, "")]++
	}

	var count int
	for _, v := range stringMap {
		count += v * (v - 1) / 2
	}

	fmt.Println(count)
}


Measured memory_bytes: 11776
// 素因数分解

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

    vector<vector<int>> f;
    vector<vector<ll>> dp;
    vector<int> t(3);

    ll dsp(int k,int kk, int p){
        if(kk==f[k].size()) return 0;
        if(p>=0 && dp[kk][p]!=-1){
            return dp[kk][p];
        }
        ll ret=0;
        rep(i,3){
            if(i==p) continue;
            ll ten=0;
            if(f[k][kk]==i) ten=t[i];
            ten+=dsp(k,kk+1,i);
            ret=max(ret,ten);
        }
        if(p>=0) dp[kk][p]=ret;
//        cout<<k<<" "<<kk<<" "<<p<<"  "<<ret<<endl;
        return ret;
    }

int main(){
    int N,K;
    cin>>N>>K;
    // R,S,P;
    rep(i,3)cin>>t[i];
    string s;
    cin>>s;
    int n=s.size();
    f.resize(K);
    rep(i,n){
        int k=i%K;
        if(s[i]=='s') f[k].push_back(0);
        else if(s[i]=='p') f[k].push_back(1);
        else f[k].push_back(2);
    }
    ll ans=0;
    rep(i,K){
        int n=f[i].size();
        dp.resize(n+1, vector<ll>(3));
        rep(j,n+1)rep(k,3) dp[j][k]=-1;
        ans+=dsp(i, 0, -1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 18264
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    A = input()
    n = len(A)

    res = (n - 1) * n // 2 + 1
    D = Counter(A)
    for v in D.values():
        if v >= 2:
            res -= (v - 1) * v // 2
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9488
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<u64>();

    let mut count = 0;
    for i in 0..n {
        let mut x = v[i];
        while x % 2 == 0 {
            count += 1;
            x /= 2;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 4352
z['   '],i;
main(j){
	for(;++i<2e3;)
		for(j=z[i>>5]&1<<i?1e7:-2*i*~i;j<5e6;j+=i-~i)z[j>>5]|=1<<j;
	for(;scanf("%d",&i),i;)
		for(j=~i/-2;i;)
			z[--j>>5]&1<<j|
			z[j-1>>5]&1<<j-1|
			z[j-3>>5]&1<<j-3|
			z[j-4>>5]&1<<j-4||printf("%d\n",j*2+1,i=0);
	return 0;
}

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

if 0 <= N < 10:
  print(N)
elif 10 <= N < 100:
  print(9)
elif 100 <= N < 1000:
  print(9 + N - 99)
elif 1000 <= N < 10000:
  print(909)
elif 10000 <= N < 100000:
  print(909 + N - 9999)
elif N == 100000:
  print(90909)

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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  list<int> b;

  rep(i, n) {
    int a;
    cin >> a;
    if (i % 2 == 0)
      b.push_front(a);
    else
      b.push_back(a);
  }

  if (n % 2 == 0)
    reverse(b.begin(), b.end());

  for (auto it = b.begin(); it != b.end(); it++) {
    if (it != b.begin())
      cout << " ";
    cout << *it;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 100000000
#define mod 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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;
}

int N;
int a[210000];
int res[210000];

int main () {
  cin >> N;
  rep(i, N) cin >> a[i];

  for(int k=N;k>=1;--k) {
    int tmp = 0;

    for (int i=(k*2);i<=N;i+=k) {
      tmp += res[i];
    }

    tmp = tmp % 2;

    if (a[k] == tmp) {
      res[k] = 0;
    } else {
      res[k] = 1;
    }
  }

  vector <int> ans;

  rep(i, N) {
    if (res[i] == 1) {
      ans.push_back(i);
    }
  }

  cout << ans.size() << "\n";

  if (ans.size() > 0) {
    Rep(i, ans.size()-1) {
      cout << ans[i] << " ";
    }
    cout << ans[ans.size()-1] << "\n";
  }
}


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,b,bu=1,cou=0;
vector<int> a;
bool pu[100000]={false}; 
bool fin=false;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>b;
		a.push_back(b);
	}
	while(!fin){
		pu[bu-1]=true;
		bu=a[bu-1];
		cou++;
		if(pu[bu-1]==true){
			cout<<-1<<endl;
			fin=true;
		}
		if(bu==2){
			cout<<cou<<endl;
			fin=true;
		}
	}
	return 0;
}

Measured memory_bytes: 892
/*痛みを受け取れ，痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;

int main()
{
	//freopen("in.txt", "r", stdin);
	string s;
	while (cin >> s)
	{
		ll ans = 0;
		for (auto i : s)ans += i - '0';
		if ((ans % 9 == 0))puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 3752
#include <algorithm>
#include <cstring>
#include <cstdio>
#define MOD 1000000007
typedef long long ll; 
int fact[1005], inv[1005], dfn[1005], low[1005], t, st[1005]; 
int lst[1005], to[1005], pre[1005], tot, tp, ecnt[1005], vcnt[1005], bcc, col[1005]; 
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u]; 
	lst[u] = tot++; 
}
inline int quick_pow(int a, int n)
{
	int res = 1; 
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD; 
		a = (ll)a * a % MOD; 
		n >>= 1; 
	}
	return res; 
}
inline int gcd(int x, int y)
{
	while (y)
	{
		int r = x % y; 
		x = y; 
		y = r; 
	}
	return x;
}
inline int C(int n, int m)
{
	return (ll)fact[n] * inv[m] % MOD * inv[n - m] % MOD; 
}
void tarjan(int u, int fa = -1)
{
	dfn[u] = low[u] = t++; 
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (i == fa)
			continue; 
		if (-1 == dfn[to[i]])
		{
			st[tp++] = i; 
			tarjan(to[i], i ^ 1); 
			low[u] = std::min(low[u], low[to[i]]); 
			if (low[to[i]] >= dfn[u])
			{
				do
				{
					int x = st[--tp]; 
					ecnt[bcc]++; 
					if (col[to[x]] != bcc)
					{
						col[to[x]] = bcc; 
						vcnt[bcc]++; 
					}
					if (col[to[x ^ 1]] != bcc)
					{
						col[to[x ^ 1]] = bcc; 
						vcnt[bcc]++; 
					}
				}
				while (st[tp] != i); 
				bcc++; 
			}
		}
		else if (dfn[to[i]] < dfn[u])
		{
			st[tp++] = i; 
			low[u] = std::min(low[u], dfn[to[i]]); 
		}
	}
}
int main()
{
	// freopen("ARC062-F.in", "r", stdin); 
	memset(lst, -1, sizeof(lst)); 
	memset(dfn, -1, sizeof(dfn)); 
	memset(col, -1, sizeof(col));
	fact[0] = inv[0] = 1; 
	for (int i = 1; i < 1005; i++)
	{
		fact[i] = (ll)fact[i - 1] * i % MOD; 
		inv[i] = quick_pow(fact[i], MOD - 2); 
	}
	int n, m, k; 
	scanf("%d%d%d", &n, &m, &k); 
	for (int i = 0; i < m; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		add_edge(--u, --v);
		add_edge(v, u); 
	}
	for (int i = 0; i < n; i++)
	{
		if (-1 == dfn[i])
			tarjan(i); 
	}
	int ans = 1; 
	for (int i = 0; i < bcc; i++)
	{
		if (ecnt[i] == 1)
			ans = (ll)ans * k % MOD; 
		else if (ecnt[i] == vcnt[i])
		{
			int sum = 0; 
			for (int j = 1; j <= ecnt[i]; j++)
				(sum += quick_pow(k, gcd(j, ecnt[i]))) %= MOD; 
			ans = (ll)ans * sum % MOD * quick_pow(ecnt[i], MOD - 2) % MOD; 
		}
		else
			ans = (ll)ans * C(ecnt[i] + k - 1, k - 1) % MOD; 
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 256
N,M=map(int,input().split())
d={1:set(),N:set()}
for i in range(M):
    a,b=map(int,input().split())
    if a in d.keys():
        d[a]|={b,}
    if b in d.keys():
        d[b]|={a,}
if len(d[1]&d[N])>0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 18992
#include <stdio.h>

int main() {
	int L, R, d, cnt=0;
	scanf("%d %d %d", &L, &R, &d);
	for(int i=L; i<=R; i++)
	{
		if(i%d==0)
		{
			cnt++;
		}
	}
	printf("%d", cnt);
	
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,m;
 	cin >> n>>m;
 	bool x[n][m]{};
 	for (int i = 0; i < n; i++){
 		int a;
 		cin >> a;
 		for (int j = 0; j < a; j++){
 			int b;
 			cin >> b;
 			x[i][b-1]=true;
 		}
 	}
 	int ans=0;
 	for (int i = 0; i < m; i++){
 		bool z=true;
 		for (int j = 0; j < n; j++){
 			if(!x[j][i]){
 				z=false;
 			}
 		}
 		if(z){
 			ans++;
 		}
 	}
 	cout << ans << endl;
 }

Measured memory_bytes: 256
from math import sqrt
n = int(input())
k = int(sqrt(n))
Primes = [False,False]
for i in range(k + 2):
    Primes.append(True)
for i in range(2, k + 1):
    if Primes[i]:
        j = 2 * i
        while j < k + 1:
            Primes[j] = False
            j += i
primes = [i for i in range(k + 1) if Primes[i]]
del(Primes)
ans = []
index = 0
tmp = n
while n > 1 and len(primes) > index:
    if n % primes[index] == 0:
        n /= primes[index]
        ans.append(str(primes[index]))
    else:
        index += 1
if n != 1:
    ans.append(str(int(n)))
print(str(tmp) + ": " + " ".join(ans))


Measured memory_bytes: 6016
n = int(input())
h = list(map(int, input().split(' ')))
c = 0
max_c = 0
for i in range(n):
  if i:
    if h[i] <= prev:
      c += 1
    else:
      if max_c < c:
        max_c = c
    
      c = 0

  prev = h[i]

if c > max_c:
  max_c = c

print(max_c)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;


int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n-1,vector<int>(0));
    rep(i,n-1){
        rep(j,n-i-1){
            int k=1,t=j+1;
            while(true){
                if (t%2==1) break;
                t/=2;
                k++;
            }
            a.at(i).push_back(k);
        }
    }
    rep(i,n-1){
        rep(j,a.at(i).size()-1) cout << a.at(i).at(j) << " ";
        cout << a.at(i).at(a.at(i).size()-1) << endl;
    }
}


Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int arr[100005];
int ans[102][102];
int main()
{
  int h,w,n;
    cin>>h>>w>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int i=0,j=0;
    int counter=0;
    int op=1;
    int save=0;
    while(true){
        if(arr[counter]==0){
            counter+=1;
        }
         ans[i][j]=counter+1;
         --arr[counter];
         save=i;
         i+=op;
        if(i==h||i==-1){
            j++;
            op=op*-1;
            i=save;
        }
        if(j==w&&((i==h)||(i==0))){
            break;
        }
    }
    for(int k=0;k<h;k++){
        for(int m=0;m<w;m++){
            cout<<ans[k][m]<<" "<<flush;
        }
        cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M   1000000009
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1];
}





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

using namespace std;

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

	int a = N;

	string ans;
	if (a == 0) {
		ans = "0";
	}

	while (a != 0) {
		if (a % 2 == 0) {
			ans = "0" + ans;
		} else {
			ans = "1" + ans;
			a--;
		}
		a /= -2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

int main(){
    int n, k, h[100000];
    cin >> n >> k;
    cal(i, n) cin >> h[i];
    int total = 0;
    cal(i, n){
        if(h[i] >= k) total++;
    }
    cout << total;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[500];
int main()
{
	gets(a);
	int len=strlen(a);
	for(int i=0;i<len;i++)
	{
		if(a[i]=='C')
		  for(int j=i+1;j<len;j++)
		    if(a[j]=='F')
		    {
		    	cout<<"Yes"<<endl;
		    	return 0;
			}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

bool flag=false;

ll change(ll n,ll k){
    if(n>k){
        return n%k;
    }else{
        if(n>k-n){
            return k-n;
        }else{
            flag=true;
            return n;
        }
    }
}

int main() {
    ll n,k;
    cin>>n>>k;
    while(true){
        n=change(n,k);
        if(flag) break;
    }
    cout<<n<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  if(2*x==w&&2*y==h)
  {
  		printf("%0.9lf 1" , (w*h)/2);
  }
  else
    printf("%0.9lf 0" , (w*h)/2);
	return 0;
}

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


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

    int n, l;

    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0; i < n; ++i)
        cin >> s[i];

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

    for (auto x : s)
        cout << x;
    cout << endl;

    return 0;
}

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

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;
    vector<int> time(3);
    time.at(0) = P;
    time.at(1) = Q;
    time.at(2) = R;
    sort(time.begin(), time.end());
    cout << time.at(0) + time.at(1) << endl;
}

Measured memory_bytes: 256
main(n){
	for(;scanf("%d",&n)*n;){
		int p[201]={0};//J[hÌLÒ(0=Ôq,1=¾Y,2=ê)
		int m[]={n,n};
		int i,c,t=1;
		for(i=n;i--;){
			scanf("%d",&c);
			p[c]=1;
		}
		for(i=1;;){
			if(p[i]==t){
				//J[hðêÉo·
				p[i]=2;
				if(--m[t]==0){
					printf("%d\n%d\n",m[0],m[1]);
					break;
				}
				t^=1;
			}
			if(++i>2*n){
				//pX
				i=1;
				t^=1;
			}
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long n,i,sum = 0,mn = 1e16,x = 0;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>arr[i];sum+=arr[i];
	}
	for (i=0;i<n;i++){
		x+=arr[i];mn=min(mn,abs(sum-2*x));
	}
	cout<<mn<<endl;
}

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

#define N (int)3e3+5
#define f1 first
#define s2 second
#define pb push_back
#define ll long long
#define mod (int)1e9
#define INF 99999999
#define	ull unsigned long long
#define all(a) a.begin(),a.end()
#define fri(a) freopen((a),"r",stdin);
#define fro(a) freopen((a),"w",stdout);

ll n,dizi[N],dp[N][N];

ll dpf(int l,int r){
	if(dp[l][r]!=-1)return dp[l][r];
	if(l>r)return 0;
	ll ans1=dpf(l+1,r);
	ll ans2=dpf(l,r-1);
	return dp[l][r]=max(dizi[l]-ans1,dizi[r]-ans2);
}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>dizi[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<dpf(1,n);
	return 0;
}

Measured memory_bytes: 70912
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
//#include <iostream>
//#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define deb(x) cout << #x" = " << x << '\n'
#define debd(x) pf("%s = %d\n", #x, x)
#define debs(x) pf("%s = %s\n", #x, x)
#define debll(x) pf("%s = %lld\n", #x, x)
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
//bitmask
int onbit(int x, int pos) {x |= (1 << pos); return pos;}
int offbit(int x, int pos) {x &= ~(1 << pos); return x;}
int test(int x, int pos) {return x & (1 << pos);}
int flip(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int onbitall(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};


int main() {
//  freopen("input.in", "r", stdin);
	int n, k;
	sf("%d %d", &n, &k);
	int res = 0;
	if(n%k == 0) res = 0;
	else res = ((n/k)+1) - (n/k); 
	pf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
int n, s, a[105];
int main() {
	int i;
	cin>>n;
	for(i=0; i<n; i++) cin>>a[i];
	for(i=1; i<n; i++) if(a[i] == a[i-1]) s++, i++;
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
Aa = list(map(int, input().split()))
Ab = list(map(int, input().split()))
Ac = list(map(int, input().split()))
At = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
N = int(input())

for i in range(N):
    tmp = int(input())
    if tmp in Aa:
        At[0][Aa.index(tmp)] = 1
    if tmp in Ab:
        At[1][Ab.index(tmp)] = 1
    if tmp in Ac:
        At[2][Ac.index(tmp)] = 1

if all(At[0]) or all(At[1]) or all(At[2]):
    print('Yes')
    exit()

if At[0][0] and At[1][0] and At[2][0] \
   or At[0][1] and At[1][1] and At[2][1] \
   or At[0][2] and At[1][2] and At[2][2]:
    print('Yes')
    exit()

if At[0][0] and At[1][1] and At[2][2] \
   or At[0][2] and At[1][1] and At[2][0]:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3064
n,k=map(int,input().split())
A=sorted(map(int,input().split()))
dp=[0]*(k+1)
dp[1]=0
for i in range(k):
    if dp[i]==0:
        for a in A:
            if i+a<=k:
                dp[i+a]=1
print("Second"if dp[k]==0 else"First")

Measured memory_bytes: 40176
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e9
using namespace std;

const int maxd = 20;
const int maxn = 210000;

int n;
int a[maxn],p[maxn];

int pre1[maxn][maxd],pre2[maxn][maxd];
int suf1[maxn][maxd],suf2[maxn][maxd];
int ln[maxn];

int q_1(const int l,const int r)
{
	int ld=ln[r-l+1];
	return min(suf1[l][ld],pre1[r][ld]);
}
int q_2(const int l,const int r)
{
	int ld=ln[r-l+1];
	return min(suf2[l][ld],pre2[r][ld]);
}
int query(const int l,const int r,const int t){return t?q_1(l,r):q_2(l,r);}

struct node{int l,r,fir,sec;};
inline bool operator <(const node x,const node y){return x.fir>y.fir;}
priority_queue<node>q;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),p[a[i]]=i;
	
	for(int i=2;i<=n;i<<=1) ln[i]++;
	for(int i=1;i<=n;i++) ln[i]+=ln[i-1];
	
	for(int i=1;i<=n;i++)
	{
		if(i&1) pre1[i][0]=suf1[i][0]=a[i],pre2[i][0]=suf2[i][0]=inf;
		else pre2[i][0]=suf2[i][0]=a[i],pre1[i][0]=suf1[i][0]=inf;
	}
	for(int d=1;(1<<d)<=n;d++)
	{
		for(int i=1;i<=n;i++)
		{
			if(i-(1<<d)>=0) 
				pre1[i][d]=min(pre1[i-(1<<d-1)][d-1],pre1[i][d-1]),
				pre2[i][d]=min(pre2[i-(1<<d-1)][d-1],pre2[i][d-1]);
			if(i+(1<<d)-1<=n)
				suf1[i][d]=min(suf1[i+(1<<d-1)][d-1],suf1[i][d-1]),
				suf2[i][d]=min(suf2[i+(1<<d-1)][d-1],suf2[i][d-1]);
		}
	}
	
	int fir=q_1(1,n),sec=q_2(p[fir]+1,n);
	q.push((node){1,n,fir,sec});
	while(!q.empty())
	{
		const node x=q.top(); q.pop();
		printf("%d %d ",x.fir,x.sec);
		int l=x.l,r=x.r;
		int t1=p[x.fir],t2=p[x.sec];
		if(l!=t1)
		{
			int t=l&1;
			fir=query(l,t1-1,t); sec=query(p[fir]+1,t1-1,!t);
			q.push((node){l,t1-1,fir,sec});
		}
		if(t1+1!=t2)
		{
			int t=(t1+1)&1;
			fir=query(t1+1,t2-1,t); sec=query(p[fir]+1,t2-1,!t);
			q.push((node){t1+1,t2-1,fir,sec});
		}
		if(t2!=r)
		{
			int t=(t2+1)&1;
			fir=query(t2+1,r,t); sec=query(p[fir]+1,r,!t);
			q.push((node){t2+1,r,fir,sec});
		}
	}
	
	return 0;
}


Measured memory_bytes: 70260
#include<bits/stdc++.h>
 
#define all(x) x.begin(),x.end()
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long MOD=1e9+7;
const long long LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=2050;

void solve(int T){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		printf("ACL");
	} 
	puts("");
}	
signed main(){
	int t=1;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//scanf("%d",&t); 
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 3824
#include <stdio.h>
#include <string.h>
char X[1001];
char Y[1001];
int c[1001][1001];
int n;

int lcs(){
   int m,n,i,j;
    m=strlen(X);
    n=strlen(Y);
    for(i=1;i<=m;i++){
     c[i][0]=0;
    }
    for(j=0;j<=n;j++){
      c[0][j]=0;
   }
   for(i=1;i<=m;i++){
     for(j=1;j<=n;j++){
         if(X[i-1]==Y[j-1]){
          c[i][j]=c[i-1][j-1]+1;
        } else if(c[i-1][j]>=c[i][j-1]){
          c[i][j]=c[i-1][j];
      }else{
        c[i][j]=c[i][j-1];
         }
       }
     }
   return c[m][n];
}


int main(){
    scanf("%d",&n);
    int i;
     for(i=0;i<n;i++){
        scanf("%s",X);
        scanf("%s",Y);


   printf("%d\n",lcs());
 }

 return 0;
}

Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int N;
    while(1){
        cin >> N;
        if(!N) return 0;
        vector<char> c;
        vector<P> v;
        for (int i = 0; i < N; i++) {
            char C;cin >> C;
            c.pb(C);
            if(C=='W'){
                LL x,y;cin >> x >> y;
                v.pb(mp(x,y));
            }
            else if(C=='D'){
                LL x;cin >> x;
                v.pb(mp(x,-1));
            }
            else if(C=='R'){
                LL x;cin >> x;
                v.pb(mp(-1,-1));
                x++;
                LL ans = -1;
                LL t = 0;
                map<LL,LL> ma;
                for (int j = 0; j < c.size(); j++) {
                    if(c[j]=='W'){
                        if(t+v[j].sc<=x){
                            t+=v[j].sc;
                            ma[v[j].fs]+=v[j].sc;
                        }
                        else{
                            ma[v[j].fs]+=x-t;
                            t=x;
                        }
                        if(t==x&&ans==-1){
                            ans=v[j].fs;
                        }
                    }
                    else if(c[j]=='D'){
                        t-=ma[v[j].fs];
                        if(v[j].fs==ans) ans=-1;
                    }
                }
                cout << ans << endl;
            }
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3396
n, k, s = map(int, input().split())

#%%
billion = 1000000000

if s == billion:
    front = [s] * k
    back = [1] * (n - k)
else:
    front = [s] * k
    back = [s+1] * (n - k)

front.extend(back)
print(*front)

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

class Cube{
	public:
  	int f[6];
  	Cube(){}
  	void roll_z(){roll(1,2,4,3);}
  	void roll_y(){roll(0,2,5,3);}
  	void roll_x(){roll(0,1,5,4);}
  	void roll(int i,int j,int k,int l){
    int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
    }
  	
  	void move(char ch){
    	if(ch=='E') for(int i=0;i<3;i++) roll_y();
      	if(ch=='W') roll_y();
      	if(ch=='N') roll_x();
      	if(ch=='S') for(int i=0;i<3;i++) roll_x();
    }
};
 
int main(){
  Cube c;
  string com;
  
  for (int i=0;i<6;i++) cin>>c.f[i];
  cin>>com;
  for (int i=0;i<com.size();i++) c.move(com[i]);
  cout<<c.f[0]<<endl;
  return 0;
}


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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    unordered_map<char, int> m;
    REPS(c, s) m[c]++;
    if (m['N'] == 0 && m['S'] == 0 || m['N'] != 0 && m['S'] != 0) {
        if (m['E'] == 0 && m['W'] == 0 || m['E'] != 0 && m['W'] != 0) {
            cout << "Yes" << EOL;
        } else {
            cout << "No" << EOL;
        }
    } else {
        cout << "No" << EOL;
    }
}


Measured memory_bytes: 256
s = input()

count = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "L":
            break
    else:
        if s[i] == "R":
            break
    count += 1
      
if count == len(s):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <string>

int main(){
    int K;
    std::string S;
    std::cin >> K >> S;

    if(S.size() <= K){
        std::cout << S << std::endl;
    }
    else{
        
        std::cout << S.substr(0,K) << "..." << std::endl;
    }

}





Measured memory_bytes: 3620
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

def count(X):
    cnt  = 0
    for i in range(1, X + 1):
        if X % i == 0:
            cnt += 1
    return cnt


if __name__ == "__main__":
    N = int(sys.stdin.readline())
    ans = 0
    for i in range(1, N + 1):
        if i % 2 != 0:
            if count(i) == 8:
                ans += 1
    print(ans)



Measured memory_bytes: 5456
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n;

    cin >> n;
    V b;
    REP(i, n)
    {
        int a;
        cin >> a;
        if (i % 2 == 1)
        {
            b.insert(b.begin(), a);
        }
        else
        {
            b.push_back(a);
        }
    }

    REP(i, n)
    {
        if (n % 2 == 0)
            cout << b[i];
        else
            cout << b[n - 1 - i];

        if (i == n - 1)
            cout << endl;
        else
            cout << " ";
    }

    return 0;
}

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<ll> factmemo, factmemoInv;
ll factmemoMod = -1;

ll factorial(int n, int M){
  if(factmemoMod == M) return factmemo[n];
  if(n <= 1) return 1;

  ll res = 1;
  for(int i=1; i<=n; i++) res = res * i % M;
  return res;
}

ll power(ll k, ll n, int M){
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}

void initFactorial(int n, int M){
  factmemo.assign(n+1, 0);
  factmemoInv.assign(n+1, 0);
  factmemoMod = M;
  factmemo[0] = 1;
  for(int i=1;i<=n;i++) factmemo[i] = factmemo[i-1] * i % M;
  factmemoInv[n] = power(factmemo[n], M-2, M);
  for(int i=n;i>0;i--) factmemoInv[i-1] = factmemoInv[i] * i % M;
}

//nCm nPm nHm (mod M)

/*Combination*/
ll C(int n, int m, int M){
  if(n < m) return 0;
  if(m == 0 || n == m) return 1;

  if(factmemoMod == M)
    return factmemo[n] * factmemoInv[m] % M * factmemoInv[n-m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(m, M) * factorial(n-m, M) % M;

  denom = power((int)denom, M-2, M);

  return numer * denom % M;
}
/*Permutation*/
ll P(int n, int m, int M){
  if(n < m) return 0;
  if(m == 0) return 1;

  if(factmemoMod == M)
    return factmemo[n] * factmemoInv[n-m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(n-m, M);

  denom = power((int)denom, M-2, M);

  return numer * denom % M;
}
/*Combination with Repetitions*/
ll H(int n, int m, int M){
  if(n == 0 && m == 0) return 1;
  return C(n+m-1, m, M);
}

int main(){
  int X, Y;

  cin >> X >> Y;

  int S = X + Y;

  if (S % 3 != 0) {
    puts("0");
    return 0;
  }

  int N = S / 3;

  int x2 = X - N;
  int x1 = N - x2;

  if (x2 < 0 || x1 < 0 || x2 * 2 + x1 != X || x2 + x1 * 2 != Y) {
    puts("0");
    return 0;
  }

  cout << C(x2+x1, x1, mod) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmin(x, y) x = min(x, y)
#define ll long long
#define ld long double
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;


int n, W;
int weight[3300], value[3300];
int dp[3300][3300] = {0}; 
int prev_w[3300][3300];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; ++i) cin >> weight[i] >> value[i];

  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W-1; ++w) {

      if (w >= weight[i]) {
        if (dp[i+1][w] < dp[i][w-weight[i]] + value[i]) {
          dp[i+1][w] = dp[i][w-weight[i]] + value[i];
          prev_w[i+1][w] = w - weight[i];
        }
      }

      if (dp[i+1][w] < dp[i][w]) {
        dp[i+1][w] = dp[i][w];
        prev_w[i+1][w] = w;
      }
    }
  }

  set<int> Selected;
  // cout << "Selected items are..." << endl;
  int cur_w = W-1;
  for (int i = n-1; i >= 0; --i) {
    // 選んでいた場合
    if (prev_w[i+1][cur_w] == cur_w - weight[i]) {
      Selected.insert(i);
      // cout << i << " th item (weight = " << weight[i] << ", value = " << value[i] << ")" << endl;
    }

    cur_w = prev_w[i+1][cur_w];
  }
  int maxv = 0;
  rep(i, n) {
    if (!Selected.count(i)) maxv = max(maxv, value[i]);
  }
  cout << dp[n][W-1] + maxv << endl;
}


Measured memory_bytes: 80256
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val (A, B) = readInts()
    var P = readInts().sorted()

    val first = P.filter { it <= A }
    P = P.filterNot { it <= A }

    val second = P.filter { it in (A + 1)..B }
    P = P.filterNot { it in (A + 1)..B }

    val third = P.filter { it >= B + 1 }

    println(Math.min(Math.min(first.count(), second.count()), third.count()))
}

Measured memory_bytes: 38052
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n - 1); 0 <= i; --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

namespace My
{
template <typename ArrayT>
static void DumpArray(const ArrayT &arr)
{
#if defined(HOME)
	for (auto it = std::begin(arr); it != std::end(arr); ++it) {
		cerr << *it << " ";
	}
	cerr << endl;
#endif
}
template<typename T>
static void DumpGrid(const vector<vector<T>> &grid){
#if defined(HOME)
	REP (i, grid.size()) {
		REP (j, grid[i].size()) {
			cerr << grid[i][j] << " ";
		}
		cerr << endl;
	}
#endif
}
template <class ArrayT, typename T>
static void InitArray(ArrayT &arr, T initValue){
	for (auto &v : arr){
		v = initValue;
	}
}
template <typename T>
static bool ReplaceIfSmaller(T &target, T value)
{
	if (value < target) {
		target = value;
		return true;
	} else {
		return false;
	}
}
template <typename T>
static bool ReplaceIfBigger(T &target, T value)
{
	if (target < value) {
		target = value;
		return true;
	} else {
		return false;
	}
}

class Solver
{
  public:
	Solver() {}
	void Solve(istream &cin, ostream &cout)
	{
		int N, K;
		cin >> N >> K;

		for (size_t i = 0; i < 40; i++)
		{
			if (N < pow(K, i)){
				cout << i << endl;
				return;
			}
		}
	}
};
} // namespace My

#if !defined(BOOST_TEST_MODULE)
#if !defined(GTEST_INCLUDE_GTEST_GTEST_H_)
int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	My::Solver solver;
	solver.Solve(std::cin, std::cout);

	return 0;
}
#endif
#endif


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll fact[3000005];

ll pow(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}

ll nCr(ll n, ll r) {
  return fact[n] * (pow(fact[n-r],mod-2) * pow(fact[r],mod-2) % mod) % mod;
}


int main() {
  ll n,m;
 
  cin >> n >> m;
  fact[0] = 1;
 
  for(ll i = 1; i <= 3000000; i++) fact[i] = fact[i-1] * i % mod;
  
  

  ll ans = 1;
 
    for(ll i = 2; i < 3000000; i++) {
      if(m % i != 0) continue;
    ll k = 0;
    while(m % i == 0) {
      m /= i;
      k++;
    }
    ans = ans * nCr(k+n-1,k) % mod;
      }

    if(m != 1) cout << ans * n % mod << endl;
    else 
      cout << ans << endl;
}
    
    
  


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

int main()
{
	int N, X, T; cin >> N >> X >> T;

	int ans = N / X;
	if ((N % X) != 0) ans++;
	ans *= T;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll ans = 0, sum = 0;
	for(int i = 0, j = 0; i < n; i++){
		while(j < i){
			if((sum & a[i]) == 0) break;
			sum ^= a[j];
			j++;
		}
		sum ^= a[i];
		ans += i - j + 1;
	}
	cout << ans << endl;
	return 0;
}

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

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

    int N, T, ans = 1e9;
    cin >> N >> T;
    REP(i, N){
        int c, t;
        cin >> c >> t;
        if(t > T) continue;
        if(T >= t){
            ans = min(ans, c);
        }
    }
    if(ans == 1e9){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    int n, x;
    cin >> n >> x;
    VI l(n);
    FOR(i, n)cin >> l[i];
    int now = 0;
    FOR(i, n) {
        now += l[i];
        if (now > x) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << n + 1 << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n,k=map(int,input().split())
a=np.array(readline().split(),np.int64)
f=np.array(readline().split(),np.int64)
a.sort()
f.sort()
f=f[::-1]
def test(x):
  return np.maximum(0,a-x//f).sum()<=k

l=-1
r=INF
while l+1<r:
  mid=(l+r)//2
  if test(mid):
    r=mid
  else:
    l=mid
    
print(r)

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c << endl;

	return 0;
}

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

int main(){
    int a,b;cin>>a>>b;
    if(a>b)a--;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
long long n, a[200000], s[200000], cnt;
int main() {
	cin >> n; for (int i = 1; i <= n; i++)cin >> a[i];
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++)s[i] = a[i] + s[i - 1];
	bool OK = true;
	for (int i = n; i >= 1; i--) {
		if (s[i] * 2 < a[i + 1])OK = false;
		if (OK == false)break;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
X,K,D = map(int,input().split())
#0に行けない場合
if K*D <= abs(X):
    ans = abs(X) - K*D
else:#0に行ける場合
    i = abs(X) // D #i:最も0に近づくまでにかかる移動回数
    t = abs(X)-D*i #t:0を踏まずに最も0に近づいた時の距離
    if (K-i)%2==0:
        ans = t
    else:
        ans = D-t
print(ans)


Measured memory_bytes: 9180
//
// Created by SAJI Ayahito on 2018/05/23.
//

#include <iostream>
#include <string>

using namespace std;

int main(void){
    string s;
    cin >> s;
    long long int start, end;
    for(long long int i = 0;i < s.size();i ++){
        if(s[i] == 'A'){
            start = i;
            break;
        }
    }
    for(long long int i = s.size()-1;i >= 0;i --){
        if(s[i] == 'Z'){
            end = i;
            break;
        }
    }
    cout << end-start+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	string s;
	cin >> s;
	cout << ((s[5] - '0') * 10 + s[6] - '0' <= 4 ? "Heisei" : "TBD") << endl;
	return 0;
}
 

Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  const k = 10000;
  let cnt_arr = [];
  for (let i = 0; i <= k; i++) cnt_arr[i] = 0;
  for (let i = 0; i < n; i++) cnt_arr[arr[i]]++;
  for (let i = 1; i <= k; i++) cnt_arr[i] += cnt_arr[i - 1];
  let out_arr = [];
  for (let i = n - 1; i >= 0; i--) out_arr[--cnt_arr[arr[i]]] = arr[i];
  console.log(out_arr.join(' '));
})();



Measured memory_bytes: 246496
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

vector<vector<LL>> nextIndex(int k,const string &s){
    int n = s.length();
    vector<vector<LL>> ret(n+1,vector<LL> (26,n));
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) ret[i][j] = ret[i+1][j];
        ret[i][s[i]-'a'] = (i+1)%k;
    }
    return ret;
}


int main(){
    string s,t;cin >> s >> t;
    LL n = s.length();
    auto p = nextIndex(n,s+s);
    LL ans = 0;
    LL pos = 0;
    for (int i = 0; i < t.length(); i++) {
        LL nx = p[pos][t[i]-'a'];
        if(nx>=n){
            puts("-1");
            return 0;
        }
        if(nx<=pos){
            ans += n -(pos-nx);
            pos = nx;
        }
        else{
            ans += nx - pos;
            pos = nx;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 49024