akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
  int id;
  int par, lft, rit;
}T_node;
T_node *T;
/*int cntdeg(T_node *);
int cntdpt(T_node *);
int gethig(T_node *, int);*/

void preo(T_node *);
void ino(T_node *);
void psto(T_node *);

int main(){
  int n;
  scanf("%d", &n);
  T = (T_node *)malloc(sizeof(T_node) * n);
  int i, id, lcl, rcl;
  for(i = 0; i < n; i++)
    T[i].par = T[i].rit = T[i].lft = -1;
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    T[id].id = id;
    scanf("%d %d", &T[id].lft, &T[id].rit);
    if(T[id].lft >= 0)
      T[T[id].lft].par = id;
    if(T[id].rit >= 0)
      T[T[id].rit].par = id;
  }
  int rot = 0;
  for(i = n - 1; i >= 0; i--)
    if(T[i].par < 0)
      rot = i;

  printf("Preorder\n");
  preo(&T[rot]);
  printf("\nInorder\n");
  ino(&T[rot]);
  printf("\nPostorder\n");
  psto(&T[rot]);
  printf("\n");

/*  int sib;
  for(i = 0; i < n; i++){
    sib = -1;
    if(T[i].par < 0){
      if(T[i].lft >= 0)
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n", i, T[i].par, sib, cntdeg(&T[T[i].lft]), cntdpt(&T[i]), gethig(&T[i], 0));
      else
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n", i, T[i].par, sib, 0, cntdpt(&T[i]), gethig(&T[i], 0));
    }
    else{
      if(T[i].rit >= 0)
	sib = T[i].rit;
      else
	sib = T[T[i].par].lft != i ? T[T[i].par].lft : -1;
      if(T[i].lft >= 0)
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n", i, T[i].par, sib, cntdeg(&T[T[i].lft]), cntdpt(&T[i]), gethig(&T[i], 0));
      else
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n", i, T[i].par, sib, 0, cntdpt(&T[i]), gethig(&T[i], 0));
    }
  }*/
  free(T);
  return 0;
}
/*
int cntdeg(T_node *t){
  if(t->rit < 0)
    return 1;
  return cntdeg(&T[t->rit]) + 1;
}

int cntdpt(T_node *t){
  if(t->par >= 0)
    return cntdpt(&T[t->par]) + 1;
  else
    return 0;
}
  
int gethig(T_node *t, int hig){
  if(t->lft < 0)
    return hig;
  int lhi = gethig(&T[t->lft], hig + 1), rhi = -1;
  if(T[t->lft].rit >= 0)
    rhi = gethig(&T[T[t->lft].rit], hig + 1);
  return rhi < lhi ? lhi : rhi;
}
*/

void preo(T_node *t){
  printf(" %d", t->id);
  if(T[t->id].lft >= 0)
    preo(&T[T[t->id].lft]);
  if(T[t->id].rit >= 0)
    preo(&T[T[t->id].rit]);
}
void ino(T_node *t){
  if(T[t->id].lft >= 0)
    ino(&T[T[t->id].lft]);
  printf(" %d", t->id);
  if(T[t->id].rit >= 0)
    ino(&T[T[t->id].rit]);
}
void psto(T_node *t){
  if(T[t->id].lft >= 0)
    psto(&T[T[t->id].lft]);
  if(T[t->id].rit >= 0)
    psto(&T[T[t->id].rit]);
  printf(" %d", t->id);
}

Measured memory_bytes: 616
#include <iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;

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

    long long int ans = 0;
    
    for(int i=0; i<n; i++){
        if(A[i] > B[i]){
            A[i] -=B[i];
            ans += B[i];
        }else{
            B[i] -= A[i];
            ans += A[i] ;

            if(A[i+1] > B[i]){
                A[i+1] -= B[i];
                ans += B[i];
            }else{
                ans += A[i+1];
            	A[i+1] = 0;
            }

        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();
		int a = s.nextInt();
		int b = s.nextInt();
		String answer = "";

		if (0 <= b && b <= a) {
			answer = "delicious";
		} else if (a < b && b <= a + x) {
			answer = "safe";
		} else if (a + x < b) {
			answer = "dangerous";
		}
		System.out.println(answer);
	}

}


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

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int min = INF;
    int ans = 0;

    rep(i,n){
        if(p[i]<min){
            ans++;
            min = p[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

long dp[64][2];

void solve()
{
	long n, k;
	cin >> n >> k;
	vector<long> as(n);
	for (long& a : as)
	{
		cin >> a;
	}
	memset(dp, -1, sizeof(dp));
	dp[51][1] = 0;
	for (int i = 50; i>= 0; i--)
	{
		long b = 1L << i, c = 0;
		for (long a : as)
		{
			c += a >> i & 1;
		}
		if (b & k)
		{
			if (dp[i+1][1] != -1)
			{
				dp[i][1] = max(dp[i][1], dp[i+1][1]+(n-c)*(1L<<i));
				dp[i][0] = max(dp[i][0], dp[i+1][1]+c*(1L<<i));
			}
			if (dp[i+1][0] != -1)
			{
				dp[i][0] = max(dp[i][0], dp[i+1][0]+c*(1L<<i));
				dp[i][0] = max(dp[i][0], dp[i+1][0]+(n-c)*(1L<<i));
			}

		}
		else
		{
			if (dp[i+1][1] != -1)
			{
				dp[i][1] = max(dp[i][1], dp[i+1][1] + c*(1L<<i));
			}
			if (dp[i+1][0] != -1)
			{
				dp[i][0] = max(dp[i][0], dp[i+1][0]+c*(1L<<i));
				dp[i][0] = max(dp[i][0], dp[i+1][0]+(n-c)*(1L<<i));
			}
		}
	}

	cout << max(dp[0][0], dp[0][1]) << endl;

}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string s;
  cin>>s;
  if(s.at(0)==s.at(1) && s.at(1)==s.at(2)){
   cout<<"No"<<endl; 
  }else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fo(i, x, y)   for (__typeof(x) i = x; i < y; ++i)
#define fr(i, x, y)   for (__typeof(x) i = x; i > y; i--)
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
const ll mod=1000000007;
const ll AM=2e5+5;
using namespace std;
int main()
{
    fast;
    ll n; cin>>n;
    ll a[n+1][4];
    fo(i,1,n+1)
    {
    	fo(j,1,4)
    		cin>>a[i][j];
    }
    vdp(n+1,4);
    dp[1][1]=a[1][1]; dp[1][2]=a[1][2]; dp[1][3]=a[1][3];
    fo(i,2,n+1)
    {
    	dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][3]);
    	dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][3]);
    	dp[i][3]=a[i][3]+max(dp[i-1][1],dp[i-1][2]);
    } 
    cout<<max(max(dp[n][1],dp[n][2]),dp[n][3]);
    
}

Measured memory_bytes: 10368
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        b = True
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
        for j in range(N):
            if xyh[j][2] != max(H - abs(xyh[j][0]-x) - abs(xyh[j][1]-y), 0):
                b = False
                break
        if b:
            break
    if b:
        break
print(x,y,H)

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

int main(){
    int N, M;
    cin >> N >> M;
    int k, l;
    vector<vector<int>> ns(M, vector<int>(0));
    vector<int> te(M);
    rep(i, M){
        cin >> k;
        rep(j, k){
            cin >> l;
            ns.at(i).push_back(l-1);
        }
    }
    rep(i, M) cin >> te.at(i);
    ll pa = pow(2, N);
    ll ans = 0;
    for(ll ii=0; ii<pa; ii++){
        bitset<10> b(ii);
        int f = 0;
        rep(i, M){
            int cou = 0;
            rep(j, ns.at(i).size()){
                if(b.test(ns.at(i).at(j))) cou++;
            }
            if(cou%2 != te.at(i)) f = 1;
        }
        if(f == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define INFF 10000000007
#define MOD 1000000007
long long m,n,x;
int main()
{
    cin>>m>>n;
    if(m>n/2)
        x=n/2;
    else
        x=m+(n-m*2)/4;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdint>
#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>
#include <complex>
 
#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 complex<double> P;
int n;
 
double cross(P p1,P p2) {
    return (real(p1)*imag(p2) - imag(p1)*real(p2));
}
double calc_S(P p1,P p2,P p3) {
    double ret = 0.0;
    p1 -= p3;
    p2 -= p3;
 
    ret = cross(p1,p2)/2.0;
     
    return abs(ret);
}
 
int main() {
    cin>>n;
    while(n-->0) {
        double x1_,y1_;
        double x2_,y2_;
        double x3_,y3_;
        cin>>x1_>>y1_>>x2_>>y2_>>x3_>>y3_;
        P p1(x1_,y1_);
        P p2(x2_,y2_);
        P p3(x3_,y3_);
        P A = p1-p2;
        P B = p2-p3;
        P C = p1-p3;
        double S = calc_S(p1,p2,p3);
        double R = abs(A)*abs(B)*abs(C)/S;
        R /= 4.0;
         
        P A1 = 2.0*(p2-p1);
        P B1 = 2.0*(p3-p1);
        P C1 = P(norm(p1)-norm(p2),norm(p1)-norm(p3));
        double X = cross(P(imag(A1),imag(B1)),C1)/cross(A1,B1);
        double Y = cross(C1,P(real(A1),real(B1)))/cross(A1,B1);
        printf("%.3lf %.3lf %.3lf\n",X,Y,R);
 
    }
    return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

int n, k, t, u, v, l;
int road[10001];
double ti[10001];
int cnt;
queue<int> st;

int main(){
	cin >> n >> k >> t >> u >> v >> l;
	rep(i,n){
		int d; cin >> d;
		road[d] = 1;
	}
	for(int i = 1; i <= l; i++){
		if(cnt == 0){
			ti[i] = ti[i-1]+1.0/u;
		} else{
			ti[i] = ti[i-1]+1.0/v;
			if(i-st.front() >= t*v){
				st.pop();
				cnt--;
				if(cnt > 0) st.front() = i;
			}
		}
		if(road[i] == 1){
			if(cnt <= k){
				st.push(i);
				cnt++;
			} else{
				st.pop();
				st.front() = i;
				st.push(i);
			}
		}
	}
	printf("%.9f\n",ti[l]);
}

Measured memory_bytes: 1344
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner keyboard = new Scanner(System.in);
        String S = keyboard.nextLine();
       
        if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5))
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

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

llint n, m;
llint dp[5005][5005];
llint beki[5005], beki2[5005], sum[5005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	
	beki[0] = 1, beki2[0] = 1;
	for(int i = 1; i < 5005; i++) beki[i] = beki[i-1] * 2, beki[i] %= mod;
	for(int i = 1; i < 5005; i++) beki2[i] = beki2[i-1] * ((mod+1)/2) % mod, beki2[i] %= mod;
	
	dp[0][m] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 2; j <= m; j++) sum[j] = sum[j-1] + dp[i-1][j]*beki[j]%mod, sum[j] %= mod;
		for(int j = 1; j <= m; j++){
			dp[i][j] = dp[i-1][j]*(j+1)%mod;
			dp[i][j] += (sum[m] - sum[j] + mod) % mod * j % mod * beki2[j+1] % mod, dp[i][j] %= mod;
		}
	}
	
	llint ans = 0;
	for(int i = 1; i <= m; i++) ans += dp[n][i], ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 199192
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000009;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);


struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

void solve() {
	int x[5];
	rep(i, 5)cin >> x[i];
	rep(i, 5) {
		if (x[i] == 0) {
			cout << i + 1 << "\n"; return;
		}
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init_f();
	//init();
	//int t; cin >> t;rep(i,t)
	solve();
	stop
		return 0;
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

vector<string> v{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main() {
	string s;
	cin >> s;

	if(s == "SUN") {
		printf("7\n");
		return 0;
	}
	for(int i = 0; i < v.size(); i++) {
		if(v[i] == s) {
			printf("%d\n", 7-i);
			return 0;
		}
	}

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    //int N = sc.nextInt();
    int count = 0;
    
    if(str.charAt(0) == str.charAt(1)){
        count++;
    }else{
    }
    if(str.charAt(0) == str.charAt(2)){
        count++;
    }else{
    }
    if(str.charAt(1) == str.charAt(2)){
        count++;
    }else{
    }
    
    if(count == 3){
        System.out.println("No");
    }else{
        System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 23764
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String str,move;
		int shuffle,cards;
		while(true){
			str=sc.next();
			if(str.equals("-")){
				break;
			}
			else{
				shuffle=sc.nextInt();
				for(int i=0;i<shuffle;i++){
					cards=sc.nextInt();
					move=str.substring(0,cards);
					str=str.replaceFirst(move,"");
					str+=move;
				}
				System.out.println(str);
			}
		}
	}
}


Measured memory_bytes: 26660
#include <stdio.h>
#include <math.h>

int main(void) {
    int n;
    double x, y, x1, y1, x2, y2, x3, y3, x12, y12, z12, x23, y23, z23, r;
    scanf("%d", &n);

    while (n--) {
        scanf("%lf%lf%lf%lf%lf%lf",
              &x1, &y1, &x2, &y2, &x3, &y3);
        x12 = 2 * (x2 - x1);
        y12 = 2 * (y2 - y1);
        z12 = x1*x1 - x2*x2 + y1*y1 - y2*y2;
        x23 = 2 * (x3 - x2);
        y23 = 2 * (y3 - y2);
        z23 = x2*x2 - x3*x3 + y2*y2 - y3*y3;
        x = (y12*z23 - y23*z12) / (x12*y23 - x23*y12);
        y = (z12*x23 - z23*x12) / (x12*y23 - x23*y12);
        r = hypot(x1 - x, y1 - y);
        printf("%.3lf %.3lf %.3lf\n", x, y, r);
    }

    return 0;
}

Measured memory_bytes: 676
#include<stdio.h>
int main() {
	while (1) {
		int n, j,k, a[10000], sum = 0, m = 0;
		scanf("%d", &n);
		if (n == 0)
			break;
		for (j = 1; j <=n; j++) {
			scanf("%d", &a[j]);
			sum += a[j];
		}
		for (j = 1; j <=n; j++) {
			if (a[j] <= sum / n)
				m++;
		}
		printf("%d\n", m);
	}
	return 0;
}


Measured memory_bytes: 2784
#include <stdio.h>

int main(void)
{
	int num;

	scanf("%d", &num);

	if (num % 10 == 3)
	{
		printf("bon\n");
	}
	else if(num % 10 == 0 || num % 10 == 1 || num % 10 == 6 || num % 10 == 8)
	{
		printf("pon\n");
	}
	else
	{
		printf("hon\n");
	}

	return 0;
}

Measured memory_bytes: 1624
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){

	int R[MAX], n;
	cin >> n;
	for (int i=0;i<n;i++) cin >>R[i];
	
	int maxv = (1<<30)* -1;
	int minv = R[0];
	for (int i=1;i<n;i++) {
		maxv = max(maxv,R[i]-minv);
		minv = min(minv,R[i]);
	}
	cout << maxv << endl;
	return 0;
}



Measured memory_bytes: 3880
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n):
    for j in range(i+1, n):
        pw = 0
        for k in range(d):
            pw += (x[i][k]-x[j][k])**2
        if pw**0.5%1==0: ans+=1
print(ans)

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

typedef long long ll;

const ll inf = 1000000000000000;

int main()
{
    ll n, k, x[MAX], cs[MAX];

    scanf("%lld %lld", &n, &k);

    for(int i = 1; i <= n; i++){
        scanf("%lld", &x[i]);
    }

    int start = 1;

    ll Min = inf, ans;

    for(int End = k; End <= n; End++){
        ans = min(abs(x[start]) + abs(x[End] - x[start]), abs(x[End]) + abs(x[End] - x[start]));
        if(ans < Min)
            Min = ans;
        start++;
    }

    printf("%lld\n", Min);

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int a,b;
	while(scan.hasNext())
	    {
	a=scan.nextInt();
	b=scan.nextInt();
	String str=Integer.toString(a+b);
	System.out.println(str.length());
	    }
    }
}

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

int main() {
  string S,T;
  int ret = 0;
  
  cin >> S >> T;
  
  for (int i = 0; i < 3; i++){
    if(S.at(i) == T.at(i)){
      ret++;
    }
  }
  cout << ret << endl;

}


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

const double EPS = 1e-10;
struct Point2D {
    Point2D(){}
    Point2D(double x, double y): x(x), y(y) { }

    bool operator ==(const Point2D p){ return abs(p.x - x) < EPS && abs(p.y - y) < EPS; }
    Point2D operator +(const Point2D p){ return Point2D(x + p.x, y + p.y); }
    Point2D operator -(const Point2D p){ return Point2D(x - p.x, y - p.y); }
    Point2D operator *(const double d){ return Point2D(d*x, d*y); }
    double operator *(const Point2D p){ return x*p.x + y*p.y; }
    Point2D operator /(const double d){ return Point2D(x/d, y/d); }
    double norm(){ return sqrt(x*x + y*y); }

    double x, y;

    private:
        
};

struct Circle {
    Circle(){}
    Circle(Point2D center, double radius): center(center), radius(radius) { }
    Circle(Point2D p0, Point2D p1){
        // 2点を直径とする円
        center = (p0 + p1)/2;
        radius = (p0 - p1).norm()/2;
    }
    Circle(Point2D p0, Point2D p1, Point2D p2){
        // 3点の外接円
        double a = (p2 - p1).norm();
        double b = (p0 - p2).norm();
        double c = (p1 - p0).norm();
        double A = a*a*(b*b + c*c - a*a);
        double B = b*b*(c*c + a*a - b*b);
        double C = c*c*(a*a + b*b - c*c);
        
        center = (p0*A + p1*B + p2*C)/(A+B+C);
        radius = a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
    }

    Point2D center;
    double radius;
};



int main(){
    int N;  cin >> N;
    vector<Point2D> P(N);
    for(int i=0; i<N; i++){
        cin >> P[i].x >> P[i].y;
    }

    double ans = 1e9;
    for(int i=0; i<N-1; i++) for(int j=i+1; j<N; j++){
        Circle C(P[i], P[j]);
        bool ok = true;
        for(int n=0; n<N; n++){
            double dist = (C.center - P[n]).norm();
            if(C.radius + EPS - dist < 0) { ok = false;  break; }
        }

        if(ok){
            ans = min(ans, C.radius);
        }
    }

    for(int i=0; i<N-2; i++) for(int j=i+1; j<N-1; j++) for(int k=j+1; k<N; k++){
        Circle C(P[i], P[j], P[k]);
        bool ok = true;
        for(int n=0; n<N; n++){
            double dist = (C.center - P[n]).norm();
            if(C.radius + EPS - dist < 0) { ok = false;  break; }
        }

        if(ok){
            ans = min(ans, C.radius);
        }
    }

    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Anirudh Rayabharam (mail@anirudhrb.com)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        KCity solver = new KCity();
        solver.solve(1, in, out);
        out.close();
    }

    static class KCity {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int m = in.nextInt();
            int n = in.nextInt();
            out.println((m - 1) * (n - 1));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define MOD 1000000007
#define int long long int
//------------ATCODER TEMPLATE-------------

vector<int> fact, finv, inv;
void init(int N) {
  fact.resize(N + 1);
  finv.resize(N + 1);
  inv.resize(N + 1);
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= N; i++) {
    fact[i] = fact[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
  int S; cin >> S;
  init(20000);

  int total = 0;
  int ball = S-3;
  int bar = 0;
  while (true) {
    if (ball < 0) break;
    total += comb(ball + bar, bar);
    ball -= 3;
    bar += 1;
    total %= MOD;
  }
  cout << total << endl;
  return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    vector<string> M;
    REP(i, H)
    {
        string s = "";
        REP(j, W)
        {
            if ((i < B) ^ (j < A))
                s.push_back('0');
            else
                s.push_back('1');
        }
        M.push_back(s);
    }
    REP(i, H)
    {
        cout << M[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 2304
def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

n=int(input())
arr=factorization(n)
num=[1,3,6,10,15,21,28,36,45,55,66]

res=0
for x,y in arr:
	 for i in num:
	 	if y>=i:
	 		res+=1

if n==1:
	print("0")
else:
	print(res)

Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String[] caBefore = new String[n];
        
        for (int i = 0; i < n; i++)
            caBefore[i] = sc.next();
        
        String[] caAfter = caBefore.clone();
//        String[] ca2Before = caBefore.clone();
        String[] ca2After = caBefore.clone();
        
        //　バブルソート
        for (int i = 0; i < n; i++)
            for (int j = n - 1; j >= i + 1; j--)
                if (caAfter[j].charAt(1) < caAfter[j-1].charAt(1))
                    swap(caAfter, j, j-1);
                    
        printlnArray(caAfter);
        System.out.println("Stable");
        
        // 選択ソート
        for (int i = 0; i < n; i++) {
            int minj = i;
            for (int j = i+1; j < n; j++) {
                if (ca2After[minj].charAt(1) > ca2After[j].charAt(1)) {
                    minj = j;
                }
            }
            swap(ca2After, minj, i);
        }
        
        printlnArray(ca2After);
        boolean isStable = true;
        for (int i = 0; i < n; i++) {
            if (!ca2After[i].equals(caAfter[i])) {
                isStable = false;
            }
        }
        System.out.println(isStable ? "Stable" : "Not stable");
    }
    
    static void swap(String[] ca, int i, int j) {
        String temp = ca[i];
        ca[i] = ca[j];
        ca[j] = temp;
    }

    private static void printlnArray(String[] ca) {
        for (int i = 0; i < ca.length - 1; i++) {
            System.out.print(ca[i] + " ");
        }
        System.out.println(ca[ca.length - 1]);
    }
}


Measured memory_bytes: 26336
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=2e6+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll inv[N],fac[N];
void pre()
{
    fac[0]=1;
    for(int i=1;i<N;++i) fac[i]=fac[i-1]*i%mod;
    inv[N-1]=qpow(fac[N-1],mod-2,mod);
    for(int i=N-2;~i;--i) inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int n,int m)
{
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;
    pre();
    int n;cin>>n;
    string s;cin>>s;
    int m=s.size();
    ll ans=0;
    for(int i=0;i<=n;++i)
    {
        ans=(ans+qpow(26,i,mod)*C(n+m-i-1,m-1)%mod*qpow(25,n-i,mod)%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35532
#include<stdio.h>

int main(void)
{
    int a,b,x,s;
    scanf("%d%d",&a,&b);
    s=a+b;
    if(s%2!=0)
    {
        x=s/2+1;
        printf("%d\n",x);
    }
    else
    {
        x=s/2;
        printf("%d\n",x);
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String out = "Yes";
        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                if (s.charAt(i) == 'L') {
                    out = "No";
                    break;
                }
            } else {
                if (s.charAt(i) == 'R') {
                    out = "No";
                    break;
                }
            }
        }

        System.out.println(out);

        sc.close();
    }

}


Measured memory_bytes: 23124
import itertools
from collections import defaultdict
import collections
import math
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

n = list(input())

if n[-1] == "3":
    print("bon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
    print("pon")
else:
    print("hon")

Measured memory_bytes: 9404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 2147483647;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const ll LLMAX = 9223372036854775805;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    vector<bitset<32>> p(n);
    for(int i=0;i<n;i++){
        int x = a[i];
        int cnt = 0;
        while(x>0){
            p[i][cnt] = x%2;
            x /= 2;
            cnt++;
        }
    }
    int sum = 0;
    for(int i=0;i<n;i++){
        sum = (sum^a[i]);
    }
    //cout << sum << endl;
    for(int i=0;i<n;i++){
        cout << (sum ^ a[i]) << " ";
    }
    cout << endl;

}

Measured memory_bytes: 5644
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_list_of_float():
    return [float(f) for f in input().split()]


def get_list_of_char():
    return list(input().strip())


def get_data(n, order=None, **kwargs):
    if not order:
        order = range(len(kwargs))
    it = iter(order)
    var, fn = zip(*sorted(sorted(kwargs.items()), key=lambda _: next(it)))

    rows = []
    for _ in range(n):
        rows.append(input().split())
    columns = zip(*rows)
    exec("global "+", ".join(var)+"\n"+"\n".join(
        v+"=list(map(fn[{}], data[{}]))".format(i, i)
        for i, v in enumerate(var)),
        globals(),
        {"fn": list(fn), "data": list(columns)}
    )
    return


# inputs
H, W = 0, 0
h, w = 0, 0


def set_inputs():
    global H, W, h, w
    H, W = get_list_of_int()
    h, w = get_list_of_int()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    print((H - h) * (W - w))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

struct edge { ll to, cost; };
std::vector<edge>v[200010], vv[200010];
ll d[200010];

void dijkstra(ll n,ll s) {
	for (int i = 0;i <= n;i++) {
		d[i] = INF2;
	}
	d[s] = 0;
	std::priority_queue<P, std::vector<P>, std::greater<P>>pq;
	pq.push(P(d[s], s));
	while (!pq.empty()) {
		P a = pq.top();
		pq.pop();
		ll i = a.second;
		if (d[i] < a.first)continue;
		for (int k = 0;k < v[i].size();k++) {
			edge e = v[i][k];
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(P(d[e.to], e.to));
		}
	}
	return;
}

void dijkstra2(ll n, ll s) {
	for (int i = 0;i <= n;i++) {
		d[i] = INF2;
	}
	d[s] = 0;
	std::priority_queue<P, std::vector<P>, std::greater<P>>pq;
	pq.push(P(d[s], s));
	while (!pq.empty()) {
		P a = pq.top();
		pq.pop();
		ll i = a.second;
		if (d[i] < a.first)continue;
		for (int k = 0;k < vv[i].size();k++) {
			edge e = vv[i][k];
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(P(d[e.to], e.to));
		}
	}
	return;
}

int main() {
	ll n, m, s, t, x[100010], y[100010], A[100010], b[100010], yen[100010], suu[100010];
	cin >> n >> m >> s >> t;
	for (int i = 0;i < m;i++) {
		cin >> x[i] >> y[i] >> A[i] >> b[i];
		v[x[i]].pb(edge{ y[i], A[i] });
		v[y[i]].pb(edge{ x[i],A[i] });
	}
	dijkstra(n, s);
	for (int i = 0;i <= n;i++)yen[i] = d[i];
	for (int i = 0;i < m;i++) {
		vv[x[i]].pb(edge{ y[i], b[i] });
		vv[y[i]].pb(edge{ x[i],b[i] });
	}
	dijkstra2(n, t);
	for (int i = 0;i <= n;i++)suu[i] = d[i];
	vector<P>p(n);
	for (int i = 0;i < n;i++) {
		p[i].fr = suu[i+1] + yen[i+1];
		p[i].sc = i+1;
	}
	sort(ALL(p));
	int now = 1;
	for (int i = 0;i < n;i++) {
		if (now <= p[i].sc) {
			for (;now <= p[i].sc;now++) {
				cout << (ll)1000000000000000 - p[i].fr << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 28544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,E,T,q[N],head,tail,x[N];ll dp[N];
ll cost(int i,int j){return dp[j]+x[i]-x[j]+T;}
int main()
{
	scanf("%d%d%d",&n,&E,&T);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	int p=0;ll v=1e16;
	q[head=tail=1]=0;
	for (int i=1;i<=n;i++){
		for (;p<i&&2*(x[i]-x[p+1])>=T;p++) v=min(v,dp[p]-x[p]-2*x[p+1]);
		for (;head<=tail&&2*(x[i]-x[q[head]+1])>T;head++);
		dp[i]=v+3ll*x[i];
		if (head<=tail) dp[i]=min(dp[i],cost(i,q[head]));
		for (;head<=tail&&cost(i,q[tail])>=cost(i,i);tail--);
		q[++tail]=i;
	}
	printf("%lld\n",dp[n]+E-x[n]);
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main (void)

{

int a, b, c ;

int count=0;

int i;


scanf("%d %d %d",&a, &b, &c);

for(i=a; i<=b; i++){

if(c%i==0)

count++;

}



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

return 0;

}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(24) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int MOD = 1e9 + 7;

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b; //先に割り算をして掛けられる数を小さくして掛け算を行う
}

bool pairCompare(const pair<int, int> &firstElof, const pair<int, int> &secondElof)
{
    return firstElof.second < secondElof.second;
}

void solve()
{
    int n;
    map<string,int> m;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl; 
    cout << "WA x " << m["WA"] << endl; 
    cout << "TLE x " << m["TLE"] << endl; 
    cout << "RE x " << m["RE"] << endl; 
}

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


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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, x; std::cin >> n >> x;
  vi a(n); rep(i, n) std::cin >> a[i];
  ll ans = 0;
  rep(i, n-1) {
    if (a[i+1] + a[i] <= x) continue;
    int num = a[i+1] + a[i] - x;
    a[i+1] -= min(a[i+1], num);
    ans += num;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 640
N, W, *WV = map(int, open(0).read().split())

C = {0: 0}
for v, w in zip(*[reversed(WV)] * 2):
    for x, y in C.copy().items():
        if x + w <= W:
            C[x + w] = max(C.get(x + w, 0), y + v)

print(max(C.values()))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B;
cin >> A >> B;
int c,d,e;
c = A+B;
d = A*B;
e = A-B;
if(c>=d&&c>=e){
    cout<<c;
}
else if(d>=c&&d>=e){
    cout<<d;
}
else{
    cout<<e;
}
return 0;
}

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

const char Col[2][2] = { { 'R','Y' },{ 'G','B' } };
int H, W, d;

char get_col(int x, int y) {
	int i = (x / d) % 2;
	int j = (y / d) % 2;
	return Col[i][j];
}

int main() {

	ios::sync_with_stdio(false);
    cin.tie(0);
	cin >> H >> W >> d;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int x = i + j;
			int y = j - i + H;
//			cout << j <<" "<< i << "----";
//			cout << y <<" "<< x << endl;
			char c = get_col(x, y);
			cout << c;
			if (j == W - 1)
				cout << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int Travel(vector<int> c,vector<int> s,vector<int> f,int i,int n){
  int time=0;
  for(int j=i;j<n-1;j++){
    int wait_time=s[j];
    while(wait_time<time){
      wait_time += f[j];
    }
    time = wait_time + c[j];
  }
  return time;
}

int main(){
  int n;
  cin >> n;
  vector<int> c(n-1),s(n-1),f(n-1);
  for(int i=0;i<n-1;i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  int time;
  for(int i=0;i<n-1;i++){
    time = Travel(c,s,f,i,n);
    cout << time << "\n";
  }
  cout << 0 << "\n";
  

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int ll

using namespace std;

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

const int INF = 1e9 + 7;

int a[100005], b[100005], p[100005], bit[200005];

int lowbit(int x) {
	return x & -x;
}

int qry(int i) {
	int ans = 0;
	while(i) {
		ans += bit[i];
		i -= lowbit(i);
	}
	return ans;
}

void add(int i, int x) {
	while(i < 200005) {
		bit[i] += x;
		i += lowbit(i);
	}
}

int ct(int k, int n) {
	for(int i=0;i<n;i++) 
		if(a[i] >= k)
			p[i+1] = 1;
		else
			p[i+1] = -1;
	p[0] = 0;
	for(int i=1;i<=n;i++)
		p[i] += p[i-1];
	//for(int i=0;i<=n;i++) cerr << "p[" << i << "]=" << p[i] << endl;
	for(int i=0;i<=n;i++)
		p[i] += n + 1;
	memset(bit, 0, sizeof(bit));
	int ans = 0;
	for(int i=0;i<=n;i++) {
		ans += qry(p[i]);
		add(p[i], 1);
	}
	//cerr << k << ' ' << ans << endl;
	return ans;
}

int32_t main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n;i++)
		b[i] = a[i];
	sort(b, b+n);
	int l = 0, r = n-1;
	int v = n*(n+1) / 2;
	while(l <= r) {
		int m = (l + r) / 2;
		if(ct(b[m], n) > (v-1) / 2) {
			l = m + 1;
		} else {
			r = m - 1;
		}
	}
	cout << b[r] << endl;
}



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

using namespace std;

inline int inv(int a, int m) {
	int i = 1, j = 0;
	for (int b = m; a > 1; swap(i, j), swap(a, b)) {
		j = (j + b / a * long(m - i)) % m;
		b %= a;
	}
	return i;
}
long d[3333] = { 1 }, f[3333];
int main() {
	int n, k = 0, a = 1, p = 1e9 + 7;
	string s;
	cin >> n >> s;
	f[0] = p - 1;
	s += '>';
	for (auto c : s) {
		k++;
		f[k] = f[k - 1] * inv(k, p) % p;
		if (c == '<')
			continue;
		for (int i = k; i--;)
			(d[k] += d[i] * f[k - i]) %= p;
		a = -a;
	}
	cout << d[k] * (p - inv(f[k], p)*a) % p << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;

int main() {
  string S;
  cin >> S;
  if (S[0] != S[1] && S[0] != S[2] && S[2] != S[1]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        while (true) {
            String data[] = reader.readLine().split(" ");
            int a = Integer.parseInt(data[0]);
            int b = Integer.parseInt(data[1]);
            if (a == 0 && b == 0) {
                break;
            }
            sb.append(Integer.toString(a< b ? a : b)).append(" ").append(Integer.toString(a < b ? b : a)).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 26688
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif
    int x;
    while (cin >> x) {
        cout << 360 / gcd(360, x) << endl;
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 3800