akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	int N, A, B, C;

	cin >> N >> A >> B >> C ;

	vector<int> D(N);

	for (int i = 0; i < N; i++) { cin >> D[i]; }

	double price = (double)A;
	double cal = (double)C;

	sort(D.begin(), D.end(), greater<int>());

	for (int i = 0; i < N; ++i)
	{
		if (cal / price < (cal + D[i]) / (price + B))
		{
			price += (double)B;
			cal += (double)D[i];
		}
		else
		{
			break;
		}
	}

	cout << (int)(cal / price) << endl;

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,0,n) cin>>a[i];
    sort(all(a));
    cout<<abs(a[0]-a[n-1])<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{   int a,b;
   while(cin>>a>>b){
     int max1=a+b;
     if(max1<a-b){
            max1=a-b;
     }
     if(max1<a*b){
            max1=a*b;
     }

     cout<<max1<<endl;

   }

return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
bool isP(int x){
  if(x==0||x==1)return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0)return false;
  }
  return true;
}
int main(){
  while(cin>>n&&n){
    for(int i=n;i-2>=1;i--){
      if(isP(i)&&isP(i-2)){
	cout<<i-2<<' '<<i<<endl;
	break;
      }
    }
  }
}


Measured memory_bytes: 3088
def solve():  # 068C - Splitting Pile
    N = int(input())
    a = [int(x) for x in input().split(" ")]
    X = sum(a)
    sum_val = 0
    min_sum = 2 * 1e20

    for i in range(N-1):
        sum_val += a[i]
        y = X - sum_val
        min_sum = min(min_sum, abs(sum_val - y))

    print(min_sum)


solve()

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

int n,c;
vector<int>v,w;

const int sz=100000;
int dp[sz+1];  //dp[i] = min weight to get val equal to i

int32_t main()
{
cin>>n>>c;
v.resize(n);
w.resize(n);
for(int i=0;i<n;i++)
{
	cin>>w[i]>>v[i];
}
for(int i=0; i<=sz; i++)
{
	dp[i]=INT_MAX;
} 
dp[0]=0;
for(int j=0; j<n; j++)
{
for(int i=sz; i>=1; i--)
{
if(i>=v[j])
{
	if(dp[i-v[j]]==INT_MAX)
		continue;
	dp[i]=min(dp[i],dp[i-v[j]]+w[j]);
}
}
}

int ans=0;
for(int i=1; i<=sz; i++)
{
	if(dp[i]<=c)
	{
			ans=max(ans,i);
	}
}
cout<<ans;
return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    List<int>[] es;

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        int add = 0;
        int now = 0;
        foreach (var c in S)
        {
            if(c == 'S')
            {
                now++;
            }
            else
            {
                now--;
                if(now < 0)
                {
                    now++;
                    add++;
                }
            }
        }
        Console.WriteLine(add + now);
    }
    
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13216
A,B,C,D = map(int,input().split())
def battle(A,B,C,D):
    C=C-B
    A=A-D
    if C<=0 and A<=0:
        print("Yes")
    elif C<=0 and A>0:
        print("Yes")
    elif C>0 and A<=0:
        print("No")
    else:
         battle(A,B,C,D)

battle(A,B,C,D)

Measured memory_bytes: 61712
#include <stdio.h>

int main(){
  int x,y,ch,n;

  scanf("%d %d",&x,&y);
  if(x < y){
    ch = x;
    x = y;
    y = ch;
  }
 
  while(y > 0){
    n = x%y;
    x = y;
    y = n;
  }
  printf("%d\n",x);
  
  return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	string card[36],card2[36],tem;
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>card[i];
		card2[i]=card[i];
	}
	//bubblesort
	for(int i=0;i<=n-1;++i){
		for(int j=n-1;j>=i+1;j--){
			if(card[j][1]-'0'<card[j-1][1]-'0'){
				//tem=card[j];
				//card[j]=card[j-1];
				//card[j-1]=tem;
				swap(card[j],card[j-1]);
			}
		}
	}
    for(int i=0;i<=n-1;i++){
		if(i!=n-1)cout<<card[i]<<" ";
		else cout<<card[i]<<endl;
	}
	cout<<"Stable"<<endl;
	//selectionsort
	int minj=0;
	for(int i=0;i<=n-1;i++){
		minj=i;
		for(int j=i;j<=n-1;j++){
			if(card2[j][1]-'0'<card2[minj][1]-'0'){
				minj=j;	
		}
		}
			if(i!=minj){swap(card2[i],card2[minj]);}
	}
	//stable or not stable 
	for(int i=0;i<n;i++){
		if(i!=n-1)cout<<card2[i]<<" ";
		else cout<<card2[i]<<endl;
		if(card[i]==card2[i]){
			ans++;
		}
	}
	ans==n ? cout<<"Stable"<<endl  : cout<<"Not stable"<<endl;
	string a;cin>>a;
    return 0;
}

Measured memory_bytes: 3120
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n, pi=0, qi=0,cnt=1;
    cin >> n;
    vector<int>arr(n);
    iota(all(arr), 1);
    vector<int>p(n), q(n);
    rep(i, n)cin >> p[i];
    rep(i, n)cin >> q[i];
    do {
        if (arr == p)pi = cnt;
        if (arr == q)qi = cnt;
        cnt++;
    } while (next_permutation(all(arr)));

    cout << abs(pi - qi) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
 
int main(){
    int a, b;
    int d, r;
    double f;
 
    cin >> a >> b;
 
    d = a/b;
    r = a%b;
    f = double(a)/double(b);
 
    printf("%d %d %.5f", d, r, f);
 
    return(0);
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A = nextInt();
  int B = nextInt();
  cout << max({A+B, A-B, A*B}) << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    int ma=0;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==b[i])
            cnt++;
        else
        {
            ma=max(ma,cnt);
            cnt=0;
        }
    }
    ma=max(ma,cnt);
    if(ma>=3)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
 
int f(int n){
  if(n&1){
    return 3*n + 1;
  }
  else{
    return n >> 1;
  }
}
 
int main(){
  int s;
  cin >> s;
  if(s < 3){
   cout << 4 << endl;
  }
  else{
    for(int i=2; i<1000000; i++){
      if(s == 1){
      cout << i << endl;
      break;
      }
      else{
        s = f(s);
      }
    }
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define sec second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int a[3];
  cin >> a[0] >> a[1] >>a[2];
  
  sort(a,a+3);
  
  if(a[0]+a[1] == a[2]) cout << "Yes" << endl;
  else					cout << "No"  << endl;
  return 0;
}

Measured memory_bytes: 256
def a_shrinking(S):
    import string
    ans = float('inf')

    # aからzのうち1つ決めたとき、Sをすべてその文字にするためのコストを計算
    for chr in string.ascii_lowercase:
        if chr not in S:
            # chrがS中にないなら、全文字削除しなければならない
            # S中の文字のどれかに変えるより必ず損するので、計算しない
            continue
        t = list(S)
        t_prime = []
        count = 0  # 何回操作をしたか(1回操作すると文字列長が1短くなる)
        while len(set(t)) > 1:  # tがchr以外の文字を含むなら
            for k in range(len(t) - 1):
                # tのk+1文字目がchrならt_primeのk文字目はchrにしておけば得
                # そうでなければ、tのk文字目をそのまま持ってくればいい
                if t[k + 1] == chr:
                    t_prime.append(chr)
                else:
                    t_prime.append(t[k])
            count += 1
            t = t_prime
            t_prime = []
        ans = min(ans, count)
    return ans

S = input().strip()
print(a_shrinking(S))

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





int main() {
  int X,N;
  cin >> X>>N;
  int p[110];
  int ans;
  vector<pair<int,int>> pairs;
  for(int i =0;i<N;i++){
    cin >>p[i];
  }
  for(int i = 0;i<=100;i++){
    bool a = false;
    for(int j = 0;j <N;j++){
      
      if(X-i == p[j]) a = true;
    }
    if(a == false) {
      ans = X-i;
      break;
    }
    a = false;
    for(int j = 0;j <N;j++){
      
      if(X+i == p[j]) a = true;
    }
    if(a == false) {
      ans = X+i;
      break;
    }

    
  }

  cout << ans << endl;
  

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};


vector<int> to[100005];
int n;
vector<int> dist;
void dfs(int v, int d=0, int p=-1) {
    dist[v] = d;
    for (int u: to[v]) {
        if (u == p) continue;
        dfs(u, d+1, v);
    }
}

vector<int> calcDist(int s){
    dist = vector<int>(n);
    dfs(s);
    return dist;
}
int main() {
    int a, b; cin >> a >> b;
    int list[3] = {1,2,3};
    for (int i=0; i < sizeof(list) / sizeof(*list); i++) {
        if (list[i] != a && list[i] != b) {
            cout << list[i] << endl;
        }
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

int three[100005];

signed main() {
  int tmp = 1, id = 0;
  while (id < 100005) {
    three[id++] = tmp;
    tmp *= 3;
    tmp %= MOD;
  }
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(n + 1, 0), c(n + 1, 0), q(n + 1, 0);
  int Q = 0;
  rep(i, n) {
    if (s[i] == 'A')
      a[i + 1]++;
    else if (s[i] == 'C')
      c[i + 1]++;
    else if (s[i] == '?') {
      Q++;
      q[i + 1]++;
    }
  }
  rep(i, n) {
    a[i + 1] += a[i];
    c[i + 1] += c[i];
    q[i + 1] += q[i];
  }

  int ans = 0;
  rep(i, n) {
    if (s[i] == 'B') {
      ans += (a[i] - a[0]) * (c[n] - c[i + 1]) % MOD * (Q >= 0 ? three[Q] : 1) % MOD;
      ans += (a[i] - a[0]) * (q[n] - q[i + 1]) % MOD * (Q - 1 >= 0 ? three[Q - 1] : 1) % MOD;
      ans += (q[i] - q[0]) * (c[n] - c[i + 1]) % MOD * (Q - 1 >= 0 ? three[Q - 1] : 1) % MOD;
      ans += (q[i] - q[0]) * (q[n] - q[i + 1]) % MOD * (Q - 2 >= 0 ? three[Q - 2] : 1) % MOD;

    } else if (s[i] == '?') {
      ans += (a[i] - a[0]) * (c[n] - c[i + 1]) % MOD * (Q - 1 >= 0 ? three[Q - 1] : 1) % MOD;
      ans += (a[i] - a[0]) * (q[n] - q[i + 1]) % MOD * (Q - 2 >= 0 ? three[Q - 2] : 1) % MOD;
      ans += (q[i] - q[0]) * (c[n] - c[i + 1]) % MOD * (Q - 2 >= 0 ? three[Q - 2] : 1) % MOD;
      ans += (q[i] - q[0]) * (q[n] - q[i + 1]) % MOD * (Q - 3 >= 0 ? three[Q - 3] : 1) % MOD;
    }
  }
  cout << ans % MOD << endl;

  return 0;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;

    int count = 0;
    REP(i, N){ int a;
            cin >>a;
            if( ((i+1)%2 == 1) && a%2 == 1 ){
                count++;
            }
    }
    cout << count << endl;
}


Measured memory_bytes: 3632
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main(){
	int n,k;
	while(cin>>n>>k,n|k){
		vi a(n);
		REP(i,n){
			cin>>a[i];
		}

		int sum=0;
		REP(i,k){
			sum+=a[i];
		}

		int ans=sum;
		FOR(i,k,n){
			sum+=a[i];
			sum-=a[i-k];
			ans=max(ans,sum);
		}

		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1532
n = int(input())
cand = 0
memo = dict()
ans = 0
for i in range(1, n+1):
    s = str(i)[0]
    f = str(i)[-1]
    if s+f in memo:
        ans += memo[s+f]
    else:
        count = 0
        for j in range(1,n+1):
            q = str(j)[0]
            r = str(j)[-1]
            if q == f and r == s:
                count += 1
        ans += count
        memo[s+f] = count
print(ans)



Measured memory_bytes: 43696
#include<bits/stdc++.h>
 
#define ll long long
 
using namespace std;
 
bool chk_bit(ll n, ll k)
{
    return n & (1LL << k);
}
 
ll set_bit(ll n, ll k)
{
    return n | (1LL << k);
}
 
ll flip_bit(ll n, ll k)
{
    return n ^ (1LL << k);
}
 
ll fnc(ll n)
{
    if(n % 4 == 0) return n;
 
    if(n % 2 == 0) return (n ^ 1LL);
 
    if((n + 1) % 4 == 0) return 0LL;
 
    return 1LL;
}
 
int main()
{
    ll a, b;
 
    cin >> a >> b;
 
//    if(a == b){
//        cout << a << endl;
//        return 0;
//    }
 
    cout << (fnc(b) ^ fnc(a - 1)) << endl;
 
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

ll N, ruisekiwa[100001][3];
char in[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		char c;
		cin >> c;
		if (c == 'J')ruisekiwa[i + 1][0]++;
		if (c == 'O')ruisekiwa[i + 1][1]++;
		if (c == 'I')ruisekiwa[i + 1][2]++;
		for (int j = 0; j < 3; j++)ruisekiwa[i + 1][j] += ruisekiwa[i][j];
		in[i] = c;
	}

	ll hajime = 0;
	for (int i = 0; i < N - 1; i++) {
		if (in[i] == 'O') {
			hajime += ((ruisekiwa[i + 1][0] - ruisekiwa[0][0]) * (ruisekiwa[N][2] - ruisekiwa[i + 1][2]));
		}
	}
	ll ans = hajime, tmp = 0;
	//J????????? ????????????????????????????????????
	for (int i = 0; i < N; i++) {
		if (in[i] == 'O') {
			tmp += ((ruisekiwa[i + 1][0] - ruisekiwa[0][0] + 1) * (ruisekiwa[N][2] - ruisekiwa[i + 1][2]));
		}
	}
	ans = max(ans, tmp), tmp = 0;

	//O????????? ??¨????????????

	for (int i = 0; i < N - 1; i++) {
		tmp = max(tmp, 
			(ruisekiwa[i + 1][0] - ruisekiwa[0][0]) * (ruisekiwa[N][2] - ruisekiwa[i + 1][2]));
	}
	ans = max(ans, hajime + tmp), tmp = 0;

	//I????????????????????????????????????????????????
	for (int i = 0; i < N; i++) {
		if (in[i] == 'O') {
			tmp += ((ruisekiwa[i + 1][0] - ruisekiwa[0][0]) * (ruisekiwa[N][2] - ruisekiwa[i + 1][2] + 1));
		}
	}
	ans = max(ans, tmp), tmp = 0;
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5520
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
const int maxn = 1e5+10;
int n,m,q;
vector <int> vec[maxn];
int ans[maxn];
int dp[maxn][11];
int x[maxn],y[maxn],z[maxn];
int vis[maxn];
void dfs(int u,int d,int c)
{
	if(!ans[u]) ans[u]=z[c];
	if(dp[u][d]) return ;
	dp[u][d]=1;
	if(d==0) return ;
	for(auto v:vec[u]) dfs(v,d-1,c);
}

int main()
{
	scanf("%d%d",&n,&m);
	int u,v;
	while(m--)
	{
		scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++)
	scanf("%d%d%d",&x[i],&y[i],&z[i]);
	for(int i=q;i;i--) dfs(x[i],y[i],i);
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}


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

int main (){
    int N, K;
    cin>>N>>K;
    vector<char> S(N);
    for(int i=0; i<N; i++){
        cin>>S.at(i);
    }
    int Count=0;
    int Turn=0;
    int Size=S.size();
    for(int i=0; i<N-1; i++){
        if(S.at(i)=='R'&&S.at(i+1)=='R'){
            Count++;
        }if(S.at(Size-i-1)=='L'&&S.at(Size-i-2)=='L'){
            Count++;
        }

    }

    while(Count<Size-1&&Turn<K){
        Count+=2;
        Turn ++;
    }
  	if(Count==Size){
      	Count --;
    }
    cout<<Count<<endl;
    
   
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int count_1=0;
      int count_2=0;
      int count_3=0;
      int count_4=0;
      String ans = "YES";
      for(int i=0;i<6;i++){
        int a = sc.nextInt();
        if(a==1){
          count_1++;
        }else if(a==2){
          count_2++;
        }else if(a==3){
          count_3++;
        }else{
          count_4++;
        }
        if(count_1>2 || count_2>2 || count_3>2 || count_4>2){
          ans="NO";
          break;
        }
      }
        System.out.print(ans);
    }
}

Measured memory_bytes: 35780
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 *
 * AND WATCH OUT FOR OFF BY ONE!!!
 */

#include <bits/stdc++.h>
const bool unsyncedio=std::ios::sync_with_stdio(false);
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll (i)=0; (i)<(n); (i)++)

int main() {
ll m, k;
    cin>>m>>k;

    int c=(1<<m);
    if(k>=c || (m==1 && k==1)) {
        cout<<-1<<endl;  
        return 0;
    }

    if(m==1) {
        cout<<"0 0 1 1"<<endl;
        return 0;
    }

    fori(c) {
        if(i!=k) 
            cout<<i<<" ";
    }
    cout<<k<<" ";
    for(ll i=c-1; i>=0; i--) {
        if(i!=k) 
            cout<<i<<" ";
    }
    cout<<k<<" ";

    cout<<endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>

void dfs(int N, int &count, std::vector<std::pair<int, int> > &edge, std::vector<bool> &flag, int node, int depth)
{
    if(depth == N-1){
        count++; return;
    }
    flag[node] = true;
    for(auto &&itr = edge.begin(); itr != edge.end(); itr++){
        if(itr->first == node && flag[itr->second] == false) dfs(N, count, edge, flag, itr->second, depth+1);
        if(itr->second == node && flag[itr->first] == false) dfs(N, count, edge, flag, itr->first, depth+1);
    }
    flag[node] = false;
}

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<std::pair<int, int> > edge(M);
    for(int i=0; i<M; i++) std::cin >> edge[i].first >> edge[i].second;

    int count = 0;
    std::vector<bool> flag(N, false);
    dfs(N, count, edge, flag, 1, 0);
    std::cout << count << std::endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define forn(i,n) for(int i=0;i<int(n);++i)
#define vet(a) for(auto&i:a)cout<<i<<" "
#define out(a) cout<<a<<endl

typedef long long int ll;

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

	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	for(auto&i:a)cin>>i;
	sort(a.begin(),a.end());
	int ans=0;
	for(int i=0;i<k;++i){
		ans+=a[i];
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 3628
import sys
import math
import bisect
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    n = int(input())
    h = list(map(int,input().split()))
    amax = 0
    a = 0

    for i in range(n-1):
        if h[i] - h[i+1] >= 0:
            a += 1
        else:
            a = 0
        amax = max(amax, a)

    print(amax)



if __name__ == '__main__':
    main()

Measured memory_bytes: 59632
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int MAX_N = 4;

int main()
{
	string s;
	cin >> s;
	
	if (s[0] == s[1] && s[1] == s[2])
	{
		cout << "No\n";
	}
	else cout << "Yes\n";
	
	return 0;
}


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

while w != 0 and h != 0:
	print("#"*w)
	for j in range(h-2):
		print("#", end="")
		print("."*(w-2), end="")
		print("#")
	print("#"*w)
	print()
	h,w = map(int,input().split())

Measured memory_bytes: 7660
#include <iostream>
#include <cmath>
#include <vector>
#include <string>


using namespace std;


int main()
{
    char S[17];
    cin >> S;
    
    
    char ch[] = "CODEFESTIVAL2016";
    int ans = 0;
    for( int i = 0; i < 17; ++i ){
        if( S[i] != ch[i] ) ++ans;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#include <time.h>
#include <random>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
int k;
cin >> k;
cout << ((e - a) > k ? ":(" : "Yay!") << endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, k, a[100009], f[100009];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
    }
    fill(f + 1, f + 1 + n, 1e9 + 9);
    f[1] = 0;
    for(int i = 2; i <= n; ++ i)
    {
        for(int j = 1; j <= k && i - j > 0; ++ j)
        {
            f[i] = min(f[i], f[i - j] + abs(a[i - j] - a[i]));
        }
    }
    cout << f[n];
}


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

int main() {
  int N,C=0,A;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A;
    if(A%2==0){
      if(A%3!=0&&A%5!=0){
        C=1;
      }
    }
  }
  if(C==1){
    cout << "DENIED" << endl;
  }else{
    cout << "APPROVED" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

#define MAX_N 2000005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r); // n * (n-1) * ... * (n-r+1)
  ans = (ans * finv[r]) % mod; // フェルマーの小定理
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  make();
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  ll ans = 0;
  rep(i, H-A) {
    (ans += comb(i+B-1, i) * comb(W-B-2+H-i, H-i-1) % mod) %= mod;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 50516
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,ans;
  cin>>n>>k;
  int h[n],dp[n];
  for(int i=0;i<n;i++)
  {cin>>h[i];
  dp[i]=INT_MAX;}
  dp[0]=0;
  for(int i=1;i<n;i++)
{
	for(int j=1;j<=k && i-j>=0;j++)
	{
		ans=abs(h[i]-h[i-j])+dp[i-j];
		if(ans<dp[i])dp[i]=ans;
	}
}
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n;
	cin >> n;
	if ((n == 5) || (n == 3) || (n == 7)) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}


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

int main()
{
  ll n;
  cin>>n;
  vector<ll> vec(n+1,0);
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 0; i+j <= n; j+=i)
    {
      vec[i+j]+=1;
    }
  }
  ll ans=0;
  for (int i = 1; i <=n ; ++i)
  {
    ans+=i*vec[i];
  }
  cout<<ans;
}

Measured memory_bytes: 81396
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
ll r=1;
a=a%m;
while(b>0)
{
if(b&1)
r=(r*a)%m;
b=b/2;
a=(a*a)%m;
}
return r%m;
}

vi bit;//1-based indexing

void bit_update(ll x,ll n,ll val)
{
    while(x<n)
    {
        bit[x]+=val;
        x+=(x&(~x+1));
    }
}

ll bit_sum(ll x)
{
    ll sum=0;
    while(x>0)
    {
        sum+=bit[x];
        x-=(x&(~x+1));
    }
    return sum;
}



int main(){
    IOS
    float a,b;
    cin>>a>>b;
    cout<<ceil((b-1)/(a-1));



    return 0;
}


Measured memory_bytes: 256
import numpy as np

N, M, X = map(int, input().split())

data = [list(map(int, input().split())) for _ in range(N)]
INF = float('inf')

data_all = []
c_min = INF

for i in range(2**N):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

if(c_min == INF):
    print(-1)
else:
    print(c_min)





Measured memory_bytes: 27080
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())

for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0

lines = [[a[0][0], a[0][1], a[0][2]],
         [a[1][0], a[1][1], a[1][2]],
         [a[2][0], a[2][1], a[2][2]],
         [a[0][0], a[1][0], a[2][0]],
         [a[0][1], a[1][1], a[2][1]],
         [a[0][2], a[1][2], a[2][2]],
         [a[0][0], a[1][1], a[2][2]],
         [a[0][2], a[1][1], a[2][0]]]

for line in lines:
    if not any(line):
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
const int maxn = 200007;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    f(s.size()) {
        if(i % 2 == 0 && s[i] == 'L') {
            cout << "No\n";
            exit(0);
        }
        if(i % 2 == 1 && s[i] == 'R') {
            cout << "No\n";
            exit(0);
        }
    }
    cout << "Yes\n";
}  

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

    using namespace std;

int map[50][50], width, height;
int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

bool rangeCheck(int row, int col)
{
    if (row >= 0 && row <= height - 1 && col >= 0 && col <= width - 1)
        return true;
    else
    {
        return false;
    }
}

void erase(int row, int col)
{
    map[row][col] = 0;

    for (int i = 0; i < 8; i++)
    {
        if (rangeCheck(row + dy[i], col + dx[i]) == true && map[row + dy[i]][col + dx[i]] == 1)
            erase(row + dy[i], col + dx[i]);
    }
}

int main()
{

    int count;

    while (true)
    {
        scanf("%d %d", &width, &height);
        if (width == 0 && height == 0)
            break;

        for (int i = 0; i < height; i++)
        {
            for (int k = 0; k < width; k++)
            {
                scanf("%d", &map[i][k]);
            }
        }

        count = 0;

        for (int row = 0; row < height; row++)
        {
            for (int col = 0; col < width; col++)
            {
                if (map[row][col] == 1)
                {
                    count++;
                    erase(row, col);
                }
            }
        }

        printf("%d\n", count);
    }

    return 0;
}


Measured memory_bytes: 2660
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($N,$X,$T) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$P = array_map('intval',explode(" ",trim(fgets(STDIN))));

if ($N%$X==0) {
  printf("%d\n",(intdiv($N,$X))*$T);
}
else {
  printf("%d\n",(intdiv($N,$X)+1)*$T);
}


Measured memory_bytes: 16200
#include<iostream>
using namespace std;
int main()
{
	
	int x,a,b,c;
	cin>>x;
	a=x%10;
	b=x/10%10;
	c=x/100%10;
	if(a==7||b==7||c==7)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 3636
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float('inf')

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float('inf')
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float('inf')
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(' ')
        elif type(ls[0])==str:
            print(' '.join(ls))
        elif type(ls[0])==int:
            print(' '.join(map(str,ls)))
        else:
            print('Output Error')
    else:
        if len(ls)==0:
            print('')
        elif type(ls[0])==str:
            print(''.join(ls))
        elif type(ls[0])==int:
            print(''.join(map(str,ls)))
        else:
            print('Output Error')

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

mod = 10**9 + 7

n,k = MI()
d = RI()

for i in range(n,100000):
    a = str(i)
    flag = True
    for j in a:
        if int(j) in d:
            flag = False
            break
    if flag:
        print(i)
        exit()

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

int main(){
    long long A, B;
    long long ans;
    cin >> A >> B;
    ans = A*B/__gcd(A,B);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int r,c;
  cin>>r>>c;
  vector<vector<char>> a(r,vector<char>(c));
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cin>>a.at(i).at(j);
    }
  }
  vector<vector<int>> b(r,vector<int>(c));
  vector<int> dx={1,0,-1,0};
  vector<int> dy={0,1,0,-1};
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      b.at(i).at(j)=114514;
    }
  }
  queue<P> q;
  q.push(P(0,0));
  b.at(0).at(0)=1;
  while(q.size()){
    P p=q.front();
    q.pop();
    if(p.first==r-1&&p.second==c-1){
      break;
    }
    for(int i=0;i<4;i++){
      int nx=p.first+dx.at(i);
      int ny=p.second+dy.at(i);
      if(0<=nx&&nx<r&&0<=ny&&ny<c&&a.at(nx).at(ny)=='.'&&b.at(nx).at(ny)==114514){
        q.push(P(nx,ny));
        b.at(nx).at(ny)=b.at(p.first).at(p.second)+1;
      }
    }
  }
  if(b.at(r-1).at(c-1)==114514){
    cout<<-1<<endl;
  }
  else{
    int count=0;
    for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
        if(a.at(i).at(j)=='#'){
          count++;
        }
      }
    }
    cout<<r*c-b.at(r-1).at(c-1)-count<<endl;
  }
}

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

int main(){
    int K,X;cin>>K>>X;
    if(K*500>=X){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   string s,b=""; cin>>s;
   int q; cin>>q;
   int p=0;
   while(q--){
       int ch; cin>>ch;
       if(ch==1)p++;
       else{
           int ch2; char c;
           cin>>ch2>>c;
           if(ch2==2){
               if(p%2==0)s+=c;
               else b+=c;
           }
           else{
               if(p%2==0)b+=c;
               else s+=c;
           }
       }
   }
   reverse(all(b));
   b+=s;
   if(p&1)reverse(all(b));
   cout<<b<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int A, B, C;
    cin >> A >> B >> C;
    
    if(B >= C)
    {
        cout << B + C << endl;
    }
    else
    {
        if(A + B >= C)
        {
          cout << B + C << endl;
        }
		else
        {
          cout << 2 * B + A + 1<< endl;
        }
    }
  
  return 0;
}

Measured memory_bytes: 256
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n, a, b = LI()
s = S()

# n人が参加するコンペに国内の学生か海外の学生かその他がいる。
# 国内または海外の学生のみが予選通過でき、上位の学生から以下の条件を満たすとき通過
# 国内の学生は通過確定した参加者がA+B人に満たなければ通過
# 海外の学生は通過確定した参加者がA+B人に満たず、海外の学生中での順位がB位以内ならば予選通過

# Sは参加者の情報を示す文字列。i番目の文字がaの時予選i位の参加者が国内の学生、bの時は海外の学生。
# cの時はその他。
# すべての参加者に対して予選通過に対しYes、Noを出力せよ

sl = list(s)
list_a = []
list_b = []
max_pass = a + b

for i in range(len(sl)):
    if sl[i] == "a":
        if len(list_a) + len(list_b) < max_pass:
            sl[i] = "Yes"
            list_a.append(i)
        else:
            sl[i] = "No"
    elif sl[i] == "b":
        if len(list_a) + len(list_b) < max_pass and len(list_b) < b:
            sl[i] = "Yes"
            list_b.append(i)
        else:
            sl[i] = "No"
    elif sl[i] == "c":
        sl[i] = "No"

for x in sl:
    print(x)


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

int main(){
	int N,M,K;
	cin>>N>>M;
	int tmp;
	map<int,int>arr;
	for(int i=0;i<N;++i){
		cin>>K;
		for(int j=0;j<K;++j){
			cin>>tmp;
			arr[tmp-1]++;
		}
	}
	int ans=0;
	for(int i=0;i<M;++i){
		if(arr[i]==N)ans++;
	}
	cout<<ans<<endl;
}


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

int prime[1229];
bool ifnotPrime[10001];

void setPrime(){
    int i = 0;
    ifnotPrime[0] = ifnotPrime[1] = 1;
    for(int n = 2; n <= 10000; n++){
        if(!ifnotPrime[n]){
            prime[i] = n;
            i++;
            int m = n*n;
            while(m <= 10000){
                ifnotPrime[m] = 1;
                m += n;
            }
        }
    }
}

int main(){
    setPrime();
    int N;
    cin >> N;
    while(N > 0){
        int M = N, a = 1;
        for(int i = 0; M > 1 && i < 1229; i++){
            int b = 1,c = 1;
            while( M%prime[i] == 0 ){
                c *= prime[i];
                b += c;
                M /= prime[i];
            }
            a *= b;
        }
        if(M > 1){
            a *= 1+M;
        }
        a -= N;
        if( a > N ){
            cout << "abundant number" << endl;
        }else if( a < N ){
            cout << "deficient number" << endl;
        }else{
            cout << "perfect number" << endl;
        }
        cin >> N;
    }
    return 0;
}

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

int main(){
	int N, x=0, ans=0;
	char S[N];
  	cin >> N >> S;
	for(int i=0;i<N;i++){
		if(S[i]=='I') x++;
		if(S[i]=='D') x--;
      		if(x>ans) ans=x;
	}
	cout << ans << endl;
}


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int H, W;
using P = pair<int, int>;
const array<P, 4> dVec{make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1),
                       make_pair(0, -1)};

// sを起点としたBFSを実行し、sから一番遠いマスへの距離を答える
int distance(P s, const vector<vector<char>>& Maze) {
    queue<P> que;
    int res = 0;
    vector<vector<int>> Dist(H, vector<int>(W, -1));
    que.push(s);
    Dist[s.second][s.first] = 0;

    while (!que.empty()) {
        P point = que.front();
        que.pop();
        res = max(res, Dist[point.second][point.first]);
        int px = point.first, py = point.second;
        for (auto dv : dVec) {
            P pointNew{dv.first + point.first, dv.second + point.second};
            int nx = pointNew.first, ny = pointNew.second;
            if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
            if (Maze[ny][nx] == '#') continue;
            if (Dist[ny][nx] == -1) {
                Dist[ny][nx] = Dist[py][px] + 1;
                que.push(pointNew);
            }
        }
    }
    /*
    cout << "s: (" << s.first << ", " << s.second << ")" << endl;
    for (auto& wid : Dist) {
        for (auto item : wid) {
            cout << setw(2) << item << " ";
        }
        cout << '\n';
    }
    cout << "========" << '\n';
    */
    return res;
}

int main() {
    /* code */
    cin >> H >> W;
    vector<vector<char>> Maze(H, vector<char>(W));
    REP(h, H) {
        REP(w, W) { cin >> Maze[h][w]; }
    }

    int res = 0;
    REP(sx, W) {
        REP(sy, H) {
            if (Maze[sy][sx] == '#') continue;
            res = max(res, distance(P{sx, sy}, Maze));
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,vis[2][N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        vis[i&1][x]++;
    }
    int mx1=0,p1=0,mx2=0,p2=0;
    for(int i=1;i<=100000;i++)
    {
        if(vis[0][i]>mx1) mx1=vis[0][i],p1=i;
        if(vis[1][i]>mx2) mx2=vis[1][i],p2=i;
    }
    int ans=0;
    if(p1==p2)
    {
        int m1=0,m2=0;
        for(int i=1;i<=100000;i++)
            if(i!=p1)
            m1=max(m1,vis[0][i]),m2=max(m2,vis[1][i]);
        ans=n-max(m1+mx2,m2+mx1);
    }
    else ans=n-mx1-mx2;
    printf("%d\n",ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
 
int main() {
 
    int N,X;
    cin >> N >> X;
 
    vector<int> L(N);
    rep(i,N){
        cin >> L[i];
    }
 
    int count = 0;
    int d = 0;
 
    for(int i=0; i<=N; i++){
        d = d + L[i];
        count++;
        if(d>X) break;
    }
 
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <iomanip> 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<ull> vul;
typedef vector<pair<ll, ll>> vpl;
typedef pair<ll, ll> pl;
#define For(i, n) for(ll i = 0; i < n; i++)
#define len(n) (ll)(n).size()
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
vector<vl> g;
vb used;
ll dp[100010][2];
void dfs(ll v) {
	used[v] = true;
	for (ll to : g[v]) {
		if (!used[to]) {
			dfs(to);
			dp[v][0] *= dp[to][1];
			dp[v][0] %= ((ll)1e9 + 7);
			dp[v][1] *= ((dp[to][0] + dp[to][1]) % ((ll)1e9 + 7));
			dp[v][1] %= ((ll)1e9 + 7);
		}
	}
	
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n, a, b;
	cin >> n;
	g.resize(n);
	used.resize(n);
	For(i, n - 1) {
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	For(i, n) {
		dp[i][0] = 1;
		dp[i][1] = 1;
	}
	dfs(0);
	ll ans = dp[0][0] + dp[0][1];
	ans %= ((ll)1e9 + 7);
	cout << ans;
	return 0;
}

Measured memory_bytes: 15880
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        sum+=(s[i]-'0');
    }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
  	return 0;
}







Measured memory_bytes: 3732