akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

namespace IO {
    template <typename _T>
    inline bool read (_T& x) {
        x = 0;
        _T y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return false;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return true;
    }

    template <typename _T>
    inline _T input () {
        _T x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return x;
    }
};
using namespace IO;

#define reg register
#define MAX_N 200007
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define lep(i, l, r) for(int i = l; i < r; ++i)
#define irep(i, r, l) for(int i = r; i >= l; --i)
#define ilep(i, r, l) for(int i = r; i > l; --i)
typedef long long ll;

int N;
int head[MAX_N], to[MAX_N << 1], nxt[MAX_N << 1], cap;
int val[MAX_N];
int fa[MAX_N];

inline void addE (int u, int v) {
    nxt[++cap] = head[u];
    head[u] = cap;
    to[cap] = v;
}

int tmp[MAX_N], top;
void dfs (int x) {
    val[x] = 0;
    for (int i = head[x]; i; i = nxt[i]) 
        dfs(to[i]);
    top = 0;
    for (int i = head[x]; i; i = nxt[i]) tmp[++top] = val[to[i]];
    std::sort(tmp + 1, tmp + top + 1);
    int s = 1;
    irep (i, top, 1) {
        val[x] = std::max(val[x], tmp[i] + s);
        s++;
    }
}

int main () {
#ifdef LOCAL
    FIN("in");
#endif
    read(N);
    rep (i, 2, N) {
        read(fa[i]);
        addE(fa[i], i);
    }
    dfs(1);
    printf("%d\n", val[1]);
    return 0;
}

Measured memory_bytes: 8320
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
ans=0
if(N>K):
    ans=min(N%K,K-(N%K))
else:
    ans=min(N,K-N)

print(ans)

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

void Constraints(int H,int W)
{
  if(!(3<=H&&H<=300&&3<=W&&W<=300))
  {
    printf("条件を満たす入力をしてください。\n");
    exit(0);
  }
}

void PrintFrame(int H,int W)
{
  for(int i=0;i<H;i++)
  {
      for(int j=0;j<W;j++)
      {
        if(i==0||i==H-1){
          printf("#");
        }
        else{
          if(j==0||j==W-1) {
            printf("#");
          }else{
            printf(".");
          }
        }
      }
      printf("\n");
  }
  printf("\n");
}

int main(void)
{
  int H=1;
  int W=1;
  while(H!=0&&W!=0)
  {
    scanf("%d %d",&H,&W);
    if(H!=0&&W!=0)
    {
      Constraints(H,W);
      PrintFrame(H,W);
    }
  }
  return 0;
}



Measured memory_bytes: 1980
N=int(input())
dp=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  a=str(i)
  dp[int(a[0])][int(a[-1])]+=1
ans=0
for i in range(10):
  for j in range(10):
    ans+=dp[i][j]*dp[j][i]
print(ans)

Measured memory_bytes: 9116
A,B=list(map(int,input().strip().split()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def prime_decomposition(n):
  i = 2
  c = 0
  while i * i <= n:
      flag=0
      while n % i == 0:
          n /= i
          if flag==0:
              c+=1
              flag=1
      i += 1
  if n > 1:
    c+=1
  return c

GCD=gcd(A,B)
print(prime_decomposition(GCD)+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=211005;
const int NN=20005;
const ll md=998244353;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    str s;
    cin >> s;
    int a[N]={0};
    int n=s.sz();
    for (int i=1;i<=n;i++){
        a[i]=s[i-1]-'0';
    }
    ll kl[N]={0};
    kl[0]=1;
    ll ans=0;
    ll c=2019;
    ll s10[N]={0};
    s10[n]=1;
    for (int i=n-1;i>=1;i--){
        s10[i]=s10[i+1]*10;
        s10[i]%=2019;
    }
    for (int i=n;i>=1;i--){
        s10[i]*=a[i];
        s10[i]%=2019;
        c+=s10[i];
        c%=2019;
        ans+=kl[c];
        //if (kl[c]>0)cout << i << E;
        kl[c]++;

        //cout << i << " " << c << E;
    }
    cout << ans << E;
    r0;
}
/*


1
5
2 3 4 5 1


1
4
4 2 3 1








*/


Measured memory_bytes: 7848
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb emplace_back
typedef pair<int,int> pi;

int h, w, ans, dist[1005][1005], dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
char grid[1005][1005];
queue<pi> q;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cin >> h >> w;
	memset(dist, -1, sizeof dist);
	for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) {
		cin >> grid[i][j];
		if (grid[i][j] == '#') {
			q.emplace(i, j);
			dist[i][j] = 0;
		}
	}
	while (q.size()) {
		int x = q.front().first, y = q.front().second;
		q.pop();
		// cout << x << ' ' << y << '\n';
		for (int i = 0; i < 4; ++i) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
			if (dist[nx][ny] != -1) continue;
			dist[nx][ny] = dist[x][y] + 1;
			q.emplace(nx, ny);
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (grid[i][j] == '.') ans = max(ans, dist[i][j]);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 16368
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forab(i, a, b) for(int i=(int)a; i<(int)b; ++i)

const int inf = (int)1e6+5;
const int nax = (int)3e5+5;

void compute(){
    int a[5], k;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
    forn(i, 5){
        forn(j, 5)
        if(abs(a[i] - a[j]) > k){
            cout<<":(\n";
            return;
        }
    }
    cout<<"Yay!\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    //    int t;
    //    cin>>t;
    //    while(t--)
    compute();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
money = [input().rstrip().split() for _ in range(N)]
total = 0
JPY = [int(money[i][0]) for i in range(N) if money[i][1] == 'JPY']
BTC = [float(money[i][0])*380000.0 for i in range(N) if money[i][1] == 'BTC']

print(sum(JPY)+sum(BTC))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x ;
        n = n / 2;
        x = x * x;
    }
    return result;
}
int main() {
    fio
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++) cin>>a[i];
   int c=0;
for(int i=0;i<n;i++){
    if((i+1)%2!=0 and a[i]%2!=0)
        c++;
}
cout<<c<<endl;
   return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int a[10000], b[10000],i;
    char c[10000];
    i = 1;
    while (1) {
        cin >> a[i] >> c[i] >> b[i];
        if (c[i] == '?' ) { break; }
        else if (c[i] == '+') { printf("%d\n", a[i] + b[i]); }
        else if (c[i] == '-') { printf("%d\n", a[i] - b[i]); }
        else if (c[i] == '*') { printf("%d\n", a[i] * b[i]); }
        else if (c[i] == '/') { printf("%d\n", a[i] / b[i]); }
      
        i++;
    }
    return 0;
}


Measured memory_bytes: 3244
import math
a,b=map(int,input().split())
gcd=math.gcd(a,b)

def prime_factorization(n):
  i=2
  prime=[]
  if n%i==0:
    n//=i
    prime.append(2)
    while n%i==0:
      n//=i
  i+=1
  k=int(n**0.5)+1
  for j in range(i,k+1,2):
    if n%j==0:
      n//=j
      prime.append(j)
      while n%j==0:
        n//=j
  if n>1:
    prime.append(n)
  return prime

print(len(prime_factorization(gcd))+1)

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


// combination ----------------------------------------------------------------
const ll M = 998244353;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){
  //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
  ll ans = 1;
  while(n != 0){
	if(n&1) ans = ans*x % M;
	x = x*x % M;
	n = n >> 1;
  }
  return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
  if(a == 0 && b == 0)return 1;
  if(a < b || a < 0)return 0;
  ll tmp = ifac[a-b]* ifac[b] % M;
  return tmp * fac[a] % M;
}


int main()
{
  fac[0] = 1;
  ifac[0] = 1;
  for(ll i = 0; i<300000; i++){
	fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
	ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
  }
  
  ll n, m, k, ans=0, c=1;
  cin >> n >> m >> k;
  c = m;
  if (k == n-1)
	ans += c;
  forll(i, 1, n){
	c *= (m-1);
	c %= 998244353;
	if (k >= n-1-i){
	  ans += c * (comb(n-1, i) % 998244353);
	  ans = ans % 998244353;
	}
  }
  cout << ans << endl;
}


Measured memory_bytes: 7832
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll mpow(ll x,ll n){
    if(n==0) return 1;
    else if(n%2) return x*mpow(x,n-1)%MOD;
    return mpow(x*x%MOD,n/2)%MOD;
}

ll mfrac(ll n){
    if(n==0) return 1;
    else return n*mfrac(n-1)%MOD;
}

ll mperm(ll n,ll r){
    ll res=1;
    for(ll i=0;i<r;i++) res=res*(n-i)%MOD;
    return res;
}

ll mcomb(ll n,ll r){
    if(r>n-r) r=n-r;
    ll res=mperm(n,r);
    return res*mpow(mfrac(r),MOD-2)%MOD;
}

ll S;

int main(){
    cin>>S;

    ll ans=0;
    repn(i,S/3){
        ll a=S-(i*3);
        ans+=mcomb((i-1)+a,i-1);
        ans%=MOD;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3584
n = int(input())
t, a = list(map(int,input().split()))
H = list(map(int,input().split()))
best = 1000000000
bestid = -10
for i in range(n):
  if abs(a-(t-H[i]*0.006)) < best:
    best = abs(a-(t-H[i]*0.006))
    bestid = i+1
print(bestid)

Measured memory_bytes: 3060
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
  
int main(){
	vector<pair<int,pair<int,int>>> vx,vy;
	int i=0,r=0,n,x1,y1,x2,y2;
	for(scanf("%d",&n);i<n;i++){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(x1>x2)swap(x1,x2);
		if(y1>y2)swap(y1,y2);
		if(x1==x2)vy.emplace_back(make_pair(x1,make_pair(y1,y2)));
		else vx.emplace_back(make_pair(y1,make_pair(x1,x2)));
	}
	//sort(vx.begin(),vx.end());
	sort(vy.begin(),vy.end());
	for(auto &e:vx){
		auto it1=lower_bound(vy.begin(),vy.end(),make_pair(e.second.first,make_pair(-2000000000,-2000000000)));
		auto it2=lower_bound(vy.begin(),vy.end(),make_pair(e.second.second+1,make_pair(-2000000000,-2000000000)));
		
		for(;it1!=it2;++it1){
			auto &f=*it1;
			if(f.second.first<=e.first&&e.first<=f.second.second)r++;
		}
	}
	printf("%d\n",r);
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int h, w;
  cin >> h >> w;
  int c[10][10];
  int a[h][w];
  rep(i, 10) rep(j, 10) cin >> c[i][j];
  rep(i, h) rep(j, w) cin >> a[i][j];
  int ans = 0;

  for (int k = 0; k < 10; ++k) {
    for (int i = 0; i < 10; ++i) {
      for (int j = 0; j < 10; ++j) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }

  // rep(i, 10) {
  //   rep(j, 10) cout << c[i][j] << " ";
  //   cout << endl;
  // }

  rep(i, h) {
    rep(j, w) {
      if (a[i][j] == -1) continue;
      ans += c[a[i][j]][1];
    }
  }

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


Measured memory_bytes: 384
import           Data.List
import qualified Data.Vector.Unboxed as V
getIntList = map read . words <$> getLine
main = do
  [n,k] <- getIntList
  p <- V.fromList . map pred <$> getIntList
  c <- V.fromList <$> getIntList
  let cp = V.fromList [c V.! (p V.! i) | i <- [0..n-1]]
      acc i = tail . scanl' (+) 0 $ map (cp V.!) $ takeWhile (/=i) (iterate (p V.!) (p V.! i)) ++ [i]
      ans i =
        if val > 0
          then
            if rem /= 0
              then num * val + maximum (take rem list)
              else (num-1) * val + maximum list
          else maximum list
        where list = acc i
              val = last list
              len = length list
              (num,rem) = k `divMod` len
  (print . maximum . map ans) [0..n-1]

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>


using namespace std;
typedef long long ll;
ll N;

int main(){

    string A, B, C;

    cin >> A >> B >> C;

    if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]){
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
    return 0;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint n,k;
    cin>>n>>k;
    if((n+1)/2>=k){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define il inline
#define ri register
#define ll long long
#define Size 200050
using namespace std;
struct point{
	int next,to,w;
}ar[Size];
int head[Size],art,a[Size],
	fa[Size],in[Size],a1[Size],a1t,
	out[Size],sum;
il bool dfs(int);
il void read(int&),link(int,int,int);
int main(){
	//sfreopen("in","r",stdin);
	ll ans(0);int n,m;read(n),read(m);
	for(int i(1),u,v;i<=m;++i)
		read(u),read(v),link(u,v,1),
			link(v,u,2),++in[v],++out[u];
	memset(a,-1,sizeof(a));
	for(int i(1),j;i<=n;++i){
		if(~a[i])continue;
		a1t=sum=a[i]=0;
		bool pd(dfs(i)),pd1(false);
		for(j=1;j<=a1t;++j)
			if(in[a1[j]]&&out[a1[j]])
			{pd1=true;break;}sum>>=1;
		if(pd1){
			if(pd)ans+=(ll)a1t*a1t;
			else{
				int a2[3]{};for(j=1;j<=a1t;++j)++a2[a[a1[j]]];
				ans+=(ll)a2[0]*a2[1]+(ll)a2[1]*a2[2]+(ll)a2[2]*a2[0];
			}
		}else ans+=sum;
	}return printf("%lld",ans),0;
}
il bool dfs(int x){
	a1[++a1t]=x;bool pd(false);
	for(int i(head[x]),i1;i;i=ar[i].next)
		if(++sum,!~a[i1=ar[i].to]){
			a[i1]=(a[x]+ar[i].w)%3;
			pd|=dfs(i1);
		}else if(a[i1]^(a[x]+ar[i].w)%3)pd|=1;
	return pd;
}
il void link(int u,int v,int w){
	ar[++art]={head[u],v,w},head[u]=art;
}
il void read(int&x){
	x^=x;ri char c;while(c=getchar(),c<'0'||c>'9');
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}


Measured memory_bytes: 8448
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, a, b] <- getIntList
  let x = n `div` (a+b)
      y = n `mod` (a+b)
      ans = a*x + min a y
  print ans

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    int n, p;cin >> n >> p;
    vector<pair<LL,P>> v(n);
    LL aa = 0, bb = 0;
    for (int i = 0; i < n; i++) {
        LL w,b;cin >> w >> b;
        v[i] = mp(100 * w + p * (b - w), mp(w,b));
        bb += b;
    }
    sort(RALL(v));
    for (int i = 0; i < n; i++) {
        aa += v[i].sc.fs;
        bb -= v[i].sc.sc;
        if(100 * aa / (aa + bb) >= p){
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N,L;
  cin >> N >> L;
  
  vector<string> S(N);
  for(int i=0; i<N;i++){
    cin >> S[i];
  }
  
  sort(S.begin(), S.end());
  
  string s;
  for(int i=0; i<N;i++){
    s+=S[i];
  }
  
  cout << s << endl;
   
}

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

using edge = struct{int to;int depth;};
vector<edge> tree[100010];
int depth[100010];

void dfs(int now,int parent,int now_depth){
	depth[now]=now_depth;
	for(auto &e : tree[now]){
		if(e.to == parent)continue;
		dfs(e.to,now,now_depth+1);
	}
}

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

	int fromWhite[100010]={0},fromBlack[100010]={0};
	int whiteTotal=0,blackTotal=0;
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin >> a >> b;
		tree[a].push_back({b,0});
		tree[b].push_back({a,0});
	}
	dfs(1,0,0);
	for(int i=1;i<=N;i++){
		fromBlack[i]=depth[i];
	}
	dfs(N,N+1,0);
	for(int i=1;i<=N;i++){
		fromWhite[i]=depth[i];
	}
	
	for(int i=1;i<=N;i++){
		if(fromBlack[i]<=fromWhite[i]){
			blackTotal++;
		}else{
			whiteTotal++;
		}
	}
	
	if(blackTotal>whiteTotal){
		cout << "Fennec" << endl;
	}else{
		cout << "Snuke" << endl;
	}
	
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	ll A = 1;
	ll B = 1;
	F0R(i, N) {
		ll a, b; cin >> a >> b;
		ll lo = 1;
		ll hi = (1e18+max(a,b)-1)/(max(a,b));
		while (lo < hi) {
			ll mid = lo + (hi - lo) / 2;
			if (a * mid >= A && b * mid >= B) {
				hi = mid;
			} else {
				lo = mid + 1;
			}
		}
		A = a * lo;
		B = b * lo;
	}
	print(A+B);
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<bool> c(1000000001,0);
  rep(i,n){
    int x;
    cin >> x;
    c[x] = !c[x];
  }
  int ans = 0;
  rep1(i,1000000000){
    ans += c[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 122368
#include <stdio.h>
 
int main(void){
    char str[1];
    scanf("%s", str);//文字列取得
  
  if(str[0] == 'A'){
    printf("T");
  }
  else if(str[0] == 'T'){
    printf("A");
  }
  else if(str[0] == 'C'){
    printf("G");
  }
 else if(str[0] == 'G'){
    printf("C");
  }
  
    return 0;
}

Measured memory_bytes: 128
import numpy as np
n = int(input())
a,b = map(int, input().split())
p = np.array([int(i) for i in input().split()])
x1 = len(p[p <= a])
x2 = len(p[(a+1 <= p) & (p <= b)])
x3 = len(p[p>= b+1])
print(min(x1,x2,x3))

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

int main()
{
  int num;
  int A, B, C, D;

  cin >> num;

  D = num % 10;
  num /= 10;
  C = num % 10;
  num /= 10;
  B = num % 10;
  num /= 10;
  A = num;

  for (int i = 0; i < (1 << 3); i++)
  {
    int sum = A;
    char op1, op2, op3;
    bitset<3> op(i);

    if (op.test(0))
    {
      sum += B;
      op1 = '+';
    }

    else
    {
      sum -= B;
      op1 = '-';
    }

    if (op.test(1))
    {
      sum += C;
      op2 = '+';
    }

    else
    {
      sum -= C;
      op2 = '-';
    }

    if (op.test(2))
    {
      sum += D;
      op3 = '+';
    }

    else
    {
      sum -= D;
      op3 = '-';
    }

    if (sum == 7)
    {
      cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
      break;
    }
  }
}


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

const long long MOD = 1e9 + 7;

long long n, k, dp[MAXN];

long long power(long long x, unsigned long long y)  
{  
    long long res = 1; 
    x = x % MOD;
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % MOD;
        y = y>>1;  
        x = (x*x) % MOD;  
    }  
    return res;  
}  

int main() {
	cin >> n >> k;
	for (long long i=k; i>0; i--) {
		dp[i] = power(k/i, n);
		long long temp = 2*i;
		while (temp <= k) {
			dp[i] -= dp[temp];
			dp[i] = (dp[i] + MOD) % MOD;
			temp += i;
		}
	}
	long long ans = 0;
	for (long long i=1; i<=k; i++) {
		// cout << dp[i] << " ";
		ans += i * dp[i];
		ans %= MOD;
	}
	// cout << "\n";
	cout << ans;
}

Measured memory_bytes: 4340
H, W = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
yoko = set(A)
tate = set(B)
MOD = 10 ** 9 + 7

# 縦棒、横棒
numTate = 0
numYoko = 0
# 大きい方から見て行って、ありえる個数をかけていく
# 両方出てる: 1通り。(両方＋1する)
# 片方が隠れる: 隠れてる方の本数。(出てる方の本数を＋1する)
# 完全に隠れる: tate * yoko - n
ans = 1
num = 0
for n in range(1, H*W+1)[::-1]:
  t = n in tate
  y = n in yoko
  if t and y:
    numTate += 1
    numYoko += 1
  elif t and not y:
    ans *= numYoko
    numTate += 1
  elif not t and y:
    ans *= numTate
    numYoko += 1
  else:
    ans *= numTate * numYoko - num
  ans %= MOD
  num += 1
  if ans == 0:
    break

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define mp make_pair
#define pp pop_back
#define pi 3.141592653589793238
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
bool sortbysec(const pair<int,int> &a,
             const pair<int,int> &b)
{
   return (a.second < b.second);
}
bool sortinrev(const pair<int,int> &a,  
              const pair<int,int> &b)
{
      return (a.first > b.first);
}
int ispal(string s)
{
    int x=s.length();
    for(int i=0,j=x-1;i<x/2,j>=x-x/2;i++,j--)
        if(s[i]!=s[j])
            return 0;
    return 1;
}
void solve()
{
     int n,m;
     cin>>n>>m;
     int arr[m];
     int total=0;
     rep(i,0,m)
     {
     	cin>>arr[i];
     	total+=arr[i];
     }
     n-=total;
     if(n<0)
     	cout<<-1;
     else
     	cout<<n;
}    
signed main()
{
                   // #ifndef ONLINE_JUDGE
                   // freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
                   // #endif 
  int t=1;
 //cin>>t;
  while(t--){
  solve();
  cout<<"\n";
}
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
 return 0;
}  

Measured memory_bytes: 3856
'use strict'

main()

function main (input) {
  readInput()
  .then(parseInput)
  .then(calc)
}

function calc (input) {
  let a = input[0]
  let b = input[1]
  let c = input[2]
  let ok = false
  for (let n = 1; n <= b; n++) {
    if ((n * a) % b === c) {
      ok = true
    }
  }
  let answer = ok ? 'YES' : 'NO'
  console.log(answer)
}

function parseInput (inputRaw) {
  let input = inputRaw.split(' ').map(Number)
  return input
}

function readInput () {
  return new Promise((resolve) => {
    let inputArr = []
    process.stdin.resume()
    process.stdin.setEncoding('utf8')
    process.stdin.on('data', (chunk) => {
      inputArr.push(chunk)
    })
    process.stdin.on('end', () => {
      let input = inputArr.join('').trim()
      resolve(input)
    })
  })
}


Measured memory_bytes: 21448
#include<stdio.h>
#include<math.h>
int main()
{
    long long int a, b, i, p, q, count = 0;
    scanf("%lld%lld", &a, &b);
    for (i=0; i<a; i++){
        scanf("%lld%lld", &p, &q);
        if ((double)(sqrt(pow(p,2)+pow(q,2))) <= b) count ++;
    }
    printf("%lld\n", count);
    return 0;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;

vector<i64> a;

int main(){
  cin >> N;
  a.resize(N * 3);
  for(auto & x : a) cin >> x;
  vector<i64> A(N * 3 + 1,0);
  vector<i64> B(N * 3 + 1,0);

  {
    priority_queue<i64,vector<i64>,greater<i64>> que;
    i64 sum = 0;
    rep(i,0,3 * N - 1){
      que.push(a[i]);
      sum += a[i];
      if(i >= N){
        sum -= que.top();
        que.pop();
      }
      A[i] = sum;
    }
  }
  {
    priority_queue<i64> que;
    i64 sum = 0;
    for(int i = 3 * N - 1;i >= 0;i--)
    {
      que.push(a[i]);
      sum += a[i];
      if(i < 2 * N){
        sum -= que.top();
        que.pop();
      }
      B[i] = sum;
    }
  }

  i64 ans = A[N - 1] - B[N];
  for(int i = N - 1;i < N * 2;i++){
    ans = max(ans,A[i] - B[i + 1]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 9068
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int colornum[9];
const int colorrate[9]={399,799,1199,1599,1999,2399,2799,3199,4800};

int a,N;
int main(){
    cin>>N;
    REP(i,N){
        cin>>a;
        for(int j=0;j<9;j++){
            if(a<=colorrate[j]){
                colornum[j]++;
                break;
            }    
        }
    }
    // cout<<"H C Md Mi A K D A R"<<endl;
    // REP(i,9){
    //     cout<<colornum[i]<<" ";
    // }
    // cout<<endl;
    int sum=0;
    int sum_min=0;
    for(int i=0;i<8;i++){
        if(colornum[i]!=0){
            sum++;
        }
    }
    sum_min=sum;
    //色を自由に選べる
    if(sum==0&&colornum[8]!=0){
        sum_min=1;
    }
    if(colornum[8]!=0){
        for(int j=0;j<colornum[8];j++){
            sum++;
            // if(sum<8){
            //     sum++;
            // }
            // else{
            //     break;
            // }
        }
    }
    cout<<sum_min<<" "<<sum<<endl;
}

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

int main(){

	string str, str1, str2;
	int m;

	while(cin >> str){
		if(str == "-") break;
		cin >> m;
		int h;

		for(int i=0; i<m; i++){
			cin >> h;
			str1 = str.substr(0,h);
			str2 = str.substr(h);
			str = str2 + str1;
		}

		cout << str << endl;

	}
}

Measured memory_bytes: 1216
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    n = int(input())
    a = list(map(int, input().split()))
    aaa=1
    a_sum=0
    for index in range(len(a)):
        aaa = aaa * a[index]
        a_sum = a_sum + a[index]

    a_numerator = 0
    for index in range(len(a)):
        a_fac = aaa // a[index]
        a_numerator += a_fac
        
        
            
    print(aaa / a_numerator)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 66540
import math

a, b, h, m = map(int, input().split())

bb = math.pi * m / 30.
aa = math.pi * (h+m/60.) / 6.
print(math.sqrt((b*math.sin(bb)-a*math.sin(aa))
                ** 2 + (b*math.cos(bb)-a*math.cos(aa))**2))


Measured memory_bytes: 9372
import math
import itertools

N = int(input())
A = [int(x) for x in input().split(' ')]

M = []
M.append(sum([A[i] if i % 2 == 0 else -A[i] for i in range(N)]))
for i in range(1, N):
    M.append(2*A[i-1]-M[i-1])

print(' '.join([str(m) for m in M]))


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

#define rep(i, n)     for(int i = 0;      i < int(n); ++i)
#define rep3(i, a, b) for(int i = int(a); i < int(b); ++i)
#define all(x)        (x).begin(),(x).end()
#define sz(x)         int(x.size())
#define mp            make_pair
#define pb            push_back


typedef long long ll;

using namespace std;

int main(){
  string s;
  ll k;
  cin >> s;
  cin >> k;

  const ll days = 5000 * 1000000000000;
  ll pos = 0;

  rep(i, sz(s)){
    if(s[i] == '1'){
      pos++;
      if(k <= pos){
        cout << s[i] << endl;
        break;
      }
    }else{
      cout << s[i] << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long lint;
using namespace std;
 
int main(){
	int h,n;
	cin>>h>>n;
	vector<int> a(n);
	rep(i,n) cin>>a.at(i);
	rep(i,n){
		h-=a.at(i);
	}
	cout<<((h<=0)?"Yes":"No")<<endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  double t, x;
  cin >> t >> x;
  cout << t / x << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	inputs := strings.Split(sc.Text(), " ")

	var a []int
	for _, input := range inputs {
		n, _ := strconv.Atoi(input)
		a = append(a, n)
	}

	ans := []int{
		a[0] * a[2],
		a[0] * a[3],
		a[1] * a[2],
		a[1] * a[3],
	}

	sort.Ints(ans)
	fmt.Println(ans[3])
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef STOP_DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false; }
template <typename T> bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false; }

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;

int main() {
  lint k, a, b;
  cin >> k >> a >> b;
  bool change = (a < b && b - a > 1);
  lint biscuit = 1;
  lint ans = 1;
  for (;0 <= k; --k) {
    chmax(ans, biscuit);
    if (change && biscuit >= a && k > 1) {
      biscuit += b - a;
      --k;
      continue;
    }
    ++biscuit;
  }
  cout << ans << '\n';
}


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

namespace ABC_C
{
    class C060
    {
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            int N = int.Parse(s1[0]);
            int T = int.Parse(s1[1]);
            string[] t = Console.ReadLine().Split(' ');

            long sum = 0;
            for(int i = 1; i < t.Length; i++)
            {
                sum += Math.Min(int.Parse(t[i]) - int.Parse(t[i - 1]), T);
            }
            sum += T;
            Console.WriteLine(sum);
        }
    }
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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




//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x / tmp) * y;
}


struct Combination {

	vector<ll> fact, rfact;

	Combination(ll sz) : fact(sz + 1), rfact(sz + 1) {

		fact[0] = 1;
		for (ll i = 1; i < fact.size(); i++) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		//逆元
		rfact[sz] = inv(fact[sz]);
		for (ll i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % MOD;
		}
	}

	ll inv(ll x) {
		return pow(x, MOD - 2);
	}
	ll pow(ll x, ll n) {
		ll ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return (ret);
	}
	ll P(ll n, ll r) {
		if (r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % MOD);
	}

	ll C(ll p, ll q) {
		if (q < 0 || p < q) return (0);
		return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD);
	}

	ll H(ll n, ll r) {
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};


/******************************************************************************************/



int main() {

	ll n;
	cin >> n;
	vector<ll> a(n);

	ll sum = 0;
	ll cnt = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
		if (i % 2)cnt += a[i];
	}

	vector<ll> ans(n);
	ans[0] = sum - 2 * cnt;

	for (int i = 1; i < n; i++)
	{
		ans[i] = 2 * a[i-1] - ans[i - 1];
	}

	for (int i = 0; i < n; i++)
	{
		if (i == 0) {
			cout << ans[i];
		}
		else
		{
			cout << " " << ans[i];
		}
	}
	cout << endl;




	return 0;
}


Measured memory_bytes: 2944
import math
from functools import reduce
import itertools
import numpy as np

K = int(input())



ans = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        for k in range(j, K + 1):
            if i == j and j == k:
                dup_num = 1
            elif i == j or j == k:
                dup_num = 3
            else:
                dup_num = 6
            ans += math.gcd(math.gcd(i, j), k) * dup_num

print(ans)


Measured memory_bytes: 27040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int d;
	cin >> d;
	cout << "Christmas";
	rep(_, 25 % d)
		cout << " Eve";
	cout << endl;
}

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

	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    ll x; cin >> x;
    ll a = 100;
    ll cnt=0;
    while(a<x){
        a = a * 1.01;
        cnt++;
    }
    cout << cnt << endl;

}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ b.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
コード変えたらコンパイルする
不正解ならWAが出る
*/

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

long long min(long long x, long long y){
    if(x > y){
        return y;
    }else{
        return x;
    }
}

int main(void){

    int N, K;

    scanf("%d%d", &N, &K);

    long long x[N], y[N];
    long long xa[N], ya[N];

    for(int i = 0; i < N; i++){
        scanf("%lld%lld", &x[i], &y[i]);
        xa[i] = x[i], ya[i] = y[i];
    }

    mergeSort(xa, 0, N);
    mergeSort(ya, 0, N);

    long long ans = (xa[N-1] - xa[0]) * (ya[N-1] - ya[0]);

    for(int xi = 0; xi < N; xi++){
        for(int xj = xi+1; xj < N; xj++){
            for(int yi = 0; yi < N; yi++){
                for(int yj = yi+1; yj < N; yj++){
                    int num = 0;

                    long long lx = xa[xi], rx = xa[xj];
                    long long by = ya[yi], uy = ya[yj];

                    for(int i = 0; i < N; i++){
                        if(lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy){
                            num++;
                        }
                    }
                    if(num >= K){
                        ans = min(ans, (rx-lx) * (uy-by));
                    }
                }
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1700
#include<cstdio>

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000003;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
		int res = 1, mu = base%mod;
		for(;p>0;p/=2) {
			if (p&1) res = mul(res, mu);
			mu = mul(mu, mu);
		}
		return res;
	}
	int rev(int x) {return pw(x, mod-2);}
};
modular_arithmetic ma;

int v[1001001];

int main() {
	v[0] = v[1] = 1;
	for(int i=2;i<ma.mod;i++)
		v[i] = ma.mul(v[i-1], i);
	
	int T;
	for(scanf("%d", &T);T--;) {
		int x, d, n;
		scanf("%d%d%d", &x, &d, &n);
		x%=ma.mod;
		d%=ma.mod;
		if(d==0) {
			printf("%d\n", ma.pw(x, n));
			continue;
		}
		
		int xd = ma.mul(x, ma.rev(d));
		if (xd+n-1>=ma.mod) {
			puts("0");
			continue;
		}
		
		int ans = ma.pw(d, n);
		int l = xd, r = xd+n-1;
		ans = ma.mul(ans, v[r]);
		if(l>1) ans = ma.mul(ans, ma.rev(v[l-1]));
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 4736