akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li n;
li a[55];

int main() {
    cin >> n;
    li maa = 0;
    li mai = -1;
    rin{
        cin >> a[i];
        if (abs(a[i]) > maa) {
            maa = abs(a[i]);
            mai = i;
        }
    }
    if (mai < 0) {
        puts("0");
        return 0;
    }
    cout << n * 2 - 1 << endl;
    rin{
        if (i == mai) {
            continue;
        }
        cout << mai + 1 << " " << i + 1 << endl;
    }

    if (a[mai] > 0) {
        cout << mai + 1 << " " << 1 << endl;
        rep(i, n - 1) {
            cout << i + 1 << " " << i + 2 << endl;
        }
    } else {
        cout << mai + 1 << " " << n << endl;
        for (li i = n - 2; i >= 0; i--) {
            cout << i + 2 << " " << i + 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const int N = 100010;
const int M = 110;
const int mod = 1e9 + 7;
ll f[N][M]; //f[i][j] i-bit的数数位之和%d等于j的个数
string num;
int d;

void init() {
    f[0][0] = 1;
    for(int i = 1; i <= num.size(); i ++) {
        for(int j = 0; j < d; j ++) {
            for(int bit = 0; bit < 10; bit ++) {
                f[i][j] += f[i-1][(10*d+j-bit) % d];
                f[i][j] %= mod;
            }
        }
    }
}

ll dp() {
    vector<int> nums;
    ll cnt = 0;
    ll last = 0; // 前缀信息；
    for(int i = num.size() - 1; i >= 0; i --) nums.push_back(num[i] - '0');
    for(int i = num.size() - 1; i >= 0; i --) {
        int curr = nums[i]; //当前位；
        if(curr > 0) {
            for(int digit = 0; digit < curr; digit ++) {
                cnt += f[i][(10*d - digit - last) % d];
                cnt %= mod;
            }
        }
        last += curr;
        last %= d;
    }
    if(last % d == 0) cnt ++;
    return cnt % mod;
}

int main() {
    cin >> num >> d;
    init(); //计算f
    cout << (dp() - 1 + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N;
    cin >> N;
    vector<ll> x(N),y(N),h(N);
    rep(i,N){
        cin >> x[i] >> y[i] >> h[i];    
    }

    bool flag = true;
    rep(a,101){
        rep(b,101){
            ll L = 0;
            ll R = 1e18;
            while(L+1 < R){
                ll X = (L+R)/2;
                ll flag = -1;
                rep(i,N){
                    if(max(X - abs(x[i]-a) - abs(y[i]-b),ll(0)) < h[i]){
                        flag = 1;
                        break;
                    }else if(max(X - abs(x[i]-a) - abs(y[i]-b),ll(0)) > h[i]){
                        flag = 0;
                        break;
                    }
                }
                if(flag == -1){
                    cout << a << " " << b << " " << X << endl;
                    return 0;
                }else if(flag == 1){
                    L = X;
                }else{
                    R = X;
                }
            }
        }
    }
    //cout << cnt << endl;
}

Measured memory_bytes: 256
INF = 10 ** 20

m, n = map(int, input().split())
manju_lst = [int(input()) for i in range(m)]
manju_lst.sort(reverse=True)

acc = 0
cum_sum = [0]
for manju in manju_lst:
  acc += manju
  cum_sum.append(acc)

clst = []
elst = []

for i in range(n):
  c, e = map(int, input().split())
  clst.append(c)
  elst.append(e)

dp = [[INF] * (m + 1) for _ in range(n)]
for i in range(n):
  dp[i][0] = 0

#dp[x][y]...x種類目までの箱でy個以下売る時の最小コスト
#dp[x][y] = min(dp[x - 1][y], dp[x - 1][y - cx] + ex) if (y - cx >= 0) else min(dp[x - 1][y], dp[x - 1][y + 1])

for x in range(n):
  cx = clst[x]
  ex = elst[x]
  for y in range(m, 0, -1):
    if y >= cx:
      dp[x][y] = min(dp[x - 1][y], dp[x - 1][y - cx] + ex)
    else:
      if y + 1 <= m:
        dp[x][y] = min(dp[x - 1][y], dp[x][y + 1])
      else:
        dp[x][y] = min(dp[x - 1][y], ex)

print(max([cum_sum[x] - dp[n - 1][x] for x in range(m + 1)]))


Measured memory_bytes: 61340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int answer[] = new int[n];

		for (int i = 1; i < n; i++) {
			for (int j = i + 1; j <= n; j++) {
				int calc = Math.min(Math.abs(x - i) + Math.abs(y - j) + 1, j - i);
				answer[calc]++;
			}
		}

		for (int i = 1; i < n; i++) {
			System.out.println(answer[i]);
		}
		sc.close();

	}
}

Measured memory_bytes: 22100
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int n;cin>>n;
  string str="null";
  int s=0;
  string sl,sr;
  int t=n-1;
  cout<<0<<endl;
  cin>>sl;
  cout<<n-1<<endl;
  cin>>sr;
  if(sl=="Vacant"||sr=="Vacant")goto FINE;
  while(str!="Vacant"){
    int mid=(s+t)/4;
    mid*=2;
    if(mid==s)mid++;
    cout<<mid<<endl;
    cin>>str;
    if(str==sl){
      s=mid;
    }
    else{
      t=mid;
    }
  }
  FINE:
  return 0;
}

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

typedef long double ld;

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
	ll x;
	cin>>x;
	
	ll co = 0;
	
	ll val = x/500;
	
	co = 1000*val;
	
	x = x%500;
	
	val = x/5;
	
	co += val*5;
	
	cout<<co;	
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n,h,w;
	while(~getIII(n,h,w)){
		int ans=0;
		while(n--){
			VgetII(h1,w1);
			if(h1>=h&&w1>=w) ans++;
		}
		printf("%d\n",ans);
	}
}


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

int digit(int C, int d);
int f(int C);

int A, B, j=0;

int main() {
  cin >> A >> B;
  int times = B-A+1;
  for (int i=0; i<times; i++){
    j += f(A);
    A++;
  }
  cout << j << endl;
}

int digit(int C, int d){
  int x=0, y=1;
  for(int i=0; i<d; i++){
    x = (C%(y*10) -x)/y;
    y *= 10;
  }
  return x;
}

int f(int C){
  bool i;
  if(digit(C, 1) == digit(C, 5) && digit(C, 2) == digit(C, 4)){
    i = 1;
  } else {
    i = 0;
  }
  return i;
}

Measured memory_bytes: 3616
#include<cstdio>

int N;

int  main()
{
	scanf("%d",&N);
	int res = N;

	for(int i=0;i<=N;i++)
	{
		int cc=0;
		int t=i;
		while(t>0)cc+=t%6,t/=6;
		t=N-i;
		while(t>0)cc+=t%9, t/=9;

		if(res>cc)res = cc;
	}

	printf("%d\n",res);

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    
    vector<int> C(N);
    REP(i, 0, N) cin >> C[i];

    unordered_map<int, int> last;
    vector<int> next(N);
    for (int i = N - 1; i >= 0; i--) {
        if (last.count(C[i])) next[i] = last[C[i]];
        else next[i] = -1;
        last[C[i]] = i;
    }

    ll dp[N + 1] = {}; dp[N] = 1;
    for (int i = N - 1; i >= 0; i--) {
        dp[i] = (dp[i] + dp[i + 1]) % MOD;
        if (next[i] != -1 && (i < N - 1 && C[i] != C[i + 1])) dp[i] = (dp[i] + dp[next[i]]) % MOD;
    }

    cout << dp[0] << endl;

    return 0;
}

Measured memory_bytes: 11592
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<stdlib.h>
using namespace std;

int n,k;
int X,Y;

class Cor{
public:
	int x,y;
	Cor(int x,int y):x(x),y(y){}
	bool operator == (const Cor &a){
		if(a.x==x && a.y==y) return true;
		return false;
	}
};

bool operator < (Cor a,Cor b){
	if(a.x!=b.x) return a.x<b.x;
	return a.y<b.y;
}

set<Cor> Rock;
set<vector<Cor> > Done;
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};

bool is_next(Cor a,Cor b){
	for(int r=0;r<6;r++){
		if(a.x+dx[r]==b.x && a.y+dy[r]==b.y) return true;
	}
	return false;
}

bool check(vector<Cor> snake,int pos){ //posまで確定
	if(Rock.count(snake[pos]))return false;
	for(int i=0;i<pos-1;i++){
		if(is_next(snake[i],snake[pos])) return false;
		if(snake[i]==snake[pos]) return false;
	}
	
	if(pos-1>=0 && !is_next(snake[pos-1],snake[pos])) return false;
//	if(pos+1<snake.size() && !is_next(snake[pos],snake[pos+1])) return false;
	return true;
}

bool connect(const vector<Cor> &snake,int pos){
	if(pos!=0){
		if(!is_next(snake[pos],snake[pos-1])) return false;
	}
	if(pos!=snake.size()-1){
		if(!is_next(snake[pos],snake[pos+1])) return false;
	}
	return true;
}

class state{
public:
	int cost;
	vector<Cor> snake;
	state(vector<Cor> snake,int cost):cost(cost),snake(snake){}
};

queue<state> Q;
void make_snake(vector<Cor> &snake,int pos,int cost){
	if(pos>=snake.size()){
		if(!Done.count(snake)){
			Done.insert(snake);
			if(check(snake,snake.size()-1))
				Q.push(state(snake,cost));
		}
		return;
	}

	for(int r=0;r<6;r++){
		snake[pos].x+=dx[r]; snake[pos].y+=dy[r];
		if(!Rock.count(snake[pos])){
			if(pos+1>=snake.size() || is_next(snake[pos],snake[pos+1]) )
				if(check(snake,pos) )
					make_snake(snake,pos+2,cost);
		}
		snake[pos].x-=dx[r];snake[pos].y-=dy[r];
	}
	if(check(snake,pos))
		make_snake(snake,pos+1,cost);
}

int bfs(vector<Cor> first){
	Done.clear();
	Q=queue<state>();
	Q.push(state(first,0));
	Done.clear();

	while(!Q.empty()){
//		cout<<"size "<<Q.size()<<endl;

		state now=Q.front();Q.pop();
		if(now.snake[0].x==X && now.snake[0].y==Y) return now.cost;
		if(abs(now.snake[0].x-X)>20-now.cost || abs(now.snake[0].y-Y)>20-now.cost) continue;
		make_snake(now.snake,0,now.cost+1);
	}
	return -1;
}


int main()
{
	while(cin>>n && n!=0){
		Rock.clear();
		Done.clear();
		vector<Cor>S;
		for(int i=0;i<n;i++){
			int x,y; cin>>x>>y; S.push_back(Cor(x,y));
		}
		cin>>k;
		for(int i=0;i<k;i++){
			int x,y;cin>>x>>y;Rock.insert(Cor(x,y));
		}
		cin>>X>>Y;
		cout<<bfs(S)<<endl;;
	}
	return 0;
}

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

using namespace std;

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

    long n;
    cin >> n;
    char s[n];
    // cin >> s;
    scanf("%s", &s);
    long right_e = 0;
    for (long i = 1; i < n; i++) right_e += (s[i] == 'E');
    long min_count = right_e;
    // long left_w = 0;
    for (long i = 1; i < n; i++) {
        if (!min_count) break;
        right_e -= s[i] == 'E';
        right_e += s[i - 1] == 'W';
        min_count = min(min_count, right_e);
    }
    // cout << min_count << endl;
    cout << min_count << '\n';

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
using namespace std;

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 0; i < s.length();i++) {
		if ((s[i]+n)>'Z') {
			s[i] = s[i] + n - 26;
		}
		else {
			s[i] = s[i] + n;
		}
	}
	cout << s;
}

Measured memory_bytes: 256
fizzBuzz = []
inputNumber = int(input())
for i in range(inputNumber + 1):
    if i % 3 == 0 and i % 5 == 0:
        metCondition = 'FizzBuzz'
    elif i % 5 == 0:
        metCondition = 'Buzz'
    elif i % 3 == 0:
        metCondition = 'Fizz'
    else:
        metCondition = i
    fizzBuzz.append(metCondition)
metCondition_2 = [num for num in fizzBuzz if isinstance(num, (int, float))]
print(sum(metCondition_2))

Measured memory_bytes: 37864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
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 a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    double L;cin >> L;

    cout << fixed << setprecision(10) << L * L * L / 27.0 << endl;
}


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

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

  cout<<abs(a-b)+abs(b-c)+abs(c-a)-max({abs(a-b),abs(b-c),abs(c-a)})<<endl;
}


Measured memory_bytes: 256
def bounding(N: int, X: int, L: list)->int:
    D = [0] * (N+1)
    for i, l in enumerate(L):
        D[i+1] = D[i] + l

    l, r = 0, N+1
    while r-l > 1:
        m = (l+r)//2
        if D[m] <= X:
            l = m
        else:
            r = m

    return r


if __name__ == "__main__":
    N, X = map(int, input().split())
    L = [int(s) for s in input().split()]

    ans = bounding(N, X, L)
    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b;
  
  if(a+b<10) co(a+b);
  else co("error");
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

int a[110];

void solve(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    
    rep(i,n-1){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;

    rep(i,n){
        if(i==0) continue;
        int key = a[i];
        int j=i-1;
        while(j>=0&&a[j]>key){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=key;

        rep(i,n-1){
        cout << a[i] << " ";
        }
        cout << a[n-1] << endl;
    }
    
}

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



Measured memory_bytes: 3124
n,a,b = map(int,input().split())
if n == 1:
    if a==b:
        print("1")
    else:
        print("0")
else:
    low = (n-2)*a + a + b 
    high = (n-2)*b + a + b 
    ans = max(0,high-low+1)
    print(ans)

Measured memory_bytes: 3060
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
const ll MAX_N = 1e5;
ll N;
ll h[MAX_N];
ll dp[MAX_N+1]; // メモ化テーブル
 
// i番目以降の品物から重さの総和がj以下になるように選ぶ
void rec(ll i){
	if (i==0) dp[i] = 0;
	else if (i==1) dp[i] = abs(h[1]-h[0]);
	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	return;
}

int main() {
	// 入力
	ll a;
	cin >> a;
	ll ans = pow(a, 2) * 3;
	printf("%lld\n", ans);
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;


int main(void)	
{
	ll a, b;
	cin >> a >> b;
	for (int i = 0; i < 10000; i++) {
		ll da = i * 8 / 100;
		ll db = i * 10 / 100;
		if (a == da && b == db) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 256
N, K, Q = list(map(int, input().split(' ')))
yes = 'Yes'
no = 'No'

# 誰が何回正解したか保存
A = [0] * N
for i in range(Q):
  a = int(input()) - 1
  A[a]+=1

# K + (正解した回数) - Q > 0 ならYes
for a in A:
  if K + a - Q > 0:
    print(yes)
  else:
    print(no)

Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define M 1000000007
#define N 100001
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll t, n;

int main() {
    //scanf("%d", &t);
    t = 1;
    while(t--) {
        scanf("%lld", &n);  
        if(n == 1) {
            printf("0\n");
            return 0;
        }

        ll ans = 1, only0 = 1, only9 = 1, no0_no9 = 1;
        for(int i=0; i<n; i++) {
            ans = (ans * 10LL) % M;   // total
            only0 = (only0 * 9LL) % M;
            only9 = (only9 * 9LL) % M;
            no0_no9 = (no0_no9 * 8LL) % M;
        }
        
        only0 = (only0 - 1 + M) % M;   // no 0
        only9 = (only9 - 1 + M) % M;   // no 9
        
        ll temp = (only0 + only9) % M;
        temp = (temp - no0_no9 + M) % M;
        ans = (ans - temp - 2LL + M) % M;

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


Measured memory_bytes: 3812
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int main() {
	// your code goes here
	int num;
	cin>>num;
	string s = to_string(num);
	int ans=0;
	for(char c:s)
	{
	    ans+=(c-'0');
	    
	}
	if(num%ans==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(ll i=0;i<(int)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(int)(n);i++)
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; }
typedef long long ll;
typedef pair<ll,ll> pint;
const long long INF = 1LL<<60;
const ll MOD = 1000000007;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
int main(){
    ll n;cin>>n;
    vector<ll> T(n);rep(i,n)cin>>T[i];
    vector<ll> A(n);rep(i,n)cin>>A[i];
    vector<ll> tamin(n,0);
    vector<ll> ans(n,0);
    bool flag=false;
    tamin[0]=T[0];
    rep(i,n-1){
        if(flag)break;
        if(T[i]!=T[i+1]){
            tamin[i+1]=T[i+1];
            if(A[i]<T[i+1]){
                flag=true;
                cout<<0<<endl;
                break;
            }
        }
    }
    if(tamin.back()!=0&&tamin.back()!=A.back()){
        cout<<0<<endl;
        flag=true;
    }
    else if(tamin.back()==0){
        tamin[n-1]=A[n-1];
    }
    rep(i,n-1){
        if(flag) break;
        ll m = n-1-i;
        if(A[m]!=A[m-1]){
            if(tamin[m-1]==0){
                tamin[m-1]=A[m-1];
                if(A[m-1]>T[m-1]){
                    flag=true;
                    cout<<0<<endl;
                    break;
                }
            }
            else if(A[m-1]!=tamin[m-1]){
                cout<<0<<endl;
                flag=true;
            }
        }
    }
    if(! flag){
        ll res=1;
        rep(i,n){
            //cout<<tamin[i];
            if(tamin[i]==0){
                res*=min(T[i],A[i])%MOD;
                res%=MOD;
            }
        }
        cout<<res%MOD<<endl;
    }
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n>>k;
 ll a[n];
 for (int i = 0; i < n; ++i)
 {
 	cin>>a[i];
 }
 sort(a,a+n);
 for (int i = 0; i < n-k; ++i)
 {
 	c+=a[i];
 }
 c(c);
  
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  ll T=1;
  //cin>>T;
  while(T--){
  solve();
  }
  return 0;
}


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

mt19937_64 llrand(random_device{}());

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define gcd(x, y) __gcd((x), (y))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector<vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

int vis[N];
vi adj[N];
ll dp[N][2];

void dfs (int v) {
    vis[v] = 1;

    dp[v][0] = dp[v][1] = 1;

    for (auto u : adj[v]) if (!vis[u]) {
        dfs(u);

        dp[v][0] *= dp[u][0] + dp[u][1];
        dp[v][0] %= MOD;

        dp[v][1] *= dp[u][0];
        dp[v][1] %= MOD;
    }
}

int n, a, b;

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

    dfs(1);

    printf("%lld\n", (dp[1][0] + dp[1][1]) % MOD);

    return 0;
}

Measured memory_bytes: 11904
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;
using System.Drawing;
using Microsoft.VisualBasic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {


            int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = Arr[0];
            int X = Arr[1];
            int T = Arr[2];

            int ans = 0;

            if (N / X < 1)
            {
                ans = T;
            }
            else if(N / X >= 1 && N % X == 0)
            {
                ans = T * (N / X);
            }
            else if (N / X >= 1 && N % X != 0)
            {
                ans = T * ((N / X) + 1);
            }

            Console.WriteLine(ans);

        }

    }
}


Measured memory_bytes: 28272
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

int main(){
    int n,X[100],Y[100];
    cin >> n;

    for(int i=0;i<n;i++)cin >> X[i];
    for(int i=0;i<n;i++)cin >> Y[i];

    double D1=0;
    for(int i=0;i<n;i++)D1 += fabs(X[i]-Y[i]);

    double D2=0;
    double sum=0;
    for(int i=0;i<n;i++)sum += (fabs(X[i]-Y[i]))*(fabs(X[i]-Y[i]));
    D2 = sqrt(sum);

    double D3=0;
    double sum1=0;

    for(int i=0;i<n;i++)sum1 += pow(fabs(X[i]-Y[i]),3);
    D3 = pow(sum1,1.0/3);
 
    double D[100];
    double D4=0;
    double m=0;

    for(int i=0;i<n;i++)D[i] = fabs(X[i]-Y[i]);
    for(int i=0;i<n;i++){
        
        if(D[i]<m)m = m;
        else if(D[i]>m)m=D[i];
        else if(D[i]=m)m=D[i];

        D4=1.0*m;
    }
    


    printf("%lf\n",D1);
    printf("%lf\n",D2);
    printf("%lf\n",D3);
    printf("%lf\n",D4);

      
    return 0;

}


Measured memory_bytes: 3356
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>


using namespace std;

int H, W;
int A[9][9];

int startY = -1, startX;

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

int dfs(int y, int x) {
  int ret = 0;
  for (int i = 0; i < 2; i++) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (ny < 0 || ny >= H) {
      continue;
    } 
    if (nx < 0 || nx >= W) {
      continue;
    }
    if (A[ny][nx] == 0) {
      continue;
    } else {
      ret = 1 + dfs(ny, nx);
    }
  }

  return ret;
}


int main() {
  cin >> H >> W;
  int count = 0;
  for (int y = 0; y < H; y++) {
    for (int x =  0; x < W; x++) {
      char c;
      cin >> c;
      if (c == '#') {
        A[y][x] = 1;
        if (startY == -1) {
          startY = y;

        }
        count++;
      }  
    }
  }

  int d = 1 + dfs(startY, startX);
  if (d == count) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let a' = Array.init n (fun i -> a.(i)) in
  Array.sort (-) a';
  let m1, m2 = a'.(n/2-1), a'.(n/2) in
  Array.iter (fun e ->
    Printf.printf "%d\n" @@ if e <= m1 then m2 else m1) a

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, X;
int x[100100];

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

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

    std::cin >> N >> X;

    for(int i=0;i<N;++i){
        std::cin >> x[i];
    }

    int g = 0;
    for(int i=0;i<N;++i){
        g = gcd(g, std::abs(x[i] - X));
    }

    std::cout << g << std::endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

typedef pair<double, double> Point;
Point p[3], I;

double distance_of_Point_to_Point(Point A, Point B) { // 点 A と点 B の距離
	return hypot(A.FI - B.FI, A.SE - B.SE);
}

double distance_of_Point_to_Line(Point P, Point A, Point B) { // 点 P と直線 AB の距離
	double a = B.SE - A.SE;
	double b = A.FI - B.FI;
	double c = A.SE * B.FI - A.FI * B.SE;
	// 直線 AB の方程式は ax + by + c = 0
	return abs(a * P.FI + b * P.SE + c) / hypot(a, b);
}

Point triangle_incenter(Point A, Point B, Point C) { // 三角形 ABC の内心の座標
	double a = distance_of_Point_to_Point(B, C);
	double b = distance_of_Point_to_Point(C, A);
	double c = distance_of_Point_to_Point(A, B);
	return MP(
		(a * A.FI + b * B.FI + c * C.FI) / (a + b + c), 
		(a * A.SE + b * B.SE + c * C.SE) / (a + b + c)
	);
}

double f(int a, int b) {
	double l = distance_of_Point_to_Point(p[a], p[b]);
	double h = distance_of_Point_to_Line(I, p[a], p[b]);
	return l / (2.0 + l / h);
}

int main() {
	inc(i, 3) { cin >> p[i].FI >> p[i].SE; }
	
	I = triangle_incenter(p[0], p[1], p[2]);
	
	double ans = 0.0;
	inc(i, 3) { setmax(ans, f(i, (i + 1) % 3)); }
	
	printf("%.12f\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    int odd = 0;
    for (int i = 1; i <= n; i++)
        if (i % 2)
            odd++;
    cout <<(double)odd / n;
}

Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> vs;
    for (int i = 0; i < M; ++i) {
        int s, c;
        cin >> s >> c;
        vs.push_back(make_pair(s, c));
    }


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

        string str = to_string(i);
        if (str.size() != N) {
            continue;
        }
        bool ok = true;
        for (int j = 0; j < vs.size(); ++j) {
            if (str[vs[j].first - 1] - '0' != vs[j].second) {
                ok = false;
            }
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n;
  cin >> n;
  string s="";
  
  while(n>0){
    n--;
    char a=n%26+'a';
    s+=a;
    n/=26;
  }
  reverse(s.begin(),s.end());
  cout << s << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <queue>

using namespace std;
typedef pair<int, int> P;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

int n;
UnionFind uf(100005);
set<int> B[100005], R[100005];
queue<P> Q;

int main(void)
{
	cin >> n;
	int u, v;
	for(int i = 1; i <= n; i++) B[i].insert(0), R[i].insert(0);
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		B[u].insert(v);
		B[v].insert(u);
	}
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		R[u].insert(v);
		R[v].insert(u);
	}
	
	for(int i = 1; i <= n-1; i++){
		for(auto it = B[i].begin(); it != B[i].end(); it++){
			int v = *it;
			if(v == 0) continue;
			if(v > i && R[i].count(v)){
				auto tmp = it; tmp--;
				Q.push(P(i, v));
				R[v].erase(i);
				B[v].erase(i);
				R[i].erase(v);
				B[i].erase(it);
				it = tmp;
			}
		}
	}

	while(Q.size()){
		u = Q.front().first, v = Q.front().second;
		Q.pop();
		if(uf.same(u, v)){
			cout << "NO" << endl;
			return 0;
		}
		u = uf.root(u), v = uf.root(v);
		
		if((int)B[v].size()+(int)R[v].size() > (int)B[u].size()+(int)R[u].size()) swap(u, v);
		for(auto it = B[v].begin(); it != B[v].end(); it++){
			if(*it == 0) continue;
			if(R[u].count(*it)){
				auto tmp = it; tmp--;
				Q.push(P(u, *it));
				R[*it].erase(u);
				B[*it].erase(v);
				R[u].erase(*it);
				B[v].erase(it);
				it = tmp;
			}
		}
		for(auto it = R[v].begin(); it != R[v].end(); it++){
			if(*it == 0) continue;
			if(B[u].count(*it)){
				auto tmp = it; tmp--;
				Q.push(P(u, *it));
				B[*it].erase(u);
				R[*it].erase(v);
				B[u].erase(*it);
				R[v].erase(it);
				it = tmp;
			}
		}
		
		for(auto it = B[v].begin(); it != B[v].end(); it++){
			if(*it == 0) continue;
			B[*it].erase(v), B[*it].insert(u);
			B[u].insert(*it);
			
		}
		for(auto it = R[v].begin(); it != R[v].end(); it++){
			if(*it == 0) continue;
			R[*it].erase(v), R[*it].insert(u);
			R[u].insert(*it);
		}
		uf.unite(v, u);
	}
	
	for(int i = 1; i <= n; i++){
		if(uf.root(1) != uf.root(i)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 38400
import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int q = sc.nextInt();
    	StringBuilder sb = new StringBuilder();
    	UnionFindTree uft = new UnionFindTree(n);
    	for (int i = 0; i < q; i++) {
    	    int type = sc.nextInt();
    	    int a = sc.nextInt();
    	    int b = sc.nextInt();
    	    if (type == 0) {
    	        uft.unite(a, b);
    	    } else {
    	        if (uft.same(a, b)) {
    	            sb.append("1\n");
    	        } else {
    	            sb.append("0\n");
    	        }
    	    }
    	}
   	    System.out.print(sb);
	}
	
	static class UnionFindTree {
	    int[] parents;
	    
	    public UnionFindTree(int size) {
	        parents = new int[size];
	        for (int i = 0; i < size; i++) {
	            parents[i] = i;
	        }
	    }
	    
	    public int find(int x) {
	        if (x == parents[x]) {
	            return x;
	        } else {
	            return parents[x] = find(parents[x]);
	        }
	    }
	    
	    public boolean same(int x, int y) {
	        return find(x) == find(y);
	    }
	    
	    public void unite(int x, int y) {
	        if (!same(x, y)) {
	            parents[find(x)] = find(y);
	        }
	    }
	}
}

Measured memory_bytes: 59908
s = input()

if s[0] != 'A':
    print('WA')
    quit()
s = s[1:]

if 'C' not in s[1 : - 1]:
    print('WA')
    quit()
else:
    s = list(s)
    s.pop(s.index('C'))
    s = ''.join(s)
    if s.lower() != s:
        print('WA')
        quit()
print('AC')

Measured memory_bytes: 3064
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
    }
    let mut ans = 1;

    for i in 0..n {
        if ans <= k {
            ans *= 2
        } else {
            ans += k
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double area,circumference,r;
        double pi = Math.PI;
        r = sc.nextDouble();
        area = Math.pow(r,2) * pi;
        circumference = r*2 *pi;
        System.out.printf("%.10f %.10f\n",area,circumference);


    }
}


Measured memory_bytes: 28228
import numpy as np
import math

N = int(input())

A = np.array(list(map(int,input().split())))

B = np.arange(1,N+1)

dif = np.median(A-B)

# if dif < 0:
#     dif = int(math.floor(dif))
# else:
#     dif = int(round(dif))


ans = int(np.sum(np.abs(A-B-dif)))

print(ans)

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

using namespace std;

int main()
{

	int n;
	cin>>n;
	bool flag=1;
	
	while(n)
	{
		if(n%10==7)
		{
			flag=0;
		}
		n/=10;
	}
	
	if(flag)
		cout<<"No";
		else
		cout<<"Yes";

	
	return 0;

}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int n, h[100005], dp[100005];

int main()
{
    cin >> n;

    for(int i=0; i<n; i++)
    {
        cin >> h[i];
    }

    dp[0] = 0;

    dp[1] = abs(h[0] - h[1]);

    for(int i=2; i<n; i++)
    {
        dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]);

        //cout << dp[i] << endl;
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W,D;
  cin>>H>>W>>D;
  int a[301][301];
  int x[90001],y[90001];
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      cin>>a[i][j];
      x[a[i][j]]=i,y[a[i][j]]=j;
    }
  }
  int S[90001];
  for(int i=1; i<=H*W; i++){
      if(i<D){continue;}
      S[i]=S[i-D]+(abs(x[i-D]-x[i])+abs(y[i-D]-y[i]));
  }
  int Q;
  cin>>Q;
  for(int i=0; i<Q; i++){
    int a,b;
    cin>>a>>b;
    cout<<S[b]-S[a]<<endl;
  }
} 

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  cin >> n;
  double a[n],sum=0;
  rep(i,n) cin >> a[i];
  rep(i,n) sum+=a[i];
  sum/=n;
  double M=MAX;
  ll k=0;
  rep(i,n) {
    double d=fabs(a[i]-sum);
    if(M>d) {
      M=d;
      k=i;
    }
  }
  pr(k);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))
set_d = set(map(int, input().split()))
g = n
while(True):
    set_g = set(str(g))
    set_g = [int(i) for i in set_g]
    for i in set_g:
        if i in set_d:
            g += 1
            break
    else:
        break
print(g)


Measured memory_bytes: 2940
#include<stdio.h>

void main(){
    int hol;
    int num;
    int sum=0;

    scanf("%d",&hol);
    scanf("%d",&num);

    int s=0;

    for(int i=0;i<num;i++){
        scanf("%d",&s);
        sum +=s;
    }

    if(hol < sum){
        printf("-1");
    }else{
        printf("%d",hol-sum);
    }

}

Measured memory_bytes: 1700
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int k;
    cin >> k;
    int ans = 0;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
        if(h.at(i) >= k) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int n; cin>>n;
int cnt[1000001]={0} , cnt2[1000001]={0};
vin A (n);
F (i,0,n,1) {cin>>A[i]; ++cnt2[A[i]];}
sort (fall(A));
if (A[0]==1) {
  if (A[1]!=1) cout<< 1<<endl;
  else cout<<0<<endl;
}
else {
  int ans=0;
  F (i,0,n,1) {
    int j=2 , res=A[i];
    while (res<=A[n-1]) {
      res=A[i]*j;
      cnt[res]=1;
      ++j;
    }
    if (!cnt[A[i]] && cnt2[A[i]]==1) ++ans;
  }
  cout<<ans;
}
return 0;
}


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

int main() {

    ll n , t ,q  , j ;

    string s ;

    cin >> n ;
    ll ans = 0 ;

    while(n) {
        if (n%10==7) ans =1 ;
        n/=10 ;
    }
    cout << (ans==1 ? "Yes\n" : "No\n") ;

    return 0 ;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;
int x, y, n;
vector<int> v;
set<int> sx, sy, t;

int main() {
	cin >> s >> x >> y;
	
	s += "T";
	int c = 0;
	inc(i, s.size()) {
		if(s[i] == 'F') { c++; } else { v.PB(c); c = 0; }
	}
	
	x -= v[0];
	sx.insert(0);
	sy.insert(0);
	incID(i, 1, v.size()) {
		t.clear();
		FOR(it, (i % 2 == 0 ? sx : sy)) {
			t.insert(*it + v[i]);
			t.insert(*it - v[i]);
		}
		swap(t, (i % 2 == 0 ? sx : sy));
	}
	
	cout << (sx.count(x) == 1 && sy.count(y) == 1 ? "Yes": "No") << endl;
	
	return 0;
}


Measured memory_bytes: 768