akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
#define INF 1e6


template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};


int l[200010],r[200010],d[200010];
int main(){
    int n,m;
    cin>>n>>m;
    
    UnionFind<int> uni(n);
    
    for (int i = 0; i < m; i++)
    {
        cin>>l[i]>>r[i]>>d[i];
        l[i]--;
        r[i]--;

    }
    for (int i = 0; i < m; i++)
    {
        if(uni.issame(l[i],r[i])){
            int diff=uni.diff(l[i],r[i]);
            if(diff!=d[i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
            uni.merge(l[i],r[i],d[i]);
        }
    }

    cout<<"Yes"<<endl;
   
    
    
   

    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <cmath>

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

using namespace std;

double sx, sy, sz, dx, dy, dz;

int outside(double a, double b, double c)
{
	double x, y, z;
	x = sqrt((a - sx) * (a - sx) + (b - sy) * (b - sy) + (c - sz) * (c - sz));
	y = sqrt((a - dx) * (a - dx) + (b - dy) * (b - dy) + (c - dz) * (c - dz));
	z = sqrt((sx - dx) * (sx - dx) + (sy - dy) * (sy - dy) + (sz - dz) * (sz - dz));

	double keep1 = (x * x + z * z - y * y) / (2 * x * z);
	double keep2 = (y * y + z * z - x * x) / (2 * y * z);

	if (keep1 < 0) return 1;
	else if (keep2 < 0) return 2;
	else return 0;
}


int main(void)
{
	int n, q;
	cin >> n >> q;

	vec<double> x(n), y(n), z(n), r(n);
	vec<ll> l(n);

	rep(i, n) cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];

	rep(i, q) {
		cin >> sx >> sy >> sz >> dx >> dy >> dz;
		ll ans = 0;
		rep(j, n) {
			int w = outside(x[j], y[j], z[j]);
			if (w == 1) {
				if ((x[j] - sx) * (x[j] - sx) + (y[j] - sy) * (y[j] - sy) + (z[j] - sz) * (z[j] - sz) <= r[j] * r[j]) ans += l[j];
			}
			else if (w == 2) {
				if ((x[j] - dx) * (x[j] - dx) + (y[j] - dy) * (y[j] - dy) + (z[j] - dz) * (z[j] - dz) <= r[j] * r[j]) ans += l[j];
			}
			else {
				double v1 = sx - dx;
				double v2 = sy - dy;
				double v3 = sz - dz;
				double v = v1 * v1 + v2 * v2 + v3 * v3;
				double t = (v1 * (x[j] - sx) + v2 * (y[j] - sy) + v3 * (z[j] - sz)) / v;
				if ((x[j] - sx) * (x[j] - sx) + (y[j] - sy) * (y[j] - sy) + (z[j] - sz) * (z[j] - sz) - v * t * t <= r[j] * r[j]) ans += l[j];
			}
		}

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

Measured memory_bytes: 3224
function Main(input) {
  input = input.split("\n");
  var S = input[0].split("");
  var ans = "Good"
  for(var i=1;i<4;i++){
    if(S[i]==S[i-1]){
      ans="Bad";
      break;
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
using namespace std;
int main(){
  char O[50];
  char E[50];
  int i=0;
cin>>O>>E;
  while(O[i]){
      cout<<O[i];
      if(!E[i])break;
      cout<<E[i];
      i++;
  }
  cout<<endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
S=list(map(int,input().split()))

S.sort()
S.reverse()


goukei=0
pos=0

while pos<K:
    S[pos]=0
    pos+=1
    if pos>=N:
        break

for i in range(N):
    goukei+=S[i]
print(goukei)
    

Measured memory_bytes: 25768
#include<iostream>
using namespace std;
int main(void){
  int n,k;
  cin>>n>>k;
  int l[n];
  for(int i(0);i<n;i++){
    cin>>l[i];
  }
  for(int i(0);i<n-1;i++){
    for(int j(0);j<n-1-i;j++){
      if(l[j]>l[j+1]){
        int t=l[j];
        l[j]=l[j+1];
        l[j+1]=t;
      }
    }
  }
  int sum(0);
  for(int i(n-k);i<n;i++){
    sum+=l[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    string s;cin>>s;
    vector<int> v(3,0);
    for(int i=0;i < siz(s);i++)
    {
        if(s[i]=='a')v[0]++;
        else if(s[i]=='b')v[1]++;
        else v[2]++;
    }
    sort(all(v));


    if(v[0]==0){
        if(v[2]==1 && v[1]<=1){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }else{
        if(v[2]-1<=v[1] && v[2]-1 <=v[0]){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
}

Measured memory_bytes: 512
#include <cstdio>
int main(){
int N,k=0,x=0;
char S[100];
scanf("%d",&N);
scanf("%s",S);
for(int i=0;i<N;i++){
if(S[i]=='I'){
x+=1;
if(k<=x){
k=x;
}
}else{
x-=1;
}
}
printf("%d",k);
return 0;
}

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

int main()
{
	long long int i, a, b, n, ans, n1_2;
	cin >> n;
	ans=n+1;
	n1_2=pow(n, 0.5);
	for(i=1; i<=n1_2; i+=1)
	{
		a=i;
		if(n%a==0)
		{
			b=n/a;
			ans=min(a+b-2, ans);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
k, n = input().split()
a = input().split()
max = 0
for i in range(0,len(a)):
    if i==0:
        max = int(k)-int(a[len(a)-1])+int(a[0])
    d = int(a[i])-int(a[i-1])
    if d>max:
        max=d
print(int(k)-max)

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

#define TRACE
#ifdef TRACE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (ll)(a.size())
#define all(a) a.begin(), a.end() 
#define fr(i,n) for(i=1;i<=n;i++)
#define rp(i,n) for(i=0;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
typedef pair<ll, ll> ii;
typedef vector<ll> vl;
const ll N = 200010;
ll mod=1e9+7;

ll ffmod(ll x, ll y, ll mod)
{
    ll rt=1;
    while(y)
    {
        if(y&1ll) rt=(rt*x)%mod;
        x=(x*x)%mod, y/=2ll;
    }
    return rt;
}

ll dp[110][100010], a[110];

int main()
{
    FIO;
    ll n,k,i,j;
    cin>>n>>k;
    fr(i,n) cin>>a[i];
    dp[1][0]=1;
    fr(i,a[1]) dp[1][i]=1;
    fr(i,k) dp[1][i]+=dp[1][i-1];
    for(i=2;i<=n;i++)
    {
        for(j=0;j<=a[i];j++)
            dp[i][j]=dp[i-1][j];
        for(;j<=k;j++)
            dp[i][j]=(dp[i-1][j]-dp[i-1][j-a[i]-1]+mod)%mod;
        fr(j,k) dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
    }
    if(k==0)
        cout<<dp[n][k]<<endl;
    else
        cout<<(dp[n][k]-dp[n][k-1]+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll S;
	cin >> S;
	ll x1 = 1000000000;
	ll x2,y2;
	y2 = ceil((long double)(S)/(double)(x1));
	x2 = x1 * y2 - S;
	cout << 0 << ' ' << 0 << ' ' << x1<< ' ' << 1 << ' ' << x2 << ' ' << y2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
       
   }
}


ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
int main(){
    ll ans,a,b,c,d;
    cin>>a>>b>>c>>d;
    ll GCD=lcm(c,d);
    ans = (b-a+1)-((b/c - (a-1)/c)+(b/d - (a-1)/d)-(b/(GCD)-(a-1)/(GCD)));
    //cout<<(b/c)<<""
    cout<<ans<<endl;
}
   



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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define mp make_pair
#define pi pair<string, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define mod 998244353

signed main()
{
  int x, y;
  cin >> x >> y;
  bool ok = true;
  if (y % 2 != 0)
    ok = false;
  int count = y / 2;
  if (count < x)
    ok = false;
  if (count > x)
  {
    if (count & 1 && (count / 2) + 1 > x)
      ok = false;
    else if (!(count & 1) && (count / 2) > x)
      ok = false;
  }
  (ok) ? cout << "Yes\n" : cout << "No\n";
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)

#define F_H 500
#define O_H 100
#define F_T 50


typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  int count = 0;
  for (int i = 0; i <= a; i++)
  {
      /* code */
      for(int j = 0; j <= b; j++)
      {
          /* code */
          for (int k = 0; k <= c; k++)
          {
              /* code */
              if (a > x) break;
              if (F_H * i + O_H * j + F_T * k == x) count++;
          }
      }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 200000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
int x[101010];
int main()
{
	int num;
	scanf("%d", &num);
	int s, t;
	for (int i = 0; i < num + 1; i++)
	{
		int z;
		scanf("%d", &z);
		if (x[z] != 0)s = x[z] - 1, t = i;
		x[z] = i + 1;
	}
	num++;
	invinit();
	for (int i = 1; i <= num; i++)
	{
		ll a = com(num, i) + mod - com(num - (t - s) - 1, i - 1);
		printf("%lld\n", a%mod);
	}
}

Measured memory_bytes: 6272
#include <iostream>

using namespace std;

int main()
{
    int x,y;
    cin >> x >> y;
    
    int sum = 0;
    if(x == 3) sum += 100000;
    else if(x == 2) sum += 200000;
    else if(x == 1) sum += 300000;
    if(y == 3) sum += 100000;
    else if(y == 2) sum += 200000;
    else if(y == 1) sum += 300000;
    if(x == 1 && y == 1) sum += 400000;
    cout << sum << endl; 
   
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    while(true){
        string S; cin >> S;
        if(S=="#") break;
        int a,b,c; cin >> a >> b >> c;
        if(a>31 || a==31 && b>=5){
            cout << "? " << a-30 << " " << b << " " << c << "\n";
        } else {
            cout << S << " " << a << " " << b << " " << c << "\n";
        }
    }
}


Measured memory_bytes: 3244
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    a,b,c=map(int,input().split())
    print(c,a,b)


if __name__ == "__main__":

    main()

Measured memory_bytes: 38384
use std::f64::consts::PI;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
 
fn main() {
    input! {
        r: f64,
    }
 
    println!("{}", r * 2.0 * PI);
}

Measured memory_bytes: 2224
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int
main()
{
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(begin(a), end(a));
  if (n == 2) {
    cout << a[1] - a[0] << '\n';
    return 0;
  }
  long long x = 0;
  long long y = 0;
  int l = 0, r = n - 1;
  while (l + 2 < r) {
    int al = a[l];
    int ar = a[r];
    int d = ar - al;
    x += d;
    y += d;
    ++l, --r;
    x += ar - a[l];
    y += a[r] - al;
  }
  if (l + 1 < r) {
    int al = a[l];
    int ar = a[r];
    int d = ar - al;
    r = a[l + 1];
    x += d + r - a[0];
    y += d + a[n - 1] - r;
  }
  else {
    x += a[r] - a[0];
    y += a[n - 1] - a[l];
  }
  cout << max(x, y) << "\n";
  
  return 0;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int a, b, N;

int main() {
	cin >> a >> b >> N;
	bool f = false;
	for (int i = 0; i < N; i++) {
		int s, e;
		cin >> s >> e;
		if ((s <= a && a < e) || (s < b && b <= e) || (a <= s && e <= b))f = true;

	}
	if (f)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3084
sa = input()
sb = input()
sc = input()

cs = sa
cp = ""
np = "a"
while(True):
    cp = np
    if cs=='' :
        break
    np = cs[0]
#    print(cp)
    cs = cs.replace(np, '', 1)
#    print(np)
#    print(cs)
#    print("")
    
    if cp=="a" :
        sa = cs
    elif cp=="b" :
        sb = cs
    elif cp=="c" :
        sc = cs

    if np=="a" :
        cs = sa
    elif np=="b" :
        cs = sb
    elif np=="c" :
        cs = sc

print(cp.upper())


Measured memory_bytes: 3064
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    A.sort()
    max_a = A[-1]
    A = A[:-1]
    A.sort(key=lambda a: abs(a - max_a / 2))
    print('{} {}'.format(max_a, A[0]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14428
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String line = sc.nextLine();
			Scanner scstr = new Scanner(line);
			scstr.useDelimiter(",");
			XPoint a = new XPoint(scstr.nextDouble(), scstr.nextDouble());
			XPoint b = new XPoint(scstr.nextDouble(), scstr.nextDouble());
			XPoint c = new XPoint(scstr.nextDouble(), scstr.nextDouble());
			XPoint d = new XPoint(scstr.nextDouble(), scstr.nextDouble());

			
			XTriangle abc = new XTriangle(a, b, c);
			XTriangle bcd = new XTriangle(b, c, d);
			XTriangle cda = new XTriangle(c, d, a);
			XTriangle dab = new XTriangle(d, a, b);
			
			if(!abc.isInThisTriangle(d) && !bcd.isInThisTriangle(a) && !cda.isInThisTriangle(b) && !dab.isInThisTriangle(c)) System.out.println("YES");
			else System.out.println("NO");
			scstr.close();
		}
		sc.close();
	}
	
}

class XPoint{
	
	private double x;
	private double y;
	
	public double getX(){
		return this.x;
	}
	
	public double getY(){
		return this.y;
	}
	
	public XPoint(double d, double e){
		this.x = d;
		this.y = e;
	}
}

class XLine{
	
	double p;
	double q;
	double r;
	
	/**
	 * ??´???px+qy=r??????????????????
	 * 
	 * @param p
	 * @param q
	 * @param r
	 */
	XLine(double p, double q, double r){
		this.p = p;
		this.q = q;
		this.r = r;
	}
	
	public XLine(XPoint p1, XPoint p2){
	
		if(p1.getX() != p2.getX()) {
			this.p = -(p1.getY()-p2.getY())/(p1.getX()-p2.getX());
			this.q = 1;
			this.r = p1.getX()* this.p +p1.getY();
		}else {
			if(p1.getY() != p2.getY()) {
				this.p = 1;
				this.q = 0;
				this.r = 0;
			}else {
				this.p = 1;
				this.q = 1;
				this.r = 1;
			}
		}
	}
	
	/**
	 * ????????´???????????????2????????????????????´????????????????????????????????????
	 * 
	 * @param x
	 * @param y
	 * @return 2???x, y???????????´???????????°true
	 */
	boolean isTheSameSide(XPoint x, XPoint y){
		double result = (this.calcPX_QY(x.getX(), x.getY()) - this.r)
				* (this.calcPX_QY(y.getX(), y.getY()) - this.r);
		return (result > 0) ? true: false;
	}
	
	/**
	 * ???????????????x, y????????????px+qy????¨?????????????
	 * 
	 * @param x
	 * @param y
	 * @return
	 */
	double calcPX_QY(double x, double y){
		return x * p + y * q;
	}
}

class XTriangle{
	
	XPoint p1;
	XPoint p2;
	XPoint p3;
	
	XTriangle(XPoint p1, XPoint p2, XPoint p3){
		this.p1 = p1;
		this.p2 = p2;
		this.p3 = p3;
	}
	
	XPoint getCenter(){
		return new XPoint((p1.getX() + p2.getX() + p3.getX()) / 3, (p1.getY()
				+ p2.getY() + p3.getY()) / 3);
	}
	
	boolean isInThisTriangle(XPoint p) {
		XLine l12 = new XLine(p1, p2);
		XLine l23 = new XLine(p2, p3);
		XLine l31 = new XLine(p3, p1);
		XPoint center = this.getCenter();
		
		return l12.isTheSameSide(p, center) && l23.isTheSameSide(p, center) && l31.isTheSameSide(p, center);
	}
}

Measured memory_bytes: 26508
#include <stdio.h>
int main(void){
    char S[100001];
    scanf("%s",S);
    int i=0,ok=0,bad=0;
    while(S[i]!='\0'){
        if((S[i]-'0')%2 == i%2) ok++;
        else bad++;
        i++;
    }
    
    if(ok>bad) printf("%d",bad);
    else printf("%d",ok);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
  	int	K;
  	int	num;
  	int i;
  	int	s[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  	num = scanf("%d", &K);
  	printf("%d", s[K-1]);
  	return (0);
}

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

a = list(map(int,input().split()))

a.sort()

if a[0] == 0:
    print(0)
    exit()

total = a[0]

for i in range(1,N):
    total *= a[i]
    if  10 ** 18 < total:
        print(-1)
        exit()
print(total)


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

int main() {
    int n, r;
    cin >> n >> r;
    int ans;
    if(n>=10) ans=r;
    else ans=100*(10-n)+r;
    cout << ans << endl;
}

    


Measured memory_bytes: 256
use std::cmp::max;
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, k) = scan!(usize, usize, usize);
    let mut divisors = vec![];
    for i in 1..max(a, b) + 1 {
        if a % i == 0 && b % i == 0 {
            divisors.push(i)
        }
    }

    println!(
        "{}",
        divisors.into_iter().rev().collect::<Vec<usize>>()[k - 1]
    )
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin>>n>>x;
    ll ans[n*2];
    if(x==1 || x==2*n-1){
        cout<<"No"<<endl;
    }else{
        cout << "Yes"<<endl;
        if(n==2){
            for(int i=1;i<4;i++){
                cout << i<<endl;
            }
            return 0;
        }
        n--;
        if(x==2){
            ans[n-1]=3;
            ans[n]=2;
            ans[n+1]=1;
            ans[n+2]=4;
            ll index=5;
            for(int i=0;i<n-1;i++){
                ans[i]=index;
                index++;
            }
            for(int i=n+3;i<=2*n;i++){
                ans[i]=index;
                index++;
            }
        }
        else{
            ans[n]=x+1;
            ans[n+1]=x-1;
            ans[n-1]=x;
            ans[n-2]=x-2;
            
            vector<ll> v;
            for(int i=1;i<=2*n+1;i++){
                if(i<x-2||x+1<i){
                    v.pb(i);
                }
            }
            ll index=0;
            for(int i=0;i<n-2;i++){
                ans[i]=v[index];
                index++;
            }
            for(int i=n+2;i<=2*n;i++){
                ans[i]=v[index];
                index++;
            }
        }
        for(int i=0;i<=2*n;i++){
            cout << ans[i]<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3568
n=int(input())
T=list(map(int,input().split()))
m=int(input())
PX=[]
for i in range(m):
  p,x=map(int,input().split())
  PX.append((p,x))
for i in range(m):
  print(sum(T)-T[PX[i][0]-1]+PX[i][1])

Measured memory_bytes: 3064
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit
from math import hypot


def main(readline=stdin.readline):
    answer = ('NA', 'OK')

    while 1:
        height, width, depth = (float(s) for s in readline().split())
        if not height:
            exit()

        hw = hypot(height, width)
        wd = hypot(width, depth)
        dh = hypot(depth, height)

        for _ in range(int(readline())):
            size = float(int(readline()) * 2)
            print(answer[size > hw or size > wd or size > dh])


if __name__ == '__main__':
    main()

Measured memory_bytes: 4396
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        c: Chars,
    }
    let r = c.iter().filter(|&&ci| ci == 'R').count();
    let ans = c[..r].iter().filter(|&&ci| ci == 'W').count();
    println!("{}", ans);
}


Measured memory_bytes: 3020
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	int n;
	cin >> n;
	vector<int> L(n);
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int M = L[i] + L[j];
			int m = L[j] - L[i];
			//cout << M << " " << m << endl;
			ll t  = L.end() - upper_bound(L.begin(), L.end(), m);
			ll t2 = L.end() - lower_bound(L.begin(), L.end(), M);
			ans += t - t2 - (L[i] > m && L[i] < M) - (L[j] > m && L[j] < M);
			//dump(t - t2);
		}
	}
	dump(ans / 3);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, res;
pair<int,int> p[100100];

signed main() {
	cin >> n >> m;
	rep(i,n) cin >> p[i].first >> p[i].second;
	sort(p, p+n);
	rep(i,n) {
		int t = min(m, p[i].second);
		m -= t, res += t * p[i].first;
	}
	cout << res << endl;
}

Measured memory_bytes: 1920
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		Scanner sc=new Scanner(System.in);
		String buf;
		buf=sc.nextLine();
		String[] sbuf=buf.split("");
		
		int sn=0;
		int n=Integer.parseInt(buf);
		
		for(int i=0; i<sbuf.length; i++){
			sn+=Integer.parseInt(sbuf[i]);
		}
		
		System.out.println( (n%sn==0)? "Yes" : "No" );

	}

	static void disp(long[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
}


Measured memory_bytes: 21844
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll a(n),p(n) ;
	for(auto &i:p) cin >> i ;
	for(auto &i:a) cin >> i ;
	ll ans = -INF ;
	for(int i=0;i<n;i++){
		vll sum = {0} ;
		ll cnt = 0 ;
		ll pos = i ;
		for(int j=0;j<n;j++){
			pos = p.at(pos)-1 ;
			cnt += a.at(pos) ;
			sum.push_back(cnt) ;
			if(pos==i) break ;
		}
		if(k<sum.size()-1){
			for(int j=1;j<=k;j++) ans = max(ans,sum.at(j)) ;
		}else{
			for(int j=1;j<sum.size();j++) ans = max(ans,sum.at(j)) ;
			if(sum.at(sum.size()-1)>0){
				ll sub = k/(sum.size()-1)-1 ;
				for(int j=0;j<sum.size();j++) ans = max(ans,sub*sum.at(sum.size()-1)+sum.at(j)) ;
				sub++ ;
				for(int j=0;j<=k%(sum.size()-1);j++) ans = max(ans,sub*sum.at(sum.size()-1)+sum.at(j)) ;
			}
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 3748
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for x in combinations(l, 3):
    if x[0]!=x[1] and x[0]!=x[2] and x[1]!=x[2]:
        if x[0] + x[1] > x[2]:
            ans+=1
print(ans)

Measured memory_bytes: 9412
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;

    if(a > b)
        cout << "a > b" << endl;
    else if(a < b)
        cout << "a < b" << endl;
    else
        cout << "a == b" << endl;
  
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

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

    ll tmp = 0;
    while (b <= a)
    {
        tmp++;
        b *= 2;
    }
    while (c <= b)
    {
        tmp++;
        c *= 2;
    }

    
    if (tmp <= k)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
    
    int n,d,x,sum;
    sum=0;
    scanf("%d %d %d",&n,&d,&x);
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if(d%a[i]==0)
            sum+=d/a[i];
        else
            sum+=d/a[i]+1;
    }
    printf("%d\n",x+sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,m;
int main(){
	cin>>n>>m;
	int ans=1;
	for(int i=1;i<=sqrt(m);i++){
		if(m%i==0){
			if(i<=m/n)ans=max(ans,i);
			if(m/i<=m/n)ans=max(ans,m/i);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main(void) {
  int N[4];
  for (int i = 0; i < 4; i++) {
    cin >> N[i];
  }
  sort(N, N+4);
  if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define LOCAL
/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

#define int long long

using namespace std;

template<typename T>
void debug_out(T x) {
  cerr << x;
}

template<typename A>
void debug_out(vector<A> v) {
  cerr << '{';
  for (int i = 0; i < (int) v.size(); i++) {
    if (i) {
      cerr << ", ";
    }
    debug_out(v[i]);
  }
  cerr << '}';
}

template <typename A, typename B>
void debug_out(pair<A, B> p) {
  cerr << '(';
  debug_out(p.first);
  cerr << ", ";
  debug_out(p.second);
  cerr << ')';
}

template <typename A, typename B, typename C>
void debug_out(tuple<A, B, C> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ')';
}

template <typename A, typename B, typename C, typename D>
void debug_out(tuple<A, B, C, D> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ", ";
  debug_out(get<3>(p));
  cerr << ')';
}

template <size_t N>
void debug_out(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  cerr << res;
}

template <typename T>
void debug_with_endl(T v) {
  debug_out(v);
  cerr << endl;
}

template <typename Head, typename... Tail> 
void debug_with_endl(Head H, Tail... T) {
  debug_with_endl(H);
  debug_with_endl(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_with_endl(__VA_ARGS__)
#else
#define debug(...) 2003
#endif

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double PI = 3.14159265359;
  double r;
  cin >> r;
  cout << fixed << setprecision(17);
  cout << (double) 2 * r * PI << '\n';
  return 0;
}

Measured memory_bytes: 3696
N = int(input())
L = [list(map(int,input().split())) for i in range(N)]

dp = [[0,0,0] for i in range(N)]
dp[0] = L[0]

for i in range(1,N) :
    dp[i][0] = max(dp[i-1][1] + L[i][0],dp[i-1][2] + L[i][0])
    dp[i][1] = max(dp[i-1][2] + L[i][1],dp[i-1][0] + L[i][1])
    dp[i][2] = max(dp[i-1][0] + L[i][2],dp[i-1][1] + L[i][2])

ans = max(dp[N-1])

print(ans)


Measured memory_bytes: 47368
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
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;}
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

int main(){
    rep(i,3){
        char in; cin >> in;
        if(in=='1') cout << '9';
        else cout << '1';
    }
}


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

int main(){
    //input
    int n,d,x;
    cin >> n >> d >> x;

    int sum = 0;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        for(int j=1;j<=d;j+=a){
            sum++;
        }
    }

    cout << sum + x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));
int arr[200010]; 
int main(){
	int n;
	cin>>n;
	int sum=0;
	int a=0;
	arr[0]=0;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
		sum+=abs(arr[i]-a);
		a=arr[i];
	} 
	sum+=abs(arr[n]);
	for(int i=1;i<=n;i++){
		cout<<sum-abs(arr[i]-arr[i-1])-abs(arr[i]-arr[i+1])+abs(arr[i-1]-arr[i+1])<<endl;
	}
} 

Measured memory_bytes: 1664
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

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

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

template<typename T>
struct Dinic {
	const T INF = 1e9;
	const int INF1 = 1e9;
	struct edge {
		int a, b;
		T f, c;
	};
	int s, t;
	vector<edge> ed;
	int n;
	vector<vector<int> > eds;
	vector<T> dd;
	vector<int> pp;
	vector<int> inCut;
	Dinic(int N, int S, int TT) {
		n = N, s = S, t = TT;
		eds.clear();
		dd.clear();
		pp.clear();
		ed.clear();
		eds.resize(n);
		dd.resize(n);
		pp.resize(n);
		inCut.clear();
	}
	void add_edge(int a, int b, T c) {
		edge x;
		x.a = a;
		x.b = b;
		x.f = 0;
		x.c = c;
		eds[a].push_back(ed.size());
		eds[b].push_back(ed.size() + 1);
		ed.push_back(x);
		x.c = 0;
		swap(x.a, x.b);
		ed.push_back(x);
	}
	T dfs(int v, T fl) {
		if (v == t)
			return fl;
		if (dd[v] == dd[t])
			return 0;
		T sum = 0;
		for (; pp[v] < (int)eds[v].size(); ++pp[v]) {
			int e = eds[v][pp[v]];
			int u = ed[e].b;
			T fr = ed[e].c - ed[e].f;
			if (fr == 0 || dd[u] != dd[v] + 1 || pp[u] == (int)eds[u].size())
				continue;
			fr = dfs(u, min(fl, fr));
			ed[e].f += fr;
			ed[e ^ 1].f -= fr;
			sum += fr;
			fl -= fr;
			if (fl == 0)
				break;
		}
		return sum;
	}
	T flow() {
		T sum = 0;
		T lst = 0;
		do {
			lst = 0;
			fill(dd.begin(), dd.end(), INF1);
			dd[s] = 0;
			queue<int> qu;
			qu.push(s);
			while (!qu.empty()) {
				int x = qu.front();
				qu.pop();
				for (int i = 0; i < (int)eds[x].size(); ++i) {
					if (ed[eds[x][i]].f < ed[eds[x][i]].c) {
						int u = ed[eds[x][i]].b;
						if (dd[u] > dd[x] + 1)
							dd[u] = dd[x] + 1, qu.push(u);
					}
				}
			}
			if (dd[t] == INF)
				break;
			fill(pp.begin(), pp.end(), 0);
			lst = dfs(s, INF);
			sum += lst;
		} while (lst);
		return sum;
	}
	void dfs1(int s) {
		pp[s] = 1;
		for (int e: eds[s]) {
			if (ed[e].c != ed[e].f && !pp[ed[e].b])
				dfs1(ed[e].b);
		}
	}
	void markCut() {
		inCut.resize(ed.size());
		fill(pp.begin(), pp.end(), 0);
		dfs1(s);
		for (int i = 0; i < ed.size(); ++i)
			if (pp[ed[i].a] && !pp[ed[i].b])
				inCut[i] = 1;
			else
				inCut[i] = 0;
	}
};

const ll INF = 1e12;

int n;
ll a[120];

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	ll sum = 0;
	Dinic<ll> dn(n + 2, n, n + 1);
	for (int i = 1; i <= n; ++i) {
		if (a[i] < 0) {
			dn.add_edge(i - 1, n + 1, -a[i]);
		}
		else {
			dn.add_edge(n, i - 1, a[i]);
			sum += a[i];
		}
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 2 * i; j <= n; j += i)
			dn.add_edge(j - 1, i - 1, INF);
	cout << sum - dn.flow() << "\n";
	return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    ll ans = LINF;
    REP(bits,1<<N){
        if(__builtin_popcount(bits) != K) continue;
        ll tmp = 0;
        ll ma = 0;
        REP(j,N){
            if(bits >> j & 1){
                if(ma < A[j]) ma = A[j];
                else tmp += ma + 1 - A[j], ma++;
            }
            else chmax(ma, A[j]);
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++){
            System.out.print(A[i]);
            if(i != N - 1){
                System.out.print(" ");
            }
        }
        System.out.println();
        insertionSort(A, N);
    }

    public static void insertionSort(int[] A, int N){
        for(int i = 1; i < N; i++){
            int v = A[i];
            int j = i - 1;
            while(j >= 0 && A[j] > v){
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = v;
            for(int k = 0; k < N; k++){
                System.out.print(A[k]);
                if(k != N - 1){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34240
N = int(input())
A = list(map(int, input().split()))

mi = 10 ** 5

for i in range(N):
    temp = A[i]
    c = 0
    while temp % 2 == 0:
        c += 1
        temp = temp // 2
    if c < mi:
        mi = c
print(mi)

Measured memory_bytes: 3060