akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

void trace(int A[], int N){
    int i;
    for(i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}
void insertionSort(int A[], int N){
    int i, v, j;
    for(i = 1; i < N; i++){
        v = A[i];
        j = i-1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}
int main(){
    int N, i, j;
    int A[100];
    cin >> N;
    for(i = 0; i < N; i++) cin >> A[i];
    trace(A, N);
    insertionSort(A, N);
    return 0;
}


Measured memory_bytes: 3116
l = []
for i in range(3):
    l.append(list(map(int, input().split())))

a2 = l[0][1] - l[0][0]
a3 = l[0][2] - l[0][0]
b2 = l[1][0] - l[0][0]
b3 = l[2][0] - l[0][0]

is_takahashi_true = True

for i in range(1, 3):
    ta2 = l[i][1] - l[i][0]
    ta3 = l[i][2] - l[i][0]
    tb2 = l[1][i] - l[0][i]
    tb3 = l[2][i] - l[0][i]
    if a2 != ta2 or a3 != ta3 or b2 != tb2 or b3 != tb3:
        is_takahashi_true = False

print("YNeos"[not is_takahashi_true::2])


Measured memory_bytes: 3064
#!/usr/bin/env python3
# O(NlogN)

n = int(input())

div = [0 for _ in range(n+1)]
for i in range(1, n+1):
    ti = i 
    while True:
        if ti > n:
            break
        div[ti] += 1 
        ti += i
ans = 0 
for i in range(1, n+1):
    ans += i*div[i]
print(ans)


Measured memory_bytes: 224664
N, Q = map(int, input().split())
S = input()

L = []
for i in range(Q):
  L.append([int(i) for i in input().split()])
  
for i in range(N-1):
  if S[i] == "A" and S[i+1] == "C":
    S = S[:i] + "a" + S[i+1:]

l = []
c = 0
for i in range(N):
  l.append(c)
  if S[i] == "a":
    c += 1
  

for i in range(Q):
  print(l[L[i][1]-1] - l[L[i][0]-1])

Measured memory_bytes: 24440
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define pll pair<ll,ll>
#define pvii pair<vi,int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define ff first
#define ss second

void solve() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    string s;
    vll a(26, 0);
    multiset<vll > x;
    set<vll > y;
    forn(i, n) {
        forn(j, 26) {
            a[j] = 0;
        }
        cin >> s;
        forn(j, 10) {
            a[s[j] - 'a']++;
            //cout << j << " " << 'a' << " " << j - 'a' << endl;
        }
        x.insert(a);
        y.insert(a);
    }
    vll cnt(sz(y));
    int r = 0;
    for (auto i: y) {
        cnt[r] = x.count(i);
        r++;
    }
    ll ans = 0;
    for (auto i: cnt) {
        forn(j, i - 1) {
            ans += j + 1;
        }
    }
    cout << ans;
    return 0;
}


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

#define ll long long int
#define endl '\n'
const long long inf=1e18;
vector<ll>tree[100005];
ll dp[100005];
ll vis[100005];
void dfs(ll v)
{
    vis[v]=true;
    for(int child:tree[v])
    {
        if(!vis[child])
        {
            dfs(child);
        }
        dp[v]=max(dp[v],dp[child]+1);
    }
}
void testCase()
{
   // ll t; cin>>t; while(t--)
    {
        ll n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            tree[x].push_back(y);
        }

        for(int i=1;i<=n;i++)
        {
            if(!vis[i])
            {
                dfs(i);
            }
        }
        ll ans=0;
        for(int i=1;i<=n;i++)
        ans=max(ans,dp[i]);
        cout<<ans<<endl;
    } 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    testCase();
    return 0;
}

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

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


Measured memory_bytes: 256
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    a, b, c = nm()
    print(min(c, b // a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9016
K=int(input())
S=[1]
while 1:
    #print(S,K)
    flag=0
    idxflag=0
    for i in range(len(S)-1):
        if not S[i] in [S[i+1]+1,S[i+1],S[i+1]-1]:
            flag=1
            break
    if flag:
        S[i]+=1

        for m in range(i+1,len(S)):
            S[m]=max(S[m-1]-1,0)
    else:
        K-=1
        if K==0:
            break
        S[-1]+=1


    for i in range(1,len(S))[::-1]:
        if S[i]==10:
            idx=i
            idxflag=1
            S[i]=0
            S[i-1]+=1
            #S[i]=max(S[i-1]-1,0)
    if idxflag:
        for i in range(idx,len(S)):
            S[i]=max(S[i-1]-1,0)


    if S[0]==10:
        S=[0 for i in range(len(S)+1)]
        S[0]=1
print(int("".join([str(i) for i in S])))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int main() {
    int l; cin >> l;
    vector<tuple<int,int,int>> ans;
    rep(i,18) {
        ans.emplace_back(i + 1, i + 2, 0);
        ans.emplace_back(i + 1, i + 2, 1 << i);
    }
    bool exception = false;
    if (l >= (1 << 19)) {
        ans.emplace_back(19, 20, 0);
        ans.emplace_back(19, 20, 1 << 18);
        exception = true;
        l -= 1 << 19;
    }
    int sum = exception ? 1 << 19 : 0;
    rep(i,20) {
        if (l >> i & 1) {
            ans.emplace_back(i + 1, 20, sum);
            sum += 1 << i;
        }
    }
    cout << 20 << " " << (int)ans.size() << endl;
    rep(i,ans.size()) {
        int u, v, c;
        tie(u, v, c) = ans[i];
        cout << u << " " << v << " " << c << endl;
    }
}

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

#define INF (ll)1e+18

int main(){

	  int V,E; cin >> V >> E;
	  AdjMat G(V,vector<ll>(V,INF));

	  for(int i=0; i<E; i++){
			ll s,t,d; cin >> s >> t >> d;
			G[s][t] = d;
	  }

	  for(int i=0; i<V; i++) G[i][i] = 0;

	  for(int k=0; k<V; k++)
			for(int j=0; j<V; j++)
				  for(int i=0; i<V; i++)
						G[i][j] = min(G[i][j], G[i][k] + G[k][j]);

	  for(int i=0; i<V; i++)
			if(G[i][i] != 0){	  cout << "NEGATIVE CYCLE" << endl;	  return 0;			}

	  for(int i=0; i<V; i++){
			for(int j=0; j<V; j++){
				  if(G[i][j] >= INF/10) cout << "INF";
				  else cout << G[i][j];
				  if(j==V-1) cout << endl;
				  else cout << " ";
			}
	  }
}
			
	  
			   

Measured memory_bytes: 1300
#include<bits/stdc++.h>
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n+2];
    a[0]=0;
    int sum=0;
    fr(i,1,n+1){
        cin>>a[i];
        sum+=a[i];
    }
    a[n+1]=0;
    int ans=0;
    while(1){
        // between two zero in array...find min index ,min and max....if min endex is at
        // end point....add max to answer and make all element equal to 0
        // in between... add mn to answer and subtract min from that segment
        int i=0,j=0;
        while(i<n+2){
            int mx=-1,mn=101,mni=-1;
            while(i<n+2&&a[i]==0)
            i++;
            j=i;
            while(j<n+2&&a[j]){
                mx=max(mx,a[j]);
                if(mn>a[j]){
                    mn=a[j];
                    mni=j;
                }
                j++;
            }
            j--;
            int n1=0,n2=0;
            fr(k,i+1,j+1){
                if(a[k]-a[k-1]>0)
                n1++;
                else if(a[k]-a[k-1]<0)
                n2++;
            }
            if(mni!=-1){
                if(n1==0||n2==0){ // ascending or descending
                    ans+=mx;
                    fr(k,i,j+1)
                    a[k]=0;
                }
                else{
                    ans+=mn;
                    fr(k,i,j+1){
                        a[k]-=mn;
                    }
                }
            }
        //    cout<<"i="<<i<<" j="<<j<<"ans="<<ans<<endl;
        }
        bool f=1;
        fr(i,0,n+2)
        if(a[i])
        f=0;
        if(f)
        break;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin >> c;
    cout << char(c+1) << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int count = 0;
  if(s[0] == 'o') count++;
  if(s[1] == 'o') count++;
  if(s[2] == 'o') count++;
  int price;
  price = 700 + count*100;
  cout << price << endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    for(auto &I:a){cin>>I; I--;}
    vector<pll> A(3*m,{0,0});
    ll ans=0;
    for(int i=1;i<n;i++){
        if(a[i-1]>a[i]){
            ans+=a[i]+m-a[i-1];
            A[a[i-1]].S+=1;
            A[a[i]+m].S-=1;
            A[a[i]+m].F-=a[i]+m-a[i-1];
            A[a[i-1]+m].S+=1;
            A[a[i]+m*2].S-=1;
            A[a[i]+m*2].F-=a[i]+m-a[i-1];
        }
        else{
            ans+=a[i]-a[i-1];
            A[a[i-1]].S+=1;
            A[a[i]].S-=1;
            A[a[i]].F-=abs(a[i-1]-a[i]);
            A[a[i-1]+m].S+=1;
            A[a[i]+m].S-=1;
            A[a[i]+m].F-=a[i]-a[i-1];
            A[a[i-1]+m*2].S+=1;
            A[a[i]+m*2].S-=1;
            A[a[i]+m*2].F-=a[i]-a[i-1];
        }
    }
    ll mx=0;
    ll cnt=0;
    ll sum=0;
    for(int i=0;i<3*m;i++){
        sum+=cnt;
        sum+=A[i].F;
        //cout<<" "<<sum;
        cnt+=A[i].S;
        mx=max(mx,sum);
    }
    //cout<<endl;
    cout<<ans-mx<<endl;
    
    
    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  ll n, x;
  cin >> n >> x;
  ll prv = 0, a, ans = 1;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    ll cur = prv + a;
    if(cur <= x)
      ++ans;
    prv = cur;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
#define rep(i,n) for (ll i=0;i<n;i++)
using namespace std;


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

    ll n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    rep(i,1000){
        string t = to_string(i);
        ll len = t.size();
        rep(j,3-len){
            t = '0' + t;
        }
        // cout << t << endl;

        ll cnt = 0;
        rep(i,n){
            if(s[i]==t[cnt]){
                cnt++;
            }
            if(cnt==3){
                ans++;
                break;
            }
        }

    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>

using namespace std;

     //??????????¶????
void out (int a[],int n){
    for (int i = 0; i < n-1 ; ++i) {
        cout << a[i] << " ";
    }
        cout << a[n-1] << endl;
}

int main() {
    int a[100];
    int n;

    //??\?????¨
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> a[i];
    }
    //???????????¶?????????
    out (a,n);

    //?????\?????????
    for (int i = 1; i < n ; ++i) {
        int j = i-1;  //????¨????????????????
        int v = a[i]; //?¬???????????????????????¨???¶

        // ????¨????????????????????????? ?????? ????¨??????????????????????????????????????????§???????????????????????????
        while( j >= 0 and a[j]>v) {
            a[j + 1] = a[j];
            --j;
        }
        a[j + 1] = v;
        out (a,n);
        }
    return 0;
}

Measured memory_bytes: 1164
n,k = map(int,input().split())
B = list(map(int,input().split()))
A = [i for i in range(0,10)]
for number in B:
    A.remove(number)

for i in range(n,10*n+1):
    for j in str(i):
        if not int(j) in A:
            break
    else:
        print(i)
        exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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 long long INF = 1LL << 60;
long long h[100010];

int main()
{
    int N; cin >> N;
    vector<int> c;
    c.push_back(1);
    for (int i = 6; i <= N; i *= 6) c.push_back(i);
    for (int i = 9; i <= N; i *= 9) c.push_back(i);

    vector<ll> dp(100010, INF);
    dp[0] = 0;

    rep(i, N+1)
    {
        rep(j, c.size())
        {
            if (i >= c[j])
            {
                dp[i] = min(dp[i], dp[i - c[j]] + 1);
            }
        }

    }
    cout << dp[N] << endl;
}



Measured memory_bytes: 1024
n = int(input())
a = input().split()
even = []
even_counter = 0
div = 0
 
for i in a:
  int_a = int(i)
  if int_a % 2 == 0:
    even.append(int_a)
    even_counter += 1
 
for i in range(even_counter):
  if int(even[i]) % 3 == 0 or int(even[i]) % 5 == 0:
    div += 1
 
if div == even_counter:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
  int x;
  std::cin >> x;
  rrep(i,x,1000000){
    if(IsPrime(i)){
      std::cout << i << std::endl;
      exit(0);
    }
  }
}

Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline

  r,c,k = map(int,input().split())
  b = [[0 for _ in range(c)] for _ in range(r)]
  for i in range(k):
    y,x,v = map(int,input().split())
    y -= 1
    x -= 1
    b[y][x] = v

  # dp[j][l]:(i,j)に居て、i行目のアイテムをl個拾ったときの価値最大値。
  dp = [[0 for _ in range(4)] for _ in range(c+1)]
  for i in range(r):
    for j in range(c):
      # アイテムを拾う遷移。個数が多い方から計算する。
      for l in range(2,-1,-1):
        dp[j][l+1] = max(dp[j][l]+b[i][j],dp[j][l+1])
      # 移動する遷移。行を移動する際は、拾ったアイテム数はリセットされる。
      for l in range(4):
        dp[j+1][l] = max(dp[j][l],dp[j+1][l])
        dp[j][0] = max(dp[j][l],dp[j][0])
  ans = 0
  for i in range(4):
    ans = max(dp[c-1][i],ans)
  print(ans)

main()

Measured memory_bytes: 154244
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < s.Length; i++) {
                if (s[i] == t[i]) {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
N,X = map(int, input().split())


m=[]
for i in range(0,N):
    m.append(int(input()))

m.sort()
m.reverse()

X -= sum(m)
count = len (m)

for i in m:
    deviser = m.pop()
    count += X //deviser
    X = X % deviser

print(count)



Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main() {
    ll x,y;
    cin>>x>>y;

    if(y == 0) {
        if(x > 0) cout<<x+1;
        else cout<<-x;
        return 0;
    }

    if(abs(x) == abs(y)) {
        cout<<"1";
    } else if(abs(x) < abs(y)) {
        if(x >= 0 and y > 0) {
            cout<<y-x;
        } else if(x<0 and y<0) {
            cout<<2-y+x;
        } else if(x>=0 and y<0) {
            cout<<1-y-x;
        } else cout<<1+x+y;
    } else {
        if(x>0 and y>0) cout<<x-y+2;
        else if(x<0 and y<0) cout<<y-x;
        else if(x<0 and y>0) cout<<1-x-y;
        else cout<<1+x+y;
    }

    return 0;
}


Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  int a = n % 10;
  if (a == 3) {
    cout << "bon" << endl;
  } else if (a <= 1 || a == 6 || a == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }

  return 0;
}

Measured memory_bytes: 3624
e = input()
o = input()

no = len(o)
ne = len(e)
i = 0
oi = 0
ei = 0
s = ''
while i < no+ne:
    if i % 2 != 0 and oi < no:
        s += o[oi]
        oi += 1
    elif i % 2 == 0 and ei < ne:
        s += e[ei]
        ei += 1
    i += 1

print(s)
    

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    long int i, n;
    scanf("%ld", &n);
    long int arr[n], a[n];
    for(i=0; i<n; i++)
    {
        a[i]=0;
    }
    for(i=0; i<n-1; i++)
    {
        scanf("%ld", &arr[i]);
        a[arr[i]-1]++;
    }
    for(i=0; i<n; i++)
    {
        printf("%ld\n", a[i]);
    }
    return 0;
}

Measured memory_bytes: 4852
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i=0; i<N; i++) {
        cin >> p[i];
    }
    
    int miss = 0;
    for (int i=0; i<N; i++) {
        if(p[i] != i+1){
            miss++;
        }
    }
    
    if (miss == 0 || miss == 2) {
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


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

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

    ll ans = 999999;
    rep(h, H) {
        ll A   = h * W;
        ll B1  = round((double)(H - h) / 2) * W;
        ll C1  = H * W - (A + B1);
        ll mn1 = max({A, B1, C1}) - min({A, B1, C1});

        ll B2  = (H - h) * round((double)W / 2);
        ll C2  = H * W - (A + B2);
        ll mn2 = max({A, B2, C2}) - min({A, B2, C2});

        ans = min({ans, mn1, mn2});
    }

    rep(w, W) {
        ll A   = H * w;
        ll B1  = H * round((double)(W - w) / 2);
        ll C1  = H * W - (A + B1);
        ll mn1 = max({A, B1, C1}) - min({A, B1, C1});

        ll B2  = round((double)H / 2) * (W - w);
        ll C2  = H * W - (A + B2);
        ll mn2 = max({A, B2, C2}) - min({A, B2, C2});

        ans = min({ans, mn1, mn2});
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
const int MAX = 100000+5;
typedef struct Node{
	char name[20];
	int t;
}P;
P p[MAX];
queue<P> Q;
int main(int argc, char const *argv[])
{
	int n,q,sumt = 0;
	cin >> n >> q;
	for(int i = 0;i < n;i++){
		cin >> p[i].name >> p[i].t;
		Q.push(p[i]);
	}
	while(!Q.empty()){
		if(Q.front().t > q){
			sumt += q;
			P tp = Q.front();
			tp.t -= q;
			Q.push(tp);
			Q.pop();
		}
		else{
			sumt += Q.front().t;
			cout << Q.front().name <<" "<< sumt << endl;
			Q.pop();
		}
	}
	return 0;
}


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

signed main(){

  int q;
  cin>>q;
  bitset<64> b;
  while(q--){
    int c;
     cin>>c;
     if(c==0){
       int i;
       cin>>i;
      cout<< b[i] <<endl;
     }
     else if(c==1){
       int i;
       cin>>i;
       b.set(i);
     }
     else if(c==2){
       int i;
       cin>>i;
       b.reset(i);
     }
     else if(c==3){
       int i;
       cin>>i;
       b.flip(i);
     }
     else if(c==4){
       cout<< (b.all()) <<endl;
     }
     else if(c==5){
       cout<< (b.any()) <<endl;
     }
     else if(c==6){
       cout<< (b.none()) <<endl;
     }
     else if(c==7){
       cout<< (b.count()) <<endl;
     }
     else if(c==8){
       cout<< (b.to_ullong()) <<endl;
     }
  }

}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

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

int main() {
	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC";
	else cout << "ABC";
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const ll INF = 1LL << 60;

ll calc(ll b,ll n){

    if(n < b){
        return n;
    }else{
        return calc(b,n/b) + n % b;
    }
}

int main(){

    ll n,s;
    cin >> n >> s;

    if(n < s){
        cout << "-1" << endl;
        return 0;
    }
    if(n == s){
        cout << s+1 << endl;
        return 0;
    }
    ll mini = INF;

    for(ll i = 2;i*i <= n;i++){
        if(calc(i,n) == s){
            mini = min(mini,i);
        }
    }

    if(mini != INF){
        cout << mini << endl;
        return 0;
    }
    //ここからは2 <= b <= sqrt(n)までに解がなかった場合

    for(ll p = 1;p*p < n;p++){

        ll b = (n-s)/p+1;
        if(b == 1){
            continue;
        }
        if(calc(b,n) == s){
            mini = min(mini,b);
        }
    }

    if(mini != INF){
        cout << mini << endl;
    }else{
        cout << "-1" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

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

	int H, W, D;
	cin >> H >> W >> D;
	int A[301][301] = {};
	int gyakux[90001] = {};
	int gyakuy[90001] = {};
	rep1(i, H) {
		rep1(ii, W) {
			cin >> A[i][ii];
			gyakux[A[i][ii]] = i;
			gyakuy[A[i][ii]] = ii;
		}
	}

	ll B[90001] = {};
	rep1(i, D) {
		int maex = gyakux[i];
		int maey = gyakuy[i];
		for (int ii = i + D; ii <= H * W; ii += D) {
			int tugix = gyakux[ii];
			int tugiy = gyakuy[ii];
			B[ii] = B[ii - D] + abs(maex - tugix) + abs(maey - tugiy);
			maex = tugix;
			maey = tugiy;
		}
	}

	int Q;
	cin >> Q;
	rep(i, Q) {
		int L, R;
		cin >> L >> R;
		co(B[R] - B[L]);
	}

	Would you please return 0;
}

Measured memory_bytes: 2944
(defparameter *k* 1)
(defparameter *l* 0)

(defun cnt (lst)
  (if lst
      (progn (unless (equal (car lst) *k*)
	       (setf *l* (+ *l* 1)))
	     (setf *k* (+ *k* 1))
	     (cnt (cdr lst))
	     )
      *l*
      )
  )
 
      
	  
(let* ((n (read))
       (lst (loop :repeat n :collect (read)))
       )
(if (member (cnt lst) '(0 2))
    (princ "YES")
    (princ "NO")
    )
)

Measured memory_bytes: 13668
// finish date: 2019/1/26

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    map<pii, ll> mp;
    FOR(i, 1, N + 1) {
        int head = to_string(i)[0] - '0';
        int tail = i % 10;
        mp[pii(head, tail)] += 1;
    }
    ll cnt = 0;
    FOR(i, 1, N + 1) {
        int head = to_string(i)[0] - '0';
        int tail = i % 10;
        cnt += mp[pii(tail, head)];
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
//WAPER
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define N 85
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int E[N][N][N*N*2];int *f[N][N];
int n,m,v1[N][N],v2[N][N],a[N][N],b[N][N],sum=6400;
int V[2*N*N];int *tmp=V+N*N+1;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	for(register int i=0;i<N;i++)
	{
		for(register int j=0;j<N;j++)f[i][j]=E[i][j]+N*N+1;
	}
	n=read(),m=read();
	for(register int i=1;i<=n;i++)
	{
		for(register int j=1;j<=m;j++)a[i][j]=read();
	}
	for(register int i=1;i<=n;i++)
	{
		for(register int j=1;j<=m;j++)b[i][j]=read();
	}
	for(register int i=1;i<=n;i++)
	{
		for(register int j=1;j<=m;j++)v1[i][j]=a[i][j]-b[i][j],v2[i][j]=b[i][j]-a[i][j];
	}
	for(register int i=1;i<=n;i++)
	{
		for(register int j=1;j<=m;j++)
		{
			if(i==1&&j==1){f[i][j][v1[i][j]]=f[i][j][v2[i][j]]=1;continue;}
			memset(tmp,0,sizeof(tmp));
			for(register int k=-sum;k<=sum;k++)tmp[k]=f[i-1][j][k]|f[i][j-1][k];
			for(register int k=-sum;k<=sum;k++)
			{
				if(!tmp[k])continue;
				f[i][j][k+v1[i][j]]=1;f[i][j][k+v2[i][j]]=1;
			}
		}
	}
//	for(register int i=1;i<=n;i++)
//	{
//		for(register int j=1;j<=m;j++)
//		{
//			cout<<v1[i][j]<<" ";
//		}
//		cout<<endl;
//	}
//	for(register int i=1;i<=n;i++)
//	{
//		for(register int j=1;j<=m;j++)
//		{
//			cout<<v2[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	int ans=inf;
	for(register int i=-sum;i<=sum;i++)if(f[n][m][i])ans=min(ans,abs(i));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 385536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
using namespace std;
using ll = long long;

int main() {
	int N, T, cmax=1001;
	cin >> N >> T; 
	int tmin = T, tmax = 1001;

	vector<ll> c(N), t(N);

	for (int i = 0; i < N; i++)
	{
		cin >> c[i] >> t[i];
		if (t[i] < tmax)
			tmax = t[i];
	}
		
	for (int i = 0; i < N; i++)
	{
		
		if (t[i] <= T)
		{
			tmin = t[i];
			if (cmax > c[i])
				cmax = c[i];
		}
	}
	if (tmax > T)
	{
		cout << "TLE\n";
	}
	else
	{
		cout << cmax << endl;
	}
	cin >> N;
}

Measured memory_bytes: 256
import sys
# 未解決(最後だけREになる)


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


a = get()
b = a[0]
c = a[1]
if b < c:
    if abs(b - c) < b:
        print(abs(b - c))
        sys.exit(0)
    else:
        print(b)
        sys.exit(0)
else:
    if a[0] % a[1] == a[1] or a[0] % a[1] == 0:
        print(0)
        sys.exit(0)
    else:
        if abs((a[0] % a[1]) - a[1]) < abs(((a[0] % a[1]) - a[1]) % a[1]):
            if abs(a[0] % a[1]) < abs((a[0] % a[1]) - a[1]):
                print(abs(a[0] % a[1]))
                sys.exit(0)
            else:
                print(abs((a[0] % a[1]) - a[1]))
                sys.exit(0)
        else:
            if abs(a[0] % a[1]) < abs(((a[0] % a[1]) - a[1]) % a[1]):
                print(abs(a[0] % a[1]))
                sys.exit(0)
            else:
                print(abs(((a[0] % a[1]) - a[1]) % a[1]))
                sys.exit(0)


Measured memory_bytes: 38384
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vec;

vec Add(vec,vec);
vec Power(vec,int);
vec Formula();
vec Ar();
vec v[26];
string s;
int n,p;

int main(){
  int k,h,a;
  char c;
  cin>>n>>k;
  while(k--){
    cin>>c>>h;
    for(int i=0;i<n;i++) v[c-'A'].push_back(i);
    for(int i=0;i<h-1;i++)
      for(int j=0;j<n-1;j++){
	cin>>a;
	if(a) swap(v[c-'A'][j],v[c-'A'][j+1]);
      }
  }
  cin>>k;
  while(k--){
    cin>>s;
    s+='$';
    p=0;
    vec ans=Formula();
    for(int i=0;i<n;i++){
      if(i) cout<<' ';
      cout<<ans[i]+1;
    }
    cout<<endl;
  }
  return 0;
}

vec Add(vec A,vec B){
  vec res=vec(n);
  for(int i=0;i<n;i++) res[i]=A[B[i]];
  return res;
}

vec Power(vec A,int x){
  vec res;
  for(int i=0;i<n;i++) res.push_back(i);
  while(x){
    if(x%2) res=Add(res,A);
    x/=2;
    A=Add(A,A);
  }
  return res;
}

vec Formula(){
  vec res=Ar();
  while(s[p]=='+') p++,res=Add(res,Ar());
  return res;
}

vec Ar(){
  if(s[p]=='('){
    p++;
    vec res=Formula();
    p++;
    return res;
  }
  if('0'<=s[p]&&s[p]<='9'){
    int num=0;
    while('0'<=s[p]&&s[p]<='9') num=num*10+s[p]-'0',p++;
    vec res=Ar();
    return Power(res,num);
  }
  if('A'<=s[p]&&s[p]<='Z') return v[s[p++]-'A'];
}

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

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

using namespace std;

int f(const vector<int>& v, int i) {
  int n = v.size();
  if (i == n) return 0;
  int ml = 100;
  int k = (10 - v[i]) % 10;
  if (k == 0) return f(v, i+1);
  for (int j=i; j<n; ++j) {
    auto cp = v;
    for (int l=i; l<=j; ++l) {
      cp[l] += k;
      cp[l] %= 10;
    }
    ml = min(ml, f(cp, i+1) + 1);
  }
  return ml;
}

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n) break;
    string a, b;
    cin>>a>>b;
    vector<int> v(n);
    REP(i,n) {
      v[i] = a[i] + 10 - b[i];
      v[i] %= 10;
    }
    cout << f(v, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
using System;
using System.Linq;

namespace _169_c
{
    internal class Multiplication3
    {
        private static void Main(string[] args)
        {
            var ab = Console.ReadLine()?.Split(" ");
            if (ab == null) return;

            var a = long.Parse(ab[0]);
            var b = double.Parse(ab[1]);

            var b100 = (long)Math.Round(b * 100);
            var result = a * b100;
            Console.WriteLine(result / 100);
        }
    }
}

Measured memory_bytes: 27524
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=tmp*10+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll tmp=1; for(;b;b>>=1){if(b&1)tmp=tmp*a%mod; a=a*a%mod;} return tmp;}
using namespace std;
int n;
bool check(int x)
{
	if(x==1)return 0;
	for(int i=2;i*i<=x;i++)
		if(x%i==0)return 0;
	return 1;
}
int main()
{
	n=read();
	for(int i=1;n;i++)
		if(check(i)&&i%10==1){
			--n; printf("%d ",i);
		}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
    int N, M, i, A, B, count=0;

    scanf("%d",&N);
    scanf("%d",&M);
    long H[N], H2[N];

    for(i=0; i<N; i++) {
        scanf("%ld",&H[i]);
        H2[i] = 0;
    }

    for(i=0;i<M;i++) {
        scanf("%d",&A);
        scanf("%d",&B);
        if(H[A-1] < H[B-1]) {
            H2[A-1] = 1;
        } else if(H[A-1] > H[B-1]) {
            H2[B-1] = 1;
        } else {
            H2[A-1] = 1;
            H2[B-1] = 1;
        }
    }

    for(i=0;i<N;i++) {
        if(H2[i] == 0) {
            count++;
        } 
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n,m,x,y;cin>>n>>m>>x>>y;

    int X = -1000, Y = 1000;
    REP(i, n) {
        int x1;cin>>x1;
        if (X < x1) X=x1;
    }
    REP(i,m) {
        int y1;cin>>y1;
        if (Y > y1) Y=y1;
    }

    if (X >= y || Y <= x) {
        cout << "War" <<endl;
    } else {
        if (Y > X) {
            cout << "No War" << endl;
        }else {
            cout << "War" <<endl;
        }
    }
}


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

int main(){
    long long N,K;
    cin >> N >> K;
    long long A[N+1];
    long long i;
    for(i=1; i<=N; i++){
        cin >> A[i];
    }
    long long kcou;
    long long L=1;
    long long R=1000000000;
    long long M;
    while(L+1<R){
        kcou=0;
        M=(L+R)/2;
        for(i=1; i<=N; i++){
            if(A[i]%M==0){
                kcou+=A[i]/M-1;
            }else{
                kcou+=A[i]/M;
            }
        }
        if(kcou<=K){
            R=M;
        }else{
            L=M;
        }
    }
    kcou=0;
    for(i=1; i<=N; i++){
        if(A[i]%L==0){
            kcou+=A[i]/L-1;
        }else{
            kcou+=A[i]/L;
        }
    }
    if(kcou<=K){
        cout << L << endl;
    }else{
        cout << R << endl;
    }
    system("pause");
    return 0;
}

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

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
/*-------------------------------------------------*/
using CostType = long long;
struct Edge {
  int src, dst;
  CostType cost;
  Edge(int src_, int dst_, CostType cost_ = 0) : src(src_), dst(dst_), cost(cost_) {}
  inline bool operator<(const Edge &rhs) const {
    return cost != rhs.cost ? cost < rhs.cost : dst != rhs.dst ? dst < rhs.dst : src < rhs.src;
  }
  inline bool operator<=(const Edge &rhs) const { return cost <= rhs.cost; }
  inline bool operator>(const Edge &rhs) const {
    return cost != rhs.cost ? cost > rhs.cost : dst != rhs.dst ? dst > rhs.dst : src > rhs.src;
  }
  inline bool operator>=(const Edge &rhs) const { return cost >= rhs.cost; }
};

bool is_bipartite(const vector<vector<Edge> > &graph, vector<int> &color) {
  int n = graph.size();
  color.assign(n, 0);
  function<bool(int, int)> dfs = [&](int ver, int now) {
    color[ver] = now;
    for (const Edge &e : graph[ver]) {
      if (color[e.dst] == now || (color[e.dst] == 0 && !dfs(e.dst, -now))) return false;
    }
    return true;
  };
  REP(i, n) {
    if (color[i] == 0 && !dfs(i, 1)) return false;
  }
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n; int m; cin >> n >> m;
  vector<vector<Edge> > graph(n);
  REP(_, m) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(a, b);
    graph[b].emplace_back(b, a);
  }
  vector<int> color;
  if (is_bipartite(graph, color)) {
    long long black = 0, white = 0;
    REP(i, n) ++(color[i] == 1 ? black : white);
    cout << black * white - m << '\n';
  } else {
    cout << n * (n - 1) / 2 - m << '\n';
  }
  return 0;
}


Measured memory_bytes: 8576
items = ['A', 'C', 'G', 'T']
 
def max(a, b):
    return a if a > b else b
x= 0
y = 0
for c in list(input()):
    if c in items:
 
        y += 1
        x = max(x, y)
    else:
        y = 0
print(x)

Measured memory_bytes: 9036
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
s = str(input())
t = str(input())

for i in range(N):
    if s[i:]==t[:N-i]:
        break
else:
    i += 1
print(N+i)

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

int main(){
   int K,N,max_a;
   cin>>K>>N;
   vector<int> vec(N);
   max_a=0;
  
   for(int i=0;i<N;i++){
      int a;
      cin>>a;
      vec.at(i)=a;
   }
   
   for(int i=0;i<N-1;i++){
      int a;
      a=vec.at(i+1)-vec.at(i);
      max_a=max(max_a,a);
   }
  
   max_a=max(max_a,K-vec.at(N-1)+vec.at(0));
   cout<<K-max_a<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
//#include <iostream>
//#include <vector>
//#include <string>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
	dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
	dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
	dx4[4] = { 0,1,0,-1 },
	dy4[4] = { 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main() {
	setc;

	lint n; cin >> n;
	if (n < 1200)co("ABC");
	else if (n < 2800)co("ARC");
	else co("AGC");
	gc();
}

Measured memory_bytes: 256
import java.util.*;
public class Main  {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int x = sc.nextInt();
      int y = sc.nextInt();

      int count = 0;

      for (int i = 0; i <= x; i++) {
         if (i*2+(x-i)*4 == y) {
            count++;
         }
      }


      if (count != 0) {
         System.out.println("Yes");
      } else {
         System.out.println("No");
      }
   }
}

Measured memory_bytes: 35776