akhauriyash/Code-Regression huggingface dataset:
const Main = input => {
    input = input.trim();
    input = input.split(" ").map(value => parseInt(value, 10));

    const x = input[0];
    const y = input[1];

    const a = (4 * x - y) / 2;
    const b = (y - 2 * x) / 2;

    if(a >= 0 && b >= 0 && Number.isInteger(a) && Number.isInteger(b)) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29624
#include <stdio.h>
#include <memory.h>
#define N 20000
struct data{
  int t,s,d;
};
int main(void){
  int n,m,i,j,ans,f[N+1];
  struct data d[N],t;
  while(1){
    scanf("%d %d",&n,&m);
    if(!n)
      break;
    memset(f,0,sizeof(f));
    memset(d,0,sizeof(d));
    for(i=0;i<m;i++)
      scanf("%d %d %d",&d[i].t,&d[i].s,&d[i].d);
    for(i=0;i<m-1;i++){
      for(j=m-1;j>i;j--){
	if(d[j-1].t>d[j].t){
	  t=d[j-1];
	  d[j-1]=d[j];
	  d[j]=t;
	}
      }
    }
    f[1]=1;
    for(i=0;i<m;i++)
      if(f[d[i].s])
	f[d[i].d]=1;
    ans=0;
    for(i=0;i<=n;i++)
      ans+=f[i];
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 920
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
x=[a,b,c,d,e]
y=[]
z=[]
ans=0
for i in range(5):
    z.append(x[i]//10)
    if x[i]%10==0:
        y.append(10)
        z[0]-=1
    else:
        y.append(x[i]%10)
    
for i in range(5):
    ans+=z[i]

ans+=4
ans*=10
ans+=min(y)

print(ans)


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll r, g;
	cin >> r >> g;
	cout << 2 * g - r;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool flag = true;
            for(int i = 0; i < s.Length; i++)
            {
                if ((i + 1) % 2 == 0)
                {
                    if (s[i] == 'R')
                    {
                        flag = false;
                        break;
                    }
                }
                else
                {
                    if (s[i] == 'L')
                    {
                        flag = false;
                        break;
                    }
                }
            }
            if (flag) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 25844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int facc(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    int n; cin >> n;
    vector<int> p(n), q(n), r(n), s(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
        r[i] = p[i];
    }
    for(int i=0; i<n; i++){
        cin >> q[i];
        s[i] = q[i];
    }
    sort(r.begin(), r.end());
    sort(s.begin(), s.end());
    int ans1 = 1, ans2 = 1;
    int final_ans1, final_ans2;
    do {
        for(int i=0; i<r.size(); i++) 
        if(p[i] != r[i]){
            ans1 += 1;
            break;
        }else if((i == r.size()-1) && (r[i] == p[i])){
            final_ans1 = ans1;
        }
    } while( next_permutation(r.begin(), r.end()));
    do {
        for(int i=0; i<s.size(); i++) 
        if(q[i] != s[i]){
            ans2 += 1;
            break;
        }else if((i == s.size()-1) && (s[i] == q[i])){
            final_ans2 = ans2;
        }
    } while( next_permutation(s.begin(), s.end()));
    cout << abs(final_ans1 - final_ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 8

int mp[N][N],row[N],col[N],dneg[2*N-1],dops[2*N-1];

void init()
{
    for(int i=0; i<N; i++)
        row[i]=col[i]=0;
    for(int i=0; i<2*N-1; i++)
        dneg[i]=dops[i]=0;
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++)
            mp[i][j]=0;
}

void check()
{
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++)
            if(mp[i][j])
            {
                if(row[i]!=j)
                    return ;
            }
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<N; j++)
        {
            printf("%c",(row[i]==j)?'Q':'.');
        }
        printf("\n");
    }
    return ;
}

void dfs(int i)
{
    if(i==N)
    {
        check();
        return ;
    }
    for(int j=0; j<N; j++)
    {
        if(col[j] || dops[i+j] || dneg[i-j+N-1]) continue;
        row[i]=j;
        col[j]=dops[i+j]=dneg[i-j+N-1]=1;
        dfs(i+1);
        row[i]=col[j]=dops[i+j]=dneg[i-j+N-1]=0;
    }
}

int main()
{
    int k,r,c;
    while(~scanf("%d",&k))
    {
        init();
        for(int i=0; i<k; i++)
        {
            scanf("%d%d",&r,&c);
            mp[r][c]=1;
        }
        dfs(0);
    }
    return 0;
}



Measured memory_bytes: 2596
n = int(input())
list_val = [int(val) for val in input().split()]
if len(list_val)<1:
  print(0)
dict_val = {}
count=0
for i in range(n):
  dict_val[list_val[i]] = dict_val.get(list_val[i],0)+1
for key, values in dict_val.items():
  if key>values:
    count+=values
  elif key<values:
    count+=values-key
print(count)

Measured memory_bytes: 21836
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;
int p[MAX_N];

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d", &p[i]);
  int res = 0;
  for (int i = 1; i <= N; ++i)
    if (p[i] == i) {
      int j = i;
      while (p[j] == j && j <= N) j++;
      res += (j - i + 1) / 2;
      i = j - 1;
    }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s = "AKIHABARA";
	string t;
	cin >> t;
	int in = 0;
	int cnt = 0;
	string a = "";
	vector<int> c;
	vector<int> ok = {1, 0, 0, 1, 1, 1};
	REP(i, t.size()){
		if(t[i] != 'A'){
			a = a+t.substr(i, 1);
			c.push_back(cnt);
			cnt = 0;
		}else{
			cnt++;
		}
	}
	c.push_back(cnt);
	if(a != "KIHBR" || c.size() != ok.size()){
		cout << "NO" << endl;
	}else{
		REP(i, c.size()){
			if(c[i] > ok[i]){
				cout << "NO" << endl;
				return 0;
			}
		}
		cout << "YES" << endl;
	}
}


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

// #define int long long
#define rep(i, n) for (ll i = (ll)(0); i < (ll)(n); ++i)
#define reps(i, n) for (ll i = (ll)(1); i <= (ll)(n); ++i)
#define rrep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define rreps(i, n) for (ll i = ((ll)(n)); i > 0; i--)
#define irep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); ++i)
#define ireps(i, m, n) for (ll i = (ll)(m); i <= (ll)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) ll(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

const ll maxn_bellmanford=2505;
vector<vll> G(maxn_bellmanford);
bool reachableFrom1[maxn_bellmanford];
void dfs(ll v){
  if(reachableFrom1[v]) return;
  reachableFrom1[v]=true;
  for(auto nv: G[v]){
    dfs(nv);
  }
}

vector<vll> rG(maxn_bellmanford);
bool reachableToN[maxn_bellmanford];
void rdfs(ll v){
  if(reachableToN[v]) return;
  reachableToN[v]=true;
  for(auto nv: rG[v]){
    rdfs(nv);
  }
}

ll n,m;
vector<tuple<ll,ll,ll>> es;
ll dist[maxn_bellmanford];
bool ok[maxn_bellmanford];

bool bellmanford(ll s){
  fill(dist,dist+n,INF);
  dist[s]=0;
  bool update=true;
  ll cnt=0;
  while(update){
    update=false;
    for(auto e: es){
      ll a,b,c;
      tie(a,b,c)=e;
      if(!ok[a]||!ok[b]) continue;
      if(chmin(dist[b],dist[a]+c)) update=true;
    }
    if(cnt>=n){
      return true; // has negative loop
    }
    cnt++;
  }
  return false;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll m; cin>>n>>m;
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--; c=-c;
    es.emplace_back(a,b,c);
    G[a].push_back(b);
    rG[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i]=reachableFrom1[i]&&reachableToN[i];
  if(bellmanford(0)){
    cout<<"inf"<<endl;
  }else{
    cout<<-dist[n-1]<<endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0) {
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
s = list(input())
g = 0
p = 0
ans = 0
for i in range(len(s)):
    if s[i] == "g":
        if p+1 <= g:
            ans += 1
            p += 1
        else:
            g += 1
    else:
        if p+1 <= g:
            p += 1
        else:
            ans -= 1
            g += 1
print(ans)

Measured memory_bytes: 9684
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int func(int n){
  int cnt = 0;
  for(int i=1; i<=n; i++){
    if( n%i == 0 ) cnt++;
  }
  return cnt;
}

int main() {

  int n; cin >> n;
  int ans = 0;
  for(int i=1; i<=n; i+=2) {
    if(func(i) == 8){
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}




//


Measured memory_bytes: 256
N=int(input())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

ans=0
for i in range(N):
    a=A[N-1-i]+ans 
    b=B[N-1-i]
    if a%b==0:
        continue
    else:
        c=a//b
        d=c+1
        e=b*d
        f=e-a
        ans+=f
print(ans)


Measured memory_bytes: 11052
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 2005;

int N, Z, W;
int a[MAX_N];
int X[MAX_N][MAX_N], Y[MAX_N][MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> Z >> W;
    for (int i = 1; i <= N; i++) {
        std::cin >> a[N - i + 1];
    }

    for (int i = 2; i <= N; i++) {
        X[1][i] = abs(a[1] - a[i]);
        Y[1][i] = abs(a[1] - a[i]);
    }
    X[1][N+1] = abs(a[1] - W);
    Y[1][N+1] = abs(a[1] - Z);

    for (int n = 2; n <= N; n++) {
        for (int i = n + 1; i <= N + 1; i++) {
            X[n][i] = std::max(X[n-1][i], Y[n-1][n]);
            Y[n][i] = std::min(Y[n-1][i], X[n-1][n]);
        }
    }

    std::cout << X[N][N+1] << std::endl;
    return 0;

}



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

const int64_t mod = 1000000007;

void matmul(vector<vector<int64_t>> &a, const vector<vector<int64_t>> &b) {
  int n = a.size();
  vector<vector<int64_t>> ans(n, vector<int64_t>(n));
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < n; k++) {
      for (int j = 0; j < n; j++) {
        (ans.at(i).at(j) += a.at(i).at(k) * b.at(k).at(j) % mod) % mod;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      a.at(i).at(j) = ans.at(i).at(j) % mod;
    }
  }
}

void matpow(vector<vector<int64_t>> &a, int64_t k) {
  if (k == 1) return;
  vector<vector<int64_t>> a_old = a;
  matmul(a, a);
  matpow(a, k / 2);
  if (k % 2) matmul(a, a_old);
}

int main() {
  int64_t n, k;
  cin >> n >> k;
  vector<vector<int64_t>> a(n, vector<int64_t>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a.at(i).at(j);
    }
  }
  matpow(a, k);
  int64_t ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ans += a.at(i).at(j);
      ans %= mod;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1536
// B: Cakes & Donuts
"use strict";

const DEBUG_MODE = false;
const rawInput = DEBUG_MODE
  ? "83"
  : require("fs")
    .readFileSync("/dev/stdin", "utf8")
    .trim();

const process = inputRaw => {
  const cash = parseInt(inputRaw);
  let valid = false;

  if (cash%7 === 0 || cash%4 === 0) {
    valid = true;
  } else {
    // check all multiples of 4 and subtract from cash-7 and check if it is divisible by 7
    for (let i=4, lim=cash-7; i<=lim; i+=4) {
      if ((lim-i)%7 === 0) {
        valid = true;
        break;
      }
    }

    // if still not valid, do the reverse
    if (!valid) {
      // check all multiples of 7 and subtract from cash-4 and check if it is divisible by 4
      for (let i=7, lim=cash-4; i<=lim; i+=7) {
        if ((lim-i)%4 === 0) {
          valid = true;
          break;
        }
      }
    }
  }

  console.log(valid ? 'Yes' : 'No');
};

process(rawInput);

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;

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

    int n,l[15];
    cin>>n;

    int maxv=0,sum=0;
    rep(i,n){
	cin>>l[i];
	maxv=max(maxv,l[i]);
	sum+=l[i];    
    }

    if(sum-maxv>maxv){
	cout<<"Yes"<<'\n';
    }
    else{
	cout<<"No"<<'\n';
    }
    return 0;
}


Measured memory_bytes: 256
N,M = map(int, raw_input().split())
YP = [None]*M
for i in range(M):
  P, Y = map(int, raw_input().split())
  YP[i] = (Y,P,i)
YP.sort()
C = [0]*(N+1)
code = [""]*M
for j in range(M):
  Y,P,i = YP[j]
  C[P] += 1
  code[i] = "%06d%06d"%(P, C[P])
for c in code:
  print c


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

int main(){
	int a,b;
	char op;
	while(cin>>a>>op>>b){
	if(op=='+'){
		cout<<a+b<<endl;
	}else if(op=='-'){
		cout<<a-b<<endl;
	}else if(op=='*'){
		cout<<a*b<<endl;
	}else if(op=='/'){
		cout<<a/b<<endl;
	}
}
		return 0;
}	


Measured memory_bytes: 3116
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;

void solve(){
    vi v(5);
    for(int i = 0; i < 5; i++) cin>>v[i];
    int ans=INF;
    for(int i = 0; i < 5; i++){
        int sum=0;
        for(int j = 0; j < 5; j++){
            if(j!=i){
                if(v[j]%10>0) {
                    sum+=v[j]+10-v[j]%10;
                    //cout<<v[j]+10-v[j]%10<<" ";
                }
                else{
                    sum+=v[j];
                    //cout<<v[j]<<" ";
                } 
            }
            else{
                sum+=v[j];
                //cout<<v[j]<<" ";
            }
        }
        //cout<<sum<<endl;
        ans=min(ans,sum);
    }
    cout<<ans;
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

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

int main() {
  int64_t l,r,ans=2018;
  cin >> l >> r;
  if(r-r%2019>=l) ans=0;
  else if(r-r%3>=l && r-r%673>=l) ans=0;
  else{
  	for(int64_t i=l;i<r;i++){
  		for(int64_t j=i+1;j<=r;j++){
  			ans=min(ans,(i*j)%2019);
  		}
  	}
  }
  cout << ans << endl; 
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a, b, c, k;
	int x;
	scanf("%d%d%d", &a, &b, &c);
	scanf("%d", &k);
	x = 0;
	if (a < b) {
		x = 1;
	}
	if (a < c) {
		if (b < c) {
			x = 2;
		}
	}
	for (int i = 0; i < k; i++) {
		switch (x){
		case 0:
			a = a * 2;
			break;
		case 1:
			b = b * 2;
			break;
		case 2:
			c = c * 2;
			break;
		}
	}
	printf("%d", a + b + c);
	return 0;
}

Measured memory_bytes: 128
#include <tuple>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
using ll	= long long;
using ull	= unsigned long long;
using ld	= long double;
using pii	= pair<int,int>;
using pll	= pair<ll,ll>;
using vi	= vector<int>;
using vb	= vector<bool>;
using vc	= vector<char>;
using vvi	= vector<vi>;
using vvb	= vector<vb>;
using vpii	= vector<pii>;
using vpll	= vector<pll>;
using vll	= vector<ll>;
using vull	= vector<ull>;
#define ever (;;)
#define f first
#define s second
#define pb emplace_back
#define sz size()
#define graph vector<vertex>
#define deg(X) (int)G[X].e.size()
#define INF 1234567890
#define INFll 2000000000000000000
#define maxe(X, Y) if((Y) > (X)) (X) = (Y)
#define mine(X, Y) if((Y) < (X)) (X) = (Y)
#define rep(i, begin, end) for(__typeof(end) i = (begin); i < (end); ++i)
#define repr(i, begin, end) for(__typeof(end) i = (begin)-1; i >= (end); --i)
#define bend(X) X.begin(), X.end()
pii operator+(const pii& A, const pii& B) { return {A.f+B.f, A.s+B.s}; }
pii operator-(const pii& A, const pii& B) { return {A.f-B.f, A.s-B.s}; }
pii operator-(const pii& A) { return {-A.f, -A.s}; }

//
// END OF DEFINES
//

int n;
vi T[3];
vi DP[3];

bool in() {
	scanf("%d", &n);
	rep(k, 0, 3) {
		T[k].resize(n+1);
		DP[k].resize(n+1);
	}
	rep(i, 1, n+1)
		scanf("%d %d %d", &T[0][i], &T[1][i], &T[2][i]);
	
	return true;
}

ll solve() {
	rep(i, 1, n+1)
		rep(k, 0, 3)
			rep(l, 0, 3)
				if(k != l)
					maxe(DP[k][i], DP[l][i-1]+T[k][i]);
	
	return max({DP[0][n], DP[1][n], DP[2][n]});
	
	return -INF;
}

int main() {
	int noOfTests = 1;
	//scanf("%d", &noOfTests);
	
	while(noOfTests --> 0) {
		if(!in()) {
			printf("popsute wejscie\n");
			continue;
		}
		ll result = solve();
		if(result == ll(-'t'))
			printf("TAK\n");
		else if(result == ll(-'n'))
			printf("NIE\n");
		else if(result != -INF)
			printf("%lld\n", result);
	}
	
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(){
  int ps[3];
  int i,j,s,m;
  scanf("%d %d %d",&ps[0],&ps[1],&ps[2]);
  s=ps[0];
  if(ps[1]>=s)s=ps[1];
  if(ps[2]>=s)s=ps[2];
  m=ps[0]+ps[1]+ps[2]-s;
  printf("%d\n",m);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  vll A(5);
  rep(i, 5) {
    cin >> A[i];
  }

  ll m = INF;
  rep(i, 5) {
    if (A[i] % 10 == 0) {
      continue;
    }
    if (m > A[i] % 10) {
      m = A[i] % 10;
    }
  }

  ll ans = 0;
  rep(i, 5) {
    if (m == A[i] % 10) {
      m = INF;
    } else {
      if (A[i] % 10 != 0) {
        A[i] += 10 - A[i] % 10;
      }
    }
    ans += A[i];
  }
  COUT(ans);

  return 0;
}

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

const int maxn = 1e5 + 5;
int n, k;
int a[maxn];
int f[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),	cout.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	memset(f, 2e5, sizeof(f));
	f[0] = f[1] = 0, f[2] = abs(a[2] - a[1]);
	for(int i = 3; i <= n; ++i){
		for(int j = 1; j <= k; ++j){
			if(j >= i) break;
			f[i] = min(f[i], f[i-j] + abs(a[i]-a[i-j]));
		}
	}
	cout << f[n];
}

Measured memory_bytes: 4348
def chmin(a, b)
  a > b ? b : a
end
s = gets.chomp

t = s.length
cnt1 = 0
cnt0 = 0
(0..t - 1).each do |i|
    s[i] == '0' ? cnt0 += 1 : cnt1 += 1
end

k = chmin(cnt0,cnt1)

puts k * 2



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


int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<char>a(n/2),b(n/2);
  if(n%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  rep(i,n/2) a.at(i) = s.at(i);
  for(int i = n/2;i<n;i++){
    b.at(i-n/2) = s.at(i);
  }
  rep(i,n/2){
    if(a.at(i) != b.at(i)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new FastScanner(System.in)
  val h, w, m = sc.nextInt()
  val hw = Array.fill(m)((sc.nextInt()-1, sc.nextInt()-1))
  var bombs = hw.map{case (i, j) => i.toLong * w + j}.sorted
  val hb = Array.fill(h)(0)
  val wb = Array.fill(w)(0)
  for ((h, w) <- hw) {
    hb(h) += 1
    wb(w) += 1
  }

  def binSearch(begin: Int, end: Int, k: Long): Int = {
    if (end - begin <= 1) {
      begin
    } else {
      val m = begin + (end - begin) / 2
      if (bombs(m) <= k) binSearch(m, end, k) else binSearch(begin, m, k)
    }
  }

  val hMax = hb.max
  val wMax = wb.max

  var hMaxIndices = List[Int]()
  var wMaxIndices = List[Int]()
  for (i <- 0 until h if hb(i) == hMax) {
    hMaxIndices ::= i
  }
  for (j <- 0 until w if wb(j) == wMax) {
    wMaxIndices ::= j
  }
  if (hMaxIndices.length.toLong * wMaxIndices.length > m) {
    println(hb.max + wb.max)
  } else {
    var found = false
    for {
      hi <- hMaxIndices
      wi <- wMaxIndices
      if !found
    } {
      if (bombs(binSearch(0, m, hi.toLong * w + wi)) != hi.toLong * w + wi) {
        found = true
      }
    }
    println(if (found) hb.max + wb.max else hb.max + wb.max - 1)
  }
}

class FastScanner(source: java.io.InputStream) {
  val buf = new Array[Byte](1024)
  var now, end = 0

  def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126
  def isNum(b: Byte): Boolean = 48 <= b && b <= 57

  def hasNextByte: Boolean = {
    if (now < end) {
      true
    } else {
      now = 0
      end = source.read(buf)
      end > 0
    }
  }

  def nextByte(): Byte = {
    if (hasNextByte) {
      val b = buf(now)
      now += 1
      b
    } else {
      -1
    }
  }

  def hasNext: Boolean = {
    while (hasNextByte && !isPrintable(buf(now))) {
      now += 1
    }
    hasNextByte
  }

  def next(): String = {
    if (hasNext) {
      val sb = new StringBuilder()
      var b = nextByte()
      while (isPrintable(b)) {
        sb += b.toChar
        b = nextByte()
      }
      sb.toString
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextInt(): Int = {
    nextLong().toInt
  }

  def nextLong(): Long = {
    if (hasNext) {
      var b = nextByte()
      var sign = 1
      var n = 0L
      if (b == '-') {
        sign = -1
        b = nextByte()
      }
      while (isNum(b)) {
        n = n * 10 + (b - 48)
        b = nextByte()
      }
      sign * n
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 122468
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

s = 0
for i in range(1, N + 2):
    s += abs(A[i] - A[i - 1])

for i in range(1, N + 1):
    print(s - abs(A[i+1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1]))


Measured memory_bytes: 14048
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i];
  // b[i] = a[i] + a[2 i] + a[3 i] + ...
  vector<int> ans;
  vector<int> b(n + 1);

  for(int i = n; i >= 1; i--) {
    int t = 0;
    for(int j = i + i; j <= n; j += i) {
      t ^= b[j];
    }
    if(a[i] != t) {
      b[i] = 1;
      ans.emplace_back(i);
    }
  }

  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++) cout << ans[i] << " \n"[i + 1 == ans.size()];
  return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	string n;
	cin >> n;
	if (n[0]==n[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <cstdio>
#include <numeric>
#include <climits>
#include <cstring>
#include <map>
#include <utility>
#include <tuple>
#include <set>

using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl
bool possible(ll x, ll sum) {
    return x*(x + 1) / 2 >= sum;
}

void solve(ll n) {
    ll lb = 0, ub = n;
    while (lb + 1 < ub) {
        ll m = (lb + ub) / 2;
        if (possible(m, n)) {
            ub = m;
        } else {
            lb = m;
        }
    }
    int rem = n;
    int x = ub;
    while (rem) {
        int sub = min(rem, x);
        cout << sub << endl;
        rem -= sub;
        x = sub - 1;
    }
}

signed main() {
    ll n;
    while (cin >> n) {
        solve(n);

    }
    //for (int i = 1; i < 1000; i++) {
    //    solve(i);
    //}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){
    if(a>b) {
        a = b;
        return true;
    }
    return false;

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

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

/*
 *
 * */

int main() {
//    int N;
//    cin >> N;
//
//    double res = N * 2 * 3.14159265;
//    cout << res << endl;

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

    int count[N];rep(i,N) count[i] = 0;
    for (int i = 1; i < N; ++i) {
        count[A[i]-1]++;
    }

    rep(i,N){
        cout << count[i] << endl;
    }
}

Measured memory_bytes: 5184
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007;




void main() {
    int a, b;
    scan(a, b);

    if ((a + b) % 2) {
        writeln("IMPOSSIBLE");
        return;
    }

    int ans = (a + b) / 2;

    writeln(ans);
}


















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<c){
        if(c < b){
            cout << "Yes";
        }
        else{
            cout << "No";
        }
    }
    else{
        if(b<c){
            cout << "Yes";
        }
        else{
            cout << "No";
        }
    }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int k,a,b;
  cin>>k;
  cin>>a>>b;int c=0;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {c++;
    break;
    }
    
  }
  if(c==0)
    cout<<"NG";
  else cout<<"OK";
  return 0;
}

Measured memory_bytes: 3132
def main():
    n = int(input())
    s_dict = dict()

    for _ in range(n):
        s = input()
        if s in s_dict:
            s_dict[s] += 1
        else:
            s_dict[s] = 1

    max_appear = max(s_dict.values())
    lst = []

    for key, value in s_dict.items():
        if value == max_appear:
            lst.append(key)

    lst.sort()

    for s in lst:
        print(s)


if __name__ == "__main__":
    main()


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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N; vector<int> A, B;
vector<int> sA, sB;
void input() {
	cin >> N;
	int all = 0;
	all = 0;
	REP(i, N) {
		int x; scanf("%d", &x);
		all ^= x;
		A.push_back(x);
	}
	A.push_back(all);

	all = 0;
	REP(i, N) {
		int x; scanf("%d", &x);
		all ^= x;
		B.push_back(x);
	}
	B.push_back(all);

	N++;
	sA = A; sB = B;
	sort(ALL(sA)); sort(ALL(sB));
}

const int MAX_N = 1e5 + 100;
vector<int> Ed[MAX_N];
int main() {
	input();

	bool isSame = true;
	REP(i, N) if(sA[i] != sB[i]) isSame = false;
	if(!isSame) {
		puts("-1");
		return 0;
	}
	sA.erase(unique(ALL(sA)), sA.end());
	
	int diff = 0, comp = 0;
	REP(i, N) {
		A[i] = lower_bound(ALL(sA), A[i]) - sA.begin();
		B[i] = lower_bound(ALL(sA), B[i]) - sA.begin();
		if(A[i] != B[i]) {
			Ed[A[i]].push_back(B[i]);
			diff++;
		}
	}
	if(diff == 0) {
		printf("0\n");
		return 0;
	}

	if(A[N-1] == B[N-1]) comp++;
	if(A[N-1] == B[N-1] && Ed[A[N-1]].size() == 0) comp++;

	int sN = SZ(sA);
	vector<bool> vis(sN, false);
	queue<int> Q;
	for(int i=0; i<sN; i++) {
		if(vis[i] == true) continue;
		if(Ed[i].size() == 0) continue;
		Q.push(i); vis[i] = true;
		while(!Q.empty()) {
			int v = Q.front(); Q.pop();
			for(int w : Ed[v]) if(vis[w] == false) {
				vis[w] = true;
				Q.push(w);
			}
		}
		comp++;
	}
//	printf("%d %d\n", diff, comp);
	printf("%d\n", diff-1 + comp-1);
	return 0;
}

Measured memory_bytes: 7288
from collections import Counter

n = int(input())
A = list(map(int,input().split()))
A = Counter(A).most_common()
ans = 0

for i,j in sorted(A,reverse=True):
  if j >=4 and ans ==0:
    ans = i*i
    break
  elif j >= 2 and ans == 0:
    ans = i
  elif j >= 2:
    ans *= i
    break
print(ans)

Measured memory_bytes: 21540
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

struct UnionFind{
  vector<int> d;
  UnionFind(int n) : d(n, -1){}
  int find(int x){
    if(d.at(x) < 0) return x;
    return d.at(x) = find(d.at(x));
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d.at(x) > d.at(y)) swap(x, y);
    d.at(x) += d.at(y);
    d.at(y)= x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d.at(find(x)); }
};

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uff(n);
  vector<int> ans(n, 0);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    uff.unite(a, b);
    ans.at(a)--; ans.at(b)--;
  }
  vector<set<int>> vsb(n);
  rep(i, k){
    int c, d;
    cin >> c >> d;
    c--; d--;
    vsb.at(c).insert(d);
    vsb.at(d).insert(c);
  }

  rep(i, n){
    if(i != 0) cout << " ";
    ans.at(i) += uff.size(i) - 1;
    for(auto j : vsb.at(i)){
      if(uff.same(i, j) == true) ans.at(i)--;
    }
    cout << ans.at(i);
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 15616
use proconio::input;

fn main() {
  let _a : [i128;7] = [1,3,5,7,8,10,12] ;
  let _b : [i128;4] = [4 , 6, 9  , 11];
  let _c : [i128;1] = [ 2 ];
 
let mut _x : i128 ;
let mut _y : i128 ;

    input! {
     
      mut x : i128,
      mut y : i128,

    }
if _a.contains(&x)&&_a.contains(&y){
  println!("Yes");

}else if _b.contains(&x)&&_b.contains(&y){
  println!("Yes");

}else if _c.contains(&x)&&_c.contains(&y){
println!("Yes");
}else {
  println!("No");
}

}


Measured memory_bytes: 2192
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();

	out((int)ceil(N/2.0));
	return 0;
}


Measured memory_bytes: 256
N = int(input())
alphas = [ chr(i) for i in range(ord("a"), ord("z")+1)]

res = ""
while N != 0:
  ch = N % 26
  if ch==0:
    res += alphas[-1]
    N = N//26
    N -= 1
  else:
    res += alphas[ch-1]
    N = N//26

print(res[::-1])

Measured memory_bytes: 61772
#include<iostream>

using namespace std;

int main()
{
	long n, answer,a[100000], inpu;
	
	cin >> n;
	
	int counter = 0;
	
	answer = 0;
	
	for (long x = 0; x<n ; x++)
	{
		cin >> inpu;
		
		if (inpu < 0)
		{
			counter++;
			a[x] = inpu*-1;
		}
		else a[x] = inpu;
		answer += a[x];
	}
	
	if (counter%2 == 1)
	{
		long lowest = 1000000000;
		for (long x = 0; x<n ; x++)
		{
			if (a[x] < lowest) //lowest == a[x]; (FATAL MISTAKE)
			lowest = a[x];
		}
		answer -= lowest*2;
	}
	
	cout << answer;
	
}


Measured memory_bytes: 1024
n = int(input())
a = 0
w = 0
t = 0
r = 0
i = 1
while i <= n:
  s_i = input()
  if s_i == "AC":
    a += 1
  elif s_i == "WA":
    w += 1
  elif s_i == "TLE":
    t += 1
  else:
    r += 1
  i += 1
print("AC x "+str(a))
print("WA x "+str(w))
print("TLE x "+str(t))
print("RE x "+str(r))

Measured memory_bytes: 9220
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int n,m,X,Y;
int main(){
    cin >> n >> m >> X >> Y;
    int x[n],y[m];
    int x_right=X;
    int y_left=Y;
    for(int i=0; i<n; i++){
        cin >> x[i];
        if(x[i]>x_right){
            x_right=x[i];
        }
    }
    for(int i=0; i<m; i++){
        cin >> y[i];
        if(y[i]<y_left){
            y_left=y[i];
        }
    }
    if(x_right>=y_left){
        cout << "War" << endl;
    }else{
        cout << "No War" << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>

int Board[100][100] = {};
int dx[8] = {1, 2, 1, 2, -1, -2, -1, -2}, dy[8] = {2, 1, -2, -1, -2, -1, 2, 1};

int main() {
	string w; cin >> w;
	int check_num[26] = {};
	for(int i = 0; i < w.length(); i++) {
		check_num[ w[i] - 'a']++;
	}
	for(int i = 0; i < 26; i++) {
		if(check_num[i] % 2 == 1) { cout << "No" <<endl; return 0;}
	}
	cout << "Yes" <<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np

N = int(readline())
info = []
for i in range(N):
    A = int(readline())
    for _ in range(A):
        x,y = map(int,readline().split())
        info.append((i,x-1,y))
        
A = np.array(list(itertools.product([0,1],repeat=N)),np.bool)
for i,x,y in info:
    bl = (~A[:,i]) | (A[:,x] == bool(y))
    A = A[bl]

answer = A.sum(axis = 1).max()
print(answer)


Measured memory_bytes: 27084
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector> 
 
using namespace std;
 
int main() {
	int n, x, y;
	cin >> n;
	x = 800 * n;
	y = 200 * (n / 15);
	cout << x - y << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;

int check(const int n, const int k, int* w, int p)
{
    int index = 0;
    for(int i=0; i<k; i++){
        long long int sum = 0;
        //cout << "  -> k" << i+1 << ": ";
        while(1){
            if(sum+w[index] > p){
                break;
            }
            sum += w[index];
            //cout << w[index] << " ";
            index++;
            if(index >= n){
                //cout << "*" << endl;
                return index;
            }
        }
        //cout << endl;
    }
    return index;
}
int main()
{
    int n,k;
    cin >> n >> k;
    int w[100000];
    int sum = 0;
    for(int i=0; i<n; i++){
        cin >> w[i];
        sum += w[i];
    }

    int left = 0;
    //int right = 100000 * 10000;
    int right = sum;
    int mid;
    while(left < right){
        mid = (left+right)/2;
        //cout << "mid:" << mid << endl;
        int ret = check(n, k, w, mid);
        if(ret >= n){  // 分配できた
            right = mid;
        }else{         // 分配できなかった
            left = mid + 1;
        }
    }
    cout << right << endl; // 最後に分配できた値を出力
}


Measured memory_bytes: 3476
ans=0
s=input()
length=len(s)
if len(s)%2==0:
    for i in range(int(length/2)):
        if s[i]!=s[-1-i]:
            ans+=1
else:
    for i in range(int((length-1)/2)):
        if s[i]!=s[-1-i]:
            ans+=1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;
const double PI = acos(-1);

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long gcd(long long a, long long b) {
  if(a % b == 0) return b;
  else return gcd(b, a % b);
}

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long left;
  if(n % (a + b) > a) left = a;
  else left = n % (a + b);
  cout << n / (a + b) * a + left << endl;
}


Measured memory_bytes: 256
main = do
  s <- getLine
  let q = read s :: Double 
  if (q /= -1) then func (q / 2) q else return ()
  if (q == -1) then return () else main

func m n = do
  if (abs (m*m*m - n)) < (0.00001 * n)
    then putStrLn (show m)
    else let nex = m - (m*m*m - n) / (3*m*m) in
      func nex n

Measured memory_bytes: 4244
import sys
import math
import bisect
from collections import defaultdict, deque
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    n = I()
    print(n // 2 - 1 if n % 2 == 0 else n // 2)
    return


# B
def B():
    n = I()
    d = LI()
    if d[0] != 0:
        print(0)
        return
    d.sort()
    if d[1] == 0:
        print(0)
        return
    cnt = []
    prenum = 1
    for i in range(1, max(d) + 1):
        num = bisect.bisect_right(d, i)
        if num - prenum == 0:
            print(0)
            return
        else:
            cnt.append(num - prenum)
            prenum = num
    ans = 1
    for i in range(1, max(d)):
        ans *= cnt[i - 1] ** cnt[i]
    print(ans % 998244353)
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 55900