akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;
using VI = vector<int>;

int main() {
    VI v;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 1; i < 3; i++) {
        ans += v[i] - v[i - 1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

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

    int a[60], b[60];

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

    int res[60] = {0};

    for(int i = 0; i < M; i++){
        res[a[i]]++;
        res[b[i]]++;
    }

    for(int i = 1; i <= N; i++){
        cout << res[i] << endl;
    }

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,a,i,j=1,d[10]={};
  scanf("%d %d",&m,&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    d[a]=1;
  }
  for(i=m;j;i++){
    for(j=i;j;j/=10){
      if(d[j%10])break;
    }
  }
  printf("%d\n",i-1);      
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
void shellsort(int a[], int l, int r);

int main(void)
{
  int n, k;
  int arr[200500] = {0};

  scanf("%d %d", &n, &k);

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

  int x = 0;
  for (int i = 0; i <= n; i++) {
    if (arr[i] > 0) {
      count[x] = arr[i];
      x++;
    }
  }

  shellsort(count, 0, x-1);
  int ans=0;

  for (int i=0; i < (x-k); i++) {
    ans += count[i];
  }
    printf("%d\n", ans);

    return 0;
}

void shellsort(int a[], int l, int r)
{
  int i, j, h;

  for (h = 1; h <= (r-1)/9; h = 3*h+1)
      ;
      for ( ; h > 0; h /= 3) {
        for (i = l+h; i <= r; i++) {
          j = i;
          int v = a[i];
          while (j >= l+h && v < a[j-h]) {
            a[j] = a[j-h];
            j -= h;
          }
          a[j] = v;
        }
      }
}


Measured memory_bytes: 1792
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
using namespace std;
int main() {
    long long mod = 1000000007;
    long long a1 = 1, a2 = 1, a3 = 1;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) a1 = a1 * 10 % mod, a2 = a2 * 9 % mod, a3 = a3 * 8 % mod;
    a1 = a1 - a2 * 2 + a3;
    a1 %= mod;
    if (a1 < 0) a1 += mod;
    cout << a1 << endl;
    return 0;
}


Measured memory_bytes: 3596
<?php
fscanf(STDIN,'%d%d%d',$A,$B,$X);
$P=$A%$X;
$Q=$B%$X;
$T=($B-$Q-$A+$P)/$X;
if($A==$B){
  if($P==0){
    echo 1;
  }else{
    echo 0;
  }
}else{
  if($P==0){
    echo $T+1;
  }else{
    echo $T;
  }
}
echo "\n";

 ?>


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

int main() {
  int n;
  cin >> n;
  string acl = "ACL";
  string ans = "";
  rep(i,n) {
    ans += acl;
  }
  cout << ans << endl;
  return 0;
}

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



#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}

 
/*CODE START HERE*/
int main() {
  int x_1 , y_1 , x_2 , y_2, x_3 , y_3 , x_4 , y_4;
  cin >> x_1 >> y_1 >> x_2 >> y_2;
 int x_dif = x_2 -x_1;
 int y_dif = y_2 - y_1;
  x_3 = x_2-y_dif;
  x_4 = x_3 - x_dif;
  y_3 = y_2 + x_dif ;
  y_4 = y_3 - y_dif ;
  cout << x_3 <<  ' ' << y_3 << ' ' << x_4 << ' ' << y_4 << endl;
}

Measured memory_bytes: 3556
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();

		Pattern p = Pattern.compile("^[0-9]{"+a+"}-[0-9]{"+b+"}");
		Matcher m = p.matcher(s);
		if (m.find()) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
class Edge {
public:
    ll t;
    ll w;
    Edge() {}
    Edge(ll t, ll w): t(t), w(w) {}
};


int main(void) {
    ll N, K;
    ll a[100001];
    ll i;
    ll s[100001]={};
    ll pos[100001]={};
    cin >> N >> K;
    for(i=1; i<=N; i++) {
        cin >> a[i];
        s[i]=s[i-1]+a[i];
        if(a[i]>0)
            pos[i]=pos[i-1]+a[i];
        else
            pos[i]=pos[i-1];
    }
    ll max=-INF;
    for(i=0; i<=N-K; i++) {
        ll tmp=0;
        if(s[i+K]-s[i]>0) {
            tmp+=s[i+K]-s[i];
        }
        
        tmp+=pos[i];
        tmp+=pos[N]-pos[i+K];
        
        max=max(max, tmp);
    }
    
    prin(max);
}


Measured memory_bytes: 2560
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

H, W = map(int,input().split())
sth, stw = map(int,input().split())
glh, glw = map(int,input().split())
sth, stw = sth-1, stw-1
glh, glw = glh-1, glw-1

INF = -1
Gmap = [list(input()) for _ in range(H)]
seen = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1), (0,-1)}
direc5 = set([])
for i in range(-2,3):
    for j in range(-2,3):
        direc5.add((i, j))
direc5 = direc5 - direc
direc5 = direc5 - {(0,0)}

def bfs(pnxt):
    next_q = deque([])
    for h, w in pnxt:
        next_q.append((h,w))
        seen[h][w] = 0
    nxt = set([])
    while len(next_q)!=0:
        h, w = next_q.popleft()
        if h == glh and w == glw:
            print(ret)
            exit()
        for dh, dw in direc:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF:
                next_q.append((hs, ws))
                seen[hs][ws] = 0
        for dh, dw in direc5:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF and not (hs, ws) in nxt:
                nxt.add((hs, ws))
    return nxt

ret = 0
nxt_st = set([])
nxt_st.add((sth, stw))
while len(nxt_st)>0:
    nxt_st = bfs(nxt_st)
    ret += 1
print(-1)


Measured memory_bytes: 137712
N = gets.to_i
A = gets.split.map(&:to_i)
S = (N * (N + 1)) / 2
K = A.inject(:+) / S

if A.inject(:+) != S * K
  puts 'NO'
  exit
end

D = Array.new(N, 0)

N.times do |i|
  right = (i + 1) % N

  diff = A[right] - A[i]

  D[i] = diff
end

if D.all? { |d| d <= K && (K - d) % N == 0}
  puts 'YES'
else
  puts 'NO'
end


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

int main(void)
{
    int d, t;
    char c;
    double x = 0.0, y = 0.0, r = 0.0;
    while(cin >> d >> c >> t) {
        if (d == 0 && t == 0)
            break;
        y += d * cos(r / 180 * M_PI);
        x += d * sin(r / 180 * M_PI);
        r += t;
    }

    cout << (int)x << endl;
    cout << (int)y << endl;
    return 0;
}






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

int main() {
  int n;
  cin >> n;
  string s[n];
  int p[n];
  vector<string> s_cp(n);
  map<string, vector<int>> sp;
  map<string, int> sp_sum;
  int i, j, k;
  for (i = 0; i < n; i++) {
    cin >> s[i] >> p[i];
    sp[s[i]].push_back(p[i]);
    sp_sum[s[i]]++;
    s_cp[i] = s[i];
  }
  sort(s_cp.begin(), s_cp.end());
  for (i = 0; i < n; i++) {
    sort(sp[s[i]].begin(), sp[s[i]].end(), greater<int>());
  }


  map<int, int> result;

  bool break_flag = false;
  for (i = 0; i < n; i++) {
    break_flag = false;
    for (j = 0; j < s_cp.size(); j++) {
      if (s[i] == s_cp[j]) {
        for (k = 0; k < sp[s[i]].size(); k++) {
          if (p[i] == sp[s[i]][k]) {
            result[j + k] = i + 1;
            break_flag = true;
            break;
          }
        }
        if (break_flag) {
          break;
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    cout << result[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
using namespace std;



int main(){
vector<pair<int,int>> tas;
ll n,tmp1,tmp2;
cin>>n;
for(int i=0;i<n;i++){
cin>>tmp1>>tmp2;
tas.emplace_back(make_pair(tmp2,tmp1));
}

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

int t=0;
for(int i=0;i<n;i++){
t+=tas[i].second;
if(tas[i].first<t){

        printf("No\n");
        return 0;
}
}



printf("Yes\n");

}


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


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

int main(){
	int K,T;
	cin>>K>>T;
	vector<int> v(T);
	int i,j,k;
	for(i=0;i<T;i++) cin>>v[i];
	sort(v.begin(),v.end());
	int s=0;
	for(i=0;i<v.size()-1;i++) s+=v[i];
	if(s>=v.back()-1) cout<<0<<endl;
	else cout<<(v.back()-1-s)<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m;
struct A {
	int a;
	vector<int>v;
};
A a[2000];
int dp[2000][1 << 13];
signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u;
		cin >> a[i].a >> u;
		for (int j = 0; j < u; j++) {
			a[i].v.push_back(read() - 1);
		}
	}
	for (int i = 0; i < 2000; i++) {
		for (int j = 0; j < (1 << 13); j++) {
			dp[i][j] = Inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < (1 << n); j++) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			int k = j;
			for (int z = 0; z < a[i].v.size(); z++) {
				k |= (1 << a[i].v[z]);
			}
			dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + a[i].a);
		}
	}
	if (dp[m][(1 << n) - 1] == Inf) dp[m][(1 << n) - 1] = -1;
	cout << dp[m][(1 << n) - 1] << endl;
}

Measured memory_bytes: 128384
// VU TRUONG AN
#include <bits/stdc++.h>
#define F first
#define S second
#define maxn 200005
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define pi acos(-1)
#define bit(p,x) ((x>>p) & 1)
#define Task "CF"
using namespace std;

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

const int base = 100003;
const long long MM = 1ll * MOD * MOD;

int n,m;
long long k;
long long sA[maxn],sB[maxn];
void Solve(){
    cin >> n >> m >> k;
    for(int i = 1;i <= n;++i){
        int a;
        cin >> a;
        sA[i] = sA[i - 1] + a;
    }
    for(int i = 1;i <= m;++i){
        int b;
        cin >> b;
        sB[i] = sB[i - 1] + b;
    }
    int maxx = 0;
    for(int i = 0;i <= n;++i){
        if(sA[i] > k) break;
        int pos = upper_bound(sB + 1,sB + m + 1,k - sA[i]) - sB - 1;
        maxx = max(pos + i,maxx);
    }
    cout << maxx;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen(Task".inp", "r", stdin);
    freopen(Task".out", "w", stdout);
#endif
    int test = 1;
//    cin >> test;
    while(test--)
        Solve();
}


Measured memory_bytes: 6824
A,B,C,X=[int(input()) for _ in range(4)]
res=0
for a in range(A, -1, -1):
  a_500 = 500 * a
  if a_500 > X:
    continue
  elif a_500 == X:
    res += 1
    continue
  else:
    for b in range(B, -1, -1):
      b_100 = 100 * b
      if a_500 + b_100 > X:
        continue
      elif a_500 + b_100 == X:
        res += 1
      else:
        for c in range(C, -1, -1):
          c_50 = 50 * c
          if a_500 + b_100 + c_50 > X:
            continue
          elif a_500 + b_100 + c_50 == X:
            res += 1
            break
          else:
            break
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 333333,mo=1e9+7;
int res,n,f[N][4][3];char s[N];
//1100
void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	f[0][0][0]=1;
	rep(i,0,n-1)rep(a,0,3)rep(b,0,2)if(f[i][a][b]){
		int xs=f[i][a][b];//printf("%d %d %d:%d\n",i,a,b,f[i][a][b]);
		if(s[i+1]!='1'){//0
			int x=a,y=b+1;if(y==3)y=1;add(f[i+1][x][y],xs);
		}
		if(s[i+1]!='0'){//1
			int x=a,y=b;
			if(y)y--;else x++;x=min(x,3);
			add(f[i+1][x][y],xs);
		}
	}
	rep(i,0,2)add(res,f[n][3][i]);
	add(res,f[n][1][0]);add(res,f[n][2][1]);cout<<res;
	return 0;
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
 
int main() {

 long double angL;
 long double angS;
 long double t,s;
 long double ans;
 long double  A,B,H,M;
 cin>>A>>B>>H>>M;

 angL=(long double)((H*60.0+M)/2.0);
 angS=(long double)(M*6.0);

 s=(long double)(abs(angL-angS));
 t=(long double)((s/180.0)*pi);

 ans=(long double)(A*A+B*B-2.0*A*B*cos(t));

printf("%21.20Lf",sqrt(ans));


}

Measured memory_bytes: 4156
package main

import "fmt"

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return nums
}

func main() {
	nums := scanNums(3)

	if (nums[0] < nums[1] && nums[0] <= nums[2] && nums[2] <= nums[1]) || (nums[0] > nums[1] && nums[1] <= nums[2] && nums[2] <= nums[0]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
N, K = map(int, input().split())
mod = 1000000007


def factorial_2(N: int, M: int) -> int:
    res = 1
    for i in range(2, N+1):
        res *= i
        res %= M
    return res


def nCr(n: int, r: int, mod: int):
    if n == r:
        return 1
    if r > n:
        return 0
    return (factorial_2(n, mod) * pow((factorial_2(n-r, mod) * factorial_2(r, mod)), mod-2, mod)) % mod


for i in range(1, K+1):
    print(nCr(N-K+1, i, mod) * nCr(K-1, i-1, mod) % mod)


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

int main()
{
  int m,d;
  cin >> m >> d;
  int p,q;
  cin >> p >> q;
  if(m==p)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }


/*USE DP & REFER TO DFS.CPP*/

const int mod = 1e9+7;
const int dx[] = { 1,0 };
const int dy[] = { 0,1 };
const int maxn = 1010;
int w,h;
char G[maxn][maxn];
int dp[maxn][maxn];

int dfs(const int i, const int j)
{
    if (i == h-1 && j == w-1)
        return 1;
    int& ans = dp[i][j];
    if (-1 == ans) {
        ans = 0;
        FOR(d,0,2) {
            const int x = i+dx[d];
            const int y = j+dy[d];
            if (0 <= x && x < h && 0 <= y && y < w) {
                if (G[x][y] ==  '.') {
                    ans += dfs(x,y);
                    ans %= mod;
                }
            }
        }
    }
    return ans;
}
    
int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);
    while (cin >> h >> w) {
        memset(dp,-1,sizeof(dp));
        FOR(i,0,h) FOR(j,0,w) {
            cin >> G[i][j];
        }
        cout << dfs(0,0) << endl;
    }
    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

ll pow2(ll a, ll b) {
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

int main() {

    ll n;
    cin >> n;


    vector<ll> koho;

    koho.push_back(1);
    for (int i = 1; i < 10; i++) {
        koho.push_back(pow2(9, i));
    }
    for (int i = 1; i < 10; i++) {
        koho.push_back(pow2(6, i));
    }

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


    vector<ll> dp(n + 1, INF);
    dp[0] = 0;

    for (ll i = 0; i <= n; i++) {
        for (ll j = 0; j < koho.size(); j++) {
            if (dp.size() <= (i + koho[j])) break;
            dp[i + koho[j]] = min(dp[i + koho[j]], dp[i] + 1);
        }
    }

    cout << dp[n] << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair

int main()
{
  ll a;
  cin>>a;
  bool check=true,kk=true;
  ll c[a];
  for(ll i=0;i<a;i++)
  {
    cin>>c[i];
    if(c[i]==0)
    {
      kk=false;
    }
  }
  ll pro=1;
  if(!kk)
  pro=0;
  for(ll i=0;i<a&&kk;i++)
  {
    ll j=pro;
    pro*=c[i];
    if(pro>(ll)1e18)
    {
      check=false;
      break;
    }
    if(pro<c[i]||j>pro)
    {
      check=false;
      break;
    }
  }
  if(check)
  cout<<pro<<endl;
  else
  cout<<-1<<endl;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

using namespace std;

#define fi first
#define se second

int x[10], y[10];

long double dist (int i, int j) {
    long double dx = x[i] - x[j];
    long double dy = y[i] - y[j];
    return sqrt(dx*dx + dy*dy);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> perm(n, 0);
    for (int i = 0; i < n; ++i) {
        perm[i] = i;
        cin >> x[i] >> y[i];
    }
    long double ans = 0.0;
    int fac = 0;
    do {
        for (int i = 0; i < n-1; ++i) ans += dist(perm[i], perm[i+1]);
        fac++;
    } while (next_permutation(perm.begin(), perm.end()));
    cout << fixed << setprecision(10) << ans/fac << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
#define int long long
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;

signed main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int N, W; cin >> N >> W;
  vector<ii> v(N); for(auto& i: v) cin >> i.first >> i.second;
  vvi res(W+1, vi(N+1));
  rep(k,1,N+1){
    rep(x,0,W+1){
      res[x][k] = res[x][k-1];
      if(x-v[k-1].first >= 0) res[x][k] = max(res[x][k], v[k-1].second + res[x-v[k-1].first][k-1]);
    }
  }
  cout << *max_element(all(res[W])) << "\n";
  return 0;
}


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

int main(){
    int n,a[MX],b[MX],c[MX];
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    ll ans=0;
    rep(i,n){
        ans+=(lower_bound(a,a+n,b[i])-a)*(n-(upper_bound(c,c+n,b[i])-c));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define ll long long
const int INF = 1e8;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;

int dx[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy[] = {1, -1, 0, 1, -1, 0, 1, -1};
ll MOD = 1e9 + 7;
ll dp[4005][4005];
int a[MAXN], b[MAXN];
ll base = 2002;
ll ch[MAXN], zn[MAXN];
int n;
long long  per(long long x, ll step){

    long long r = 1;

    while (step){
        if (step & 1) r = (r * x ) % MOD;
        x *= x;
        x %= MOD;
        step >>= 1;
    }
    return r;
}

void calc(){
    ch[0] = 1;
    for (int i = 1; i <= MAXN - 10; i++)
        ch[i] = ch[i - 1] * i % MOD;
    zn[MAXN - 10] = per(ch[MAXN - 10], MOD - 2);
    for (int i = MAXN - 11; i >= 0; i--){
        zn[i] = zn[i + 1] * (i + 1)  % MOD;
    }
}

ll C(int n, int m){
    return ch[n] % MOD * zn[m] % MOD * zn[n - m] % MOD;
}
void solve(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
        dp[-a[i] + base ][ -b[i] + base ]++;
    }
    calc();

    for (int i = 1; i <= 4004; i++){
        for (int j = 1; j <= 4004; j++)
            dp[i][j] = (dp[i][j] + dp[i - 1][j] + dp[i][j - 1] ) % MOD;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++){
        ans += dp[a[i] + base][b[i] + base];
        ans %= MOD;
        ans = ((ans - C(2 * a[i] + 2 * b[i], 2 * a[i]) % MOD + MOD) % MOD);
    }
    cout << (ans * zn[2] ) % MOD;

}

int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(7);
    //freopen("inevit.in", "r", stdin);
    //freopen("inevit.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++)
        solve();

}

Measured memory_bytes: 132608
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 2000 + 5;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

vector<int> G[maxn];

int n, k;
int dep[maxn], ans = INT_MAX;

int res = 0;
void dfs(int u, int f = 0) {
    dep[u] = dep[f] + 1;
    if(dep[u] > k/2 + 1) ++ res;

    for(int i = 0; i < int(G[u].size()); ++i) {
        int v = G[u][i];
        if(v == f) continue;
        dfs(v, u);
    }
}

int main() {
    //freopen("c.in", "r", stdin);
    //freopen("c.out", "w", stdout);

    n = read<int>();
    k = read<int>();
    for(int i = 1; i < n; ++i) {
        static int u, v;
        u = read<int>();
        v = read<int>();
        G[u].pb(v); G[v].pb(u);
    }

    if((k&1) == 0) {
        for(int i = 1; i <= n; ++i) {
            res = 0;
            dfs(i);
            chkmin(ans, res);
        }
    }else {
        for(int i = 1; i <= n; ++i) {
            for(int j = 0; j < int(G[i].size()); ++j) {
                res = 0;

                dep[G[i][j]] = 0;
                dfs(i, G[i][j]);
                dep[i] = 0;
                dfs(G[i][j], i);

                chkmin(ans, res);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int n, num[100005], a[100005];
string ta;
bool f(int p) {
    int t1,t2;
    t1 = (p - 1 + n) % n;
    t2 = (p + 1) % n;
    if ((num[t1] ^ num[t2]) == (num[p] ^ a[p])) return true;
    else return false;
}
int main()
{
    int i, j, k, t1, t2;
    cin >> n;
    cin >> ta;
    for (i = 0; i < n; i++) {
		if (ta[i] == 'o') a[i] = 0;
		else a[i] = 1;
    }
    for (i = 0; i< 2; i++) {
        for (j= 0; j< 2; j++) {
            num[0] = i;
            num[1] = j;
//            if (i == j && a[1] == 'x' || i != j && a[2] == 'o') continue;
            for (k = 1; k < n - 1; k++) {
				num[k+1]=((num[k - 1] ^ num[k]) ^ a[k]);
//                if (num[k] == 1) {
//                    if (a[k] == 'o') num[k + 1] = num[k - 1];
//                    else num[k + 1] = 3 - num[k - 1];
//                } else {
//                    if (a[k] == 'o') num[k + 1] = 3 - num[k - 1];
//                    else num[k + 1] = num[k - 1];
//                }
            }
            for (k = 0; k < n; k++) {
                if (!f(k)) break;
            }
            if (k == n) {
                for (k = 0; k < n; k++) {
                    if (num[k] == 0) printf("S");
                    else printf("W");
                }
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 1408
// uneven numbers.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	int n , c = 0; 
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (to_string(i).length() % 2)
			c++;
			
	}
	cout << c;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <time.h>
#define mp(a,b)   make_pair(a,b)
#define ll        long long
#define mp(a,b)   make_pair(a,b)
#define si(n)     scanf("%d",&n)
#define sl(n)     scanf("%lld",&n)
#define pi(n)     prllf("%d\n",n)
#define pl(n)     prllf("%lld\n",n)
#define           newline cout << endl;
#define           ff first
#define           ss second
using namespace std;

int main(){
  //clock_t tStart = clock();
  ll n; cin >> n;
  ll arr[n];
  ll ans = 0;
  for(ll i=0;i<n;i++){
    cin >> arr[i];
    ans+=(arr[i]-1);
  }
  cout << ans << endl;
  //prllf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    var (n, a, b) = readLine()!!.split(" ").map { it.toInt() }

    var cnt = 0
    for (i in 1..n) {
        val sum = digitSum(i)
        if (sum in a..b) cnt += i
    }
    print(cnt)
}

fun digitSum(num: Int): Int{
    var sum = 0
    sum += num%10
    sum += num/10%10
    sum += num/100%10
    sum += num/1000%10
    sum += num/10000%10


    return sum
}

Measured memory_bytes: 37820
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 
int main(){ 
  int n;cin>>n;
  if(n%2==0)
    cout<<n;
  else
    cout<<n*2;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, L, Q;
int A[MAX];
int jump[MAX][33];
vector<int> vec;

int func(int i, int j) {
	if (j == 0) return jump[i][0];
	int &ret = jump[i][j];
	if (ret != -1) return ret;
	return ret = func(func(i, j - 1), j - 1);
}
int main()
{
	int i, j, k;
	scanf("%d", &N);
	for (i = 1; i <= N; ++i) {
		scanf("%d", &A[i]);
		vec.push_back(A[i]);
	}
	scanf("%d%d", &L, &Q);
	sort(vec.begin(), vec.end());
	memset(jump, -1, sizeof(jump));
	for (i = 1; i <= N; ++i) {
		auto it = upper_bound(vec.begin(), vec.end(), A[i] + L);
		--it;
		jump[i][0] = it - vec.begin() + 1;
	}
	j = 0;
	while (N > (1 << j)) j++;
	for (i = 1; i <= N; ++i) {
		func(i, j);
	}
	int a, b;
	for (i = 1; i <= Q; ++i) {
		scanf("%d%d", &a, &b);
		int days = 0;
		if (b < a) swap(a, b);
		for (k = j; k >= 0; --k) {
			if (jump[a][k] < b) {
				days += (1 << k);
				a = jump[a][k];
			}
		}

		printf("%d\n", days + 1);
	}
}

Measured memory_bytes: 14584
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
    
    
    int n,m,a[111111*2],b[111111*2];
    cin>>n>>m;
    set<int> s;
    int count=0;
    rep(i,m){
        cin>>a[i]>>b[i];
        if(a[i]==1){
            s.insert(b[i]);
            count++;
        }
        if(b[i]==n){
            s.insert(a[i]);
            count++;
        }
    }
    if(count!=s.size())cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    
    
    
	

}

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

using ll = long long;

const ll INF = 1001001001;
const ll mod = 1000000007;

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> grid(H);
	for (int i = 0; i < H; ++i) cin >> grid[i];
	vector<vector<ll>> dp(H, vector<ll>(W, 0));
	for (int i = 0; i < H; ++i) {
		if (grid[i][0] == '#') break;
		dp[i][0] = 1;
	}
	for (int i = 0; i < W; ++i) {
		if (grid[0][i] == '#') break;
		dp[0][i] = 1;
	}
	for (int i = 1; i < H; ++i) {
		for (int j = 1; j < W; ++j) {
			if (grid[i][j] == '#') continue;
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	cout << dp[H - 1][W - 1] << endl;
}

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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ull long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int Maxn = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

struct pos { int first, second, third; }; 

ull k, a, b;
ull ans = 1; 

ull maxx(ull x)
{
	if (x > 0) return x; 
	return 0; 
}

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	scanf("%d%d%d", &k, &a ,&b); int cntt = 0; 
	while (2 < b - a)
	{
		if (maxx(a - ans) + 2 <= k)
		{
			k -= maxx(a - ans) + 2; 
			int p = b - a + maxx(a - ans); 
			ans += b - a + maxx(a - ans); 
		}
		else break; 
	}
	ans += k; 
	
	printf("%lld\n", ans); 
	
	return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm> 
#include <string.h>
using namespace std;
char s[300002];
int d[300001][2]; 
int ans;
int main(){
	ans=1000000;
	int n,i,j,l,a;
	scanf("%d",&n);
	scanf("\n");
	scanf("%s",s+1);
    for(i=1;i<=n;i++){
    d[i][0]=d[i-1][0];
    d[i][1]=d[i-1][1];
    if(s[i]=='W')d[i][0]++;
	else d[i][1]++;	
    	
    	
    	
    	
	}
	for(i=1;i<=n;i++){
	a=d[i-1][0]+d[n][1]-d[i][1];	
	if(a<ans)ans=a;	
		
		
		
		
		
		
		
	}
printf("%d",ans);
return 0;		
		
	}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if(cur == nil) break;
    if(isf == 0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if(t == nil) return;
  deleteNode(t);
  return;
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = nil->next;
  while(1){
    if(t == nil) break;
    if(t->key == key){
      deleteNode(t);
      break;
    }
    t = t->next;
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main(){
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com)>6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();
      } else{
	delete(key);
	nd++; 
      }
      size--;
    }
  }
  
  printList();
  return 0;
}



Measured memory_bytes: 32960
#include<iostream>
using namespace std;
long long risi(long long yokin)
{
	long long ans;
	ans = yokin + (long long)(yokin/100);
	return ans;
}
int main()
{
	long long X;
	cin >> X;
	long long yokin = 100;
	long long i = 0;
	while(yokin < X)
	{
		yokin = risi(yokin);
		i++;
	}
	cout << i;
}


Measured memory_bytes: 3652
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

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

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	
	int total = 0;
	if ((a + b) >= (2 * c))
	{
		total += (min(x, y) * 2 * c);
		if (x >= y)
		{
			if (a >= (2 * c))
			{
				total += (x - y) * 2 * c;
			}
			else
			{
				total += (x - y) * a;
			}
		}
		else
		{
			if (b >= (2 * c))
			{
				total += (y - x) * 2 * c;
			}
			else
			{
				total += (y -x) * b;
			}
		}
	}
	else
	{
		total += (a * x);
		total += (b * y);
	}
	
	cout << total << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


Measured memory_bytes: 3608
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
inline ll exponentiation(ll base, ll exp)
{
	ll t = 1;
	while (exp > 0)
	{

		
		if (exp % 2 != 0)
			t = (t * base) % N;

		base = (base * base) % N;
		exp /= 2;
	}
	return t % N;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0),cin.tie(0);
	string s, t;
	cin >> s;
	f(i, 0, s.length())
	{
		s[i] = 'x';
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e6+10;
const int MAXM = (int) 1e6+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int n,x;
int a[MAXN];

int gcd(int x,int y){
    return x==0 ? y : gcd(y%x,x);
}

void work(){
//    printf("%d\n",gcd(3,5));
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int ans;
    if(a[1]<x) ans=x-a[1];
    else ans=a[1]-x;
    for(int i=2;i<=n;i++){
        int y;
        if(a[i]<x) y=x-a[i];
        else y=a[i]-x;
        ans=gcd(ans,y);
    }
    printf("%d\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<ll> h(n);
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	
	vector<ll> dp(n + 10, 1LL << 60);
	dp[0] = 0; 
	
	for(int i = 1; i < n; ++i) {
		for(int j = 1; j <= k; ++j) {
			if( i < j ) continue;
			else dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	
	cout << dp[n - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;

vector<pair<ll, ll>> fs;

void PF(ll n) {
    ll base = n;
    for (ll i = 2; i * i <= base; i++) {
        if (base % i == 0) {
            int cnt = 0;
            while (base % i == 0) {
                base /= i;
                cnt++;
            }
            fs.emplace_back(i, cnt);
        }
    }
    
    if (base > 1) {
        fs.emplace_back(base, 1);
    }
    
    /*
    for (int i = 0; i < fs.size(); i++) {
        cout << fs[i].first << " " << fs[i].second << endl;
    }
    */
}

int main(void){
    ll n;
    cin >> n;
    PF(n);
    
    if (n == 2) {
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 1, p=1;
    for (int i = 0; i < fs.size(); i++) {
        ans *= (pow(fs[i].first, fs[i].second + 1) - 1) / (fs[i].first - 1);
        p *= fs[i].second + 1;
    }
    //cout << ans <<endl;
    
    for (int i = 1; i <= sqrt(n)+1; i++) {
        if (n % i == 0) {
            ans -= i;  p--;
        }
    }
    
    cout << ans - p << endl;
}


Measured memory_bytes: 384