akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

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

    vector<int> a(n);
    // R, G, B を 3 で割った余りの 1, 2, 0 で分類してる
    REP(i, n) a[i] = s[i] % 3;

    vector<long long> count(3);
    // 1, 2, 0 が何個あるのかを数えてる
    REP(i, n) count[a[i]]++;

    long long ans = 1;
    // とりあえず全ての通りを計算する
    REP(i, 3) ans *= count[i];

    REP(j, n) REP(i, j) { // i < j < n の順番になっている
        int k = j + (j - i); // (j - i) = (k - j) の式変形
        if (k < n) {
            // i, j, k 3つが全て異なることを確認する
            if (a[i] == a[j]) continue ;
            if (a[i] == a[k]) continue ;
            if (a[k] == a[j]) continue ;
            ans--;
        }
    }

    cout << ans << '\n';
    return 0;
}


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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

double memo[302][302][302]={};

double dp(ll i,ll j,ll k,ll &n){
    if(i==1 && j==1 && k==1) return 0;
    if(i==0 || j==0 || k==0) return 0;
    if(memo[i][j][k]!=0) return memo[i][j][k];
    memo[i][j][k]=((i-1)*dp(i-1,j,k,n)+(j-1)*dp(i+1,j-1,k,n)+(k-1)*dp(i,j+1,k-1,n)+n)/(i+j+k-3);
    return memo[i][j][k];
}

int main() {
    ll n;cin>>n;
    ll a[n];
    ll b[3]={};
    for(ll i=0;i<n;i++){
        cin>>a[i];
        b[a[i]-1]++;
    }
    double ans;
    ans=dp(b[0]+1,b[1]+1,b[2]+1,n);
    cout<<setprecision(30)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 214656
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 15
 
const string gesture[MAX] = {
    "Rock","Fire","Scissors","Snake","Human","Tree","Wolf","Sponge",
    "Paper","Air","Water","Dragon","Devil","Lightning","Gun"
};
 
vector<int> v;
bool ges[MAX];
 
int solve(){
    int res = -1, N = (int)v.size();
 
    if(N == 1){
	return res;
    } 
 
    for(int i = 0 ; i < N ; i++){
	int win = 0, lose = 0;
	for(int j = 0 ; j < MAX ; j++){
	    if(v[i] == j || !ges[j]){
		continue;
	    }

	    int cnt = 0, pos = v[i];
	    while(true){
		pos++; cnt++;
		if(pos >= MAX){
		    pos = 0;
		}
 
		if(j == pos){
		    if(cnt > 7){
			lose++;
		    }else{
			win++;
		    }
		    break;
		}
	    }
	}
	if(win == N-1){
	    res = v[i];
	    break;
	}
    }
 
    return res;
}
 
int main(){
    int n;
 
    while(cin >> n ,n){
	string str;
	set<string> st;
 
	v.clear();
	memset(ges,false,sizeof(ges));
 
	for(int i = 0 ; i < n ; i++){
	    cin >> str;
	    if(st.count(str)){
		continue;
	    }
	    for(int j = 0 ; j < MAX ; j++){
		if(gesture[j] == str){
		    v.push_back(j);
		    st.insert(str);
		    ges[j] = true;
		    break;
		}
	    }
	}
    
	sort(v.begin(),v.end());
	int ans = solve();
 
	if(ans == -1){
	    cout << "Draw" << endl;
	}else{
	    cout << gesture[ans] << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3144
#include <stdio.h>

int main()
{
	int k, n, N;
	scanf("%d", &N);
	for (n = N, k = 0; n > 0; n /= 10) k += n % 10;
	if (N % k == 0) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1644
mod=10**9+7
s=input()
dp=[[0]*13 for _ in range(len(s)+1)]
dp[0][0]=1
r=[i%13 for i in range(130)]

for i in range(len(s)):
  if s[i]=='?':
    for j in range(13):
      for k in range(10):
        dp[i+1][r[j*10+k]]+=dp[i][j]
  else:
    t = int(s[i])
    for j in range(13):
      dp[i+1][r[j*10+t]] += dp[i][j]

  for k in range(13):
    dp[i+1][k] %= mod

print(dp[len(s)][5])

Measured memory_bytes: 62044
h,w,k=list(map(int,input().split()))
s=[list(map(int,[x for x in input()])) for _ in range(h)]

cnt=10001

for i in range(2**(h-1)):
    split=[0]*h
    curcnt=0
    for j in range(h):
        if (i>>j)&1:
            split[j]=1
            curcnt+=1
        
    nsplit=curcnt+1
    sumlst=[[0]*(nsplit) for _ in range(w)]

    cw=0
    memo=0
    chk=0
    flag=False
    while cw<w:
        l=0
        for ch in range(h):
            sumlst[memo][l]+=s[ch][cw]

            if sumlst[memo][l]>k:
                memo+=1
                chk+=1
                break

            if split[ch]:
                l+=1
        else:
            chk=0
            cw+=1
            continue

        if chk>1:
            break
    else:
        cnt=min(cnt,curcnt+memo)

print(cnt)

Measured memory_bytes: 48604
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#define ll long long
using namespace std;
int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f*=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
	return f*x;
}
char s[110];
int sum=0;
int main(){
	scanf("%s",s+1);
	if(s[1]!='A'){
		printf("WA");
		return 0;
	}
	if(s[2]>='A'&&s[2]<='Z'){
		printf("WA");
		return 0;
	}
	int len=strlen(s+1);
	for(int i=3;i<len;i++){
		if(s[i]=='C')sum++;
		if(sum>1){
			printf("WA");
			return 0;
		}
		if(s[i]>='A'&&s[i]<='Z'&&s[i]!='C'){
			printf("WA");
			return 0;
		}
	}
	if(sum==0){
		printf("WA");
		return 0;
	}
	if(s[len]>='A'&&s[len]<='Z'){
		printf("WA");
		return 0;
	}
	printf("AC");
	return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e6 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

ll ans[maxn], a[maxn];
vector <pair <ll, ll> > q;
ll r, n;

int main() {
//    fin("t.in");
    sync;
    cin >> n;
    q.pb(mp(-inf, -inf));
    fi(1, n) {
        cin >> a[i];
        q.pb(mp(-a[i], i));
        ans[i] = 0;
    }
    sort(q.begin(), q.end());
    fi(1, n) {
        q[i].X = -q[i].X;
    }
    r = 0;
    q.pb(mp(0, 0));
    fi(1, n) {
        r = i;
        while (r <= n && q[r].Y >= q[i].Y) {
            ++r;
        }
        ans[q[i].Y] += (ll)i * (q[i].X - q[r].X);
        fj(i + 1, r) {
            ans[q[i].Y] += q[j].X - q[r].X;
        }
        i = r - 1;
    }
    fi(1, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8052
import java.util.Scanner;

//Red and Black
public class Main{

	static int c, h, w;
	static int[][] move = {{1,0},{-1,0},{0,1},{0,-1}};
	static char[][] m;
	
	static void dfs(int i, int j){
		for(int k=0;k<4;k++){
			int ni = i + move[k][0];
			int nj = j + move[k][1];
			if(0<=ni&&ni<h&&0<=nj&&nj<w&&m[ni][nj]!='#'){
				m[ni][nj] = '#';
				c++;
				dfs(ni,nj);
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h)==0)break;
			m = new char[h][w];
			int si = 0;
			int sj = 0;
			for(int i=0;i<h;i++){
				char[] s = sc.next().toCharArray();
				for(int j=0;j<w;j++){
					m[i][j] = s[j];
					if(s[j]=='@'){
						si = i;
						sj = j;
					}
				}
			}
			c = 1;
			m[si][sj] = '#';
			dfs(si,sj);
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    ll n, w, wi, vi, M = 1e9 + 7;
    cin >> n >> w;
    ll dp[100001] = {};
    memset(dp, M, sizeof(dp));
    dp[0] = 0;

    for (int i = 0; i < n; ++i) {
        cin >> wi >> vi;
        for (int j = 100000; j >= vi; --j) dp[j] = min(dp[j], dp[j - vi] + wi);
        // for (int j = 0; j <= w; ++j) cout << dp[j] << " \n"[j == w];
    }
    for (int i = 100001; i--;)
        if (dp[i] <= w) {
            cout << i << '\n';
            return 0;
        }
    cout << 0 << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll N,M;
    cin>>N>>M;
    vector<ll> A(N);
    ll total=0;
    rep(i,N) {
        cin>>A.at(i);
        total+=A.at(i);
    }
    sort(ALLOF(A));
    reverse(ALLOF(A));
    ll ans=total/(4*M);
    if(total%(4*M)) ans++;
    if(A.at(M-1)>=ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i,j,a[1000],b[1000],c[1000];
	
	scanf("%d",&i);
	j=i;
	
	for(;i!=0;i--)
	{
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	
	for(;j!=0;j--)
	{
		if(a[j]*a[j]+b[j]*b[j]==c[j]*c[j])	printf("YES");
		else if(b[j]*b[j]+c[j]*c[j]==a[j]*a[j])	printf("YES");
		else if(c[j]*c[j]+a[j]*a[j]==b[j]*b[j])	printf("YES");
		else printf("NO");
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    int cnt=0;
    if(K>=A){
        cnt = cnt + A;
        K = K-A;
        if(K>=B){
            K = K-B;
            cnt = cnt - K;
            cout << cnt << endl;
        }else{
            cout << cnt << endl;
        }
    }else{
        cnt = K;
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3624
/*
AuThOr GaRyMr
技巧:
1.区别对待大数据&小数据！
2.Dp难推时算贡献！
3.long long (尤其乘法)！
4.long long INF 要大
5.Dp on trees: 换根法，每次清空当前的节点和换到的子节点
6.long double | 输出浮点数
7.注意特判!(prince and princess)
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,k;
int num[300000+10];
int used[300000+10];
vector<pair<int,mp > > v;
int main(){
	cin>>n>>k;
	rb(i,1,n+n+n) num[i]=k+i-1;
	if(k*2>n+1){
		puts("-1");
		return 0;
	}
	n=n*3;
	int l=1,r,l2=(n+n)/3+1;
	rb(i,1,l2-1)
	if(num[i]+num[1]==num[l2]){
		r=i;break;
	}
	while(r-l>=3){
		used[l]=used[r]=1;
		cout<<num[l++]<<" "<<num[r--]<<' '<<num[l2++]<<endl;
		l++;
	}
	l=1,r=(n+n)/3;
	rb(i,l2,n){
		rb(j,l,r){
			if(!used[j]){
				l=j;
				break;
			}
		}
		rl(j,r,l){
			if(!used[j]){
				r=j;
				break;
			}
		}
		v.PB(II(num[l++]+num[r--],II(l,r)));
	}
	sort(ALL(v));
	int tot=0;
	rb(i,l2,n){
		cout<<num[v[tot].SEC.FIR]<<" "<<num[v[tot].SEC.SEC]<<" "<<num[i]<<endl;
		tot++;
	}
	return 0;
}


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

bitset<100100100> is_prime(0);
vector<int> prime_numbers;
void sieve_of_eratosthenes(int n=1e8) {
  for (int i = 2; i < n + 1; i++) {is_prime.set(i);}
  for (int i = 2; i < (int)sqrt(n) + 1; i++) {
    if (is_prime[i]) for (int j = i * 2; j < n + 1; j += i) is_prime.reset(j);
  }
  for (int i = 2; i < n + 1; i++) if (is_prime[i]) prime_numbers.push_back(i);
}

unordered_map<int, int> prime_factorize(int n) {
  unordered_map<int, int> res;
  int border = int(sqrt(n));
  for (int &p : prime_numbers) {
    if (p > border) break;
    if (n % p == 0) {
      res[p] = 1; n /= p;
      while (n % p == 0) {res[p]++; n /= p;}
    }
    if (n == 1) return res;
  }
  res[n] = 1; return res;
}

unordered_map<int, int> prime_factorize_factorial(int n) {
  unordered_map<int, int> res;
  for (int i = 2; i < n + 1; i++) {
    for (auto &pc : prime_factorize(i)) {
      if (res.find(pc.first) == res.end()) res[pc.first] = pc.second;
      else res[pc.first] += pc.second;
    }
  }
  return res;
}

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

  int x; cin >> x;
  int i = lower_bound(prime_numbers.begin(), prime_numbers.end(), x) - prime_numbers.begin();
  cout << prime_numbers[i] << '\n';
  return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    double W, H, x, y;
    std::cin >> W >> H >> x >> y;

    long double ans = W * H / 2.0;
    if(x == W / 2 && y == H / 2) {
        std::cout << ans << setprecision(20) << " " << 1 << std::endl;
    }
    else {
        std::cout << ans << setprecision(20) << " " << 0 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}

int main()
{
	int n, d, ans, cnt;
	cin >> n >> d;
	cnt = d + d + 1;
	ans = n / cnt;
	if (n % cnt != 0) {
		ans += 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int main() {
	for (int n; cin >> n; ) {
		for (int i = 0; (n >> i); i++) if ((n >> i) & 1) cout << (1 << i) << ((n >> (i + 1)) ? ' ' : '\n');
	}
	
	return 0;
}

Measured memory_bytes: 0
def solve(choco, cut_pos, k):
    cuts = len(cut_pos) - 2
    blocks = [0] * (len(cut_pos) - 1)

    for col in zip(*choco):
        need_cut = False
        for i, blk in enumerate(zip(cut_pos, cut_pos[1:])):
            s, e = blk
            white = sum(col[s:e])
    
            if white > k:
                return float('inf')

            if blocks[i] + white > k:
                need_cut = True
                break
            else:
                blocks[i] += white

        if need_cut:
            for i, blk in enumerate(zip(cut_pos, cut_pos[1:])):
                s, e = blk
                blocks[i] = sum(col[s:e])

        cuts += need_cut
    # print('cuts:', cuts)
    return cuts


def main():
    h, w, k = map(int, input().split())

    choco = [[int(s) for s in list(input())] for _ in range(h)]
    min_cuts = float('inf')

    for cuts in range(1 << (h-1)):
        cut_pos = [0] + [i+1 for i in range(h-1) if cuts & (1 << i)] + [h]
        min_cuts = min(min_cuts, solve(choco, cut_pos, k))

    print(min_cuts)


if __name__ == "__main__":
    main()


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

using namespace std;

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

	vector<vector<long long int> > DP(N + 1, vector<long long int> (W + 1));
	int w;
	long long int v;

	for(int index = 1; index <= N; index++){
		cin >> w >> v;
	    for (int weight = 1; weight <= W; weight++)
	        if(w <= weight) DP[index][weight] = max(v + DP[index - 1][weight - w],  DP[index - 1][weight]); 
	        else DP[index][weight] = DP[index - 1][weight];
	}
	  
	cout << DP[N][W];

	return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_V 1010
#define INF 1234567812345678

double cost[MAX_V][MAX_V];
double d[MAX_V];
bool used[MAX_V];
int V;

void dijkstra(int s){
    fill(d,d+V,INF);
    fill(used,used+V,false);
    d[s] = 0;

    while(true){
        int v = -1;
        for(int u = 0; u < V; u++){
            if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
        }
        if(v == -1)break;
        used[v] = true;
        for(int u = 0; u < V; u++){
            d[u] = min(d[u], d[v] + cost[v][u]);
        }
    }
}

double distance(double x1, double y1, double x2, double y2){
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main() {
    double sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int n;
    cin >> n;
    double x[n+2], y[n+2], r[n+2];
    x[0] = sx; y[0] = sy; r[0] = 0;
    x[n+1] = tx; y[n+1] = ty; r[n+1] = 0;
    srep(i,1,n+1){
        cin >> x[i] >> y[i] >> r[i];
    }
    V = n + 2;

    rep(i,n+2){
        rep(j,n+2){
            double tmp = distance(x[i],y[i],x[j],y[j]) - (r[i]+r[j]);
            cost[i][j] = max((double)0, tmp);
        }
    }

    dijkstra(0);
    /*
    rep(i,n+2){
        rep(j,n+2){
            cout << cost[i][j] << ' ';
        }
        cout << endl;
    }
    */
    cout << fixed << setprecision(10) << d[n+1] << endl; // 10桁表示

    return 0;
}
 
 


Measured memory_bytes: 8192
def lscan; gets.split.map(&:to_i); end

def bye(msg); puts msg.to_s; exit; end
str = gets.chomp

str.chars.each_with_index do |c, i|
    bye 'No' if i.even? && c == 'L'
    bye 'No' if i.odd? && c == 'R'
end
bye 'Yes'

Measured memory_bytes: 1788
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,W;
    cin >> N >> W;
    ll w[110], v[110];
    rep(i,0,N) cin >> w[i] >> v[i];
    ll dp[100010] = {};
    rep(i,0,N){
        rrep(j,W,0){
            if(j - w[i] >= 0) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
        }
    }
    print(dp[W]);
    

}

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

bool solve() {
    ll N, sa = 0;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        sa += A[i];
    }
    ll nn = N*(N+1)/2;
    if ( sa % nn != 0 ) return false;
    ll k = sa / nn;
    for ( int i = 0; i < N; i++ ) {
        ll d = - ( A[(i+1)%N] - A[i] - k );
        if ( d < 0 || d % N != 0 ) return false;
    }
    return true;
}

int main() {
    string ans = solve() ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

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

void solver() {
  int a, b, k;
  cin >> k;
  cin >> a >> b;

  string ans = "NG";
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      ans = "OK";
      break;
    }
  }

  cout << ans << "\n";
}

int main() {
  solver();
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
#define chmax(x,y) x=max(x,y)

int dp[3005][5005];

int main()
{
    int n,t;
    cin>>n>>t;
    vector<p> p(n);
    rep(i,n)
    {
        cin>>p[i].first>>p[i].second;
    }
    sort(p.begin(),p.end());
    int ans=0;
    rep(i,n)
    {
        rep(j,t)
        {
            chmax( dp[i+1][j], dp[i][j]);
            int nj=j+p[i].first;
            if(nj<t)chmax( dp[i+1][nj], dp[i][j]+p[i].second);
        }
        int now=dp[i][t-1]+p[i].second;
        chmax(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 58240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] ab=reader.readLine().split(" ");
        List<Integer> nums=new ArrayList<Integer>();
        for(int i=0;i<3;i++){
        	nums.add(Integer.parseInt(ab[i]));
        }
        Collections.sort(nums);
        for(int i=0;i<3;i++){
        	System.out.print(nums.get(i));
        	if(i!=2){
        		System.out.print(" ");
        	}
        }
    	System.out.println();
	}
}

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

using namespace std;

int main()
{
    int n;
    double t,a;
    cin >> n;
    cin >> t >> a;
    
    int ans;
    double tmin=1e9;
    for(int i=0;i<n;i++){
        double h;
        cin >> h;
        double cal=abs(a-(t-h*0.006));
        if(tmin>cal){
            ans=i+1;
            tmin=cal;
        }
    }
    cout << ans << endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  LL n,x;
  cin >> n >> x;
  vector<LL> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  vector<LL> mi(n);
  LL ans=0,tmp;
  for(int i=0;i<n;i++){
    mi[i]=a[i];
    ans+=mi[i];
  }
  for(int i=1;i<n;i++){
    tmp=x*i;
    for(int j=0;j<n;j++){
      mi[j]=min(mi[j],a[(j-i+n)%n]);
      tmp+=mi[j];
    }
    ans=min(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b;
    char op;
    int ans;

    while (1) {
        scanf("%d %c %d", &a, &op, &b);
        if (op == '+') {
            ans = a + b;
        } else if (op == '-') {
            ans = a - b;
        } else if (op == '*') {
            ans = a * b;
        } else if (op == '/') {
            ans = a / b;
        } else if (op == '?') {
            break;
        }
        printf("%d\n", ans);
    }
    return 0;
}

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

int main(int argc, const char * argv[]) {
    
    int S, high, low;
    
    cin >> S;
    
    low = S % 100;
    high = S / 100;
    
    // YYMM
    if(1 <= low && low <= 12){
        // AMBIGUOUS
        if(1 <= high && high <= 12){
            cout << "AMBIGUOUS";
        } else{
            cout << "YYMM";
        }
    } else{
        if(1 <= high && high <= 12){
            cout << "MMYY";
        } else{
            cout << "NA";
        }
    }
    
    return 0;
}



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

int main(int argc, char **argv) {
  int N;
  cin >> N;
  
  vector<double> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  double ans = 0;
  for (int i = 0; i < N; i++) {
    ans += 1.0000000000000 / A[i];
  }

  ans = 1.00000000000 / ans;

  cout << std::setprecision(13) << std::fixed << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF 10000
#define dm(x) cerr << #x << " = " << x << endl;
using namespace std;

int main()
{
  int n, d[10][10], city, s[10], ms, mc;
  while(scanf("%d",&n),n){
    city=0;

    rep(i,10) rep(j,10)
      if (i==j) d[i][j]=0;
      else d[i][j]= INF;
    
    rep(i,n) {
      int a,b,c;
      scanf("%d %d %d", &a, &b, &c);
      d[a][b]=c;
      d[b][a]=c;
      city = max(max(a,b),city);
    }

    rep(k,10) rep(i,10) rep(j,10){
      d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
    
    // rep(i,city+1) rep(j,city+1)
    //   printf("%d %d: %d\n", i,j,d[i][j]);

    ms=-1;mc=INF;
    rep(i,city){
      s[i]=0;
      rep(j,city+1)
        s[i]+=d[i][j];
      if(s[i] < mc) {
        ms = i;
        mc = s[i];
      }
    }
    
    printf("%d %d\n", ms, mc);
  }
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
  char a[1000];
  int i=0,n,k;
  cin>>n>>k;
  while(scanf("%c",&a[i])){
    if(i!=0 && a[i]=='\n')break;
    i++;
  }
  a[k]-='A'-'a';
  for(i=1;i<=n;++i)cout<<a[i];
  cout<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int k;string s;
int main(){
    cin>>s>>k;
    for(int i=0;i<k-1;i++){
        if(s[i]!='1'){
            cout<<s[i];return 0;
        }
    }
    cout<<s[k-1];
    return 0;
}


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

int main()
{
  int N,K;
  int count=1;
  
  cin >> N >> K;
  
  for(int i=0;i<N;i++)
  {
    if(count*2<count+K)
      count *= 2;
    else
      count += K;
  }
  cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100100
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define INF 1000000000
using namespace std;

int abs(int& a){
	if(a<0)a=-a;
	return a;
}

int32_t main(){
	fastio;
	int n,h[MAXN],k;
	cin>>n>>k;
	int custo[MAXN];
	for(int i=1;i<=n;i++){cin>>h[i];
	custo[i]=INF;
	}
	custo[1]=0;
	custo[0]=0;
	for(int i=2;i<=n;i++)
		for(int j=1;j<=k;j++)
			if(i-j>=1)custo[i]=min(custo[i],custo[i-j]+abs(h[i-j]-h[i]));
			else break;
			
			
			cout<<custo[n]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int Maxn = 2e5 + 1;
int f1[ Maxn ], f2[ Maxn ], n, k, l;
std::map < std::pair < int, int >, int > mp;
int p, q;
int find( int *f, int x )
{
 return f[ x ] == x ? x : f[ x ] = find( f, f[ x ] ); 
}
void merge( int *f, int x, int y )
{
 int x1 = find( f, x ), y1 = find( f, y );
 if( x1 == y1 )
  return;
 f[ y1 ] = x1;
 return;
}
int main( )
{
 std::ios::sync_with_stdio( false );
 std::cin >> n >> k >> l;
 for( int i = 1; i <= n; ++i )
  f1[ i ] = f2[ i ] = i;
 for( int i = 1; i <= k; ++i )
 {
  std::cin >> p >> q;
  merge( f1, p, q );
 }
 for( int i = 1; i <= l; ++i )
 {
  std::cin >> p >> q;
  merge( f2, p, q );
 }
 for( int i = 1; i <= n; ++i )
  find( f1, i ),
  find( f2, i );
 for( int i = 1; i <= n; ++i )
  mp[ std::make_pair( f1[ i ], f2[ i ] ) ]++; 
 for( int i = 1; i <= n; ++i )
  std::cout << mp[ std::make_pair( f1[ i ], f2[ i ] ) ] << " ";
 return 0;
}

Measured memory_bytes: 16572
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
mae = [a[0]]
for i in range(n-1):
    mae.append(gcd(mae[i],a[i+1]))
ushiro = [a[n-1]]
for i in range(n-1):
    ushiro.append(gcd(ushiro[i],a[n-i-2]))

ans = ushiro[n-2]

for i in range(n-1):
    if i != n-2:
        ans = max(ans,gcd(mae[i],ushiro[n-i-3]))
    else:
        ans = max(ans,mae[n-2])

print(ans)


Measured memory_bytes: 92256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

string E, O;
void input() {
  cin >> O;
  cin >> E;
}
void solve() {
  int k = E.size() + O.size();
  rep(i, 0, k - 1) {
    if (i % 2)
      cout << E[i / 2];
    else
      cout << O[i / 2];
  }
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

const int MAX=1010;
int caves[MAX][MAX];
bool is_prime[MAX*MAX];
void init() {
    int y=MAX/2;
    int x=MAX/2;

    int d=0;
    int k=1;
    while(1) {
        caves[y][x]=k;
        k++;

        y+=dy[d];
        x+=dx[d];
        if(y<0) break;
        if(x<0) break;
        if(MAX<=y) break;
        if(MAX<=x) break;

        if(caves[y+dy[(d+1)%4]][x+dx[(d+1)%4]]==0) d=(d+1)%4;
    }
    
    rep(i,MAX*MAX) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<MAX*MAX;i++) {
        if(is_prime[i]) for(int j=i+i;j<MAX*MAX;j+=i) is_prime[j]=false;
    }

}
int m,n;
int dp[MAX][MAX];
typedef pair<P,int> Pi;
int maxi[MAX*MAX];

int bfs(int y,int x) {
    dp[y][x]=is_prime[caves[y][x]];
    // dp[y][x]=0:
    int t=0;
    if(is_prime[caves[y][x]]) t=caves[y][x];
    queue<Pi> que;
    que.push(Pi(P(y,x),t));

    while(que.size()) {
        Pi p=que.front();
        y=p.fr.fr;
        x=p.fr.sc;
        que.pop();
        maxi[dp[y][x]]=max(maxi[dp[y][x]],p.sc);

        t=p.sc;
        if(is_prime[caves[y][x]]) t=max(t,caves[y][x]);

        // printf("[debug] %d %d %d\n",caves[y][x],p.sc,dp[y][x]);

        int d[]={-1,0,1};
        rep(i,3) {
            int ny=y+1;
            int nx=x+d[i];
            if(!(0<=ny&&ny<MAX)) continue;
            if(!(0<=nx&&nx<MAX)) continue;
            if(m<caves[ny][nx]) continue;

            maxi[dp[ny][nx]]=max(maxi[dp[ny][nx]],t);

            if(dp[ny][nx]<dp[y][x]+is_prime[caves[ny][nx]]) {
                dp[ny][nx]=dp[y][x]+is_prime[caves[ny][nx]];

                que.push(Pi(P(ny,nx),t));

            }
        }
    }

    int ans=0,ans2=0;
    rep(y,MAX) rep(x,MAX) ans=max(ans,dp[y][x]);
    rep(y,MAX) rep(x,MAX) if(dp[y][x]==ans&&is_prime[caves[y][x]]) ans2=max(ans2,caves[y][x]);

    cout<<ans<<" "<<ans2<<endl;
    return 0;
}

void solve() {
    memset(dp,-1,sizeof(dp));
    memset(maxi,0,sizeof(maxi));
    P p;
    rep(y,MAX) rep(x,MAX) if(caves[y][x]==n) p=P(y,x);
    // int ans=dfs(p.fr,p.sc);

    bfs(p.fr,p.sc);
}

int main() {
    init();
    while(cin>>m>>n) {
        if(m+n==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 14196
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


int N, A, B, C, X;
int Y[100];

int getRansu(int x)
{
	return (A * x + B) % C;
}


int main()
{
	while (cin>>N>>A>>B>>C>>X, N||A||B||C||X)
	{
		rep(i, N) cin >> Y[i];
		
		int ans = 10001;
		int now = 0;
		
		for (int i=-1; i<=10000; i++)
		{
			if (X == Y[now]) now++;
			if (now >= N)
			{
				ans = i + 1;
				break;
			}
			X = getRansu(X);
		}
		
		if (ans == 10001)
		{
			cout << -1 << endl;
		} else {
			cout << ans << endl;
		}
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1160
#define scanf_s scanf
#include <stdio.h>
#include<iostream>
#include <deque>
using namespace std;
#define MAX 1025
int main()
{
	int n;
	char str[MAX];
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		int now = 0;
		deque<char> qu;
		scanf_s("%s", str, MAX);
		for (int j = 0; str[j] != '\0'; ++j) {
			if ('a' <= str[j] && str[j] <= 'z') {
				if (qu.empty() || now  == (int)qu.size()) {
					qu.push_back(str[j]);
				}
				else if(now == -1){
					qu.push_front(str[j]);
					++now;
				}
			}
			if (str[j] == '>') { ++now; }
			else if (str[j] == '<') { --now; }
		}
		for (int k = 0; k < (int)qu.size(); ++k) {
			printf("%c", qu[k]);
		}
		printf("\n");
	}
}

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

const ll hoshii=5000000000000000;

int main() {
	string S;
	cin >> S;
	int K;
	cin >> K;
	int ichi=0;
	for(int i=0;i<S.size();i++){
		if(S.at(i)=='1'){
			ichi++;
		}
		else break;
	}
	
	if(K>ichi) cout<<S.at(ichi)<<endl;
	else cout<<'1'<<endl;
}





Measured memory_bytes: 256
import collections
n = int(input())
s = list(input())
s_cnt = collections.Counter(s)

for i in range(n-1):
  tmp = input()
  for k in s_cnt:
    s_cnt[k] = min(s_cnt[k],tmp.count(k))

s_cnt=dict(sorted(s_cnt.items(), key=lambda x:x[0]))
ans = ""      
for k in s_cnt:
  ans += k*s_cnt[k]
print(ans)

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

int main(){
int a,b,c,temp;

cin >> a ;
cin >> b ;
cin >> c ;

if(a>b){
temp=a;
a=b;
b=temp;
}


if(b>c){
temp=b;
b=c;
c=temp;
}

if(a>b){
temp=a;
a=b;
b=temp;
}



cout << a << " " << b << " " << c <<endl ;

return 0 ;

}

Measured memory_bytes: 1164
# https://atcoder.jp/contests/abc075/tasks/abc075_b


H, W = gets.split.map(&:to_i)
Ss = Array.new(H) { gets.chomp }
ans = Array.new(H) { '#' * W } # 文字列オブジェクトを指定した回数繰り返す

# 行の繰り返しを見る
H.times do |y|
  # 列の繰り返しを見る
  W.times do |x|
    bom = 0

    # 爆弾がある場合
    if Ss[y][x] == '#'
      next # "#"を置いて次を見る
    end

    # 時計回りに見ていく
    # 左上
    if y != 0 && x != 0
      if Ss[y - 1][x - 1] == '#'
        bom += 1     
      end
    end

    # 上 x 軸は変わらない
    if y != 0
      if Ss[y - 1][x] == '#'
        bom += 1
      end
    end

    # 右上
    if y != 0 && x != W - 1
      if Ss[y - 1][x + 1] == '#'
        bom += 1
      end
    end

    # 右 y 軸は変わらない
    if x != W - 1
      if Ss[y][x + 1] == '#'
        bom += 1
      end
    end

    # 右下
    if y != H - 1 && x != W - 1
      if Ss[y + 1][x + 1] == '#'
        bom += 1
      end
    end

    # 下
    if y != H - 1
      if Ss[y + 1][x] == '#'
        bom += 1
      end
    end

    # 左下
    if y != H - 1 && x != 0
      if Ss[y + 1][x - 1] == '#'
        bom += 1
      end
    end

    # 左 y 軸は変わらない
    if x != 0
      if Ss[y][x - 1] == '#'
        bom += 1
      end
    end

    ## 一周終わり
    ans[y][x] = bom.to_s
  end
end

puts ans

#      -----
#      .....
#      .#.#.
#      .....
#      -----


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

const int MOD = 1e9+7;

int n;
string s;
v2<int> dp;
void solve(){
    cin >> s;
    n = s.length();
    dp = fill(n+1, 13, 0);
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 13; j++){
            if(s[i-1] == '?'){
                for(int k = 0; k < 10; k++){
                    int nxt = (10*j + k)%13;
                    dp[i][nxt] = (dp[i][nxt] + dp[i-1][j])%MOD;
                }
            } 
            else{
                int nxt = (10*j + s[i-1]-'0')%13;
                dp[i][nxt] = (dp[i][nxt] + dp[i-1][j])%MOD;
            }
        }
    }
    
    cout << dp[n][5] << '\n';
}

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


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3596
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mp make_pair
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<ll,ll> P;

template<typename T, typename S>
struct Mypair{
    T first;
    S second;
    Mypair(){
        first = 0;
        second  = 0;
    }
    Mypair(T _first, S _second){
        first = _first;
        second = _second;
    }
};
template<typename T, typename S>
bool operator<(const Mypair<T, S> &left, const Mypair<T, S> &right){
    if(left.first == right.first){
        return left.second > right.second;
    }
    else{
        return left.first < right.first;
    }
}
template<typename T, typename S> bool operator>(const Mypair<T, S> &left, const Mypair<T, S> &right){return right < left;}
template<typename T, typename S> bool operator>=(const Mypair<T, S> &left, const Mypair<T, S> &right){return !(left < right);}
template<typename T, typename S> bool operator<=(const Mypair<T, S> &left, const Mypair<T, S> &right){return !(right < left);}


int main(){
    int n;
    cin >> n;
    vector<P> da(n);
    rip(i,n,0){
        cin >> da[i].first >> da[i].second;
        da[i].second++;
    }
    ll ans = 0,R = INT_MAX, L = -1, larger = 0;
    rip(i,n,0){
        larger = max(larger, da[i].second - da[i].first);
        R = min(R, da[i].second);
        L = max(L ,da[i].first);
    }
    //printf("%lld %lld %lld\n", L, R, larger);
    ans = larger + max((ll)0, R - L);
    vector<Mypair<ll, ll>> li(n);
    rip(i,n,0){
        li[i].first = max(da[i].second - L, (ll)0);
        li[i].second  = max(R - da[i].first, (ll)0);
    }
    sort(all(li));
    ll mi = li[0].second;
    rip(i,n,1){
        ans = max(ans, li[i].first + mi);
        mi = min(mi, li[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,k,a[200050];
	cin >> n >> k;
	for(int i=1; i<=n; i++)cin >> a[i];
	ll l=1,r=1e9,mid,ans=0;
	while(l<=r){
		mid=(l+r)/2;
		ll jum=0;
		for(int i=1; i<=n; i++){
			jum+=(a[i]-1)/mid;
		}
		if(jum<=k){
			r=mid-1;
			ans=mid;
		}
		else{
			l=mid+1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5084
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        if (n == 1)
        {
            Console.WriteLine("! 1");
            return;
        }
        int max = -1, maid = -1;
        for (int i = 1; i < n; i++)
        {
            Console.WriteLine("? 1 " + (i + 1));
            int a = int.Parse(Console.ReadLine());
            if (max < a)
            {
                max = a;
                maid = i;
            }
        }
        var ans = new int[n];
        ans[0] = maid + 1;
        for (int i = 0; i < n; i++)
        {
            if (maid == i) continue;
            Console.WriteLine("? " + (maid + 1) + " " + (i + 1));
            int a = int.Parse(Console.ReadLine());
            ans[a] = i + 1;
        }
        Console.Write("!");
        foreach (var item in ans)
        {
            Console.Write(" " + item);
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 9436
a=Array.new(4){Array.new(3){Array.new(10,0)}}
gets.to_i.times{
b,f,r,v=gets.split.map &:to_i
a[b-1][f-1][r-1]+=v
}
4.times{|i|
3.times{|j| puts" #{a[i][j]*' '}"}
if i!=3
puts"#"*20
end
}

Measured memory_bytes: 8696
N = int(input())

result = 0
if N < 10:
  result = N
elif N < 100:
  result = 9
elif N < 1000:
  result = 9 + (N - 100 + 1)
elif N < 10000:
  result = 9 + 900
elif N < 100000:
  result = 9 + 900 + (N - 10000 + 1)
else:
  result = 9 + 900 + 90000
print(result)

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

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k){
        cout << s << endl;
    }
    else{
        rep(i, 0, k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
S = input()
N = len(S)
for i in range(0,(N-1)//2):
    if(S[i] != S[(N-1)//2-i-1]):
        print("No")
        exit()
for i in range(N):
    if(S[i] != S[N-1-i]):
        print("No")
        exit()
for i in range((N+3)//2-1,N):
    if(S[i] != S[N-i-1]):
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
// ---------- BEG ../defs.hpp BEG ----------
#ifndef atcoder_defs_hpp
#define atcoder_defs_hpp
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
using i8t = std::int64_t;
using u8t = std::uint64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
using vu8t = std::vector<u8t>;
#include <limits>
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
#include <unordered_map>
#include <unordered_set>
template<typename Key,typename Value> using map_t=std::unordered_map<Key, Value>;
template<typename Key> using set_t=std::unordered_set<Key>;
#define F3(i,i0,iN,step) for(i8t i=i0,i##_N=iN;i<i##_N;i+=step)
#define F2(i,i0,iN) F3(i,i0,iN,1)
#define F(i,N) F3(i,0,N,1)
#define FR(i,N) for(i8t i=N;i--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}
template<typename T> struct identity { using type = T; };
#endif
// ---------- END ../defs.hpp END ----------

int main() {
  R(L);
  printf("%.12f\n",L*L*L/27.0);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <complex>
#include <cstdlib>
#include <iomanip>

using namespace std;

const double eps = 1e-10;
typedef complex<double> Point;

ostream& operator<<(ostream& os, const Point& p){
    return os <<  p.real() << " " << p.imag();
}

inline double cross(const Point& a, const Point& b){
    return imag(conj(a) * b);
}

struct Line : vector<Point> {
    Line(const Point& a, const Point& b):vector<Point>{a, b}{}
};

inline bool interSP(const Line& s, const Point& p){
    return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < eps;
}

Point xptSS(const Line& s, const Line& t){
    double d = cross(s[1] - s[0], t[1] - t[0]);
    if(abs(d) < eps){
        if(interSP(t, s[0]))return s[0];
        if(interSP(t, s[1]))return s[1];
        if(interSP(s, t[0]))return t[0];
        return t[1];
    }
    return t[0] + (t[1] - t[0]) * cross(s[1] - s[0], s[1] - t[0]) * (1.0 / d);
}

int main(){
    int q;
    cin >> q;
    while(q--){
        int x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Line s(Point(x0, y0), Point(x1, y1)), t(Point(x2, y2), Point(x3, y3));
        cout << fixed << setprecision(10) << xptSS(s, t) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1268