akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second
const lint MOD = (lint)1e9 + 7LL;

bool check(string s){
    REP(i, 4){
        string t = s;
        if(i>0){
            t[i] = s[i-1];
            t[i-1] = s[i];
        }
        REP(j, 2){
            if(t.substr(j, 3)=="AGC") return false;
        }
    }
    return true;
}
string L[4] = {"A", "T", "G", "C"};

signed main(){
    ll N; cin>>N;
    vector<map<string, lint> > dp(N+1); 
    REP(i, 4){
        REP(j, 4){
            REP(k, 4){
                string t = L[i]+L[j]+L[k];
                if(t=="AGC" or t=="ACG" or t=="GAC") continue;
                dp[3][t]=1;
            }
        }
    }
    FOR(i, 3, N){
        for(auto x=dp[i].begin(); x!=dp[i].end(); x++){
            for(int j=0; j<4; j++){
                if(check(x->first+L[j])){
                    dp[i+1][x->first.substr(1,2)+L[j]] = (dp[i+1][x->first.substr(1,2)+L[j]] + x->second ) % MOD;
                }
            }
        }
    }
    lint res = 0;
    for(auto x=dp[N].begin(); x!=dp[N].end(); x++){
        res = (res + x->second) %MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 896
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
    
def solve(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
    
    
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"
 

 
  

Measured memory_bytes: 6440
n = int(input())
A = list(map(int,input().split()))
res = "APPROVED"
for a in A :
    if a  % 2 == 0 :
        if a % 3 == 0 or a % 5 == 0 :
            continue
        
        res = "DENIED"
        break
    
print(res)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int l,r,res=2019;
  cin >> l >> r;
  for (int i = l; i <= r; i++)
  {
    if (i%2019 == 0)
    {
      cout << "0" << endl;
      return 0;
    }
  }
  l%=2019;
  r%=2019;
  for(int i=l;i<=r;i++)
  {
    for(int j= i+1;j<=r;j++)
    {
      if(i==j)continue;
      res=min(res,(i*j)%2019);
    }
  }
  cout << res <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

void RLE(string &s, vector<pair<char,int> > &v){
	v.push_back({s[0],0});
	for(int i=0;i<s.size();i++){
		if(s[i]==v[v.size()-1].first){
			v[v.size()-1].second++;
		}else{
			v.push_back({s[i],1});
		}
	}
}

ll n,k,ans=0;
string s;
V<pair<char,int>> v;


void init(){
	cin>>n>>k>>s;
	// RLE(s,v);
	s="*"+s+"*";
}

int main(void){
	init();
	reg(i,1,n){
		if(s[i]=='L' && s[i-1]=='L'){
			ans++;
			// cerr<<i<<endl;
		}
		if(s[i]=='R' && s[i+1]=='R'){
			ans++;
			// cerr<<i<<endl;
		}
	}
	// cerr<<"ans:"<<ans<<endl;
	ans=min(n-1,ans+2*k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;   
    if(k % 2 == 0) cout << a - b << endl;
    else cout << b - a << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        int[] T = new int[N];
        for(int i = 0; i < N; i++)
            T[i] = sc.nextInt();
        sc.close();
        Arrays.sort(T);

        int index = 0;
        int count = 0;
        int now = 0;
        while(index < N){
            int limit = T[index] + K;
            int number = 1;
            while(T[index] <= limit && number <= C){
                index++;
                number++;
                if(index == N)
                    break;
            }
            count++;
        }

        System.out.println(count);


    }
}

Measured memory_bytes: 50132
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    string s;cin>>s;
    rep(i,3){
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using  namespace std;
int main()
{
  string s;
  cin>>s;
  int count=0;
  int mx=0;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='R'){ count++; mx=max(mx,count); }
    else count=0;
  }
  cout<<mx<<endl;
}

Measured memory_bytes: 3624
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, ma, mb;
  cin >> N >> ma >> mb;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }
  vector<vector<int>> dp(401, vector<int>(401, INF));
  dp[0][0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 400; j >= 0; j--) {
      for(int k = 400; k >= 0; k--) {
        if (j + A[i] > 400) continue;
        if (k + B[i] > 400) continue;
        dp[j + A[i]][k + B[i]] = min(dp[j + A[i]][k + B[i]], dp[j][k] + C[i]);
      }
    }
  }
  int ans = INF;
  for(int k = 1; k * ma <= 400 && k * mb <= 400; k++) {
    ans = min(ans, dp[k * ma][k * mb]);
  }
  if (ans == INF) {
    cout << "-1" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int X = GetInt();

		int q = X / 100;
		int r = X % 100;

		int must = r / 5;
		if(r % 5 != 0)
			must++;

		WriteLine((must <= q) ? 1 : 0);	
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

int main() {
	int N, M; cin >> N >> M;
	vector<int>X(M);
	for (int i = 0; i < M; i++) {
		cin >> X[i];
	}
	sort(X.begin(), X.end());

	int ans = 0;
	if (N >= M);
	else {
		vector<int>diff;
		for (int i = 0; i < (M - 1); i++) {
			diff.push_back(X[i + 1] - X[i]);
		}
		sort(diff.begin(), diff.end());
		for (int i = 0; i < (M - N); i++) {
			ans += diff[i];
		}
	}
	cout << ans << endl;

	return 0;
}

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

count = 0
for i in range(N):
  d1,d2 = map(int,input().split())
  if(d1==d2):
    count = count + 1
  else:
    count = 0
  if(count == 3):break
if(count == 3):
  print("Yes")
else:
  print("No")

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

int main(){

	int n;
	cin >> n;
	ll a[MAX] = {}, b[MAX] = {};
	vector<ll> plus;
	rep(i,n) {
		cin >> a[i];
	}
	rep(i,n) {
		cin >> b[i];
	}

	ll minus_sum = 0;
	ll plus_sum = 0;
	int cnt = 0;
	rep(i,n) {
		ll dif = a[i] - b[i];
		if (dif < 0) {
			minus_sum -= dif;
			cnt++;
		} else if (dif > 0) {
			plus_sum += dif;
			plus.push_back(dif);
		}
	}

	if (cnt==0) {
		cout << "0" << endl;
		return 0;
	} else if (minus_sum > plus_sum) {
		cout << "-1" << endl;
		return 0;
	}

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

	while(minus_sum > 0) {
		ll last = plus.back();
		plus.pop_back();
		minus_sum -= last;
		cnt++;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 2428
from itertools import*

p, _ = map(int, input().split())
nums = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - {int(i) for i in input().split()}
for i in count(p):
    if {int(d) for d in str(i)} - nums == set():
        print(i)
        break


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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;
#define debug(x) cout << #x << "=" << x << endl;
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); cout << (i>0 ? " ":"") << v[i++]); cout << "\n"; return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    int x = (a/k)*k;
    if(x < a) x += k;
    if(x >= a && x <= b){
        cout << "OK\n";
    }else{
        cout << "NG\n";
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,f;
  cin >>a>>b>>c>>d;
  e=a+b;
  f=c+d;
  if(e>f){
    cout<<"Left"<<endl;
  }else if(e==f){
    cout<<"Balanced"<<endl;
    
  }else{
    cout<<"Right"<<endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int arr[5],k;
    for(int i=0; i<5; i++)
        cin>>arr[i];
    cin>>k;
    int f=0;
    for(int i=0; i<5; i++)
    {
        for(int j=0; j<5; j++)
        {
            int d=abs(arr[i]-arr[j]);
            if(d>k)
                f=1;
        }

    }


    if(!f)
        cout<<"Yay!"<<endl;
    else
        cout<<":("<<endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
string S,T;

bool f( string s, string t ){
  for(int i = 0;i<t.size();i++){
    if(s[i]=='?')continue;
    if(s[i]==t[i])continue;
    return false;
  }
  return true;
}
void g( string& s, int n, string t){
  for(int i = 0;i<t.size();i++){
    s[n+i]=t[i];
  }
  for(int i = 0;i<s.size();i++){
    if(s[i]=='?')s[i]='a';
  }
}
int main() {
  cin>>S>>T;


  for(int i = S.size()-T.size();i>=0;i--){
    if(f(S.substr(i),T)){
      g(S,i,T);
      break;
    }
  }
  if(S.find_first_of('?') == string::npos){
    cout<<S<<endl;
  }else{
    cout<<"UNRESTORABLE"<<endl;
  }
  

  return 0;
}


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

int main() {
  int64_t bb=2,b=1,ans=0;
  int n=0;
  cin >> n;
  
  if (n==0) cout << 2 << endl;
  else if (n==1) cout << 1 << endl;
  else {
    for (int i =2 ; i <= n ; i++) {
      ans = bb + b;
      bb = b;
      b = ans;
    }
    cout << ans << endl;
  }        
}

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

using namespace std;

long long int comb(long long int n, long long int k) {
	if (k == 0) return 1;
	return (n + 1 - k) * comb(n, k - 1) / k;
}

int main(void) {
	int N, P;

	cin >> N >> P;
	long long int odd = 0, even = 0;
	for (int i = 0; i < N; i++) {
		int input;
		cin >> input;
		if (input % 2 == 0) even++;
		else odd++;
	}

	long long int ans = 0;

	if (P == 0) {
		for (int i = 0; i <= odd; i += 2) ans += comb(odd, i);
	}
	else {
		for (int i = 1; i <= odd; i += 2) ans += comb(odd, i);
	}
	ans <<= even;
	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void)
{
  char W[11],T[1001];
  int count=0,i;
  scanf("%s",&W);
  fflush(stdin);
  for(i=0;i<11;i++ )
    {
      W[i] = tolower(W[i]);
      if(W[i] == '\0'){break;}
    }
  for( ; ; ){
    scanf("%s",&T);
    if(!strcmp(T,"END_OF_TEXT")){break;}
    fflush(stdin);
     for(i=0;i<1001;i++ )
    {
      T[i] = tolower(T[i]);
      if(T[i] == '\n'){break;}
    }
  if(!strcmp(W,T)){count++;}
  }
  printf("%d\n",count);
   
    return 0;
}

Measured memory_bytes: 556
import java.util.Scanner;
 
class Main {
  static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
      
      int a = sc.nextInt();
      int b = sc.nextInt();
      String s = sc.next();
      char[] s_chars = s.toCharArray();
      s_chars[b-1]+=32;
      
      System.out.print(s_chars);
      

      
    }
}

Measured memory_bytes: 20808
fn main(){
    let k = input().parse::<usize>().unwrap();
    let s = input();
    if s.len() <= k {
        println!("{}", s);
    }else{
        println!("{}...", s.get(..k).unwrap());
    }
}

fn input() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_string()
}

Measured memory_bytes: 2168
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int a, S;
void dfs(int i, int s, int n) {
	if (s == S&&n == 0) {
		a++;
		return;
	}
	if (i == 10 || n == 0)
		return;

	dfs(i + 1, s + i, n - 1);
	dfs(i + 1, s, n);
}

int main() {
	for (int n; cin >> n >> S && (n || S);) {
		a = 0;
		dfs(0, 0, n);
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#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)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    long double A;
    long double B;
    cin >> A >> B;
    cout << ll(A * B) << endl;
}

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

const int P = 1000000007;
int n, k, binom[1005][1005], dp[25][1005];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i <= n; ++i)
		for (int j = binom[i][0] = 1; j <= i; ++j)
			binom[i][j] = (binom[i - 1][j] + binom[i - 1][j - 1]) % P;
	dp[0][0] = 1;
	for (int i = 1, d; i <= k; ++i) {
		scanf("%d", &d);
		for (int j = 0; j <= n; ++j)
			if (dp[i - 1][j])
				for (int k = 0; k <= d && j + k <= n; ++k)
					dp[i][j + k] = (dp[i][j + k] + 1ll * dp[i - 1][j] * binom[n - j][k] % P * binom[n - k][d - k]) % P;
	}
	printf("%d\n", dp[k][n]);
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define sd(x) scanf("%d",&x)
#define ss(x) scanf("%s",x)
#define sc(x) scanf("%c",&x)
#define sf(x) scanf("%f",&x)
#define slf(x) scanf("%lf",&x)
#define slld(x) scanf("%lld",&x)
#define me(x,b) memset(x,b,sizeof(x))
#define pd(d) printf("%d\n",d);
#define plld(d) printf("%lld\n",d);
#define eps 1.0E-8
// #define Reast1nPeace

typedef long long ll;

using namespace std;

const int INF = 0x3f3f3f3f;

bool p[1000010];

void P(){
	memset(p,1,sizeof(p));
	p[0] = p[1] = 0;
	for(int i = 2 ; i*i<=1000000 ; i++){
		if(p[i]){
			for(int j = i+i ; j<=1000000 ; j+=i){
				p[j] = 0;
			}
		}
	}
}

int main(){
#ifdef Reast1nPeace
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	P();
	
	int n;	
	while(cin>>n){
		int ans = 0;
		for(int i = 1 ; i<=n ; i++){
			if(p[i]){
				ans++;
			}
		}
		cout<<ans<<endl;	
	}
	return 0;
}



Measured memory_bytes: 4068
#include <iostream>

using namespace std;

int main() {
    int n;

    cin >> n;

    int t[1010], a[1010];

    for (int i = 0; i < n; ++i) {
        cin >> t[i] >> a[i];
    }

    long long x = t[0], y = a[0], s;

    for (int i = 1; i < n; ++i) {
        s = max((x + t[i] - 1) / t[i], (y + a[i] - 1) / a[i]);
        x = t[i] * s;
        y = a[i] * s;
    }

    cout << x + y << endl;
}


Measured memory_bytes: 256
// ITP1_3

import java.util.Scanner;

class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );

		int a = 0;
		int b = 0;
		int c = 0;
		int d = 0;
		int count = 0;

		a = sc.nextInt ();
		b = sc.nextInt ();
		c = sc.nextInt ();
		d = a;
	
		for (; a <= b; a++ ) {
			if ( c % a == 0 ) {
				count++;
			}
		}

		System.out.println ( count );
	}
}

Measured memory_bytes: 26184
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
m1, m2 = -1, -1
for e in a:
  if e > m1:
    m2 = m1
    m1 = e
  elif e > m2:
    m2 = e
for e in a:
  if e == m1:
    print(m2)
  else:
    print(m1)

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

int main(){
    long double tansin,tyousin;
    cin>>tansin>>tyousin;
    long double jikan,hun;
    cin>>jikan>>hun;
    long double kakujikan,kakuhun;
    kakujikan=jikan*30.0+30.0*(hun/60.0);
    kakuhun=hun*6;
    long double kakudo;
    if(kakujikan>kakuhun){
        kakudo=kakujikan-kakuhun;
    }
    else if(kakujikan<kakuhun){
        kakudo=kakuhun-kakujikan;
    }
    else{
        kakudo=0.0;
    }
    long double radian;
    radian=M_PI*(kakudo/180.0);
    long double ans;
    ans=sqrtl((pow(tansin,2.0))+(pow(tyousin,2.0))-(2.0*tansin*tyousin*cos(radian)));

    cout<<fixed<<setprecision(10)<<ans<<endl;



}

Measured memory_bytes: 4088
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
typedef struct {
    int tate;
    int yoko;
} lamp;

int main()
{
    int x,a;
    scanf("%d%d",&x,&a);
    printf(x<a?"0":"10");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int n;
    scanf("%d", &n);

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



    qsort(a, n, sizeof(int), comp);


    for(int i = 0; i < n - 1; i++){
        if(a[i] == a[i + 1]){
            printf("NO");
            return 0;
        }
    }

    printf("YES");

}


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

using namespace std;
 
 

typedef long long ll;
//c++ templte for help............................................................................................................................................


template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;





	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
#define M int(1e9+7)
const int INF=1e9+5;
 
//iterate map
//template<typename T>
//void itR(T map){
	 //for(auto itr=map.begin();itr!=map.end();itr++){
				//deb(itr->first,itr->second);
			//}
	//cout<<endl;
//}


 

 
//c++ template for help...........................................................................................................................................

string solve(){
	int n;
	cin>>n;
	if(n>=30) return "Yes";
	return "No";
}


int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ofstream myfile;
	//myfile.open ("output.txt");
	

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		string ans=solve();
		cout<<ans<<endl;
	//}
	//myfile.close();
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,i;
	cin>>a>>b>>c;
	for(i=0;i<=1000;i++)
	{
		if(a*i%b==c)
		{
			cout<<"YES";
			return 0;
		}
	} 
	cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;

int main () {
  int N,Y;
  int flag= 0;
  cin >> N >> Y;
  for (int i=N; i>=0; i--) {
    for (int j=N-i; j>=0; j--) {
      for (int k=N-i-j; k>=0; k--) {
        if (Y==10000*i+5000*j+1000*k && i+j+k==N) {
          cout << i << " " << j << " " << k;
          return 0;
        }
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
A = [i**2 for i in range(1,128)]
ans = 0
for i in range(N-1) :
    for j in range(i+1,N) :
        calc = 0
        for k in range(D) :
            calc += (X[i][k] - X[j][k])**2
        if calc in A :
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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 ll INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
        ans%=MOD;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans=ans*modinv(i,MOD)%MOD;
    }
    return ans;
}

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans=modpow(2,n,MOD);
    ans--;
    ll p,q;
    p=nCr(n,a);
    q=nCr(n,b);
    ans-=p;
    if (ans<0)ans+=MOD;
    ans-=q;
    if (ans<0)ans+=MOD;
    ans%=MOD;
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int N;
  long Y;
  cin >> N >> Y;
  rep(i, N+1){
    rep(j, N+1-i){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        cout << i << " " << j << " " << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int[] a = new int[6];
        int[] b = new int[3];
        for(int i = 0; i < 6; i++){
            a[i] = sc.nextInt();
        }
        String ans = "YES";
        int[] jud = new int[4];
        for(int i = 0; i < 6; i++){
            jud[a[i] - 1] ++;
        }
        for(int i = 0; i < 4; i++){
            if(jud[i] == 3){
                ans = "NO";
                
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include<stdio.h>
#include<stdlib.h>

int main()
{
  long long n,m,i;
  scanf("%lld%lld",&n,&m);
  long long tmp = m/n;
  for(i=tmp;i>1;)
  {
    if(m%i==0) break;
    else i--;
  }
  
  printf("%lld",i);
}


Measured memory_bytes: 1716
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
 	int a,b,k;
  cin>>a>>b>>k;
  vector<int> v;
  for(int i=1; i<=min(a,b); i++)
  {
    if(a%i==0 && b%i==0)
    {
     	v.push_back(i); 
    }
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  cout<<v[k-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
from collections import defaultdict

#key = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

# N, M = map(int, input().split())  #
# A = [int(k) for k in input().split()] 

N = int(input())  #
x_list = list()
u_list = list()
for i in range(N):
    x, u = input().split(' ')  # type(A) => <class 'str'>
    x = float(x)
    #print(x,u)
    #x, u = map(int, input().split())  #
    x_list.append(x)
    u_list.append(u)

suma = 0
for x, u in zip(x_list, u_list):
    if u == "JPY":
        suma += x
        pass
    elif u == "BTC":
        suma += x*380000
print(suma)
    

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

#define M 1000001
#define L 14

char H[M][L];

int getChar(char);
long long getKey(char *);
int h1(int);
int h2(int);
int find(char *);
int insert(char *);

int main(){
int i, n, h;
   char str[L],com[9];
   for ( i = 0; i < M; i++ ) H[i][0] = '\0';

	 scanf("%d", &n);

	 for ( i = 0; i < n; i++ ){
		 scanf("%s %s", com, str);

		 if ( com[0] == 'i' ){
			 insert(str);
		 }
		 else {
			 if (find(str) == 1){
				 printf("yes\n");
			 }
			 else {
				 printf("no\n");
			 }
		 }
	 }
	 return 0;
 }

 int getChar(char ch){
	 if ( ch == 'A') return 1;
	 else if ( ch == 'C') return 2;
	 else if ( ch == 'G') return 3;
	 else if ( ch == 'T') return 4;
 }

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int k){
	return k % M;
}
int h2(int k){
	return 1 + (k % (M - 1));
}

int find(char str[]){
	long long k,i,h;

	k = getKey(str);
	for (i = 0;;i++) {
		h = (h1(k) + i * h2(k)) % M;
		if(strcmp(H[h],str) == 0) return 1;
		else if( strlen(H[h]) == 0) return 0;
		}
		return 0;
}

int insert(char str[]){
	long long k,i,h;

	k = getKey(str);
	for (i = 0;;i++) {
		h = (h1(k) + i * h2(k)) % M;
		if(strcmp(H[h],str) == 0) return 1;
		else if( strlen(H[h]) == 0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 15468
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 2019;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  int A,P;
  cin>>A>>P;
  int P1=(A*3+P)/2;
  cout<<P1<<endl;
}

Measured memory_bytes: 256
#ABC147 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=int(input())
shogen=[]
for _ in range(n):
    a=int(input())
    t=[]
    for __ in range(a):
        s=list(map(int,input().split()))
        t.append(s)
    shogen.append(t)

ans=0

for i in range(2**n):
    flag=True
    for j in range(n):
        if not flag:
            break
        if ((i>>j) & 1):
            for s in shogen[j]:
                if ((i>>s[0]-1)&1) !=s[1]:
                    flag=False
    if flag:
        mnt = bin(i).count("1")
        ans=max(ans,mnt)
print(ans)



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

int main() {
  string S;
  cin >> S;
  if (S == "Sunny") 
    cout << "Cloudy" << endl;
  if (S == "Cloudy") 
    cout << "Rainy" << endl;
  if (S == "Rainy") 
    cout << "Sunny" << endl;
}

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

int main() {
	char op;
	int a, b;


	while (1) {
		cin >> a >> op >> b;
		if (op == '+') {
			cout << a + b << endl;
		}
		else if (op == '-') {
			cout << a - b << endl;
		}
		else if (op == '*') {
			cout << a * b << endl;
		}
		else if ( op == '/') {
			cout << a / b << endl;
		}
		else  { break; }
	}
	return 0;

}


Measured memory_bytes: 3068
n = int(input())
s = input()
x = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
y = []
for i in range(len(s)):
    for j in range(len(x)):
        if s[i] == x[j]:
            y.append(x[(j+n)%26])
ans = ''.join(y)
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main(void) {
    int a,b;
    scanf("%d %d",&a, &b);
    if ( b % a == 0) {
        printf("%d\n", a+b);
    } else {
        printf("%d\n", b-a);
    }
}


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

signed main() {                
	int N, A, B;
	cin >> N >> A >> B;
	int k = (N + A + B - 1) / (A + B);
	int blue_erase = 0;
	int have = k * (A + B);	
	while (have > N) {
		int rem = min(have - N, B);
	 	have -= rem;
		if (have <= N) break;
		rem = min(have - N, A);
		have -= rem;
		blue_erase += rem;
	}
	cout << k * A - blue_erase << '\n';	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int s;
  cin >> s;
  int a[1100000], b[100000];
  a[0] = s;
  for (int i = 0; i < 101; i++) {
    b[i] = 0;
  }
  b[s] = 1;
  int res;

  for (int i = 1;i < 1100000; i++) {
    if (a[i-1] % 2 == 0) {
      a[i] = a[i-1] / 2;
    } else {
      a[i] = a[i-1]* 3 + 1;
    }
    b[a[i]]++;

    if (b[a[i]] > 1) {
      res= i+1;
      break;
    }

  }

  cout << res << "\n";
}


Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n,k;
  cin >> n >> k;
  
  if((k + k-1) > n){
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

  return 0;
}

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

int n,d,q,a[500000],x[500010],y[500010] = {};

bool C(int i,int z){
	for(;i < n;i++){
		if(a[i] / 2 <= z) z = max(a[i] / 2,z - a[i]);
	}
	return !z;
}

signed main(){
	scanf("%lld %lld",&n,&d);
	for(int i = 0;i < n;i++) scanf("%lld",&a[i]);
	x[0] = d;
	for(int i = 0;i < n;i++){
		if(x[i] > a[i]) x[i + 1] = x[i] - a[i];
		else x[i + 1] = min(x[i],a[i] - x[i]);
	}
	bool flag = false;
	for(int i = n - 1;i >= 0;i--){
		if(flag){
			if(y[i + 1] < a[i] / 2) y[i] = y[i + 1];
			else y[i] = y[i + 1] + a[i];
		}
		if(a[i] == 1 && !flag){
			int low = 0,up = d + 1;
			while(up - low > 1){
				int mid = (low + up) / 2;
				if(C(i,mid)) low = mid;
				else up = mid;
			}
			y[i] = low;
			flag = true;
		}
	}
	scanf("%lld",&q);
	for(int i = 0;i < q;i++){
		int t;
		scanf("%lld",&t); t--;
		if(x[t] <= y[t + 1]) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 13696
/*
    24.03.2019 15:11:07
*/

#include <bits/stdc++.h>

using namespace std;

#ifdef HOME
#define TAG_LENGTH 45
#define LR_LEFT left
#define LR_RIGHT right
#define LR_VALUE value
#define LR_SECOND_VALUE mn
#include "C:/C++ libs/print.cpp"
#define showl cout << endl;
#define shows cout << string(5, ' ') + string(TAG_LENGTH, '-') << endl;
#else
#define show(...) 42;
#define showt(...) 42;
#define showl 42;
#define shows 42;
#define print(...) 42;
#define printTree(...) 42;
#define printLRTree(...) 42;
#define printMatrix(...) 42;
#endif

long long mod = 1e9+7;

bool check(int j0, int j1, int j2, int j3) {
    if (j0 == 0 && j1 == 1 && j2 == 2) return false;
    if (j0 == 0 && j1 == 1 && j3 == 2) return false;
    if (j0 == 0 && j2 == 1 && j3 == 2) return false;
    if (j1 == 0 && j2 == 1 && j3 == 2) return false;
    if (j0 == 1 && j1 == 0 && j2 == 2) return false;
    if (j0 == 0 && j1 == 2 && j2 == 1) return false;
    if (j1 == 1 && j2 == 0 && j3 == 2) return false;
    if (j1 == 0 && j2 == 2 && j3 == 1) return false;
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<vector<vector<vector<long long>>>> dp(n + 1, vector<vector<vector<long long>>>(4,
        vector<vector<long long>>(4, vector<long long>(4, 0))));
    // AGCT
    // string ss = "AGCT";
    // for (int i = 0; i < 4 * 4 * 4 * 4; ++i) {
    //     vector<int> j;
    //     int x = i;
    //     for (int i = 0; i < 4; ++i) {
    //         j.push_back(x % 4);
    //         x /= 4;
    //     }
    //     if (check(j[0], j[1], j[2], j[3]))
    //         cout << ss[j[0]] << ss[j[1]] << ss[j[2]] << ss[j[3]] << '\n';
    //     else
    //         cout << ss[j[0]] << ss[j[1]] << ss[j[2]] << ss[j[3]] << " --- bad" << '\n';
    // }
    dp[0][3][3][3] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j1 = 0; j1 < 4; ++j1) {
            for (int j2 = 0; j2 < 4; ++j2) {
                for (int j3 = 0; j3 < 4; ++j3) {
                    if (j1 == 0 && j2 == 1 && j3 == 2)
                        continue;
                    for (int j0 = 0; j0 < 4; ++j0) {
                        if (check(j0, j1, j2, j3))
                            dp[i][j1][j2][j3] += dp[i - 1][j0][j1][j2];
                    }
                    dp[i][j1][j2][j3] %= mod;
                }
            }
        }
    }
    long long ans = 0;
    for (int j1 = 0; j1 < 4; ++j1) {
        for (int j2 = 0; j2 < 4; ++j2) {
            for (int j3 = 0; j3 < 4; ++j3) {
                ans += dp[n][j1][j2][j3];
            }
        }
    }
    cout << ans % mod << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 INF = 1e9;
const LL LLINF = 1e16;

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1), b(n);
	rep(i, n+1) cin >> a[i];
	rep(i, n) cin >> b[i];
	LL ans = 0;
	rep(i, n){
	  	LL tmp = min(a[i], b[i]);
		a[i] -= tmp;
		b[i] -= tmp;
		ans += tmp;
		if(b[i] > 0){
		  tmp = min(a[i+1], b[i]);
		  a[i+1] -= tmp;
		  b[i] -= tmp;
		  ans += tmp;
		}
	}
	cout << ans << endl;
		     

}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if(A == B && B == C) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

bool solve(int a,int b,int c,int k,int n){
  if(b > a && c > b){
    return true;
  }
  if(n >= k){
    return false;
  }


  bool f1,f2,f3;
  f1 = solve(a*2,b,c,k,n+1);
  f2 = solve(a,b*2,c,k,n+1);
  f3 = solve(a,b,c*2,k,n+1);

  if(f1 == true || f2 == true || f3 == true) return true;
  else return false;

}

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

  bool f = solve(a,b,c,k,0);

  if(f){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }

}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int X; cin >> X;
    bool isFin = false;
    for(int A=-118; A<=119; A++){
        for(int B = -118; B<=119; B++){
            if(pow(A,5) - pow(B, 5) == X){
                printf("%d %d\n", A, B);
                isFin = true;
                break;
            }
        }
        if(isFin) break;
    }
}

Measured memory_bytes: 4168
arr = gets.strip.split.map(&:to_i)

arr.each do |a|
    if a%2==1
        puts 0
        exit
    end
end
if arr[0]==arr[1] && arr[1]==arr[2]
    puts -1
    exit
end
ans=0
while true
    ans+=1
    brr=[(arr[0]+arr[1])/2, (arr[0]+arr[2])/2, (arr[1]+arr[2])/2 ]
    brr.each do |a|
        if a%2==1
            puts ans
            exit
        end
    end
    arr=brr
end


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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	map<int, int> mp1;
	rep(i, n){
		int d;
		cin >> d;

		if(mp1.count(d) == 0) mp1[d] = 0;
		mp1[d]++;
	}

	int m;
	cin >> m;

	map<int, int> mp2;
	rep(i, m){
		int t;
		cin >> t;

		if(mp2.count(t) == 0) mp2[t] = 0;
		mp2[t]++;
	}

	for(auto p : mp2){
		int k = p.first;
		int v = p.second;
		if(mp1.count(k) == 0 || mp1[k] < v){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}


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

ll xorsum(ll x, vector<ll> &a) {
	ll sum=0;
	//cout << x << '\t' << bitset<8>(x) << endl;
	for (ll i : a) {
		sum+=x^i;
		//cout << i << '\t' << bitset<8>(i) << endl;
	}
	//cout << "---" << endl;
	//cout << sum << '\t' << bitset<8>(sum) << endl << endl;

	return sum;
}

ll countBits(ll bit, vector<ll> &a) {
	ll count=0;
	for (ll i : a)
		if ( (1ll<<bit) & i ) count++;
	return count;
}

int main() {
	ll n,k; cin>>n>>k;
	vector<ll> a(n);
	for (ll i=0; i<n; i++)
		cin >> a[i];
	
	ll shift=62;
	ll x=0;
	while (1ll<<shift > k) shift--;

	while (shift>=0) {
		ll onBits=countBits(shift,a);
		if (onBits*2 <= a.size())
			if (x+(1ll<<shift) <= k)
				x+=(1ll<<shift);
		shift--;
	}
	cout << xorsum(x,a) << endl;
	return 0;
}

Measured memory_bytes: 1024
//----------------------------------------------------------------------
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
//----------------------------------------------------------------------
using namespace std;
int main(void) {
    int n; cin >> n;
    int k; cin >> k;
    vector<long long> h(n);
    for(auto& v : h) {
        cin >> v;
    }
    sort(h.begin(),h.end());
    long long atk = 0;
    for(int i = 0 ; i < (int)h.size()-k; ++i) {
        atk += h[i];
    }
    cout << atk << endl;

    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	if(x<=0)return 0;
	LL res = 0;
	PER(i, 40){
		if(x&BIT(i)){
			if(i==0)res ^= x;
			else res ^= BIT(i+1) - 1;
		}
	}
}

int main(){
	string str;
	cin >> str;
	vector<int> ans(str.size(), 0);
	int count = 0;
	REP(i, str.size()){
		if(str[i]=='R')++count;
		else{
			ans[i-1] += (count+1)/2;
			ans[i] += count / 2;
			count = 0;
		}
	}

	PER(i, str.size()){
		if(str[i]=='L')++count;
		else{
			ans[i+1] += (count+1)/2;
			ans[i] += count / 2;
			count = 0;
		}
	}

	bool flag = false;
	foreach(i, ans){
		if(flag)cout << " ";
		flag = true;
		cout << i;
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
ll	n, a[100005], ans;
int main()
{	
	while (~scanf("%d", &n))
	{
		ans = 0;
		for (int i = 1; i <= n; i++)
		{
			scanf("%d", a + i);
			if (i > 1 && a[i - 1] == i - 1)
			{
				swap(a[i - 1], a[i]);
				ans++;
			}
		}
		if (a[n] == n)	ans++;
		printf("%d\n", ans);	
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans;
    for (int i = 111; i <= 999; i+=111){
        if (n <= i){
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}

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

int main() {
  int64_t N;
  cin >> N;
  int64_t min = 10000000000;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      int64_t x = max((int)log10(i), (int)log10(N/i)) + 1;
      if (x < min) min = x;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cassert>
#include<map>

using namespace std;

#define fi first
#define se second
#define rep(i,s,t) for(int i=(s),_t=(t);i<_t;++i)
#define per(i,s,t) for(int i=(t)-1,_s=(s);i>=_s;--i)
#define debug(x) cerr<<#x<<" == "<<(x)<<endl
#define bug(x) cerr<<#x<<" == "<<(x)<<" "

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

template<class T>inline void rd(T &x){
	static char c,f;
	x=0;f=1;
	while(c=getchar(),c<48)if(c=='-')f=-1;
	do x=x*10+(c&15);
	while(c=getchar(),c>47);
	x*=f;
}

template<class T>void pf(T x){
	if(x<0)putchar('-'),x=-x;
	else if(!x){putchar('0');return ;}
	static int stk[100],tp;
	for(tp=0;x;x/=10)stk[tp++]=x%10;
	while(tp)putchar(stk[--tp]^48);
}

template<class T>void ptn(T x){pf(x),putchar('\n');}
template<class T>void ptk(T x){pf(x),putchar(' ');}
template<class T>void Min(T &A,T B){if(A>B)A=B;}
template<class T>void Max(T &A,T B){if(A<B)A=B;}

const int N=(int)2e5+5;
int cnt[N],a[N],n,m,sum[N],tot;
int main(){
	rd(n);rd(m);
	rep(i,1,n+1)rd(a[i]),++cnt[a[i]];
	rep(i,1,n+1)rep(j,0,min(cnt[i],i)){
		if(!sum[i-j])++tot;
		sum[i-j]++;
	}
	for(int x,y;m--;){
		rd(x),rd(y);
		--cnt[a[x]];
		if(a[x]-cnt[a[x]]>0&&!(--sum[a[x]-cnt[a[x]]]))--tot;
		a[x]=y;
		if(a[x]-cnt[a[x]]>0&&!sum[a[x]-cnt[a[x]]]++)++tot;
		++cnt[a[x]];
		ptn(n-tot);
	}
	return 0;
}

Measured memory_bytes: 3712