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

using namespace std;
typedef long long lint;

class nCk {
public:
    nCk(int N)
    : mod(1000*1000*1000+7)
    , ps(N+1)
    , rps(N+1)
    {
        ps[0] = rps[0] = 1;
        for (int i = 1; i <= N; i++) {
            ps[i] = (ps[i-1] * i) % mod;
            rps[i] = powMod(ps[i], mod-2);
        }
    }
    lint calc(int n, int k) const {
        if (n < 0 || k < 0) return 0;
        if (n < k) return 0;
        return (ps[n] * rps[k] % mod) * rps[n-k] % mod;
    }
    lint getMod() const {
        return mod;
    }
private:
    const int mod;
    vector<lint> ps;
    vector<lint> rps;
    lint powMod(lint x, int p) {
        lint ret = 1;
        lint cur = x;
        while (p) {
            if (p%2) {
                (ret *= cur) %= mod;
            }
            (cur *= cur) %= mod;
            p /= 2;
        }
        return ret;
    }
};

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1), prev(N, -1);
    int medium = 0;
    for (int i = 0; i < N+1; i++) {
        cin >> A[i];
        --A[i];
        if (prev[A[i]] >= 0) {
            medium = i - prev[A[i]] - 1;
        } else {
            prev[A[i]] = i;
        }
    }
    nCk solve(N);
    for (int k = 1; k <= N+1; k++) {
        lint ans = solve.calc(N-1, k) + solve.calc(N-1, k-2) + 2 * solve.calc(N-1, k-1) - solve.calc(N-1-medium, k-1);
        (ans += solve.getMod()) %= solve.getMod();
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))
import fractions

a,b,c,d=input_list()

l_c=(a+c-1)//c
h_c=b//c
c_num=h_c-l_c+1

l_d=(a+d-1)//d
h_d=b//d
d_num=h_d-l_d+1


g=c*d//fractions.gcd(c,d)
l_g=(a+g-1)//g
h_g=b//g
g_num=h_g-l_g+1

ans=b-a+1-c_num-d_num+g_num
print(ans)

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

int main() {
    int k;
    cin >> k;
    long long ans = 0;
    for (long long a = 1; a <= k; a++) {
        for (long long b = 1; b <= k; b++) {
            for (long long c = 1; c <= k; c++) {
                ans += (long long)gcd(gcd(a, b), c);
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp61 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            float[] x = new float[N];
            string[] u = new string[N];

            for (int i = 0; i < N; i++) {
                var st = Console.ReadLine().Split();

                x[i] = float.Parse(st[0]);
                u[i] = st[1];
            }

            float ans = 0;

            for (int i = 0; i < N; i++) {
                if (u[i] == "BTC") {
                    ans += 380000 * x[i];
                } else {
                    ans += x[i];
                }

            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
 
using namespace std;
 
 
class DICE {
    enum {
        Top,
        Front,
        Right,
        Left,
        Rear,
        Bottom
    };
 
    void Roll(const char*Directions) {
        for (int i = 0; Directions[i] != '\0'; i++) {
            Roll(Directions[i]);
        }
    }
 
    void Roll(const char Direction) {
        int tmpTop = Num[Top];
 
        switch (Direction) {
        case'E':
            Num[Top] = Num[Left];
            Num[Left] = Num[Bottom];
            Num[Bottom] = Num[Right];
            Num[Right] = Num[tmpTop];
            break;
        case'N':
            Num[Top] = Num[Front];
            Num[Front] = Num[Bottom];
            Num[Bottom] = Num[Rear];
            Num[Rear] = tmpTop;
            break;
        case'S':
            Num[Top] = Num[Rear];
            Num[Rear] = Num[Bottom];
            Num[Bottom] = Num[Front];
            Num[Front] = tmpTop;
            break;
        case'W':
            Num[Top] = Num[Right];
            Num[Right] = Num[Bottom];
            Num[Bottom] = Num[Left];
            Num[Left] = tmpTop;
            break;
        }
    }
 
    bool SameDiceDirectionFlag(DICE Dice) {
        for (int i = 0; i < 6; i++) {
            if (Num[i] != Dice.Num[i])return false;
        }
        return true;
    }
 
public:
    int Num[6];
 
    bool SameDiceNoneDirectionFlag(DICE Dice) {
        const char Directions[][3] = { "N","N","N","NW","WW","\0" };
 
        for (int i = 0; i < 6; i++) {
            if (Num[Top] == Dice.Num[Top]) {
                for (int j = 0; j < 4; j++) {
                    if (SameDiceDirectionFlag(Dice))return true;
 
                    int tmpFront = Dice.Num[Front];
                    Dice.Num[Front] = Dice.Num[Right];
                    Dice.Num[Right] = Dice.Num[Rear];
                    Dice.Num[Rear] = Dice.Num[Left];
                    Dice.Num[Left] = tmpFront;
                }
            }
 
            Dice.Roll(Directions[i]);
        }
 
        return false;
    }
 
};
 
int main() {
    DICE Dice[101];
    int n;
 
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 6; j++)cin >> Dice[i].Num[j];
    }
 
    for (int i = 1; i < n; i++) {
        if (Dice[0].SameDiceNoneDirectionFlag(Dice[i])) {
            cout << "No" << endl;
            return 0;
        }
    }
 
    cout << "Yes" << endl;
 
    return 0;
}

Measured memory_bytes: 3084
(N,M,T),*Y=$<.map{|l|l.split.map &:to_i};X=Y.reverse;$><<(T<2?(a=(r=0..N).map{|i|1<<i-1};Y.each{|x,y|a[x]=a[y]|=a[x]};q=2**N-2;g=r.find{|i|a[i]>q})?(o=[p]*-~N;o[g]=1;X.map{|x,y|o[x]?o[y]=?^:(o[x]||=o[y];?v)}):[-1]:N<3?[-1]:X.map{|x,y|y<4&&Y[x]==Y[6-x-y]?(Y[x]=Y[y];?v):(Y[y]=Y[x];?^)}).reverse.join

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

int H, W, Sr, Sc, Gr, Gc, ans;
int B[25][25];
int dr[4] = {-1, 1, 0, 0};
int dc[4] = {0, 0, -1, 1};

void dfs(int r, int c, int d) {
    if (d == 10) return;
    REP(i, 4) {
        int nr = r;
        int nc = c;
        bool out = false;
        bool goal = false;
        while (true) {
            nr += dr[i];
            nc += dc[i];
            if (nr < 0 || nr >= H || nc < 0 || nc >= W) {
                out = true;
                break;
            }
            if (nr == Gr && nc == Gc) {
                goal = true;
                ans = min(ans, d+1);
                break;
            }
            if (B[nr][nc] == 1) {
                break;
            }
        }

        if (out) continue;
        if (goal) return;
        if (nr-dr[i] == r && nc-dc[i] == c) continue;

        B[nr][nc] = 0;
        dfs(nr-dr[i], nc-dc[i], d+1);
        B[nr][nc] = 1;
        
    }
}

int solve() {
    cin >> W >> H;
    if (H == 0) return 0;

    REP(i, H) REP(j, W) {
        cin >> B[i][j];
        if (B[i][j] == 2) Sr = i, Sc = j;
        if (B[i][j] == 3) Gr = i, Gc = j;
    }

    ans = 1 << 29;
    dfs(Sr, Sc, 0);
    if (ans == 1 << 29) ans = -1;
    
    return ans;
}

int main() {
    while (true) {
        int ret = solve();
        if (ret == 0) break;
        cout << ret << endl;
    }
}

Measured memory_bytes: 3076
#include <iostream>
using namespace std;
int main(void){
    int n,j,a[100]={0};
    cin >>n;
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    for(int i=0;i<n;i++){
        j=n-1-i;
        if(j==n-1){
            cout <<a[j];
        }
        else{
            cout <<" "<<a[j];
        }
    }
    cout <<endl;
}



Measured memory_bytes: 3080
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

vi six,nine;

int n;
int ans=INF;

void ume(){
    int i=6;
    while(true){
        if(i>100000) break;
        six.pb(i);
        i*=6;
    }
    i=9;
    while(true){
        if(i>100000) break;
        nine.pb(i);
        i*=9;
    }
    sort(rall(six));
    sort(rall(nine));
}

void dfs(int zan, int num){
    if(num>=ans) return;
    if(zan<6){
        ans = min(num+zan,ans);
        return;
    }
    rep(i,six.size()){
        if(six[i]>zan) {
            //six.erase(six.begin()+i);
            continue;
        }
        dfs(zan-six[i],num+1);
        break;
    }
    
    rep(i,nine.size()){
        if(nine[i]>zan) {
            //nine.erase(nine.begin()+i);
            continue;
        }
        dfs(zan-nine[i],num+1);
        break;
    }

}

signed main(){
    io();

    ume();
    n=in();

    dfs(n, 0);
    out(ans);

    return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int H, W; cin >> H >> W;
	map<char, int> ch2NumMap;
	REP(i, H * W) {
		char ch; cin >> ch; ++ch2NumMap[ch];
	}
	int fourPairNum = (H / 2) * (W / 2);
	int twoPairNum = (H % 2) * (W / 2) + (H / 2) * (W % 2);
	int singleNum = (H % 2 == 1 && W % 2 == 1) ? 1 : 0;
	if (singleNum == 1)
	{
		for (auto &kvp : ch2NumMap)
		{
			if (kvp.second % 4 == 1 || kvp.second % 4 == 3)
			{
				--singleNum;
				--kvp.second;
				break;
			}
		}
	}
	for (auto &kvp : ch2NumMap)
	{
		int max = kvp.second / 4;
		kvp.second -= std::min(fourPairNum * 4, max * 4);
		fourPairNum -= std::min(fourPairNum, max);
	}
	for (auto &kvp : ch2NumMap)
	{
		int max = kvp.second / 2;
		kvp.second -= std::min(twoPairNum * 2, max * 2);
		twoPairNum -= std::min(twoPairNum, max);
	}
	bool isYes = true;
	for (const auto &kvp : ch2NumMap)
	{
		if (kvp.second != 0)
		{
			isYes = false;
			break;
		}
	}
	cout << (isYes ? "Yes" : "No") << endl;
}

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

typedef struct Eq{
  int location,eq;
}S;

int pop1();
S pop2();
void push1(int);
void push2(int,int);

int S1[20000];
S S2[20000];

int top1 = 0;
int top2 = 0;

int main(){
  int i,j,n,ad,sum = 0;
  char C[20000];
  scanf("%s",C);
  n = strlen(C);
  for(i = 0; i < n; i++){
      if(C[i] == '\\'){
        push1(i);
      }
      else if( top1 > 0 && C[i] == '/'){
        j = pop1();
        ad = i - j;
        sum += ad;
        while( top2 > 0 && S2[top2-1].location > j){
          ad += pop2().eq;
        }
        
        push2(j,ad);
      }
      
  }
  

  printf("%d\n",sum);
  printf("%d",top2);
  for(i = 0; i < top2; i++){
    printf(" %d",S2[i].eq);
  }
  
  printf("\n");

  return 0;
  
}


void push1(int i){
  S1[top1] = i;
  top1++;
  
}

int pop1(){
  top1--;
  return S1[top1];
  
}

void push2(int j,int add){
  S2[top2].location = j;
  S2[top2].eq = add;
  top2++;
  
}

S pop2(){
  top2--;
  return S2[top2];
  
}



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

using namespace std;

#define int long long

void solve() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' '<< z;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second
    
int x,a,b;

int main()
{
    scanf("%d%d%d",&x,&a,&b);
    printf("%d",a+b+x-max(x,max(a,b)));
    return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
L_max = 0
R_min = N
for i in range(M):
    L,R = map(int, input().split())
    if L > L_max:
        L_max = L
    if R < R_min:
        R_min = R

if R_min-L_max < 0:
    print(0)
else:
    print(R_min-L_max+1)

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

int main() {
    int a1, a2 ,a3;
    cin >> a1 >> a2 >> a3;
    int sum = a1+a2+a3;

    if (sum >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

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


Measured memory_bytes: 1408
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>

int cmpfunc(const void *a, const void *b)
{
    return (*(int *)a - *(int *)b);
}

int main()
{
    int N, K;
    scanf("%d %d", &N, &K);

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

    qsort(array, N, sizeof(int), cmpfunc);

    int sum = 0;
    for (int i = 0; i < K; i++)
    {
        sum += array[i];
    }

    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	ll s = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < (n + 1) / 2; i++) {
		s += 2 * a[n - i - 1];
	}
	s -= a[n - 1];
	if (n & 1)s -= a[n / 2];
	cout << s;
}

Measured memory_bytes: 3972
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
using namespace std;
void q42() {
	int w, n;
	int c = 0;
	for (; cin >> w >> n;) {
		char tmp[32];
		scanf("%c", &tmp[0]);
		c++;
		int value[1001];
		int weight[1001];
		int dp[1001];
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; i++) {
			int v_i, w_i;
			scanf("%d,%d", &v_i, &w_i);
			scanf("%c", &tmp[0]);
			value[i] = v_i;
			weight[i] = w_i;
		}
		for (int i = 0; i < n; i++) {
			for (int j = w; j >= weight[i]; j--) {
				dp[j] = max(dp[j], dp[j - weight[i]] + value[i]);
			}
		}
		int max_value = 0;
		int max_weight = 0;
		for (int i = 1; i <= w; i++) {
			if (dp[i] > max_value) {
				max_value = dp[i];
				max_weight = i;
			}
		}
		cout << "Case " << c << ":" << endl;
		cout << max_value << endl;
		cout << max_weight << endl;
	}
}

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

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  vector<ll> a(3);
  REP(i, 3) { cin >> a[i]; }
  sort(ALL(a));
  if (a[0] != a[1] && a[1] == a[2] || a[0] == a[1] && a[1] != a[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
int main(void)
{
    char s[5];
    int count1 = 0;
    int count2 = 0;
    
    scanf("%s", s);
    
    while(s[count1]){
        if(s[count1] == '+'){
            count2++;
        }else if(s[count1] == '-'){
            count2--;
        }
        count1++;
    }

    printf("%d", count2);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=100005;
int n,m,fa[N],A[N],B[N],C[N],id[N];bool pd[N];LL sum[N],f[N];
int pp,lnk[N],nxt[N*2],to[N*2];
void ae(int k1,int k2){to[++pp]=k2,nxt[pp]=lnk[k1],lnk[k1]=pp;}
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
bool cmp(int k1,int k2){return C[k1]<C[k2];}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n)scanf("%d%d",&A[i],&B[i]),C[i]=max(A[i]-B[i],0),sum[i]=B[i];
	rep(i,1,m){
		int k1,k2;scanf("%d%d",&k1,&k2);
		ae(k1,k2),ae(k2,k1);
	}
	rep(i,1,n)fa[i]=i,id[i]=i;
	sort(id+1,id+1+n,cmp);
	rep(_,1,n){
		int k1=id[_];
		pd[k1]=1;LL c=C[k1];
		for(int i=lnk[k1];i;i=nxt[i])if(pd[to[i]]){
			int k2=fd(to[i]);if(k2==k1)continue;
			fa[k2]=k1,sum[k1]+=sum[k2],c=min(c,max((LL)C[k1],f[k2])-sum[k2]);
		}
		f[k1]=sum[k1]+c;
//		fprintf(stderr,"f[%d]=%lld\n",k1,f[k1]);
	}
	printf("%lld\n",f[fd(1)]);
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) cout << exchange(dlm, "\t") << x;
  return os;
}
struct Graph{
  size_t time;
  vector<vector<size_t>> v;
  vector<size_t> d,f;
  Graph(size_t n): time(1), v(n), d(n,0), f(n) {}
  void dfs(size_t i){
    d[i]=time++;
    for(const auto& x:v[i]) if(d[x-1]==0) dfs(x-1);
    f[i]=time++;
  }
};
ostream& operator<<(ostream& os, const Graph& x){
  for(size_t i=0; i<x.v.size(); ++i)
    cout<<(i+1)<<' '<<x.d[i]<<' '<<x.f[i]<<'\n';
  return os;
}
int32_t main(){
  size_t n; cin>>n;
  Graph graph(n);
  for(size_t i=0; i<n; ++i){
    size_t id,k; cin>>id>>k;
    graph.v[id-1].resize(k); for(auto&& x:graph.v[id-1]) cin>>x;
  }
  for(size_t i=0; i<n; ++i){
    if(graph.d[i]==0) graph.dfs(i);
  }
  cout<<graph;
}


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

using namespace std;

const int MAX_N = 100;
int n,x;
int a[MAX_N];

int main()
{
  cin >> n >> x;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a+n);

  int i, y = 0;
  for (i = 0; i < n && y < x; i++) {
    y += a[i];
  }

  cout << (x == y ? i : i - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i = 0;i < N;i++) {
    cin >> V.at(i);
  }
  vector<int> C(N);
  for(int i = 0;i < N;i++) {
    cin >> C.at(i);
  }
  int sum = 0;
  for(int i = 0;i < N;i++) {
    if(V.at(i) - C.at(i) > 0) {
      sum += V.at(i) - C.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,m,ac=0,wa=0;
    cin>>n>>m;
    long long p;
    vector<long long> a(n+1,0),w(n+1,0);
    string s;
    f(i,0,m){
        cin>>p>>s;
        if(s=="AC"&&a[p]==0){
            a[p]++;
        }
        else if(s=="WA"&&a[p]==0){
            w[p]++;
        }
    }
    f(i,1,n+1){
        ac+=a[i];
        if(a[i]!=0){
            wa+=w[i];
        }
    }
    cout<<ac<<" "<<wa<<endl;
    return 0;
}


Measured memory_bytes: 4848
#include <stdio.h>
#define N 100
void insert(int *,int);

int main(){
  int a[N],i,length,n,j;
  scanf("%d",&length);
  for(i=0;i<=length-1;i++){
    scanf("%d",&n);
    a[i]=n;
      }
  insert(a,length);
  
  return 0;
}

void insert(int a[],int l){
  int i,key,j,c;
      for(c=0;c<l-1;c++){
      printf("%d ",a[c]);
    }
      printf("%d\n",a[c]);
     
  for(i=1;i<=l-1;i++){
    key = a[i];
    j = i-1;
    while(j>=0&&key<a[j]){
      a[j+1]=a[j];
      j--;
      a[j+1]=key;
    }
    for(c=0;c<l-1;c++){
      printf("%d ",a[c]);
    }
    printf("%d\n",a[c]);
  } 
}



Measured memory_bytes: 2128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;

//最大公約数
ll gcd(ll a,ll b){
    
    if(a==0 || b==0)return max(a,b);
    if(a<b){
        ll sw;
        sw=a;
        a=b;
        b=sw;
    }
    
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}

signed main(){
	
	int n,a[111111];
	int f[111111],b[111111];
	cin>>n;
	rep(i,n)cin>>a[i];
	int g;
	f[0]=0;
	for(int i=0;i<n;i++){
		f[i+1]=gcd(f[i],a[i]);
	}
	b[n]=0;
	for(int i=n-1;i>=0;i--){
		b[i]=gcd(b[i+1],a[i]);
	}
	int max=0;
	rep(i,n){
		max=std::max(gcd(f[i],b[i+1]),max);
		//DEB(a[i-1])END
		//DEB(a[i])END
	}
	cout<<max<<endl;
	
}

Measured memory_bytes: 2816
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 1000000007L;
	static final int INF = 50000000;
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.ni();
		long[] nums = new long[N];
		long[] target = new long[N];
		nums[0] = sc.nl();
		target[0] = nums[0];
		long ans = 0;
		for (int i = 1; i < N; i++) {
			nums[i] = sc.nl();
			target[i] = Math.max(nums[i], target[i-1]);
			ans += (target[i]-nums[i]);
		}
		pw.println(ans);
		pw.close();
	}

    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        }
        
        int ni() { 
            return Integer.parseInt(next()); 
        }
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() {
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

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

using namespace std;



int main() {
 int n;
  cin >> n;
  vector<vector<int>> days(n, vector<int>(3));
  for (int i = 0; i < n; i++) {
   	cin >> days[i][0] >> days[i][1] >> days[i][2]; 
  }
  
  vector<vector<int>> dp(n, vector<int>(3));
  dp[0][0] = days[0][0];
  dp[0][1] = days[0][1];
  dp[0][2] = days[0][2];
  
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 3; j++) {
   		for (int k = 0; k < 3; k++) {
         if (k != j) dp[i][j] = max(dp[i][j], dp[i - 1][k] + days[i][j]); 
        }
    }
  }
  
  cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}

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

using namespace std;

#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))
const int mod = 2019;
int main(){
	fast;
    string s;
    cin>>s;
    int n = s.size();
    ll ans = 0;
    int suf = 0;

    vector<int>cnt_suf(2019);
    cnt_suf[suf]++;
    int power_of_ten = 1;
    for(int i = n-1; i >= 0; i--) {
		int digit = s[i] - '0';
		suf = (suf + digit * power_of_ten) % mod;
		power_of_ten = (10 * power_of_ten) % mod;
		ans += cnt_suf[suf];
		cnt_suf[suf]++;
	}
	cout<<ans<<endl;



return 0;
}


Measured memory_bytes: 3744
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#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 <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(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 FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

typedef vector<double> vd;

vi subset_combination(int n, int k) {
	vi res;
	int S = (1 << k) - 1;
	int E = ~((1 << n) - 1);
	while (!(S&E)) {
		res.push_back(S);
		int smallest = S & -S;
		int ripple = S + smallest;
		int nsmallest = ripple & -ripple;
		S = ripple | (((nsmallest / smallest) >> 1) - 1);
	}
	return res;
}

double dist(vd a, vd b) {
	double res = 0;
	REP(i, a.size()) {
		res += pow(a[i] - b[i], 2);
	}
	return res;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vd> data(N, vd(3));
	REP(i, N) {
		REP(j, 3) {
			cin >> data[i][j];
		}
	}

	double ans = 0;
	if (N == 0 || M == 0) {

	} else {
		vi comb = subset_combination(N, M);
		int size = comb.size();
		REP(i, size) {
			double tmp = 0;
			REP(j, N) {
				REP(k, N) {
					if (j != k && comb[i] & (1 << j) && comb[i] & (1 << k)) {
						tmp += dist(data[j], data[k]);
					}
				}
			}
			ans = max(ans, tmp);
		}
		ans /= 2;
	}

	printf("%.6f\n", ans);
	return 0;
}

Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  string s;
  cin>>s;
  if(s.find("YAKI")==0) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

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 = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int h, w, n;
  cin >> h >> w >> n;
  vector<int> colors;
  rep(i, n) {
    int a; cin >> a;
    rep(j, a) colors.push_back(i+1);
  }

  vector<vector<int>> ans(h, vector<int>(w));
  int idx = 0;
  rep(i, h) rep(j, w) {
    ans[i][j] = colors[idx++];
  }

  rep(i, h) {
    if (i % 2 == 1) {
      reverse(ALL(ans[i]));
    }
    rep(j, w) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
n = int(input())
L = [3,5,7]
for i in range(9):
    P = []
    for p in L:
        a = str(p)+"3"
        P.append(int(a))
        b = str(p)+"5"
        P.append(int(b))
        c = str(p)+"7"
        P.append(int(c))
        
    L.extend(P)
L = list(set(L))
ans = 0
for q in L:
    x = list(str(q))
    if q <= n:
        if "3" in x and "5" in x and "7" in x:
            ans += 1

print(ans)

Measured memory_bytes: 52484
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    cout<<s[0]<<n-2<<s[n-1];
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    for(int i=0;i<N;++i) cin >> h[i];
    int j=0,cnt=0;
    for(int i=0;i<N;++i){
        while(h[i]>0){
            for(int j=i;j<N && h[j]>0;++j){
                --h[j];
            }
            ++cnt;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
def c_atcodeer_and_election_report(N, R):
    vote_takahashi, vote_aoki = 1, 1
    for x, y in R:
        # v_t<=nx ∧ v_a<=ny を満たす最小のnを求める(切り上げを先に行う)
        n = max(-(-vote_takahashi // x), -(-vote_aoki // y))
        vote_takahashi = n * x
        vote_aoki = n * y
    return vote_takahashi + vote_aoki

N = int(input())
R = [[int(i) for i in input().split()] for j in range(N)]
print(c_atcodeer_and_election_report(N, R))

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

struct node{
    int self;
    ll parent;
    vector<int> child;
};

int main(){
    int N,Q;
    cin >> N;
    cin >> Q;

    map<int,node> edges;
    int a,b;
    REP(i,0,N-1){
        cin >> a;
        cin >> b;
        edges[b].parent=a;
        edges[a].child.push_back(b);
    }

    vector<ll> ans(N+1,0);
    REP(i,0,Q){
        cin >> a;
        cin >> b;
        ans[a]+=b;
    }

    queue<int> que;
    que.push(1);
    ll self,parent,par_value=0;
    while(!que.empty()){
        //P(que.front());
        self=que.front();
        que.pop();
        if(self!=1){
            parent=edges[self].parent;
            par_value = ans[parent];
            ans[self]+=par_value;
        }

        for(auto c:edges[self].child){
            que.push(c);
        }
    }

    cout << ans[1];
    REP(i,2,N+1){
        cout << " " <<ans[i];
    }
    cout << endl;
    
}

Measured memory_bytes: 28928
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  vll A(3);
  cin >> A[0] >> A[1] >> A[2];
  SORT(A);

  ll ans = 0;
  while (1) {
    if (A[2] - A[0] < 2 && A[2] - A[1] < 2) {
      ans += A[2] - A[0];
      ans += A[1] - A[0];
      break;
    }
    A[0] += 2;
    ans++;
    SORT(A);
  }
  ANS;
  return 0;
}

Measured memory_bytes: 3652
package main

import "fmt"

func scanStrs(h int) (strs [][]rune) {
	strs = make([][]rune, h)
	var s string
	for i := range strs {
		fmt.Scan(&s)
		strs[i] = []rune(s)
	}
	return
}

func drawable(strs [][]rune, i, j int) bool {
	if strs[i][j] == '.' {
		return true
	}

	result := false
	if i-1 >= 0 {
		if strs[i-1][j] == '#' {
			result = true
		}
	}

	if j-1 >= 0 {
		if strs[i][j-1] == '#' {
			result = true
		}
	}

	if j+1 < len(strs[0]) {
		if strs[i][j+1] == '#' {
			result = true
		}
	}

	if i+1 < len(strs) {
		if strs[i+1][j] == '#' {
			result = true
		}
	}

	return result
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	strs := scanStrs(h)

	is_complete := true
	for i := 0; i < h; i++ {
		if !is_complete {
			break
		}

		for j := 0; j < w; j++ {
			if !is_complete {
				break
			}

			if drawable(strs, i, j) {
				is_complete = true
			} else {
				is_complete = false
			}
		}
	}

	if is_complete {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000
#define BEAM 30

using namespace std;

class state {
    public:
        int day;
        int previous_score;
        vector<int> previous;
        vector<int> types;

        state() {}

        state(const state& a) : day(a.day), previous_score(a.previous_score), previous(a.previous), types(a.types) {}
};

int _scoring(const vector<int> &c,
        const vector<vector<int>> &s,
        int day,
        int type,
        const vector<int> &previous) {
    int score = s[day][type];

    REP(i, 26) {
        score -= c[i] * (day + 1 - previous[i]);
    }

    return score;
}

int scoring(const vector<int> &c,
        const vector<vector<int>> &s,
        state &this_state) {
    this_state.previous[this_state.types.back()] = this_state.day + 1;
    return this_state.previous_score + _scoring(c, s, this_state.day, this_state.types.back(), this_state.previous);
}

using queue_type = pair<state, int>;
struct CustomCompare
{
    bool operator()(const queue_type &a, const queue_type &b) {
        return a.second < b.second;
    }
};

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

    vector<int> c(26);
    REP(i, 26)
        cin >> c[i];

    vector<vector<int>> s(D, vector<int>(26, 0));
    REP(i, D)
        REP(j, 26)
        cin >> s[i][j];

    vector<state> initial;
    REP(i, 26) {
        state this_state;
        this_state.day = 0;
        this_state.types.push_back(i);
        this_state.types.reserve(D);
        this_state.previous_score = 0;
        this_state.previous = vector<int>(26, 0);
        initial.push_back(this_state);
    }

    priority_queue<queue_type, vector<queue_type>, CustomCompare> q1, q2;
    REP(i, D) {
        if (i == 0) {
            // use initial
            for (auto i : initial) {
                q2.push(make_pair(i, scoring(c, s, i)));
            }
        } else {
            // use queue
            for (int ii = 0; ii < BEAM && !q1.empty(); ++ii) {
                auto i = q1.top();

                REP(j, 26) {
                    state new_state = i.first;
                    new_state.day++;
                    new_state.types.push_back(j);

                    q2.push(make_pair(new_state, scoring(c, s, new_state)));
                    //q2.emplace_back(new_state, scoring(c, s, new_state));
                }

                q1.pop();
            }
        }
        swap(q1, q2);

        q2 = decltype(q2)();
    }

    auto res = q1.top().first;

    for (auto t : res.types)
        cout << t + 1 << endl;

    return 0;
}



Measured memory_bytes: 6668
/* Breadth First Graph */
#include <stdio.h>

void visit(int);
int dequeue(void);
void enqueue(int);

int map[101][101];
int Q[101], n, head=0, tail=0, color[101], d[101];

int main()
{
    int i, j, v, vv, m, u, k;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        color[i] = 0;
        for(j=0; j<n; j++){
            map[i][j] = 0;
        }
    }
    for(i=0; i<n; i++){
        scanf("%d%d", &v, &m);
        for(j=0; j<m; j++){
            scanf("%d", &vv);
            map[v-1][vv-1] = 1;
        }
    }
    for(j=0; j<n; j++){
        if(map[0][j] == 1){
            color[j] = 0;
        }
    }
    color[0] = 1;
    d[0] = 0;
    enqueue(0);
    while(head != tail){
        u = dequeue();
        for(k=0; k<n; k++){
            if(map[u][k] == 1 && color[k] == 0){
                color[k] = 1;
                d[k] = d[u]+1;
                enqueue(k);
            }
            color[u] = 2;
        }
    }

    for(i=0; i<n; i++){
        if(color[i] == 2){
            printf("%d %d\n", i+1, d[i]);
        } else{
            printf("%d -1\n", i+1);
        }
    }
    return 0;
}

int dequeue()
{
    int x;
    x = Q[head];
    if(head + 1 == 100){
        head = 0;
    } else{
        head = head + 1;
    }
    return x;
}

void enqueue(int x)
{
    Q[tail] = x;
    if(tail +1 == 100){
        tail = 0;
    } else{
        tail = tail + 1;
    }
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll //9223372036854775807
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
#define nl "\n"
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;}
//ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
inline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
ll inve(ll x){return x==1?1:(mod-mod/x)*inve(mod%x)%mod;}

const int N = 1e5+5;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    cout<<(min(c,b/a))<<nl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	priority_queue<ll>a;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		a.push(now);
	}
	for(ll i=0;i<k;i++){
		ll now=a.top();
		a.pop();
		a.push(now/2);
	}
	ll ans=0;
	while(a.size()!=0){
		ll now=a.top();
		a.pop();
		ans+=now;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1400
from collections import defaultdict

N, M = map(int, input().split())
AB = []
d = defaultdict(list)
for _ in range(M):
    A, B = map(int, input().split())
    # A, B = A - 1, B - 1  # 0-indexed
    A, B = min(A, B), max(A, B)
    AB.append((A, B))
    d[A].append(B)
    d[B].append(A)
# print('AB', AB)
# print('d', d)

V = [-1] * (N + 1)
R = [-1] * (N + 1)
V[1] = 0

q = d[1]
for i in d[1]:
    R[i] = 1
cnt = 0
while True:
    cnt += 1
    qq = []
    for i in q:
        if V[i] != -1:
            continue
        V[i] = cnt
        for j in d[i]:
            if R[j] == -1:
                qq.append(j)
                R[j] = i
    # print('qq', qq, V, R)
    if qq:
        q = qq
    else:
        break
# print('V', V)
# print('R', R)

print('Yes')
for r in R[2:]:
    print(r)


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

public class Main implements Runnable {
	static final int INF = (int)1e9+7;
	int N,M;
	char[] a,b;
	int[][] dp;

	public int dfs(int x,int y){

		if(x == 0 && y == 0){
			return 0;
		}

		if(x == 0){
			return y;
		}

		if(y == 0){
			return x;
		}

		if(dp[x][y] != INF)return dp[x][y];

		int ret = INF;

		//add
		if(x > 0){
			ret = Math.min(ret,dfs(x-1,y) + 1);
		}

		//remove
		if(y > 0){
			ret = Math.min(ret, dfs(x,y-1) + 1);
		}

		//replace
		if(x > 0 && y > 0){
			ret = Math.min(ret, dfs(x-1,y-1) + (a[x-1] == b[y-1] ? 0 : 1));
		}
		return dp[x][y] = ret;
	}

	public void solve() {
		a = next().toCharArray();
		b = next().toCharArray();

		N = a.length;
		M = b.length;

		dp = new int[N+1][M+1];
		for(int i = 0;i < N+1;i++){
			for(int j = 0;j < M+1;j++){
				dp[i][j] = INF;
			}
		}
		out.println(dfs(N,M));

	}

	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	@Override
	public void run() {
		out.flush();
		new Main().solve();
		out.close();

	}
}

Measured memory_bytes: 30288
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


# 初期入力　　２０２０－０７２７　21：50
from collections import Counter
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
*S, =input().strip()
"""
c =Counter(S)
ans =combinations_count(N, 3) -len(c)
"""
count =0
x100=0
x10=0
x1=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            if str(i) in S:
                x100 =S.index(str(i)) +1
                if str(j) in S[x100:]:
                    x10 =S[x100:].index(str(j)) +1
                    if str(k) in S[x100 +x10:]:
                        x1 =S[x100+x10:].index(str(k)) +1
                        count +=1
                        #print("aa",i,j,k,"bb",x100,x100+x10,x100+x10+x1)

print(count)

Measured memory_bytes: 9664
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	ll n,k;
	cin>>n>>k;
	int ans=0;
	while(n)
    {
        ans++;
        n=n/k;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
def calc_sum_digits(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n //= 10
    return sum

N, A, B = map(int, input().split())
result = 0
for n in range(1, N+1):
    sum = calc_sum_digits(n)
    if sum >= A and sum <= B:
        result += n
print(result)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
int main(){
	reg int a,b,k;
	scanf("%d%d%d",&k,&a,&b);
	if((a+k-1)/k>b/k)puts("NG");
	else puts("OK");
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define PI (ld)acos(-1)
#define endl '\n'
#define dbg(x) cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl; 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const ld eps=(ld)1e-9;
const ll inf=(ll)1e9;
const ll mod=(ll)1e9+7;

void solve(){
	int n;
	cin>>n;
	vector<int>a(3),dp(3,0);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin>>a[j];
		}
		vector<int>ndp(3,0);
		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 3; ++k)
			{
				if(j!=k){
					ndp[j]=max(ndp[j],dp[k]+a[j]);
				}
			}
		}
		dp=ndp;
	}
	cout<<max({dp[0],dp[1],dp[2]});
}

int main(){fio;
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}
return 0;
}


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

int main()
{
  long a;
  std::cin >> a ;
  std::vector<long> r;
  long ans = 1e12;
  for(long i = 1; i <= std::sqrt(a); i++)
  {
    if(a%i==0)
    {
      long b = a/i;
      ans = std::min(ans, (b-1)+(i-1));
      // r.push_back((b-1)+(i-1));
    }
  }
  std::cout<<ans<<std::endl;
  // std::cout  << *std::min_element(r.begin(),r.end()) << std::endl;
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
	int n,x1,y1,z1,w1,x2,y2,z2,w2,r,i,j,k;
	
	while(1)
	{
		std::cin>>n;
		if(n==0)break;
		for(int m=0;m<n;m++)
		{
			std::cin>>x1>>y1>>z1>>w1>>x2>>y2>>z2>>w2;
			
			r=x1*x2-y1*y2-z1*z2-w1*w2;
			i=x1*y2+y1*x2+z1*w2-w1*z2;
			j=x1*z2-y1*w2+z1*x2+w1*y2;
			k=x1*w2+y1*z2-z1*y2+w1*x2;
			std::cout<<r<<' '<<i<<' '<<j<<' '<<k<<std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164