akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int key[][] = new int[M][2];
		for(int i=0;i<M;i++) {
			int a = sc.nextInt(), b = sc.nextInt();
			int s = 0;
			for(int j=0;j<b;j++) {
				int c = sc.nextInt()-1;
				s |= 1<<c ;
			}
			key[i][0]=s; //開けれる宝箱の番号が1で表現された01フラグ
			key[i][1]=a; //鍵の値段
		}
		sc.close();
		
		int dp[] = new int[1<<N]; //開けれる宝箱の状態を、要素番号の二進数表記の１で表現したときの、最小コスト
		int INF = Integer.MAX_VALUE/2;
		Arrays.fill(dp, INF);
		dp[0]=0;
		for(int i=0;i<(1<<N);i++) {
			for(int j=0;j<M;j++) {
				int keyOpenNum = key[j][0];
				int keyCost = key[j][1];
				int nextOpenNum = i|keyOpenNum;
				dp[nextOpenNum]= Math.min(dp[nextOpenNum], dp[i]+keyCost);
			}
		}
		
		int ans = (dp[(1<<N) -1]==INF)? -1:dp[(1<<N) -1];
		System.out.println(ans);
	}
}


Measured memory_bytes: 30688
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

template<typename T>
T gcd(T u, T v) {
    if(u==0)return v;
    if(v==0)return u;
    T r;
    while (v) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

int main(){
    int a,b,c,d,x,y;
    cin >> a >> b >> c >> d;
    x = abs(a-c);
    y = abs(b-d);
    int z = gcd(x,y);
    put((x/z+y/z-1)*z);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int i,ii;
int prime[55566];
bool mark[55566];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for( i=1;i<=55555;i++){
		prime[i]=i;
	}
	for( i=2;i<=55555;i++){
		if (mark[i]==false){
			for(ii=2;ii*i<=55555;ii++){
				mark[ii*i]=1;
			}
		}
	}
	int n;
	cin>>n;
	i=0;
	int last=3;
	while(i<n){
		if (mark[last]==false&&last%5==1){
			cout<<last<<" ";
			i++;
		}
		last++;
	}
	
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > b)
	printf("a > b\n");
	if (a == b)
	printf("a == b\n");
	if (a < b)
		printf("a < b\n");
	return 0;
}

Measured memory_bytes: 2608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m, k; cin >> n >> m >> k;
	vi p(n + m);
	rep(i, n + m) p[i] = i;
	
	function<int(int)> root = [&](int x){
		if(p[x] == x) return x;
		return p[x] = root(p[x]);
	};
	rep(it, k){
		int a, b, c; cin >> a >> b >> c; b--; c--;
		if(a == 1){
			int rb = root(b + m), rc = root(c + m);
			if(rb < m && rc < m && rb != rc){
				cout << it + 1 << endl;
				return 0;
			}
			if(rb > rc) swap(rb, rc);
			p[rc] = rb;
		}
		else{
			int rb = root(b + m);
			if(rb < m && rb != c){
				cout << it + 1 << endl;
				return 0;
			}
			p[rb] = c;
		}
		//if(it % 1000 == 999) rep(i, n + m) root(i);
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3624
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#define sz(v) (int)v.size()
#define ll long long
#define ull unsigned long long
using namespace std;
const int PI = 3.14159265;
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
int main()
{
	//freopen("file.in","r",stdin);
	//freopen("file.out","w",stdout);
	fast();

	int n, p[1001];
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
		if (i % 2 == 0 && p[i] % 2 == 1) {
			cnt++;
		}
	}
	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv){
	int x, h;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> x >> h){
#else
	while(std::cin >> x >> h){
#endif
		if(x == 0 && h == 0){ break; }

		double S = x * x + 2 * x * sqrt(x * x / 4.0 + h * h);

		printf("%.6lf\n", S);

	}


 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3116
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt(), y = sc.nextInt();
		List<Integer> a = new ArrayList<>(Arrays.asList(1, 3, 5, 7, 8, 10, 12));
		List<Integer> b = new ArrayList<>(Arrays.asList(4, 6, 9, 11));
//		List<Integer> c = new ArrayList<>(Arrays.asList(2));
		
		if((a.contains(x)&&a.contains(y))||(b.contains(x)&&b.contains(y))) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    ll n;
    cin >>n;
    ll sum =0;
    rep(i,n+1){
        if(i%3!=0 && i%5!=0){
            sum += i;
        }
    }
    cout << sum <<endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

int a[100002];
ll fac[100005];
ll inv[100005];
ll nCr(int n, int r)
{
	if(r>n)return 0;
	ll c = fac[n];
	c = (c*inv[r]) % MOD;
	c = (c*inv[n - r]) % MOD;
	return c;
}
int main() {
	fac[0] = inv[0] = 1;
	fup(i, 1, 100004, 1)
		fac[i] = (fac[i - 1] * i) % MOD;
	inv[100004] = POW(fac[100004], MOD - 2);
	fdn(i, 100003, 1, 1)
		inv[i] = (inv[i + 1] * (i+1)) % MOD;
	int n;
	scanf("%d",&n);
	int l,r;
	fup(i,1,n+1,1)
	{
		int x;
		scanf("%d",&x);
		if(a[x])
		{
			l=a[x],r=i;
			break;
		}
		a[x]=i;
	}
	int tot=n+l-r;
	fup(i,1,n+1,1)
	{
		ll res=nCr(n+1,i);
		res=(res+MOD-nCr(tot,i-1))%MOD;
		printf("%lld\n",res);
	}
}
	

Measured memory_bytes: 3200
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("in.txt",  "r",  stdin);
        freopen("out.txt", "w", stdout);
    #endif
//*/

        

        
    int a,b;
    cin>>a>>b;


    if(a > 2*b)
    {
        cout<<(a-2*b);
    }
    else
    {
        cout<<0;
    }











    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

if M % 2 == 1:
    ll, lr, rl, rr = 1, M, M+1, M*2+1
    for i in range(M//2):
        print(ll+i, lr-i)
    for i in range(M//2+1):
        print(rl+i, rr-i)
else:
    ll, lr, rl, rr = 1, M+1, M+2, M*2+1
    for i in range(M//2):
        print(ll+i, lr-i)
        print(rl+i, rr-i)


Measured memory_bytes: 70068
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int dp[100000][4],n;
vector<int>v[N];
int solve(int i,int prev){
    if(i==n){
        return 0;
    }
    if(dp[i][prev]!=-1){
        return dp[i][prev];
    }
    if(prev==3){
        int choice1=v[i][0]+solve(i+1,0);
        int choice2=v[i][1]+solve(i+1,1);
        int choice3=v[i][2]+solve(i+1,2);
        return dp[i][prev]=max(choice1,max(choice2,choice3));
    }
    if(prev==2){
        int choice1=v[i][0]+solve(i+1,0);
        int choice2=v[i][1]+solve(i+1,1);
        return dp[i][prev]=max(choice1,choice2);
    }
    if(prev==1){
        int choice1=v[i][0]+solve(i+1,0);
        int choice3=v[i][2]+solve(i+1,2);
        return dp[i][prev]=max(choice1,choice3);
    }
    if(prev==0){
        int choice2=v[i][1]+solve(i+1,1);
        int choice3=v[i][2]+solve(i+1,2);
        return dp[i][prev]=max(choice2,choice3);
    }
}
int main()
{
memset(dp,-1,sizeof(dp));
scanf("%d",&n);
for(int i=0;i<n;++i){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    v[i].push_back(a);
    v[i].push_back(b);
    v[i].push_back(c);
}
cout<<solve(0,3)<<endl;





    return 0;
}


Measured memory_bytes: 15348
main :: IO()
main = do
	hoge <- words <$> getLine
	if ((read(hoge !! 0)::Int) <= (read(hoge !! 2)::Int) && ((read(hoge !! 2)::Int) <= (read(hoge !! 1)::Int)))
		then putStr "Yes\n"
		else putStr "No\n"


Measured memory_bytes: 508
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	long h = sc.nextLong();
      	long n = (int)(Math.log(h)/Math.log(2)) + 1;
      	long ans = (long)Math.pow(2,n) - 1;
      	
      	System.out.println(ans);
        
	}
}


Measured memory_bytes: 35740
N,M = map(int,input().split())
table = []
for i in range(N):
    table.append(list(map(int,input().split())))
table.sort(key=lambda x: x[0])
num = 0
total = 0
i = 0
while num < M:
    num += table[i][1]
    total += table[i][1] * table[i][0]
    cost = table[i][0]
    i += 1
print(total-cost*(num-M))

Measured memory_bytes: 29024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
double dp[100010][21]={0};
int main(){
	dp[0][0]=1;
	double sum=0;
	vector<double>out(100010);

	rep(i,100005){
		rep(j,20)if(dp[i][j]){
			double t=1/pow(2,j);
			sum+=dp[i][j]*t;
			if(j)dp[i+1][0]+=dp[i][j]*(1-t);
			dp[i+1][j+1]+=dp[i][j]*t;
		}
		out[i+1]=sum;
	}
	int n;
	while(cin>>n,n)printf("%.5f\n",out[n]);
}

Measured memory_bytes: 18260
#include <iostream>
using namespace std;
int main(){
	int X;
	int num_500,num_5;
	cin >> X;
	num_500 = (X - (X % 500)) / 500;
	num_5 = ((X - num_500 * 500) - (X - num_500 * 500) % 5) / 5;
	cout << 1000 * num_500 + 5 * num_5;
	return 0;
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	int sum = a + b + c;
	int mx = std::max(a, b);
	mx = std::max(mx, c) * 3;

	int tmp = mx - sum;

	if (tmp % 2 == 0) {
		cout << tmp / 2 << "\n";
		return 0;
	}

	while (true) {
		mx += 3;
		if ((mx-sum)%2==0) {
			cout << (mx-sum)/2 << "\n";
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int dy[] = {0, 0, 1, -1};
    int dx[] = {1, -1, 0, 0};

    for(;;){
        int h, w;
        cin >> h >> w;
        if(h == 0)
            return 0;
        vector<string> s(h+2);
        s[0] = s[h+1] = string(w+2, ' ');
        for(int i=1; i<=h; ++i){
            cin >> s[i];
            s[i] = ' ' + s[i] + ' ';
        }

        vector<vector<bool> > check(h+2, vector<bool>(w+2, false));
        int ret = 0;
        for(int i=1; i<=h; ++i){
            for(int j=1; j<=w; ++j){
                if(check[i][j])
                    continue;
                ++ ret;
                queue<pair<int, int> > q;
                q.push(make_pair(i, j));
                check[i][j] = true;
                while(!q.empty()){
                    int y0 = q.front().first;
                    int x0 = q.front().second;
                    q.pop();
                    for(int k=0; k<4; ++k){
                        int y = y0 + dy[k];
                        int x = x0 + dx[k];
                        if(s[y0][x0] == s[y][x] && !check[y][x]){
                            q.push(make_pair(y, x));
                            check[y][x] = true;
                        }
                    }
                }
            }
        }
        cout << ret << endl;
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;

    int MIN = 100000;
    rep(i, 54) {
        int temp = 0;
        if (A < i) {
            if ((i - A) % 2 == 0) temp += (i - A) / 2;
            else temp += (i - A) / 2 + 2;
        } else {
            temp += A - i;
        }
        if (B < i) {
            if ((i - B) % 2 == 0) temp += (i - B) / 2;
            else temp += (i - B) / 2 + 2;
        } else {
            temp += B - i;
        }
        if (C < i) {
            if ((i - C) % 2 == 0) temp += (i - C) / 2;
            else temp += (i - C) / 2 + 2;
        } else {
            temp += C - i;
        }
        if (temp < MIN) MIN = temp;
    }

    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nitro ios_base::sync_with_stdio(false);cin.tie(0);
#define l  long
#define ll  long long
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
int main()
{
     nitro
     int n,d,c=0;cin>>n>>d;
     while(n>0)
     {
         n-=(2*d+1);
         c++;
     }
     cout<<c;
     return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var n int32
	fmt.Scan(&n)
	var str string
	fmt.Scan(&str)

	for _, v := range str {
		changed := v + n
		if changed > 90 {
			changed = changed - 26
		}
		fmt.Print(string(changed))
	}
	fmt.Println()
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int func(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }
  return sum;
}
int main(){
  int n,a,b; cin>>n>>a>>b;int sum=0;
  for(int i=1;i<=n;i++){
  
    if(a<=func(i)&&func(i)<=b)sum+=i;
  }
  cout <<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define db double
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define inf LONG_LONG_MAX
#define inf1 INT_MAX
using namespace std;
/*
ll mpow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=mpow(a,b/2);
    temp=(temp*temp)%mod;
    if(b%2)
        return (a*temp)%mod;
    return temp;
}

ll _pow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=_pow(a,b/2);
    temp=(temp*temp);
    if(b%2)
        return (a*temp);
    return temp;
}

ll mod_in(ll n){
    return mpow(n,mod-2);
}
*/
int main()
{
    fastio
    ll n;
    cin>>n;
    ll a[n];
    ll i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(i=2; i<n; i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
a,b,c = [input() for _ in range(3)]
i,j,k = 0,0,0
turn = 'a'

while(True):
    if turn=='a':
        if i>=len(a): break
        turn = a[i]
        i+=1
    elif turn=='b':
        if j>=len(b): break
        turn = b[j]
        j+=1
    else:
        if k>=len(c): break
        turn = c[k]
        k+=1
        
print(turn.upper())

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, w;
    cin >> n >> w;
    vector<int> weight(n + 1), value(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    //whenever bidirectional
    //sol of knapsack with n items when max weight is w
    long long dp[n + 1][w + 1];
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            dp[i][j] = max((weight[i] <= j ? value[i] + dp[i - 1][j - weight[i]] : 0), dp[i - 1][j]);
        }
    }
    cout << dp[n][w];
}

Measured memory_bytes: 79104
package main

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

var (
	x, y int
)

func main() {
	x = readi()
	y = readi()

	for i := 0; i <= x; i++ {
		turu := i
		kame := x - i
		if y == (turu*2 + kame*4) {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

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

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

// func searchInts(a []int, k int) int {
// 	return binarySearch(len(a), func(i int) bool {
// 		return a[i] >= k
// 	})
// }

func binarySearch(n int, f func(int) bool) int {
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if !f(h) {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 1756
import math
n = int(input())
l = [int(i) for i in input().split()]

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義
s = gcd(l[0],l[1])
for i in l:
    s = gcd(s,i)
   

print(s)

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

int main(){
  int N,X,ans=0;
  cin >> N >> X;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
    X -= vec[i];
    ans++;
  }
  sort(vec.begin(),vec.end());
  if(X == 0){
    cout << ans << endl;
    return 0;
  }
  for(int i=0; X >= 0; X -= vec[0]){
    ans++;
  }
  cout << ans-1 << endl;
} 


Measured memory_bytes: 3620
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;




#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200007
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll a[N],b[N];


int main()
{
    ll n,i,ok=0,cnt=0;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cnt+=(n-1)/i;
    }
    //cnt+=(n-(n+1)/2);
    cout<<cnt<<endl;
    //main();
    return 0;
}





















Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	int result = s.compare(t);
	if(result < 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
int n,m,l,r;
int a[5];
void input(){
	rep(i,4)scanf("%1d",&a[i]);
}
vector<char>ans;
void dfs(int pos,int now,vector<char>t){
/*	rep(i,t.size()){
		cout<<t[i];
	}*/
	//cout<<now<<endl;
	if(pos>=3){
		if(now==7){
			ans=t;
		//	p("aaa")
		}
		return ;
	}
	t.pb('+');
	dfs(pos+1,now+a[pos+1],t);
	t.pop_back();
	t.pb('-');
	dfs(pos+1,now-a[pos+1],t);
	t.pop_back();
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	vector<char>m;
	dfs(0,a[0],m);
	if(ans.size()!=0){
		rep(i,3){
			cout<<a[i]<<ans[i];
		}
		cout<<a[3];
		cout<<'='<<'7'<<endl;
	}

	return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    int c = int.Parse(input[2]);
    int d = int.Parse(input[3]);
    
    if(a * b <= c * d) Console.WriteLine(c * d);
    else Console.WriteLine(a * b);
  }
}

Measured memory_bytes: 13140
n=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(n[k-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){   
   ll n,cnt = 0;
   string s;
   cin>>n>>s;
   rep(i,n-2){
       if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')cnt++;
   }
   cout<<cnt<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string S;
  cin >> S;
  int ans=0;
  for(int i=0;i < S.size();++i){
  if(S.at(i) != S.at(S.size() -1 -i))
     ans++;
     
  
  }
cout << ans/2 << endl;
}

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

int main() 
{
    int d, n;
    cin >> d >> n;
    if (n==100 && d==0)
        cout << 101;    
    else if (n==100 && d==1)
        cout << 10100;
    else if (n==100 && d==2)
        cout << 1010000;
    else
        cout << n*pow(100,d);    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Dice dice;
	void run(){
		Scanner s = new Scanner(System.in);
		int[] num = new int[6];
		for(int i = 0;i < num.length;i++){
			num[i] = s.nextInt();
		}
		dice = new Dice(num);
		int q = s.nextInt();
		for(int i = 0 ; i < q ; i++){
			int top = s.nextInt();
			int front = s.nextInt();
			dice.label = dice.replaceLabel(top, front);
			//System.out.println(i+ "回目");
			//System.out.println(top + ":" + front);
			dice.printLabel(2);
		}
	}
	public static void main(String args[]){
		new Main().run();
	}
}

class Dice {
	static final int labelNum = 6;
	int[] label;
	Dice(int[] num){
		label = new int[labelNum];
		for(int i = 0;i < labelNum;i++)
			label[i] = num[i];
	}
	
	int[] roll(String pro){
		int[] dice = new int[labelNum];
		switch(pro.hashCode()){
			case 69://E->3
				dice[0] = this.label[3];
				dice[1] = this.label[1];
				dice[2] = this.label[0];
				dice[3] = this.label[5];
				dice[4] = this.label[4];
				dice[5] = this.label[2];
				break;
			case 78://N->5
				dice[0] = this.label[1];
				dice[1] = this.label[5];
				dice[2] = this.label[2];
				dice[3] = this.label[3];
				dice[4] = this.label[0];
				dice[5] = this.label[4];
				break;
			case 83://S->2
				dice[0] = this.label[4];
				dice[1] = this.label[0];
				dice[2] = this.label[2];
				dice[3] = this.label[3];
				dice[4] = this.label[5];
				dice[5] = this.label[1];
				break;
			case 87://W->4
				dice[0] = this.label[2];
				dice[1] = this.label[1];
				dice[2] = this.label[5];
				dice[3] = this.label[0];
				dice[4] = this.label[4];
				dice[5] = this.label[3];
				break;
			default:
				break;
		}
		return dice;
	}
	/*
	int searchIndex(int label){
		int i;
		for(i=0;i<6;i++){
			if(label == this.label[i])break;
		}
		return i;
	}
	*/
	int[] replaceLabel(int top,int front){
		int[] dice = this.label;
		while(true){
			if(top == dice[0]&&front == dice[1])break;
			for(int i = 0 ; i < 5;i++){
				if(top == dice[0])break;
				int tmp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = tmp;
			}
			for(int i = 0 ; i < 5;i++){
				if(front == dice[1])break;
				int tmp = dice[4];
				dice[4] = dice[3];
				dice[3] = dice[1];
				dice[1] = dice[2];
				dice[2] = tmp;
			}
		}
		return dice;
	}	
	void print(){
		for(int i = 0;i<this.label.length;i++){
			System.out.println(this.label[i]);
		}
	}
	void printTop(){
		System.out.println(this.label[0]);
	}
	void printLabel(int index){
		System.out.println(this.label[index]);
	}

}

Measured memory_bytes: 26132
using System;
using System.Linq;
using System.Collections.Generic;

class Mondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(n => Int32.Parse(n)).ToArray();
        var N = line[0];
        var M = line[1];
        var min = int.MinValue;
        var max = int.MaxValue;
        for (int i=0;i<M;++i)
        {
            var card = Console.ReadLine().Split(' ').Select(n => Int32.Parse(n)).ToArray();
            if (min < card[0]) min = card[0];
            if (card[1] < max) max = card[1];
        }
        var ans = 0;
        if(0<=max-min) ans = max - min + 1;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17456
# %%
s = int(input())


# %%
def a_n(a_n_1):
    if a_n_1 % 2 == 0:
        return a_n_1 // 2
    else:
        return 3 * a_n_1 + 1


# %%
a = [s]
m = 1
a_n_1 = s

while (a_n_1 not in a[:m - 1]):
    a_n_1 = a_n(a_n_1)
    a.append(a_n_1)
    m += 1
else:
    print(m)


Measured memory_bytes: 2940
#include<iostream>
#include<utility>

using namespace std;

int main(){
	int N, M, *A;
	int i, j;
	cin >> N >> M;
	A = new int[N + 1];
	for(i = 1; i <= N; i++) cin >> A[i];
	for(i = 1; i <= M; i++){
		for(j = 1; j <= N; j++){
			if(1 <= j && j <= N - 1){
				if(A[j] % i >  A[j + 1] % i){
					swap(A[j], A[j + 1]);
				}
			}
		}
	}
	for(i = 1; i <= N; i++){
		cout << A[i] << endl;
	}
	return 0;
}

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

class Jud
{
public:
    int a1=0;
    int calc(int n){

    for(int i=1;i<n+1;i++){
    a1+=i;
    }
    return a1;
    }
        
};
void solve(){
    Jud jud;
    int a,b,c,ori,ans;
    cin>>a>>b;
    c=b-a;
    ori=jud.calc(c);
    ans=ori-b;
    cout<<ans<<endl;
}

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

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

using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define floot10 cout<<fixed<<setprecision(10)

signed main(){
  int x,y;
  cin>>x>>y;
  while(1){
    int xmemo;
    xmemo=x%y;
    if(xmemo==0){
      cout<<y<<endl;
      break;
    }
    x=y;
    y=xmemo;
  }
  return 0;
}



Measured memory_bytes: 3088
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()

    println(if ((1..b).map { it * a }.any {it % b == c }) "YES" else "NO")
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int n,m,k;
  cin >> n >> m >> k;
  vi a(n),b(m);
  rep(i,n)cin >> a[i];
  rep(i,m)cin >> b[i];

  int ac = 0,bc = 0;
  while(ac < n){
    if(a[ac] > k)break;
    k -= a[ac];
    ac++;
  }
  while(bc < m){
    if(b[bc] > k)break;
    k -= b[bc];
    bc++;
  }

  int ret = ac+bc;
  while(ac > 0 && bc < m-1){
    k += a[ac-1];
    ac--;
    while(bc < m){
      if(b[bc] > k)break;
      k -= b[bc];
      bc++;
    }
    ret = max(ret, ac + bc);
  }

  cout << ret << endl;
}

Measured memory_bytes: 4724
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int s = Integer.parseInt(scan.next());
		int w = Integer.parseInt(scan.next());
		if (s<=w){
			System.out.print("unsafe");
		}else{
			System.out.print("safe");
		}


	}
}
//end


Measured memory_bytes: 35688
import java.util.Scanner;
 
class Node{
    int id;
    int parent, left, right;
    public Node(int id){
        this.id = id;
        this.parent = -1;
        this.left = -1;
        this.right = -1;
    }
}
class Nodes{
    Node[] nodes;
    public int getDepth(int id){
        int d = 0;
        int u = nodes[id].parent;
        while(u != -1){
            u = nodes[u].parent;
            d++;
        }
        return d;
    }
    public void printChildren(int id){
        int c = nodes[id].left;
        while(c!=-1){
            System.out.print(c);
            c = nodes[c].right;
            if(c!=-1) System.out.print(", ");
        }
    }
    public void printNode(int id){
        System.out.print("node " + id + ": ");
        System.out.print("parent = " + nodes[id].parent + ", ");
        System.out.print("depth = " + getDepth(id) + ", ");
        if(nodes[id].parent == -1)
            System.out.print("root, ");
        else if(nodes[id].left == -1)
            System.out.print("leaf, ");
        else
            System.out.print("internal node, ");
        System.out.print("[");
        printChildren(id);
        System.out.println("]");
    }
}
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
         
        Nodes mynodes = new Nodes();
        Node[] nodes = new Node[n];
        mynodes.nodes = nodes;
        for(int i = 0;i<n;i++){
            nodes[i] = new Node(i);
        }
        int l = 0;
        for(int i=0;i<n;i++){
            int id = in.nextInt();
            int k = in.nextInt();
            for(int j=0;j<k;j++){
                int c = in.nextInt();
                if(j==0){
                    nodes[id].left = c;
                }
                else 
					nodes[l].right = c;
                l = c;
                nodes[c].parent = id;
            }
        }
        for(int j=0;j<n;j++){
            mynodes.printNode(j);
        }
    }
}

Measured memory_bytes: 135748
import java.util.Scanner;
public class Main{
	
	private static int N_MAX = 100;
	
	static int[] a = new int[N_MAX];

public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		int n;
		n = scan.nextInt();
		int ans = 0;
		for (int i = 0; i < n; i++){
			a[i]= scan.nextInt();
			
		}
		for(int i = 0; i< n; i++){
			int mini = i;
			for (int j = i; j < n; j++){
				if(a[j] < a[mini]){
					mini = j;
				} else {}
				
			}
			if (i != mini){
				ans++;
				int hold = a[i];
				a[i] = a[mini];
				a[mini] = hold;
			}
		}
		
		for (int k = 0; k < n - 1; k++){
			System.out.printf(a[k] + " ");
		}
		System.out.println(a[n-1]);
		System.out.println(ans);
	
}
}



Measured memory_bytes: 26456
N, L = map(int, input().split())
name = [i for i in range(1, N+1)]
all_taste = [j + L -1 for j in name]
all_sum = sum(all_taste)
if 0 in all_taste:
  print(all_sum)
else:
  abs_li = [abs(k) for k in all_taste]
  mi = min(abs_li)
  if not mi in all_taste:
    mi = -1 * mi
  print(all_sum - mi)

Measured memory_bytes: 3060
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def prepare(n, mod=pow(10, 9) + 7):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= mod
        factorials.append(f)
    inv = pow(f, mod - 2, mod)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= mod
        invs[m - 1] = inv

    return factorials, invs


# 実装を行う関数
def resolve(test_def_name=""):
    n, k = map(int, input().split())

    # 逆数を求める
    fns, invs = prepare(pow(10, 6))

    # 計算
    ans = 0
    for i in range(1, min(n - 1, k) + 1):
        # (fns[n] * invs[i] * invs[n - i]) 0の部屋パターン数
        # (fns[n - 1] * invs[i] * invs[n - 1 - i])  移動先数(重複組み合わせで求める。)
        ans += (fns[n] * invs[i] * invs[n - i]) * (fns[n - 1] * invs[i] * invs[n - 1 - i]) % (pow(10, 9) + 7)
        ans = ans % (pow(10, 9) + 7)

    # ALL1のパターンを考慮して+1した結果を出力。
    print(ans + 1)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 2"""
        output = """10"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """200000 1000000000"""
        output = """607923868"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """15 6"""
        output = """22583772"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 161432
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var s = Console.ReadLine();
        var next = "";
        switch (s)
        {
            case "Sunny":
                next = "Cloudy";
                break;
            case "Cloudy":
                next = "Rainy";
                break;
            case "Rainy":
                next = "Sunny";
                break;
        }

        Console.WriteLine(next);
    }
}

Measured memory_bytes: 11092
nk = input().split(" ")
n = int(nk[0])
k = int(nk[1])
p = input().split(" ")
for i in range(n):
    p[i] = int(p[i])

max = 0
for i in range(k):
    max += p[i]

tmp = max
for i in range(1, n+1-k):
    tmp -= p[i-1]
    tmp += p[i+k-1]
    if max < tmp:
        max = tmp

print(k+(max-k)/2)


Measured memory_bytes: 17316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
int main(){
    vi y(2),m(2),d(2);
    rep(i,2){
        cin>>y[i]>>m[i]>>d[i];
    }
    if(y[0]==y[1]){
        if(m[0]==m[1]&&d[0]==d[1])dame(0);
        dame(1);
    }
    ll a=0,b=1;
    if(y[0]>y[1])swap(a,b);
    ll ans=y[b]-y[a];
    if(m[b]>m[a])ans++;
    if(m[b]==m[a]&&d[b]>d[a])ans++;
    out(ans);
}


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

int main() {

	ll k, a, b;
	cin >> k >> a >> b;

	if(b-a <= 2){
		cout << k+1 << endl;
	}
	else{
		ll ans = a;	// aまでビスケット叩く

		int t = (k-a+1) / 2;
		ans += (b-a) * t;

		if((k-a+1) & 1) ans++; //最後奇数なら

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256