akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	int n; cin >> n;
	int even = 0;
	rep(i, n){
		int t; scanf("%d", &t);
		even+=t%2;
	}
	
	if(even%2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
while True:
    N, M, P, A, B = map(int, input().split())
    if not (N | M | P | A | B):
        break
    A, B = A - 1, B - 1
    T = [int(x) for x in input().split()]
    dp = [[float("inf")] * M for _ in range(1 << N)]
    dp[0][A] = 0
    edges = []
    for _ in range(P):
        s, t, c = map(int, input().split())
        s, t = s - 1, t - 1
        edges.append((s, t, c))
        edges.append((t, s, c))
    ans = float('inf')
    for state in range(1 << N):
        for s, t, c in edges:
            for k in range(N):
                if state >> k & 1 and dp[state][t] > dp[state & ~(1 << k)][s] + c / T[k]:
                    dp[state][t] = dp[state & ~(1 << k)][s] + c / T[k]
    ans = min(dp[state][B] for state in range(1 << N))
    print("Impossible" if ans == float("inf") else "{:.05f}".format(ans))

Measured memory_bytes: 7836
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
 
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   
	ll a;
	
	cin >> a;
	
	cout << 3*(a*a) << endl;
   
return 0;   
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

    vl x(n), y(n);
    vl vx, vy;
    rep(i, n) {
        cin >> x[i] >> y[i];
        vx.pb(x[i]);
        vy.pb(y[i]);
    }
    sort(all(vx));
    sort(all(vy));

    ll ans = (vx[n-1] - vx[0])*(vy[n-1] - vy[0]);
    exrep(i1, 0, n-2) {
        exrep(i2, i1+1, n-1) {
            exrep(j1, 0, n-2) {
                exrep(j2, j1+1, n-1) {
                    ll cnt = 0;
                    rep(k1, n) {
                        if(vx[i1] <= x[k1] && x[k1] <= vx[i2] && vy[j1] <= y[k1] && y[k1] <= vy[j2]) {
                            cnt++;
                        }
                    } 
                    if(cnt >= k) {
                        chmin(ans, (vx[i2] - vx[i1])*(vy[j2] - vy[j1]));
                    }
                }
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 384
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var sum = 0;
        for (int i = 0; i < s.Length; i++)
            sum += int.Parse(s[i].ToString());
        Console.WriteLine(int.Parse(s) % sum == 0 ? "Yes" : "No");
    }
}



Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {
	int n, low, high;

	std::cin >> n >> low >> high;

	std::vector<int> a, b, c;

	for (size_t i = 0; i < n; i++) {
		int score;

		std::cin >> score;
		if (score <= low) {
			a.push_back(score);
		}
		else if (score <= high) {
			b.push_back(score);
		}
		else {
			c.push_back(score);
		}
	}

	std::cout << std::min(a.size(), std::min(b.size(), c.size())) << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, a, b;
cin >> N >> M >> a >> b;

for (int i = 0; i < M - 1; i++) {
  int na, nb;
  cin >> na >> nb;
  if (na > a) {
    a = na;
  }
  if (nb < b) {
    b = nb;
  }
}
if (b - a < 0) {
  cout << 0 << endl;
}
else {
  cout << b - a + 1 << endl;
}
}

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

using namespace std;

int main() {
	int m, nmin, nmax;
	while (cin >> m >> nmin >> nmax) {
		if (m == 0 && nmin == 0 && nmax == 0) {
			break;
		}
		vector<int> d(m);
		for (int i = 0; i < m; i++) {
			cin >> d[i];
		}
		int MAX = d[nmin-1]-d[nmin];
		int maxn = nmin;
		for (int i = nmin-1; i <= nmax-1; i++) {
			int mm = d[i]-d[i+1];
			if (mm >= MAX) {
				MAX = mm;
				maxn = i+1;
			}
			//cout << MAX << ' ' << maxn << endl;
		}
		cout << maxn << endl;
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    // i=0 が一文字目であることに注意
    rep(i, s.size())
    {
        if (i%2==0){
            if (s[i] == 'L')
            {
                cout << "No";
                return 0;
            }
        }
        else{
            if (s[i] == 'R')
            {
                cout << "No";
                return 0;
            }
        }
    }
    
    cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> g(n, vector<pair<int, int>>());
    int a, b, w;
    REP(i, n - 1) {
        cin >> a >> b >> w;
        a--; b--;
        w %= 2;
        g[a].emplace_back(b, w);
        g[b].emplace_back(a, w);
    }

    vi color(n, 0);

    function<void(int, int)> dfs = [&](int c, int p) {
        if (p != -1 and sz(g[c]) == 1) return;
        for (auto e : g[c]) {
            if (e.first == p) continue;
            if (e.second == 0) {
                if (color[c] == 0) color[e.first] = 0;
                else color[e.first] = 1;
            } else {
                if (color[c] == 0) color[e.first] = 1;
                else color[e.first] = 0;
            }
            dfs(e.first, c);
        }
    };

    dfs(0, -1);
    printlnv(color);
}


Measured memory_bytes: 13008
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int f(int n){
    if(n==-1) return 1;
    if(n==-2) return 0;
    int64_t a=1,b=0,temp;
    rep(i,n){
        temp=b%MOD;
        b=a%MOD;
        a=(a+temp)%MOD;
    }
    return (a+b)%MOD;
}

int main() {
  int64_t n,m,me=-1,ans=1;
  cin>>n>>m;
  rep(i,m){
      int64_t s;
      cin>>s;
      ans=(ans*f(s-me-3))%MOD;
      me=s;
  }
cout<<(ans*f(n-me-2))%MOD<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
typedef long long lld;
const int MAXN = 2e5+5;
const int NOPE = -1;
int A[MAXN];
int B[MAXN];
int N;

bool local_max(int i) {
    int u = (i + N - 1) % N;
    int v = (i + 1) % N;
    return (B[i] > B[u] + B[v]);
}

lld solve() {
  std::queue<int> Q;
  for (int i = 0; i < N; ++i) {
    if (local_max(i)) Q.push(i);
  }
  lld ret = 0LL;
  while (!Q.empty()) {
    int cur = Q.front();
    Q.pop();
    if (B[cur] < A[cur]) break;
    if (!local_max(cur)) continue;

    int u = (cur + N - 1) % N;
    int v = (cur + 1) % N;
    int sum = B[u] + B[v];
    int step = (B[cur] - A[cur]) / sum;
    B[cur] -= 1LL * step * sum;
    ret += step;

    if (local_max(u)) Q.push(u);
    if (local_max(v)) Q.push(v);
  }
  for (int i = 0; i < N; ++i) {
    if (B[i] != A[i]) return NOPE;
  }
  return ret;
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
  for (int i = 0; i < N; ++i) scanf("%d", &B[i]);
  printf("%lld\n", solve());
  return 0;
}

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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, m, k, cnt, s;
int mask[10];
int p[10];
int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> k;
        for (int j = 0; j < k; ++j) {
            cin >> s;
            mask[s - 1] |= 1 << i;
        }
    }
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < (1 << n); ++i) {
        int msk = 0;
        bool ok = true;
        for (int j = 0; j < n; ++j) {
            if (i & (1 << j)) {
                msk ^= mask[j];
            }
        }
        for (int j = 0; j < m; ++j) {
            if (((msk & (1 << j)) >> j) != p[j]) {
                ok = false;
                break;
            }
        }
        if (ok)
            ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3652
// https://atcoder.jp/contests/dp/tasks/dp_b
#include <bits/stdc++.h>
using namespace std;

#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector<vector<ll>> happiness(100100, vector<ll>(3));
vector<vector<ll>> dp(100100,vector<ll>(3));
const ll ins[6][2] = { {0,1}, {0,2}, {1,0}, {1,2}, {2,0}, {2,1} };

int main() {
    // 入力
    ll N;cin>>N;
    for( ll i = 0; i < N; i++ ) 
        cin >> happiness.at(i).at(0) >> happiness.at(i).at(1) >> happiness.at(i).at(2);

    for (ll i = 0; i < N; ++i) {
        for (ll j = 0; j < 6 ; j++) {
            if (chmax( dp.at(i+1).at(ins[j][1]),
                   dp.at(i).at(ins[j][0])+
                   happiness.at(i).at(ins[j][1]) )) {
                    //    cout << i+1 << ' ' << ins[j][1] << ' ' << ins[j][0] << ' ';
                    //    cout << dp.at(i+1).at(ins[j][1]) << endl;;
                   }
        }
    }

    cout << *max_element(dp.at(N).begin(), dp.at(N).end()) << endl;

    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n, x;
	cin >> n >> x;
	int arr[n];
	int tmp;
	int dif = INT_MAX;
	REP(i, 0, n){
		cin >> tmp;
		arr[i] = abs(x-tmp);
		//cout << arr[i] << endl;
		if(arr[i] > 0 && arr[i] < dif) dif = arr[i];
	}
	//cout << dif << endl;
	bool f = false;
	while(!f){
		f = true;
		REP(i, 0, n){
			if(arr[i] % dif != 0){
				f=false;
				break;
			}
		}
		if(!f) --dif;
	}
	cout << dif;
	

}


Measured memory_bytes: 640
import collections
import itertools
import sys
import time

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

n,x=getints()
vs=getints()

res = 0
if vs[0] > x:
    eat = vs[0] - x
    res += eat
    vs[0] -= eat

for i in range(1,n):
    exceed = max(0, vs[i-1] + vs[i] - x)
    eat = min(vs[i], exceed)
    vs[i] -= eat
    res += eat
    exceed = max(0, vs[i-1] + vs[i] - x)
    eat = min(vs[i-1], exceed)
    res += eat

print (res)

Measured memory_bytes: 15160
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;



int main(){
  string s;
  int num = 0;
  cin >> s;
  REP(i,(int)s.length()){
    if(s[i] == 'o') num++;
  }
  num += 15 - (int)s.length();
  if(num >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		//??£?¨?
		Scanner sc = new Scanner(System.in);
		int[] dice = new int[6];

		//?¬??????????????????????????????§??°?????????
		while(sc.hasNext()){

			//???????????????????????°????????\??????
			for(int i = 0; i < 6; i++){
				int a = sc.nextInt();
				dice[i] = a;
				//System.out.println(dice[i]);
			}

			//????????????????????????
			String command = sc.next();

			//????????????char????????????
			for(int i = 0; i < command.length(); i++){
				char c = command.charAt(i);
				int a = 0;

				if (c == 'N'){
					a = dice[0];
					dice[0] = dice[1];
					dice[1] = dice[5];
					dice[5] = dice[4];
					dice[4] = a;

				}else if (c == 'S'){
					a = dice[0];
					dice[0] = dice[4];
					dice[4] = dice[5];
					dice[5] = dice[1];
					dice[1] = a;

				}else if (c == 'E'){
					a = dice[0];
					dice[0] = dice[3];
					dice[3] = dice[5];
					dice[5] = dice[2];
					dice[2] = a;

				}else if (c == 'W'){
					a = dice[0];
					dice[0] = dice[2];
					dice[2] = dice[5];
					dice[5] = dice[3];
					dice[3] = a;
				}
			}
			System.out.println(dice[0]);
		}
		sc.close();
	}
}

Measured memory_bytes: 26232
from collections import deque
MOD = 10**9 + 7
while 1:
    N, M = map(int, input().split())
    if N == M == 0:
        break
    G = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    que = deque()
    used = [0]*N
    r = 0; k = 0
    for i in range(N):
        if used[i]:
            continue
        k += 1
        used[i] = 1
        c = 1
        que.append(i)
        while que:
            v = que.popleft()
            for w in G[v]:
                if used[w]:
                    continue
                que.append(w)
                used[w] = 1
                c += 1
        if c > 1:
            r += 1
    if r > 0:
        print((pow(2, k, MOD) + 1) % MOD)
    else:
        print(pow(2, N, MOD))


Measured memory_bytes: 31636
// atcoder abc 176 b
#include<bits/stdc++.h>
using namespace std;
int main(){
   string s;
   cin>>s;
   long long int sum=0;
   for(int i=0;i<s.size();i++)
   sum+=s[i] - '0';
   cout<<(sum%9==0 ? "Yes" : "No");
}


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

int main(){
  int n, sum=0, ans=0;
  cin >> n;
  vi d(n);
  rep(i, n){
    cin >> d[i];
    sum+=d[i];
  }

  rep(i, n){
    ans+=(sum-d[i])*d[i];
  }

  cout << ans/2 << endl;

  return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
from collections import *

S = input()[:-1]
cnt = defaultdict(int)
cnt[0] = 1
ans = 0
now = 0

for i in range(len(S)-1, -1, -1):
    now = (int(S[i])*pow(10, len(S)-1-i, 2019)+now)%2019
    ans += cnt[now]
    cnt[now] += 1

print(ans)

Measured memory_bytes: 69392
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
llint a[200005];

bool check(llint x)
{
	if(x <= 0) return false;
	llint cnt = 0;
	for(int i = 1; i <= n; i++){
		cnt += (a[i]+x-1)/x-1;
	}
	return cnt <= k;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint ub = 2e9, lb = 0, mid;
	while(ub-lb > 1){
		mid = (ub+lb)/2;
		if(check(mid)) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
	
	return 0;
}

Measured memory_bytes: 5212
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int a[10],b[11];
	for(int i=0;i<11;i++)
		b[i]=0;
	memset(b,0,sizeof(b));
	for(int i=0;i<4;i++)
		cin>>a[i];
	for(int i=0;i<4;i++)
		b[a[i]]=1;
	if(b[1]==1&&b[4]==1&&b[7]==1&&b[9]==1)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;				
} 

Measured memory_bytes: 256
import sys
N = int(input())
H = list(map(int, input().split()))

for i in range(N - 1):
    
    if H[i] - H[i + 1] > 1:
        print("No")
        sys.exit()
    
    elif H[i] - H[i + 1] == 1:
        H[i + 1] += 1

print("Yes")

Measured memory_bytes: 63984
import sys
n = input()
nums = [int(e) for e in input().split()]

if 0 in nums:
  print('0')
  sys.exit()

ans = 1
s = 10**18

for i in nums:
  ans = ans * i
  if(ans > s):
    print('-1')
    break


if(ans <= s):
  print(ans)

Measured memory_bytes: 21620
import sys

bingo = [[0 for i in range(3)] for j in range(3)]
for ii in range(0,3):
    a, b, c = map(int, input().split())
    bingo[ii][0] = a
    bingo[ii][1] = b
    bingo[ii][2] = c

n = int(input())
bs = list()
for ii in range(0,n):
    bs.append(int(input()))

for b in bs:
    for ii in range(0,3):
        for jj in range(0,3):
            if bingo[ii][jj] == b:
                bingo[ii][jj] = 0

for ii in range(0,3):
    tmp_row = 0
    tmp_col = 0
    for jj in range(0,3):
        tmp_row = tmp_row + bingo[ii][jj]
        tmp_col = tmp_col + bingo[jj][ii]

    if (tmp_row == 0) or (tmp_col == 0):
        print('Yes')
        sys.exit()

ob1 = bingo[0][0] + bingo[1][1] + bingo[2][2]
ob2 = bingo[0][2] + bingo[1][1] + bingo[2][0]

if (ob1 == 0) or (ob2 == 0):
    print('Yes')
    sys.exit()

print('No')


Measured memory_bytes: 3064
n, k = gets.split( " " ).map { |val| val.to_i }
w = []
maxW = sumW = 0
n.times {
	num = gets.to_i
	sumW += num
	w.push( num )
}
maxW = w.max

minP = 0
if 1 == k
	minP = sumW
elsif n == k
	minP = maxW
else
	left = maxW
	right = 100000*10000
	while left <= right
		middle = ( left+right ).div( 2 )
		truckCnt = i = loadings = 0

		while i < n
			loadings += w[i]
			if middle < loadings
				truckCnt += 1
				break if k < truckCnt+1
				loadings = w[i]
			end
			i += 1
		end
		( minP = middle ) if truckCnt+1 <= k
		
		if k < truckCnt+1
			left = middle + 1		
		else
			right = middle - 1
		end
	end
end

puts( minP )

Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int n=s.size();
	vector<vector<ll>> dp(n+1,vector<ll>(13));
	dp[0][0]=1;
	int k=1;
	for(int i=n-1;i>=0;i--){
		int num=0;
		if(s.at(i)!='?') num=s.at(i)-'0';
		int t=0;
		rep(j,10){
			if(s.at(i)=='?'){
				rep(l,13){
					dp[n-i][(l+t)%13]+=dp[n-i-1][l];
					dp[n-i][(l+t)%13]%=mod;
				}
			}
			else if(j==num){
				rep(l,13){
					dp[n-i][(l+t)%13]+=dp[n-i-1][l];
					dp[n-i][(l+t)%13]%=mod;
				}
			}
			t+=k;
			t%=13;
		}
		k=t;
	}
	cout << dp[n][5] << endl;
}


Measured memory_bytes: 13776
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

int main(){

	int p, q, r;
	scanf("%d %d %d", &p, &q, &r);
	printf("%d\n", min(p+q, min(q+r, p+r)));

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int a[200];
int main(){
    FILE *fp=stdin;//fopen("input.txt","r");
    int k,n;
    fscanf(fp,"%d%d",&k,&n);
    rep(i,0,n) fscanf(fp,"%d",&a[i]);
    if(n==1){ cout<<k-1<<endl; return 0;}
    int maxa=0,id=-1;
    rep(i,0,n) if(a[i]>maxa){id=i, maxa=a[i];}
    int other=0;
    rep(i,0,n) if(i!=id) other+=a[i];
    if(other+1>=maxa) cout<<0<<endl;
    else cout<<maxa-other-1<<endl;
    return 0;
}


Measured memory_bytes: 256
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

struct SegTree {
    data: Vec<i64>,
}

impl SegTree {
    fn id() -> i64 {
        0
    }

    fn op(a: i64, b: i64) -> i64 {
        gcd(a, b)
    }

    fn new(v: Vec<i64>) -> SegTree {
        let mut n = v.len().next_power_of_two();
        let mut data = vec![Self::id(); n * 2];
        for (i, x) in v.into_iter().enumerate() {
            data[n + i] = x;
        }
        for i in (1..n).rev() {
            data[i] = Self::op(data[i * 2], data[i * 2 + 1]);
        }
        SegTree { data: data }
    }

    // update data[n] to x
    fn update(&mut self, n: usize, v: i64) {
        let mut n = n + self.data.len() / 2;
        self.data[n] = v;
        while n > 0 {
            n = n / 2;
            self.data[n] = Self::op(self.data[n * 2], self.data[n * 2 + 1]);
        }
    }

    // query for data[l, r)
    fn query(&mut self, l: usize, r: usize) -> i64 {
        let mut l = l + self.data.len() / 2;
        let mut r = r + self.data.len() / 2;
        let mut vl = Self::id();
        let mut vr = Self::id();
        while l < r {
            if l % 2 == 1 {
                vl = Self::op(vl, self.data[l]);
            }
            l = (l + 1) / 2;

            if r % 2 == 1 {
                vr = Self::op(self.data[r - 1], vr);
            }
            r = r / 2;
        }
        Self::op(vl, vr)
    }
}

fn main() {
    input! {
        n: usize,
        a: [i64; n]
    }

    let mut s = SegTree::new(a);
    let mut ans = 0;
    for i in 0..n {
        let l = s.query(0, i);
        let r = s.query(i + 1, n);
        let x = gcd(l, r);
        ans = std::cmp::max(ans, x);
    }

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


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N, ans;
  ans = 0;
  cin >> N;
  int L[N+1];
  for (int i = 0; i < N; ++i) {
    cin >> L[i];
  }
  // sort(L, L+N);
  for (int i = 0; i < N-2; ++i) {
    for (int j = i+1; j < N-1; ++j) {
      for (int k = j+1; k < N; ++k) {
        if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k]) {
          continue;
        }
        if (abs(L[k]-L[j]) < L[i] && L[i] < L[k] + L[j]) {
          ++ans;
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3760
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC109C
{
    static class MainClass
    {
        public static void Main(string[] args)
        {

            string[] input1 = Console.ReadLine().Split(' ');
            int N = int.Parse(input1[0]);
            int X = int.Parse(input1[1]);

            string[] input2 = Console.ReadLine().Split(' ');
            var x = new List<int>();
            for (int i = 0; i < N; i++)
            {
                x.Add(int.Parse(input2[i]));
            }

            x.Sort();

            for (int i = 0; i < N - 1; i++)
            {
                x[i + 1] = Gcd(Math.Abs(x[i] - X), Math.Abs(x[i + 1] - X))+X;
            }

            Console.WriteLine(Math.Abs(x[N - 1]-X));

        }


        public static int Gcd(int a, int b){
            int tmp;
            // a<bにする
            if(a >=b){
                tmp = a;
                a = b;
                b = tmp;
            }

            if (a == 0){
                return b;
            }

            tmp = a;
            a = b % a;
            b = tmp;
            return Gcd(a, b);

        }


    }

}






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

void Solve(){
    vector<bool> vst(6);
    for(int i = 0; i < 5; i++){
        int x;
        cin>>x;
        vst[x] = true;
    }
    for(int i = 1; i <= 5; i++){
        if(!vst[i]){
            cout<<i<<'\n';
            return;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    //cin>>T;
    while(T--){
        Solve();
    }
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n;
  cin >> n;
  
  int a = 1000;
  
  while(a < n)
    a+= 1000;
  
  cout << a-n << endl;
  
  return 0;
  
}

Measured memory_bytes: 3628
<?php
fscanf(STDIN, '%d', $len);
fscanf(STDIN, '%s', $str);
if (strlen($str) <= $len) {
    echo $str;
} else {
    $arr = str_split($str);
    for ($i=0; $i < $len; $i++) { 
        echo $arr[$i];
    }
    echo '...';
}

Measured memory_bytes: 16208
s = list(input())
g_minus_p = 0
score = 0
for i in range(len(s)):
    if g_minus_p > 0:
        g_minus_p -= 1
        if s[i] == "g":
            score += 1
    else:
        g_minus_p += 1
        if s[i] == "p":
            score -= 1
print(score)


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

class Cube{
	public:
		int f[6];
		Cube(){}
		void roll_z(){ roll(1, 2, 4, 3);}
		void roll_y(){ roll(0, 2, 5, 3);}
		void roll_x(){ roll(0, 1, 5, 4);}
		void roll(int i, int j, int k, int l){
			int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
		}
};

bool eq(Cube c1, Cube c2){
	for(int i=0;i<6;i++)
		if(c1.f[i] != c2.f[i]) return false;
	return true;
}

bool equal(Cube c1, Cube c2){
	for(int i=0;i<6;i++){
		for(int j=0;j<4;j++){
			if(eq(c1,c2)) return true;
			c1.roll_z();
		}
		if(i%2==0) c1.roll_y();
		else c1.roll_x();
	}
	return false;
}

Cube C[100]; int n;

bool check(){
	for(int i=0;i<n-1;i++)
		for(int j=i+1;j<n;j++) if(equal(C[i],C[j])) return false;
	return true;
}

int main(){
	cin >> n;

	for(int j=0;j<n;j++)
		for(int i=0;i<6;i++) cin >> C[j].f[i];

	if(check()) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3100
input = gets.split

def reverse_porland(input)
  stack = []
  input.each do |i|
    if i == '+' || i == '-' || i == '*'
      a = stack.pop
      b = stack.pop
      c = b.send(i.to_sym, a)
      stack.push(c)
    else
      stack.push(i.to_i)
    end
  end
  return stack[0]
end

ans = reverse_porland(input)
puts ans


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

int main(){
    int n,a,b,c,d=0;
    cin >> n;
    vector<string> ja(n);
    for(int i=0;i<n;i++){
        cin >> ja.at(i);
    }
    a = 0;
    b =0;
    c=0;
    d=0;
    for(int i=0;i<n;i++){
        if(ja.at(i)=="AC"){
            a++;
        }else if(ja.at(i)=="WA"){
            b++;
        }else if(ja.at(i)=="TLE"){
            c++;
        }else if(ja.at(i)=="RE"){
            d++;
        }
    }
    cout <<"AC x "<<a<<endl;
    cout <<"WA x "<<b<<endl;
    cout <<"TLE x "<<c<<endl;
    cout <<"RE x "<<d<<endl;
}

Measured memory_bytes: 6352
import collections
head = 0
tail = 0


def queue_put(q, a):
    global tail
    q[tail] = a
    tail = (tail + 1) % len(q)


def queue_get(q):
    global head
    result = q[head]
    head = (head + 1) % len(q)
    return result


Q = collections.namedtuple("Q", "nm tm")
n, period = map(int, input().split())

q = ["" for _ in range(n + 1)]
for i in range(n):
    nm, tmp = input().split()
    tm = int(tmp)

    queue_put(q, Q(nm, tm))

tm = 0
while head != tail:
    a = queue_get(q)

    d = min(period, a.tm)
    tm += d
    a = a._replace(tm=a.tm - d)

    if a.tm == 0:
        print(a.nm, tm)
    else:
        queue_put(q, a)


Measured memory_bytes: 14336
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;
//* dfs for bipartite graph check
bool dfs(vector<vll> &G, vll &color, ll v, ll c){
    color[v] = c; //* 
    REP(u, G.size()){
        if(G[v][u] == INF) continue; //* no edge
        if(color[u] == c)  //* if already painted same color
            return false;
        if(color[u] == 0 && !dfs(G, color, u, -c)) //* something wrong deeper
            return false;  
    }
    return true;
}

//* dijkstra algorithm with adjacency matrix
void dijkstra(vector<vll> &G, vll &dist, ll s){
    fill(dist.begin(), dist.end(), INF);
    priority_queue<pll, vector<pll>, greater<pll> > que;
    dist[s] = 0;
    que.push(pll(0, s));
    while(!que.empty()){
        ll score = que.top().first;
        ll u = que.top().second;
        que.pop();
        for(ll v=0; v< G[u].size(); v++){
            if(dist[v] > score + G[u][v]){
                dist[v] = score + G[u][v];
                que.push(pll(dist[v], v));
            }
        }
    }
    return;
}

//* calculate diameter of a Graph in O(m*n*log n)
ll graphDiameter(vector<vll> &G){
    ll N = G.size();
    vector<vll> D(N, vll(N, INF));
    //* calculate all-pair shortest path
    REP(i, N){
        dijkstra(G, D[i], i);
    }
    ll res = 0;
    REP(i, N){
        REP(j, N){
            if(D[i][j] < INF)
                res = max(res, D[i][j]);
        }
    }
    return res;
}

void solve(){
    //* process input
    long long N;
    scanf("%lld",&N);
    std::vector<string> S(N);
    for(int i = 0 ; i < N ; i++) cin >> S[i];
    vector<vll> G(N, vll(N, INF));
    REP(i, N)  REP(j, N)  if(S[i][j] == '1') G[i][j] = 1;
    //* check bipartite graph
    vll color(N, 0);
    bool isBipartite = dfs(G, color, 0, 1);
    if(!isBipartite){
        cout<<-1<<endl; return;
    }
    //* calculate graph diameter
    ll dm = graphDiameter(G);
    cout<<dm+1<<endl;
}

int main(){
    
    solve();
    return 0;
}


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

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        var list1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x));
        int q = int.Parse(Console.ReadLine());
        var list2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x));

        var intersectList = list1.Intersect(list2);
        Console.WriteLine(intersectList.Count());


    }
}


Measured memory_bytes: 31460
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

string s,s1;
string S;


int solve(){
    s=S;
    int count=0;
    for(int i=0;i<(int)s.size()-1;i++){
        if(s[i+1]==s[i]){
            count++;
            s[i+1]='?';
        }
    }
    return count;
}



int main(){
    ll K;
    cin>>S>>K;
    int ans=solve();
    bool flag=true;
    for(int i=1;i<S.size();i++){
        if(S[i]!=S[0]) flag=false;
    }
    if(flag){
        int num=S.size();
        cout<<(num*K)/2<<endl;
    }else{
        int num=S.size();
        for(int i=0;i<num;i++) S.push_back(S[i]);
        int ans2=solve();
        ll sum=ans+(ans2-ans)*(K-1);
        cout<<sum<<endl;
    }

}


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

using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	if (a == b)
	{
		cout << "Draw" << endl;
	}
	else if (a == 1)
	{
		cout << "Alice" << endl;
	}
	else if (b == 1)
	{
		cout << "Bob" << endl;
	}
	else if (a-b > 0)
	{
		cout << "Alice" << endl;
	}
	else if (a - b < 0)
	{
		cout << "Bob" << endl;
	}
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    string n;
    cin >> n;
    ((n[0] == '9' || n[1] == '9') ? puts("Yes") : puts("No"));
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		int result = 0;
		if(s.equals("SUN")){
		    result = 7;
		}else if(s.equals("MON")){
		    result = 6;
		}else if(s.equals("TUE")){
		    result = 5;
		}else if(s.equals("WED")){
		    result = 4;
		}else if(s.equals("THU")){
		    result = 3;
		}else if(s.equals("FRI")){
		    result = 2;
		}else if(s.equals("SAT")){
		    result = 1;
		}
		
		// 出力
		System.out.println(result);
	}
	
}


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

using namespace std;

typedef long long ll;


int main()
{

int n;
cin>>n;

vector<int> first;
for(int index=1;index<=n;index++)
    first.push_back(index);

vector<int> P,Q;
for(int index=0;index<n;index++)
{
    int val;
    cin>>val;

    P.push_back(val);
}

for(int index=0;index<n;index++)
{
    int val;
    cin>>val;

    Q.push_back(val);
}

int a=0,b=0;
int counter=0;
do{
   bool equa=true;
   for(int index=0;index<n;index++)
    if(first[index]!=P[index])
   {
       equa=false;
       break;
   }
   if(equa)
    a=counter;


      equa=true;
   for(int index=0;index<n;index++)
    if(first[index]!=Q[index])
   {
       equa=false;
       break;
   }
   if(equa)
    b=counter;

    counter++;

}
while(next_permutation(first.begin(),first.end()));


cout<<abs(a-b)<<endl;
return 0;
 }



Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int x[2010],n,a,b;
int main(){
  cin>>n>>a>>b;
  lol(i,n)cin>>x[i];
  int ans=abs(b-x[n-1]);
  if(n>1)ans=max(ans,abs(x[n-2]-x[n-1]));
  cout<<ans<<endl;
  return 0;
}


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

string t;
ll rp, sp, pp;
ll cal_score(char hand) {
  if (hand == 'r') return pp;
  if (hand == 's') return rp;
  if (hand == 'p') return sp;
  return 0;  // ここは通らない。
};

int main() {
  int n, k;
  cin >> n >> k >> rp >> sp >> pp >> t;

  ll score = 0;
  for (int i = 0; i < k; i++) {
    // MOD k で場合分け
    // 同じグループ内なら、「前回と同じ手は出せない」の条件になる。
    // プレイヤーはあいこ無し。勝つか負けるかする。

    bool lose_before = false;
    for (int j = i; j < n; j += k) {
      if (j == i) {
        // 初手は勝利
        score += cal_score(t[j]);
        lose_before = false;
        continue;
      }

      if (t[j - k] != t[j]) {
        // ロボットの手が前回と異なるとき、必ず勝てる。
        score += cal_score(t[j]);
        lose_before = false;
        continue;
      }

      if (t[j - k] == t[j] && lose_before) {
        // ロボットの手が前回と同じとき、前回負けてたら今回必ず勝てる。
        score += cal_score(t[j]);
        lose_before = false;
        continue;
      }

      lose_before = true;
    }
  }

  cout << score << endl;
  return 0;
}

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


int main(){
    int N, K;
    int p[1000];
    int res=0;
    cin >> N >> K;
    for(int i=0; i<N; i++)
        cin >> p[i];

    sort(p, p+N);
    for(int i=0; i<K; i++){
        res += p[i];
    }
    cout << res << endl;

    
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

string s;

int main() {
	rd(s);
	if (s[0] == s[2]) wrln("Yes");
	else wrln("No");
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[]
sum=0
res=0
for i in range(m):
  d,e=map(int,input().split())
  b.append([e,d])
a.sort()
b.sort()
b.reverse()

for i in range(1,m):
  b[i][1]+=b[i-1][1]

id=0
if b[0][1]>0 and b[0][0]>a[0]:
  a[0]=b[0][0]
if n>=2:
  for i in range(1,n):
    while i>b[id][1]-1:
      id+=1

      if id>m-1:
        break
    if id>m-1:
      break
    if b[id][0]>a[i]:
      a[i]=b[id][0]
    else:
      break
for i in range(n):
  res+=a[i]
print(res)


Measured memory_bytes: 27576
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int m[5];
int main()
{
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++)m[s[i]-'a']++;
    sort(m,m+3);
    m[1]-=m[0],m[2]-=m[0];
    if(m[2]<2)puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
//  int a, b, c, d, e, X, Y;
  int a, b, c,  d, e,f;
  //  double  c;
//  long long  A[1000001]={};
  int  A[2000001]={};
  int  B[2000001]={};
  int  ans[100003]={};
  int  sum[100003]={};
  int  cnt_flag[100003]={};

  int  L[1003]={};


//  long long  a, b, c, d, X, Y;
//  long long   d, X, Y;
  long long JPY;
  double BTC;
  char s[200001]={};
  char t[200001]={};
  char u[200001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  int flag=0;
//  int flag[10000003]={};
  int tmp=0;
//  int min=1000000;
  int min=10;
  int len=0;
  int cnt=0;
  int cnt0=0;
  int cnt1=0;
  int num=0;
//  double ans=0.0;
//  long long ans=0;
  int max=0;
//  int sum=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
 

  scanf("%s", &s);
  len=strlen(s);
//  scanf("%d", &max);
  for(i=0;i<len;i++){
    if(s[i-1]=='0'){
//  printf("%d\n", cnt);
      if(s[i]=='0'){
        s[i]='1';
        cnt++;
      }
    }
    if(s[i-1]=='1'){
      if(s[i]=='1'){
        s[i]='0';
        cnt++;
      }
    }
  }
  
  printf("%d\n", cnt);
/*    
    */

//  printf("%s\n",s);
//    else  
  
return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int n;
int A[100010];
ll sum[200010];

bool check(int i, ll x, bool f = false)
{
    int nowidx = i;
    ll cur = i == 0 ? 0 : sum[i - 1];

    rep(_, 2) {
        nowidx = lower_bound(sum, sum + i + n, cur + x) - sum;
        if (nowidx == i + n) return false;
        cur = sum[nowidx];
    }

    return sum[i + n - 1] - sum[nowidx] >= x;
}

int main()
{
    n = in();

    rep(i, n) {
        A[i] = in();
        sum[i] = A[i];
        if (i) sum[i] += sum[i - 1];
    }

    rep(i, n - 1) {
        sum[i + n] = A[i] + sum[i + n - 1];
    }

    ll ma = 0;

    rep(i, n) {
        ll l = 0, r = linf;

        rep(_, 65) {
            ll mid = (l + r) / 2;

            (check(i, mid) ? l : r) = mid;
        }

        chmax(ma, l);
    }

    printf("%lld\n", ma);
}

Measured memory_bytes: 5168
def main():
    S = list(input())
    T = list(input())
    S.reverse()
    T.reverse()
    SL = list(S)
    f = False
    for i in range(len(S) - len(T) + 1):
        SL = list(S)
        for j in range(len(T)):
            if S[i + j] == '?' or S[i + j] == T[j]:
                SL[i + j] = T[j]
            else:
                break
        else:
            f = True
            break
    if f is False:
        print('UNRESTORABLE')
    else:
        SL.reverse()
        print(''.join(SL).replace('?', 'a'))


main()


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

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int x;
  cin >> x;
  if (x >= 2100) cout << 1 << endl;
  
  else {
    int a = x / 100, b = x % 100;
    if (a * 5 < b) cout << 0 << endl;
    else cout << 1 << endl;
  }

  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (x + r > W||x - r < 0||y + r > H||y - r < 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3100