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

int main(){
    map<string, int> m;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;

    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        m[s] += 1;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

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

int main() {
  int N, K ;
  cin >> N >> K;
  
  double ans = 0;
  for (int i = 1; i < N+1; ++i) {
    int score = i;
    double prob_loop = 1.0;
    while(score <= K-1) {
      prob_loop *= 1.0 / 2.0;
      score *= 2;
    }
    prob_loop *= 1.0 / (double)N;
    ans += prob_loop;
  }
  cout << fixed << setprecision(12) << ans << endl;
}

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

#define int long long 

using namespace std;

signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  if (n == 1) {
    if (a == b) {
      ans = 1;
    } else {
      ans = 0;
    }
  }
  if (a > b) {
    ans = 0;
  }
  
  ans = max(0LL, (b - a) * (n - 2) + 1);

  cout << ans  << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int pasta, drink;
	int i, min_p, min_d;
	
	min_p = 3000;
	min_d = 3000;
	
	for (i = 0; i < 3; i++){
		scanf("%d", &pasta);
		
		if (min_p > pasta){
			min_p = pasta;
		}
	}
	
	for (i = 0; i < 2; i++){
		scanf("%d", &drink);
		if (min_d > drink){
			min_d = drink;
		}
	}
	
	printf("%d\n", min_d + min_p - 50);
	
	return (0);
}
	
	

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
#define countbits __builtin_popcount
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
int n,a[100005],cnt[3];
int main() {
	n=readint();
	rep(i,1,n) a[i]=readint();
	rep(i,1,n) {
		if (a[i]%4==0) cnt[2]++;
		else if (a[i]%2==0) cnt[1]++;
		else cnt[0]++;
	}
	if (cnt[0]>0) cnt[0]--;
	if (cnt[2]<cnt[0]) {
		printstr("No");return 0;
	}
	if ((cnt[1]&1)&&!(cnt[2]-cnt[0])) {
		printstr("No");return 0;
	}
	printstr("Yes");
	return 0;
}


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

const long long MOD = 1000000007;

int main() {
    long long n, result = 1;
    string s;
    cin >> n >> s;
    map<char, long long> count;
    for (char c : s) {
        count[c]++;
    }
    for (auto& p : count) {
        result = result * (p.second + 1) % MOD;
    }
    cout << (result - 1 + MOD) % MOD;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll x,n;
 cin>>x>>n;
 vector<ll> a(n);
 for(ll i=0;i<n;i++)cin>>a[i];
 set<ll> e;
 for(ll i=0;i<n;i++)e.insert(a[i]);
 //vector<mp> b(n);
 //for(ll i=0;i<n;i++) b[i] = mp( abs( a[i]-x ) , a[i] );
 //sort(b.begin() , b.end() );
 //cout<<b[0].second<<endl;
 ll l=0;

 while(1){
  if( e.find( x - l ) == e.end() ){
   cout<<x-l<<endl;
   break;
  }
  if( e.find( x + l ) == e.end() ){
   cout<<x+l<<endl;
   break;
  }
  l++;
 }
 return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    map<ll, ll> m;
    rep(i, n) {
        ll a; cin >> a;
        m[a]++;
    }
    ll ans = 0;
    for(auto x : m) {
        if(x.second >= x.first) ans += x.second - x.first;
        else ans += x.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9604
#include<stdio.h>
#include<string.h>

int main(int argc, char *argv[])
{
  int m, f, r, i;
  char ans[1000];

  m = f = r = 0;
  memset(ans, 0x00, 1000);

  for (i = 0; ;i++) {
    scanf("%d %d %d", &m, &f, &r);

  if (m == -1 && f == -1 && r == -1)
    break;

   if (m == -1 || f == -1)
      ans[i] = 'F';
    else if ((m +f) >= 80)
      ans[i] = 'A';
    else if ((m + f) >= 65)
      ans[i] = 'B';
    else if ((m + f) >= 50)
      ans[i] = 'C';
    else if ((m + f) >= 30)
      if (r >= 50)
        ans[i] = 'C';
      else
	ans[i] = 'D';
    else
      ans[i] = 'F';
  }

  for (i = 0; ans[i] != 0; i++) {
    printf("%C\n", ans[i]);
  }

  return 0;
}

Measured memory_bytes: 608
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def slv2(N, K, A):
    ans = (-1, -1)
    for k in range(K+1):
        tmp = 0
        for a in A:
            tmp += k ^ a
            # print(k, k ^ a)
        if ans[0] < tmp:
            ans = (tmp, k)
    
    # print(ans)
    return ans[0]


@mt
def slv(N, K, A):

    @lru_cache(maxsize=None)
    def ai(i):
        ii = 1 << i
        c = 0
        for a in A:
            if a & ii > 0:
                c += 1
        return c, ii

    @lru_cache(maxsize=None)
    def a(i):
        if i < 0:
            return 0
        c, ii = ai(i)
        return max(ii*(N-c), ii*c) + a(i-1)

    
    def r(k, i):
        if i < 0:
            return 0
        
        c, ii = ai(i)
        
        if k < ii:
            return r(k, i-1)+ii*(c)
        
        return max(r(k-ii, i-1)+ii*(N-c), a(i-1)+ii*(c))
    
    return r(K, 40)

def main():
    N, K = read_int_n()
    A = read_int_n() 
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 17008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int p[100500];
int gcd(int x,int y) {
    if(!y)
    return x;
    else
    return gcd(y,x%y);
}
int main() {
    int n,s,res,ans;
    cin>>n>>s;
    p[0]=s;
    for(int i=1;i<=n;i++)
      scanf("%d",&p[i]);
    sort(p,p+n+1);
    res=p[1]-p[0];
    for(int i=1;i<n;i++)
        {
            ans=p[i+1]-p[i];
            res=gcd(ans,res);
        }
    cout<<res<<endl; 

}

Measured memory_bytes: 640
//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include<bits/stdc++.h>
using namespace std;

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 1e5+7;

int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,x,y,z,u,v;
    string s;
    cin>>s;
    if(s[sz(s)-1]!='s')
    {
        cout<<s<<"s"<<endl;
    }
    else
    {
        cout<<s<<"es"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3624
r,g,b,n=map(int,input().split())
rr=0
ans=0
while rr*r<=n:
    gg=0
    while rr*r+gg*g<=n:
        if (n-(rr*r+gg*g))%b == 0:
            ans+=1
        gg+=1
    rr+=1
print(ans)

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

int main(){
  int n;
  cin >> n;
  bool ans=false;
  for(int i=0;i<=n/4;i++){
    if((n-i*4)%7==0){
      cout << "Yes" << endl;
      ans=true;
      break;
    }
  }
  if(!ans){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n;
  string s,ss,sss;
  cin>>s>>ss;
  cout<<ss<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
long long int max(long long int a,long long int b){
	if(a<b)return b;
	else return a;
}
int main(){
	long long int n,k;
	scanf("%lld%lld",&n,&k);
	long long int ans=0;
	for(int i=k+1;i<=n;i++){
		ans+=(n/i)*(i-k)+max((n%i)-k+1,0);
	}
	if(k==0)ans=n*n;
	printf("%lld\n",ans);
	return 0;
}

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

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

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = ll(b) - 1; i >= (a); i--)
#define TR(X)                                                  \
    ({                                                         \
        if (1) cerr << "TR: " << (#X) << " = " << (X) << endl; \
    })
#define LL(name) \
    ll name;     \
    cin >> name;
#define VL(name, num) \
    vl name(num);     \
    FOR(INPUT_VL_I, 0, num) { cin >> name[INPUT_VL_I]; }

int main() {
    cin.sync_with_stdio(0);
    LL(K);
    string S;
    cin >> S;

    FOR(i, 0, min(K, sz(S))) { cout << S[i]; }

    if (sz(S) > K) {
        cout << "...";
    }
    cout << endl;
}  // cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int n, k;
int ans = 1;
int main () {
    ios::sync_with_stdio(false);
    
    cin >> n >> k;
    
    if (n == 1) {
        cout << k << endl;
        return 0;
    }
    ans = k;
    for (int i =2; i <=n; i++)
        ans *= (k-1);
    
    cout << ans;
    
    
    return 0;
}


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

V = []
for i, v in enumerate(A):
    V.append((v, i))

V.sort()

s = ""
for v in V:
    if len(s) > 0:
        s += " "
    s += str(v[1] + 1)

print(s)

Measured memory_bytes: 23352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;

    vector <int> v;
    v.push_back(a+b);
    v.push_back(a-b);
    v.push_back(a*b);

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

    cout << v[2] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    int w, h;
    while (cin >> w >> h, w | h) {
        vector<vector<int> > map(h, vector<int>(w));
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> map[i][j];
            }
        }

        // bfs
        int islandCount = 0;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                queue<pair<int, int> > que;
                if (map[i][j] != 1) {
                    continue;
                }
                ++islandCount;
                que.push({i, j});
                while (!que.empty()) {
                    pair<int, int> p = que.front(); que.pop();
                    if (map[p.first][p.second] == -1) {
                        continue;
                    }
                    map[p.first][p.second] = -1;
                    for (int k = -1; k < 2; ++k) {
                        for (int l = -1; l < 2; ++l) {
                            if ((k | l) == 0) {
                                continue;
                            }
                            int ny = p.first + k;
                            int nx = p.second + l;
                            if (0 <= nx && nx < w &&
                                    0 <= ny && ny < h) {
                                if (map[ny][nx] == 1) {
                                    que.push({ny, nx});
                                }
                            }
                        }
                    }
                }
            }
        }
        cout << islandCount << endl;
    }

    return 0;
}

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

int getLength(string s){
  while (1) {
    s.pop_back();
    s.pop_back();
    int len = (int)s.length()/2;
    for (int i = 0; i < len; i++) {
      if (s[i] != s[len + i]) {
	break;
      }

      if (i + 1 == len) {
	return len * 2;
      }
    }
  }
}

int main()
{
  string s;
  cin >> s;
  cout << getLength(s) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D ;
  cin >> A >> B >> C >> D;
 
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
    else if(A+B < C+D) {
      cout << "Right" << endl;
    }
  else {
    cout << "Balanced" << endl;
  }
}

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

const int INF = 1<<28;
const int MAXH = 1001;
const int MAXW = 1001;
const int MAXN = 1000006;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};

struct State {
  int pi, pj, d, step;
  bool operator < (const State &s) const {
    return step > s.step;
  }
};

int H, W, N;
char G[MAXH][MAXW];
string S;
int cost[MAXH][MAXW][4];
int mem[MAXN][4];

int minStep(int index, int dd) {
  int &res = mem[index][dd];
  if(res != -1) return res;
  if(dd == 0) return res = 0;
  if(index == N) return res = INF;
  return res = 1 + minStep(index+1,
                           (dd - (S[index] == 'R' ? 1 : -1) + 4) % 4);
}

int dijkstra(int si, int sj, int gi, int gj) {
  memset(mem, -1, sizeof(mem));
  priority_queue<State> que;
  fill(cost[0][0], cost[MAXH][0], INF);
  cost[si][sj][3] = 0;
  que.push((State){si, sj, 3, 0});
  while(que.size()) {
    const State s = que.top();
    que.pop();
    do { // forward
      State t = {s.pi + di[s.d], s.pj + dj[s.d], s.d, s.step};
      if(t.pi < 0 || t.pi >= H) break;
      if(t.pj < 0 || t.pj >= W) break;
      if(G[t.pi][t.pj] == '#') break;
      if(cost[t.pi][t.pj][t.d] <= t.step) break;
      if(t.pi == gi && t.pj == gj) return true;
      cost[t.pi][t.pj][t.d] = t.step;
      que.push(t);
    } while(0);

    // turn
    for(int nd = 0; nd < 4; ++nd) {
      if(nd == s.d) continue;
      State t = {s.pi, s.pj, nd, s.step + minStep(s.step, (nd-s.d+4)%4)};
      if(cost[t.pi][t.pj][t.d] <= t.step) continue;
      cost[t.pi][t.pj][t.d] = t.step;
      que.push(t);
    }
  }
  return INF;
}

int main() {
  while(cin >> H >> W >> N && (H|W|N)) {
    cin >> S;
    int si, sj, gi, gj;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
        if(G[i][j] == 'S') {
          si = i; sj = j;
        }
        if(G[i][j] == 'G') {
          gi = i; gj = j;
        }
      }
    }
    if(dijkstra(si, sj, gi, gj) != INF) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 39580
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//The Oldest Site
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int M = 30000;
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			Set<Integer> set = new HashSet<Integer>();
			int[][] p = new int[n][2];
			for(int i=0;i<n;i++){
				for(int j=0;j<2;j++)p[i][j]=sc.nextInt()+10000;
				set.add(p[i][1]*M+p[i][0]);
			}
			int max = 0;
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					int dx = p[j][0]-p[i][0];
					int dy = p[j][1]-p[i][1];
					if(set.contains((p[i][1]+dx)*M+p[i][0]-dy)&&set.contains((p[j][1]+dx)*M+p[j][0]-dy)||
							set.contains((p[i][1]-dx)*M+p[i][0]+dy)&&set.contains((p[j][1]-dx)*M+p[j][0]+dy)){
//						System.out.println("I:" + i + " J:" + j + " DX:" + dx + " DY:" + dy);
						max = Math.max(max, dx*dx+dy*dy);
					}
				}
			}
			System.out.println(max);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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


void main() {
    int a, b;
    scan(a, b);
    writeln(max(a + b, a - b, a * b));
}





































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

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



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


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


int main ()
{
	
	int j;
	int batu[250][3]={{}},kad[250][3]={{}},ten[250]={};
	
	cin>>j;
	for(int i=0;i<j;i++)
	{
		for(int q=0;q<3;q++)
		{
			cin>>kad[i][q];
			batu[kad[i][q]][q]+=1;
		}
	}
	for(int i=0;i<j;i++)
	{
		for(int q=0;q<3;q++)
		{
			if(batu[kad[i][q]][q]==1)ten[i]+=kad[i][q];
			
		}
		cout<<ten[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        out.println(a*b/2);
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n,a,b,c,d,e ;
 cin >>n>>a>>b>>c>>d>>e  ;
ll x=min(a,min(b,min(c,min(d,e)))) ;

 cout <<4+(n+x-1)/x<<endl ;
     return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli sum=0,pos=0;
    string s;
    lli i,j=0;
    cin>>s;
    rep(i,0,s.size()){
        if(s[i]=='W'){
            sum+=i-pos;
            pos++;
        }
    }
    cout<<sum<<endl;
}


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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555555555555555555555555555555555555455555555555555555555555555555555555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
// 2020-08-22 21:02:26
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  string s;
  cin >> s;
  int cur = 0;
  rep(i, s.size()) {
    cur += s[i] - '0';
    cur %= 9;
  }
  string ans = "Yes";
  if(cur > 0) ans = "No";
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
const int64_t MOD = 1000000007;

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

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

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

int main()
{
  int64_t N, a, first = 0, second = 0;
  cin >> N;
  vector<int> exists(N + 1, -1);
  for (int i = 0; i <= N; i++)
  {
    cin >> a;
    if (exists[a] != -1)
    {
      first = exists[a];
      second = i;
    }
    else
    {
      exists[a] = i;
    }
  }
  initCombination();
  for (int i = 1; i <= N + 1; i++)
  {
    int64_t r = first + (N - second);
    int64_t c = nCk(N + 1, i);
    if (r >= i - 1)
    {
      c -= nCk(r, i - 1);
      (c += MOD) %= MOD;
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 6020
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

const long long MOD = 1000000007;

int main(){
	int n;
	long long x;
	cin >> n >> x;
	vector<int> a(n);
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	sort(a.begin(),a.end());
	
	for(int i=0;i<n;i++){
		x-=a[i];
		if(x==0){
			cout << i+1 << endl;
			return 0;
		}
		if(x<0){
			cout << i << endl;
			return 0;
		}
	}
	
	cout << n-1 << endl;
	
	return 0;
}


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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define pmod 1000000007
#define maxn 100005
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
ll a[1005];
bool c[8000000];
ll e[500005];

ll prime(long long m, ll n, int u){
if (n<m) cout<<n+m<<endl;
else{
    ll j=0;
    //memset(c,0,sizeof(c));
    //FOR (i,0,m-1) c[i]=0;
    //ll u=m;
    while (j<=n){
    if (c[m]==0){
    for(ll i=1; i*m<=7368792;i++){
        c[i*m]=1;
    }
    j++;
    //cout<<m<<" ";
    if (u==0 ) e[j-1]=m;
    }
    //cout<<c[m]<<" ";

    m++;
    }
  //  cout<<j<<endl;
  //return (j-50051);
 if (u!=0) cout<<m-1<<endl;


}
}
int t;
int d[101]={0,0,0,0,1,1,3,3,6,6,7,7,11,11,16,16,17,17,23,23,30,30,31,31,39,39,41,41,42,42,51,51,61,61,62,62,64,64,75,75,76,76,88,88,101,101,102,102,116,116,119,119,120,120,135,135,137,137,138,138,154,154,171,171,172,172,174,174,192,192,193,193,212,212,232,232,233,233,236,236,257,257,258,258,280,280,282,282,283,283,306,306,309,309,310,310,312,312,336,336,337};
int main()
{ll m=1;ll n;
prime (2,500000,0);

while (1){
    //memset(c,0,sizeof(c));
    cin>>m>>n;
    t=1;
//FOR (m,2,100)  cout<<prime(m,n)<<",";
if (m==0) return 0;
if (n<=20000){

//return 0;
memset(c,0,1000000);
    prime(m,n,1);
}

else{
    pf("%ld\n",e[n-d[m]]);
}

}

         return 0;
}

Measured memory_bytes: 14244
#include<iostream>
#include<algorithm>
#define MAX_M 101
#define MAX_N 301
#define MAX_K 201
#define MAX_INT 1 << 28;
using namespace std;

//dx[wa][wb][XCb`(0:àz, 1:Ô)] = (waÆwbÔÌàz or Ô)
int dx[MAX_N][MAX_N][2];

//p©çqÜÅÌÅ¬àzÜ½ÍÅZÔðÔ·
int tell(int p, int q, int n, int m, int r);

int main(){
	//n = üHÌîñÌ, m = wÌ
	int n, m;
	
	//üHÌîñðüÍ
	while(cin >>n >>m){
		if(n == 0 && m == 0) break;
		
		//dx[][][]Ìú»(SÄ-1É·é)
		for(int i = 0; i < MAX_N; i++){
			for(int j = 0; j < MAX_N; j++){
				dx[i][j][0] = -1;
				dx[i][j][1] = -1;
			}
		}
		
		for(int i = 0; i < n; i++){
			
			//a = wa, b = wb, cost = wa`wbÌàz, time = wa`wbÌÔ
			int a, b, cost, time;
			
			cin >>a >>b >>cost >>time;
			dx[a][b][0] = cost;
			dx[a][b][1] = time;
		}
		
		//k = â¢í¹Ì
		int k;
		
		cin >>k;
		for(int i = 0; i < k; i++){
			
			//p = o­w, q = w, r = oÍ·élÌíÞ
			int p, q, r;
			cin >>p >>q >>r;
			
			cout <<tell(p, q, n, m, r) <<endl;
		}
	}
	return 0;
}

int tell(int p, int q, int n, int m, int r){
	
	//checkendnum[wÌÔ] = Å¬àzÜ½ÍÅZÔ(¢mèÌêÍMAX_INT)
	int checkendnum[MAX_N];
	
	//checkendi[wÌÔ] = Å¬àzÜ½ÍÅZÔªmèµ½©Ç¤©(false:¢mè, true:mè)
	bool checkendi[MAX_N] = {false};
	
	//checkendnum[1 ` MAX_N]ðMAX_INTÅú»
	for(int i = 0; i < MAX_N; i++){
		checkendnum[i] = MAX_INT;
	}
	
	//p = ¡²×Ä¢ém[h
	int node = p;
	
	//o­wÍà¤0ÅmèµÄ¢é
	checkendnum[node] = 0;
	checkendi[node] = true;
	
	//EoðÍmè³ê½m[h = q
	while(1){
		
		//SÄÌüHÌîñð²×é
		for(int i = 0; i < MAX_N; i++){
			
			//p©çiÉs­àzÜ½ÍÔÌîñª èA»êªmèµÄ¢È¯êÎ
			if(dx[node][i][r] != -1){
				if(checkendi[i] == false){
					
					//¡ÜÅiÌm[hÉüÁÄ¢½óâÌîñÆAVµ­XV³êéûÌA¬³¢ûðóâÆ·é
					checkendnum[i] = min(checkendnum[i], (dx[node][i][r] + checkendnum[node]));
				}
			
			//àµ­ÍAp©çiÉs­àzÜ½ÍÔÌîñª èA»êªmèµÄ¢È¯êÎ
			} else if(dx[i][node][r] != -1){
				if(checkendi[i] == false){
					
					//¡ÜÅiÌm[hÉüÁÄ¢½îñÆAVµ­XV³êéûÌA¬³¢ûðóâÆ·é
					checkendnum[i] = min(checkendnum[i], (dx[i][node][r] + checkendnum[node]));
				}
			}
		}
		
		//minnum = mèµÄ¢È¢wÌÅAÅ¬ÌàzÜ½ÍÅZÌÔ, mini = minnumðÂwÌÔ
		int minnum = MAX_INT;
		int mini = -1;
		
		//SÄÌwð²×é
		for(int i = 1; i <= m; i++){
			
			//àzÜ½ÍÔªmèµÄ¨ç¸Aminnumæè¬³¢àzÜ½ÍÔðÂÈç
			if(checkendi[i] == false && checkendnum[i] < minnum){
				minnum = checkendnum[i];
				mini = i;
			}
		}
		
		//miniÌwÌàzÜ½ÍÔðmè
		checkendi[mini] = true;
		
		//Ì²×ém[hðminiÉ·é
		node = mini;
		
		//qÌÅ¬àzÜ½ÍÅZÔªmèµ½ÈçI¹(I¹ð)
		if(checkendi[q] == true){
			break;
		}
	}
	return checkendnum[q];
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    long long int n,a[110],cost[300]={},ans=100000000;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=-100;i<101;i++){
        for(int j=0;j<n;j++){
            cost[i+100]+=(a[j]-i)*(a[j]-i);
        }
        if(cost[i+100]<ans)ans=cost[i+100];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	H := sc.NextInt()
	W := sc.NextInt()
	h := sc.NextInt()
	w := sc.NextInt()
	fmt.Printf("%+v\n", (H-h)*(W-w)) // output for debug
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int comb(int n, int k) {
    int r = 1;
    for (int d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main(){
    int N, M;
    cin >> N >> M;
    int a = comb(N, 2), b = comb(M, 2);
    cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <string>

using namespace std;

int n, m;
string s, t;

int gcd(int a, int b) {
	if (a%b == 0)
		return b;

	return gcd(b, a%b);
}

int main() {

	cin >> n >> m;
	cin >> s >> t;

	long long len = n;
	len = len * m;

	int g = gcd(n, m);

	len /= g;

	int a = len/n, b = len/m;

	bool flag = true;
	long long idx1 = 0, idx2 = 0;
	int count1 = 0, count2 = 0;
	while (idx1 < len && idx2 < len) {
		if (idx1 == idx2)
		{
			if (s[count1] != t[count2])
			{
				flag = false;
				break;
			}

			idx1 += a;
			idx2 += b;

			++count1;
			++count2;
		} else 
			if (idx1 < idx2)
			{
				idx1 += a;
				++count1;
			}
			else
			{
				idx2 += b;
				++count2;
			}
	}

	if (flag)
		cout << len << endl;
	else
		cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 512
program irreversible_operation
  implicit none
  character(len=200000) :: s
  integer               :: i, n
  integer(8)            :: b, a
  read(*,*) s
  n = len_trim(s)
  a = 0
  b = 0
  do i = 1, n
     if (s(i:i) .eq. 'B') then
        b = b + 1
     else
        a = a + b
     end if
  end do
  write(*,'(i0)') a
  stop
end program irreversible_operation

Measured memory_bytes: 1468
def fib(x):
  a = 1
  b = 1
  if x == 0:
    return 0
  elif x == 1:
    return a
  elif x == 2:
    return b
  else:
    for i in range(x-2):
      c = a + b
      a = b
      b = c
    return b 
n,m = map(int, input().split())
A = [int(input()) for i in range(m)]
if m >= 1:
  c = fib(A[0])
  for i in range(m-1):
    c *= fib(A[i+1] - A[i] - 1)
  c*= fib(n - A[m-1])
  print(c%1000000007)
else:
  print(fib(n+1)%1000000007)

Measured memory_bytes: 7080
#include <cstdio>
#include <algorithm>

using namespace std;

typedef struct {
	int m;
	int a, b;
}PASSER;

bool cmp(const PASSER &a, const PASSER &b)
{
	return a.a < b.a;
}

int main()
{
	int n;
	
	while (scanf("%d", &n), n != 0){
		PASSER pa[110];
		bool flag = true;
		
		
		for (int i = 0; i < n; i++){
			scanf("%d %d %d", &pa[i].m, &pa[i].a, &pa[i].b);
		}
		
		int sum = 0;
		sort(pa, pa + n, cmp);
		
		for (int i = 0; i < n; i++){
			sum += pa[i].m;
			int j = i;
			while (j-- > 0){
				if (pa[i].a >= pa[j].b){
					sum -= pa[j].m;
					pa[j].m = 0;
				}
			}
			//printf(" %d\n", sum);
			if (sum > 150){
				flag = false;
			}
		}
		
		if(flag){
			puts("OK");
		}
		else{
			puts("NG");
		}
	}
}

Measured memory_bytes: 1032
// https://atcoder.jp/contests/arc069/tasks/arc069_b
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
const int MAXN = 1e5 + 4;
char s[MAXN];

int main() {
    int n;
    cin >> n;
    cin >> s;
    s[n] = s[0], s[n + 1] = s[1];
    bitset<100005> a;
    REP(i, 4) {
        a[0] = i & 1, a[1] = (i >> 1) & 1;
        FOR(j, 2, n + 2) a[j] = (s[j - 1] == 'x') ^ a[j - 1] ^ a[j - 2];
        if (a[0] == a[n] && a[1] == a[n + 1]) {
            REP(j, n) { cout << (a[j] ? "W" : "S"); }
            cout << "\n";
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define mid (l+r>>1)
#define lc k<<1
#define rc k<<1|1
using namespace std;
const int N=2e6+10,mod=1e9+7;
typedef long long ll;
typedef double db;

int x[7],y[7],frc[N],nv[N];
int ans,Ax,Ay,Bx,By;
vector<int>f[4],g[4];

inline void ad(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void dc(int &x,int y){x-=y;if(x<0) x+=mod;}

inline int C(int n,int m)
{return (ll)frc[n+m]*nv[n]%mod*(ll)nv[m]%mod;}

inline int cal(int oa,int ob)
{
    int x,y,re=0,ix=f[oa][0],iy=f[oa][1],jx=g[ob][0],jy=g[ob][1];
    for(x=Ax;x<=Bx;++x)
    	ad(re,(ll)(x+By+1)*C(x-ix,By-iy)%mod*(ll)C(jx-x,jy-By-1)%mod),//(jy-By-1表示强制下一步离开y=By)
	    dc(re,(ll)(x+Ay)*C(jx-x,jy-Ay)%mod*(ll)C(x-ix,Ay-iy-1)%mod); //(Ay-iy-1)上同理 
	for(y=Ay;y<=By;++y)
	    ad(re,(ll)(Bx+y+1)*C(Bx-ix,y-iy)%mod*(ll)C(jx-Bx-1,jy-y)%mod),//(jx-Bx-1表示强制下一步离开x=Bx)
	    dc(re,(ll)(Ax+y)*C(jx-Ax,jy-y)%mod*(ll)C(Ax-ix-1,y-iy)%mod);//(Ax-ix-1)上同理 
	if(f[oa][2]==g[ob][2]) return re;
	return re?mod-re:0;
}

int main(){
	int i,j;frc[0]=frc[1]=nv[0]=nv[1]=1;
	for(i=2;i<N;++i)
	 frc[i]=(ll)frc[i-1]*i%mod,
	 nv[i]=(ll)(mod-mod/i)*nv[mod%i]%mod;
	for(i=2;i<N;++i) nv[i]=(ll)nv[i-1]*nv[i]%mod;
	
	for(i=1;i<7;++i) scanf("%d",&x[i]);
	for(i=1;i<7;++i) scanf("%d",&y[i]);
	
	f[0]={x[1]-1,y[1]-1,1};
	f[1]={x[1]-1,y[2],-1};
	f[2]={x[2],y[1]-1,-1};
	f[3]={x[2],y[2],1};
	
	g[0]={x[6]+1,y[6]+1,1};
	g[1]={x[6]+1,y[5],-1};
	g[2]={x[5],y[6]+1,-1};
	g[3]={x[5],y[5],1};
	
	Ax=x[3];Ay=y[3];Bx=x[4];By=y[4];
	
	for(i=0;i<4;++i)
	 for(j=0;j<4;++j)
	  ad(ans,cal(i,j));
	  
	printf("%d",ans);
	return 0;
}


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

struct Card {
	char sign;
	int num;
	int inputTime;
};

int partition(Card *ca, int p, int r) {
	int x = ca[r].num;
	int i, j;
	i = p - 1;
	for (j = p; j < r; j++) {
		if (ca[j].num <= x) {
			i++;
			swap(ca[i], ca[j]);
		}
	}
	i++;
	swap(ca[i], ca[r]);
	return i;
}

void quickSort(Card *ca, int p, int r) {
	if (p < r) {
		int q = partition(ca, p, r);
		quickSort(ca, p, q - 1);
		quickSort(ca, q + 1, r);
	}
}

int main(void) {
	int n, i;
	cin >> n;
	Card ca[n];
	for (i = 0; i < n; i++) {
		cin >> ca[i].sign >> ca[i].num;
		ca[i].inputTime = i;
	}

	quickSort(ca, 0, n-1);
	bool flag = true;
	for (i = 1; flag && i < n - 1; i++) {
		if (ca[i].num == ca[i - 1].num && ca[i].inputTime < ca[i - 1].inputTime)
			flag = false;
	}
	if (flag) {
		cout << "Stable\n";
	} else {
		cout << "Not stable\n";
	}

	for (i = 0; i < n; i++) {
		cout << ca[i].sign << " " << ca[i].num << endl;
	}
}


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

int main(){
    int a,b;
    while(scanf("%d%d",&a,&b)==2){
        if(a==1) a=14;
        if(b==1) b=14;
        if(a>b) printf("Alice\n");
        else if(a<b) printf("Bob\n");
        else printf("Draw\n");
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int n1=N/1000, n2=N/100 - n1*10, n3=N/10 - n1*100 - n2*10, n4=N%10;
  
  if((n1 == n2 && n2 == n3) || (n2 == n3 && n3 == n4)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#pragma warning (disable: 4996)

int H, W, N, maxn, ret = (1 << 30);
vector<int> X[100009];

int main() {
	scanf("%d%d%d", &H, &W, &N);
	for (int i = 0; i < N; i++) {
		int p, q; scanf("%d%d", &p, &q);
		X[p].push_back(q);
	}
	for (int i = 100000; i >= 0; i--) {
		ret = min(ret, i + maxn);
		for (int j : X[i]) maxn = max(maxn, j);
	}
	cout << ret << endl;
	return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int p, n, x, mm, counting, cnt;
    cin >> n >> x;
    vector<int> m;
    while(cin >> mm) m.push_back(mm);

    for(int i = 0; i < n; i++){
        counting += m[i];
        cnt++;
    }
    p = x - counting;
    cnt += p / *min_element(m.begin(), m.end());

    cout << cnt << '\n'; 
}

Measured memory_bytes: 256
N = int(input())
working_list = list(map(int, input().split()))
exchange_count = 0
for i in range(N):
    minj = i
    for j in range(i+1, N):
        if working_list[j] < working_list[minj]:
            minj = j
    if i != minj:
        working_list[i], working_list[minj] = working_list[minj], working_list[i]
        exchange_count += 1

print(*working_list)
print(exchange_count)


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


#define ll long long int
#define ld long double
#define mod 998244353
#define big 1e18+10
#define small -big
#define pb push_back
#define endl "\n"


template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}



void solve() {
    
    ll A[6];
    ll ans = 0;
    
    for(int i  = 1; i <= 5; i++) {
        cin >> A[i];
        if(A[i] == 0) ans = i;
    }
    
    cout << ans << endl;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   
    
    

    int t=1;
   // cin >> t;

    while(t--){  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 3560
#!/usr/bin/env python

def main():
    n, a, b = map(int, input().split())
    c = n // (a + b)
    n -= (a + b) * c

    count = a * c

    if n < a:
        count += n
    else:
        count += a

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
    int h,w,i,j;
	while(scanf("%d %d", &h, &w)!=EOF && (h!=0 || w!=0)){
		for(i=h;i;i--){
			for(j=w;j;j--){
				putchar('#');
			}
			putchar('\n');
		}
		putchar('\n');
	}
    return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,m;
    ll A,B,C;
    cin>>n>>m>>A>>B>>C;
    ll p[A],q[B],r[C];
    for(ll i=0;i<A;++i){cin>>p[i];}
    for(ll i=0;i<B;++i){cin>>q[i];}
    for(ll i=0;i<C;++i){cin>>r[i];}
    sort(p,p+A);
    sort(q,q+B);
    sort(r,r+C);

    priority_queue<ll,vector<ll>,greater<ll> > pq;
    ll sum=0;
    ll br[C+1];
    ll idx=B-1;
    while(pq.size()<m){
        pq.push(q[idx]);
        sum+=q[idx];
        --idx;
    }

    br[0]=sum;
    for(ll i=0;i<C;++i){
        if(r[i]>pq.top()){
            sum-=pq.top();
            pq.pop();
            sum+=r[i];
            pq.push(r[i]);
        }
        br[i+1]=sum;
    }

    ll ans=0;
    ll presum[C+1];
    presum[C]=0;
    for(ll i=C-1;i>=0;--i){
        if(i==C-1){
            presum[i]=r[i];
        }
        else{
            presum[i]=presum[i+1]+r[i];
        }
    }

    if(n<=C){
        ll cost=presum[C-n]+br[C-n];
        ans=max(ans,cost);
    }

    sum=0;
    idx=0;
    for(ll i=A-1;i>=0;--i){
        ++idx;
        if(idx>n){break;}
        sum+=p[i];
        if(n-idx>C){continue;}
        ll ii=C-n+idx;
        ll cost=sum+presum[ii]+br[ii];
        ans=max(ans,cost);
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 4980
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    long double prob[n + 1];
    for (int i = 0; i <= n; i++) prob[i] = 0;
    prob[0] = 1;
    for (int i = 0; i < n; i++) {
        long double p; cin >> p;
        for (int j = n; j > 0; j--) {
            prob[j] = prob[j] * (1.0 - p) + prob[j - 1] * p;
        }
        prob[0] *= (1.0 - p);
    }
    long double ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i > n - i) ans += prob[i];
    }
    cout << fixed << setprecision(10) << ans;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define N 100000
 
int32_t main(){
    IOS;
 
int n,W;
cin>>n>>W;
 
vector<int > dp(N+1 , INT_MAX);
dp[0] = 0;
for(int i=0;i<n;i++)
{
    
    int w,v;
    cin>>w>>v;
    
    for(int j=N-v;j>=0;j--)
    {
        dp[j+v] = min(dp[j+v] , dp[j] + w);
    }
 
}
 
int i;
for(i=N;i>=0;i--)
if(dp[i] <= W)
break;
 
cout<<i<<endl;
 
}

Measured memory_bytes: 1152
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline


n,*p = map(int,read().split())

a = [i==pi-1 for i,pi in enumerate(p)] + [False]

v = 0
ans = 0
for i in a:
    if i:
        v += 1
    else:
        ans += (v+1)//2
        v = 0

print(ans)




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


int main(void) {
    string s;
    cin >> s;
    int topping = 0;
    if(s[0] == 'o')topping ++;
    if(s[1] == 'o')topping ++;
    if(s[2] == 'o')topping ++;
    cout << 700 + topping*100 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
int block;
struct query{
	int l,r,id;
	bool operator < (const query& x) const{
		if(l/block!=x.l/block) return l/block<x.l/block;
		if(l/block%2) return r<x.r;
		else return r>x.r;
	}
}seg[N];
int a[N];
int cnt[N];
int res[N];
int ans;
void add(int x){
	cnt[x]++;
	if(cnt[x]==1) ans++;
}
void del(int x){
	cnt[x]--;
	if(cnt[x]==0) ans--;
}
int main(){
	int n,q;
	scanf("%d %d",&n,&q);
	block=int(sqrt(1.0*n));
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=q;i++){
		scanf("%d %d",&seg[i].l,&seg[i].r);
		seg[i].id=i;
	}
	sort(seg+1,seg+q+1);
	int l=seg[1].l,r=seg[1].l-1;
	for(int i=1;i<=q;i++){
		while(l<seg[i].l) del(a[l++]);
		while(r>seg[i].r) del(a[r--]);
		while(l>seg[i].l) add(a[--l]);
		while(r<seg[i].r) add(a[++r]);
		res[seg[i].id]=ans;
	}
	for(int i=1;i<=q;i++){
		printf("%d\n",res[i]);
	}
	return 0;
}

Measured memory_bytes: 15472
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> top(110);
    for(int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        top.at(i) = top.at(i-1) + A;
    }
    vector<int> bottom(110);
    for(int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        bottom.at(i) = bottom.at(i-1) + A;
    }
    
    int ans = -1;
    for(int i = 1; i <= N; i++) {
        ans = max(ans, top.at(i) + (bottom.at(N)-bottom.at(i-1)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    S = SI()
    rem = 15 - len(S)
    cnt = 8
    for s in S:
        if s == 'o':
            cnt -= 1
    ans = 'YES' if rem >= cnt else 'NO'
    return ans

print(main())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000001

int main(){
	
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	
	while(true){
		C-=B;
		if(C<=0){
			cout<<"Yes"<<endl;
			return 0;
		}
		A-=D;
		if(A<=0){
			cout<<"No"<<endl;
			return 0;
		}
	}
		
	return 0;
}

Measured memory_bytes: 3636