akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define inf 10000+10
using namespace std;
const int maxn=100+10,maxm=5000+10;
int n,m,S,T,cnt;
int hd[maxn],to[maxm],nxt[maxm],fl[maxm],pos[maxn];
void add(int x,int y,int z){
	to[cnt]=y,fl[cnt]=z,nxt[cnt]=hd[x],hd[x]=cnt++;
	to[cnt]=x,fl[cnt]=0,nxt[cnt]=hd[y],hd[y]=cnt++;
}
bool dfs(){
	memset(pos,-1,sizeof(pos));
	int head=0,tail=0,q[maxn];
	pos[q[0]=S]=0;
	while(head<=tail){
		int v=q[head++];
		for(int i=hd[v];i!=-1;i=nxt[i])
			if(pos[to[i]]==-1&&fl[i])
				pos[q[++tail]=to[i]]=pos[v]+1;
	}
	return pos[T]!=-1;
}
int find(int v,int f){
	if(v==T)
		return f;
	int res=0,t;
	for(int i=hd[v];i!=-1&&f>res;i=nxt[i])
		if(pos[v]+1==pos[to[i]]&&fl[i])
			t=find(to[i],min(f-res,fl[i])),fl[i]-=t,res+=t,fl[i^1]+=t;
	if(!res)
		pos[v]=-1;
	return res;
}
int dinic(){
	int res=0,t;
	while(dfs())
		while(t=find(S,inf))
			res+=t;
	return res;
}
int main(){
	cnt=0;
	memset(hd,-1,sizeof(hd));
	scanf("%d%d",&n,&m);
	for(int i=1,x,y,z;i<=m;i++)
		scanf("%d%d%d",&x,&y,&z),add(x,y,z);
	S=0,T=n-1;
	printf("%d\n",dinic());
	return 0;
}

Measured memory_bytes: 1228
n,c = map(int,input().split())
x = [0]*n
v = [0]*n
for i in range(n): x[i],v[i] = map(int,input().split())
x1 = [0]+x
v1 = [0]+v
x2 = [0]+list(map(lambda a:c-a,x[::-1]))
v2 = [0]+v[::-1]
lst1 = [0]*(n+1)
lst2 = [0]*(n+1)
lst1[0] = lst2[0] = (0,0)

def f(l,x,v):
    maxcal = pos = sumcal = 0
    for i in range(1,n+1):
        dist = x[i]-x[i-1]
        sumcal += v[i] - dist
        if sumcal > maxcal:
            maxcal = sumcal
            pos = x[i]
        l[i] = (maxcal,pos)

f(lst1,x1,v1)
f(lst2,x2,v2)
# print(lst1)
# print(lst2)

ans = 0
for i in range(n+1):
    maxcal1,dist1 = lst1[i]
    maxcal2,dist2 = lst2[n-i]
    ans = max(ans,maxcal1+maxcal2-min(dist1,dist2))
print(ans)

Measured memory_bytes: 39172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
const long long INF = 1LL << 60;
using namespace std;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {
 int n;
 cin >> n;
 if(n%10 == 2 || n%10 == 4|| n%10 == 5|| n%10 == 7 || n%10 == 9){
cout << "hon";
 }
else if(n%10 == 0 || n%10 == 1|| n%10 == 6|| n%10 == 8){
   cout << "pon";
 }
 else cout << "bon";
return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>

using namespace std;

#define cn cout << '\n'
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main() {
    cio;
    int n;
    string s;
    cin >> n >> s;
    ll g = 0, ar[90]={0}, k, l;
    for (int i = 0; i < n; ++i) {
        ar[s[i]]++;
        for (int j = 0; j < n; ++j) {
            k = 2 * j + i;
            l = j + i;
            if (k >= n) break;
            if (s[i] != s[l] && s[i] != s[k] && s[l] != s[k])
                g++;
        }
    }

    cout << ar['R'] * ar['G'] * ar['B'] - g << endl;
}


Measured memory_bytes: 3188
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long H;
  scanf("%lld", &H);

  ll ans = 0;
  int cnt = 0;
  while (H)
  {
    ans += pow(2, cnt);
    cnt++;
    H /= 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
l = list(input()) + ["R"]
ans = [0] * len(l)
cnt = 0

for i in range(len(l)-1):
  if (l[i] == "R") & (l[i+1] == "R"):
    cnt += 1
    ans[i] = 0
  elif (l[i] == "R") & (l[i+1] == "L"):
    now = i
    ans[i] = cnt // 2 + 1
    ans[i+1] = cnt - cnt // 2 + 1
    cnt = 0
  elif (l[i] == "L") & (l[i+1] == "L"):
    cnt += 1
    if i != now+1:
      ans[i] = 0
  elif (l[i] == "L") & (l[i+1] == "R"):
    if i != now+1:
      ans[i] = 0
    ans[now+1] += cnt//2
    ans[now] += cnt - cnt // 2
    cnt = 0
    
print(*ans[:-1])

Measured memory_bytes: 7192
import java.io.*
import java.util.*

fun solve(A: Long, B: Long){
    println(listOf(A+B, A-B, A*B).max()!!)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toLong()
    val B = sc.next().toLong()
    solve(A, B)
}



Measured memory_bytes: 33840
{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n, a, b] <- readIntegers
  print $ solve n a b

solve n a b = a * nsets + remb
  where
    s = a + b
    nsets = n `div` s
    remb = min (n `mod` s) a

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

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


int main(){
  string s ;
  cin >>s ;
  char a =s[0];
  char b =s[1];
  char c =s[2];
  if(a==b&&a==c&&b==c){
    cout <<"No"<<endl;
    return 0;
  }
  cout <<"Yes"<<endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001
typedef long long ll;

string s;
int k;

// char X[100][100];
// int dp[1000000001];

int main(void) {
    cin >> s >> k;
    
    char ans = '1';
    REP(i,0,k) {
        if (s[i] != '1') {
            ans = s[i];
            break;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

struct Point { double x, y; };

void koch(int n, Point a, Point b) {
	if (n == 0)return;

	Point s, t, u;
	double th = PI*60.0 / 180.0;

	s.x = (2.0*a.x + 1.0*b.x) / 3.0;
	s.y = (2.0*a.y + 1.0*b.y) / 3.0;
	t.x = (1.0*a.x + 2.0*b.x) / 3.0;
	t.y = (1.0*a.y + 2.0*b.y) / 3.0;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

	koch(n - 1, a, s);
	cout << fixed << setprecision(13) << s.x << " " << s.y << endl;
	koch(n - 1, s, u);
	cout << fixed << setprecision(13) << u.x << " " << u.y << endl;
	koch(n - 1, u, t);
	cout << fixed << setprecision(13) << t.x << " " << t.y << endl;
	koch(n - 1, t, b);
}

int main() {
	Point a, b;
	int n;
	cin >> n;

	a.x = 0.0, a.y = 0.0;
	b.x = 100.0, b.y = 0.0;

	cout <<fixed<<setprecision(13)<< a.x << " " << a.y << endl;
	koch(n, a, b);
	cout << fixed << setprecision(13) << b.x<<" " << b.y << endl;
}


Measured memory_bytes: 3276
<?php
// B
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$ans = 1;
sort($a);
for ($i = 0; $i < $n; $i++) {
    if ($a[$i] === 0) exit('0');
    $ans *= $a[$i];
    if ($ans > 10 ** 18) exit('-1');
}
echo $ans;

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

int main() {
    int n, reserve, l, count;
    cin >> n;
    l = 0;
    reserve = n;
    count = 1;
    while(reserve) {
        reserve /= 10;
        l++;
    }
    if(l % 2){
        count = pow(100, (l - 1) / 2);
        count = (count - 1) / 11;
        int delta;
        delta = n + 1;
        reserve = pow(10, l - 1);
        delta -= reserve;
        count += delta;

    }else {
        count = pow(100, l / 2);
        count = (count - 1) / 11;
    }

    cout << count * (l != 1) + n * (l == 1) << endl;

    return 0;
}

Measured memory_bytes: 384
'use strict'
function Main(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  var N=input.shift();
  var M=input.shift();
  var C=input.shift();
  var B=[];
  for(let i=0;i<M;i++)B[i]=input[i];
  var counter=0;
  for(let i=1;i<=N;i++){
    let sum=0;
    for(let j=0;j<M;j++){
      sum+=B[j]*input[M*i+j];
    }
    if(sum+C>0)counter++;
  }
  console.log(counter);
}

Main(require("fs").readFileSync('/dev/stdin','utf8'));

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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll ;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define NP next_permutation
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------




















//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  priority_queue<ll, vector<ll>, greater<ll>> que;
  priority_queue<ll, vector<ll>, less<ll>> que2;
  REP(i,n){
    ll a ;
    cin >> a ;
    que.push(a) ;
    que2.push(a) ;
  }
  deque<ll> deq ;
  int cnt = 0 ;
  deq.PB(que.top()) ;
  que.pop() ;
  cnt++ ;
  while(cnt<n){
    if(cnt==n-1){
      ll k = que.top() ;
      if(abs(deq.front()-k)>=abs(deq.back()-k)){
        deq.push_front(k) ;
      }
      else{
        cnt++ ;
        deq.push_back(k) ;
      }
      break ;
    }
      
    if(cnt%4==1){
      deq.push_front(que2.top()) ;
      que2.pop() ;
      cnt++ ;
    }
    else if(cnt%4==2){
      deq.push_back(que2.top()) ;
      que2.pop() ;
      cnt++ ;
    }
    else if(cnt%4==3){
      deq.push_front(que.top()) ;
      que.pop() ;
      cnt++ ;
    }
    else{
      deq.push_back(que.top()) ;
      que.pop() ;
      cnt++ ;
    }
  }
  
  vll num ;
  auto itr = deq.begin() ;
  while(itr !=deq.end()){
    num.PB((*itr)) ;
    itr++ ;
  }
  ll ans = 0;
  REP(i,n-1){
    ans += abs(num[i]-num[i+1]) ;
  }
  cout << ans <<endl ;
      
  
  
  
  
  return 0 ;


}




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

#define task "D"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
ll A;
ld B;
int main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#else
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#endif
    cin >> A >> B;
    ld ans = (ld) A * B;
    ll res = (ll) ans;
    cout << res;
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
string s, t;
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    while(cin >> s >> t) {
        int ls = s.length(), lt = t.length();
        if(lt > ls) {
            cout << "UNRESTORABLE" << endl;
            continue;
        }
        bool flag = false;
        int tt = -1;
        for(int i = 0; i <= ls - lt; ++i) {
            if(s[i] == t[0] || s[i] == '?') {
                int k = 0;
                for(int j = 0; j < lt; ++j) {
                    if(s[i + j] == t[j] || s[i + j] == '?') k++;
                    else break;
                }
                if(k == lt) {
                    flag = true;
                    tt = i;
                }
            }
        }
        if(flag) {
            s.replace(tt, lt, t);
            for(int i = 0; i < ls; ++i) {
                if(s[i] == '?') cout << 'a';
                else cout << s[i];
            }
            cout << endl;
        } else cout << "UNRESTORABLE" << endl;
    }
}

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

int main(){
    int a,b,n, d[200],x=1;
    cin >> n;
    set<int> s;
    rep(i, n) {
        cin >> d[i];
        s.insert(d[i]);
    }
    cout << s.size() << endl;
    /*
    sort(d, d + n);
    rep(i,n){
        if(i==0)
            continue;
        a = d[i];
        b = d[i - 1];
        if(a!=b){
            x++;
        }
    }
    
    cout << x << endl;
*/

}

Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){
	char c=getchar();
	while(c<'0'||'9'<c) c=getchar();
	uint_fast32_t x=0;
	while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); }
	return x;
}

char s[11];

void f(int d, int n, char c){
	if(n==0){
		puts(s);
		return;
	}
	for(char i='a'; i<c; i++){
		s[d]=i;
		f(d+1, n-1, c);
	}
	s[d]=c;
	f(d+1, n-1, c+1);
}
int main(void){
	long n=nextpint();
	f(0, n, 'a');
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
int main(){
ll a,b;
bool k=false;
cin>>a>>b;
for(int i=1;i<=1250;i++){
if(floor((double)i*0.08)==a && floor((double)i*0.10)==b)
{
k=true;
cout<<i;
break;
}
}
if(!k)
cout<<-1;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;


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

ll n,m,k;
cin >> n >> m >> k;
vl a(n),b(m);
rep(i,n) cin >> a[i];
rep(i,m) cin >> b[i];

vl sa(n+1),sb(m+1);
rep(i,n) sa[i+1] = sa[i] + a[i];
rep(i,m) sb[i+1] = sb[i] + b[i];

ll res = 0;
rep(i,n+1) {
    if(sa[i] > k) break;
    ll key = k - sa[i];
    ll ika = upper_bound(all(sb), key) - sb.begin();
    chmax(res, i + ika - 1);
}
cout << res << endl;
return 0;
}

Measured memory_bytes: 9504
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
struct Main {}

#[allow(dead_code)]
impl Main {}

fn main() {
    let mut a = read::<i32>();
    let b = read::<i32>();
    let mut c = read::<i32>();
    let d = read::<i32>();
    loop {
        c -= b;
        if c <= 0 {
            println!("Yes");
            break;
        }
        a -= d;
        if a <= 0 {
            println!("No");
            break;
        }
    };
}


Measured memory_bytes: 2108
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    string S;
    cin >> S;

    stack<char> s;
    s.push('T');
    long long count = 0;
    for (long long i = 0; i < S.size(); i++)
    {
        if (S[i] == 'S')
            s.push('S');
        else
        {
            if (s.top() == 'S')
            {
                count += 2;
                s.pop();
            }
            else
                s.push('T');
        }
    }

    cout << S.size() - count << endl;
}

Measured memory_bytes: 644
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *p;
  struct node *r;
  struct node *l;
  int key;
};
typedef struct node * Node;
Node root;
void insert(int v){
  Node y=NIL;
  Node x=root;
  Node c;
  c=malloc(sizeof(struct node));
  c->key=v;
  c->l=NIL;
  c->r=NIL;
  while(x!=NIL){
    y=x;
    if(c->key < x->key) x=x->l;
    else x=x->r;
  }
    c->p=y;
    if(y==NIL) root=c;
    else if(c->key < y->key) y->l=c;
    else y->r=c;
}
void inorder(Node w){
  if(w!=NIL){
    inorder(w->l);
    printf(" %d",w->key);
    inorder(w->r);
  }
}
 
void preorder(Node w){
  if(w!=NIL){
    printf(" %d",w->key);
    preorder(w->l);
    preorder(w->r);
  }
}
 
Node find(Node a,int b){
  if (a==NIL || b==a->key) return a;
  if(b < a->key) return find(a->l,b);
  else return find(a->r,b);
}
 
int main(){
  int a,b,i;
  char com[20];
 
  scanf("%d",&a);
 
  for(i=0;i<a;i++){
    scanf("%s",com);
 
  if(com[0]=='i'){
    scanf("%d",&b);
    insert(b);
  }
  else if(com[0]=='p'){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
  }
  else if(com[0]=='f'){
    scanf("%d",&b);
    Node s=find(root,b);
    if(s!=NIL) printf("yes\n");
    else printf("no\n");
  }
  }
  return 0;
}



Measured memory_bytes: 20468
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3 1
4 1 5
---+/
/+---test
8 9
7 9 3 2 3 8 4 6
---+/
/+---test
3 0
1000000000 1000000000 1000000000
---+/

void main(string[] args) {
  long N, K;
  readf(" %d %d ", &N, &K);

  auto H = readln.split.map!(to!long).array;
  H.sort!"a > b";

  H[min($, K)..$].sum.writeln;
}


Measured memory_bytes: 11112
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key = lambda x:x[0])
s = 0
c = 0
for i in range(N):
    for j in range(AB[i][1]):
        s += AB[i][0]
        c += 1
        if c >= M:
            print(s)
            exit()

Measured memory_bytes: 29028
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S[100];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> S[i];

	string ans;
	rep(i, 0, 26) {
		char c = i + 'a';
		int mv = 50;
		rep(j, 0, N) {
			int a = count(all(S[j]), c);
			MIN(mv, a);
		}
		while(mv--) ans += c;
	}
	cout << ans << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


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

    N = int(input())
    ans = [[0] * (N+1) for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            for k in range(10):
                if (i >> k & 1) != (j >> k & 1):
                    ans[i][j] = k+1
                    break
    for i in range(1, N):
        print(*ans[i][i+1:])


if __name__ == '__main__':
    main()


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

int main() {
	int a[7];
  	for (int i = 0; i < 7; i++)
      	scanf("%d", a + i);
  	long long res = a[1];
  	if (a[0] && a[3] && a[4] && a[0] % 2 + a[3] % 2 + a[4] % 2 > 1) {
  		res += 3;
  		a[0]--, a[3]--, a[4]--;
  	}
  	res += (a[0] / 2) * 2;
  	res += (a[3] / 2) * 2;
  	res += (a[4] / 2) * 2;
  	printf("%lld\n", res);
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> a(n), dp(1e6+1);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    dp[a[i]]++;
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    bool judge = true;
    for(int j = 2; j*j <= a[i]; j++){
      if(a[i] % j == 0 && dp[j] > 0) judge = false;
      if(a[i] % j == 0 && dp[a[i]/j] > 0) judge = false;
    }
    if(a[i] != 1 && dp[1] > 0) judge = false;
    if(dp[a[i]] == 1) ans += judge;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 12688
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Integer
getInt = (\a -> read a :: Integer) <$> getLine

getIntArray :: IO [Integer]
getIntArray = ((map (\a -> read a :: Integer)) . words) <$> getLine

getStrArray :: Integer -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

rmSpace :: String -> String
rmSpace "" = ""
rmSpace (' ':rst) = rmSpace rst
rmSpace (x:rst) = x : (rmSpace rst)

main = do
    n <- ((\a -> read a :: Int) . rmSpace) <$> getLine
    putStrLn $ if 0 == mod n 4 then "YES" else "NO"


Measured memory_bytes: 380
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  string s;
  cin>>s;
  int ans = 0;
  for(int i = 0; i+2<n; i++){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P, ll> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int x;
    cin >> x;
    if(x < 1200){
        cout << "ABC" << endl;
    }
    else{
        cout << "ARC" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque


def bfs(start):
    Q = deque()
    child = deque()
    Q.append(start)
    dist[start[1] - 1][start[0] - 1] = 0

    while Q:
        x, y = Q.popleft()
        x = x - 1
        y = y - 1

        for i in range(4):
            child.clear()
            nx = x + dx[i]
            ny = y + dy[i]

            if nx < 0 or nx >= W or ny < 0 or ny >= H:
                continue
            if G[ny][nx] == "#":
                continue
            if dist[ny][nx] != -1:
                continue

            child.append((nx + 1, ny + 1))

            if len(child) > 0:
                for c in child:
                    dist[c[1] - 1][c[0] - 1] = dist[y][x] + 1
                    Q.append(c)


H, W = map(int, input().split())
G = [[] for _ in range(H)]

kuro = 0
for i in range(H):
    G[i] = list(input())
    kuro += G[i].count('#')

dist = [[-1 for _ in range(W)] for _ in range(H)]
dx = [1, 0, -1, 0]  # 斜めも含むならその方向もプラス
dy = [0, 1, 0, -1]

start = (1, 1)
bfs(start)

# for i in range(H):
#     print(dist[i])

if dist[H - 1][W - 1] == -1:
    res = -1
else:
    res = H * W - (dist[H - 1][W - 1] + 1) - kuro

print(res)

Measured memory_bytes: 3316
import java.util.*;

/**
 * Created by nirpis.hu on 2019/3/9.
 */
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> s = new HashSet<>();
        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            if (s.contains(p)) {
                s.remove(p);
            } else {
                s.add(p);
            }
        }
        System.out.print(s.size());
    }

}


Measured memory_bytes: 62804
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(0 <= y-r && y+r <= h && 0 <= x-r && x+r <= w) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3100
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

###########

n=i()
a=[0]*n
p=0
cnt=0
for j in range(n):
    a[j]=i()
    if a[j]==0:
        p+=cnt%2
        cnt=0
    else:
        cnt+=a[j]%2

print (sum(a)-p)/2


Measured memory_bytes: 9088
x,y = map(int, raw_input().split(' '))


"""
a + b = x
2a + 4b = y

a = x-b
2x- 2b + 4b = y

a = x-b
2b = y  - 2x
"""
def f(x,y):
  	
	if (y - 2*x) < 0: return False
	b = (y - 2*x)/2
	a = x - b

	b = (y - 2*x)/2
	a = x - b
	
	if a < 0: return False


	return a+b == x and 2*a + 4*b ==y
  
print 'Yes' if f(x,y) else 'No'


Measured memory_bytes: 64276
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include <functional>
using namespace std;


int main(){
	int t;
	while(cin>>t&&t){
		int n,s,f,sum=0;
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>s>>f;
			sum+=f-s;
		}
		if(sum>=t)cout<<"OK"<<endl;
		else cout<<t-sum<<endl;
	}
	return 0;
}

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

const int inf=1001;
int md=1e9+7;
int n, m;
int mat[inf][inf];
int dp[inf][inf];

void add_self(int&a, int b){
    a=a+b;
    if(a>=md)a=a-md;
}

int f(int x, int y){
     if(x==n-1 and y==m-1) return 1;
     if(x>=n or y>=m) return 0;
    if(mat[x][y]==1) return 0;
     int&ans=dp[x][y];
     if(ans!=-1) return ans;
     
     ans=0;
     add_self(ans, f(x+1, y));
     add_self(ans, f(x, y+1));
     return ans;
}
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     memset(dp, -1, sizeof(dp));
     cin>>n>>m;
     for(int i=0;i<n;i++){
          string temp;
          cin>>temp;
          for(int j=0;j<m;j++){
               if(temp[j]=='#')mat[i][j]=1;
          }
     }
    cout<<f(0, 0);
}

Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>

#define ll long long

using namespace std;

inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int ac,wa,tle,re;

int main() {
	int n=read();
	for (int i=1;i<=n;i++) {
		string s;
		cin>>s;
		if (s[0]=='A') ac++;
		else if (s[0]=='W') wa++;
		else if (s[0]=='T') tle++;
		else re++;	
	}
	printf("AC x %d\n",ac);
	printf("WA x %d\n",wa);
	printf("TLE x %d\n",tle);
	printf("RE x %d\n",re);
	return 0;
}

Measured memory_bytes: 3724
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let m: u64 = sc.cin();
    let n: usize = sc.cin();
    let x: u64 = sc.vec::<u64>(n).iter().sum::<u64>();
    if m >= x {
        put!(m - x);
    } else {
        put!(-1);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 2556
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

int main() {
    ll K,N;
    cin >> K >> N;
    vector<ll> A(N);
    for(ll i=0;i<N;i++){
        cin >> A[i];
    }

    ll result = 0;
    for(ll i=N-1;i>=0;i--){
        if(i == 0){
            result = max(result,A[i]-A[N-1]+K);
        }else{
            result = max(result,A[i]-A[i-1]);
        }
        
    }

    result = K-result;

    cout << result << endl;


}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
int main(int argc, char** argv)
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x = 700;
    string s;
    cin >> s;
    while (!s.empty())
    {
        x += (s.back() == 'o' ? 100 : 0);
        s.pop_back();
    }
    cout << x << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
 

int main(){ 
	ll N;
	cin >> N;
	vector<ll> x(N),y(N);
	FOR(i,0,N){
		cin >> x[i] >> y[i];
	}
	ll ans = N,zero=0;
	map<P,ll> ma;
	FOR(i,0,N){
		FOR(j,0,N){
			if(i==j)continue;
			ma[{x[i]-x[j],y[i]-y[j]}]++;
			ans = min(ans,N-ma[{x[i]-x[j],y[i]-y[j]}]);
		}
	}
	cout << ans << endl;
}


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


int main() {
  ll H, N;
  cin >> H >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  ll s = 0;
  rep(i, N) s += A[i];
  if (s >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdint.h>

uint32_t a[200000];
uint32_t e[200000];

int main(int argc, char **argv)
{
  int n;

  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d ", &a[i]);
  }

  const int c = 200000 / 2;
  int f;
  if (n % 2) { // odd
    for (int i = 0; i < n; i++) {
      int j = ((i + 1) % 2) ? -1 : 1;
      e[c + (i + 1) / 2 * j] = a[i];
    }
    f = c - n / 2;
  }
  else { // even
    for (int i = 0; i < n; i++) {
      int j = (i % 2) ? -1 : 1;
      e[c + (i + 1) / 2 * j] = a[i];
    }
    f = c - n / 2;
  }

  for (int i = 0; i < n - 1; i++) {
    printf("%d ", e[f + i]);
  }
  printf("%d\n", e[f + n - 1]);

  return 0;
}


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

int main()
{
    int x ,y ;
    cin >> x >> y ;
    if ((x==1 || x==3 || x==5 || x==7 || x==8  || x==10 || x==12 ) && (y==1 || y==3|| y==5 || y==7 || y==8 || y==10 || y==12) )
    cout <<"Yes" ;
    else if (( x==4 || x==6 || x==9 || x==11) && ( y==4 || y==6|| y==9 || y==11 ))
    cout <<"Yes" ;
    else if (x==2 && y==2)
    cout <<"Yes" ;
    else
    cout <<"No" ;

    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;

    if ((a%3==0) || (b%3==0) || ((a+b)%3==0)){
        cout << "Possible" << endl;
    }

    else{
        cout << "Impossible" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  string ans;
  cin >> A>>B;
  if (A>B) {
    for (int i = 0;i<A;i++) {
      cout << B;
    };
  }else{
    for (int i = 0;i<B;i++) {
      cout << A;
    };
  };
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(input())
B = list(input())
C = list(input())

ans = 0
for c in zip(A, B, C):
    char_cnt = Counter(c)
    max_val = 0
    for val in char_cnt.values():
        if val > max_val:
            max_val = val
    ans += 3 - max_val

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    if(a>b)
    {
        for(i=1;i<=a;i++) cout<<b;
    }
    else for(i=1;i<=b;i++) cout<<a;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
int a;
cin>>a;
int mina=a,maxa=a;
long long int sum=a;
n--;
for(int i=0;i<n;i++)
{
cin>>a;
sum+=a;
mina=min(mina,a);
maxa=max(maxa,a);
}
cout<<mina<<" "<<maxa<<" "<<sum<<endl;
return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <atcoder/all>

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

using namespace std;
using namespace atcoder;
using ll = long long;

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

    int n, q;
    cin >> n >> q;
    dsu d(n);
    int t, u, v;
    rep(i, q) {
        cin >> t >> u >> v;
        if(t) {
            printf("%d\n", d.same(u, v));
        } else {
            d.merge(u, v);
        }
    }

    return 0;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
main()
{
    int k,a,b;
    cin>>k;
    cin>>a>>b;
    int flag =0;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK";
            flag =1;
            break;
        }
    }
    if(flag!=1)
        cout<<"NG";
}


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

using namespace std;

const int N = 1e5+5;

typedef long long ll;

int n, a, b, pos[N], curr = 1, tmp;
ll ans;

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin>>n>>a>>b;
  for(int i=0; i<n; i++){
    cin>>tmp;
    if(i==0)
    {
      curr = tmp;
      continue;
    }
    ll dist = tmp - curr;
    ans += min(dist*a, b*1LL);
    curr = tmp;
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main{
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        int H=sc.nextInt();
        int N=sc.nextInt();
        int A=0;
        while(N-->0){
            A=A+sc.nextInt();
        }
        if(A<H)System.out.println("No");
        else System.out.println("Yes");
    }
}
        
        



Measured memory_bytes: 49060
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N;
    cin>>N;
    vector<string>W(N);
    bool flag=true;

    for(int i=0;i<N;i++)cin>>W[i];
    for(int i=1;i<N;i++){
        if(W[i].front()!=W[i-1].back())flag=false;
    }

    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            if(W[i]==W[j])flag=false;
        }
    }

    if(flag==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}




Measured memory_bytes: 256