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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

struct UnionFind {
    vector<ll> parent;
    vector<ll> usize;
 
    UnionFind(int n) : parent(n), usize(n, 1LL){
        rep(i, n)parent[i]=i;
    }
    
    int root(int x){
        if(parent[x] == x) return x;
        else return parent[x] = root(parent[x]);
    }
    
    bool issame(int x, int y){
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
 
        if(x == y)return false;
 
        if(parent[x] > parent[y]) swap(x, y);

        usize[x] += usize[y];
        parent[y] = x;
 
        return true;
    }
    
    int size(int x) {
        return usize[root(x)];
    }
};


int main(){
    ll n, m;
    cin >> n >> m;

    vector<ll> a(m), b(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    reverse(ALL(a));
    reverse(ALL(b));

    UnionFind uf(n);
    vector<ll> ans(m);
    ans[0] = n*(n-1)/2;
    rep(i, m-1){
        if(uf.issame(a[i], b[i]))ans[i+1] = ans[i];
        else {
            ans[i+1] = ans[i] - uf.size(a[i])*uf.size(b[i]);
            uf.merge(a[i], b[i]);
        }
    }

    reverse(ALL(ans));
    rep(i, m)cout << ans[i] << endl;
}

Measured memory_bytes: 5248
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

bool match(vector<string> A, int i, int j, vector<string> B) {
	int N = A.size();
	int M = B.size();
	FOR(p, 0, M) {
		FOR(q, 0, M) {
			if (B[p][q] != A[i + p][j + q]) return false;
		}
	}
	return true;
}

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

	const int D = 1000000007;
	ll pw = 1;
	FOR(i, 1, N+1) {
		pw *= i;
		pw %= D;
	}

	ll ans = pw%D;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5;
typedef long long ll;

int main(){
	ll a, b, n;
	cin >> a >> b >> n;
	if(n >= b){
		ll z = floor((a*(b-1))/b);
		cout << z << endl;
	}
	else{
		ll z = floor((a*n)/b);
		cout << z << endl;
	}
	return 0;
}

// 1000000 1000000000000 1000000000000

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  
  char D = 'A' - 'a';
  
  cout << char(A.at(0) + D) << char(B.at(0) + D) << char(C.at(0) + D) << endl;
}


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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; string s; cin>>n>>s;
  vi c(26);
  rep(i,n){
    c[s[i]-'a']++;
  }
  ll ans=1;
  rep(i,26){
    if(c[i]){
      (ans*=(c[i]+1))%=MOD;
    }
  }
  ans--;
  cout<<ans<<endl;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

int point(int x) {
  return x * 100;
}

int ceil_div(int a, int b) {
  return (a + b - 1) / b;
}

void MAIN() {
  int n, g;
  cin >> n >> g;
  vector<int> a(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> c[i];
  }
  int ans = 2e9;
  for (int i = 0; i < (1 << n); i++) {
    int cnt = 0, pnt = 0;
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        cnt += a[j];
        pnt += a[j] * point(j + 1) + c[j];
      }
    }
    for (int j = n - 1; j >= 0; j--) {
      if (pnt >= g) break;
      if (((i >> j) & 1) == 0) {
        int t = ceil_div(g - pnt, point(j + 1));
        t = min(t, a[j]);
        cnt += t;
        pnt += t * point(j + 1);
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3596
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

//#define pb push_back
//#define mp make_pair
//
//#define F first
//#define S second

typedef long long ll;

#define rept(_i,iv,n,type) for(type _i=(type)(iv);_i<(type)(n);++_i)
//#define repi(_i,iv,n) rept(_i,iv,n,int)
//#define repl(_i,iv,n) rept(_i,iv,n,ll)

#define rept0(_i,n,type) rept(_i,0,n,type)
#define repi0(_i,n) rept(_i,0,n,int)
#define repl0(_i,n) rept(_i,0,n,ll)

//#define repst(_i,iv,n,type) for(type _i=iv;_i<=(type)(n);++_i)
//#define repsi1(_i,n) repst(_i,1,n,int)

#define REPT(_i,iv,_l,n,type) for(type _i=(type)(iv),_l=(type)(n);_i<_l;++_i)
//#define REPI(_i,iv,_l,n) REPT(_i,iv,_l,n,int)
//#define REPL(_i,iv,_l,n) REPT(_i,iv,_l,n,ll)
//
#define REPT0(_i,_l,n,type) REPT(_i,0,_l,n,type)
#define REPI0(_i,_l,n) REPT(_i,0,_l,n,int)
#define REPL0(_i,_l,n) REPT(_i,0,_l,n,ll)


//#define rrept(_i,x,e,type) for(type _i=((type)(x)-1);_i>=e;--_i)
//
//#define rrept0(_i,x,type) rrept(_i,x,0,type)
//
//#define RREPT(_i,x,_e,e,type) for(type _i=((type)(x)-1),_e=(type)(e);_i>=_e;--_i)
//
//#define RREPT0(_i,x,_e,type) RREPT(_i,x,_e,0,type)
//
//#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;


//typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
//typedef vector<ll> vll;
//typedef vector<vll > vvll;

#define MOD7 1'000'000'007
#define MOD9 1'000'000'009

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    vi A(N);
    REPV(A, itr, end){
        cin>>(*itr);
    }
    ll sum=0;
    int bh=0;
    repi0(i, N){
        if(bh<=A[i]){
            bh=A[i];
        }else{
            sum+=bh-A[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<map>
#include<vector>
#include<set>
#include<queue>
using namespace std;

int main()
{
  map<string,vector<string> > M;
  map<string,bool> Mp;
  int n;
  string s;
  string f;

  while(1){
    cin>>n;
    if(n==0)break;
    M.clear();
    Mp.clear();
    for(int i=0;i<n;i++){
      cin>>s;
      vector<string> V;
      int start=0;
      for(int j=0;j<s.length();j++){
	if(s[j]==':' || s[j]==',' || s[j]=='.'){
	  V.push_back(s.substr(start,j-start));
	  start=j+1;
	}
	if(s[j]==':' && i==0)f=s.substr(0,j);
      }
      s=V[0];
      V.erase(V.begin());
      M[s]=V;
    }

    queue<string> Q;
    set<string> set;
    Q.push(f);
    Mp[f]=true;
    while(!Q.empty()){
      string S=Q.front();
      Q.pop();
      vector<string> V=M[S];

      for(int i=0;i<V.size();i++){
	if(M[V[i]].empty())set.insert(V[i]);
	else {
	  if(Mp[V[i]])continue;
	  Mp[V[i]]=true;
	  Q.push(V[i]);
	}

      }
    }
    cout<<set.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1420
N,K = map(int,input().split())
S = list(input())

ans = 0
if S[0] == 'R':
    flagr = True
else:
    flagr = False

for i in range(1,N):
    if flagr:
        if S[i] == 'R':
            ans += 1
        else:
            flagr = False
    else:
        if S[i] == 'L':
            ans += 1
        else:
            flagr = True
            
ans = min(ans+2*K,N-1)
print(ans)


Measured memory_bytes: 4084
x= gets.chomp.to_i
ab = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
fuga = []
hoge = []
while x != 0
  x -= 1
  q = x / 26
  r = x % 26
  fuga << r
  x = q
end

fuga.reverse.each do |i|
  print ab[i]
end
puts

Measured memory_bytes: 14260
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(((A > C && B > C) || (A < C && B < C)) ? "No" : "Yes");
	}
	int A,B,C;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1]; C = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

# ITP1_5_C

sample="#."*300

def printresult(x,y):
    for i in range(y):
        if i%2==0:
            print(sample[0:x])
        else:
            print(sample[1:x+1])
            
while(True):
    y,x=map(int,input().split())
    if x==0 and y==0:
        break
    else:
        printresult(x,y)
        print("")


Measured memory_bytes: 5620
def main():
    a, b, c, d = map(int, input().split())
    if b * d > 0 or a * c > 0:
        x = max(b * d, a * c)
    else:
        x = max(a * d, b * c)
    print(x)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
# https://atcoder.jp/contests/dp/tasks/dp_a

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

dp = [0]
for i in range(1, N):
    if i == 1:
        cost1 = abs(h[i] - h[i - 1])
        dp.append(cost1)
    if i >= 2:
        cost1 = abs(h[i] - h[i - 1])
        cost2 = abs(h[i] - h[i - 2])
        dp.append(min(
            dp[i - 1] + cost1,
            dp[i - 2] + cost2,
        ))
# print(dp)

answer = dp.pop()

print(answer)


Measured memory_bytes: 13980
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const ll INF = LONG_LONG_MAX;
const int MAX_N = 112345;

int dirx[4] = {0,1,0,-1};
int diry[4] = {1,0,-1,0};

struct point{
    int x,y,d;
    point(int _x,int _y,int _d)
    :x(_x),y(_y),d(_d){}
};

int bfs(vector<vector<int> >& fld,int w,int h){
    int ret=-1;
    queue<point> Q;
    Q.push(point(1,1,1));
    while(!Q.empty()){
        point p = Q.front();
        Q.pop();
        if(p.x == w && p.y == h){
            ret = p.d;
            break;
        }
        if(fld[p.x][p.y] < 0) continue;
        fld[p.x][p.y] = -1;
        repeat(d, 4){
            int nx = p.x+dirx[d];
            int ny = p.y+diry[d];
            if(fld[nx][ny]>0){
                Q.push(point(nx,ny,p.d+1));
            }
        }
    }
    return ret;
}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int H,W;
    cin >> H >> W;
    vector<vector<int> >fld(W+2,vector<int>(H+2,-1));
    int dot_num=0;
    repeat(i, H){
        repeat(j, W){
            char c;
            cin >> c;
            if(c=='.'){
                fld[j+1][i+1] = 1;
                dot_num++;
            }
        }
    }
    int ans = dot_num-bfs(fld,W,H);
    if(ans >dot_num){
        ans = -1;
    }
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())-1
result = ""
v = 11

tmp = n % 26
result += chr(tmp+97)
n = n // 26

if n!=0:
    while(1):
        n -= 1
        # print(tmp,result,n)
        tmp = n % 26
        result += chr(tmp+97)
        n = n // 26
        if n==0: break

print(result[::-1])

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long WARU  = 1e9 + 7;

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

int main(){
    ll n,m;
    cin >> n >> m;
    ll ans;
    if(abs(n-m)>=2)cout << 0 << endl;
    else if(abs(n-m)==1){
        ans = fact(n)*fact(m)%WARU;
        printf("%lld\n",ans);
    }
    else{
        ans = fact(n);
        ans = (ans*ans)%WARU;
        ans = ans*2%WARU;
        //cout << ans << endl;
        printf("%lld\n",ans);
    } 
    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
      // 整数の入力
      int n = int.Parse(Console.ReadLine());
      // スペース区切りの整数の入力
      string[] input = Console.ReadLine().Split(' ');
      ulong[] inputs = new ulong[n];
      ulong total = 0;
      for (int i = 0; i<n;i++) {
      	inputs[i] = ulong.Parse(input[i]);
        total += inputs[i];
      }
      ulong sumA = 0;
      ulong tmp = 0;
      for (int i = 0; sumA*2 < total; i++) {
        tmp = sumA;
      	sumA += inputs[i];
      }

      ulong res = 0;
      if (sumA*2 - total < total - tmp*2) {
      	res = sumA*2 - total;
      } else {
      	res = total - tmp*2;
      }
      Console.WriteLine(res);
	}
}

Measured memory_bytes: 35280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vll;
int N;
vll A;

bool is_possible(int j){
  ll sum=A[j];
  priority_queue<ll, vector<ll>, greater<ll>> que;
  for (int i=0;i<N;++i){
    if(j!=i){
      que.push(A[i]);
    }
  }

  while(!que.empty()){
    ll a=que.top();que.pop();
    if(a>2*sum) return false;
    sum+=a;
  }
  return true;
}

int main(){
  cin>>N;
  for (int i=0;i<N;++i){
    ll a;cin>>a;A.push_back(a);
  }
  sort(A.begin(), A.end());
  int lb=-1, ub=N;
  while(ub-lb>1){
    int mid=(ub+lb)/2;
    if(is_possible(mid)) {ub =mid;}
    else{lb=mid;}
  }
  cout << N-lb-1 << endl;
}

Measured memory_bytes: 2500
#include <bits/stdc++.h>
using namespace std;
const long long OO = (long long) 1e15;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define PI acos(-1.0)
#define vec(a,b)                ((b)-(a))
#define length(a)               (hypot((a).imag(), (a).real()))
typedef vector<int> vi ;
typedef   long long ll;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;


using namespace std;
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m

ll n,d,a, x,h ,mxx=0,mnx=1000000005;
vector<pair<ll,ll>> enemies;
vector<pair<ll,ll>> bombs;

ll bs1(ll pos){
    ll frst = 0; ll lst= bombs.size()-1;
    while(frst<=lst){
        ll md =(frst+lst)/2;
        if(bombs[md].first<pos) frst=md+1;
        else lst=md-1;
    }
    return frst;
}
ll bs2(ll pos){
    ll frst = 0; ll lst= bombs.size()-1;
    while(frst<=lst){
        ll md =(frst+lst)/2;
        if(bombs[md].first>pos) lst=md-1;
        else frst=md+1;
    }
    return lst;
}


ll solve(ll pos){
    if(bombs.size()==0) return 0;
    ll frst = bs1( max(mnx,pos-d) );
    ll lst= bs2(min(mxx,pos)+d );
//    if(frst>=bombs.size()) return 0;
  // if(lst<=0) return 0;
    //cout << pos << " " <<  frst << " " <<lst  <<endl;
    lst= bombs[lst].second;
    frst==0? frst =0:frst=bombs[frst-1].second;
    return lst-frst;

}


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

  cin>>n>>d>>a;
  ll ans=0;
  lp(i,0,n){
    cin >> x>>h;
    mxx=max(mxx,x);
    mnx=min(mnx,x);
    h= (ll)ceil( h*1.0/a );
    enemies.push_back({x,h});
  }
  sort(enemies.begin(),enemies.end());
  for(pair<ll,ll>p:enemies){
    ll pos = p.first;
    ll needed = p.second;
    ll iHave = solve(pos);
    ll ad = needed-iHave;
    if(ad>0) ans += ad;

    if(bombs.size()>0) ad += bombs[ bombs.size()-1].second;
    if(needed > iHave) {bombs.push_back({min(pos+d,mxx), ad});  }
  }

  cout <<ans;




    return 0;
}


Measured memory_bytes: 12396
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 5005;
const int MAXM = 205;
int a[MAXN][MAXM], suf[MAXN][MAXM], c[MAXM];
int n, m, i, j, k;
long long tot, ans, d[MAXN];
inline int get()
{
	char c;
	while ((c = getchar()) < 48 || c > 57);
	int res = c - 48;
	while ((c = getchar()) >= 48 && c <= 57)
	res = res * 10 + c - 48;
	return res;
}
int main()
{
	cin >> n >> m;
	for(i = 2; i <= n; i ++)
		d[i] = get(), d[i] += d[i - 1];
	for(i = 1; i <= n; i ++)
		for(j = 1; j <= m; j ++)
			a[i][j] = get();
	for(i = n; i >= 1; i --)
		for(j = 1; j <= m; j ++)
			suf[i][j] = max(suf[i + 1][j], a[i][j]);
	for(i = 1; i <= n; i ++)
	{
		for(j = 1; j <= m; j ++)
			c[j] = 0;
		tot = 0;
		for(j = i; j <= n; j ++)
		{
			for(k = 1; k <= m; k ++)
				if (a[j][k] > c[k]) tot += a[j][k] - c[k], c[k] = a[j][k];
			ans = max(ans, tot - (d[j] - d[i]));
			int tt = 0;
			for(k = 1; k <= m; k ++)
				if (a[i][k] < c[k]) tt ++;
			if (tt == m) break;
			tt = 0;
			for(k = 1; k <= m; k ++)
				if (c[k] >= suf[j + 1][k]) tt ++;
			if (tt == m) break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8320
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0)break;    
        for(int i=0;i<H;i++){       
            for(int j=0;j<W;j++){
                if((i+j)%2==0){
                    cout<<"#";
                }else{cout<<".";}
                            
                }
            cout<<endl;
        }  
    cout<<endl;
    }
    return 0;
}   



Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int[] w = new int[n + 1];
		int[] e = new int[n + 1];
		e[0] = 0;
		for (int i = 1; i <= n; i++) {
			if (s[i-1] == 'E') {
				e[i] = e[i - 1] + 1;
			} else {
				e[i] = e[i - 1];
			}
		}
		w[n] = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (s[i] == 'W') {
				w[i] = w[i + 1] + 1;
			} else {
				w[i] = w[i + 1];
			}
		}
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < n + 1; i++) {
			max = Math.max(max, w[i] + e[i]);
		}
		System.out.println(n - max);
	}
}

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

    class Clazz {
	String name;
	int am, pm, sum;
	long money;

	Clazz(String n, int a, int p){
	    name = n;
	    am = a;
	    pm = p;
	    sum = am+pm;
	    money = am*200 + pm*300;
	}

	String show(){
	    return 
		name+" "+sum+" "+money;
	}
    }

    void run(){
	Clazz[] cl = new Clazz[9];
	int i=0;
	for(i=0; i<9; i++){
	    String s = sc.next();
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    cl[i] = new Clazz(s, a, b);
	}
	for(i=0; i<9; i++)
	    System.out.println(cl[i].show());
    }
}
	    

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

const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

  vector<ll> h(n, 0);

  for(int i = 0; i < n; i++){
    cin >> h[i];
  }

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

  for(int i = 1; i < n; i++){
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i != 1) {
      chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  }

  cout << dp[n - 1] << endl;

  return 0; 
}


Measured memory_bytes: 1792
n = int(input())
p = [0]*(n+1)

INF = 1000000000

for i in range(n):
    if i == 0:
        p[0],p[1] = map(int,input().split())
    else:
        tmp,p[i+1] = map(int,input().split())

dp = [[-1]*(n+2) for _ in range(n+2)]

def DFS(i,j):
    if dp[i][j] != -1:
        return dp[i][j]
    else:
        if j-i == 2:
            dp[i][j] = p[i]*p[i+1]*p[i+2]
            return dp[i][j]
        elif j-i == 1:
            dp[i][j] = 0
            return 0
        else:
            calculation_amount = INF
            for k in range(i+1,j):
                tmp = DFS(i,k) + DFS(k,j) + p[i]*p[j]*p[k] 
                calculation_amount = min(calculation_amount,tmp)
            dp[i][j] = calculation_amount
            return calculation_amount

print(DFS(0,n))


Measured memory_bytes: 5724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;


int main() {
	int H, W; cin >> H >> W;
	vector<string> t(H);
	vector<vector<int> > dp(H, vector<int>(W, -1));
	for (int i = 0; i < H; i++) cin >> t[i];
	int cnt = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cnt += t[i][j] == '.';
		}
	}
	vector<int> dx{ 1, 0, -1, 0 }, dy{ 0, 1, 0, -1 };
	deque<pair<int, int> > que;
	que.push_back({ 0, 0 });
	dp[0][0] = 1;
	while (!que.empty()) {
		auto p = que.front();
		que.pop_front();
		int x = p.first, y = p.second;
		if (x == H - 1 && y == W - 1) {
			cout << cnt - dp[x][y] << endl;
			return 0;
		}
		for (int i = 0; i < 4; i++) {
			if (!(0 <= x + dx[i] && x + dx[i] < H)) continue;
			if (!(0 <= y + dy[i] && y + dy[i] < W)) continue;
			if (t[x + dx[i]][y + dy[i]] != '.') continue;
			if (dp[x + dx[i]][y + dy[i]] != -1) continue;
			dp[x + dx[i]][y + dy[i]] = dp[x][y] + 1;
			que.push_back({ x + dx[i], y + dy[i] });
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 384
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let l = {
        let mut ws = s.split_whitespace();
        let l: i64 = ws.next().unwrap().parse().unwrap();
        l
    };

    println!("{}", (l as f64 / 3.0) * (l as f64 / 3.0) * (l as f64 / 3.0));
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, m = 0, k = 0, sum = 0, MASK = 0;
ll A[500000] = {}, B[500000] = {}, X[1500][13], rui[500000] = {}, dp[1 << 12] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = true, check2 = false;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	//Code Line
	cin >> n;
	for (int i = 0; i < n; i++)cin >> A[i];
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += A[i] * A[j];
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int r,l;
    l=a+b;
    r=c+d;

    if(l>r){
        cout << "Left" << endl;
    }else if(l<r){
        cout <<"Right"<<endl;
    }else {
        cout <<"Balanced"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),r=Number(t[0]),n=t[1].split(""),o=t[2].split(""),u=0,i="",f="",l=0;l<r;l++)(i=n[r-1-l]+i)==(f+=o[l])&&(u=l+1);var c=2*r-u;console.log(c)}},function(e,t){e.exports=require("fs")}]);

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

int main(){
    int N, sum=0, tmp=0;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
	cin >> a[i];
	sum += a[i];
    }

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

    for(int i=0; i<N; i++){
	if(a[i]%10!=0){
	    tmp=a[i];
	    break;
	}
    }

    if(sum%10!=0)
	cout << sum << endl;
    else
	cout << (tmp==0? 0: sum-tmp) << endl;
}




Measured memory_bytes: 256
//package Qf
import java.util.*
import java.math.*
import java.lang.Math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = {readLine()!!.toInt()}
private val readLong: ()->Long = {readLine()!!.toLong()}
private val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
private val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
private val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
private val MOD = 1e9.toLong()+7
private val INF = Int.MAX_VALUE/2
private val LINF = Long.MAX_VALUE/2


fun solveF(S: String, T: String): String {
    val N = S.length
    val M = T.length
    val dp = Array(N+1){IntArray(M+1){0}}

    for(i in 0 until N) {
        for (j in 0 until M) {
            if (T[j] == S[i]) {
                dp[i+1][j+1] = dp[i][j] + 1
            } else {
                if (dp[i][j+1] >= dp[i+1][j]) {
                    dp[i+1][j+1] = dp[i][j+1]
                } else {
                    dp[i+1][j+1] = dp[i+1][j]
                }
            }
        }
    }

    var i = N
    var j = M
    var res = ""
    while (0<i && 0<j) {
        if (dp[i][j] == dp[i-1][j]+1 && dp[i][j] == dp[i][j-1]+1) {
            res += S[i-1]
            i--
            j--
        } else if (dp[i][j] == dp[i-1][j]) {
            i--
        } else if (dp[i][j] == dp[i][j-1]) {
            j--
        }
    }

    return res.reversed()
}


fun main(args: Array<String>) {
    val S = readString()
    val T = readString()

    val ans = solveF(S, T)

    println(ans)
}


Measured memory_bytes: 98664
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto N = readln.chomp.to!(wchar[]);
    writeln(N[1] != N[2] ? "No" : N[0] == N[1] || N[2] == N[3] ? "Yes" : "No");

}

Measured memory_bytes: 256
//abc074.cpp
//Sat Sep  1 20:39:29 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,k;
	cin >> n >> k;

	int ans = 0;
	int x[n];
	for (int i=0;i<n;i++){
		cin >> x[i];
		if (x[i] < k-x[i]){
			ans += 2*x[i];
		}else {
			ans += 2*(k-x[i]);
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e9+7;
const ll N = 1002;
const ll M = 21;
ll n,a[N],q,m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	FOR(i,0,n)cin>>a[i];
	vector<ll> v;
	set <ll> s;
	s.insert(0);
	v.push_back(0);
	FOR(i,0,n){
		ll pp=v.size();
		FOR(j,0,pp){
			if(s.count(v[j]+a[i])==0){
				s.insert(v[j]+a[i]);
				v.push_back(v[j]+a[i]);
			}
		}
	}
	cin>>q;
	FOR(i,0,q){
		cin>>m;
		if(s.count(m)==1){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
using namespace std;
il int read() {
	int res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = (res<<3)+(res<<1)+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	int n; void main() {
		n = read(); if (n == (n&(-n))) {puts("No"); return;} puts("Yes"); printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n",1+n,1+n,2+n,2+n,3+n);
		rep(i,2,(n-1)>>1) printf("1 %d\n1 %d\n%d %d\n%d %d\n",i<<1,i<<1|1,i<<1|1,(i<<1)+n,i<<1,(i<<1|1)+n);
		if (!(n&1)) {rep(i,2,n) if (i != 3) {int x = n^i^1; if (x != 3 && x < n) {printf("%d %d\n%d %d\n",n,i,n<<1,x); break;}}}
	}
}
int main() {qiqi::main(); return 0;}

Measured memory_bytes: 2304
while True:
  h, w = map(int, input().split())
  if h == 0 and w == 0:
    break

  for i in range(h):
    for j in range(w):
      if i == 0 or i == h - 1 or j == 0 or j == w - 1:
        print("#", end = "")
      else:
        print(".", end = "")
    print()
  print()


Measured memory_bytes: 7008
import java.util.*;
import java.lang.*;
public class Main{

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		int total = 0;
		for( int i=0; i<M; i++ ){
			int a = sc.nextInt();
			total += a;
		}
		if( total<=N ){
			System.out.println(N-total);
		}else{
			System.out.println(-1);
		}
	}
}

Measured memory_bytes: 46264
import java.util.Scanner;
 
public class  Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
 
        if ((a < c && c < b) || (b < c && c < a)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define fi first
#define se second
using ii = pair<int, int>;

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

	string s1; cin >> s1;
	double t1, l1; cin >> t1 >> l1;
	string s2; cin >> s2;
	double t2, l2; cin >> t2 >> l2;
	auto calc = [](double t, double l, string s) {
		t = t * M_PI / 180;
		double w = sin(t) / sin(M_PI * 2 / 3 - t);
		l = l * sin(M_PI * 2 / 3 - t) / sin(M_PI / 3);
		int x = (1 - w) * l;
		int y = w * l;
		x = abs(x) % 2;
		y = abs(y) % 2;
		int z = abs((int)l) % 2;
		int val = -1;
		if (x == 0) {
			if (y == 0) val = z;
			else if (y == 1) val = z + 2;
		} else if (x == 1) {
			if (y == 0) val = 3 - z;
			else if (y == 1) val = 1-z;
		} else assert(0);
		assert(val != -1);
		vector<int> bc = {3, 0, 2, 1};
		vector<int> cd = {1, 0, 3, 2};
		vector<int> db = {2, 0, 1, 3};
		if (s == "BC") return bc[val];
		else if (s == "CD") return cd[val];
		else if (s == "DB") return db[val];
		else assert(0);
	};
	bool ok = calc(t1, l1, s1) == calc(t2, l2, s2);
	cout << (ok ? "YES" : "NO") << endl;
}


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

left = 1
right= max(A)

import math

dict_X = {}
while True:
  
  cl = 0
  for i in range(N):
    cl += math.ceil(A[i]/left) - 1
  cr = 0
  for i in range(N):
    cr += math.ceil(A[i]/right) - 1
  
  mid = (left + right)//2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  if(cl<=K):
    right = left
    break
  elif(cm<=K):
    right = mid
  else:
    left = mid
  
  if(left>=right-1):
    break
    
print(right)
 
  
    
    














Measured memory_bytes: 104416
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<cmath>

using namespace std;

//int mod_num_counter[2030];

int main()
{
  //fill(mod_num_counter,mod_num_counter+2030,0);
  
  long long x;
  cin >> x;
  
  long long a,b;
  long long diff;
  bool end = false;
  for(a=0;a<1000;a++)
  {
    long long a2 = a*a;
    long long a5 =a2*a2*a;
    diff = (x-a5);

    for(b=0;b<1000;b++)
    {
      long long b2 = b*b;
      long long b5 = b2*b2*b;
      if(diff >= 0 && diff == b5) end=true;
      if(diff <0 && diff == -b5) end = true;
      if(end) break;
    }
    if(end) break;
  }
  
  if(diff>0) b=-b;
  
        cout << a << " " << b << endl;
    
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n;
char march[] = {'M', 'A', 'R', 'C', 'H'};
int cnt[] = {0, 0, 0, 0, 0};

int main(){
    cin >> n;

    for (int i = 0; i < n; ++i) {
        string name;
        cin >> name;
        for (int k = 0; k < 5; ++k) {
            if (name[0] == march[k]) {
                cnt[k]++;
            }
        }
    }

    long long ans = 0;

    int bit = 0;
    while (bit < 32) {
        int c = 0;
        for (int i = 0; i < 5; ++i) {
            c += (bit >> i) & 1;
        }
        if (c == 3) {
            long long tmp = 1;
            for (int i = 0; i < 5; ++i) {
                if ((bit >> i) & 1) tmp *= cnt[i];
            }
            ans += tmp;
        }
        bit++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
const int LN = 60;
int n;
int x[N];
int m;
long long k;
int a;
int p[LN][N];
int res[N];
long long ans;
int main(){
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , x + i);
        p[0][i] = i;
    }
    scanf("%d %lld" , &m , &k);
    for(int i = 1 ; i <= m ; ++i){
        scanf("%d" , &a);
        swap(p[0][a] , p[0][a + 1]);
    }
    for(int i = 1 ; i < LN ; ++i){
        for(int j = 1 ; j <= n ; ++j){
            p[i][j] = p[i - 1][p[i - 1][j]];
        }
    }
    for(int i = 1 ; i <= n ; ++i){
        int res = i;
        for(int j = 0 ; j < LN ; ++j){
            if(k & (1LL << j)){
                res = p[j][res];
            }
        }
        ::res[i] = res;
    }
    for(int i = 1 ; i <= n ; ++i){
        ans += x[res[i]] - x[res[i] - 1];
        printf("%lld\n" , ans);
    }
}

Measured memory_bytes: 25472
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <bitset>
#include <time.h>
#include <numeric>
using namespace std;
 
#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define test(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
void fast_io()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
#endif
}

void sol()
{
	string s; cin>>s;
	int n=s.length();
	if(s[n-1]=='s')
	{
		s+="es";
	}
	else
		s+='s';
	cout<<s;
	
}
int32_t main()
{
	fast_io();
	//test(t)
	sol();
	//cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int a,b,k;
  cin>>a>>b>>k;
  for(Int i=a;i<=min(a+k-1,b);i++) cout<<i<<endl;
  for(Int i=max(a+k,b-k+1);i<=b;i++) cout<<i<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,x,t; cin>>n>>x>>t;
    int time = (n+x-1)/x;
    cout << t *time << '\n';
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

int next(int N)
{
    string S = to_string(N), L;

    while (S.size() < 4)
        S = "0" + S;

    sort(ALL(S));

    REP(i, 4)
    L += S[3 - i];

    return stoi(L) - stoi(S);
}

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

    int N;

    while (cin >> N, N)
    {
        int ans = 0;

        for (;;)
        {
            if (N % 1111 == 0)
            {
                cout << "NA" << endl;
                break;
            }
            else if (N == 6174)
            {
                cout << ans << endl;
                break; 
            }

            N = next(N);

            ans++;
        }
    }

    return 0;
}


Measured memory_bytes: 3232
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn pow_mod(x: u64, y: u64, mm: u64) -> u64{
    let mut ans = 1;
    for _ in 0..y{
        ans *= x;
        ans %= mm;
    }

    return ans;
}

fn main(){
    let n: usize = read_as_vec()[0];
    let d = read_as_vec::<usize>();
    let mm: u64 = 998244353;
    let mut count_table = vec![0;*d.iter().max().unwrap()+1];

    for i in 0..n{
        if i == 0 && d[i] != 0{
            println!("0");
            return;
        }

        if i != 0 && d[i] == 0{
            println!("0");
            return;
        }

        count_table[d[i]] += 1;
    }

    //if found zero
    if count_table.iter().any(|x| *x == 0){
        println!("0");
        return;
    }


    let mut ans = 1;
    for i in 1..count_table.len(){
        ans *= pow_mod(count_table[i-1], count_table[i], mm);
        ans %= mm;
    }

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


Measured memory_bytes: 6524
#include <iostream>
#include <string>
#define rep(i, n)for(int i=0; i<n; i++)
using namespace std;

int main(){
    string s;
    cin >> s;
    int num=0, ans=0;

    rep(i, s.size()){
        bool can = false;
        if(s[i]=='A')can = true;
        if(s[i]=='C')can = true;
        if(s[i]=='G')can = true;
        if(s[i]=='T')can = true;

        if(can){
            num++;
            if(num>ans) ans = num;
        }
        else num = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(long long i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
 
 
 
struct Edge{
    ll to;
    ll id;
    Edge(ll a, ll b):to(a), id(b){};
};
 
vector<Edge> g[55];
vector<ll> es;
 
bool dfs(ll v, ll tv, int p = -1)
{
    if (p==-1) es = vector<ll> ();
    if (v==tv) {
        return true;
    }
    for (Edge e: g[v]) {
        if (e.to==p) continue;
        if (dfs(e.to, tv, v)) {
            es.emplace_back(e.id);
            return true;
        }
    }
    return false;
}
 
int main(){
    ll n, m;
    cin >> n;
    rep (i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }
    cin >> m;
    vector<ll> eset(m);
    rep (i, m) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        dfs(a, b);
        for (ll e: es) {
            eset[i] |= (1LL << e);
        }
    }
    ll ans = 0;
    rep (i, 1LL<<m) {
        ll mask = 0;
        rep (j, m) {
            if (i>>j & 1) {
                mask |= eset[j];
            }
        }
        ll white = __builtin_popcountll(mask);
        ll now = 1LL << (n-1-white);
        if (__builtin_popcountll(i)%2==0) ans += now;
        else ans -= now;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
k=gets.to_i
if k<10
  puts k
  exit
end
lunlun=(1..9).to_a
k-=9
while true
  ans=[]
  lunlun.each do |lun|
    one=lun%10
    ans.push(lun*10+one-1) if one!=0
    ans.push(lun*10+one)
    ans.push(lun*10+one+1) if one!=9
  end
  if k<=ans.size
    puts ans[k-1]
    break
  end
  lunlun=ans
  k-=ans.size
end


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int a,b,x,flag=1;
    cin>>a>>b;
    for (x=1;x<1251;x++)
    {
        if(floor(x*0.08)==a && floor(x*0.1)==b)
        {
            flag=0;
            cout<<x;
            break;
        }
    }
    if(flag==1) cout<<-1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b, c;
	cin >> a >> b >> c;

	if (a <= c && c <= a + b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << 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();
        }

        long yen = 1000;
        for (int i = 0; i < n - 1; i++) {
            if (a[i] < a[i + 1]) {
                yen += (a[i + 1] - a[i]) * (yen / a[i]);
            }
        }
        System.out.println(yen);
    }

}


Measured memory_bytes: 35720
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

int n;
ll a, b;
vector<int> h;

bool isEnough(ll num) {
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		if (h[i] > b* num) {
			cnt += (h[i] - b * num) / (a - b);
			if ((h[i] - b * num) % (a - b) != 0) {
				cnt++;
			}
		}
	}

	return cnt <= num;
}

int main() {

	
	cin >> n >> a >> b;

	h = vector<int>(n);
	for (int i = 0; i < n;i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());

	int l = 0;
	int r = h[n - 1] / b;
	if (h[n - 1] % b != 0) {
		r++;
	}

	int mid = (l + r) / 2;
	while (mid !=l) {
		if (isEnough(mid)) {
			r = mid;
		}
		else {
			l = mid;
		}

		mid = (l + r) / 2;
	}
	cout << r << endl;

}



Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    void solve(){
        int n;
        cin>>n;
        int sum=0; 
        for(int u=0;u<n;u++){
            int x;
            cin>>x;
            sum+=x-1;
        }
        cout<<sum;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new  Solver())->solve();
}

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

using namespace std;

int main() {
	int n, a[100010], ans = 0, batas;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) {
		batas = i;
		while (batas + 1 < n) {
			if (a[batas + 1] > a[batas])
				break;
			batas++;
		}
		ans = max(ans, batas - i);
		i = batas;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640