akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
bool dp[101][10001];

int main(){
    int N;
    cin >> N;
    memset(dp,false,sizeof(dp));
    dp[0][0]=true;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int i=1;i<=N;i++){
        for(int j=0;j<=10000;j++){
            if(dp[i-1][j]!=true) continue;
            dp[i][j]=true;
            dp[i][j+a[i-1]]=true;
        }
    }
    for(int i=10000;i>=0;i--){
        if((dp[N][i]==true)&&(i%10!=0)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "0\n";
    return 0;
}

Measured memory_bytes: 1280
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int ms = 1e5 + 10;
int a[ms], l[ms][2], r[ms][2], b[ms];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    map<int, int> m;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        a[t] = i;
        b[i] = t;
    }
    set<int> s;
    s.insert(n);
    s.insert(-1);
    s.insert(-2);
    s.insert(n + 1);
    for (int i = n; i > 0; --i)
    {
        auto it = s.lower_bound(a[i]);
        r[a[i]][0] = *it;
        ++it;
        r[a[i]][1] = *it;
        --it;
        --it;
        l[a[i]][0] = *it;
        --it;
        l[a[i]][1] = *it;
        s.insert(a[i]);
    }
    ll res = 0;
    for (int i = 0; i < n; ++i)
    {
        if (l[i][0] != -1)
        {
            res += 1ll * (r[i][0] - i)*(l[i][0] - l[i][1])*b[i];
        }
        if (r[i][0] != n)
        {
            res += 1ll * (r[i][1] - r[i][0])*(i - l[i][0])*b[i];
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

bool solve() {
    int n, m, t, p;
    cin >> m >> n >> t >> p;
    if(n == 0) {
        return false;
    }
    vector<vector<int>> cnt(2 * n + 10, vector<int>(2 * m + 10, 0));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cnt[i][j]++;
        }
    }
    while(t--) {
        int d, c;
        cin >> d >> c;
        if(d == 1) {
            for(int i = 0; i < n; i++) {
                for(int j = 0; j < c; j++) {
                    int k = c - 1 + (c - j);
                    cnt[i][k] += cnt[i][j];
                    cnt[i][j] = 0;
                }
            }
            for(int i = 0; i < n; i++) {
                for(int j = c; j < 2 * m + 10; j++) {
                    cnt[i][j - c] = cnt[i][j];
                    cnt[i][j] = 0;
                }
            }
        } else {
            for(int i = 0; i < c; i++) {
                for(int j = 0; j < m; j++) {
                    int k = c - 1 + (c - i);
                    cnt[k][j] += cnt[i][j];
                    cnt[i][j] = 0;
                }
            }
            for(int i = c; i < 2 * n + 10; i++) {
                for(int j = 0; j < m; j++) {
                    cnt[i - c][j] = cnt[i][j];
                    cnt[i][j] = 0;
                }
            }
        }
        // for(int i = 0; i < n; i++) {
        //     for(int j = 0; j < m; j++) {
        //         cout << cnt[i][j] << " ";
        //     }
        //     cout << endl;
        // }
    }
    while(p--) {
        int x, y;
        cin >> x >> y;
        cout << cnt[y][x] << endl;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        if(!solve()) {
            return 0;
        }
    }
}


Measured memory_bytes: 3200
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200020
vector<int>e[N];
int cc[2];
int c[N];
vector<int>ca[2];
void dfs(int k, int nc) {
	c[k] = nc;
	ca[nc].push_back(k);
	cc[nc]++;
	f(i, e[k].size()) {
		if (c[e[k][i]] == -1)dfs(e[k][i], ((nc + 1) % 2));
	}
	return;
}


int main() {
	int a[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n-1) {
		scanf("%d %d", &x, &y);
		e[x - 1].push_back(y - 1);
		e[y - 1].push_back(x - 1);
	}
	f(i, n) {
		c[i] = -1;
	}
	cc[0] = 0;
	cc[1] = 0;
	dfs(0, 0);
	x = (n + 2) / 3;
	if (cc[0] >= x) {
		cc[0] -= x;
		f(i, x)a[ca[0][i]] = (3 * i) + 1;
	}
	else {
		cc[1] -= x;
		f(i, x)a[ca[1][i]] = (3 * i) + 1;
	}
	y = (n + 1) / 3;
	if (cc[0] < cc[1]) {
		z = ca[1].size();
		f(i, y) {
			a[ca[1][z - i - 1]] = (3 * i) + 2;
		}
	}
	else {
		z = ca[0].size();
		f(i, y) {
			a[ca[0][z - i - 1]] = (3 * i) + 2;
		}
	}
	x = 3;
	f(i, n) {
		if (a[i] == 0) {
			a[i] = x;
			x += 3;
		}
	}
	f(i, n) {
		printf("%d", a[i]);
		if (i < (n - 1))printf(" ");
		else printf("\n");
	}


	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  vector<int> v;
  map<int,int> mp;
  rep(i,n) mp[a[i]]++;
  sort(a,a+n);
  v.push_back(a[0]);
  for(int i = 1; i < n; i++) {
    if(a[i] != a[i-1]) v.push_back(a[i]);
  }
  int ans = 0;
  vector<bool> f(MAX,false);
  for(auto x : v) {
    if(!f[x] && mp[x] == 1) ans++;
    for(int i = 1; i*x <= MAX; i++) f[i*x] = true; 
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    vector<pair<int,int> >ar;
    int N,puntero=0,temp,sol=0;

    cin>>N;

    for(int i=0;i<N;i++)
    {
        cin>>temp;
        ar.push_back(pair<int,int>(temp,i));
    }
    sort(ar.begin(),ar.end());

    for(int i=0;i<N;i++)
    {
      if(ar[i].second%2!=i%2)
        sol+=1;
    }


    cout <<  sol/2<< endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    VI a, b;
    int n;
    cin >> n;
    REP(i,n) {
        long c;
        cin >> c;
        a.push_back(c);
    }
    REP(i,n) {
        long c;
        cin >> c;
        b.push_back(c);
    }
    long ans = 0;
    REP(i,n) {
        long sum = 0;
        REP(j,i) {
            sum += a[j];
        }
        sum += a[i];
        REPI(k,i,n) {
            sum += b[k];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int A[1100];
int B[1100];
int C[1100];
int D[1000100];
int E[3000100];

priority_queue<int> PQ;

signed main() {
  int x, y, z, k; cin >> x >> y >> z >> k;
  for (int i = 0; i < x; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < y; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < z; i++) {
    cin >> C[i];
  }

  int t = 0;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      D[t++] = A[i] + B[j];
    }
  }

  sort(D, D+t);
  reverse(D, D+t);

  int m = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < z; j++) {
      E[m++] = D[i] + C[j];
    }
  }

  sort(E, E+m);
  reverse(E, E+m);
  for (int i = 0; i < k; i++) {
    cout << E[i] << endl;
  }
  // for (int i = 0; i < x; i++) {
  //   for (int j = 0; j < y; j++) {
  //     for (int k = 0; k < z; k++) {
  //       PQ.push(A[i] + B[j] + C[k]);
  //     }
  //   }
  // }

  // for (int i = 0; i < k; i++) {
  //   cout << PQ.top() << endl;
  //   PQ.pop();
  // }
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 2010

int N;
ll M;
ll dp[2][SIZE];
ll from[1005],to[1005];


void func(){

	for(int i = 0; i < N; i++){

		scanf("%lld",&from[i]);
	}

	for(int i = 0; i < N; i++){

		scanf("%lld",&to[i]);
		to[i] -= from[i];
		if(to[i] < 0){
			to[i] += M;
		}
	}

	int PRE = 0,CURRENT = 1;

	for(int i = 0; i < SIZE; i++){

		dp[PRE][i] = HUGE_NUM;
		dp[CURRENT][i] = HUGE_NUM;
	}

	for(ll k = 0; k <= 1000; k++){

		if(to[0]+M*k >= 0){

			dp[PRE][k] = to[0]+M*k;
		}
	}

	for(int i = 1; i < N; i++){
		for(ll k = 0; k < SIZE; k++){
			if(dp[PRE][k] == HUGE_NUM)continue;

			//下り:1つ左の加算値以下の、最も大きいiの加算値
			if(to[i-1] >= to[i]){

				dp[CURRENT][k] = min(dp[CURRENT][k],dp[PRE][k]); //下りなので押す回数は増えない

			}else{ //to[i-1] < to[i]

				if(k > 0){
					dp[CURRENT][k-1] = min(dp[CURRENT][k-1],dp[PRE][k]);
				}
			}

			//上り:1つ左の加算値より大きい、最も小さいiの加算値
			if(to[i-1] >= to[i]){

				dp[CURRENT][k+1] = min(dp[CURRENT][k+1],dp[PRE][k]+to[i]+M-to[i-1]); //増加分を足す

			}else{ //to[i-1] < to[i]

				dp[CURRENT][k] = min(dp[CURRENT][k],dp[PRE][k]+(to[i]-to[i-1]));
			}
		}
		swap(PRE,CURRENT);
		for(int k = 0; k < SIZE; k++){

			dp[CURRENT][k] = HUGE_NUM;
		}
	}

	ll ans = HUGE_NUM;

	for(int i = 0; i < SIZE; i++){

		ans = min(ans,dp[PRE][i]);
	}

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


int main(){

	while(true){

		scanf("%d %lld",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3208
main(a,b,c){scanf("%d%d%d",&a,&b,&c);double s=a*b*sin(c*3.14159265/180)/2;
printf("%lf\n%lf\n%lf\n",s,a+b+sqrt(a*a+b*b-2*a*b*cos(c*3.14159265/180)),2*s/a);exit(0);}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std; 
int main() 
{ 
    int n;
    cin>>n;
    int m=n%100;
    int y=n/100;
    if(m>=1 && m<=12 && (y>12 || y==0))
    {
        cout<<"YYMM"<<endl;
    }
    else if(y>=1 && y<=12 && (m>12 || m==0))
    {
        cout<<"MMYY"<<endl;
    }
    else if(m>=1 && m<=12 && y>=1 && y<=12)
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else 
    {
        cout<<"NA"<<endl;
    }
}


Measured memory_bytes: 256
import sys

n, a, *x = map(int, sys.stdin.read().split())

def main():
    ma = a * n
    res = [[[0] * (ma + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    res[0][0][0] = 1
    for i in range(n):
        cur = x[i]
        for j in range(i+2):
            for k in range(ma + 1):
                res[i+1][j][k] += res[i][j][k]
                if k >= cur:
                    res[i+1][j][k] += res[i][j-1][k-cur]
    
    ans = 0
    for j in range(1, n+1):
        ans += res[n][j][j*a]

    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 54080
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
#define mod 1000000007
#define INF 0x7fffffffff
#define N 300100
#define endl '\n'
int a[110000],dp[110000][25];
int main()
{
    int n,m,L;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    scanf("%d%d",&L,&m);
    for(int i=1;i<=n;i++) dp[i][0]=upper_bound(a+i+1,a+1+n,a[i]+L)-a-1;
    for(int j=0;j<18;j++)
        for(int i=1;i<=n;i++)
            dp[i][j+1]=dp[dp[i][j]][j];
    while(m--)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        if(l>r) swap(l,r);
        int ans=1;
        for(int i=17;i>=0;i--)
        {
            if(dp[l][i]<r) ans+=(1<<i),l=dp[l][i];
        }
        cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 11008
#include<iostream>
#include<string>

using namespace std;
int main(){
	int cnt=0;
	string w,t;
	cin>>w;
	while(1){
		cin>>t;
		if(t=="END_OF_TEXT")break;
		for(int i=0;i<t.size();i++){
			if(isupper(t[i])){
				t[i]=tolower(t[i]);
			}
		}
		if(t==w)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3208
#include<stdio.h>
#include<string.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int n;
    char s[10010];
    cin >> n;
    cin >> s;
    int len = strlen(s);
    for (int i = 0; i < len; i++) {
        int x  = s[i] - 'A';
        x = (x + n) % 26;
        putchar('A' + x);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n,m,k;cin>>n>>m>>k;
	bool f=false;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i*m+j*n-2*i*j==k){
				f=true;
			}
		}
	}
	if(f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		int[] t = new int[999];
		int sum=0;
		for(int i=1; i<999;i++) {
			sum+=i;
			t[i]=sum;
		}
		System.out.println(t[b-a-1]-a);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
//#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 21, mod = 1e9 + 7;

int n, comp[N][N], dp[N][1 << N];

int go(int id, int taken){
    if(id >= n)
        return 1;
    int &ways = dp[id][taken];
    if(~ways)
        return ways;
    ways = 0;
    for(int i = 0; i < n; i++) if((taken >> i & 1) == 0){
        if(comp[id][i])
            ways = (ways + go(id + 1, taken | (1 << i))) % mod;
    }
    return ways;
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
  
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> comp[i][j];
    cout << go(0, 0);
}


Measured memory_bytes: 172288
#include <bits/stdc++.h>
using namespace std;
#define LIM 300010
#define left st,(st+en)/2,n+n
#define right (st+en)/2+1,en,n+n+1
#define ll long long
#define OUTSIDE en<l || st>r
#define INSIDE st>=l && en<=r
#define INF 1<<19

struct info
{
    int mn,lazy;
    info() {}
    info(int a,int b){mn = a;lazy = b;}
};

info tree[4*LIM+5];
set<int>L,R;
char str[LIM+5];
int n,sum[LIM+5];

void relax(int n)
{
    tree[n+n].mn+=tree[n].lazy;
    tree[n+n].lazy+=tree[n].lazy;
    tree[n+n+1].mn+=tree[n].lazy;
    tree[n+n+1].lazy+=tree[n].lazy;
    tree[n].lazy = 0;
}

void build(int st,int en,int n)
{
    if(st==en){tree[n] = info(sum[st],0);return;}
    build(left);
    build(right);
    tree[n].mn = min(tree[n+n].mn,tree[n+n+1].mn);
}

void update(int st,int en,int n,int l,int r,int x)
{
    if(INSIDE){tree[n].mn+=x;tree[n].lazy+=x;return;}
    if(OUTSIDE)return;
    relax(n);
    update(left,l,r,x);
    update(right,l,r,x);
    tree[n].mn = min(tree[n+n].mn,tree[n+n+1].mn);
}

int query(int st,int en,int n,int l,int r)
{
    if(OUTSIDE)return INF;
    if(INSIDE)return tree[n].mn;
    relax(n);
    return min(query(left,l,r),query(right,l,r));
}

void flip(int pos)
{
    if(str[pos]=='(')
    {
        str[pos]=')';
        L.erase(pos);
        R.insert(pos);
        update(0,n-1,1,pos,n-1,-2);
    }
    else
    {
        str[pos]='(';
        R.erase(pos);
        L.insert(pos);
        update(0,n-1,1,pos,n-1,2);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int q,pos;
    cin >> n >> q >> str;
    for(int i=0; i<n; i++)
    {
        if(!i)sum[i] = (str[i]=='('?1:-1);
        else sum[i]=sum[i-1]+(str[i]=='('?1:-1);
        if(str[i]=='(') L.insert(i);
        else R.insert(i);
    }
    build(0,n-1,1);
    for(int i=0; i<q; i++)
    {
        cin >> pos;--pos;
        if(str[pos]=='(')
        {
            flip(pos);
            int ans = *(R.begin());
            cout << ans+1 << "\n";
            flip(ans);
        }
        else
        {
            flip(pos);
            int l,r,mid;
            l = 0;
            r = n;
            while(l<r)
            {
                mid=(l+r)/2;
                if(query(0,n-1,1,mid,pos)>=2)r = mid;
                else l = mid+1;
            }
            int res = *(L.lower_bound(l));
            flip(res);
            cout << res+1 << "\n";
        }
    }

    return 0;
}



Measured memory_bytes: 26948
using System;

namespace A___Transfer
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            var c = int.Parse (input[2]);
            var ans = c - (a - b);
            if (ans >= 0)
            {
                Console.WriteLine (ans);
            }
            else
            {
                Console.WriteLine (0);
            }
        }
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, M;
    cin >> N >> M;

    vector<pair<intmax_t, intmax_t>> vec;
    for (size_t i = 0; i < M; ++i) {
        intmax_t a, b; cin >> a >> b;
        a--, b--;
        vec.emplace_back(b, a);
    }

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

    intmax_t res = 1;
    intmax_t x = vec[0].first - 1;
    for (size_t i = 1; i < M; ++i) {
        intmax_t l, r;
        tie(r, l) = vec[i];
        if (l <= x) {
            continue;
        } else {
            res++;
            x = r - 1;
        }
    }

    cout << res << "\n";

    return 0;
}


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

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a; i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = n; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int i, j, k;

int main() {
	int r, g, b, n, c = 0;
	scanf("%d%d%d%d", &r, &g, &b, &n);
	REP(i, n / r + 1) {
		REP(j, (n - i * r) / g + 1) {
			if ((n - i * r - j * g) % b == 0)c++;
		}
	}
	printf("%d", c);
	return 0;
}

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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 3e3 + 5;
const int inf = 1e9+7;

double dp[N][N], a[N], ans;

int n;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    dp[0][0] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            dp[i][j] = (j == 0 ? 0 : dp[i - 1][j - 1] * a[i]) + dp[i - 1][j] * (1 - a[i]);
        }
    }
    for (int i = n / 2 + 1; i <= n; i++)
        ans += dp[n][i];

    cout << fixed << setprecision(12) << ans << endl;
}



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

int main(){
  int a, b, c, i, x;
  cin >> a >> b >> c;
  i = 0;
  for (x = a; x <= b; x++) {
    if(c % x == 0) {
      i++;
    } 
  }
  cout << i << endl;
  return 0;
}


Measured memory_bytes: 3100
def make_divisor(n):
    table = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    return table

n = int(input())
t = make_divisor(n)
print(len([1 for i in range(1, n + 1) if i & 1 and t[i] == 8]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<float,float>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;


int main(){
	int h,w;
	cin>>h>>w;
	vector<vector<int>> c(10,vector<int>(10));
	vector<vector<int>> d(10,vector<int>(10,INF));
	vector<vector<int>> a(h,vector<int>(w));
	rep(i,10){
		rep(j,10){
			cin>>d[i][j];
			//d[i][j]=;
		}
	}
//	cout<<'c';

	rep(k,10)rep(i,10)rep(j,10){
		d[i][j]=min(d[i][k]+d[k][j],d[i][j]);
	}

	int ans=0;
	rep(i,h){
		rep(j,w){
			cin>>a[i][j];
		//	cout<<'c';

			if (a[i][j]!=-1) ans+=d[a[i][j]][1];
		}
	}
	cout<<ans;







}


Measured memory_bytes: 384
using System;
using System.Linq;

namespace B.Toll_Gates
{
    class Program
    {
        static void Main(string[] args)
        {
            var NMX = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NMX[0];
            int M = NMX[1];
            int X = NMX[2];

            var Ai = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(Math.Min(Ai.Count(i => i > X), Ai.Count(i => i < X)));

        }
    }
}


Measured memory_bytes: 13396
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;


int main()
{

	int n; cin >> n;
	string s; cin >> s;

	string news = "";

	for (char c : s) {
		int a = (int)c;

		if (a + n > (int)'Z') {
			int d = (a + n) - (int)'Z' + (int)'A' - 1;
			char newc = (char)d;
			news += newc;
			continue;
		}

		a += n;
		char newc = (char)a;
		news += newc;
	}

	cout << news;
	return 0;

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n, i;
    cin >> n;
    ll a[n + 4];
    for (i = 0; i < n; i++)
        cin >> a[i];

    ll sum = 0;
    for (i = 0; i < n; i++)
    {
        sum = sum + a[i];
    }
    ll avg = sum / n;
    ll count1 = 0, count = 0;
    for (i = 0; i < n; i++)
    {
        count = count + pow(abs(avg - a[i]), 2);
    }

    avg++;
    for (i = 0; i < n; i++)
    {
        count1 = count1 + pow(abs(avg - a[i]), 2);
    }
    count = min(count, count1);

    avg--;
    avg--;
    count1 = 0;
    for (i = 0; i < n; i++)
    {
        count1 = count1 + pow(abs(avg - a[i]), 2);
    }
    count = min(count, count1);

    cout << count;

    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    char c[a+2][b+2];
    for(int i=1;i<=a;i++)
        for(int j=1;j<=b;j++)
            cin>>c[i][j];
    for(int i=1;i<=a;i++)
        for(int j=1;j<=b;j++)
            if(c[i][j]=='#')
            {
                bool f=false;
                if(c[i-1][j]=='#'||c[i+1][j]=='#'||c[i][j-1]=='#'||c[i][j+1]=='#')
                    f=true;
                if(!f)
                {
                    cout<<"No";
                    return 0;
                }
            }
    cout<<"Yes";
    return 0;
}

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

void mark(int i, int j) {
    if (i % 2 == 0) {
        if (j % 2 == 0) {
            cout << "#";
        } else {
            cout << ".";
        }
    } else {
        if (j % 2 == 0) {
            cout << ".";
        } else {
            cout << "#";
        }
    }
}

int main() {
    while (1) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                mark(i, j);
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
const int MAXN = 52;
int a[MAXN];

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    int mi = a[0], ma = a[0];
    int mi_idx = 0, ma_idx = 0;
    for (int i = 1; i < N; ++i) {
        if (a[i] > ma) {
            ma = a[i];
            ma_idx = i;
        }
        if (a[i] < mi) {
            mi = a[i];
            mi_idx = i;
        }
    }
    cout << (N-1)*2 << endl;
    if (abs(ma) >= abs(mi)) {
        for (int i = 0; i < N; ++i) {
            if (ma_idx == i)  continue;
            cout << ma_idx+1 << ' ' << i+1 << endl;
        }
        for (int i = 0; i < N-1; ++i) {
            cout << i+1 << ' ' << i+2 << endl;
        }
    } else {
        for (int i = 0; i < N; ++i) {
            if (mi_idx == i)  continue;
            cout << mi_idx+1 << ' ' << i+1 << endl;
        }
        for (int i = N-1; i >= 1; --i) {
            cout << i+1 << ' ' << i << endl;
        }
    }
    return 0;
}


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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  string n;
  cin >> n;

  char s1 = n[n.length() - 1];
  if (s1 == '2' || s1 == '4' || s1 == '5' || s1 == '7' || s1 == '9') cout << "hon" << endl;
  else if (s1 == '0' || s1 == '1' || s1 == '6' || s1 == '8') cout << "pon" << endl;
  else cout << "bon" << endl;

  return 0;
}

Measured memory_bytes: 3640
import math

def kock(n,p1x,p1y,p2x,p2y):
    if n==0:
        pass
    else:
        sx=(2*p1x+p2x)/3
        sy=(2*p1y+p2y)/3
        tx=(p1x+2*p2x)/3
        ty=(p1y+2*p2y)/3

        ux=(tx-sx)*math.cos(math.pi*1/3)-(ty-sy)*math.sin(math.pi*1/3)+sx
        uy=(tx-sx)*math.sin(math.pi*1/3)+(ty-sy)*math.cos(math.pi*1/3)+sy

        kock(n-1,p1x,p1y,sx,sy)
        print(sx,sy)
        kock(n - 1, sx, sy, ux, uy)
        print(ux,uy)
        kock(n - 1, ux, uy, tx, ty)
        print(tx,ty)
        kock(n - 1, tx, ty, p2x, p2y)

n=int(input().strip())

zero=0.0
hundred=100.0
print(zero,zero)
kock(n,0,0,100,0)
print(hundred,zero)

Measured memory_bytes: 8100
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <queue>

using namespace std;

int main(){
    int N;
    int D;
    cin >> N >> D;
    
    /* cordinate */
    vector<int> X(N);
    vector<int> Y(N);

    /* input coordinate */
    for(int i=0; i<N; i++){
        cin >> X.at(i) >> Y.at(i);
    }

    int cnt = 0;

    for(int i=0; i<N; i++){
        
        double p2 = pow((double)X.at(i), (double)2);
        double q2 = pow((double)Y.at(i), (double)2);

        double dist = sqrt(p2+q2);

        /* 繰り上げ */

        if( dist <= (double)D){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;

}

Measured memory_bytes: 4504
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c; cin >> a >> b>>c;
	//string s; cin >> s;
	if (c <= b && c >= a)cout << "Yes";
	else cout << "No";


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n, q;
int a[100010];
int b[100010];
int c[100010];

int dCount[100010];
long long total;

int main()
{
	for (int i = 0 ; i <= 100000 ; i++)
		dCount[i] = 0;
	
	scanf("%d", &n);
		
	total = 0;

	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &(a[i]));
		dCount[a[i]]++;
		total = total + a[i];
	}
	
	scanf("%d", &q);
	
	for (int i = 0 ; i < q ; i++) {
		scanf("%d%d", &(b[i]), &(c[i]));

		long long count = dCount[b[i]];
		total = total - b[i] * count;
		dCount[b[i]] = 0;
		total = total + c[i] * count;
		dCount[c[i]] = dCount[c[i]] + count;
		printf("%lld\n", total);
	}
		
		
		
	return 0;
}


Measured memory_bytes: 3288
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();

    sc.close();

    int a = 100000;

    int l = String.valueOf(N).length();

    int ans = 0;

    switch(l){
      case 1:
        ans = N;
      break;
      case 2:
        ans = 9;
      break;
      case 3:
        ans = 9 + N - 99;
      break;
      case 4:
        ans = 909;
      break;
      case 5:
      ans = 909 + N - 9999;
      break;
      case 6:
        ans = 90909;
      break;
    }

    System.out.println(ans);
    
  }

}

Measured memory_bytes: 21844
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        boolean[] valList = new boolean[n];
        Arrays.fill(valList, false);
        for (int i = 0; i < k; i++) {
            int d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                int havingMan = sc.nextInt();
                valList[havingMan - 1] = true;
            }
        }
        sc.close();

        int result = 0;
        for (boolean b : valList) {
            if (!b) {
                result++;
            }
        }

        System.out.println(result);
    }

}

Measured memory_bytes: 46040
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll a,b;cin>>a>>b;
    if(a*b%2==1)cout<<"Odd\n";
    else cout<<"Even\n";
}

Measured memory_bytes: 256
input = defined?(DATA) ? DATA : STDIN

x, n = input.gets.split(' ').map(&:to_i)
list = input.gets.split(' ').map(&:to_i).sort

if n == 0
  puts x
  exit
end

hash = {}
list.each do |i|
  hash[i] = true
end

upper = x
loop do
  unless hash[upper]
    break
  end
  upper += 1
end

lower = x
loop do
  unless hash[lower]
    break
  end
  lower -= 1
end

puts (upper - x) < (x - lower) ? upper : lower


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

int main()
{
	int x1, y1, x2, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	int dx = x2 - x1, dy = y2 - y1;

	cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;

	return ( 0 );
}


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

#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int W, H;
int P[100000], Q[100000];
long long s[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> W >> H;
  rep(i, W) cin >> P[i];
  rep(i, H) cin >> Q[i];
  sort(P, P+W);
  sort(Q, Q+H);
  s[0] = P[0];
  for (int i=1; i<W; i++) {
    s[i] = s[i-1] + P[i];
  }
  long long c = s[W-1];
  rep(i, H) {
    int p = lower_bound(P, P+W, Q[i]) - P;
    c += 1LL * Q[i] * (W+1-p);
    if (p>0) c += s[p-1];
  }
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 1792
//ITP1_5_B:   Print a Frame
#include <stdio.h>
void a(char character,int max){
	int i;
	for (i=0; ++i<=max;) putchar(character);
}
int main(){
	int H, W;
	int h;
	while(1){
		scanf("%d%d", &H, &W);
		if (H==0&&W==0) break;
		a('#', W);
		putchar('\n');
		for (h=0; ++h<=H-2;){
			putchar('#');
			a('.', W-2);
			printf("#\n");
		}
		a('#', W);
		printf("\n\n");
	}
}


Measured memory_bytes: 1896
import heapq

n, m = map(int, input().split())
alst = list(map(int, input().split()))
heap = [-1 * num for num in alst]
ans = sum(alst)
heapq.heapify(heap)

num = heapq.heappop(heap)
for _ in range(m):
    num *= -1
    tmp = num // 2
    ans -= num - tmp
    tmp *= -1
    num = heapq.heappushpop(heap, tmp)
print(ans)


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

void solve() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = max({
    a * c,
    b * d,
    a * d,
    b * c
  });
  if ((a <= 0 && b >= 0) || (c <= 0 && d >= 0)) {
    ans = max(ans, 0LL);
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);  int t = 1;
  // cin >> t;
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

int main(){
	IOS;
	int q=1,c=1;
	//cin>>q;
	while(q--){
		int s,w;
		cin>>s>>w;
		if(s<=w)
			cout<<"unsafe"<<endl;
		else
			cout<<"safe"<<endl;

	}
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int maxLength = s.length() - 1;
        for (int i = s.length() - 1; i > 0; i--) {
            if (i % 2 != 0) {
                continue;
            }
            boolean isSS = true;
            for (int t = 0; t < i / 2; t++) {
                if (s.charAt(t) != s.charAt(i / 2 + t)) {
                    isSS = false;
                    break;
                }
            }
            if (isSS) {
                maxLength = i;
                break;
            }
        }

        System.out.println(maxLength);
    }
}


Measured memory_bytes: 22996
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007
#define int long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))

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

signed main()
{
    int CX, CY, H;
    int N;
    cin >> N;
    int xdata[N], ydata[N], hdata[N];
    rep(i, N)
    {
        cin >> xdata[i] >> ydata[i] >> hdata[i];
    }
    for (int x = 0; x <= 100; x++)
    {
        for (int y = 0; y <= 100; y++)
        {
            int h = 0;
            bool is_ans = true;
            rep(i, N)
            {
                if (hdata[i] != 0)
                {
                    h = abs(x - xdata[i]) + abs(y - ydata[i]) + hdata[i];
                    break;
                }
            }
            rep(i, N)
            {
                if (hdata[i] != MAX(0, h - abs(x - xdata[i]) - abs(y - ydata[i])))
                {
                    is_ans = false;
                    break;
                }
            }
            if (is_ans)
            {
                cout << x << " " << y << " " << h << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
void dfs(int a, int c, string s){
	if(a == 0){
		cout << s << endl;
		return;
	}
	
	for(int i = 0; i < c; i++){
		dfs(a-1, max(i+2,c), s+(char)('a'+i));
	}
}
void solve(){
	cin >> n;
	
	string s;
	dfs(n,1, s);
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
        v.pb(2);
    }
    //if(x>0)
    //v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
            v.pb(i);
        }
        //if(y>0)
        //v.pb({i,y});
    }
    if (n > 2)
        v.pb(n);
    return v;
}

vector<int>leastPrimeFactor(int n)
{
    vector<int>least_prime(n);
    // Create a vector to store least primes.
    // Initialize all entries as 0.
    // We need to print 1 for 1.
    least_prime[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        // least_prime[i] == 0
        // means it i is prime
        if (least_prime[i] == 0)
        {
            // marking the prime number
            // as its own lpf
            least_prime[i] = i;

            // mark it as a divisor for all its
            // multiples if not already marked
            for (int j = 2*i; j <= n; j += i)
                if (least_prime[j] == 0)
                   least_prime[j] = i;
        }
    }
    return least_prime;
}

void solve()
{
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];
int ans=0;
sort(a,a+n);
for(int i=0;i<k;i++)
    ans+=a[i];
cout<<ans<<endl;
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
solve();
}
}



Measured memory_bytes: 3640
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            int K = sc.nextInt();
            int sum = K;
            for(int i = 1;i < N;i++){
                sum = sum * (K-1);
            }
            System.out.println(sum);

        
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
typedef long long LL;
const int N=100010;
const LL inf=1LL<<60;
int n; LL x[N],y[N];
int main(){
	cin>>n;
	ref(i,1,n)cin>>x[i]>>y[i];
	LL L=-inf,R=inf;
	while(L<R){
		LL m=(L+R+1)>>1;bool s=0;
		ref(i,1,n)if(x[i]<m)s^=(!((m-1-x[i])&(inf-y[i])));
		if(s)R=m-1;else L=m;
	}
	cout<<L<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000007
#define ll long long
using namespace std;
int main() {
  ll n;
  cin >> n;
  ll eve = 0;
  ll odd = 0;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    if (a % 2 == 0) {
      eve++;
    } else {
      odd++;
    }
  }
  if (odd % 2 == 1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define s second
#define f first
#define ll long long 
bool comp(pair<int,int> &a , pair<int,int>&b)
{
    return a.s>=b.s;
}
int main()
{
	ll n,m;
    cin>>n>>m;
    ll h[n];
   	for(int i=0;i<n;i++){
       cin>>h[i];
    }
    ll ishigher[n];
    memset(ishigher,0,sizeof ishigher);
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        a--,b--;
        if(h[a]>=h[b])
        {
            ishigher[b]=-1;
        }
        if(h[b]>=h[a])
        {
            ishigher[a]=-1;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++)
        if(ishigher[i]==0)
            ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 5180
def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(n):
    pi = 3.14159
    return 2*pi*n


if __name__ == "__main__":
    n = i1num()
    print(solve(n), flush=True)


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b,c,d;
  cin >> n >> a >> b>>c>>d;
  char s[n];
  cin >> s;
  int hantei = 1;
  if(c < d){
    for(int i = b-1+1; i < d-1-1; i++){
      if(s[i] == '#' && s[i+1] == '#'){
        hantei = 0;
        break;
      }
    }
    if(hantei == 1){
      for(int i = a-1+1; i < c-1-1; i++){
        if(s[i] == '#' && s[i+1] == '#'){
          hantei = 0;
          break;
        }
      }
    }
  }
  else{
    int tri = 0;
    for(int i = a-1+1; i < c-1-1; i++){
      if(s[i] == '#' && s[i+1] == '#'){
        hantei = 0;
        break;
      }
      if(i >= b-1-1 && i <= d-1-1){
        if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') tri = 1;
      }
    }
    if(tri ==0) hantei = 0;
    if(hantei == 1){
      for(int i = b-1+1; i < d-1-1; i++){
        if(s[i] == '#' && s[i+1] == '#'){
          hantei = 0;
          break;
        }
      }
    }
  }

  if(hantei == 1){
    cout << "Yes" << "\n";
  }
  else cout << "No\n";
  return 0;
}


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

int main() {
    // input
    string A, B;
    cin >> A >> B;

    // solve & output
    if (A.length() == B.length()) {
        if (A.compare(B) > 0) cout << "GREATER" << endl;
        else if (A.compare(B) < 0) cout << "LESS" << endl;
        else cout << "EQUAL" << endl;
    } else {
        if (A.length() > B.length()) cout << "GREATER" << endl;
        else cout << "LESS" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[3];
int main() {
	for(int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[2] * 10 + a[1] + a[0];

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B;
    int a,b,c;
    scanf("%d%d",&A,&B);
    a=A+B;
    b=A*B;
    c=A-B;

    if(a>b&&a>c){
        printf("%d",a);
    }
    else if(b>c){
        printf("%d",b);
    }
    else{
        printf("%d",c);
    }

    return 0;
}

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

void func1(int W) {
  for(int i=0; i<W; ++i) {
    if(i==0 || i==(W-1)) {
      cout << '+';
    }
    else {
      cout << '-';
    }
  }
}

void func2(int W, string c) {
  for(int i=0; i<W; ++i) {
    if(i==(W/2)) {
      cout << c;
    }
    else if(i==0 || i==(W-1)) {
      cout << '|';
    }
    else {
      cout << '.';
    }
  }
}

void func3(int W) {
  for(int i=0; i<W; ++i) {
    if(i==0 || i==(W-1)) {
      cout << '|';
    }
    else {
      cout << '.';
    }
  }
}

int main() {
  int W, H;
  string c;
  cin >> W >> H >> c;

  for(int i=0; i<H; ++i) {
    if(i==0 || i==(H-1)) {
      func1(W);
      cout << endl;
    }
    else if(i==(H/2)) {
      func2(W, c);
      cout << endl;
    }
    else {
      func3(W);
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3164