akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;

		rep(i, n) {
			int a, b, c; cin >> a >> b >> c;
			char ans;

			if ((a == 100 || b == 100 || c == 100) || (a + b >= 180) || (a + b + c >= 240))ans = 'A';
			else if ((a + b + c >= 210) || (a + b + c >= 150 && (a >= 80 || b >= 80)))ans = 'B';
			else ans = 'C';

			Cout(ans);
		}
	}
}


Measured memory_bytes: 3008
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int number,counter=0;
    string name;
    cin >>number>> name;
    for (int i = 0 ; i<number-1; i++)
    {
        if(name[i] != name[i+1] )
        {
            counter++;
        }
    }
    cout  << counter+1<<"\n";
}


Measured memory_bytes: 512
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void solve() {
		int b = sc.nextInt();
		int r = sc.nextInt();
		int g = sc.nextInt();
		int c = sc.nextInt();
		int s = sc.nextInt();
		int t = sc.nextInt();
		if (t == 0) return;
		int medal = 100;
		int bonusGame = b * 5 + r * 3;
		int normalGame = t - bonusGame;
		medal -= normalGame * 3;
		medal -= bonusGame * 2;
		medal += bonusGame * 15;
		medal += b * 15;
		medal += r * 15;

		medal += g * 7;
		medal += c * 2;
		medal += s * 3;
		System.out.println(medal);
	}

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

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define all(x) (x).begin(), (x).end()
#define fap(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int inf = 0x3f3f3f3f;
const ll INF = 2e18;

int main() {
	FastIO;

	int n;
	cin >> n;

	int nn = n * 3;
	vector<int> a(nn);
	for(int &x : a) cin >> x;

	sort(all(a));
	ll res = 0;
	for(int i=nn-2, j=0; j<n; ++j, i-=2) {
		res += a[i];
	}
	cout << res << "\n";
	
	return 0;
}

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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;
  ll binpow(ll b,ll n){
  	ll res =1;
  	while(n){
  		if(n%2)
  			res = (res%MOD*b%MOD)%MOD;
  		n/=2;
  		b= (b%MOD*b%MOD)%MOD;
  	}
  	return res;
  }	

  void solve(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll sum = binpow(2LL,n);
    ll cala=1;
    ll calb=1;
    ll mina=1,minb=1;
    for(ll i=1;i<=min(a,n-a);i++){
    	mina = (mina*i)%MOD;
    }
    for(ll i=1;i<=min(b,n-b);i++){
    	minb = (minb*i)%MOD;
    }    
    ll inva = binpow(mina,MOD-2);
    ll invb = binpow(minb,MOD-2);
    for(ll i=n;i>max(a,n-a);i--){
    	cala = (cala*i)%MOD;
    }
    for(ll i=n;i>max(b,n-b);i--){
    	calb = (calb*i)%MOD;
    }
    
    cala = (cala*inva)%MOD;
    calb = (calb*invb)%MOD;		
    sum = max(0LL,((sum - cala - calb-1)%MOD + MOD)%MOD);
    cout << sum;    
  }

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3748
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int K,X;cin >> K >> X;
    for(int i = X-K+1;i <= X+K-1;i++){
        cout<<i<<" ";
    }
    cout<<endl;
}


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

int main() {
  string s;
  int length, first, last, i;
  int sum = 0;
  bool cnt_tr = 0;
  
  cin >> s;
  
  length = s.size();

  for (i = 0; i < length; i++) {
    if ((s.at(i) == 'A') && (cnt_tr == 0)) {
      first = i;
      cnt_tr = 1;
    }
    if(s.at(i) == 'Z') last = i;
  }
  cout << last - first + 1 << endl;  
}

Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.buffer.readline
    from itertools import accumulate
    from math import sqrt

    def Eratosthenes(x: int) -> set:
        sup = int(x)
        primes = {i for i in range(2, sup+1)}
        for i in range(2, int(sqrt(sup+1))+1):
            if i in primes:
                mul = 2
                while i*mul <= sup:
                    primes.discard(i*mul)
                    mul += 1
        return primes
    P = Eratosthenes(10**5+5)
    A = [0]*(10**5+5)
    for i in range(3, 10**5+5):
        if i in P and (i+1)//2 in P:
            A[i] = 1
    S = list(accumulate(A))

    Q = int(input())
    LR = [[int(i) for i in input().split()] for j in range(Q)]
    for le, ri in LR:
        print(S[ri] - S[le-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 67172
N = int(input())
ans = []
for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        ans.append('1')
    else:
        ans.append('0')
S = ''.join(ans)
if '111' in S:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62312
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> G[N];
bool v[N];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++ i) {
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	queue<int> q;
	q.push(1);
	v[1] = 1;
	vector<int> ans = {1};
	while (!q.empty()) {
		int p = q.front(); q.pop();
		for (int u : G[p]) {
			if (v[u]) continue;
			q.push(u);
			v[u] = 1;
			ans.push_back(u);
			break;
		}
	}
	q.push(1);
	vector<int> ans2;
	while (!q.empty()) {
		int p = q.front(); q.pop();
		for (int u : G[p]) {
			if (v[u]) continue;
			q.push(u);
			v[u] = 1;
			ans2.push_back(u);
			break;
		}
	}
	reverse(ans2.begin(), ans2.end());
	printf("%d\n", (int) ans.size() + (int) ans2.size());
	for (int x : ans2) printf("%d ", x);
	for (int i = 0; i < (int) ans.size(); ++ i) printf("%d ", ans[i]); puts("");
}


Measured memory_bytes: 6904
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

li judge(vector<li>& a,vector<li>& f,li m){
  int n=a.size();
  li s=0;
  rep(i,n){
    li d=a[i]-m/f[i];
    if(d>0) s+=d;
  }
  return s;
}

int main(){
  int n; li k; cin >>n >>k;
  vector<li> a(n),f(n);
  rep(i,n) cin >>a[i];
  rep(i,n) cin >>f[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  sort(f.begin(),f.end());
  li ok=a[0]*f[n-1]+1,ng=-1;
  while(ok-ng>1){
    li m=(ok+ng)/2;
    (judge(a,f,m)<=k?ok:ng)=m;
  }
  print(ok);
}


Measured memory_bytes: 6404
#include <iostream>
#include <algorithm>
#include <utility>

#define INF 1000000005


using namespace std;

long long ile, pojemnosc;
pair <long long, long long> tab[100000];
long long dp[1000000];
long long minimum = INF;
long long wynik = 0;

int main(){
    
    cin >> ile >> pojemnosc;
    
    
	for(int i = 0; i < ile; i++){
        cin >> tab[i].first >> tab[i].second;
        // first - weight
        // second - value
        minimum = min(minimum, tab[i].first);//do kiedy mam sprawdzac od dp[pojemnosc] do do[pojemnosc - minimum]
	}
    
    
    for(int element = 0; element < ile; element++){
        
        for(int i = pojemnosc; i >= 0; i--){
            dp[i + tab[element].first] = max(dp[i + tab[element].first], dp[i] + tab[element].second);
            
        }
        
    }
    
    /*
    for(int i = 0; i < pojemnosc; i++){
        cout << dp[i] <<  " ";
    }*/
    
    for(int i = 0; i < minimum; i++){
        //cout << dp[i] << " ";
        wynik = max(wynik, dp[pojemnosc - i]);
    }
    cout << wynik;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

signed main() {
	string s;
	int a = 1, b = 11;
	while (a != b) {
		int t = (a + b) / 2;
		if (b - a == 1)t = b;
		cout << "? 1" << string(t - 1, '0') << endl;
		string res; cin >> res;
		if (res == "N")b = t - 1;
		else a = t;
	}
	if (a == 11) {//最初が1であとは0
		a = 1; b = 10;//最小の"Y"
		while (a != b) {
			int t = (a + b) / 2;
			cout << "? " << string(t, '9') << endl;
			string res; cin >> res;
			if (res == "Y")b = t;
			else a = t + 1;
		}
		cout << "! 1" << string(a - 1, '0') << endl;
		return 0;
	}
	rep(i, a) {
		int l = (i == 0 ? 1 : 0), r = 9;//"Y"になる最小
		while (l != r) {
			int t = (l + r) / 2;
			cout << "? " << s << (char)('0' + t) << string(10 - s.size(), '9') << endl;
			string res; cin >> res;
			if (res == "Y")r = t;
			else l = t + 1;
		}
		s += '0' + l;
	}
	cout << "! " << s << endl;
}

Measured memory_bytes: 596
N = int(input())

dp = [[] for _ in range(N)]
dp[0].append('a')

for i in range(1, N):
    for strings in dp[i-1]:
        j = 97
        while j <= ord(max(strings))+1:
            nextstr = strings
            nextstr += chr(j)
            dp[i].append(nextstr)
            j += 1

dp[N-1].sort()

for strings in dp[N-1]:
    print(strings)

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

int main() {
  int n;
  cin>>n;
  vector<int> mochi(n);
  for(int i=0;i<n;i++){
    int d;
    cin>>d;
    mochi[i]=d;
  }

  while(true){
    int change=0;
    for(int i=0;i<n-1;i++){
      if(mochi[i]>mochi[i+1]){
        swap(mochi[i],mochi[i+1]);
        change=1;
      }
    }
    if(change==0){
      break;
    }
  }
  
  int tmp=0,num=0;
  for(int i=0;i<n;i++){
    if(mochi[i]!=tmp){
      num+=1;
      tmp=mochi[i];
    }
  }
  cout<<num<<endl;
}

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

int main(){
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> memo(100005, 0);
  int l=0, r=0, ans = 0, nans = 0;
  bool frag1 = false;
  for(int i=0; i<n; ++i){
    if(s[i] == '0'){
      if(frag1){
        ++memo[r];
        ++nans;
      }else{
        frag1 = true;
        if(k>0) --k;
        else{ nans -= memo[l]; ++l;}
        ++memo[r];
        ++nans;
      }
    }
    else{ //s[i] == "1"
      if(frag1){
        frag1 = false;
        ++r;
      }
      ++memo[r];
      ++nans;
    }
    ans = max(nans, ans);
    //cout << "i:" << i << " nans:" << nans << " ans:" << ans << endl;
  }
  ans = max(memo[r]-memo[l], ans);
  cout << ans << endl;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N,depth=1,ans[100]={};
int pow1(int a,int b){
  int ans=1;
  if(b==0){
    return 1;
  }
  else{
    for(int i=0;i<b;i++){
      ans = a*ans;
    }
    return ans;
  }
}
signed main(){
  cin >> N;
  int num=N;
  if(abs(N)%2==1) ans[0]=1;
  num-=ans[0];
  while(1){
    //cout << num << endl;
    if(num==0) break;
    if(num%pow1(-2,depth+1)==0) ans[depth]=0;
    else{
      ans[depth]=1;
      num-=pow1(-2,depth);
    }
    depth++;
  }
  for(int i=depth-1;i>=0;i--) cout << ans[i];
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

dp = [0] * n

for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[i]-h[0])
        continue
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

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

#define lint long long
#define P pair<lint, lint>

const lint INF = 1E18;

int main(){
    int N; cin >> N;
    vector<lint> a(N + 1);
    for(int i = 0; i < N + 1; ++i){
        cin >> a[i];
    }
    
    vector<lint> Capacity(N + 1);
    lint  num = 1;
    for(int i = 0;i < N + 1; ++i){
        Capacity[i] = num - a[i];
        num = min(Capacity[i] * 2,INF);
        if(Capacity[i] < 0){
            cout << -1 << endl;
            return 0;
        }
    }
    
    
    vector<lint> ans(N + 1);
    
    ans[N] = a[N];
    for(int i = N - 1; i >= 0; --i){
        ans[i] = min(Capacity[i], ans[i + 1]) + a[i];
    }
    
    lint Final = 0;
    for(int i = 0; i < N + 1; ++i){
        Final += ans[i];
    }
    
    cout << Final << endl;
    
}

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

using namespace std;

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

    vector<int> even_numbers_on_doc;
    for (int i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        if (input % 2 == 0)
            even_numbers_on_doc.push_back(input);
    }

    int number_of_valid_numbers = 0;
    for (int i = 0; i < even_numbers_on_doc.size(); i++)
    {
        if (even_numbers_on_doc.at(i) % 3 == 0 || even_numbers_on_doc.at(i) % 5 == 0)
            number_of_valid_numbers++;
    }

    string result = even_numbers_on_doc.size() == number_of_valid_numbers ? "APPROVED" : "DENIED";

    cout << result;
}

Measured memory_bytes: 256
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n, k = map(int, input().split())
nk = Base_10_to_n(n,k)
print(len(nk))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	
	public static void main(String[] args) {
	
		FastScanner fs = new FastScanner();
		int mod = fs.nextInt();
		int val = 7%mod;
		for(int i=1;i<1e7;i++) {
			if(val==0) {
				System.out.println(i);
				return;
			}
			val = (10*val + 7)%mod;
		}
		System.out.println(-1);
	}

	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}
 
}





Measured memory_bytes: 32876
#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 n;
vector<int> a;

int check(int m){
    map<int,int> mp;
    rep1(i,n-1){
        if(a[i-1] < a[i]) continue;
        if(m == 1) return false;
        int pos = a[i];
        while(true){
            if(mp[pos] < m - 1){
                mp[pos]++;
                mp.erase(mp.upper_bound(pos), mp.end());
                break;
            }
            pos--;
            if(pos == 0) return false;
        }
    }
    return true;
}

int main(void){
    cin >> n;
    a.resize(n);
    rep(i,n) cin >> a[i];
    int l = 0, r = n;
    while(l+1 < r){
        int m = (l+r)/2;
        if(check(m)){
            r = m;
        }else{
            l = m;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>
int main() {
	double q, x;
	while (fscanf(stdin, "%lf", &q) && q != -1) {
		x = q/2.0;
		while (fabs(x*x*x - q) > 0.00001*q)	x = x - ((x*x*x - q) / (3.0*x*x));
		fprintf(stdout, "%lf\n", x);
	}
	return 0;
}

Measured memory_bytes: 652
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-12;
const int mod =  1000000007;
const int LIM = 100005;


#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define se second
#define fi first
 
int fpow(int x, int n){
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int gcd(int a,int b){
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n){
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
     for (int p = 2; p <= rootn; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//******************************************* CHECK CONSTRAINTS **************************************************
vvi dp(500,vi(500));
vi sum(500);

int get(int l,int r){
      if(l>=r){
            return 0;
      }
      if(!dp[l][r]){
            dp[l][r]=1e15;
            for(int i=l;i<r;i++){
                  dp[l][r] = min(dp[l][r],get(l,i)+get(i+1,r)+sum[r]-sum[l-1]);
            }
      }
      return dp[l][r];
}

int32_t main()
{     fio;
      cin>>n;
      forr(i,n){
            cin>>a[i];
            dp[i-1][i]=a[i-1]+a[i];
            sum[i]=sum[i-1]+a[i];
      }
      cout<<get(1,n);
}


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


#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;


using namespace std;




int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

    ll x;

    cin >> x;

    for (ll i = -2000; i <= 2000; i++)
    {
        for (ll j = -2000; j <= 2000; j++)
        {
            if (i * i * i * i * i - j * j * j * j * j == x)
            {
                cout << i << " " << j;

                return 0;
            }
        }
    }
}

Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (S, W) = Read2Longs();

            return W>=S?"unsafe":"safe";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28260
#include <stdio.h>
#include <string.h>
int main(){
char str[1000];
int n, t, ctr = 0;
scanf("%s", str);
if(str[strlen(str) - 1] == 's'){
	printf("%s%c%c", str, 'e', 's');
}else{
	printf("%s%c", str, 's');
}
return 0;
}



Measured memory_bytes: 1728
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  ll r;

  cin >> r;

  if (r < 1200)
  {
    cout << "ABC" << endl;
  }
  else if (r < 2800)
  {
    cout << "ARC" << endl;
  }
  else
  {
    cout << "AGC" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

static const int MAX = 100;

int main() {
  int n, ans = 0, d[MAX];
  cin>>n;
  for(int i = 0; i<n; i++) cin>>d[i];

  for(int i = 0; i<n; i++){
    for(int j = i + 1; j<n; j++){
      ans += d[i] * d[j];
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	int n;
	cin >> n;
	cout << n / 3;

	return 0;
}





Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int MAP[100001] = {-1};

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> freq;
    int tmp;
    uint64_t sum = 0;
    rep(i, N) {
        cin >> tmp;
        freq[tmp]++;
        sum += tmp;
    }

    int Q;
    cin >> Q;
    int B, C;
    rep(i, Q) {
        cin >> B >> C;
        sum -= B * freq[B];
        sum += C * freq[B];

        freq[C] += freq[B];
        freq[B] = 0;
        cout << sum << endl;
    }


    return 0;
}


Measured memory_bytes: 7580
main :: IO ()
main = do
  [q,h,s,d] <- fmap read . words <$> getLine :: IO [Int]
  n <- readLn :: IO Int
  let base = minimum [q * 4 , q * 2 + h , h * 2, s]
  let dob = min d (2 * base)
  print $ (n `div` 2) * dob + (if odd n then base else 0)


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

const int MOD = 1000000007;
using PP = pair<int, int>;
vector<PP> factor(int num) {
  vector<PP> ret;
  for (int i = 2; i * i <= num; ++i) {
    int cnt = 0;
    while (num % i == 0) {
      ++cnt;
      num /= i;
    }
    if (cnt > 0) {
      ret.push_back(PP(i, cnt));
    }
  }
  
  if (num > 1) {
    ret.push_back(PP(num, 1));
  }
  return ret;
}

long pow(long base, int exp) {
  if (exp == 0) return 1;
  long ret = pow(base, exp / 2);
  ret = (ret * ret) % MOD;
  if (exp % 2 == 1) ret = (ret * base) % MOD;
  return ret;
}

long inv(long num) {
  return pow(num, MOD - 2);
}
long DP[200001];
long fact(long n) {
  if (n == 0) return 1;
  if (DP[n] != 0) return DP[n];
  return DP[n] = (fact(n - 1) * n) % MOD;
}

long combi(long n, long r) {
  return fact(n) * inv((fact(r) * fact(n - r)) % MOD) % MOD;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<PP> f = factor(m);
  
  long prod = 1;
  for (PP p : f) {
    prod = (prod * combi(n + p.second - 1, p.second)) % MOD;
  }
  cout << prod << endl;
  
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int n,m;
	cin>>n>>m;
	vpii s(n),c(m);
	for(int i=0;i<n;i++) {
		cin>>s[i].F>>s[i].S;
	}
	for(int i=0;i<m;i++)cin>>c[i].F>>c[i].S;
	for(pair<int,int> p:s) {
		int dist = INT_MAX;
		int ind = -1;
		for(int j=0;j<m;j++) {
			pair<int,int> a=c[j];
			if(abs(p.F-a.F)+abs(p.S-a.S)<dist) {
				dist = abs(p.F-a.F)+abs(p.S-a.S);
				ind=j;
			}
		}
		cout<<ind+1<<"\n";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    vector<ll> s(n);
    rep(i, n) cin >> s.at(i);

    ll mi = 101;
    rep(i, n) if(s.at(i) % 10 != 0) mi = min(mi, s.at(i));

    ll sum = 0;
    rep(i, n) sum += s.at(i);

    ll ans = 0;
    if(sum % 10 != 0)
        ans = sum;
    else if(mi != 101)
        ans = sum - mi;
    else
        ans = 0;
    cout << ans;
}


Measured memory_bytes: 256
// Problem : A - Strings
// Contest : AtCoder - AtCoder Beginner Contest 149
// URL : https://atcoder.jp/contests/abc149/tasks/abc149_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
using namespace std;
int main()
{
	lli t,a,i;
	string s1,s2;
	cin>>s1>>s2;
	cout<<s2+s1;
	
	
	
	return 0;
}

Measured memory_bytes: 3564
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [0]*(n+1)
fir = []
sec = []
for i in range(3):
  if a[i]>b[i]:
    sec.append((b[i],a[i]))
  else:
    fir.append((a[i],b[i]))
for i in range(1,n+1):
  dp[i] = i
  for x,y in fir:
    if i-x >= 0:
      dp[i] = max(dp[i],dp[i-x]+y)
n = dp[n]
dp = [0]*(n+1)
for i in range(1,n+1):
  dp[i] = i
  for x,y in sec:
    if i-x >= 0:
      dp[i] = max(dp[i],dp[i-x]+y)
print(dp[n])

Measured memory_bytes: 230424
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	a1, a2 := make([]int, n+1), make([]int, n+1)

	for i := 1; i <= n; i++ {
		a1[i] = a1[i-1] + nextInt()
	}
	for i := 1; i <= n; i++ {
		a2[i] = a2[i-1] + nextInt()
	}

	m := a1[1] + a2[n] - a2[n-1]
	for i := 1; i < n; i++ {
		c := a1[i] + a2[n] - a2[i-1]

		if m < c {
			m = c
		}
	}

	fmt.Println(m)
}


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  vi a(n);
  rep(i, n) cin >> a[i];

  vector<bool> dp(k+1);
  rep(i, k+1){
    int cnt = 0;
    bool lose = false;
    rep(j, n) if(i-a[j] >= 0){
      cnt++;
      if(!dp[i-a[j]]) lose = true;
    }

    if(cnt == 0) dp[i] = false;
    else dp[i] = lose;
  }

  cout << (dp[k] ? "First" : "Second") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n, m, x;
  cin >> n >> m >>x;
  int tmp= 0;
  int k = 0;
  REP(i, m){
    cin >> tmp;
    if(tmp > x){
      k = i;
      break;
    }
  }
  cout << min(k, m - k) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << 2 * n * M_PI;
    return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for(auto&e:a) cin >> e;
	int ans=0;
	for(int i=1;i<n;++i)
		if(a[i-1]<a[i]) ++ans;
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3116
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let s: String = read();
    let mut cnt = 0;
    for c in s.into_bytes() {
        if c == b'1' {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
s = list(map(int, input().split()))
for i in range(len(s)-1):
    for j in range(len(s)-1, i, -1):
        if s[j-1] > s[j]:
            tmp = s[j-1]
            s[j-1] = s[j]
            s[j] = tmp
        
print(" ".join(map(str, s)))


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl;
const int MOD = 1e9 + 7;

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    int a;
    vector<int> p(n, k-q);
    rep(i, q) {
        cin >> a;
        p[a - 1]++;
    }
  //rep(i,n) cout<<p[i]<<endl;
    rep(i, n){
        if (p[i] <= 0)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    } 
}

Measured memory_bytes: 1024
import copy
N = int(input())
Cards1 = list(map(str, input().split()))
# リストのコピー
# copyをインポートしてcopy.deepcopy()関数を使う。
Cards2 = copy.deepcopy(Cards1)


# バブルソート: Cards1
for i in range(0, N):
    for j in reversed(range(i+1, N)):
        if int(Cards1[j][1:]) < int(Cards1[j-1][1:]):
            Cards1[j], Cards1[j-1] = Cards1[j-1], Cards1[j]

# 選択ソート: Cards2
for i in range(0, N):
    minj = i
    for j in range(i, N):
        if int(Cards2[j][1:]) < int(Cards2[minj][1:]):
            minj = j
    Cards2[i], Cards2[minj] = Cards2[minj], Cards2[i]

print(*Cards1)
print('Stable')
print(*Cards2)
if Cards1 != Cards2:
    print('Not stable')
else:
    print('Stable')

# バブルソートは安定ソート
# 選択ソートは安定ソートではない



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

int main(){
    long long a,b,c, k;
    cin >> a >> b >> c >> k;
    if(k<=a) cout << k << endl;
    else if(k <= a+b) cout << a << endl;
    else cout << a - (k - a - b) << endl;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] s = br.readLine().split(" ");
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			int c = Integer.parseInt(s[2]);
			int d = Integer.parseInt(s[3]);
			while (true) {
				c -= b;
				if (c <= 0) {
					System.out.println("Yes");
					return;
				}
				a -= d;
				if (a <= 0) {
					System.out.println("No");
					return;
				}
			}
		}
	}
}

Measured memory_bytes: 32756
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=1e5+5;
int he[N],ver[N],nex[N],tot;
void add(int,int);
int dp[N];
void dfs(int);
int main(){
    int n,m;scanf("%d%d",&n,&m);
    int u,v;tot=1;
    for(int i=0;i<m;i++){
        scanf("%d%d",&u,&v);
        add(u,v);
    }
    for(int i=1;i<=n;i++)if(!dp[i]) dfs(i);
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
    cout<<ans;
}
void add(int u,int v){
    ver[tot]=v;nex[tot]=he[u];he[u]=tot++;
}
void dfs(int u){
    for(int i=he[u];i;i=nex[i]){
        int v=ver[i];
        if(!dp[v]) dfs(v);
        dp[u]=max(dp[v]+1,dp[u]);
    }
}


Measured memory_bytes: 3200
#include <iostream>

using namespace std;

 

int main() 
{
    int a, b, c;
    
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else
        cout << b << " " << a << " " << c << endl;
}


Measured memory_bytes: 3084
N= int(input())
H = list(map(int, input().split()))
rev, cur, tmp = 0, 0, 0
for i in range(N - 1):
  if i == 0:
    cur = abs(H[0] - H[1])
  else:
    tmp = cur
    cur = min(cur + abs(H[i] - H[i + 1]),
              rev + abs(H[i - 1] - H[i + 1]))
    rev = tmp
print(cur)


Measured memory_bytes: 13980
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
count = 0
for i in range(N):
    judge = A[i] - B[i]
    if judge <= 0:
        count += A[i]
    else:
        count += B[i]

    if judge < 0:
        if (A[i+1]+judge) >= 0:
            count += -judge
            A[i+1] += judge
        else:
            count += A[i+1]
            A[i+1] = 0
print(count)

Measured memory_bytes: 18624
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
const int d[10][10]={{1,1},{1,-1},{-1,1},{-1,-1}};
int n,a[100005];
char s[100005];
bool check(){
    for(int i=1;i<=n;i++){
        int l=(i==1?n:i-1);
        int r=(i==n?1:i+1);
        if(s[i]=='o'){
            if(a[i]==1&&a[l]!=a[r])return 0;
            if(a[i]==-1&&a[l]==a[r])return 0;
        }
        else{
            if(a[i]==1&&a[l]==a[r])return 0;
            if(a[i]==-1&&a[l]!=a[r])return 0;
        }
    }
    return 1;
}
int main(){
	in(n);
    scanf("%s",s+1);
    for(int ca=0;ca<4;ca++){
        a[1]=d[ca][0];
        a[2]=d[ca][1];
        for(int i=2;i<n;i++){
            if(a[i]==1)a[i+1]=(s[i]=='o'?a[i-1]:-a[i-1]);
            else a[i+1]=(s[i]=='x'?a[i-1]:-a[i-1]);
        }
        if(check()){
            for(int i=1;i<=n;i++)putchar((a[i]==1?'S':'W'));
            puts("");
            return 0;
        }
    }
    puts("-1");
	return 0;
}


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

using namespace std;

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

    int R; cin >> R; const int max_rating[] { 1199, 2799, 4208 };

    const auto solution = [] ( int i )
    {
        const string s[] = { "ABC", "ARC", "AGC" }; cout << s[ i ]; return 0;
    };

    for( int i = 0; i < 3; i++ )
        if ( R <= max_rating[ i ] )
            return solution( i );
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e17;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;

ll n, m, p;
ll dist[2505];
ll heiro[2505];
vvll edges;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> p;
    rep(i,m){
        vll e(3);
        cin >> e[0] >> e[1] >> e[2];
        e[0]--;
        e[1]--;
        e[2] -= p;
        e[2] *= -1;
        edges.eb(e);
    }
    vll dist(n, infl);
    dist[0] = 0;
    rep(k,2){
        rep(i,n){
            rep(j,m){
                ll u = edges[j][0], v = edges[j][1], d = edges[j][2];
                if (dist[u]>infl/2)
                    continue;
                if (dist[v]>dist[u]+d){
                    dist[v] = dist[u] + d;
                    if (i==n-1){
                        dist[v] = -infl;
                    }
                }
            }
        }
    }
    if (dist[n-1]<-infl/2 || infl/2<dist[n-1]){
        cout << -1 << ENDL;
    }
    else{
        cout << max(0ll, -1 * dist[n - 1]) << ENDL;
    }
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void) {
	int n, m;
	char s[100];
	char t[1000];
	scanf("%s", s);
	scanf("%s", t);
	int cnt = 0;
	for (int i = 0; i <3; i++) {
		if (s[i] == t[i]) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
n = input()
x = map(int, raw_input().split())
c = 0
for i in range(n):
    for j in range(i+1,n)[::-1]:
        if x[j] < x[j-1]:
            x[j],x[j-1] = x[j-1], x[j]
            c += 1
for e in x:
    print e,
print
print c

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 a, x, b, y, t; cin >> a >> x >> b >> y >> t;

	if(x <= y) {
		printf("NO\n");
		return 0;
	}

	if(t * (x - y) >= std::abs(b - a)) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 3636