akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            boolean ok = false;
            if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) ok = true;
            out.println(ok ? "Possible" : "Impossible");

        }

    }
}



Measured memory_bytes: 21844
D, G = map(int, input().split())
PC = [list(map(int, input().split())) for i in range(D)]
PC_new = sorted([(PC[i][0]*100*(i+1) + PC[i][1], PC[i][0]) for i in range(D)],
                key=lambda x: x[1], reverse=True)

ans = 99999999
for i in range(1<<D):
    ct = 0
    score = 0
    for j in range(D):
        if i>>j&1:
            score += PC[j][1]
            score += PC[j][0] * (j+1) * 100
            ct += PC[j][0]
    for j in range(D-1, -1, -1):
        if i>>j&1: continue
        if score >= G: break
        g = (j+1)*100
        got = (G-score+g-1)//g
        score += min(got, PC[j][0]) * g
        ct += min(got, PC[j][0])
    ans = min(ans, ct)
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

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

    int cnt = 0;
    for(int i=0;i<N;i++){
        int day = 1;
        while(day<=D){
            cnt++;
            day += A[i];
        }
    }
    cout << cnt + X << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100100
using namespace std;
typedef long long LL;
int prime[2200],len;
int n,m,ans;
LL l[N],r[N];
map<LL,int> ma;
int main(){
	for(int i=2;i<2200;i++){
		int fla=1;
		for(int j=2;j<i;j++)
			if(i%j==0) fla=0;
		if(fla) prime[len++]=i;
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		long long a,els=1,f=1;
		scanf("%lld",&a);
		for(int j=0;j<len;j++){
			int t=0;
			while(a%prime[j]==0) a/=prime[j],t++;
			t%=3;
			if(t){
				for(int i=t;i<3;i++){
					els*=prime[j];
					if(els>1e10) els=0;
				}
				while(t) f*=prime[j],t--;
			}
		}
		ma[f*a]++;
		l[i]=f*a,r[i]=els;
		long long w=(LL)sqrt(a);
		if(w*w!=a){
			if(a*r[i]<=1e10) r[i]*=a;
			else r[i]=0;
			if(a*r[i]<=1e10) r[i]*=a;
			else r[i]=0;
		}
		else{
			if(r[i]*w<=1e10) r[i]*=w;
			else r[i]=0;
		}
	}
	for(int i=0;i<n;i++){
		if(l[i]==1) continue;
		ans+=max(ma[l[i]],ma[r[i]]);
		ma[l[i]]=ma[r[i]]=0;
	}
	ans+=(ma[1]>0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 12032
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=2E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
void solve(){
    int k,a,b;
    cin>>k>>a>>b;
    fr(i,a,b){
        if(i%k==0){
            cout<<"OK\n";
            return;
        }
    }
    cout<<"NG\n";
    return;
}
int main(){
    IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>

using namespace std;



int main(){
    int N, M;
    while(cin >> N >> M){
        string res(N, '?');
        bool valid = true;
        for(int i=0;i<M;i++){
            int s, c; cin >> s >> c;
            if(s == 1 && c == 0 && N != 1) valid = false;
            if(res[s-1] != '?' && res[s-1] - '0' != c) valid = false;
            res[s-1] = c + '0';
        }
        if(valid){
            for(int i=0;i<N;i++){
                if(res[i] == '?') res[i] = (i==0 && N > 1 ? '1' : '0');
            }
            cout << res << endl;
        } else {
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

W, H, x, y = rl()

area = H*W*0.5
flag = 0
if x*2 == W and y*2 == H:
	flag = 1
print(area, flag)


Measured memory_bytes: 68640
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n,m;
    cin >> n >> m;
    
    vector<LL> vec(n+1,0);

    for(int i = 0; i < m; i++){
        LL a,b;
        cin >> a >> b;
        vec[a]++;
        vec[b]++;
    }

    bool ans = true;

    for(int i = 1; i < n+1; i++){
        ans &= vec[i]%2==0;
    }

    cout << (ans?"YES":"NO") << endl;

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve()
{
    double H, A; cin >> H >> A;
    cout << ((int)ceil(H / A)) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    for i in range(n):
        if a[i] == ans + 1:
            ans += 1
    if ans:
        print(n - ans)
    else:
        print(-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26524
#include<bits/stdc++.h>
    #define _USE_MATH_DEFINES
    using namespace std;
    
    #define ll long long int
    #define pb push_back
    #define rep(i , j , n) for(ll i = j ; i < n ; i++)
    #define per(i , j , n) for(ll i = j ; i >= n ; i--)
    #define all(x) x.begin(), x.end()
    typedef pair<int, int>	pii;
    typedef pair<ll, ll>	pl;
    typedef vector<int>		vi;
    typedef vector<ll>		vll;
    typedef vector<bool>	vb;



int main(){ 
    ll n;
    cin >> n;
    string ans = "";
    while(n > 0){
        ll i = n % 26;
        if(i == 0){
            char x = 'z';
            ans += x;
            n = (n/26) - 1;
            continue;
        } 
        i = (i + 26 - 1) % 26;
        char x = 'a' + i;
        ans += x;
        n = n/26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  string s;
  cin >> s;
  map<char, int> ss;
  rep(i, 0, s.size()) ss[s[i]]++;
  if (ss.size() == 2 && ss[s[0]] == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << 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() {
  string a;
  cin>>a;
  
  if(a.at(0)=='7'||a.at(1)=='7'||a.at(2)=='7'){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void){

  char s[100000+1];
	int end;
	for (int i = 0; i < 100000+1; i++) {
		scanf("%c", &s[i]);
		if (s[i] < 'a' || s[i] > 'z') {
			end = i-1;
			break;
		}
	}

	int flag = 1;
	for (int i = end; i >= 0; i--) {
		if (s[i] == 'm') {
			if (s[i-1] == 'a' && s[i-2] == 'e' && s[i-3] == 'r' && s[i-4] == 'd') {
				i = i-4;
			} else {
				flag = 0;
				break;
			}
		} else if (s[i] == 'r') {
			if (s[i-1] == 'e' && s[i-2] == 'm' && s[i-3] == 'a' && s[i-4] == 'e' && s[i-5] == 'r' && s[i-6] == 'd') {
				i = i-6;
			} else if (s[i-1] == 'e' && s[i-2] == 's' && s[i-3] == 'a' && s[i-4] == 'r' && s[i-5] == 'e') {
				i = i-5;
			} else {
				flag = 0;
				break;
			}
		} else if (s[i] == 'e') {
			if (s[i-1] == 's' && s[i-2] == 'a' && s[i-3] == 'r' && s[i-4] == 'e') {
				i = i-4;
			} else {
				flag = 0;
				break;
			}
		} else {
			flag = 0;
			break;
		}
	}

	if (flag == 1) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

  return 0;
}

Measured memory_bytes: 256
md = 10 ** 9 + 7
n = int(input())
s = input()
dp = [1] * n
for i in range(n - 1):
    if s[i] == "<":
        L = dp[0]
        for dpi in range(1, n - i - 1):
            dp[dpi] = L = (dp[dpi] + L) % md
        dp = dp[:-1]
    else:
        R = dp[-1]
        for dpi in range(n - i - 2, 0, -1):
            dp[dpi] = R = (dp[dpi] + R) % md
        dp = dp[1:]
print(dp[0])


Measured memory_bytes: 3064
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

pii indt[1100000];
void update(int p, pii v) {
	p += IT_MAX - 1;
	for (; p; p /= 2) indt[p] = min(indt[p], v);
}
pii getmn(int p1, int p2) {
	p1 += IT_MAX - 1;
	p2 += IT_MAX - 1;
	pii rv = pii(INF, INF);
	for (; p1 <= p2; p1 /= 2, p2 /= 2) {
		if (p1 % 2 == 1) rv = min(rv, indt[p1++]);
		if (p2 % 2 == 0) rv = min(rv, indt[p2--]);
	}
	return rv;
}

int in[500050];
int rin[500050];

vector <int> conn[500050];
vector <int> rconn[500050];
int deg[500050];
int ans[500050];
int main() {
	int N, K, i, j;
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) {
		scanf("%d", &in[i]);
		rin[in[i]] = i;
	}
	
	memset(indt, 0x3f, sizeof(indt));
	for (i = N; i >= 1; i--) {
		int p = rin[i];

		int st = p + 1, en = min(N, p + K - 1);
		pii u = getmn(st, en);
		if (u.first != INF) {
			conn[p].push_back(u.second);
			rconn[u.second].push_back(p);
		}

		st = max(1, p - K + 1), en = p - 1;
		u = getmn(st, en);
		if (u.first != INF) {
			conn[p].push_back(u.second);
			rconn[u.second].push_back(p);
		}

		update(p, pii(in[p], p));
	}

	for (i = 1; i <= N; i++) deg[i] = conn[i].size();

	priority_queue <int> Hx;
	for (i = 1; i <= N; i++) if (!deg[i]) Hx.push(i);

	for (i = N; i >= 1; i--) {
		int t = Hx.top();
		Hx.pop();

		for (auto it : rconn[t]) {
			deg[it]--;
			if (deg[it] == 0) Hx.push(it);
		}
		ans[t] = i;
	}
	for (i = 1; i <= N; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 75136
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(n)]
for x in a:
  l[x-1]+= 1
sum = 0
for x in l:
  sum += x * (x - 1) // 2
for x in a:
  y = l[x-1]
  r = y * (y - 1) // 2 - (y - 1) * (y - 2) // 2
  print(sum - r)

Measured memory_bytes: 25716
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  vector<ll> a;
  rep(i,3){
    ll inp;
    cin >> inp;
    a.pb(inp);
  }

  sort(rall(a));

  cout << a[0]* 10 + a[1]+ a[2]<< endl;
    

  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << x
#define print(x) cout << x << '\n'
#define debug(x) cerr << #x << ": " << x << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        ll p[n], c[n];
        mn = INF;
        rep(i, n){
            cin >> p[i] >> c[i];
        }
        rep(mask, (1 << n)){
            ll tmp = 0, num = 0, rest_max = -1;
            rep(i, n){
                if(mask >> i & 1){
                    tmp += 100 * (i + 1) * p[i] + c[i];
                    num += p[i];
                }else{
                    rest_max = i;
                }
            }
            if(tmp < m){
                ll tmp1 = 100 * (rest_max + 1);
                ll need = (m - tmp + tmp1 - 1) / tmp1;
                if(need >= p[rest_max]){
                    continue;
                }
                num += need;
            }
            mins(mn, num);
        }
        print(mn);
    }
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

str_lines = [x.strip("\n") for x in sys.stdin.readlines()]
int_lines = list( map( int, str_lines ) )

#-----
i=1
for x in int_lines:
  if x != 0:
    print( "Case " + str(i) + ": " + str(x) )
    i += 1



Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  string s;
  cin>>s;
  int flag=0;
  int fb=0;
  int ans=0;
  rep(i,s.size() ){
    //cout<<flag<<" "<<fb<<endl;
    if(s[i]=='A'){
      if(fb==1){flag=1;fb=0;}
      else flag++;
    }else{
      if(s[i]=='B'){
	if(fb==0 && flag!=0) fb++;
	else{flag=0;fb=0;}
      }
      if(s[i]=='C'){
	if(fb==1){
	  ans+=flag;
	  fb=0;
	}else{flag=0;fb=0;}
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define M 55
ll dp[M][2][2];//取不取、奇偶 
int a[M];
int n,p;
int main(){
	scanf("%d %d",&n,&p);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		x%=2;
		a[i]=x;
	}
	memset(dp,0,sizeof dp);
	dp[0][1][0]=dp[0][0][0]=1;
	for(int i=1;i<=n;i++){
		dp[i][0][0]=dp[i-1][1][0]+dp[i-1][0][0];
		dp[i][0][1]=dp[i-1][1][1]+dp[i-1][0][1];
		if(a[i]){
			dp[i][1][0]=dp[i-1][0][1]+dp[i-1][1][1];
			dp[i][1][1]=dp[i-1][0][0]+dp[i-1][1][0];
		}else{
			dp[i][1][0]=dp[i-1][0][0]+dp[i-1][1][0];
			dp[i][1][1]=dp[i-1][0][1]+dp[i-1][1][1];
		}
	}
	printf("%lld\n",(dp[n][1][p]+dp[n][0][p])>>1ll);
	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>

int main(void) {
  int n;
  char s[10000];
  scanf("%d",&n);
  scanf("%s",&s);

  for (int i = 0; s[i]!='\0'; i++)
  {
    if(s[i]=='\0')break;
    s[i]+=n;
    if(s[i]>=91){
      s[i]=64+(s[i]-90);
    }
  }
  printf("%s\n",s);
  return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
c = 0
l = list(map(int, input().split()))
s = sum(l)/(4*m)
#print(n, m, s)
for i in l:
#  print(i, s)
  if i >= s:
    c = c + 1
if c >= m:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define mod 1000000007
#define sz(v) v.size()
#define all(x) x.begin(), x.end()
#define prec(x) fixed << setprecision(x)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)
#define speedup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;

void solve(){
    int a, b;
    cin >> a >> b;
    cout << a*b;
}

int32_t main() {
    speedup;

    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    // test{
        solve();
    // }

    return 0;
}


Measured memory_bytes: 3656
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const n: number = parseInt(tmp[0].split(" ")[0]);
    const list: number[] = [];
    let max1: number = 0;
    let max2: number = 0;
    for (let i = 1; i <= n; i++) {
      const a: number = parseInt(tmp[i].split(" ")[0]);
      list.push(a);
      if (max1 < a) {
        if (max2 < max1) {
          max2 = max1;
        }
        max1 = a;
      } else if (max2 < a || max1 == a) {
        max2 = a;
      }
    }
    const isMaxDouble: boolean = max1 == max2;
    const result: number[] = [];
    for (let i = 0; i < n; i++) {
      if (!isMaxDouble && list[i] == max1) {
        result.push(max2);
      } else {
        result.push(max1);
      }
    }
    return `${result.join("\n")}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  string s;
  cin >> s;
  vector<int> ctoi(256);
  ctoi['r'] = 2;
  ctoi['s'] = 0;
  ctoi['p'] = 1;
  int ans = 0;
  rep(i, k) {
    vector<int> x;
    // 1: rrr
    // 2: sp
    for (int j = i; j < n; j += k) {
      x.push_back(ctoi[s[j]]);
    }
    // 1: 222
    // 2: 01
    var prev = -1;
    for (var nx : x) {
      if (prev == nx) {
        ans += 0;
        // cout << "[" << ans << "]" << endl;
        prev = -1;
      } else {
        ans += a[nx];
        // cout << "[" << ans << "]" << endl;
        prev = nx;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1020
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;


int main() {
	string s; cin >> s;
	sort(s.begin(), s.end());
	int count = 1;
	int tmp = 0;
	//cout << s << endl;
	if (s.size() != 1) {
		for (int i = 0; i < s.size() - 1; i++) {
			if (s[i] == s[i + 1]) {
				count++;
			}
			else if (count % 2 == 1) {
				tmp++;
				break;
			}
			else {
				count = 1;
			}
		}
	}
	else {
		tmp++;
	}
	if (tmp == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

    

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

int main() {
  string str;
  long long k;
  bool iti=false;
  cin >> str;
  cin >> k;
  for(int i=0;i!=k;i++){
    if(str[i]=='1') i=i+1-1;
    else {
      cout << str[i] << endl;
      iti=true;
      break;
    }
  }
  if(iti==false){
    cout << "1" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 101001001;
const ll MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  int lis[100000];
  fill(lis, lis + 100000, -1);
  rep(i, n){
    int a;
    cin >> a;
    int k = 0;
    while(a <= lis[k]){
      k++;
    }
    lis[k] = a;
  }
  int i = 0;
  while(lis[i] >= 0) i++;
  cout << i << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    int N=1;
    rep(i,n-1) N*=10;
    int d[5]; d[0] = 1;
    rep(i,4) d[i+1]=d[i]*10;
    vi s(m),c(m);
    rep(i,m) cin>>s[i]>>c[i];
    if (n==1){
        bool ng = false;
        rep(j,m){
            if (0!=c[j]){
                ng = true;
                break;
            }
        }
        if (!ng){
            cout<<0<<endl;
            return 0;
        }
    }
    FOR(i,N,N*10-1){
        bool ng = false;
        rep(j,m){
            if ((i/d[n-s[j]])%10!=c[j]){
                ng = true;
                break;
            }
        }
        if (!ng){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int64_t MIN=A[0],sum=0;
  for(int i=1;i<N;i++){
    if(A[i]<MIN){sum+=(MIN-A[i]);}
    MIN=max(MIN,A[i]);
  }
  cout<<sum<<endl;
  return 0;  
}

Measured memory_bytes: 4788
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

int n, W;
int[] w;
int[] v;

long[][] dp = new long[][](114, 100010);
long rec(int i, int j) {
    if (i == n)
        return 0;
    if (dp[i][j] >= 0)
        return dp[i][j];
    if (j + w[i] <= W)
        return dp[i][j] = max(rec(i+1, j), rec(i+1, j + w[i]) + v[i]);
    else
        return dp[i][j] = rec(i+1, j);
}

void main() {
    readf("%d %d\n", &n, &W);
    w.length = v.length = n;
    foreach (i ; 0..n) {
        readf("%d %d\n", &w[i], &v[i]);
    }
    foreach (r ; dp) fill(r, -1);
    writeln(rec(0, 0));
}


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

int main() {
    vector<int> R, G, B;
    int N; char x;
    cin>>N;
    for(int i=0; i<N; i++){
        cin>>x;
        if(x=='R')  R.push_back(i);
        if(x=='G')  G.push_back(i);
        if(x=='B')  B.push_back(i);
    }

    long long cnt = 0;
    for(auto r : R)
        for(auto g : G)
            for(auto b : B)
                if(2*g != r+b && 2*r!=g+b && 2*b!=r+g)
                    cnt++;

    cout<<cnt<<endl;
}


Measured memory_bytes: 3228
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int N = sc.nextInt();
		
		int[] a = new int[N];
		int large = -1;
		int small = -1;
		
		for(int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			
			if(large != -1 && small != -1 && a[i] != large && a[i] != small) {
				System.out.println("No");
				return;
			}
			
			if(large == -1 || a[i] == large) {
				large = a[i];
			} else {
				if(a[i] > large) {
					small = large;
					large = a[i];
				} else {
					small = a[i];
				}
			}
		}
		
		if(small != -1 && large != small + 1) {
			System.out.println("No");
			return;
		}
		
		if(small == -1 && N == large + 1) {
			System.out.println("Yes");
			return;
		}
		
		for(int i=0; i<a.length; i++) {
			if(a[i] == small) {
				N--;
				large--;
			}
		}
		
		if(large >= 1 && N >= large * 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 35256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

H, W, K = rl()
M = []
for i in range(H):
	M.append(rs())

import itertools

def check(b1, b2):
	cnt = 0
	for i in range(H):
		if b1[i]: continue
		for j in range(W):
			if b2[j]: continue
			if M[i][j] == '#':
				cnt += 1
				if cnt > K:
					return False
	if cnt == K:
		return True
	else:
		return False

ans = 0
for b1 in itertools.product([0,1], repeat=H):
	for b2 in itertools.product([0,1], repeat=W):
		if check(b1, b2):
			ans += 1

print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ll mod = 1000000007;


int main(){
    ll A, B, M;
    cin >> A >> B >> M;
    vecll a(A), b(B), x(M), y (M), c(M);
    for(auto& i : a) cin >> i;
    for(auto& i : b) cin >> i;
    for(ll i = 0; i < M; i++) cin >> x.at(i) >> y.at(i) >> c.at(i);

    ll ans = 0;
    ans = *std::min_element(a.begin(), a.end()) + *std::min_element(b.begin(), b.end());
    for(ll i = 0; i < M; i++){
        ans = min(ans, a.at(x.at(i) - 1) + b.at(y.at(i) - 1) -c.at(i));
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

int R;
int d[N];

vector<int> g[N];
vector<int> path;

void dfs(int u,int p)   {
    d[u] = d[p] + 1;

    if (d[R] < d[u])
        R = u;
    
    for(int v : g[u])   if (v != p)
        dfs(v,u);
}
bool on_diameter[N];

void cal(int u,int p)   {
    path.pb(u);

    if (u == R) {
        on_diameter[u] = 1;
        return;
    }   
    for(int v : g[u])   if (v != p) {
        cal(v,u);
        if (on_diameter[v]) {
            on_diameter[u] = 1;
            return;
        }
    }
    path.pop_back();
}

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

    int n;  cin >> n;

    for(int i = 1 ; i < n ; ++i)    {
        int x;  cin >> x;
        int y;  cin >> y;

        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0);   int Rt = R;
    dfs(Rt,0);
    cal(Rt,0);

    vector<int> ans(n,1e9);

    for(int T = 0 ; T < 2 ; ++T)    {
        vector<int> res;
        int cur = 1;

        for(int x : path)   {
            int cnt = 0;

            for(int v : g[x])   if(!on_diameter[v]) {
                if (g[v].size() > 1)    {
                    cout << -1;
                    return  0;
                }
                cnt++;
            }
            for(int i = 1 ; i <= cnt ; ++i)
                res.pb(cur + i);
            
            res.pb(cur);
            cur += cnt + 1;
        }
        if (ans > res)
            ans = res;
        
        reverse(all(path));
    }
    for(int x : ans)    cout << x << " ";
}

Measured memory_bytes: 16496
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int check(int x, int y, int z)
{
	return x * 10000 + y * 5000 + z * 1000;
}

int main()
{
	int N, Y;
	int x, y, z;
	x = y = z = 0;

	cin >> N >> Y;

	for (x = 0; x <= N; x++)
	{
		for (y = 0; y <= N - x; y++)
		{
			z = N - x - y;
			
			if (check(x, y, z) == Y)
			{
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}

	cout << -1 << " " << -1 << " " << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000000
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,l[30][maxn],r[30][maxn];
ll a[maxn],p;
void init()
{
    memset(l,-1,sizeof l);
    memset(r,-1,sizeof r);
    for(int i=0;i<=n-1;i++)
    {
        r[0][i]=lower_bound(a,a+n,a[i]+p)-a;
        if(r[0][i]==n||a[r[0][i]]>a[i]+p)r[0][i]--;
        l[0][i]=lower_bound(a,a+n,a[i]-p)-a;
        if(i==n-1)r[0][i]=-1;
        if(i==0)l[0][i]=-1;
    }
    for(int i=1;i<=29;i++)
    {
        for(int j=0;j<=n-1;j++)
        {
            if(r[i-1][j]<n-1)r[i][j]=r[i-1][r[i-1][j]];
            if(l[i-1][j]>0)l[i][j]=l[i-1][l[i-1][j]];
            //if(l[i][j]!=-1)printf("%d %d %d\n",i,j,l[i][j]);
        }
    }
}
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,0,n-1)scanf("%lld",&a[i]);
    scanf("%lld",&p);
    init();
    int q;
    scanf("%d",&q);
    while(q--)
    {
        int b,c,ans=0;
        scanf("%d%d",&b,&c);
        b--,c--;
        if(b<c)
        {
            for(i=29;i>=0;i--)
            {
                if(r[i][b]!=-1&&r[i][b]<=c)
                {
                    ans+=qpow(2,i);
                    b=r[i][b];
                    if(b==c)break;
                }
            }
            if(i==-1)ans++;
        }
        else
        {
            for(i=29;i>=0;i--)
            {
                if(l[i][b]!=-1&&l[i][b]>=c)
                {
                    ans+=qpow(2,i);
                    b=l[i][b];
                    if(b==c)break;
                }
            }
            if(i==-1)ans++;
        }
        printf("%d\n",ans);
    }
    //system("Pause");
    return 0;
}


Measured memory_bytes: 25088
#include <iostream>
#include <queue>
using namespace std;
#define REP(i,a,b) for(int i = (int)(a); (i) < (int)(b); i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;

int main(){
	int n,m;
	cin >> n >> m;
	priority_queue<int> q;
	rep(i,n){
		int a;
		cin >> a;
		q.push(a);
	}
	rep(j,m){
		int tmp = q.top(); q.pop();
		q.push(tmp / 2);
	}

	ll res = 0LL;
	rep(k,n){ res += q.top(); q.pop(); }
	cout << res << endl;
	return 0; 
}

Measured memory_bytes: 892
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int main()
{
  array<int,13> ma = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  int m, d, yd;

  while ( cin >> m >> d && ( m != 0 || d != 0 ))
    {
      yd = 0;
      for ( int i = 1; i < m; ++i )
        yd += ma[i];
      yd += d;

      int wd = yd % 7;

      switch ( wd )
        {
        case 0:
          cout << "Wednesday" << endl;
          break;
        case 1:
          cout << "Thursday" << endl;
          break;
        case 2:
          cout << "Friday" << endl;
          break;
        case 3:
          cout << "Saturday" << endl;
          break;
        case 4:
          cout << "Sunday" << endl;
          break;
        case 5:
          cout << "Monday" << endl;
          break;
        case 6:
          cout << "Tuesday" << endl;
          break;
        }          
    }
  return 0;
}

Measured memory_bytes: 1152
from itertools import*
(n,), *D = [list(map(int, o.split())) for o in open(0)]
dp = [[0]*3 for _ in [None]*-~n]
for i in range(n):
  for j, k in permutations(range(3), 2):
    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + D[i][k])
print(max(dp[n]))

Measured memory_bytes: 50724
n, k, c = map(int, input().split())
s = input()
l = [0 for i in range(k)]
r = [0 for i in range(k)]
i, j = 0, 0
while i < n and (not l[-1]):
    if s[i] == "o":
        l[j] = i + 1
        i += c + 1
        j += 1
    else:
        i += 1
i, j = 0, k - 1
while i < n and (not r[0]):
    if s[n - i - 1] == "o":
        r[j] = n - i
        i += c + 1
        j -= 1
    else:
        i += 1
for i in range(k):
    if l[i] == r[i]:
        print(l[i])

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

int n, m;	
int t(int i) {
	int r = i % n;
	if (r < 0) r += n;
	return r + 1;
}

int main() {
	cin >> n >> m;
	int el = -1, er = 0, ol = n / 2 - 1, orr = ol + 2;
	int f = 0;
	rep(i, m) {
		f ^= 1;
		if (f) {
			printf("%d %d\n", t(el--), t(er++));
		} else {
			printf("%d %d\n", t(ol--), t(orr++));
		}
	}

}



Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    double a, b, c, ans;
    cin >> a >> b;
    //c = 1.0/double(a) + 1.0/double(b);
    ans = (a * b)/(a + b);
    cout << fixed << setprecision(10) ;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	ll a, b, x, ans = 0;
	CIN3(a, b, x);
	if(!a) ++ans;
	a = max(a - 1, (ll)0);
	ans += b / x - a / x;
	COUT(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

;;

int main(){
  ;;
    int x, t;
    cin >> x >> t;
    ;
    cout << (max(0, x-t)) << endl;;
}

Measured memory_bytes: 256
#include <iostream>
#define Q 100005
using namespace std;
typedef long long ll;
int n,q,t[Q],p[Q];
bool marked[Q];
char c[Q];
ll ans;

int find(int x){
  if(marked[x]) return x;
  return p[x]=find(p[x]);
}

int main(){
  while(1){
    cin>>n>>q;
    if(!n&&!q) break;
    for(int i=2;i<=n;i++) cin>>p[i];
    marked[1]=true;
    for(int i=0;i<q;i++){
      cin>>c[i]>>t[i];
      if(c[i]=='M'){
	if(marked[t[i]]) c[i]='E';
	marked[t[i]]=true;
      }
    }
    ans=0;
    for(int i=q-1;i>=0;i--){
      if(c[i]=='E') continue;
      if(c[i]=='M') marked[t[i]]=false;
      else ans+=find(t[i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2284
#include <stdio.h>

int main(){
    int n, x, l[100];
    int i, cnt = 0, keep;

    l[0] = 0;

    scanf("%d %d", &n, &x);
    for(i=1; i<=n; i++){
        scanf("%d", &l[i]);
    }

    cnt++;
    keep = 0;

    for(i=1; i<=n; i++){
        keep = keep + l[i];
        if(keep <= x)
            cnt++;
    }

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

    return 0;
}

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

using namespace std;
typedef long long ll;
    
int main()
{
    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    int count = 0;
    while (true) {
        for (int i = 0; i < N; i++) {
            if (!(A[i]%2 == 0)) {
                cout << count;
                return 0;
            }
            A[i] /= 2;
        }
        count++;
    }

    return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {          
                int n = int.Parse(Console.ReadLine());
                int[,] card = new int[4, 13];//2?¬????????????§??¨???????????????????????????????????????

                for (int row = 0; row < 4; row++)//???????????¨???0??§?????????????????????????????¶??????
                {
                        for (int col = 0; col < 13; col++)
                        {
                            card[row,col] = 0;
                        }
                 }


                for (int i = 0; i < n; i++)//?????????????????£?????????????????????1?????£??\
                {
                    string input = Console.ReadLine();
                    string[] array = input.Split(' ');
                    string handle = array[0];//??????????????????
                    int rank = int.Parse(array[1]);//??????????????°???

                    switch (handle)
                    {
                        case "S": card[0, rank-1] = 1;
                            break;
                        case "H": card[1, rank-1] = 1;
                            break;
                        case "C": card[2, rank-1] = 1;
                            break;
                        case "D": card[3, rank-1] = 1;
                            break;
                    }
                }


                for (int row = 0; row < 4; row++)
                {
                    for (int col = 0; col < 13; col++)
                    {
                        if (card[row, col] == 0)
                        {
                            switch(row){
                                case 0:Console.WriteLine(string.Format("S {0}", col+1));
                                    break;
                                case 1:Console.WriteLine(string.Format("H {0}", col+1));
                                    break;
                                case 2:Console.WriteLine(string.Format("C {0}", col+1));
                                    break;
                                case 3:Console.WriteLine(string.Format("D {0}", col+1));
                                    break;
                            }
                        }
                    }
                }
        }
    }
}

Measured memory_bytes: 9212
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll InF = 1e15;

int main() {
    int n;
    scanf("%d",&n);
    vector<ll> a(n+2,0),b(n+2,0);
    for (int i = 1; i <= n + 1; i++) scanf("%lld", &a[i]);
    for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
    ll ans = 0;
    for (int i = 1; i <= n + 1; i++) {
        ll res = min(a[i],b[i-1]+b[i]); 
        ans += res;
        if (a[i] > ans) b[i] = 0;
        else b[i] = min(b[i-1] + b[i] - res,b[i]);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
a,b,c,x,y = map(int,input().split())
s = [0 for i in range(4)]
s[0] = x*a+y*b
s[1] = a*max(0,x-y)+2*c*y
s[2] = 2*c*x+b*max(0,y-x)
s[3] = 2*c*max(x,y)
print(min(s))


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int l, r, d;
    cin >> l >> r >> d;
    Int res = 0;
    for (Int i = l; i <= r; i++) {
        if (i % d == 0) res++;
    }
    print(res);
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<tuple>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

const int MAX=510000;

int main()
{
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double ans;
    if((x==0 && y==0)|| (x==0 && y==h) || (x==w && y==0) || (x==w && y==h))
    {
        ans=(double)h*w/2;
        cout<<setprecision(9)<<ans;
        cout<<" "<<0<<endl;
        return 0;
    }
    else if(x==0 || y==0 || x==w || y==h)
    {
        ans=(double)h*w/2;
        cout<<setprecision(9)<<ans<<" "<<0<<endl;
        return 0;
    }
    else if(x==w/2 && y==h/2)
    {
        ans=(double)h*w/2;
        cout<<setprecision(9)<<ans<<" "<<1<<endl;
        return 0;
    }
    else
    {
        ans=(double)h*w/2;
        cout<<setprecision(9)<<ans<<" "<<0<<endl;
        return 0;
    }
    
    
}

Measured memory_bytes: 256
import sys
N = list(input())
answer = 'Yes'
for i in range(1, len(N)+1):
    if N[i-1]!='U' and N[i-1]!='D':
        if ((i-1)&1)==0:
            if N[i-1]!='R':
                answer = 'No'
                break
        else:
            if N[i-1]!='L':
                answer = 'No'
                break
# #A = [int(x) for x in input().split()]
print(answer)

Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
typedef int long long ll;
using namespace std;
int main(){
    ll n,m;
    cin>>n>>m;
    if(n==1&&m==1){cout<<1<<endl;return 0;}
    if(n==1){cout<<m-2<<endl;return 0;}
    if(m==1){cout<<n-2<<endl;return 0;}
    cout<<(n-2)*(m-2)<<endl;
    
    
return 0;
}


Measured memory_bytes: 256