akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
int n,m,cnt=0,ans=0;
int a[200000],b[200000];
vector<pair<int,int>>p(200000);
signed main(){
    cin>>n>>m;
    rep(i,n){
        cin>>a[i]>>b[i];
        p[i]=make_pair(a[i],b[i]);
    }
    sort(p.begin(),p.end());
    for(int i=0;cnt<m;i++){
        int x=min(p[i].second,m-cnt);
        cnt+=x;
        ans+=x*p[i].first;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

void solve();

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

void solve() {
    int d,l;
    cin >> d >> l;
    cout << d / l + d % l << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    if(b==1){
        cout << "0" << endl;
        return 0;
    }
    int ans = 1;
    int k = a; //未使用
    while(k < b){
        k += a-1;
        ans++;
    }
    //DEBUG(k);
    cout << ans << endl;
    return 0;
}

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

const int MAXN = 20;

int n, x[MAXN], y[MAXN];
long long p[MAXN], dp1[1 << 15], dp[MAXN][1 << 15];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d %d %lld", &x[i], &y[i], &p[i]);
	
	for(int mask = 0; mask < (1 << n); mask++){
		if(mask == 0)dp1[mask] = 0;
		else{
			dp1[mask] = 1LL << 50;
			for(int i = 0; i < n; i++)if(mask & (1 << i)){
				long long r0 = 0, r1 = 0;
				for(int j = 0; j < n; j++)if(mask & (1 << j)){
					int d = min(abs(x[j]), abs(y[j]));
					r0 += p[j] * min(d, abs(x[j] - x[i]));
					r1 += p[j] * min(d, abs(y[j] - y[i]));
				}
				dp1[mask] = min(dp1[mask], min(r0, r1));
			}
		}
	}
	
	for(int k = 0; k <= n; k++)
	for(int mask = 0; mask < (1 << n); mask++){
		dp[k][mask] = 0;
		for(int i = 0; i < n; i++)if(mask & (1 << i)){
			dp[k][mask] += p[i] * min(abs(x[i]), abs(y[i]));
		}
		
		if(k > 0){
			for(int sub = mask; sub > 0; sub = (sub - 1) & mask){
				dp[k][mask] = min(dp[k][mask], dp[k - 1][mask ^ sub] + dp1[sub]);
			}
		}
	}
	
	for(int k = 0; k <= n; k++){
		printf("%lld\n", dp[k][(1 << n) - 1]);
	}
	
	return 0;
}


Measured memory_bytes: 8156
n = int(input())
H = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(n - 1):
    if H[i] >= H[i + 1]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
else:
    ans = max(ans, tmp)
print(ans)


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

bool endcheck(string &s){
	bool f=false;
	rp(i,s.size()-1){
		if(s[i]!=s[i+1]){
			f=true;
			break;
		}
	}
	return f;
}

int main(){
	string s; cin>>s;
	int a = 0, b = 0;
	rp(i,s.size()){
		if(s[i]=='0')++a;
		if(s[i]=='1')++b;
	}
	int c = min(a,b);
	ote(c*2);
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			int m=sc.nextInt();
			ArrayList<Long> queue=new ArrayList<>();
			ArrayList<Long> sum=new ArrayList<>();
			long[][] a=new long[n+1][3];
			for(int i=0; i<n; i++) {
				a[i][0]=sc.nextLong();
				a[i][1]=sc.nextLong();
				a[i][2]=sc.nextLong();
			}
			long s=0;
			long ss=0;
			for(int i=0; i<(1<<3); i++) {
				ss=0;
				for(int num=0; num<n; num++) {
					s=0;
					for(int j=0; j<3; j++) {
						if((1 & i>>j)==1) s+=a[num][j];
						else s-=a[num][j];
					}
					queue.add(s);
				}
				Collections.sort(queue);
				Collections.reverse(queue);
				for(int k=0; k<m; k++) {
					ss+=queue.get(k);
				}
				queue.clear();
				sum.add(ss);
			}
			Collections.sort(sum);
			Collections.reverse(sum);
			System.out.println(sum.get(0));

		}
	}
}

Measured memory_bytes: 28524
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define se second
#define pi 3.14159265358979
//ll string_inp() {cin.get(); for(int i =0;i<n;i++){ getline(cin,s[i]);}}
ll gcd(ll a, ll b){ if (a == 0) return b;  return gcd(b % a, a);  }
ll power(ll x, ll y, ll mod = 2e18) {ll ans = 1;x %= mod;while(y){if(y&1) ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; if (m == 1) return 0; while (a > 1) { ll q = a / m; ll t = m; m = a % m,a = t; t = y; y = x - q * y; x = t; } if(x < 0) x += m0;return x;}
int takemod(int a, int mod = MOD){a%=mod;if(a<0)a+=mod;return a;}
ll binsearch(std::vector<ll>& nums, ll target) {ll n = nums.size();ll l = 0;ll r = n-1;while(l<=r){ll mid = l+ (r-l)/2;if(nums[mid]==target)return mid;else if(nums[mid]>target)r = mid-1;else l = mid+1;}return -1;}
bool isPowerOfTwo (int x) {return x && (!(x&(x-1))); }

using namespace std;

int main()
{
   fastio
   ll t;
   cin>>t;
   int ac=0,wa=0,tle=0,re=0;
   while(t--)
   {
            string s;
            cin>>s;

            if(s[0]=='A')
                ac++;
            if(s[0]=='W')
                wa++;
            if(s[0]=='T')
                tle++;
            else if(s[0]=='R') re++;


   }
            cout<<"AC x "<<ac<<endl;
            cout<<"WA x "<<wa<<endl;
            cout<<"TLE x "<<tle<<endl;
            cout<<"RE x "<<re<<endl;


}




Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) 
	{ 
		cerr << name << " : " << arg1 << endl;
	}
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) 
    {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#endif
 
 
const int N = 3e5 + 5;
const int MAXN = 1e5 + 5;
const int M = 1e5;
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
const ll INF = 1e15;
const int LG = 21;


int arr[N];
vector<int> v[N];
map<int, int> mp;
map<int, int> ret;


void solve() 
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ret = 0;
	ret += min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	ret += -1 * min(c, k);
	k -= min(c, k);
	cout << ret << endl;
}
 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 10644
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

ll dp[310][310][310];
//--MAIN-----------------------------------
void Main() {
    string S; cin>>S;
    ll N=S.size(); 
    ll K; cin>>K;
    rep(i,N+1){
        rep(j,N+1){
            rep(k,K+1){
                maxi(dp[i+1][j][k],dp[i][j][k]);
                maxi(dp[i][j+1][k],dp[i][j][k]);
                maxi(dp[i+1][j+1][k+1],dp[i][j][k]+1);
                if(i<N and N-1-j>=0 and S[i]==S[N-1-j]){
                    maxi(dp[i+1][j+1][k],dp[i][j][k]+1);
                }
            }
        }
    }
    ll ans=0;
    rep(k,K+1){
        rep(i,N+1) maxi(ans,dp[i][N-i][k]*2); 
        rep(i,N) maxi(ans,dp[i][N-1-i][k]*2+1); 
    }
    cout<< ans <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 226816
#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() {
  ll n,k;
  cin >> n >> k;
  vector<int> v(n);
  ll sum=0;
  rep(i,n){
    cin >> v[i];
    sum+=v[i];
  }
  ll finalans=1;
  int zzz=sqrt(sum)+1;
  rep(i,zzz){
    if(i==0) continue;
    if(sum%i!=0) continue;
    ll x=sum/i;
    ll ans=0;
    ll ans2=0;
    vector<pair<int,int>> vec;
    for(int y:v){
      vec.push_back(make_pair(y%x,x-y%x));
    }
    sort(vec.begin(),vec.end());
    int a=-1,b=v.size();
    while(b-a!=1){
      a++;
      ans+=vec[a].first;
      while(ans>=ans2+vec[b-1].second){
        b--;
        ans2+=vec[b].second;
      }
    }
    
    if(ans<=k) finalans=max(finalans,x);
  }
  rep(i,zzz){
    if(i==0) continue;
    if(sum%i!=0) continue;
    ll x=i;
    ll ans=0;
    ll ans2=0;
    vector<pair<int,int>> vec;
    for(int y:v){
      vec.push_back(make_pair(y%x,x-y%x));
    }
    sort(vec.begin(),vec.end());
    int a=-1,b=v.size();
    while(b-a!=1){
      a++;
      ans+=vec[a].first;
      while(ans>=ans2+vec[b-1].second){
        b--;
        ans2+=vec[b].second;
      }
    }
    if(ans<=k) finalans=max(finalans,x);
  }
  cout << finalans << endl;
}

Measured memory_bytes: 3732
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		boolean count = true;
		ArrayList<Integer> a = new ArrayList<>();
		a.add(s);
		int i = 1;

		while (count) {
			i++;
			if (s % 2 == 0) {
				s /= 2;
			} else {
				s = s * 3 + 1;
			}
			if (a.contains(s)) {
				System.out.println(i);
				break;
			}
			a.add(s);
		}

		sc.close();
	}
}


Measured memory_bytes: 22868
import math
a, b, h, m = map(int,input().split())

ax = a*math.cos(math.radians(90-360/12*(h+m/60)))
ay = a*math.sin(math.radians(90-360/12*(h+m/60)))

bx = b*math.cos(math.radians(90-360/60*m))
by = b*math.sin(math.radians(90-360/60*m))

print(math.sqrt((ax-bx)**2+(ay-by)**2))


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

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

	if (a<=200&&a>=195) {
     cout<<5<<endl;
	}
	else if (a <= 194 && a >= 189) {
		cout << 4 << endl;
	}
	else if (a <= 188&& a >= 165) {
		cout << 3 << endl;
	}
	else if (a <= 164 && a >= 135) {
		cout << 2 << endl;
	}
	else if (a <= 134 && a >= 105) {
		cout << 1 << endl;
	}
	else if (a <= 104 && a >= 1) {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;


int main(){
    ll x;
    cin>>x;
    ll ans=1;
    rep(i,1,35){
        rep(j,2,10){
            ll n=pow(i,j);
            if(n<=x){
                ans=max(ans,n);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int masu[3];
  scanf("%1d%1d%1d", &masu[0], &masu[1], &masu[2]);
  
  int count=0;
  for(int i=0; i<sizeof(masu)/sizeof(masu[0]); i++){
    if(masu[i] != 0){
      count++;
    }
  }
  printf("%d", count);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
const int maxn=1e5+10;
int n,q;
ll num[maxn],out[maxn],opt[maxn],stk[maxn],top;
IL void work(ll x,ll y){
	int bef=lower_bound(opt+1,opt+1+q,x)-opt-1;
	if(!bef){
		out[1]+=y;
		out[x+1]-=y;
	}else {
		num[bef]+=x/opt[bef]*y;
		work(x%opt[bef],y);
	}
}
int main(){
#ifdef LOCAL
	freopen("/home/noilinux/Desktop/input.txt","r",stdin);
#endif
	n=gi();q=gi();
	rep(i,1,q)scanf("%lld",&opt[i]);
	stk[++top]=n;
	rep(i,1,q){
		while(top&&opt[i]<=stk[top])top--;
		stk[++top]=opt[i];
	}
	q=top;rep(i,1,q)opt[i]=stk[i];
	num[q]=1;
	repd(i,q,1)work(opt[i],num[i]);
	rep(i,1,n)out[i]+=out[i-1];
	rep(i,1,n)printf("%lld\n",out[i]);
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#define rep(i,n) for(ll i=0;i<n;i++)
typedef long long int ll;
const ll INF = 100100100100100100;
using namespace std;

ll A,B,C,X,Y;

int main(){
    cin >> A >> B >> C >> X >> Y;
    ll XY = max(X,Y);
    ll ans = INF;
    rep(i,XY*2+1){
        ll need_A = X-i/2;
        ll need_B = Y-i/2;
        if(need_A < 0) need_A = 0;
        if(need_B < 0) need_B = 0;
        ll cost = need_A*A + need_B*B + i*C;
        if(cost < ans){
            ans = cost;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	rep(i, N) {
		if (A[i] % 2 == 0) {
			if (A[i] % 3 == 0 || A[i] % 5 == 0)continue;
			else {
				cout << "DENIED";
				return 0;
			}
		}
	}
	cout << "APPROVED";
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
# gx, gy, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

for i in range(1, 10):
    for j in range(1, 10):
        if i * j == N:
            print("Yes")
            exit()

print("No")

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

const static ll MOD = (1e+9)+7;

int main(){
    int n;cin>>n;
    vector<int> a(n,0);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    } 
    set<int> s;//ここに履歴を書いていく.
    s.insert(0);
    int now = 0;
    int cnt = 0;
    while(1){
        now = a[now];
        cnt++;
        if(now == 1){
            cout<<cnt<<endl;
            break;
        }
        if(s.count(now)){
            cout<<-1<<endl;
            break;
        }
        s.insert(now);
    }
    return 0;
}

Measured memory_bytes: 5376
N = int(input())
tasks = [list(map(int, input().split())) for i in range(N)]

tasks.sort(key= lambda x: x[1])

time = 0

for task in tasks:
    time += task[0]
    if time > task[1]:
        ans = "No"
        break
else:
    ans = "Yes"

print(ans)




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


int main (){

 int N;
 cin >> N;
 long long int ans=1;

 for(int i = 1; i <= N; i++) {
  ans *= i;
  ans %= 1000000000 + 7;
 }
 
 cout << ans << endl;

 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    string s, p;
    cin >> s >> p;
    string s2;
    s2 = s + s;
    if(s2.find(p) == string::npos) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#define mt make_tuple
#define ll long long
#define ld long double
#define eb emplace_back
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin >> vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
 
using namespace std;
 using namespace __gnu_pbds;
 template <typename T>
 using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
//----------------------------------------------------------------------------------------------------------------------
  
void swap(int & a, int & b){
    auto temp = a;
    a = b;
    b = temp;
}
 
const ll MOD = 1e9 + 7;
 
ll inf = 1LL*1e11;
 
void no(){
    cout <<"NO" << endl;exit(0);
}
void yes(){
    cout <<"YES" << endl; exit(0);
}

void solve(){
   int k,n; cin >> k >> n;
   vector< int > arr (n); scanVec(arr,n);
   int ans = 0;
   for(int i = 1;i < n;i++){
       ans = max(ans,arr[i] - arr[i-1]);
   }
   ans = max(ans,arr[0] + (k - arr[n - 1]));
   cout << (k - ans) << endl;
}       
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--) solve();
    return 0;
} 


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

string ans;
vector<string> cmds;
map<char, ll> num;

int main(void) {
    int N;
    cin >> N >> num['A'] >> num['B'] >> num['C'];
    rep(i, 0, N) {
        string cmd;
        cin >> cmd;
        cmds.pb(cmd);
    }
    
    if (num['A']+num['B']+num['C']!=2LL) {
      rep(i, 0, N) {
        
        string cmd = cmds[i];
        char X = cmd[0], Y = cmd[1];
        if (num[X]>=num[Y]) {
          num[X]--; num[Y]++;
          ans += Y;
        } else {
          num[Y]--; num[X]++;
          ans += X;
        }
        if (num['A']<0 || num['B']<0 || num['C']<0) {
          puts("No");
          return 0;
        }
       //printf("%lld %lld %lld\n", num['A'], num['B'], num['C']);
      }
     
    
    } else {
      vector<int> idxs;
      string notchoice;
      rep(i, 0, N) {
        string cmd = cmds[i];
        char X = cmd[0], Y = cmd[1];
        if (num[X]>num[Y]) {
          num[X]--; num[Y]++;
          ans += Y;
          notchoice += X;
        } else if (num[X]<num[Y]) {
          num[Y]--; num[X]++;
          ans += X;
          notchoice += Y;
        } else if (num[X]==1&&num[Y]==1) {
          num[X]++; num[Y]--;
          ans += X;
          notchoice += Y;
          idxs.pb(i);
        } else {
          if (sz(idxs)==0) {
            puts("No");
            return 0;
          }
          int idx = idxs[sz(idxs)-1];
          idxs.pop_back();
          
          num[notchoice[idx]] = 2;
          num[ans[idx]] = 0;
          swap(ans[idx], notchoice[idx]);
          
          
          if (ans[idx]==X) {
            num[Y]++;
            num[X]--;
            ans += Y;
            notchoice += X;
          } else {
            num[X]++;
            num[Y]--;
            ans += X;
            notchoice += Y;
          
          }
        }
         //printf("%lld %lld %lld\n", num['A'], num['B'], num['C']);
      }
      
    
    }

    puts("Yes");
    rep(i, 0, N)cout << ans[i] << endl;
    return 0;
}





Measured memory_bytes: 7476
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    h_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [h] = [int(input_raw[0])]
        h_list.append(h)

    h_list.sort(reverse = True)
    min_sub_h = sys.maxint
    for i in range(N - K + 1):
        min_sub_h = min(min_sub_h, h_list[i] - h_list[i + K -1])
    print min_sub_h


if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; }


#define INF 21474836

string S;

int main() {

	cin >> S;

	bool y = true;
	if (S == "AAA" || S == "BBB")y = false;

	YesNo(y);

	return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d %d" , &n , &m);
    if(n*500 >= m)printf("Yes\n");
    else printf("No\n");

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 2e3 + 5;
const int MOD = 1e9 + 7;

ll ad(ll a, ll b){
    return((a % MOD + b % MOD) % MOD);
}
ll sub(ll a, ll b){
    return((a % MOD - b % MOD + MOD) % MOD);
}
ll mul(ll a, ll b){
    return(((a % MOD) * (b % MOD)) % MOD);
}

int main(){
	fast;
	ll s;
	cin >> s;
	ll dp[s + 1] = {0};
	dp[0] = 1;
	for(int i = 3; i <= s; ++i)
		for(int j = 3; j <= i; ++j)
			dp[i] = ad(dp[i], dp[i - j]);
	cout << dp[s] << "\n";
	return 0;
}


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

using namespace std;
typedef long long ll;

#define MAX 100001

vector<int> P[MAX];
int path[MAX], p = 0;
bool vis[MAX];

void dfs(int v) {
    if(!vis[v]) path[p++] = v;
    vis[v] = true;
    for(int next : P[v]) {
        if(!vis[next]) {
            dfs(next); 
            break;
        }
    }
}

int main(void) {
    int n, m, a, b;
    scanf("%d%d", &n, &m);
    for(int i=0; i<m; i++) {
        scanf("%d%d", &a, &b);
        P[a-1].emplace_back(b-1);
        P[b-1].emplace_back(a-1);
    }

    dfs(0);
    reverse(path, path+p);
    dfs(0);
    
    printf("%d\n", p);
    for(int i=0; i<p; i++) printf("%d ", path[i]+1);
    printf("\n");
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
const ll mod = 1000000000039ll, base = 9971ll;
ll n,a[N],pre[N];
map<ll,ll> mp;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		pre[i]=pre[i-1]+a[i];
	}	
	ll res=0;
	mp[0]++;
	for(int i=1;i<=n;i++)
	{
		res+=mp[pre[i]];
		mp[pre[i]]++;
	}
	cout<<res<<'\n';

	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{

    ll x,k,d,ans;
    cin>>x>>k>>d;
    x=abs(x);
    if(d<x){
        ll div=x/d;
        if(div==k){
            cout<<x-(d*div)<<endl;
        }
        else if(div>k){
            cout<<x-(d*k)<<endl;
        }
        else{
            ans=x-(d*div);
            k-=div;
            if(k%2)
                cout<<abs(ans-d)<<endl;
            else
                cout<<ans<<endl;
        }
    }
    else if(d>x){
        if(k%2)
           cout<<abs(x-d)<<endl;
        else
           cout<<x<<endl;
    }
    else{
        if(k%2)
            cout<<0<<endl;
        else
            cout<<x<<endl;
    }

    return 0;

}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 0 , 1 } ;
const int dy[] = { 0 , -1 , 1 , 0 } ;

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int x , a ;
    cin >> x >> a ;

    if ( x < a )
        cout << 0 ;
    else
        cout << 10 ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  long long all = 0;
  long long current = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    all += abs(current - A[i]);
    current = A[i];
  }

  all += abs(current - 0);
  current = 0;

  for (int i = 0; i < N; i++) {
    int answer = all;
    answer -= abs(current - A[i]);
    if (i != N - 1) {
      answer -= abs(A[i] - A[i+1]);
      answer += abs(current - A[i+1]);
    } else {
      answer -= abs(A[i] - 0);
      answer += abs(current - 0);
    }
    current = A[i];
    
    cout << answer << endl;
  }

  return 0;

}

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

//int main(int argc, const char * argv[]) {
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    int temp;
    
    if (a > b) {
        temp = b;
        b = a;
        a = temp;
    }
    
    if (b > c) {
        temp = c;
        c = b;
        b = temp;
    }
    
    if (a > b) {
        temp = b;
        b = a;
        a = temp;
    }
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, T, A;
  cin >> N >> T >> A;
  int H[1100];
  for(int i = 0; i < N; i++) cin >> H[i];
  
  /*各地点の温度と基準との温度差*/
  int Temp[1100]; //各地点の温度を格納
  int mn = -1; //最適なiを格納するための変数
  int INF = pow(10, 6); //比較のため．T <= 50 なので100で取った．
  					   //浮動小数点を消すための1000倍
  
  for(int i = 0; i < N; i++)
  {
    Temp[i] = T*1000 - H[i]*6; //各地点の温度を計算
  }
  for(int i = 0; i < N; i++)
  {
  	if(abs(Temp[i] - A*1000) < INF)
    {
      INF = abs(Temp[i] - A*1000);
      mn = i + 1; //差の絶対値が最小になるiを求める．
    }
  }
  cout << mn << endl;
}

Measured memory_bytes: 256
N = gets.to_i
W = []
N.times{
  W << gets.chomp.split(" ").map(&:to_i)
}

W.sort_by!{|w| w[1]}
ans = "Yes"
t = 0
W.each{|w|
  t += w[0]
  (ans = "No"; break) if t > w[1]
}

puts ans


Measured memory_bytes: 22392
#include <iostream>

using namespace std;

int main(){
	int n;
	int y,m,d;
	int sandewareru;
	int warenai;
	int months;
	int years;
	cin>>n;

	for(int i=0;i<n;i++){
		int days=0;
		cin>>y>>m>>d;

		years=y-1;
		months=m-1;
		

		sandewareru=years/3;//3??§???????????´?????°
		warenai=years-sandewareru;//3??§??????????????´?????°

		days+=sandewareru*200;
	

		days+=warenai*195;

	
		
		
		if(y%3==0){//???????????§?????´
			days+=months*20;
		}else{
			if(months%2==0){
				days+=(months/2)*39;
			}else{
				days+=((months/2)*39+20);
			}
		}
		days+=d;

		
		

	cout<<196471-days<<endl;
	}

	
	return 0;


}

Measured memory_bytes: 3048
#include<bits/stdc++.h>            //  IT'S NEVER TOO LATE...
    	using namespace std;
        #include<math.h>
    	#define ll long long
    	#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
        #define forn(i, n) fore(i, 0, n)
        #define fori(i, l, r) fore(i, l, (r) + 1)
        #define sz(v) int((v).size())
        #define all(v) (v).begin(), (v).end()
        #define pb push_back
        #define mp make_pair
        #define ff first
        #define ss second

        const double PI = atan(1)*4;

        int dx[8]={1,0,-1,0,1,-1,-1,1};
        int dy[8]={0,1,0,-1,1,1,-1,-1};

    	
    	vector<int> ar[1000001];
        vector<pair<int,int>> path;
        int vis[1000001],dis[1000001];

        /*void dfs(int node)
        {
            vis[node]=1;

            for(int child : ar[node])
            {
                if(vis[child]==0)
                {
                    dis[child]=dis[node]+1;
                    dfs(child);
                }
            }
        }*/

    /*    void bfs(int i)
        {
            queue<int> q;
            q.push(i);
            vis[i]=1;
            dis[i]=0;

            while(!q.empty())
            {
                int curr=q.front();
                q.pop();

                for(int child : ar[curr])
                    if(vis[child]==0)
                    {
                        q.push(child);
                        dis[child]=dis[curr]+1;
                        vis[child]=1;
                    }
            }
        }*/

        bool isprime(int n)
        {
            for(int i=2;i*i<=n;i++)
                if(n%i==0)
                    return false;
            return true;
        }

        bool comp(pair<int,int> a, pair<int,int> b)
        {
            return b.ff < a.ff ;
        }

        int modpow(int b,int p,int m)
        {
            if(p==0) return 1%m;
            if(p%2) return (b*modpow(b,p-1,m))%m;
            int u=modpow(b,p/2,m);
            return (u*u)%m;
        }

    	int main()  
    	{
    		int t=1;
    		//cin>>t;
    		
    		while(t--)
    		{
                int n=5,ans;
                int a[n];
                forn(i,n) 
                {
                    cin>>a[i];
                    if(a[i]==0)
                        ans=i+1;
                }

                cout<<ans;

            }
            return 0;
    	}

        //              NOW IT'S TIME TO WAKE UP...

Measured memory_bytes: 27016
INFTY = 10 ** 10

import queue

def bfs(s):
    q = queue.Queue()
    q.put(s)
    d = [INFTY] * n
    d[s] = 0
    while not q.empty():
        u = q.get()
        for v in range(n):
            if M[u][v] == 0:
                continue
            if d[v] != INFTY:
                continue
            d[v] = d[u] + 1
            q.put(v)
    for i in range(n):
        if d[i] == INFTY:
            print(i+1, -1)
        else:
            print(i+1, d[i])

n = int(input())
M = [[0] * n for _ in range(n)]

for i in range(n):
    nums = list(map(int, input().split()))
    u = nums[0] - 1
    k = nums[1]
    for j in range(k):
        v = nums[j+2] - 1
        M[u][v] = 1

bfs(0)


Measured memory_bytes: 6932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
	Scanner w = new Scanner ( System.in) ;
	String s = w.next();;
	int len= s.length();
	StringBuilder sb = new StringBuilder();
	int i = 0 ; 
	while (i  < len) { 
		sb.append("x"); 
		i ++ ;
	}
	System.out.print(sb);
	}
}


Measured memory_bytes: 23124
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	long long int ans = 0,x=0;
	int n, t;
	cin >> n >> t;
	x = -t - 4;
	for (int i = 0; i < n; i++) {
		int y;
		cin >> y;
		ans += t-max(x+t-y,(long long int)0);
		x = y;
	}
	cout << ans << endl;
	return 0;

}




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

const ll INF = 1e10;

int main(){
    ll n;
    scanf("%lld", &n);
    
    ll a[n];
    for(int i = 0; i < n; i++)
        scanf("%lld", a + i);
    
    vector<ll> dp(n, INF);
    
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j <= i + 2; j++){
            if(j < n){
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
        }
    }
    
    cout<<dp[n-1];
    
    return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


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

	int N;
	cin >> N;
	int res = 1;
	int A;
	int MA = (int)1e18;
	bool ok = true;
	bool zf = false;
	rep(i, 0, N)
	{
		cin >> A;
		if (A == 0)zf = true;
		if (MA / res < A)
		{
			ok = false;
		}
		if (ok)res *= A;
	}

	if (zf)cout << 0 << endl;
	else if (!ok)cout << -1 << endl;
	else cout << res << endl;

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int a, b, t; cin >> a >> b >> t;
    int ans=0;
    while(a <= t){
        ans += b;
        t -= a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
a, b, c, x, y = map(int, input().split())
ans = min(a + b, c * 2) * min(x, y)
if x > y:
    ans += (x - y) * min(a, c * 2)
elif y > x:
    ans += (y - x) * min(b, c * 2)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdlib>

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

using namespace std;

typedef long long int lli;

int digit(int n) {
    int res = 0;
    do {
        res++;
        n /= 10;
    } while(n);
    return res;
}

int main () {
    lli N;
    cin >> N;
    int res = 1 << 30;
    for (lli i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            lli num = N /i;
            res = min(res, max(digit(num), digit(i)));
        }
    }
    cout << res << endl;
    return 0;
}


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

int sumDigits(int num) { return num / 10000 + num % 10000 / 1000 + num % 1000 / 100 + num % 100 / 10 + num % 10; }
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> roadMap(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        roadMap[a - 1]++;
        roadMap[b - 1]++;
    }
    for (int i = 0; i < N; i++) {
        cout << roadMap[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys

try:
	nums = list(map(int, input().split()))
	N, M = nums[0], nums[1]
except:
	print("整数を入力")
	sys.exit()

if (N < 0 or 100 < N) or (M < 0 or 100 < M):
	print("NとMはそれぞれ0以上100以下")
	sys.exit()
if N + M < 2:
	print("N + Mは2以上")
	sys.exit()


def keisan(num):
	# 組み合わせの数をcntでカウント
	cnt = 0
	while not num == 0:
		copy_num = num
		while not (copy_num - 1) == 0:
			copy_num -= 1
			cnt += 1
		num -= 1
	return cnt

sum = keisan(N) + keisan(M)
print(sum)


Measured memory_bytes: 3064
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>

using namespace std;

int main(void)
{
	int N;
	long long int a, b;
	vector <vector <long long int>> ratio;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> a >> b;
		ratio.push_back({ a,b });
	}

	a = 0;
	b = 0;

	for (int i = 0; i < ratio.size(); i++)
	{
		if (a <= ratio[i][0] && b <= ratio[i][1])
		{
			a = ratio[i][0];
			b = ratio[i][1];
		}
		else
		{
			long long int x, y;
			if (a > ratio[i][0] && b<=ratio[i][1])
			{
				if (a%ratio[i][0] == 0)
				{
					x = a / ratio[i][0];
				}
				else
				{
					x = (a / ratio[i][0]) + 1;
				}
				a = ratio[i][0] * x;
				b = ratio[i][1] * x;
			}
			else if(b>ratio[i][1] && a<=ratio[i][0])
			{
				if (b%ratio[i][1] == 0)
				{
					x = b / ratio[i][1];
				}
				else
				{
					x = (b / ratio[i][1]) + 1;
				}
				a = ratio[i][0] * x;
				b = ratio[i][1] * x;
			}
			else
			{
				x = a / ratio[i][0];
				if (a%ratio[i][0] != 0)
				{
					x += 1;
				}
				y = b / ratio[i][1];
				if (b%ratio[i][1] != 0)
				{
					y += 1;
				}
				x = max(x, y);
				a = ratio[i][0] * x;
				b = ratio[i][1] * x;
			}
		}

	}

	cout << a+b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	string a,b;
	int ia,ib;
	bool p;
      cin >> a >> b;
  if(a.length()==b.length()){
  	p=true;
	for(int i = 0;i<a.length()+1;i++){
  		ia=a[i]-'0';
  		ib=b[i]-'0';
	if(ia>ib){
    			cout << "GREATER" << endl;
    			p=false;
    			break;
		}
		else if(ia<ib){
    			cout << "LESS" << endl;
    			p=false;
    			break;
		}
	}
	if(p){
		cout << "EQUAL" << endl;
	}
  }
  else if(a.length()>b.length())
    cout << "GREATER" << endl;
  else if(a.length()<b.length())
    cout << "LESS" << endl;
	return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var nq=arr[0].split(" ").map(Number);
var s = arr[1];
var a=[0,0];
var cnt=0;
for(var i=1;i<s.length;i++){
   if(s[i]=="C" && s[i-1]=="A")cnt++;
   a.push(cnt);
}
var ans=[];
var i = 2;
var len = nq[1]+2;
while(i < len) {
   var lr=arr[i].split(" ");
   ans.push(a[lr[1]-0]-a[lr[0]-0]);
   i++;
}
console.log(ans.join("\n"));

Measured memory_bytes: 34640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

typedef vector<int> vi;

int n, k;
int dp[2000];
vi v[10], sum[10];

int main() {
	cin >> n >> k;
	REP(i, n) {
		int a, b;
		scanf("%d %d", &a, &b);
		v[b - 1].push_back(a);
	}

	REP(i, 10)
		sort(v[i].begin(), v[i].end(), greater<int>());
	REP(i, 10) {
		sum[i].push_back(0);
		REP(j, v[i].size()) {
			sum[i].push_back(sum[i][j] + v[i][j] + j * 2);
		}
	}

	REP(i, 10) {
		for (int j = k; j >= 0; j--) {
			FOR(l, 1, sum[i].size()) {
				if (j - l < 0) continue;
				dp[j] = max(dp[j], dp[j - l] + sum[i][l]);
			}
		}
	}
	
	cout << dp[k] << endl;
	return 0;
}

Measured memory_bytes: 1304
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    double R;
    double lpi = 3.141592653589793238462643383279;

    //input
    cin >> R;

    cout << 2 * R * lpi << endl;

    return 0;
}


Measured memory_bytes: 3780
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val _A, B = sc.nextLong()
    val A = _A - 1
    val POW = (0 until 40) map { i =>
      Math.pow(2, i).toLong
    }
    val R = new Array[Long](40)
    val N = Vector.fill(40)(0)

    var i = 0
    while (i < 40) {
      val NN = java.lang.Long.parseLong(N.updated(40 - i - 1, 1).mkString(""), 2)
      val a =
        if (A >= NN)
          ((A + 1) / POW(i) / 2 * POW(i)) + Math.max(((A + 1) % (2 * POW(i))) - POW(i), 0)
        else 0
      val b =
        if (B >= NN)
          ((B + 1) / POW(i) / 2 * POW(i)) + Math.max(((B + 1) % (2 * POW(i))) - POW(i), 0)
        else 0
      R(40 - i - 1) = (b - a) % 2L
      i += 1
    }
    println(java.lang.Long.parseLong(R.mkString(""), 2))
  }

}

Measured memory_bytes: 27320
N,M = map(int, input().split())
l=[]
g=0
for i in range(M):
    l.append(list(map(int, input().split())))
for i in range(10**N):
    f=0
    s=str(i)
    if len(s)==N:
        for j in range(M):
            if int(s[l[j][0]-1])!=l[j][1]:
                f+=1
                break
        if f==0:
            g+=1
            print(i)
            break

if g!=1:
    print(-1)

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

using namespace std;

int N;
vector<vector<int>> G;
const int MN = 100000;
int depth[MN];
int sz[MN];
int par[MN];

void dfs(int v, int p = -1) {
  par[v] = p;
  sz[v] = 1;
  for (auto u:G[v]) {
    if (u != p) {
      depth[u] = depth[v] + 1;
      dfs(u, v);
      sz[v] += sz[u];
    }
  }
}
      

int main () {
  cin >> N;
  G.resize(N);
  for (int i = 0; i < N-1; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 0; i < N; i++) depth[i] = 0;
  dfs(0);
  int D = depth[N-1];
  int up = (D-1) / 2;
  int v = N-1;
  for (int i = 0; i < up; i++) {
    v = par[v];
  }
  int B = sz[v];
  int A = N - sz[v];
  if (A <= B) cout << "Snuke" << endl;
  else cout << "Fennec" << endl;
  return 0;
}
  


Measured memory_bytes: 13184