akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define ll long long 
#define il inline
int n,m,k,tot;
int mp[10][10]; char ch;
int vis[10][10];
int ans;
void check(int s1,int s2){
    memset(vis,0,sizeof(vis));
    int res=0;
    for (int i=1;i<=n;++i){
        if (s1&(1<<(i-1))){
            for (int j=1;j<=m;++j){
                if (!vis[i][j]&&mp[i][j]==1){
                    vis[i][j]=1; ++res;
                }
            }
        }
    }
    for (int i=1;i<=m;++i){
        if (s2&(1<<(i-1))){
            for (int j=1;j<=n;++j){
                if (!vis[j][i]&&mp[j][i]==1){
                    vis[j][i]=1; ++res;
                }
            }
        }
    }
    if (tot-res==k){
        ++ans;
        //cout<<s1<<" "<<s2<<endl;
    }
}
int main(){
    scanf("%d%d%d",&n,&m,&k);
    for (int i=1;i<=n;++i){
        for (int j=1;j<=m;++j){
            ch=getchar(); while (ch!='.'&&ch!='#') ch=getchar();
            if (ch=='.'){
                mp[i][j]=0;
            }else{
                mp[i][j]=1; ++tot;
            }  
        }
    }
    for (int i=0;i<(1<<n);++i){
        for (int j=0;j<(1<<m);++j){
            check(i,j);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
int main(void){
    int a,b,d,r;
    scanf("%d %d",&a,&b);
    d = a / b;
    r = a % b;
    double f,A,B;
    A = a;
    B = b;
    f = A / B;
    printf("%d %d %lf",d,r,f);
    
    return 0;
}


Measured memory_bytes: 2144
# coding: utf-8
# Your code here!

num = int(input())

qm = 1000000000000001

alf = [chr(i) for i in range(97, 97+26)]
#print(alf)

ans = []
f = False

for i in range(12):
    c = (num-1) % 26
    ans += alf[c]
    num = (num-1) // 26
    if num < 1:
        break

print("".join(reversed(ans)))

Measured memory_bytes: 9084
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
X=many_int()

X_min=min(X)
X_max=max(X)

ans=0
mins=10**8
for i in range(X_min, X_max+1):
    now_min=0
    for x in X:
        now_min += (x-i)**2
    
    if now_min < mins:
        mins = now_min
        ans = i

print(mins)

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv( maxN+5, 1 );
vcL fac( maxN+5, 1 );

void ADD(lli &x, lli y) {
	x += y;
	if ( x >= mod ) x -= mod;
	if ( x < 0 ) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = ( x%mod + mod ) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if ( e&1 ) MUL( ans, b );
		MUL( b, b );
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow( n, mod-2 );
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod-mod/i) * inv[ mod%i ] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[ i-1 ] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if ( a < b ) return 0;

	MUL( ans, inv[ fac[ a-b ] ] );
	MUL( ans, inv[ fac[b] ] );
	MUL( ans, fac[a] );

	return ans;
}

lli Lucas(lli n, lli m) {
	if ( m == 0 ) return 1;
	return cm( n%mod, m%mod ) * Lucas( n/mod, m/mod ) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas( n, m );
}

/// coding area ///

lli lcm(lli a, lli b) {
	return a*b/__gcd( a, b );
}

lli getAns(lli big, lli s1, lli s2) {
	return big - ( big/s1 + big/s2 - big/lcm( s1, s2 ) );
}

void precal() {

	return;
}

void solve() {
	lli a, b, c, d, ans = 0, cnt = 0;
	string s;
	cin >> a >> b >> c >> d;
	
	ans = getAns( b, c, d ) - getAns( a-1, c, d );
	
	cout << ans << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}




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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, D; cin >> N >> D;
  two_sat ts(N);
  vector<int> X(N), Y(N);
  REP(i, N){
    cin >> X[i] >> Y[i];
  }
  REP(i, N-1){
    for(int j = i+1; j < N; j++){
      if(abs(X[i]-X[j]) < D) ts.add_clause(i, false, j, false);
      if(abs(X[i]-Y[j]) < D) ts.add_clause(i, false, j, true);
      if(abs(Y[i]-X[j]) < D) ts.add_clause(i, true, j, false);
      if(abs(Y[i]-Y[j]) < D) ts.add_clause(i, true, j, true);
    }
  }
  if(ts.satisfiable()){
    cout << "Yes" << endl;
    vector<bool> ans = ts.answer();
    REP(i, N){
      if(ans[i]){
        cout << X[i] << endl;
      }else{
        cout << Y[i] << endl;
      }
    }
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3800
N = int(input())
A = list(map(int, input().split()))

ans = 0
isnext = 0
# 初期化
array = [0] * N


while isnext == 0:
        array = A
        for i in range(N):
                if(array[i] % 2 == 0 and isnext == 0):
                        array[i] = int(array[i] / 2)                        
                else:
                        isnext = 1
        if isnext == 0:
                ans = ans + 1


print(ans)

Measured memory_bytes: 3064
gets;gets;x=!p,!0;x.map{|a|x.map{|b|c,d,*k=a,b;$_.chop.chars{|i|d^=c^=i<?p;k<<c^=d};c^a||d^b||k.map{|x|$>.<<x ??S:?W}&&exit}};p~0

Measured memory_bytes: 6388
# -*- coding: utf-8 -*-
from heapq import heapify, heappop, heappush
from random import randint
from collections import defaultdict
from itertools import accumulate
from fractions import gcd
from collections import defaultdict
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7

def primes(N):
    sieve = [1]*(N+1)
    sieve[:2] = [0, 0]
    P = []
    for i in range(2, N+1):
        if sieve[i]:
            P.append(i)
            for j in range(2*i, N+1, i):
                sieve[j] = 0
    return P

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m


P = primes(10**3)

size = 10**6 + 1
g1, g2, inverse = [0]*size, [0]*size, [0]*size
 
g1[:2] = [1, 1] # 元テーブル
g2[:2] = [1, 1] #逆元テーブル
inverse[:2] = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, size):
    inverse[i] = (-inverse[MOD % i] * (MOD//i) ) % MOD 

N = int(input())
A = inpl()

#N = 10**4
#A = [randint(0, 10**6) for _ in range(10**4)]
D = defaultdict(int)
for a in A:
    for p in P:
        tmp = 0
        while a%p == 0:
            tmp += 1
            a //= p
        if tmp:
            D[p] = max(D[p], tmp)
        if a == 1:
            break
    if a != 1:
        D[a] = 1

lmc = 1
for k, v in D.items():
    lmc = lmc * pow(k, v, MOD)%MOD

ans = 0
for a in A:
    ans = (ans + lmc*inverse[a])%MOD
print(ans)


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

int a[100];
int n;
int check();

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int flag1=0;
	int flag=0;
	if(check()){
		flag1=1;printf("YES\n");
	}else{
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				swap(a[i],a[j]);
				if(check()){
					flag=1;break;
				}else{
					swap(a[i],a[j]);
				}
			}
		}
		if(flag==1) printf("YES\n");
		else printf("NO\n");
	}
	
}

int check(){
	int b[100];
	for(int i=0;i<n;i++){
		b[i]=a[i];
	}
	sort(b,b+n);
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]) return 0;
	}
	return 1;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(max(a,c)-min(a,c)<=d||max(a,b)-min(a,b)<=d&&max(b,c)-min(b,c)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    bool is=false;

    int X,p,q,r,s,t;
    int Xa,Xb,Xc,Xd;
    cin >>X;
    p=X/105+1;
    rep(i,p){
        Xa=X-105*i;
        q=Xa/104+1;
        rep(j,q){
            Xb=Xa-104*j;
            r=Xb/103+1;
            rep(k,r){
                Xc=Xb-103*k;
                s=Xc/102+1;
                rep(l,s){
                    Xd=Xc-102*l;
                    if((Xd%100)*101<=Xd){
                        is=true;
                        //printf("%d %d %d %d |%d %d %d %d\n",l,k,j,i,Xa,Xb,Xc,Xd);
                        goto T;
                    }
                }
            }
        }
    }
T:
    cout << ((is) ? "1" : "0") <<endl;
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int sum(int start, int end, vector<int> vec, int skip = -1) {
	int ret = 0;
	for (int i = start; i < end; ++i) {
		if (i == skip) continue;
		ret += vec.at(i);
	}
	return ret;
}

int main(){
	int n;
	int l;

	cin >> n;
  cin >> l;

	vector<int> aji(n);

	size_t min_abs_index = 9999;
	int min_abs = 9999;
	for (int i = 0; i < n; ++i) {
		aji.at(i) = l + i;
		if (abs(l+i) < min_abs) {
			min_abs = abs(l+i);
			min_abs_index = i;
		}
	}
	
	int ret;

	ret = sum(0, n, aji, min_abs_index);

	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

struct SuffixArray{
    int N;
    vector<int> sa,rank;
    vector<int> ary;//int
    string str;//string

    SuffixArray(){}

    void build(vector<int> &S){
        int k;//重要

        N=S.size();
        sa.resize(N+1,0);
        rank.resize(N+1,0);
        for(int i=0;i<=N;i++){
            sa[i]=i;
            rank[i]=(i<N ? S[i] : -1);
        }

        auto cmp = [&](int i,int j){
            if(rank[i]!=rank[j]) return rank[i]<rank[j];
            int ri=(i+k<=N ? rank[i+k] : -1);
            int rj=(j+k<=N ? rank[j+k] : -1);
            return ri<rj;
        };

        vector<int> tmp(N+1,0);
        for(k=1;k<=N;k*=2){
            sort(sa.begin(),sa.end(),cmp);

            tmp[sa[0]]=0;
            for(int i=1;i<=N;i++){
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp(sa[i-1],sa[i]) ? 1 : 0);
            }
            rank=tmp;
        }

        //空文字を削除
        sa.erase(sa.begin());
        rank.pop_back();
        for(int i=0;i<rank.size();++i) --rank[i];
    }

    void initialize(vector<int> &A){
        ary=A;
        build(A);
    }

    void initialize(string &S){
        str=S;
        vector<int> A;
        for(int i=0;i<S.size();++i) A.push_back(S[i]);
        ary=A;
        build(A);
    }

    vector<int> lcp_array(vector<int> S,vector<int> sa){
        int N=S.size();
        vector<int> trans(N,0);
        for(int i=0;i<N;++i) trans[sa[i]]=i;

        vector<int> lcp(N-1,0);
        int prelen=0;
        for(int i=0;i+1<N;++i){
            prelen=max(0,prelen-1);
            int now=trans[i];
            if(now==N-1){
                prelen=0;
                continue;
            }

            int len=prelen;
            int tar=sa[now+1];
            while(i+len<N&&tar+len<N){
                if(S[i+len]!=S[tar+len]) break;
                ++len;
            }
            lcp[now]=len;
            prelen=len;
        }
        return lcp;
    }

    int operator[](int i)const{
        return sa[i];
    }
};

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

  string S;
  cin>>S;
  ll N=S.size();

  SuffixArray SA;
  SA.initialize(S);
  vector<int> sa=SA.sa;

  ll ans=N*(N+1)/2;
  vector<int> lcp=SA.lcp_array(SA.ary,sa);
  for(auto x:lcp){
      ans-=x;
  }
  cout<<ans-1<<"\n";

  return 0;
}


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

int main(){
  int N;
  cin>>N;
  
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  
  sort(a.begin(),a.end());
  cout<<a.at(N-1)-a.at(0)<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){


  int N=0;
  int X=0;
  int T=0;
  int x=0;
  int t=0;
  int i=1;

  cin>>N>>X>>T;


  while(N>x){
    x=X*i;
    t=T*i;
    ++i;
  }

  cout<<t<<endl;



  return 0;

}


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

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

lli gcd(lli a, lli b)
 {
   return b==0 ? a : gcd(b, a%b) ;
 }


int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    lli n, ans, x ;
    cin>> n ;
    vlli T(n) ;
    for(int i=0 ; i<n ; i++)
      cin>> T[i] ;
    sort(all(T)) ;
    reverse(all(T)) ;
    ans=T[0] ;
    if(ans==1e18)
      {
        cout<< ans ;
        return 0 ;
      }
    for(int i=1 ; i<n ; i++)
      {
        x=((T[i])/(gcd(T[i], ans))) ;
        ans=ans*x ;
      }
    cout<< ans ;
  }


Measured memory_bytes: 256
a = int(input())
three = int(a/3)
def tot(s, t):
    if t % 2 == 0:
        return s*(1 + t)*(t/2)
    elif t == 1:
        return s
    else:
        return s*(1 + t)*int(t/2) +s*(t+1)/2
three = int(a/3)
five = int(a/5)
one_five = int(a/15)
ans = tot(1, a) - tot(3, three) - tot(5, five) + tot(15, one_five)
print(int(ans))

Measured memory_bytes: 9232
#include <iostream>

using namespace std;

int main() {
    char a, b;
    cin >> a >> b;
    
    if(a=='H') {
        cout << b << endl;
    } else {
        if(b=='H') {
            cout << 'D' << endl;
        } else {
            cout << 'H' << endl;
        }
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  int L[15];
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L, L+N);
  if (accumulate(L, L+N-1, 0) > L[N-1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//________
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> Pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
inline int updiv(int a, int b){return((a+b-1) / b);}
const int INF = 1 << 29;
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define Size 1000011
#define NIL -1
//________



signed main()
{
    FAST();
    int N, A, B;
    int ans = 0;
    cin >> N >> A >> B;

    reps(i, 1, N){
        int tmp = i;
        int sum = 0;
        while(tmp != 0){
            sum += tmp % 10;
            tmp /= 10;
        }
        if(sum >= A && sum <= B)
            ans += i;
    }
    outl( ans );
}



Measured memory_bytes: 256
N = int(input())
P = [int(i) for i in input().split()]

ind = [0]*(N+1)
for i in range(N):
    ind[P[i]] = i+1

ans = 0
l = [0] + [f for f in range(N+1)]
r = [f + 1 for f in range((N+1))] + [N+1]

for j in range(1,N+1):
    f = ind[j]

    l1 = l[f]
    l2 = l[l1]
    r1 = r[f]
    r2 = r[r1]
    ans += ((l1-l2)*(r1-f) + (f-l1)*(r2-r1))*j

    l[r1] = l1
    r[l1] = r1

print(ans)

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

int main(){
    int s;
    int a;
    a = 0;
    
    cin >> s;

    if(s % 10 == 1){
        a = a + 1;
    }
    if((s / 10) % 10 == 1){
        a = a + 1;
    }
    if(s / 100 == 1){
        a = a + 1;
    }

    cout << a << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    vector<int> interval(n);
    rep(i, n - 1)
    {
        interval.at(i) = a.at(i + 1) - a.at(i);
    }
    interval.at(n - 1) = a.at(0) + k - a.at(n - 1);

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

    cout << k - interval.at(n - 1) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 10000;
    rep(i, s.size()){
        if (i + t.size() - 1 >= s.size()) break;
        int cnt = 0;
        rep(j, t.size()){
            if (s[i+j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
k = gets.chomp.to_i
a, b = gets.chomp.split(" ").map{|e|e.to_i}

def check(k,a,b)
	n = k
	while n<=1000 do
		if a<=n && n<=b then return "OK" end
		n += k
	end
	return "NG"
end

print check(k,a,b)

Measured memory_bytes: 14392
S = input()
m = ["01", "02","03","04","05","06","07","08","09","10","11","12"]
if S[:2] in m and S[2:] in m:
  print("AMBIGUOUS")
elif S[:2] in m:
  print("MMYY")
elif S[2:] in m:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
#include <stdio.h>

static inline int intmax(int a, int b) {
	return (a < b) ? b : a;
}

static inline unsigned long int nonneg(int a) {
	return (a < 0) ? 0 : a;
}

int main(void) {
	int n = 0;
	scanf("%d", &n);
	int max = 0;
	unsigned long int ans = 0;
	for (int i = 0; i < n; i++) {
		int ai = 0;
		scanf("%d", &ai);
		max = intmax(max, ai);
		ans += nonneg(max - ai);
	}
	printf("%lu\n", ans);
	return 0;
}


Measured memory_bytes: 1700
while True:
    x = [int(i) for i in input().split()]
    if x[0] == 0 and x[1] == 0:
        break
    cnt_h = 0
    for h in range(x[0]):
        cnt_w = 0
        for w in range(x[1]):
            if (cnt_h + cnt_w) % 2 == 0:
                print("#",end="")
            else:
                print(".",end="")
            cnt_w += 1
        print("")
        cnt_h += 1
    print("")



Measured memory_bytes: 7024
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e17+100)
#define N 1000005



// Driver code to test above functions
int32_t main()
{
    
 
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    
    int a[3];
    for(int i=0;i<3;i++)
        cin >> a[i];
    sort(a, a+3);

    if(a[0]==a[1] and a[1]!=a[2])
        cout << "Yes";
    else if(a[0]!=a[1] and a[1]==a[2])
        cout << "Yes";
    else
        cout << "No";


    
        


    return 0;
    
} 






































































































 

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

signed main(void)
{
	int n;
	cin >> n;
	string s;
	cin >> s;

	string ans(200, ')');
	//cout << ans << endl;
	REP(i, n+1) REP(j, n+1) {
		string t = string(i, '(') + s + string(j, ')');
		//cout << t << endl;
		stack<char> st;
		bool flag = true;
		REP(k, t.size()) {
			if(t[k] == '(') st.push('(');
			else {
				if(st.size() && st.top() == '(') st.pop();
				else {
					flag = false;
					break;
				}
			}
		}
		if(st.size() != 0) flag = false;
		if(flag) {
			if(ans.size() > t.size()) ans = t;
			else if(ans.size() == t.size() && ans > t) ans = t;
		}
	}
	cout << ans << endl;

	return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d)
        cout << "Left" << endl;
    else if(a+b < c+d)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;

    return 0;
}


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

using namespace std;
#define int long long
#define N 666666
int a[N];
int b[N];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(i%2) b[1]+=a[i];
		else b[1]-=a[i];
	} 
	
	for(int i=1;i<=n;i++){
		b[i+1]=2*a[i]-b[i];
	}
	for(int i=1;i<=n;i++) cout<<b[i]<<" ";
	return 0;
}

Measured memory_bytes: 4096
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { r: i32, g: i32 }
    println!("{}", 2*g-r);
}

Measured memory_bytes: 4352
# coding: utf-8
# Your code here!
X, Y, A, B, C = map(int, input().split(" "))
ps = list(map(int, input().split(" ")))
qs = list(map(int, input().split(" ")))
rs = list(map(int, input().split(" ")))

ps = sorted(ps)
qs = sorted(qs)
rs = sorted(rs)

nx = 0
ny = 0
nc = 0
sums = 0
for i in range(X+Y):
    a = b = c = 0
    if nx < X:
        a = ps[A-1-nx]
    if ny < Y :
        b = qs[B-1-ny]
    if nc < C:
        c = rs[C-1-nc]
    
    if a >= b and a >= c:
        sums += a
        # ps.pop(a)
        nx += 1
        
    if b > a and b >= c:
        sums += b
        # qs.pop(b)
        ny += 1
        
    if c > a and c > b:
        sums += c
        # rs.pop(c)
        nc += 1
        
print(sums)

Measured memory_bytes: 23328
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int i,j;
        
        Scanner sc=new Scanner(System.in);
        
        String str;
        Character c;
        str=sc.nextLine();
        for(i=0;i<str.length();i++){
            c=str.charAt(i);
            if(Character.isUpperCase(c))System.out.printf("%c",Character.toLowerCase(c));
            else if(Character.isLowerCase(c))System.out.printf("%c",Character.toUpperCase(c));
            else System.out.printf("%c",c);
        }
        System.out.printf("\n");
    }
}



Measured memory_bytes: 29572
x, y = map(int, input().split())

d = {
 1: 0,
 3: 0,
 5: 0,
 7: 0,
 8: 0,
 10: 0,
 12: 0,
 4: 1,
 6: 1,
 9: 1,
 11: 1,
 2: 2,
}

if d[x] == d[y]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
def reconstruct preorder, inorder
  no=inorder.size-1
  root = preorder.shift
  unless root_idx = inorder.index(root)#???
    $right_preorder << root
    reconstruct(preorder,inorder)
    return
  end
  if root_idx==0
  elsif root_idx==1
    $postorder << inorder[0]
  else
    reconstruct(preorder,inorder[0...root_idx])#???
  end

  if root_idx==no
  elsif root_idx==no-1
    $postorder << inorder[-1]
  else
    reconstruct(preorder,inorder[root_idx+1..-1])#???
  end
  $postorder << root
end

gets
Pre=gets.split.map &:to_i
In=gets.split.map &:to_i
$postorder=[]
$right_preorder=[]
reconstruct(Pre,In)
puts $postorder.join " "

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   string s,t;
    cin >> s >> t;
    
    int n = s.length();
                   int m = t.length();
    
    int res = m;
    
    f(i,n-m+1)
    {
        int temp = 0;
        
        for(int j=0;j<m;j++)
            temp+=(t[j] != s[i+j]);
        
        res = min(res,temp);
    }
    
    cout << res;
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

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

int main(){
    int n,q;
    scanf("%d %d",&n,&q);
    int s,t;
    map<int,vector<int> > tree;
    for (int i=0;i<n;i++){
        tree[i] = {};
    }
    for (int i=0;i<n-1;i++){
        int s,t;
        scanf("%d %d",&s,&t);
        tree[s-1].push_back(t-1);
        tree[t-1].push_back(s-1); 
    }
    vector<ll> p_sum(n);
    int x;
    ll p;
    for (int i=0;i<q;i++){
        cin >> x >> p;
        p_sum[x-1] += p;
    }
    queue<int> qu;
    qu.push(0);
    vector<bool> checked(n,false);
    checked[0] = true;
    vector<ll> res(n,0);
    res[0] = p_sum[0];
    while(qu.size() != 0){
        s = qu.front();
        qu.pop();
        for (auto it=tree[s].begin()-tree[s].begin();it!=tree[s].end()-tree[s].begin();it++){
            t = (tree[s])[it];
            if (! checked[t]){
                qu.push(t);
                checked[t] = true;
                res[t] = res[s] + p_sum[t];
            }
        }
    }
    for (int i=0;i<n;i++){
        cout << res[i];
        if (i<n-1) cout << " ";
        else cout << endl;
    }
    return 0;
    
}

Measured memory_bytes: 28788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

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

    int a, b;
    cin >> a >> b;
    
    int count = 0;
    while(count * (a - 1) + 1 < b){
        count++;
    }
    
    cout << count << endl;

    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  ll ans = 0;
  for (int bit = 0; bit < 1 << (N - 1); bit++) {
    ll tmp = S[0] - '0';
    for (int i = 0; i < N - 1; i++) {
      if ((bit >> i) & 1) {
        ans += tmp;
        tmp = S[i + 1] - '0';
      } else {
        tmp = tmp * 10 + S[i + 1] - '0';
      }
    }
    ans += tmp;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for(int i=0; i<N; i++)
      A[i] = sc.nextInt();
    boolean hantei = true;
    
    for(int i=0; i<N; i++){
      if(A[i] % 2 == 1) continue;
      if(A[i] % 3 == 0) continue;
      if(A[i] % 5 == 0) continue;
      hantei = false;
    }
    
    if(hantei == true)
      System.out.println("APPROVED");
    else
      System.out.println("DENIED");
    
  }
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;
// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

inline int64_t in(){int64_t x=0,m=0,k;for(;;){k=getchar_unlocked();if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){k=getchar_unlocked();if(k<'0'||'9'<k)break;x=x*10+k-'0';}if(m)x=-x;return x;}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in(), k = in();
  vector<int> a(n);
  cin >> a;

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

  vector<int> b;
  for (auto i : m) {
    b.pb(i.second);
  }

  sort(all(b));

  if (b.size() <= k) {
    cout << 0 << endl;
  } else {
    int ans = 0;
    for (int i = 0; i < b.size() - k; ++i) {
      ans += b[i];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 11516
#include<stdio.h>
int main() {
  int a, b;
  while (1) {
    scanf("%d %d", &a, &b);
    if (a == 0 && b == 0) {
      break;
    } else {
      if (a < b) {
        printf("%d %d\n", a, b);
      } else {
        printf("%d %d\n", b, a);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        do {
            int h = sc.nextInt();
            int w = sc.nextInt();

            if (h == 0 && w == 0) {
                break;
            } else {
                for (int i = 0; i < h; i++) {
                    if (i == 0 || i == h-1) {

                        for (int j = 0; j < w; j++) {
                            System.out.print('#');
                        }

                    } else {
                        
                        for (int j = 0; j < w; j++) {
                            if (j==0 || j==w-1) {
                                System.out.print('#');
                                
                            } else {
                                System.out.print('.');
                            }
                            
                        }
                    }
                    System.out.println();
                }

                System.out.println();
            }

        } while (true);
    }

}

Measured memory_bytes: 35592
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		int[][] a = new int[h][w];
		for (int i = 0; i < a.length; i++) {
			Arrays.fill(a[i], -1);
		}
		for (int i = 0; i < h; i++) {
			String string = scanner.next();
			for (int j = 0; j < w; j++) {
				if (string.charAt(j) == 'c') {
					a[i][j] = 0;
					for (int k = j + 1, l = 1; k < w; k++, l++) {
						a[i][k] = l;
					}
				}
			}
		}
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.print(a[i][j]);
				if (j != a[i].length - 1) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
		scanner.close();
	}

}



Measured memory_bytes: 36460
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(string[] ss) {
    long[string] d;
    foreach (s; ss) {
        auto t = s.array;
        t.sort();
        d[t.to!string]++;
    }

    long ans = 0;
    foreach (_, v; d) {
        if (v > 1) ans += v * (v - 1) / 2;
    }
    return ans;
}

long calc2(string[] ss) {

    long hash(dchar[] cs) {
        long h = 0;
        long b = 1;
        foreach_reverse (c; cs) {
            h += b * (c - 'a') + 1;
            b *= 26;
        }
        return h;
    }

    long[long] d;
    foreach (s; ss) {
        auto t = s.array;
        t.sort();
        d[hash(t)]++;
    }

    long ans = 0;
    foreach (_, v; d) {
        if (v > 1) ans += v * (v - 1) / 2;
    }
    return ans;
}

void main() {
    int n; scan(n);
    string[] ss;
    foreach (_; 0..n) ss ~= read!string;

    // writeln(calc(ss));
    writeln(calc2(ss));
}


Measured memory_bytes: 14588
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;

int main(void){
	int i,n,now,from,to;
	char c,rst[64];

	cin>>n;
	getchar();
	while(n--){
		now = from = to = 26;
		while((c=getchar()) != '\n'){
			if(isalpha(c)) rst[now] = c;
			else{
				if((c=getchar()) == '>'){
					now++;
					if(now > to) to++;
				}
				else{
					now--;
					if(now < from) from--;
				}
			}
		}
		for(i=from;i<=to;i++) cout<<rst[i];
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(std::string S){
  if(S == "Sunny")cout << "Cloudy" << endl;
  if(S == "Cloudy")cout << "Rainy" << endl;
  if(S == "Rainy")cout << "Sunny" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x, y;
  bool operator < (const P &a )const{
    //if(x!=a.x)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e[22],dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[21][22];
int l[21];
int j[21];


long long x,y,z,mod=1000000007;
//string r;
char r[22][22];

P u[1];
priority_queue<int> q;
stack<int> s;
//set<P> s;
map<int,int> p;

vector<int> v;

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

unsigned long long mix(unsigned long long o){
    o+=0x9e3779b97f4a7c15;
    o=(o^(o>>30))*0xbf58476d1ce4e5b9;
    o=(o^(o>>27))*0x94d049bb133111eb;
    return o^(o>>31);
    //Those constants supposedly are chosen to give this function better pseudo-random properties, but on any on-site contest, when one can't have team reference document/doesn't want to waste time searching it for implementation typing arbitrary large odd numbers by hand should be good enough
}

unsigned long long salt = (chrono::steady_clock::now().time_since_epoch().count());

int f()
{
  unsigned long long l1[22],l2[22];
  int e[22],i=0;
  if(a%2) i=1;
  for(int t=1;t<=a;t++)
    l1[t]=l2[t]=0,e[t]=1;
  for(int t=1;t<=a;t++)
  {
    for(int w=1;w<=b;w++)
    {
      l1[t]^=mix(w^mix(o[t][w]^salt));
      l2[t]^=mix((b-w+1)^mix(o[t][w]^salt));
    }
  }
  for(int t=1;t<=a;t++)
  if(e[t])
  {
    for(int w=t+1;w<=a;w++)
    if(l2[w]==l1[t])
    {
      e[t]=0;
      e[w]=0;
      goto qwe;
    }
    if(i&&l1[t]==l2[t]) i=0;
    else
    {
      return 0;
    }
    qwe:;
  }
  return 1;
}



void uu(int n)
{
  if(n>b/2)
  {
    if(b%2)
    {
      for(int i=1;i<=b;i++)
        if(!e[i]) j[b/2+1]=i;
    }
    for(int t=1;t<=a;t++)
      for(int w=1;w<=b;w++)
        o[t][w]=r[t][j[w]]-'a';
    //for(int t=1;t<=b;t++)
    //printf("%d ",j[t]);
    //puts("");
    if(f())
    {
      puts("YES");
      exit(0);
    }
  }
  for(int i=j[n-1]+1;i<b;i++)
  if(!e[i])
  for(int t=i+1;t<=b;t++)
  if(!e[t])
  {
    e[i]=e[t]=1;
    j[n]=i;
    j[b-n+1]=t;
    uu(n+1);
    e[i]=e[t]=0;
  }
  
}

int main()
{
  scanf("%d %d %d %d %d",&a,&b,&c,&n,&m);
  k=2*c*(n+m);
  for(int t=0;t<=max(n,m)*2;t+=2)
  {
    k=min(k,c*t+max(0,n-t/2)*a+max(0,m-t/2)*b);
  }
  printf("%d",k);
}
//0
//13



Measured memory_bytes: 256
n = int(input())

stations = []
for i in range(n-1):
    time_to_next, first, interval = map(int, input().split())
    stations.append([time_to_next, first, interval])

for start in range(n):
    now = 0
    for pos in range(start, n):
        if pos == n-1:
            print(now)
            break

        time_to_next, first, interval = stations[pos]
        if first >= now:
            now = first + time_to_next
            continue
        else:
            num = (now-first)//interval + bool((now-first)%interval)
            now = first + interval*num + time_to_next
            continue


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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a > b){
        for (int i = 0; i < a; i++){
            cout << b;
        }
    }
    else{
        for (int i = 0; i < b;i++){
            cout << a;
        }
    }

    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  long long la,lb;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> s;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
  ans = a+b;
  if(a>=3200) anss = s;
  else anss = "red";

  cout << anss << endl;

}

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

int main(){
  
  int N, Q, i;
  long long Sum = 0;
  cin >> N;
  map<int, int> A;
  
  for(i = 0; i < N; i++){
    int a;
    cin >> a;
    A[a]++;
    Sum += a;
  }
  cin >> Q;
  
  for(i = 0; i < Q; i++){
    int b, c;
    cin >> b >> c;
    Sum  += c * A[b] - b * A[b];
    A[c] += A[b];
    A.erase(b);
    cout << Sum << endl;
  }
}

Measured memory_bytes: 6536
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
#define MAXQ 20

int N;
int bottom, upper, center;
string strb, stru, strc;

//string answer[MAXQ];

int main() {
	cin >> N;

	cout << 0 << endl;
	cin >> strb;
	if (strb == "Vacant") {
		return 0;
	}
	cout << N-1 << endl;
	cin >> stru;
	if (stru == "Vacant") {
		return 0;
	}

	bottom = 0;
	upper = N - 1;
	center = (N - 1) / 2;


	for(int i=2;i<MAXQ;i++) {
		cout << center << endl;
		cin >> strc;
		if (strc == "Vacant") {
			return 0;
		}

		if ((strc == strb && (center - bottom) % 2 == 1) ||
			(strc != strb && (center - bottom) % 2 == 0)) {
			upper = center;
			stru = strc;
			
		}
		else {
			bottom = center;
			strb = strc;
		}
		center = (upper + bottom) / 2;


	}
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
int A[111];
int B[111];

int main() {
   cin >> N;
   int b = 0;
   rep (i, N) cin >> A[i];
   rep (i, N) {
      cin >> B[i];
      b += B[i];
   }

   repp (i, 1, N) {
      A[i] += A[i-1];
   }

   int ans = 0;
   rep (i, N) {
      int a = A[i];
      ans = max(ans, a+b);
      b -= B[i];
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256