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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  ll p = (N + 999) / 1000;
  cout << p * 1000 - N << endl;

  return 0;
}



Measured memory_bytes: 3644
n = int(input())
d, x = map(int, input().split())

index=0
while index<n:
    a = int(input())
    index2=0
    while True:
        if 1+a*index2<d+1:
            x+=1
            index2+=1
        else:
            break
    index+=1
print(x)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  int N, S=0;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a[i];
    S+=a[i];
  }
  S=S/N;
  
  int m=0;
  for (int i=0; i<N; i++) {
    m+=abs(S-a[i])*abs(S-a[i]);
  }
  S++;
  int n=0;
  for (int i=0; i<N; i++) {
    n+=abs(S-a[i])*abs(S-a[i]);
  }
  cout << min(m,n) << endl;
  
}

Measured memory_bytes: 3572
#include<iostream>
#include<set>
using namespace std;
int N,K,d,A;
set<int>S;
main()
{
  cin>>N>>K;
  for(;K--;)
  {
    cin>>d;
    for(;d--;)cin>>A,S.insert(A);
  }
  cout<<N-S.size()<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
if      (a>b&&b!=1||a<b&&a==1){
    cout<<"Alice";
}else if(a<b&&a!=1||b<a&&b==1){
    cout<<"Bob";
}else{
    cout<<"Draw";
}
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNING
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <math.h>

// #include <stack>
// #include <queue>
// #include <set>
// #include <tuple>
// #include <list>
// #include <numeric>
// #include <random>
// #include <regex>
// #include <utility>

using namespace std;
const int INF = (int)1e9;

//#define DEBUG

void solution() {
	long long n, a, b, c, d, e;
	vector<long long> v;
	v.resize(5);
	cin >> n >> v[0] >> v[1] >> v[2] >> v[3] >> v[4];
	auto m = std::min_element(v.begin(), v.end());
	cout << v.end() - v.begin() + (long long)std::ceil((double)n / *m) - 1;
	
	//answ: cout << len;
}

int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
	solution();
  return 0;		
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    string s; cin >> s;
    map<string, string> t;
    t["A"] = "T";
    t["T"] = "A";
    t["G"] = "C";
    t["C"] = "G";
    
    cout << t[s] << endl;
    return 0;
}




Measured memory_bytes: 256
import heapq

N=int(input())
A=list(map(int,input().split()))

A.sort(reverse=True)

def condition(num):
    test=A[:num]+A[num+1:]
    s=A[num]
    heapq.heapify(test)
    while test:
        x=heapq.heappop(test)
        if 2*s>=x:
            s+=x
        else:
            return False
    return True

start=0
end=N-1
while end-start>1:
    t=(end+start)//2
    if condition(t):
        start=t
    else:
        end=t

if condition(end):
    print(end+1)
elif condition(start):
    print(start+1)
else:
    print(0)

Measured memory_bytes: 95640
// Problem : C - Count Order
// Contest : AtCoder - AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		int i,n;
		cin>>n;
		vi a(n);
		vi b(n),c(n);
		repf(i,0,n) cin>>b[i];
		repf(i,0,n) cin>>c[i];
		repf(i,0,n) a[i]=i+1;
		int ib,ic;
		int cnt=0;
		do {
			cnt++;
			if(b==a) ib=cnt;
			if(c==a) ic=cnt;
		}while (next_permutation(all(a)));
		cout<<abs(ib-ic);
    }
    return 0;
} 


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

using namespace std;

int main(){
    int n,a[100];
    cin >> n;
    for(int i = 0;i < n;i++)cin >> a[i];
    sort(a,a+n,greater<int>());
    int alice = 0,bob = 0;
    for(int i = 0;i < n;i += 2){
        alice += a[i];
        if(i+1 > n-1)break;
        bob += a[i+1];
    }
    cout << alice - bob;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    switch (n % 10) {
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
        break;
    }
}

Measured memory_bytes: 3604
a = input()
a = list(a)
k = 0
b = []
for i in range(len(a)):
    if any(x in a[i] for x in ('A','T','G','C')):
        k += 1
    else:
        b.append(k)
        k = 0
b.append(k)
print(max(b))

Measured memory_bytes: 3060
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int a = std.nextInt();
        int b = std.nextInt();
        int c = std.nextInt();

        PriorityQueue<Integer> pq = new PriorityQueue<>(3);
        pq.add(a);
        pq.add(b);
        pq.add(c);

        pq.poll();
        int center = pq.poll();
        if (center == c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int n;
int a[3][101];

int main() {
    scanf("%d",&n);
    a[0][0] = 0;
    a[1][0] = 0;

    rep(i,1,3){
        rep(j,1,n+1){
            cin >> a[i][j];
            a[i][j] += max(a[i-1][j],a[i][j-1]);
        }
    }
    pout(a[2][n]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

int main()
{
    int a,b,c,d,e,f;
    int i1,i2,i3,i4,tot,sug;
    cin>>a>>b>>c>>d>>e>>f;
    a*=100;
    b*=100;
    tot=a;
    sug=0;
    for(i1=0;i1<=100;i1++)for(i2=0;i2<=100;i2++)for(i3=0;i3<=100;i3++)for(i4=0;i4<=100;i4++){
        int totwat=i1*a+i2*b;
        int totsug=i3*c+i4*d;
        if(totwat+totsug<=f){
            if(totsug*100<=totwat*e){
                if(sug*(totsug+totwat)<=tot*totsug){
                    sug=totsug;
                    tot=totwat+totsug;
                }
            }
        }
    }
    cout<<tot<<" "<<sug<<endl;
    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

vector<bool> v(100005);
void dfs(int now,int d,vector<int> &t,vector<vector<int>> &to){
	v[now] = 1;
	t[now] = d;
	for(auto next:to[now]){
		if(v[next]==0){
			v[next]=1;
			dfs(next,d+1,t,to);
			v[next]=0;
		}
	}
	v[now] = 0;
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<vector<int>> to(N);
	rep(i,N-1){
		int x,y;
		cin >> x >> y;
		x--;y--;
		to[x].push_back(y);
		to[y].push_back(x);
	}
	vector<int> adis(N);
	vector<int> bdis(N);
	//まずは0からのdisを調べる
	dfs(0,0,adis,to);
	dfs(N-1,0,bdis,to);
	int cnt = 0;
	for(int i=0;i<N;i++){
		if(adis[i]<=bdis[i])cnt++;
	}
	if(cnt>N/2)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}

Measured memory_bytes: 15872
n = int(input())
p = input().split(" ")
a = 0
for i in range(len(p)):
    try:
        pf = p[i]
        ps = p[i+1]
        pt = p[i+2]
        il = [int(pf),int(ps),int(pt)]
        max_p = max(il)
        il.remove(max_p)
        if int(ps) == max(il):
            a += 1
    except:
        pass
print(a)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, ans, x, y, xx, yy, maxx;
	cin >> n >> m;
	vector<string> s(n);
	for (i = 0; i < n; i++) cin >> s[i];
	int v[4][2] = { 1,0,0,1,-1, 0, 0, -1 };

	ans = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (s[i][j] == '#') continue;

			vector<vector<int>> d(n, vector<int>(m, 10000));
			queue<pair<int, int>> q;
			q.push({ i, j });
			d[i][j] = 0;

			maxx = 0;
			while (!q.empty()) {
				x = q.front().first;
				y = q.front().second;
				q.pop();
				maxx = max(maxx, d[x][y]);

				for (k = 0; k < 4; k++) {
					xx = x + v[k][0];
					yy = y + v[k][1];

					if ((xx >= 0) && (xx < n) && (yy >= 0) && (yy < m) && (s[xx][yy] != '#') && (d[xx][yy] == 10000)) {
						d[xx][yy] = d[x][y] + 1;
						q.push({ xx,yy });
					}

				}
			}
			ans = max(ans, maxx);
		}
	}

	cout << ans << "\n";


	return 0;
}


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

int main () {
    int n;
    while (scanf("%d", &n) == 1) {
        vector<int> a(n + 1, 0);
        vector<long long> s(n + 1, 0);
        for (int i = 0; i < n + 1; i++) cin >> a[i];
        for (int i = n ; i >= 0; i--) s[i] = (i == n ? 0 : s[i + 1]) + a[i];

        long long t = 1;
        long long res = 0;
        for (int i = 0; i < n + 1 && res >= 0; i++) {
            if (t < a[i]) res = -1;
            else {
                res += min(t, s[i]);
                t = (t >= 2e18 + 100) ? 2e18 + 100 : 2 * (t - a[i]);
            }
        }
        
        cout << res << "\n";
    }
}



Measured memory_bytes: 4576
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
        String input_line = sc.nextLine();
        double L=Double.parseDouble(input_line);
        System.out.print(Math.pow(L/3.0, 3.0));
	}
 
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	void Solve() {
		UL N; cin >> N;
		bool x1, x2; x1 = x2 = false;
		bool a1 = false;
		int buf; {char c; cin >> c; buf = c - '0'; }
		int even = 0;
		rep(i, N - 1) {
			char c; cin >> c; c -= '0';
			buf = abs(buf - c);
			if (buf == 1) a1 = true;

			if (i != 0) {
				int t = N - i - 1;
				while ((t & 1) == 0) { even++; t >>= 1; }
				t = i;
				while ((t & 1) == 0) { even--; t >>= 1; }
			}
			if (even == 0) {
				if (buf == 1) x1 = !x1;
				if (buf == 2) x2 = !x2;
			}
			buf = c;
		}
		if (x1) cout << 1 << endl;
		else if (a1) cout << 0 << endl;
		else cout << (x2 ? 2 : 0) << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;
 
vector<vector<int> > s;
vector<int> c;

int score(vector<int> held,int k){
    vector<int> ld(26,0);
    int ans=0;
    rep(i,held.size()){
        int t=held[i];
        ld[t]=i+1;
        ans+=s[i][t];
        rep(j,26){
            ans-=c[j]*(k*(1+k)/2+i+1-ld[j]);
        }
    }
    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> cc(26);
    c=cc;
    rep(i,26) cin >> c[i];
    vector<vector<int> > ss(d);
    s=ss;
    rep(i,d)rep(j,26){
        int a; cin >> a;
        s[i].push_back(a);
    }
 
    //vector<int> ld(26,0);
    vector<vector<int> > ds(26);
    vector<int> ans;
    int tmps=-INF;
    rep(p,26){
        vector<int> days(0);
    rep(i,d){
        int now=-INF;
        int whatday;
        rep(j,26){
            vector<int> tmp=days;
            tmp.push_back(j);
            int sc=score(tmp,p);
            if(sc>now){
                whatday=j;
                now=sc;
            }
        }
        days.push_back(whatday);
    }
    int nows=score(days,0);
    if(nows>tmps){
        tmps=nows;
        ans=days;
    }
    }
    rep(i,d) cout << ans[i]+1 << endl;
return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define QOEINDIEDIS freesteed
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int n,k,c; 
string s;
void solve(){
	cin>>n>>k>>c>>s;
	s = '#' + s;
	VI earliest(k+1,0),latest(k+1,0);
	int i=1,j=1;
	while(i<sz(s)&&j<=k){
		if(s[i]=='o'){
			earliest[j++] = i;
			i+=c+1;
		}else{
			i++;
		}
	}
	i=sz(s)-1,j=k;
	while(i>0&&j>=1){
		if(s[i]=='o'){
			latest[j--] = i;
			i-=c+1;
		}else{
			i--;
		}
	}
//	rep(i,1,k+1)cout<<earliest[i]<<" ";cout<<endl;
//	rep(i,1,k+1)cout<<latest[i]<<" ";cout<<endl;
	rep(i,1,k+1)if(earliest[i]==latest[i])cout<<earliest[i]<<"\n";
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}

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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

  rep(i, 0, q) {
    int c, a, n, ans = 0;
    cin >> c >> a >> n;
    int m = min(c, min(a, n));
    c -= m;
    a -= m;
    ans += m;
    m = min(c / 2, a);
    c -= m * 2;
    ans += m;
    ans += c / 3;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;

#define N_MAX   (100000)

typedef long long ll;

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

int main()
{
    // 整数の入力
    int N;
    std::stack<ll> llstack;
    cin >> N;

    for (ll i = 0; i < N; i++) {
        ll num;
        cin >> num;
        llstack.push(num);
    }

    while (true) {
        ll a, b, ans;
        a = llstack.top();
        llstack.pop();
        b = llstack.top();
        llstack.pop();
        ans = calc(a, b);
        llstack.push(ans);
        if (llstack.size() == 1) {
            break;
        }
    }

    cout << llstack.top() << endl;
    return 0;

}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	long long N;
	cin >> N;
	long long * x = new long long[N];
	for (size_t i = 0; i < N; i++)
		cin >> x[i];

	long long* ways = new long long[N];
	
	for (size_t j = 0; j < N; j++)
		ways[j] = 0;
		
	ways[0] = 2;

	long long start = 0;
	for (size_t i = 2; i < N; i++)
	{
		if ((x[i-1]+1)/2 < i - start)
			start++;
		ways[start]++;
	}

	for (size_t i = 1; i < N; i++)
	{
		ways[i] += ways[i-1];
	}

	long long result = ways[0];
	for (long long j = 1; j < N; j++)
	{
		if (ways[j] >= j)
			result = (result * (ways[j] - j)) % 1000000007LL;
	}

	cout << result;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 500050
#define MAXM
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define repd(i, x, y) for(ri i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
int n, k, a[MAXN], b[MAXN], in[MAXN], ans[MAXN], tot, minv[MAXN<<2];
vector <int> adj[MAXN];
priority_queue <int> q;
void build(int u, int l, int r) {
	minv[u] = n+1;
	if(l == r) return ;
	build(u<<1, l, mid), build(u<<1|1, mid+1, r);
}
void modify(int u, int l, int r, int x, int w) {
	minv[u] = w;
	if(l == r) return ;
	if(x <= mid) modify(u<<1, l, mid, x, w);
	else modify(u<<1|1, mid+1, r, x, w);
}
int query(int u, int l, int r, int tl, int tr) {
	if(tl > tr) return n+1;
	if(tl <= l && r <= tr) return minv[u];
	int ret = n+1;
	if(tl <= mid) ret = query(u<<1, l, mid, tl, tr);
	if(mid < tr) chkmin(ret, query(u<<1|1, mid+1, r, tl, tr));
	return ret;
}
void adde(int u, int v) {
//	cerr << "adde: " << u << ' ' << v << endl;
	in[v]++, adj[u].pb(v);
}
int main() {
	read(n, k);
	rep(i, 1, n) read(a[i]), b[a[i]] = i;
	build(1, 1, n);
	repd(i, n, 1) {
		int x = query(1, 1, n, b[i]+1, min(n, b[i]+k-1)), y = query(1, 1, n, max(1, b[i]-k+1), b[i]-1);
		if(x != n+1) adde(b[i], b[x]);
		if(y != n+1) adde(b[i], b[y]);
		modify(1, 1, n, b[i], i);
	}
	rep(i, 1, n) if(!in[i]) q.push(-i);
	while(!q.empty()) {
		int u = -q.top(); q.pop();
		ans[u] = ++tot;
		for(auto v: adj[u]) {
			--in[v];
			if(!in[v]) q.push(-v);
		}
	}
	rep(i, 1, n) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 44416
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;

typedef long long int64;
const int inf = (int)1e9;

int main()
{
	while(true) {
		
		int n, m;
		vector<vector<pair<int, int> > > s;
		vector<vector<vector<int> > > dp;
		
		const int maxx = 1000;
		
		scanf("%d%d", &n, &m);
		if(n == 0)
			break;
		
		s.resize(n + 2);
		for(int i = 1; i < n + 1; ++i) {
			int k;
			scanf("%d", &k);
			s[i].resize(k);
			for(int j = 0; j < k; ++j) {
				int a, b;
				scanf("%d%d", &a, &b);
				s[i][j] = make_pair(a, b);
			}
		}
		s[0].resize(maxx);
		s[n + 1].resize(maxx);
		for(int i = 0; i < maxx; ++i) {
			s[0][i] = make_pair(i + 1, 0);
			s[n + 1][i] = make_pair(i + 1, 0);
		}
		
		dp.resize(n + 2);
		for(int i = 0; i < n + 2; ++i) {
			dp[i].resize(s[i].size());
			for(int j = 0; j < dp[i].size(); ++j)
				dp[i][j].resize(m + 1, inf);
		}
		for(int i = 0; i < dp[0].size(); ++i)
			dp[0][i][m] = 0;
		
		for(int i = 1; i < n + 2; ++i) {
			for(int j = 0; j < dp[i].size(); ++j) {
				for(int k = 0; k < m + 1; ++k) {
					
					int &x = dp[i][j][k];
					int col = s[i][j].first;
					int score = s[i][j].second;
					
					for(int prev = 0; prev < dp[i - 1].size(); ++prev) {
						int prevcol = s[i - 1][prev].first;
						int prevscore = s[i - 1][prev].second;
						int prevdp = dp[i - 1][prev][k];
						x = min(x, prevdp + (prevscore + score) * abs(prevcol - col));
					}
					if(i < 2 || k == m)
						continue;
					
					for(int prev = 0; prev < dp[i - 2].size(); ++prev) {
						int prevcol = s[i - 2][prev].first;
						int prevscore = s[i - 2][prev].second;
						int prevdp = dp[i - 2][prev][k + 1];
						x = min(x, prevdp + (prevscore + score) * abs(prevcol - col));
					}
				}
			}
		}
		
		int ans = inf;
		
		for(int i = 0; i < dp[n + 1].size(); ++i) {
			for(int j = 0; j < m + 1; ++j)
				ans = min(ans, dp[n + 1][i][j]);
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

/* ハラスメントに負けず */
/* 0完太陽にも負けず */
/* はやく人権を獲得したい */
/* nullmineralが書きましたが */
/* 責任はまったくとりません */

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

int main()
{
  string a,b;
  cin >>a >> b;
  if(a < b){
    cout << "<" << endl;
  }else if(a == b){
    cout <<"="<<endl;
  }else{
        cout <<">"<<endl;
  }
  return 0;
}

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

int main()
{
    ll n , m , l ;
    cin >> n >> m >> l ;
    vector <ll> M1[n] ;
    vector <ll> M2[m] ;
    vector <ll> M3[n] ;
    for(ll i = 0 ; i < n ; i++)
    {
        for(ll j = 0 ; j < m ; j++)
        {
            ll G ;
            cin >> G ;
            M1[i].push_back(G) ;
        }
    }
    for(ll i = 0 ; i < m ; i++)
    {
        for(ll j = 0 ; j < l ; j++)
        {
            ll G ;
            cin >> G ;
            M2[i].push_back(G) ;
        }
    }
    for(ll i = 0 ; i < n ; i++)
    {
        for(ll j = 0 ; j < l ; j++)
        {
            ll sumi = 0 ;
            for(ll k = 0 ; k < m ; k++)
            {
                sumi += M1[i][k]*M2[k][j] ;
            }
            M3[i].push_back(sumi) ;
        }
    }
    for(ll i = 0 ; i < n ; i++)
    {
        cout << M3[i][0] ;
        for(ll j = 1 ; j < l ; j++) cout << " " << M3[i][j] ;
        cout << endl ;
    }
}


Measured memory_bytes: 3276
D = int(input())
C = list(map(int,input().split()))
 
s = [[] for _ in range(D)]
last_con = [0]*26
 
def evaluation(x,y,z,a):
    P = [0]*26
    for m in range(26):
        P[m] += x[m]
        for n in range(26):
            if m == n:continue
            P[m] -= a[n]*(z+1-y[n])
    return P.index(max(P))
 
for i in range(D):
    s[i] = list(map(int,input().split()))
 
for i in range(D):
    op = evaluation(s[i],last_con,i,C)
    last_con[op] = i+1
    print(op+1)

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x,int y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(int x,int y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(int x,int y)
{
    return (x%mod *1LL* y%mod)%mod;
}
inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}

lli MX = 1e6 + 7;

lli mypow(int b , int p){

    if(p<0) return -1;

    lli ret = 1;
    for(int i=1; i<=p; i++){
        ret *= b;
        if(ret>=MX) return -1;
    }
    return ret;
}

int main()
{
    ///freopen("output.txt","w",stdout);
    int a,b;
    cin>>a>>b;
    
    if(a<10 && b<10){
        cout<<(a*b);
    }
    else cout<<-1;

    

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


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

using namespace std;

#define fi first
#define se second
#define pb push_back
//#define FILE

#define taskname ""
#define taski taskname".in"
#define tasko taskname".out"

typedef long long ll;
typedef unsigned int uint;

const int N = 105;

int n, a[2][N], ans;

int main()
{
	ios:: sync_with_stdio(false);
	#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#elif defined(FILE)
	freopen(taski, "r", stdin);
	freopen(tasko, "w", stdout);
	#endif

	cin >> n;
	for(int i = 0; i < 2; i++)
		for(int j = 0; j < n; j++)
			cin >> a[i][j];
	for(int i = 0; i < n; i++)
	{
		int cur_ans = 0;
		for(int j = 0; j < n; j++)
		{
			if(j <= i)
				cur_ans += a[0][j];
			if(j >= i)
				cur_ans += a[1][j];
		}
		ans = max(ans, cur_ans);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;


int main(void){
    int n, l;
    cin >> n >> l;
    int mininum = 0xfffffff;
    int sum_taste = 0;
    int apple_taste;
    for(int i = 1; i <= n ; i++){
        apple_taste = l + i - 1;
        if(abs(mininum) > abs(apple_taste)){
            mininum = apple_taste;
        }
        sum_taste += apple_taste;
    }
//    cout << mininum << endl;
    cout << sum_taste - mininum << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	A := nextInt()
	B := nextInt()

	fmt.Println(max(A+B, A-B, A*B))
}

func max(a int, b ...int) int {
	l := len(b)
	for i := 0; i < l; i++ {
		if a < b[i] {
			a = b[i]
		}
	}

	return a
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n,l;
	cin >> n >> l;
	int a[n];
	for(int i=0; i<n; i++){
		a[i] = i+l;
	}
	int nearzero=1e9;
	int neari=0;
	int ans =0;
	for(int i=0; i<n; i++){
		ans+=a[i];
		if(abs(a[i])<nearzero){
			nearzero=abs(a[i]);
			neari=i;
			continue;
		}
	}
	ans-=a[neari];
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static String process(TestCase testCase) {
        final int A = testCase.A;
        final int B = testCase.B;
        int K = testCase.K;

        final int range = Math.min(A, B);

        for (int i = range; i >= 1; --i) {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        }

        throw new IllegalArgumentException("no solution");
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        return new TestCase(A, B, K);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int A;
        final int B;
        final int K;

        public TestCase(int A, int B, int K) {
            this.A = A;
            this.B = B;
            this.K = K;
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,n;
	cin>>n>>a>>b;
	long long times=n/(a+b);
	long long ans=0;
	ans+=times*a;
	if(n-times*(a+b)>=a)ans+=a;
	if(n-times*(a+b)<a)ans+=n-times*(a+b);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int M = 1000010;
int n; 
long long x,y,l,a[M];
bool cmp(int x,int y)
{
    return x > y;
}
int main()
{   
    x = 0;
    y = 0;

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
        scanf("%lld",&a[i]);

    sort(a,a+n,cmp);

    for (int i = 0; i < n; i++)
    {
        if(a[i] == a[i+1])
        {
            if(!x)
                x = a[i];
            else
            {
                y = a[i];
                break;
            }
            ++i;
        }
    }
    printf("%lld\n",(long long)x*y);
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d", &a, &b);
	if(a==1)
	a+=13;
	if(b==1)
	b+=13;
	if(a==b)
	printf("Draw\n");
	if(a>b)
	printf("Alice\n");
	if(a<b)
	printf("Bob\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    vector<char> root;
    vector<char> root2;

    // 1 回目のルート
    rep(i, abs(ty - sy)){
        if(ty - sy < 0) {
            cout << 'D';
            root.push_back('U');
        }
        else {
            cout << 'U';
            root.push_back('D');
        }
    }
    rep(i, abs(tx - sx)){
        if(tx - sx < 0) {
            cout << 'L';
            root.push_back('R');
        }
        else {
            cout << 'R';
            root.push_back('L');
        }
    }
    rep(i, root.size())
    {
        cout << root[i];
    }

    // 2 回目のルート
    if(tx - sx < 0) {
        cout << 'R';
        root2.push_back('L');
    }
    else {
        cout << 'L';
        root2.push_back('R');
    }
    rep(i, abs(ty - sy) + 1){
        if(ty - sy < 0) {
            cout << 'D';
            root2.push_back('U');
        }
        else {
            cout << 'U';
            root2.push_back('D');
        }
    }
    rep(i, abs(tx - sx) + 1){
        if(tx - sx < 0) {
            cout << 'L';
            root2.push_back('R');
        }
        else {
            cout << 'R';
            root2.push_back('L');
        }
    }
    if(ty - sy < 0) {
        cout << 'U';
        root2.push_back('D');
    }
    else {
        cout << 'D';
        root2.push_back('U');
    }
    rep(i, root2.size())
    {
        cout << root2[i];
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

using namespace std;

int x, a;

signed main() {
    cin >> x >> a;
    int ans;
    if (x >= a) ans = 10;
    else ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 256
s=input()
a="keyence"
# if a in s:
#     print("YES")
#     exit()
for i in range(len(a)):
    if a[:i] in s:
        b=s.index(a[:i])
        if b!=0:
            if i==len(a)-1:
                pass
            else:
                continue
        if a[i:] in s[b:]:
            c=s.index(a[i:])
            #print(s.index(a[i:]),s[s.index(a[i:]):],a[i:])
            if s[c:]==a[i:]:
                print("YES")
                exit()
            else:
                while True:
                    #try:
                    if c+1>=len(s):
                        break
                    if a[i:] in s[c+1:]:
                        #print(c,s[c+1:])
                        d=s[c+1:].index(a[i:])
                        if d==0:
                            if s[c+1:]==a[i:]:
                                print("YES")
                                exit()
                            else:
                                c+=1
                                continue
                        #print(s[c+1:],a[i:],d)
                        c+=d
                        #print(c,s[c:],a[i:])
                        if s[c:]==a[i:]:
                            print("YES")
                            exit()
                    else:
                        break
                    # except:
                    #     break
                    
                
print("NO")

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

int main()
{
	int n, m, i, c, b[1000], a[1000], j, cnt = 0;
	cin >> n >> m >> c;
	int sum = c;
	for(i=0;i<m;i++)cin >> b[i];
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++){
			cin>>a[j];
			sum+=a[j]*b[j];
		}
		if(sum>0)cnt++;
		sum = c;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn solve(s: String, K: usize) -> usize {
    let si: Vec<char> = s.chars().collect();

    let mut dp = vec![vec![vec![0; K+2]; 2]; s.len()+1];  // dp[決めた桁数][未満フラグ][対象カウント] := 総数
    dp[0][0][0] = 1;

    for i in 0..s.len() {
        let D: usize = (si[i] as usize) - ('0' as usize);
        for j in 0..2 {
            for k in 0..K+1 {
                for d in 0..10 {
                    if j == 0 && d > D {
                        break;
                    }
                    let is_smaller: usize = (j == 1 || d < D) as usize;
                    let count: usize;
                    if d == 0 {
                        count = k;
                    } else {
                        count = k + 1;
                    }
                    dp[i+1][is_smaller][count] += dp[i][j][k];
                }
            }
        }
    }

    return dp[s.len()][0][K] + dp[s.len()][1][K];
}

fn main() {
    let n: String = read();
    let k: usize = read();

    println!("{}", solve(n, k));
}


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

using namespace std;

int qsort_int_compare_ascend(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int qsort_int_compare_descend(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
void ascendOrder(int size, int *array) {//sho-jun
	qsort(array, size, sizeof(int), qsort_int_compare_ascend);
}
void descendOrder(int size, int *array) {//ko-jun
	qsort(array, size, sizeof(int), qsort_int_compare_descend);
}

#define max(a,b) ((a>b)?(a):(b))
int main() {
	int N; cin >> N;
	int *x = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}

	ascendOrder(N, x);

	if (N % 2 == 0) {
		long long sum = 0;
		for (int i = 0, j = N - 1; i < j; i++, j--) {
			sum += x[j] - x[i];
		}
		sum *= 2;
		sum += x[N / 2 - 1] - x[N / 2];
		cout << sum;
	}
	else {
		long long sum1 = 0, sum2 = 0;
		for (int i = 1, j = N - 1; i < j; i++, j--) {
			sum1 += x[j] - x[i];
			sum2 += x[j - 1] - x[i - 1];
		}
		sum1 *= 2, sum2 *= 2;
		sum1 -= x[0] * 2;//M
		sum2 += x[N - 1] * 2;//W

		sum1 += x[N / 2] + x[N / 2 - 1];
		sum2 -= x[N / 2] + x[N / 2 + 1];

		cout << max(sum1, sum2);
	}

	delete[] x;
	return 0;
}

Measured memory_bytes: 1020
# -*- coding: utf-8 -*-

def solve():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    if V-W >0 and abs(A-B)/(V-W) <= T:
        return 'YES'
    return 'NO'

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<=b;i++)
int n,m;
LL sum,ans;
map<LL,LL>mp;
int main()
{
	cin>>n;
	if(n<105)cout<<0;
	else if(n<135)cout<<1;
	else if(n<165)cout<<2;
	else if(n<189)cout<<3;
	else if(n<195)cout<<4;
	else cout<<5;
}


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

int main() {
  int count = 0;
  string s, t;
  cin >> s >> t;
  if (s == t) {
    cout << 0 << endl;
    return 0;
  }
  for (int n = 0; n < s.size(); n++) {
    if (s.at(n) != t.at(n)) {
      s.at(n) = t.at(n);
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	ll N, P;
	cin >> N >> P;
	if(N >= 40) {
		cout << 1 << endl;
		return 0;
	}
	if(N == 1) {
		cout << P << endl;
		return 0;
	}
	int ans = 1;
	for(int i = 2; pow((ll)i, N) <= P; i++) {
		int num = 0;
		while(P % i == 0) {
			P /= i;
			num++;
		}
		ans *= pow(i, num / N);
	}
	cout << ans << endl;
}


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

int main() {
    vector<int> result;
    // 一行分の整数値を入力
    while (1) {
        int sum = 0;
        while (1) {
            char ch;
            scanf("%c", &ch);
            if (ch == '\n') {
                break;
            } else {
                sum += ch-'0';
            }
        }
        if (sum == 0) {
            break;
        } else {
            result.push_back(sum);
        }
    }

    for (int x : result) {
        printf("%d\n", x);
    }
}


Measured memory_bytes: 3264
//AtCoder ABC059 B - Comparison
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string A,B; //数字
    cin>>A>>B;
    if (A==B){
        cout<<"EQUAL"<<endl;
    } else if (A.size()==B.size()) {
        for(int i=0;i<A.size();++i){
            if(A[i]==B[i])continue;
            cout<<(A[i]>B[i]?"GREATER":"LESS")<<endl;
            break;
        }
    } else {
        cout<<(A.size()>B.size()?"GREATER":"LESS")<<endl;
    }
    return 0;
}

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

P calc(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/(imag(a/c)-imag(b/c));
}

int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;
  scanf("%d",&n);
  while(n--){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy);
    P ans=calc(P(ax,ay),P(bx,by),P(cx,cy),P(dx,dy));
    printf("%.8f %.8f\n",ans.real(),ans.imag());
  }
  return 0;
}

Measured memory_bytes: 1256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); 
        int k = sc.nextInt();
        int min = 1;
        for(int i=0; i<n; i++){
            min = Math.min(min*2,min+k);   
        }
        System.out.println(min);
    }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

vector<pii> pp;

int cnt[2], lim[2];

void solve(){
	scanf("%d%d", &lim[0], &lim[1]);
	REP(i, 0, 2){
		REP(j, 0, lim[i]){
			int a;
			scanf("%d", &a);
			pp.pb(mp(a, i));
		}
	}
	SORT(pp);
	ll ans = 0ll;
	//ll cnt = (ll)lim[0] * (ll)lim[1];
	REP(i, 0, SZ(pp)){
		int ind = pp[i]._2;
		/*ll add = 0ll;
		if (!cnt[ind ^ 1]){
			add = lim[ind ^ 1];
		} else {
			add = lim[ind ^ 1] - max(0, cnt[ind ^ 1] - 1);
		}*/
		ll add = lim[ind ^ 1] - cnt[ind ^ 1] + 1;
		//cout << add << " " << add * pp[i]._1 << endl;
		ans += add * pp[i]._1;
		cnt[ind]++;
	}
	printf("%lld\n", ans);
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 2420
S = input()

kaibun = True
N = len(S)

if not S[:] == S[::-1]:
    kaibun = False
if not S[:(N-1)//2:] == S[(N-1)//2-1::-1]:
    kaibun = False
if not S[(N+3)//2-1:] == S[:(N+3)//2-2:-1]:
    kaibun = False

if kaibun:
    print("Yes")
else:
    print("No")

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

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int res = 0;
  for(int r = 0; r * R <= N; r++){
    for(int g = 0; g * G <= N - (r * R); g++){
       
        if((N - (r * R + g * G)) % B == 0) res++;
      
    }
  }
  cout << res << endl;
}
          

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int[] money = {1,5,10,25};
        int sum = 0;
        for(int i = 3 ; i >= 0 ; i--){
            sum += n / money[i];
            n -= n / money[i] * money[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 26408
let n, a, b =
  let l = stdin.ReadLine().Split(' ') |> Array.map int
  l.[0], l.[1], l.[2]

let s = stdin.ReadLine()

[0 .. s.Length - 1]
|> List.scan (
    fun (pass, bCnt, msg) i ->
      let c = s.[i]
      match c with
      | 'a' ->
        if pass < a + b then
          (pass + 1, bCnt, "Yes")
        else
          (pass, bCnt, "No")
      | 'b' ->
        if pass < a + b && bCnt < b then
          (pass + 1, bCnt + 1, "Yes")
        else
          (pass, bCnt + 1, "No")
      | _ ->
          (pass, bCnt, "No")
  ) (0, 0, "")
|> List.iter (fun (_, _, msg) -> stdout.WriteLine msg)

Measured memory_bytes: 32976
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C, D = map(int, readline().split())

print('Left' if A + B > C + D else 'Balanced' if A + B == C + D else 'Right')


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

typedef long long int lli;
const int MAX = 1001;
const lli MOD = 100000007;

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

  lli C[MAX][MAX];
  fill(C[0],C[MAX],1);
  for(int i=1;i<MAX;i++){
    for(int j=1;j<i;j++){
      C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
    }
  }

  while(cin >> w >> h >> x1 >> y1 >> x2 >> y2){
    int x,y;
    lli ansx = 1, ansy = 1;
    if(abs(x2-x1) == abs(w-x2)+x1) ansx++;
    x = min(abs(x2-x1), abs(w-x2)+x1);
    if(x == abs(w-x1)+x2) ansx++;
    else if(x > abs(w-x1)+x2){
      ansx = 1;
      x = abs(w-x1)+x2;
    }

    if(abs(y2-y1) == abs(h-y2)+y1) ansy++;
    y = min(abs(y2-y1), abs(h-y2)+y1);
    if(y == abs(h-y1)+y2) ansy++;
    else if(y > abs(h-y1)+y2){
      ansy = 1;
      y = abs(h-y1)+y2;
    }
 
    cout << C[x+y][x] * ansx * ansy % MOD << endl;
  }
}

Measured memory_bytes: 8984
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  int n;  cin >> n;
  map<int, int> mp;
  rep(i, 0, n)  {
    int a;  cin >> a;
    mp[a]++;
  }
  for(auto it=mp.begin(); it!=mp.end(); it++){
    if( !(it->first==0 and it->second==1) and
        !(it->first!=0 and it->second==2)){
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans=1;
  if(n&1){
    for(int i=2; i<n; i+=2) {
      ans*=2;
      ans%=MAX;
    }
  }else{
    for(int i=1; i<n; i+=2) {
      ans*=2;
      ans%=MAX;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MAX=1e6;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
const int Primes[168]=
{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,
 97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,
 227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,
 367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,
 509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,
 661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,
 829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
const char common[]="not coprime",disjoint[]="pairwise coprime",several[]="setwise coprime";
char esc[1000000];
static inline int Divide(int x)
{
  if(!x){return 0;}
  rep(i,168)
  {
    if(Primes[i]*Primes[i]>x)break;
    if(x%Primes[i])continue;
    if(esc[Primes[i]-1])return 0;
    esc[Primes[i]-1]=1;
    while(x%Primes[i]==0&&x)x/=Primes[i];
  }
  if(x>1){if(esc[x-1])return 0;esc[x-1]=1;}
  return 1;
}
int main(void)
{
  int N=IN(),A=0,f=0,g=0;
  rep(i,N){A=IN();g=GCD(g,A);if(i&&g!=1){f=1;}if(f)continue;else{if(!Divide(A))f=1;}}
  if(g>1)return puts(common),0;else{if(f)return puts(several),0;else return puts(disjoint),0;}
}

Measured memory_bytes: 2504