akhauriyash/Code-Regression huggingface dataset:
N = int(input())
keta = 1
now = 0
while now+pow(26,keta) < N:
    now += pow(26,keta)
    keta += 1
ans = ""
while keta:
    for i in range(1,27):
        if N <= now+pow(26,keta-1)*i:
            now += pow(26,keta-1)*(i-1)
            ans += chr(ord('a')+i-1)
            break
    keta -= 1
print(ans)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

ll solve(ll h, ll w)
{
    ll ret = LLONG_MAX;

    if(h>=3)
    {
        if(h%3==0) ret=min(ret,0LL);
        else ret=min(ret,w);
    }
    if(w>=3)
    {
        if(w%3==0) ret=min(ret,0LL);
        else ret=min(ret,h);
    }
    for(ll i=1; i<=w-1; ++i)
    {
        ll a = h*i;
        ll b = (w-i)*(h/2);
        ll c = (w-i)*(h-h/2);
        ret = min(ret, max({a,b,c})-min({a,b,c}));
    }
    for(ll i=1; i<=h-1; ++i)
    {
        ll a = w*i;
        ll b = (h-i)*(w/2);
        ll c = (h-i)*(w-w/2);
        ret = min(ret, max({a,b,c})-min({a,b,c}));
    }

    return ret;
}

int main()
{
    ll h,w;
    cin >>h >>w;
    cout << solve(h,w) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int Min(long long int x,long long int y)
{
    if(x<y)
        return x;
    return y;
}
int main()
{
    long long int n,k,i,j,x;
    long long int ans;
    cin>>n>>k;
    long long int ara[n];
    for(i=0; i<n; i++)
        cin>>ara[i];

    if(ara[0]<0&&ara[n-1]<=0)
        ans=(-1)*ara[0];
    else if(ara[0]>=0 && ara[n-1]>0)
        ans=ara[n-1];
    else
        ans=(ara[n-1]-ara[0]-ara[0]);

    if(ara[0]>=0)
        cout<<ara[k-1]<<endl;
    else if(k==0)
        cout<<0<<endl;
    else
    {
        for(i=0; i<n; i++)
        {
            j=i+k-1;
            if(j>n-1)
                break;
            if(ara[i]<0 && ara[j]>0){
                    x=Min(ara[j]-ara[i]-ara[i],-ara[i]+ara[j]+ara[j]);
                ans=Min(ans,x);
            }
            else if(ara[i]<0 && ara[j]<=0)
                ans=Min(ans,(-1)*ara[i]);
            else
                ans=Min(ans,ara[j]);
        }
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 4420
from collections import defaultdict
import bisect

N = int(input())
A = list(map(int, input().split()))
L2 = [1]
for i in range(40):
    L2.append(L2[-1]*2)
D = defaultdict(int)
for a in A:
    D[a] += 1
A.sort(reverse=True)
res = 0
for a in A:
    if D[a] < 1:
        continue
    D[a] -= 1
    beki2 = L2[bisect.bisect_right(L2, a)]
    j = beki2 - a
    if D[j] > 0:
        D[j] -= 1
        res += 1

print(res)


Measured memory_bytes: 110676
LIMIT = 1000000000000001
alphabet = {-1: "!", 0: "a", 1:"b", 2:"c", 3:"d", 4:"e", 5:"f", 6: "g", 7:"h", 8:"i", 9:"j", 10:"k", 11:"l",
                12:"m", 13:"n", 14: "o", 15:"p", 16:"q", 17:"r", 18:"s", 19:"t", 20:"u", 21: "v",
                22: "w", 23: "x",  24: "y",  25: "z"}



N = int(input())
answer = ""
# times = 1

while True:
    N = N - 1
    a = int(N / 26)
    b = N % 26
    answer += alphabet[b]
    if a == 0: break
    N = a


print(answer[::-1])




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

struct node{
    char name[15]; int p,id;
    friend bool operator<( const node&a , const node&b ){
        if( strcmp( a.name , b.name )==0 ) return a.p>b.p;
        else return strcmp( a.name , b.name )<0;
    }
}a[110];

int main(){
    int n;
    scanf( "%d" , &n );
    for( int i=0 ; i<n ; i++ ){
        a[i].id = i+1;
        scanf( "%s%d" , a[i].name , &a[i].p );
    }
    sort( a , a+n );
    for( int i=0 ; i<n ; i++ ){
        printf( "%d\n" , a[i].id );
    }
    return  0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


N=int(input())

x,y=map(int,input().split())
R=x
L=x
U=y
B=y

P=[(x,y)]
for i in range(1,N):
    x,y=map(int,input().split())
    P.append((x,y))
    if R<x:R=x
    if L>x:L=x
    if U<y:U=y
    if B>y:B=y

p=P[0]

UR=p
dUR=abs(R-p[0])+abs(U-p[1])
UL=p
dUL=abs(L-p[0])+abs(U-p[1])
BR=p
dBR=abs(R-p[0])+abs(B-p[1])
BL=p
dBL=abs(L-p[0])+abs(B-p[1])

for p in P[1:]:
    if dUR>abs(R-p[0])+abs(U-p[1]):
        UR=p
        dUR=abs(R-p[0])+abs(U-p[1])
    if dUL>abs(L-p[0])+abs(U-p[1]):
        UL=p
        dUL=abs(L-p[0])+abs(U-p[1])
    if dBR>abs(R-p[0])+abs(B-p[1]):
        BR=p
        dBR=abs(R-p[0])+abs(B-p[1])
    if dBL>abs(L-p[0])+abs(B-p[1]):
        BL=p
        dBL=abs(L-p[0])+abs(B-p[1])
    

ans=abs(UR[0]-BL[0])+abs(UR[1]-BL[1])

ans2=abs(UL[0]-BR[0])+abs(UL[1]-BR[1])
if ans2>ans: ans=ans2

print(ans)


Measured memory_bytes: 37508
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<>();
    try{
      while(true){
        int n = sc.nextInt();
        if(n==0) break;
        for(int i=0;i<n;i++){
          int S = sc.nextInt();
          list.add(S);
        }
        double Avg=0, sig=0;
        for(Integer num : list){
          Avg += num;
        }
        Avg = Avg / list.size();
        for(Integer num : list){
          sig += Math.pow((num - Avg), 2);
        }
        sig = sig / list.size();
        System.out.println(Math.sqrt(sig));
        list.clear();
      }
    }catch(Exception e){
    }
    sc.close();
  }
}


Measured memory_bytes: 32436
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

vector<pint> vp[30];
int d[30];
int INF=1000100010;
int dijkstra(int st){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,26) d[i]=INF;
    d[st]=0;
    pq.push(make_pair(0,st));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        if(d[t]<pi.first) continue;
        for(auto it:vp[t]){
            if(d[it.second]>d[t]+it.first){
                d[it.second]=d[t]+it.first;
                pq.push(make_pair(d[it.second],it.second));
            }
        }
    }
}
string s[51];
const int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int main(){
    int h,w;
    char sr,dt;
    cin>>h>>w>>sr>>dt;
    rep(i,h) cin>>s[i];
    rep(i,h)rep(j,w){
        if(isalpha(s[i][j])&&s[i][j]!='o'){
            rep(k,4){
                int tx=j+dx[k]*2,ty=i+dy[k]*2;
                char c;
                if(k%2==0) c='-';
                else c='|';
                while(tx>=0&&ty>=0&&tx<w&&ty<h){
                    if(isalpha(s[ty][tx])&&s[ty][tx]!='o'){
                        vp[s[i][j]-'A'].pb(1,s[ty][tx]-'A');
                        break;
                    }
                    else if(s[ty][tx]==c||s[ty][tx]=='o'){
                        tx+=dx[k],ty+=dy[k];
                    }
                    else break;
                } 
            }
        }
    }
    dijkstra(sr-'A');
    cout<<d[dt-'A']<<endl;
    return 0;
}


Measured memory_bytes: 3232
import copy

while 1:
    S = input()
    if S == '#':
        break
    a, b, c, d = map(lambda x : int(x)-1, input().split())
    F = list(S.split('/'))
    if a != c:
        f1 = list(F[a])
        f2 = list(F[c])
        F[a] = []
        for x in f1:
            if x == 'b':
                F[a].append('b')
            else:
                F[a] += [0]*int(x)
        F[c] = []
        for x in f2:
            if x == 'b':
                F[c].append('b')
            else:
                F[c] += [0]*int(x)
        F[a][b] = 0
        F[c][d] = 'b'
        l = 0
        y = ''
        for x in F[a]:
            if x == 'b':
                if l > 0:
                    y += str(l)
                    l = 0
                y += 'b'
            else:
                l += 1
        if l > 0:
            y += str(l)
        F[a] = y
        l = 0
        y = ''
        for x in F[c]:
            if x == 'b':
                if l > 0:
                    y += str(l)
                    l = 0
                y += 'b'
            else:
                l += 1
        if l > 0:
            y += str(l)
        F[c] = y
        print(*F, sep = '/')
    else:
        f1 = list(F[a])
        F[a] = []
        for x in f1:
            if x == 'b':
                F[a].append('b')
            else:
                F[a] += [0]*int(x)
        F[a][b] = 0
        F[c][d] = 'b'
        l = 0
        y = ''
        for x in F[a]:
            if x == 'b':
                if l > 0:
                    y += str(l)
                    l = 0
                y += 'b'
            else:
                l += 1
        if l > 0:
            y += str(l)
        F[a] = y
        print(*F, sep = '/')



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

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



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



int n, m;
int fi[210][210];


bool seen[210][210];
vector<pint> comp;
bool change;

void check(int i, int j) {
    seen[i][j] = true;
    for (int k = 0; k < 6; ++k) {
        int ni = i + dx[i%2][k], nj = j + dy[i%2][k];
        
        if (ni < 0 || ni >= n || nj < 0 || nj >= m) change = false;
        else if (!seen[ni][nj] && fi[ni][nj] == 0) {
            check(ni, nj);
        }
    }
    comp.PB( pint(i,j) );
}

int main() {
    while (cin >> m >> n) {
        memset(fi, 0, sizeof(fi));
        for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> fi[i][j];
        
        memset(seen, 0, sizeof(seen)); 
        for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
            if (!seen[i][j] && fi[i][j] == 0) {
                comp.clear(); change = true;
                check(i, j);
                if (change) for (int k = 0; k < comp.size(); ++k) fi[comp[k].first][comp[k].second] = 1;
            }
        }
        
        int res = 0;
        for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
            if (fi[i][j] == 0) continue;
            for (int k = 0; k < 6; ++k) {
                int ni = i + dx[i%2][k], nj = j + dy[i%2][k];
                if (ni < 0 || ni >= n || nj < 0 || nj >= m) ++res;
                else if (fi[ni][nj] == 0) ++res;
            }
        }
         
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1824
#include <iostream>
#include <cstring>
#include <vector>
bool P[1000000] = {0};

using namespace std;
int main(void) {
  long long N;
  cin >> N;

  // 素数リスト生成
  vector <int> prime_number;
  memset(P, 0, sizeof(P));
  P[0] = P[1] = 1;
  for (int i = 2; i < 1000000; i++) {
    if (P[i]==1) continue;
    if (P[i]==0) {
      prime_number.push_back(i);
      int exclude = i;
      for (;;) {
        if (exclude >= 1000000) break;
        P[exclude] = 1;
        exclude += i;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < prime_number.size(); i++) {
    int cnt = 0;
    for (;;) {
      if ((N%prime_number[i])!=0) {
        break;
      } else {
        cnt++;
        N /= prime_number[i];
      }
    }
    // ansを足す
    for (int j = 1;; j++) {
      if (cnt >= j) {
        ans++;
        cnt -= j;
      } else {
        break;
      }
    }
  }
  if (N > 1) ans++;
  cout << ans << endl;
  return 0;
}


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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
        char a, b, c;
        cin >> a >> b >> c;
        if ((a == b) && (b == c)) cout << "No" << ende;
        else cout << "Yes" << ende;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        //var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        WriteLine((double)ar[0] / ar[1]);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13140
N = int(input())
S = [input() for _ in range(N)]
from itertools import groupby
S = sorted(S)
g = groupby(S)
ans = []
j = 0
for key,group in g:
  i = len(list(group))
  if i>j:
    ans = [key]
    j = i
  elif i==j:
    ans.append(key)
  else:
    continue

for a in ans:
  print(a)

Measured memory_bytes: 84420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		short a = Short.parseShort(br.readLine());
		System.out.print((short) (a + Math.pow(a, 2) + Math.pow(a, 3)));
	}
}


Measured memory_bytes: 32728
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 200005
#define MAXM 20
#define MAXK (1<<MAXM)
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
#define prev daksiisaas
#define next aijdkjsaod
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int N,V,x[MAXN];
vector<int> v;
int prev[MAXN][MAXM],next[MAXN][MAXM];
int predp[MAXK],sufdp[MAXK];
int mini[MAXN];
int main()
{
    scanf("%d%d",&N,&V);
    for(int i=1;i<=N;i++) scanf("%d",&x[i]);
    int dummy=V;
    while(dummy)
    {
        v.push_back(dummy);
        dummy/=2;
    }
    v.push_back(0);
    reverse(v.begin(),v.end());
    int sz=(int)v.size();
    for(int i=(int)v.size()-1;i>=0;i--) next[N][i]=N;
    for(int i=N-1;i>=0;i--)
        for(int j=(int)v.size()-1;j>=0;j--)
            if(x[i+1]-x[i]>v[j]) next[i][j]=i; else next[i][j]=next[i+1][j];
    for(int i=(int)v.size()-1;i>=0;i--) prev[1][i]=1;
    for(int i=2;i<=N;i++)
        for(int j=(int)v.size()-1;j>=0;j--)
            if(x[i]-x[i-1]>v[j]) prev[i][j]=i; else prev[i][j]=prev[i-1][j];
    //for(int i=1;i<=N;i++) printf("%d %d %d %d\n",prev[i][1],prev[i][2],next[i][1],next[i][2]);
    memset(predp,0,sizeof(predp));
    for(int mask=0;mask<(1<<sz);mask++)
    {
        for(int j=0;j<sz;j++)
        {
            if(mask&(1<<j)) continue;
            predp[mask^(1<<j)]=max(predp[mask^(1<<j)],next[min(predp[mask]+1,N)][j]);
        }
    }
    for(int mask=0;mask<(1<<sz);mask++) sufdp[mask]=N+1;
    for(int mask=0;mask<(1<<sz);mask++)
    {
        for(int j=0;j<sz;j++)
        {
            if(mask&(1<<j)) continue;
            sufdp[mask^(1<<j)]=min(sufdp[mask^(1<<j)],prev[max(sufdp[mask]-1,1)][j]);
        }
    }
    for(int i=0;i<=N+1;i++) mini[i]=N+2; 
    for(int mask=0;mask<(1<<(sz-1));mask++)
    {
        int dmask=(1<<(sz-1))-1-mask;
        int l=predp[mask],r=sufdp[dmask];
        mini[l]=min(mini[l],r);
    }
    for(int i=N;i>=0;i--) mini[i]=min(mini[i],mini[i+1]);
    for(int i=1;i<=N;i++)
    {
        int l=prev[i][sz-1],r=next[i][sz-1];
        if(l==1&&r==N) {puts("Possible"); continue;}
        //printf("%d %d\n",l,r);
        if(mini[l-1]<=r+1) puts("Possible"); else puts("Impossible");
    }
    return 0;
}



Measured memory_bytes: 43392
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >>t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s<t) cout << "Yes" <<endl;
    else cout << "No" <<endl;
    return 0;
}

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

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

	vector< int > vec( a );

	for( auto &it : vec )
	{
		cin >> it;
	}

	sort( vec.begin(), vec.end(), greater<int>() );


	int cnt = 0;
	int befSize = 0;


	for( auto &it : vec )
	{
		if( befSize != it )
		{
			befSize = it;
			cnt++;
		}
		
	}





	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const MOD = 1000000007LL;

ll factorization(ll k) {
  ll sum = 1;
  for (ll i = 1; i <= k; ++i) sum = (sum % MOD) * (i % MOD);
  return sum;
}

int main() {
  ll N, M;
  cin >> N >> M;
  if (abs(N - M) > 1) {
    cout << 0 << endl;
    return 0;
  }
  ll n_fact = factorization(N);
  ll m_fact = factorization(M);
  if (N == M) {
    cout << ((n_fact % MOD) * (m_fact % MOD) * 2) % MOD << endl;
    return 0;
  }
  cout << ((n_fact % MOD) * (m_fact % MOD)) % MOD << endl;
  return 0;
}

Measured memory_bytes: 256
import copy
n,k=map(int,input().split())
d=list(map(int,input().split()))
ans=n
while True:
    flag=True
    c=copy.deepcopy(str(ans))
    for i in range(len(c)):
        if int(c[i]) in d:
            flag=False
            break
    if flag:
        print(ans)
        exit()
    ans+=1


Measured memory_bytes: 9288
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int n;

    cin >> n;

    if (n >= 1000) {
        cout << "ABD";
    } else {
        cout << "ABC";
    }
    cout << endl;

    return 0;
}



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

int main(void)
{
  int w,a,b;
  scanf("%d %d %d",&w,&a,&b);
  if(a>b){
    int tmp=a;
    a=b;
    b=tmp;
  }
  if(a+w>=b){
    puts("0");
    return 0;
  }
  printf("%d\n",abs((a+w)-b));
  return 0;
}


Measured memory_bytes: 1640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

ll powll(ll n,ll k){ ll ret=1; while(k){ if(k&1)ret=ret*n; n=n*n; k>>=1; } return ret; }

int main(){
  ll n;
  cin >> n;
  if(n==2){ cout<<1<<endl; return 0;}
  set<ll> st;
  for(ll i=2; i*i<=n; i++)if((n-1)%i==0){
    st.insert(i);
    st.insert((n-1)/i);    
  }
  for(ll i=2; i*i<=n; i++)if(n%i==0){
    ll tmp=n;
    while(tmp%i==0){tmp/=i;}
    if(tmp%i==1) st.insert(i);

    if(i==n/i) continue;
    tmp=n;
    while(tmp%(n/i)==0){tmp/=(n/i);}
    if(tmp%i==1) st.insert(n/i);    
  }
  ll ans = st.size()+2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
 
int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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(){
  ll N,sum=0,r=0,cnt=0;
  cin>>N;
  ll A[N];
  for(ll i=0;i<N;i++) cin>>A[i];
  for(ll l=0;l<N;l++){
    while(r<N&&(sum+A[r])==(sum^A[r])){
      sum+=A[r];
      r++;
    }
    cnt+=r-l;
    if(l==r) r++;
    else sum-=A[l];
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

class DirectedGraph {
   public:
    struct Node {
        vector<Node*> out_edges, in_edges;
        int index = -1;
        int __topo_indegree = 0, __topo_index = -1;
    };
    vector<Node> graph;
    DirectedGraph(int n) {
        graph = vector<Node>(n);
        for (int i = 0; i < this->graph.size(); i++) {
            this->graph[i].index = i;
        }
    }
    void add_edge(int u, int v) {
        assert(u < graph.size() && v < graph.size());
        graph[u].out_edges.push_back(&graph[v]);
        graph[v].in_edges.push_back(&graph[u]);
    }
    vector<ll> toposort() {
        // Marking in-degree and index, preparing the queue
        queue<ll> process;
        for (int i = 0; i < this->graph.size(); i++) {
            this->graph[i].__topo_indegree = this->graph[i].in_edges.size();
        }
        for (auto node : this->graph)
            if (node.__topo_indegree == 0)
                process.push(node.index);
        // Processing the queue and preparing toposorted index list
        vector<long long> toposort;
        while (!process.empty()) {
            ll node = process.front();
            process.pop();
            toposort.push_back(node);
            for (auto neighbor : this->graph[node].out_edges) {
                neighbor->__topo_indegree--;
                if (neighbor->__topo_indegree == 0)
                    process.push(neighbor->index);
            }
        }
        // Marking the topo order and returning
        for (int i = 0; i < this->graph.size(); i++)
            this->graph[toposort[i]].__topo_index = i;
        return toposort;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    DirectedGraph g(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g.add_edge(u - 1, v - 1);
    }
    auto toposort = g.toposort();
    vector<ll> dp(n, 0);
    for (int i = 0; i < n; i++) {
        for (DirectedGraph::Node* prev : g.graph[toposort[i]].in_edges) {
            dp[i] = max(dp[i], dp[prev->__topo_index] + 1);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 14456
N = int(input())
A = list(map(int, input().split()))
even = []
approved = []

for i in A:
    if i%2==0:
        even.append(i)

for i in even:
    if i%3==0 or i%5==0:
        approved.append(i)

if even == approved:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
<?php
//????????¨?????????????????????
$changeList;
//????????\???????????°
$ans = "";
while(true){
//????????¨????????°??????????????????
    $stdin=trim(fgets(STDIN));
    //?????°???0??????break
    if($stdin == 0){
        break;
    }
    for($i = 0;$i<$stdin;$i++){
        //??\??????????????§??????
        $changeIn=trim(fgets(STDIN));
        $changes = explode(" ", $changeIn);
        //????????¨?????????
        $changeList[$i][0] = $changes[0];
        $changeList[$i][1] = $changes[1];
    }
    //??????????±?????????°?????????
    $m=trim(fgets(STDIN));
    //m?????????????±??????\???
    if($m <= 10**5){
        for($i = 0;$i<$m;$i++){
            //??????????±??????\???
            $in=trim(fgets(STDIN));
            for($j = 0;$j<$stdin;$j++){
                //????????¨????????¨?????????????????´?????????
                if($in == $changeList[$j][0]){
                    $in=$changeList[$j][1];
                    break;
                }
            }
            $ans .= $in;
        }
    }
        //????????????
        echo $ans."\n";
        //?????????
        $ans = "";
}

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

int main(){
    int N;
    cin >> N;
    if (N % 2 == 0) cout << N / 2 << endl;
    else cout << N / 2 + 1 <<endl;
}



Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    array=Vector{String}()
    for i in 1:n
        s=chomp(readline())
        push!(array,join(sort(collect(s))))
    end
    sort!(array)
    pat=[0 for i in 1:10^5]
    for i in 2:10^5
        pat[i]=pat[i-1]+i-1
    end
    ans=0
    cnt=1
    for i in 1:n
        if i==n
            ans+=pat[cnt]
        elseif array[i]!=array[i+1]
            ans+=pat[cnt]
            cnt=1
        else
            cnt+=1
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 175544
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	l,r := 0,n
	fmt.Println(0)
	ls := scanText()
	rs := ls

	for r > l+1 {
		mid := (r+l)/2
		fmt.Println(mid)
		mids := scanText()

		if mids=="Vacant" {
			return
		}

		var next bool
		if ls==mids {
			if (mid-l+1)%2==0 {
				next = false
			}
		} else {
			if (mid-l+1)%2==1 {
				next = false
			}
		}
		if mids==rs {
			if (r-mid+1)%2==0 {
				next = true
			}
		} else {
			if (r-mid+1)%2==1 {
				next = true
			}
		}

		if next {
			ls = mids
			l = mid
		} else {
			rs = mids
			r = mid
		}
	}
	fmt.Println(l)
}


Measured memory_bytes: 1232
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N ; cin >> N;
  vector<ll> A;
  rep(i,N*2){
    ll inp; cin >> inp;
    A.pb(inp);
  }

  ll ans = 0;
  rep(i,N){
    ll cnt = 0; 
    rep(j,A.size()){
      cnt+=A[j];
      if(j==i) j+=(N-1);
    }
    ans = max(ans,cnt);
  }

  cout << ans << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_095_D.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(11).
    01 INP2   PIC 9(4).
    01 maxlen PIC 9(1)  VALUE 2.
    01 cur    PIC 9(2)  VALUE 1.

    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 k      PIC 9(18).

    01 len    PIC 9(2).

    01 ans    PIC X(8).

    01 NX1.
        03 NX11 OCCURS 2.
            05 NX PIC 9(8).
    01 m1.
        03 m11 OCCURS 100.
            05 m PIC 9(4).

    01 tmp    PIC 9(8).

    01 mn     PIC 9(6).
    01 sm     PIC 9(6).
    01 x      PIC 9(6).

    01 ZS     PIC Z(9).
    01 DUMMY  PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO NX(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    MOVE 0 TO sm.
    MOVE 1001 TO mn.
    PERFORM VARYING k FROM 1 BY 1 UNTIL NX(1) < k
        ACCEPT INP2
        MOVE INP2 TO m(k)
        ADD m(K) TO sm
        COMPUTE mn = FUNCTION MIN(mn, m(k))
    END-PERFORM.

    SUBTRACT sm FROM NX(2) GIVING tmp.
    DIVIDE mn INTO tmp GIVING x.

    ADD x TO NX(1).
    MOVE NX(1) TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> v(n, 0);
  for(int i = 0; i < n; i++){
    int m;
    cin >> m;
    v[m-1]++;
  }
  sort(v.rbegin(), v.rend());
  int ans = 0;
  for(int i = k; i < n; i++){
    if(v[i] > 0) ans += v[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    using namespace std;
    int N,A,B;
    cin>>N>>A>>B;

    int mina=0;
    int mid=0;
    int maxb=0;
    int p;
    for(int i=0;i<N;i++){
        cin>>p;
        if(p<=A){
            mina++;
        }else if(p<=B){
            mid++;
        }else{
            maxb++;
        }
    }

    int ans=mina;
    if(ans>mid){
        ans=mid;
    }
    if(ans>maxb){
        ans=maxb;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3656
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let last = s.trim().chars().rev().nth(0).unwrap();
    let num = last.to_string().parse().unwrap();
    match num {
        0 => println!("pon"),
        1 => println!("pon"),
        2 => println!("hon"),
        3 => println!("bon"),
        4 => println!("hon"),
        5 => println!("hon"),
        6 => println!("pon"),
        7 => println!("hon"),
        8 => println!("pon"),
        9 => println!("hon"),
        _ => println!(""),
    }
}

Measured memory_bytes: 2156
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
}

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

int main() {
  int H, W; cin >> H >> W;
  int N = H*W;
  int A[N]; string str;
  int white_num = 0;
  for (int i = 0; i < H; i++) {
    cin >> str;
    for (int j = 0; j < W; j++) {
      white_num += A[i*W+j] = (str[j] == '.');
    }
  }
  queue<pair<int, int>> Q; Q.push(make_pair(0, 1));
  bool visited[N]; for (int i = 0; i < N; i++) visited[i] = false;
  visited[0] = true;
  int score = -1;
  while (!Q.empty()) {
    auto front = Q.front(); Q.pop();
    int u = front.first, d = front.second;
    if (u == H*W-1) { score = white_num-d; break; }
    vector<int> e;
    if (u >= W) e.push_back(u-W);
    if (u % W > 0) e.push_back(u-1);
    if (u % W < W-1) e.push_back(u+1);
    if (u / W < H-1) e.push_back(u+W);
    for (int v : e) {
      if (A[v] && !visited[v]) {
        visited[v] = true;
        Q.push(make_pair(v, d+1));
      }
    }
  }
  cout << score << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);

    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if (n>k) cout << k*x+(n-k)*y << endl;
    else cout << n*x << endl;

    return 0;   
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def chmin(val: int, new: int):
    if new < val:
        return new
    else:
        return val

N = int(input())
H = list(map(int, input().split()))

dp = [sys.maxsize] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])

for i in range(2,N):
    dp[i] = chmin(dp[i],dp[i-1] + abs(H[i]-H[i-1]))
    dp[i] = chmin(dp[i],dp[i-2] + abs(H[i]-H[i-2]))

print(dp[N-1])



Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    if(n%2) cout << 0 << endl;
    else{
        ull ans = 0, a = 10;
        while(a <= n){
            ans += n/a;
            a *= 5;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	ll n, d, a;
	cin >> n >> d >> a;
	vector<P> vs(n);
	rep(i, n) {
		cin >> vs[i].first >> vs[i].second;
	}
	sort(vs.begin(), vs.end());
	map<ll, ll> memo;
	ll sum = 0;
	ll c = 0;
	vector<ll> rem;
	rep(i, n) {
		auto p = vs[i];
		auto x = p.first;
		auto h = p.second;
		rem.clear();
		for (auto e : memo) {
			if (e.first < x) {
				rem.push_back(e.first);
				c -= e.second;
			}
			else break;
		}
		for (auto e : rem) memo.erase(e);
		ll cu = h % a ? h / a + 1 : h / a;
		cu -= c;
		cu = max(0LL, cu);
		sum += cu;
		c += cu;
		memo[x + 2 * d] += cu;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000010
#define N 2010
#define red(x) (x)
#define blue(x) (n+(x))
#define id(x) (2002+(x))
using namespace std;
const ll mod=1e9+7;
ll S,T;
ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9')
    {
        if (c=='-') f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
ll n,p[N],d[N],q[N],pre[N],t=-1,ans;
bool flag[N];
ll inc(ll &x)
{
    x++;
    if (x>2007) x-=2007;
    return x;
}
struct edge
{
    ll to,nxt,cap,flow,cost;
} s[N<<5];
void add(ll x,ll y,ll z,ll cost)
{
    s[++t].to=y,s[t].nxt=p[x],s[t].cap=z,s[t].flow=0,s[t].cost=cost,p[x]=t;
    s[++t].to=x,s[t].nxt=p[y],s[t].cap=0,s[t].flow=0,s[t].cost=-cost,p[y]=t;
}
bool spfa()
{
    memset(d,60,sizeof(d));
    d[S]=0;
    memset(flag,0,sizeof(flag));
    ll head=0,tail=1;
    q[1]=S;
    do
    {
        ll x=q[inc(head)];
        flag[x]=0;
        for (ll i=p[x]; ~i; i=s[i].nxt)
            if (s[i].flow<s[i].cap&&d[x]+s[i].cost<d[s[i].to])
            {
                d[s[i].to]=d[x]+s[i].cost;
                pre[s[i].to]=i;
                if (!flag[s[i].to]) q[inc(tail)]=s[i].to,flag[s[i].to]=1;
            }
    }
    while (head!=tail);
    return d[T]<10000000000000000ll;
}
void ekspfa()
{
    while (spfa())
    {
        ll v=n;
        for (ll i=T; i!=S; i=s[pre[i]^1].to)
            v=min(v,s[pre[i]].cap-s[pre[i]].flow);
        for (ll i=T; i!=S; i=s[pre[i]^1].to)
            s[pre[i]].flow+=v,s[pre[i]^1].flow-=v,ans+=v*s[pre[i]].cost;
    }
}
ll val[10];
struct node
{
    ll x,y,z;
    ll tmp[10];
} a[N],b[N];
int main()
{
    n=read();
    memset(p,255,sizeof(p));
    S=0,T=2*n+1;
    for(ll i=1; i<=n; i++)
    {
        a[i].x=read(),a[i].y=read(),a[i].z=read();
        //readf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
        //cin>>a[i].x>>a[i].y>>a[i].z;
        add(S,i,a[i].z,0);
        a[i].tmp[0]=a[i].x+a[i].y;
        a[i].tmp[1]=a[i].x-a[i].y;
        a[i].tmp[2]=-a[i].x+a[i].y;
        a[i].tmp[3]=-a[i].x-a[i].y;
    }
    for(ll i=1; i<=n; i++)
    {
        b[i].x=read(),b[i].y=read(),b[i].z=read();
        //readf("%d%d%d",&b[i].x,&b[i].y,&b[i].z);
        add(i+n,T,b[i].z,0);
        b[i].tmp[0]=-b[i].x-b[i].y;
        b[i].tmp[1]=-b[i].x+b[i].y;
        b[i].tmp[2]=b[i].x-b[i].y;
        b[i].tmp[3]=b[i].x+b[i].y;
    }
    for(ll i=1; i<=4; i++)
    {
        val[i-1]=2*n+i+1;
    }
    for(ll i=1; i<=n; i++)
    {
        for(ll j=0; j<4; j++)
        {
            add(i,val[j],a[i].z,-a[i].tmp[j]);
            add(val[j],i+n,b[i].z,-b[i].tmp[j]);
        }
    }
    ekspfa();
    cout<<-ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
n,k = map(int,input().split())
d = list(map(lambda x: (int(x) + 1) / 2, input().split()))
ret = sum(d[:k])
tmp = ret
for i in range(k,n):
  tmp = tmp + d[i] - d[i-k]
  ret = max(ret,tmp)
print(ret)


Measured memory_bytes: 23524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;cin>>s;
    int prev,next;
    prev=10*(int)(s.at(0)-'0')+(int)(s.at(1)-'0');
    next=10*(int)(s.at(2)-'0')+(int)(s.at(3)-'0');
    if((prev>12 ||prev<=0 )&& (next>12 || next<=0)){
        cout<<"NA"<<endl;
    }else if((prev>12 || prev<=0) && (next<=12 && next>0)){
        cout<<"YYMM"<<endl;
    }else if((next>12 || next<=0)&& (prev<=12 && prev>0)){
        cout<<"MMYY"<<endl;

    }else{
        cout<<"AMBIGUOUS"<<endl;
    }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int ans=0;

int32_t main()
{
	IOS
	int n,w;cin>>n>>w;
	vector<int>W(n),V(n);
	for(int i=0;i<n;i++)cin>>W[i]>>V[i];
	vector<int>dp(w+1);
	
	for(int i=0;i<n;i++)
	{
		//why two dps are takne ? because every w get included maximum 1 times.
		vector<int>dp2=dp;
		for(int j=0;j<=w;j++)
		{
			if( j-W[i] >=0 )dp2[j]=max(dp2[j],dp[j-W[i]]+V[i]);
		}
		dp=dp2;
	}
	cout<<dp[w]<<endl;
	
}
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 1804
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout << fixed << setprecision(10);
}
const int INF = numeric_limits<int>::max();
struct edge {
	int from, to, cap, rev;
};
vector<vector<edge>>g;//グラフの隣接リスト表現
vector<int>level;//sからの距離(辺何本分離れているか)
vector<int>iter;//どこまで調べ終わったか
int v, e;

void add_edge(int from,int to, int cap) {//from→to　容量capの辺をグラフに追加
	g[from].push_back(edge{ from,to,cap,(int)g[to].size() });
	g[to].push_back(edge{ to,from ,0,(int)g[from].size() - 1 });
}
void dinic_bfs(int s) {//sからの最短距離(辺何本分離れているか)をbfsで計算する
	fill(level.begin(),level.end(),-1);
	queue<int>que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		for(int i=0;i<g[v].size();i++){
			edge &e = g[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}
int dinic_dfs(int v, int t, int f) {//増加パスをdfsで探す
	if (v == t) {
		return f;
	}
	for (int &i = iter[v]; i < g[v].size(); i++) {
		edge &e = g[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			int d = dinic_dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		dinic_bfs(s);
		if (level[t] < 0) {
			return flow;
		}
		fill(iter.begin(), iter.end(), 0);
		int f;
		while ((f = dinic_dfs(s, t, INF)) > 0) {
			flow += f;
		}
	}
}
signed main() {
	cin >> v >> e;
	g.resize(v);
	level.resize(v);
	iter.resize(v);
	for (int i = 0; i < e; i++) {
		int from, to, cap;
		cin >> from >> to >> cap;
		add_edge(from, to, cap);
	}
	cout << max_flow(0, v - 1) << endl;
	return 0;
}




Measured memory_bytes: 3248
num = 3 * int(input())
target = [int(n) for n in input().split(" ")]
target.sort()
third = num // 3
answer = 0
temp = 0
for i in range(third):
    answer += target[num - (2 * (i+1))]
    temp += target[third+i]
#     print(num - (2 * (i+1)))
print(max(answer,temp))

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

int main(){
  long long a,b,c; cin >> a >> b >> c;
  if(c<=a+b) cout << "No" << endl;
  else if(4*a*b<(c-a-b)*(c-a-b)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
def solve():
    A = [list(map(int, input().split())) for i in range(3)]
    N = int(input())
    bingo = [[False] * 3 for i in range(3)]
    for _ in range(N):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if b == A[i][j]:
                    bingo[i][j] = True
    
    for i in range(3):
        if bingo[i][0] and bingo[i][1] and bingo[i][2]:
            print('Yes')
            exit(0)
        
        if bingo[0][i] and bingo[1][i] and bingo[2][i]:
            print('Yes')
            exit(0)
    
    if bingo[0][0] and bingo[1][1] and bingo [2][2]:
        print('Yes')
        exit(0) 

    if bingo[0][2] and bingo[1][1] and bingo [2][0]:
        print('Yes')
        exit(0) 
    
    print('No')

if __name__ == '__main__':
    solve()

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> ans(n);
    rep(i, n) ans[a[i] - 1] = i + 1;
    rep(i, n)
    {
        cout << ans[i] << endl;
    }
}

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

int connected(int adj[][51], int n)
{
	int i, j, flag[51] = {0, 1}, count[2] = {1};
	while (1) {
		for (i = 1; i <= n; i++) {
			if (flag[i] == 0) continue;
			for (j = 1; j <= n; j++) if (adj[i][j] == 1) flag[j] = 1;
		}
		for (i = 1, count[1] = 0; i <= n; i++) if (flag[i] == 1) count[1]++;
		if (count[1] > count[0]) count[0] = count[1];
		else break;
	}
	if (count[0] == n) return 1;
	else return 0;
}

int main()
{
	int i, N, M, a[51], b[51];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) scanf("%d %d", &(a[i]), &(b[i]));
	
	int j, adj[51][51] = {}, count = 0;
	for (i = 1; i <= M; i++) {
		adj[a[i]][b[i]] = 1;
		adj[b[i]][a[i]] = 1;
	}
	for (i = 1; i <= M; i++) {
		adj[a[i]][b[i]] = 0;
		adj[b[i]][a[i]] = 0;
		if (connected(adj, N) == 0) count++;
		adj[a[i]][b[i]] = 1;
		adj[b[i]][a[i]] = 1;
	}
	
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128