akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto A = RDA;

	long[long] memo;
	auto index = A.MAKE_IDX!"a > b";
	
	long dfs(long ii, long l, long r)
	{
		if (ii == N) return 0;
		auto key = l*(10^^5)+r;
		auto m = memo.get(key, -1);
		if (m != -1) return m;

		long i = index[ii];
		auto s1 = abs(l - i) * A[i];
		auto s2 = abs(r - i) * A[i];
		auto r1 = dfs(ii+1, l+1, r);
		auto r2 = dfs(ii+1, l, r-1);
		auto s = max(s1+r1, s2+r2);
		memo[key] = s;
		return s;
	}

	auto ans = dfs(0, 0, N-1);

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 210620
N=int(input())
T=[]
A=[]
for i in range(N):
    Ti,Ai=[int(i) for i in input().split()]
    T.append(Ti)
    A.append(Ai)
T_ans=1
A_ans=1
k=1
for i in range(N):
    if T_ans>T[i] or A_ans>A[i]:
        k=max(-(-T_ans//T[i]),-(-A_ans//A[i]))
        T_ans=T[i]*k
        A_ans=A[i]*k
    else:
        T_ans=T[i]
        A_ans=A[i]
print(T_ans+A_ans)

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

long long gcd(long long x, long long y)
{
    if(x < y)
        return gcd(y, x);
    if(x % y == 0)
        return y;
    return gcd(y, x % y);
}

int main()
{
    int T;
    long long a, b, c, d;
    cin >> T;
    while(T --)
    {
        cin >> a >> b >> c >> d;
        if(a < b || d < b)
        {
            puts("No");
            continue ;
        }
        if(d >= b && c >= b)
        {
            puts("Yes");
            continue ;
        }
        if(d == b)
        {
            if(a % b <= c)
                puts("Yes");
            else
                puts("No");
            continue ;
        }
        long long k = gcd(b, d);
        a %= b;
        //cout << a << " " << k << endl;
        b -= a; 
        c -= a;
        long long ll = (b - 1), rr = c;
        if((ll > 0 && rr < 0) || (ll < 0 && rr > 0))
            puts("No");
        else if(ll / k <= rr / k)
            puts("Yes");
        else
            puts("No");
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }


int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    bool ok = false;
    if (m1 == 1) ok = d1 == 31;
    if (m1 == 2) ok = d1 == 28;
    if (m1 == 3) ok = d1 == 31;
    if (m1 == 4) ok = d1 == 30;
    if (m1 == 5) ok = d1 == 31;
    if (m1 == 6) ok = d1 == 30;
    if (m1 == 7) ok = d1 == 31;
    if (m1 == 8) ok = d1 == 31;
    if (m1 == 9) ok = d1 == 30;
    if (m1 == 10) ok = d1 == 31;
    if (m1 == 11) ok = d1 == 30;
    if (m1 == 12) ok = d1 == 31;

    if (ok) cout << 1 << endl;
    else cout << 0 << endl;
}


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

using namespace std;

const double ESP=1e-10;

#define EQ(a,b) (fabs((a)-(b))<ESP)

struct Vector{
	double x,y;
	Vector operator - (Vector& v){
		Vector r;
		r.x=x-v.x;
		r.y=y-v.y;
		return r;
	}
};

double norm(Vector &a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector &a){
	return sqrt(norm(a));
}

double dot(Vector &a,Vector &b){
	return a.x*b.x+a.y*b.y;
}

double cross(Vector &a,Vector &b){
	return a.x*b.y-a.y*b.x;
}

double D;
Vector p,v;

int main(){
	Vector z;
	z.x=z.y=0;
	do{
		cin>>D;
		if (EQ(D,0)) break;
		cin>>p.x>>p.y>>v.x>>v.y;
		Vector v1;
		v1=z-p;
		double d;
		if (EQ(cross(v,v1),0)){
			if (dot(v,v1)>0){
				d=abs(p);
			}else{
				d=2-abs(p);
			}
			if (d<D){
				cout<<fixed<<d<<endl;
			}else{
				cout<<"impossible"<<endl;
			}
		}else{
			cout<<"impossible"<<endl;
		}
	}while(1);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }
const int INF = 1000000000;

struct UnionFind
{
    vi par;
    vi sizes;

    UnionFind(int n) : par(n), sizes(n,1){
        rep(i,0,n) par[i]=i;
    }

    int find(int x){
        if(par[x]==x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return;
        if(sizes[x]<sizes[y]) swap(x,y);
        par[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    int size(int x){
        return sizes[find(x)];
    }

};

int main(){
    ll n,m; cin>>n>>m;
    UnionFind uf(n);
    ll a[m],b[m];
    rep(i,0,m){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    } 
    ll res=n*(n-1)/2;
    ll ans[m+1];
    ans[m]=res;
    for(int i=m-1;i>=0;i--){
        if(uf.same(a[i],b[i])) ans[i]=res;
        else{
            res-=uf.size(a[i])*uf.size(b[i]);
            uf.unite(a[i],b[i]);
            ans[i]=res;
        }
    }
    
    rep(i,1,m+1) cout<<ans[i]<<endl;
  
}

Measured memory_bytes: 4480
S = int(input())
ans = [0, 0, 1, 10 ** 9]
if S % (10 ** 9) == 0:
    ans.extend([S // (10 ** 9), 0])
else:
    ans.extend([S // (10 ** 9) + 1, 10 ** 9 - S % (10 ** 9)])
print(' '.join([str(a) for a in ans]))

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

using namespace std;

const string T = "CODEFESTIVAL2016";

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < (int)T.size(); i++) {
    if (S[i] != T[i]) cnt++;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){


	PQ que;
  	int A, B, C;	cin >> A >> B >> C;
  	que.push(A);	que.push(B);	que.push(C);
  	
  	int ans = 0;
  	ans += que.top() * 10;
  	que.pop();
  	ans += que.top();
  	que.pop();
  	ans += que.top();
  
  	SCOUT(ans) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<queue>
using namespace std;
#define Maxn 100010
#define LL long long

priority_queue<int > q;
int a[Maxn];

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	while(!q.empty()) q.pop();
	for(int i=1;i<=n;i++) q.push(a[i]);
	for(int i=1;i<=m;i++)
	{
		int nw=q.top();
		q.pop();
		nw/=2;
		q.push(nw);
	}
	LL ans=0;
	while(!q.empty())
	{
		ans+=q.top();
		q.pop();
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	long long a[3];
	int k;
	cin >> a[0] >> a[1] >> a[2];
	cin >> k;
	sort(a,a+3);
	for(int i = 0;i < k;i++){
		a[2] *= 2;
	}
	cout << (a[0] + a[1] + a[2]) << endl;
	return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 5e5 + 10;
int n , Q , D , d[N] , dis[N];
ll ban[N];

int main(){
    scanf("%d%d",&n,&D);
    rep(i,1,n+1) scanf("%d",d + i);
    dis[0] = D;
    rep(i,1,n+1) dis[i] = min(abs(dis[i-1]-d[i]),dis[i-1]);
    ban[n+1]=1;
    per(i,1,n+1) ban[i] = ban[i+1]<=d[i]/2?ban[i+1]:ban[i+1]+d[i];
    scanf("%d",&Q);
    rep(i,0,Q) {
        int q;scanf("%d",&q);
        puts(ban[q+1]<=dis[q-1]?"YES":"NO");
    }
    return 0;
}


Measured memory_bytes: 9728
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll x;
  cin >> x;
  ll ans=0;
  while(ans*(ans+1)<2*x)ans++;
  cout << ans << endl;
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
using namespace std;
typedef long long ll ;
long const M=1000000007;
ll po(ll x, ll y) {
    ll t; 
    if( y == 0) 
        return 1; 
    t = po(x, y/2); 
    if (y%2 == 0) 
        return t*t; 
    else
        return x*t*t; 
} 

int main() {
	
    ll n ,l ,mini;
    cin >> n >> l ;
    mini = l ;
    if(mini> 0)
        cout << (n-1)*(2*mini+n)/2;
    else if (l+n-1 < 0)
        cout << (n-1)*(mini + mini + n -2)/2 ;
    else
        cout << n*(mini+mini+n-1)/2;
	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> pos(n+1);
    rep1(i,n) {
        int a;
        cin >> a;
        pos[a] = i;
    }
    set<ll> st = {0, n+1};
    ll res = 0;
    rep1(i,n) {
        st.insert(pos[i]);
        ll l = *(--st.find(pos[i]));
        ll r = *(++st.find(pos[i]));
        res += (pos[i]-l)*(r-pos[i])*i;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    LL x; cin >> x;
    VL a(N); REP(i,N) cin >> a[i];
    VI cntmemo(N,0);

    LL ans = LINF;

    VL memo(N,LINF);
    for(int mag = 0; mag < N; mag++){
        for(int i = 0; i < N; i++){ //target
            //for(int j = 0; j < N; j++){ //start
            int j;
            if(i - mag >= 0){
                j = i-mag;
            }
            else{
                j = N + i -mag;
            }
                LL cost = a[j];

                int cnt;
                if(i >= j) cnt = (i-j);
                else cnt = (N-1-j+i+1);


                if(cost < memo[i]) {
                    memo[i] = cost;
                    cntmemo[i] = cnt;
                }
        }
        LL tmp = 0;
        dump(mag)
        int cntmax = 0;
        REP(i,N){
            dump(memo[i])
            tmp += memo[i];
            if(cntmemo[i] > cntmax) cntmax = cntmemo[i];
        }
        tmp += x * cntmax;
        dump(tmp)
        if(tmp < ans) ans = tmp;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int R=0;
  int H,W;
  string New,Now,Old;
  cin >> H >> W >> New;
  Old = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  for(int i=0;i<H;i++){
    Now = New;
    New = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    if(i<H-1)
      cin >> New;
    for(int j=0;j<W;j++){
      if(Now.at(j)=='.'){
        if(j>0){
          if(Old.at(j-1)=='#')
            R++;
          if(Now.at(j-1)=='#')
            R++;
          if(New.at(j-1)=='#')
            R++;
        }
        if(j<W-1){
          if(Old.at(j+1)=='#')
            R++;
          if(Now.at(j+1)=='#')
            R++;
          if(New.at(j+1)=='#')
            R++;
        }
        if(Old.at(j)=='#')
          R++;
        if(New.at(j)=='#')
          R++;
        
        cout << R;
        R=0;
      }else{
        cout << "#";
      }
    }
    //すべてのjに代入し終わったら
    cout << endl;
    Old = Now;
  }
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int H, W;
    map<int, char> mp;
    mp[1] = 'A';
    mp[2] = 'B';
    mp[3] = 'C';
    mp[4] = 'D';
    mp[5] = 'E';
    mp[6] = 'F';
    mp[7] = 'G';
    mp[8] = 'H';
    mp[9] = 'I';
    mp[10] = 'J';
    mp[11] = 'K';
    mp[12] = 'L';
    mp[13] = 'M';
    mp[14] = 'N';
    mp[15] = 'O';
    mp[16] = 'P';
    mp[17] = 'Q';
    mp[18] = 'R';
    mp[19] = 'S';
    mp[20] = 'T';
    mp[21] = 'U';
    mp[22] = 'V';
    mp[23] = 'W';
    mp[24] = 'X';
    mp[25] = 'Y';
    mp[26] = 'Z';
    vector<vector<string>> data(27, vector<string>(27));
    cin >> H >> W;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            cin >> data[i][j];
        }
    }

    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (data[i][j] == "snuke") {
                cout << mp[j]; 
                cout << i << endl; 
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using System.Threading;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		long ans=0;
		for(int i = 1;i<n;i++) {
			ans+=(n-1)/i;
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

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

int main() {
	int n;
	ll ans;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	rep(i, n)cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	if (n % 2 == 0) {
		ans = b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1;
	}
	else {
		ans = b[n / 2] - a[n / 2] + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6368
#include<iostream>
#include<queue>
#include<map>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define MAX 50
#define INFTY (1<<10)

int H, W, G[MAX][MAX];

bool isBlock(int y, int x){
    if ( 0 > y || 0 > x || y >= H || x >= W ) return true;
    return G[y][x];
}

int bfs(int tx, int ty, int kx, int ky){
    queue<pair<int, int> > Q;
    map<pair<int, int>, int> D;
    int pt = ty*W + tx;
    int pk = ky*W + kx;
    D[make_pair(pt,pk)] = 0;
    Q.push(make_pair(pt, pk));

    pair<int, int> u, v;
    const int dy[4] = {0, -1, 0, 1};
    const int dx[4] = {1, 0, -1, 0};
    int nty, ntx, nky, nkx, npt, npk;

    while(!Q.empty()){
	u = Q.front(); Q.pop();
	ty = u.first/W;
	tx = u.first%W;
	ky = u.second/W;
	kx = u.second%W;
	pt = ty*W + tx;
	pk = ky*W + kx;
	if ( pt == pk ) return D[make_pair(pt,pk)];
	rep(r, 4){
	    nty = ty + dy[r];
	    ntx = tx + dx[r];
	    nky = ky + dy[r]*(-1);
	    nkx = kx + dx[r]*(-1);
	    npt = (isBlock(nty, ntx))? pt : nty*W+ntx;
	    npk = (isBlock(nky, nkx))? pk : nky*W+nkx;
	    if ( D.find(make_pair(npt, npk)) == D.end() ){
		D[make_pair(npt,npk)] = D[make_pair(pt,pk)] + 1;
		Q.push(make_pair(npt, npk));
	    }
	}
    }
    return -1;
}

main(){
    int tx, ty, kx, ky;
    while(1){
	cin >> W >> H;
	if ( W == 0 && H == 0 ) break;
	cin >> tx >> ty >> kx >> ky;
	tx--; ty--; kx--; ky--;
	rep(i, H) rep(j, W) G[i][j] = 1;
	rep(i, H) rep(j, W) cin >> G[i][j];
	int cost = bfs(tx, ty, kx, ky);
	if ( cost < 0 ) cout << "NA" << endl;
	else cout << cost << endl;
    }
}

Measured memory_bytes: 6472
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int H, W;
	cin >> H >> W;
	int a[H][W];
	char tmp;
	rep(i, H) {
		rep(j, W) {
			cin >> tmp;
			if (tmp == '.') a[i][j] = -1;
			else a[i][j] = 0;
		}
	}
	rep(i, H) {
		rep(j, W) {
			if (a[i][j] == 0) {
				if (i+1 < H && a[i+1][j] != 0) a[i+1][j] = 1;
				if (j+1 < W && a[i][j+1] != 0) a[i][j+1] = 1;
			}
			else if (a[i][j] > 0) {
				if (i+1 < H) {
					if (a[i+1][j] < 0) a[i+1][j] = a[i][j] + 1;
					else if (a[i+1][j] > 0) a[i+1][j] = min(a[i][j]+1, a[i+1][j]);
				}
				if (j+1 < W) {
					if (a[i][j+1] < 0) a[i][j+1] = a[i][j] + 1;
					else if (a[i][j+1] > 0) a[i][j+1] = min(a[i][j]+1, a[i][j+1]);
				}
			}
		}
	}

	for (int i=H-1; i>=0; i--) {
		for (int j=W-1; j>=0; j--) {
			if (a[i][j] == 0) {
				if (i > 0 && a[i-1][j] != 0) a[i-1][j] = 1;
				if (j > 0 && a[i][j-1] != 0) a[i][j-1] = 1;
			}
			else if (a[i][j] > 0) {
				if (i > 0) {
					if (a[i-1][j] < 0) a[i-1][j] = a[i][j] + 1;
					else if (a[i-1][j] > 0) a[i-1][j] = min(a[i][j]+1, a[i-1][j]);
				}
				if (j > 0) {
					if (a[i][j-1] < 0) a[i][j-1] = a[i][j] + 1;
					else if (a[i][j-1] > 0) a[i][j-1] = min(a[i][j]+1, a[i][j-1]);
				}
			}
		}
	}

	
	int cnt = INT_MIN;
	rep(i, H) rep(j, W) cnt = max(cnt, a[i][j]);

	cout << cnt << endl;

	/*
	rep(i, H) {
		rep(j, W) cout << a[i][j];
		cout << endl;
	}
	*/


	return 0;
}



Measured memory_bytes: 4096
n=int(input())
c=[1]
i=1
while (6**i)<=100000:
    c.append(6**i)
    i+=1
i=1
while (9**i)<=100000:
    c.append(9**i)
    i+=1
c.sort(reverse=True)
dp=[[0]*(n+1) for _ in range(len(c)+1)]
dp[0]=[i for i in range(n+1)]

for i in range(len(c)):
    for j in range(n+1):
        if 0<=j-c[i]<=n:
            dp[i+1][j]=min(dp[i][j], dp[i+1][j-c[i]]+1)
        else:
            dp[i+1][j]=dp[i][j]

print(dp[-1][-1])

Measured memory_bytes: 23176
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr int64_t INF = 1'010'000'000'000'000'017LL;

constexpr int64_t MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = asin(-1.0);
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
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;
}
int main()
{
    int K;
    cin >> K;
    cout << K * K * 3;
}

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

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

int dp[50][410][410],a[50],b[50],c[50];

int main(void){
    int N,M,K,ans=1000000;
    cin >> N >> M >> K;
    REP(i,N) cin >> a[i] >> b[i] >> c[i];
    REP(i,N+1)
    	REP(j,10*N+1)
    		REP(k,10*N+1)
                dp[i][j][k] = 1000000;
    dp[0][0][0]=0;
	REP(i,N+1)
    	REP(j,10*N+1)
    		REP(k,10*N+1){
              	if(dp[i][j][k] == 1000000) continue;
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
            }
    for(int i=1;i<=10*N;i++){
        if(i*K/M>10*N) break;
      	if(i%M!=0) continue;
        ans=min(ans, dp[N][i][i*K/M]);
    }
    if(ans == 1000000) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


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

using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << '\n';
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("milkvisits.in","r",stdin );
#define outF freopen("milkvisits.out" , "w" , stdout ) ;
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define lp(i , n) for(int x = i ; x < n ; x ++)
#define ll long long
#define read(arr , x , n) for(int i = x ; i < n ; i ++ )cin >> arr[i];
const double eps = 1e-6 , PI = acos(-1) ;
const long long OO = 1e18 ;
const ll N = 2e5 + 5  , oo = 1e9 + 1  , M = 2000002, mod = 1e9 + 7 , K = 12;

int dsu[N] , sz[N];


int n , m;
int get(int u){
    if(u == dsu[u])
        return u ;

    return dsu[u] = get(dsu[u]);

}
void connect(int u , int v){
    u = get(u);
    v = get(v);


    if(u == v)
        return ;

    if(sz[u] > sz[v])
        swap(u , v);

    sz[v] += sz[u];
    dsu[u] = v ;


}
//                                                +_+
int32_t main(){
    // inF;outF;
    fastio;
    // Dont Forget memset
    cin >> n >> m ;
    iota(dsu , dsu + n + 1 , 0);
    fill(sz , sz + n + 1 , 1);
    while(m--){
        int u , v ;
        cin >> u >> v ;
        connect(u , v);

    }
    int mx= 0 ;
    map<int , int > mp ;

    for(int i = 1 ; i <= n ; i ++){
        dsu[i] = get(dsu[i]) , mp[dsu[i]]++ , mx = max(mx , mp[dsu[i]]);
        }
    cout << mx ;
}


Measured memory_bytes: 14548
n = int(input())
ss = [input() for i in range(n)]
dd = {}
for s in ss:
    dd[s] = dd.get(s, 0) + 1
#print('dd=', dd)
mm = sorted(dd, key=lambda s: -dd[s])
#print('mm=', mm)
ll = [mm[0]]
i = 1
while i < len(mm) and dd[mm[0]] == dd[mm[i]]:
    ll.append(mm[i])
    i += 1
ll.sort()
for l in ll:
    print(l)


Measured memory_bytes: 35240
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

int getans(const bitset<19>&bs,int rest,vector<vector<int>>&memo,vector<int>&confs) {
	if (!rest)return 0;
	else {
		if (memo[rest][bs.to_ulong()] != -1)return memo[rest][bs.to_ulong()];
		else {
			int ans = 10000;
			for (int bet = 1; bet < 19; ++bet) {
				bool ok = true;
				for (int i = bet; i < 19; ++i) {
					if (bs[i] && confs[bet+18-i]) {
						ok = false;
					}
				}
				if (ok) {
					bitset<19>nextbs;
					for (int i = 0; i < 19 -bet; ++i) {
						nextbs[i] = bs[i + bet];
					}
					nextbs[18] = true;
					ans = min(ans,bet + getans(nextbs, rest - 1, memo, confs));
				}
			}
			return memo[rest][bs.to_ulong()] = ans;
		}
	}
}

int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<vector<int>>tables(5, vector<int>(N));
		for (int i = 0; i < 5; ++i) {
			string st; cin >> st;
			for (int j = 0; j < N; ++j) {
				tables[i][j] = (st[j] == 'X');
			}
		}
		vector<int>conf(41);
		for (int i = 1; i < N; ++i) {
			for (int y = 0; y < 5; ++y) {
				for (int l = 0; l < N-i; ++l) {
					int r = l + i;
					if (tables[y][l] && tables[y][r])conf[i] = true;
				}
			}
		}
		bitset<19>bs;
		vector<vector<int>>memo(11, vector<int>(1 << 19,-1));
		int ans = getans(bs, 10, memo, conf);
		cout << ans+N-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 27412
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()

long long divisor(long long n, vector<long long> &d){
  long long cnt = 0;
  for(long long i=1; i*i<=n; i++){
    if(n%i==0){
      d.push_back(i);
      if(i*i!=n){
        d.push_back(n/i);
      }
      cnt++;
    }
  }
  return cnt;
}

int main(){
  int N;cin>>N;
  vector<int> A(N);
  map<int,int> mp;
  for(int i=0; i<N; i++){
    cin>>A[i];
    mp[A[i]]++;
  }
  //sort(all(A), greater<int>());
  //DEBUG(A);
  int cnt = N;
  for(int i=0; i<N; i++){
    int s = A[i];
    if(mp[s]>1){
      //DEBUG(s);
      cnt--;
      continue;
    }
    vector<long long> d;
    divisor(s,d);
    for(auto x: d){
      if(x==s)continue;
      if(mp.find(x)!=mp.end()){
        //DEBUG(s,x);
        cnt--;
        break;
      }
    }
  }
  

  cout<<cnt<<endl;
}

Measured memory_bytes: 13552
#!/usr/bin/env python3
import sys


def solve(S: int, W: int):
    if S <= W:
        print('unsafe')
    else:
        print('safe')
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(S, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
n=int(input())
s=[input() for i in range(n)]
cnt=[0]*26
t=[0]*26
for i,ss in enumerate(s):
  t=[0]*26
  if i==0:
    for sss in ss:
      cnt[ord(sss)-97]+=1
    continue
  for sss in ss:
    t[ord(sss)-97]+=1
  for i in range(26):
    if cnt[i]>t[i]:
      cnt[i]=t[i]
ans=""
for i in range(26):
  ans+=chr(i+97)*cnt[i]
print(ans)



Measured memory_bytes: 3064
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val s = read()
    val filteredOdd = s.filterIndexed { i, c -> i % 2 == 0 }
    println(filteredOdd)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


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

int main(){
    bool A=1;
    int count=0;
    while(A){
        int a;
        cin >> a;
        if (a!=0) {
            count++;
            cout << "Case " << count << ": " << a << endl;
        }
        else {A=0;}
    }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF=1e+09;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    int minus=0;
    int A_min=INF;
    ll ans=0;
    rep(i,N){
        cin >> A[i];
        A_min = min(A_min,abs(A[i]));
        ans+=abs(A[i]);
        if(A[i]<0) minus++;
    }
    if(minus%2==1) ans-=(A_min*2);

    cout << ans << endl;
    
}

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

#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
const int MAXN = 5e5+5;
const int MOD= 998244353;
int main(){
    ll a,b,c;
    while(cin>>a>>b>>c){
        if(c-a-b<0){
            puts("No");
        }
        else{
            if(4*a*b<(c-a-b)*(c-a-b)){
                puts("Yes");
            }
            else{
                puts("No");
            }
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,a,b,c,i,j,k,cnt=0;
  scanf("%d %d %d %d",&a,&b,&c,&x);
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      for(k=0;k<=c;k++){
        if(500*i+100*j+50*k==x)cnt++;
      }
    }
  }
  printf("%d\n",cnt);
}

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

int main()
{
    char s;
    cin >> s;
    if(s == 'A'){
        cout << 'T';
    }else if(s == 'T'){
        cout << 'A';
    }else if(s == 'G'){
        cout << 'C';
    }else{
        cout << 'G';
    }
}

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

using ll = long long;

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int ans = n;
    for (int i=0; i<=n-m; i++) {
        int dif = 0;
        for (int j=0; j<m; j++) {
            if (s[i+j] != t[j]) {
                dif++;
            }
        }
        ans = min(ans, dif);
    }
    cout << ans << '\n';
    return 0;
}

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

class P {
   public:
    int x, y;
    P(int x, int y) : x(x), y(y){};
};
int main(void) {
    int n;
    while (cin >> n && n) {
        vector<vector<P> > line;
        rep(l, n + 1) {
            int m, x, y;
            cin >> m;
            vector<P> tmp;
            rep(i, m) {
                cin >> x >> y;
                tmp.push_back(P(x, y));
            }
            vector<P> tmp2;
            rep(i, m - 1) {
                int d;
                if (i == m - 2) {
                    d = 0;
                } else if ((tmp[i + 1].x == tmp[i].x && tmp[i + 1].y > tmp[i].y &&
                            tmp[i + 2].x > tmp[i + 1].x && tmp[i + 2].y == tmp[i + 1].y) ||
                           (tmp[i + 1].y == tmp[i].y && tmp[i + 1].x > tmp[i].x &&
                            tmp[i + 2].x == tmp[i + 1].x && tmp[i + 2].y < tmp[i + 1].y) ||
                           (tmp[i + 1].x == tmp[i].x && tmp[i + 1].y < tmp[i].y &&
                            tmp[i + 2].y == tmp[i + 1].y && tmp[i + 2].x < tmp[i + 1].x) ||
                           (tmp[i + 1].y == tmp[i].y && tmp[i + 1].x < tmp[i].x &&
                            tmp[i + 2].x == tmp[i + 1].x && tmp[i + 2].y > tmp[i + 1].y)) {
                    d = 1;
                } else {
                    d = -1;
                }
                tmp2.push_back(P(d, abs(tmp[i + 1].x - tmp[i].x) + abs(tmp[i + 1].y - tmp[i].y)));
            }
            line.push_back(tmp2);
        }
        for (int i = 1; i < line.size(); ++i) {
            bool same, same1, same2;
            same = same1 = same2 = true;
            int len;
            if (line[i].size() != line[0].size())
                same = false;
            else {
                len = line[0].size();
            }
            rep(j, len) {
                if (line[i][j].x != line[0][j].x || line[i][j].y != line[0][j].y) {
                    same1 = false;
                    break;
                }
            }
            rep(j, len) {
                if (line[i][len - j - 1].y != line[0][j].y) {
                    same2 = false;
                    break;
                }
                if (j < len - 1) {
                    if (line[i][len - j - 2].x == line[0][j].x) {
                        same2 = false;
                        break;
                    }
                }
            }
            if (same && (same1 || same2)) cout << i << endl;
        }
        cout << "+++++" << endl;
    }
}


Measured memory_bytes: 3012
#define M_PI 3.14159265358979323846
#include <stdio.h>
#include <math.h>
 
 
int main(void){
    double PI=M_PI;
    double po=PI*2/100000;
    int N;
    scanf("%d",&N);
    double x[N],y[N];
    for(int i=0;i<N;i++)scanf("%lf %lf",&x[i],&y[i]);
    int kakuritu[N];
    for(int i=0;i<N;i++)kakuritu[i]=0;
    for(int i=0;i<1000000;i++){
        double max=cos(i*po)*x[0]+sin(i*po)*y[0];
        int maxj=0;
        for(int j=0;j<N;j++){
            if(max<cos(i*po)*x[j]+sin(i*po)*y[j]){max=cos(i*po)*x[j]+sin(i*po)*y[j];maxj=j;}
        }
        kakuritu[maxj]++;
    }
    for(int i=0;i<N;i++){
        printf("%.10f\n",(double)kakuritu[i]/1000000.0f);
    }
    return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!
import numpy as np
d= int(input())

C = list(map(int,input().split()))
CB = [0 for i in range(len(C))]

c = sum(C)

total = 0

#print(c,C,CB)
L = []

for i in range(d):
    L.append(list(map(int,input().split())))

#print(L)


#print(T)

def cnt(CB,t):
    for i in range(len(CB)):
        if i != t:
            CB[i] += 1
        else:
            CB[i] = 0
    
    return CB

def sumA(C,CB):
    a = 0
    for i in range(len(CB)):
        a += CB[i]*C[i]
    return a

for i in range(d):
    ind = np.argmax(L[i])
    CB = cnt(CB,ind)
    total += L[i][ind] - sumA(C,CB)
    print(ind+1)





Measured memory_bytes: 26644
N, M, Q = map(int, input().split())

abcd = list()
for _ in range(Q):
  abcd.append(list(map(int, input().split())))

dmax = 0

for i1 in range(1, M+1):
  for i2 in range(i1, M+1):
    for i3 in range(i2, M+1):
      for i4 in range(i3, M+1):
        for i5 in range(i4, M+1):
          for i6 in range(i5, M+1):
            for i7 in range(i6, M+1):
              for i8 in range(i7, M+1):
                for i9 in range(i8, M+1):
                  for i10 in range(i9, M+1):
                    di = 0
                    A = [0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10]
                    for a, b, c, d in abcd:
                      if A[b] - A[a] == c:
                        di += d
                    dmax = max(dmax, di)
print(dmax)

Measured memory_bytes: 9240
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

ll n,a[100005],s=0;

int main()
{ios_base::sync_with_stdio(false);
cin>>n;
rep(i,0,n-1)cin>>a[i];
sort(a,a+n);
int ans=n;
rep(i,0,n-2)
{
	s+=a[i];
	if(a[i+1]>s*2)
	ans=n-i-1;
}
ol(ans);
return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         998244353
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;
using namespace std;

bool SbS(const pair<int,int> &a,const pair<int,int> &b)
{return (a.second < b.second);}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;
}

ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}
*/
int nCrModp(int n, int r, int p)
{
    int C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = min(i, r); j > 0; j--)

            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    string st="abcdefghijklmnopqrstuvwxyz";
    ll n,m,p,k,i,j,l,t1,r,u,v,x,y,a,b,c,d,q,flag=1,x1,x2,y1,y2;
    cin >> n;
    vector<ll> A(n),D(n,0);
    cin >> A[0];
    ll ans = A[0];
    for(i=1;i<n-1;i++)
    {
        cin >> A[i];

        ans = A[i] - ans;
    }
    cin >> A[n-1];

    D[n-1] = ans + A[n-1];

    ll temp = D[n-1]/2;
    temp = A[n-1] - temp;
    D[0] = temp*2;
    temp = D[0]/2;

    for(i=1;i<n-1;i++)
    {
        D[i] = 2*(A[i-1] - temp);
        temp = D[i]/2;
    }

    COUT(D,0,n);


}
    return 0;
}


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


int main(void) {
	char c;
	cin >> c;

	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
		cout << "vowel" << endl;
	} else {
		cout << "consonant" << endl;
	 }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)

int main() {
    int n; std::cin >> n;
    std::vector<int> x(n);
    rep(i,n) std::cin >> x[i];
    int total=0;
    rep(i,n) total += x[i];
    int ret, ret1=0, ret2=0;
    int mean1=total/n;
    int mean2=mean1+1;
    int tmp=0;
    rep(i,n){
        ret1 += (mean1-x[i]) * (mean1-x[i]);
        ret2 += (mean2-x[i]) * (mean2-x[i]);
    }
    ret = std::min(ret1, ret2);
    std::cout << ret << std::endl;
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN];
int n, a[MAXN], sMin[MAXN]; bool b[MAXN];
void init() {
	for (int i = 1; i <= n; i++) {
		if (s[i] == '0') a[i] = a[i - 1] - 1;
		else a[i] = a[i - 1] + 1;
		if (s[i] == '?') b[i] = true;
	}
	sMin[n + 1] = n + 5;
	for (int i = n; i >= 0; i--)
		sMin[i] = min(sMin[i + 1], a[i]);
}
int work(int limit) {
	int mns = 0;
	for (int i = 1; i <= n; i++) {
		if (s[i] == '?' && sMin[i] - mns - 2 >= limit) {
			b[i] = false;
			mns += 2;
		} 
		a[i] -= mns;
	}
	int Max = 0;
	for (int i = 1; i <= n; i++)
		chkmax(Max, a[i]);
	return Max - limit;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int ans = n + 5, tmp = 0;
	init(); chkmin(ans, work(sMin[0]));
	init(); chkmin(ans, work(sMin[0] - 1));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13448
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] h = new int[n];
		for ( int i = 0; i < h.length; i++ ) {
			h[i] = in.nextInt();
		}

		// 各番目までの累積コストを格納する配列
		int[] cumulativeCost = new int[n];
		cumulativeCost[0] = 0;
		cumulativeCost[1] = Math.abs(h[1] - h[0]);

		// ある杭に飛び移るには、一本前か二本前から飛び移るしかない → コストの小さいほうから飛んでくる
		for ( int i = 2; i < cumulativeCost.length; i++ ) {
			int cum1 = cumulativeCost[i - 1] + Math.abs(h[i] - h[i - 1]);	// 一歩前からくる場合
			int cum2 = cumulativeCost[i - 2] + Math.abs(h[i] - h[i - 2]);	// 二歩前からくる場合

			cumulativeCost[i] = Math.min(cum1, cum2);
		}

		System.out.println(cumulativeCost[n - 1]);
		in.close();
	}
}

Measured memory_bytes: 51056