akhauriyash/Code-Regression huggingface dataset:
N=int(input())
t=[[int(x) for x in input().split()] for i in range(0,N)]

def func(N,t):
    if (t[0][0]-(t[0][1]+t[0][2]))%2==1 or t[0][0]-(t[0][1]+t[0][2])<0 : return "No"
    
    for i in range(1,N):
        if ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))%2==1 or ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))<0 : return "No"
    
    return "Yes"
    
print(func(N,t))

Measured memory_bytes: 21052
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vector
#include <set> // set
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#include <iomanip> //cout<<setprecision(n)
#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

template <typename T>
std::vector<size_t> sort_indexes(const std::vector<T> &v) {
  std::vector<size_t> idx(v.size());
  std::iota(idx.begin(), idx.end(), 0);
  std::sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) {return v[i1] < v[i2];});
  return idx;
}

int main() {
  int n;
  std::cin >> n;
  int a,b;
  std::vector<std::vector<int> > connected(n,std::vector<int>());
  std::vector<int> connectedcount(n,0);
  std::vector<std::pair<int,int> > edges(n-1);
  rep(i,n-1) {
    std::cin >> a >> b;
    a--;b--;
    connected[a].emplace_back(b);
    connected[b].emplace_back(a);
    connectedcount[a]++;
    connectedcount[b]++;
    edges[i].first = a;
    edges[i].second = b;
  }
  std::vector<size_t> idx = sort_indexes<int>(connectedcount);
  std::vector<int> c;
  c.reserve(n);
  rep(i,n) {
    int k;
    std::cin >> k;
    c.emplace_back(k);
  }
  std::sort(c.begin(),c.end());
  std::reverse(c.begin(),c.end());
  ll maxsum = 0;
  std::vector<int> maxpoints(n);
  rep(i,n) {
    if(connectedcount[i]!=1) continue;
    std::vector<int> points(n);
    ll sum = 0;
    std::vector<int> que;
    que.emplace_back(i);
    std::vector<int> went(n,0);
    int count = 0;
    rep(j,que.size()) {
      for(auto k:connected[que[j]]) {
        if(went[k]==0) {
          que.emplace_back(k);
          went[k] = c[count];
          count ++;
        }
      }
    }
    rep(i,n-1) {
      sum += std::min(went[edges[i].first],went[edges[i].second]);
    }  
    if(sum>maxsum) {
      maxsum = sum;
      maxpoints = went;
    }
    break;
  }
  std::cout << maxsum << std::endl;
  rep(i,n) {
    std::cout << maxpoints[i] << ' ';
  }
  return 0;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int a1,a2,a3,ans;
    cin >> a1 >> a2 >> a3;
    ans=max({a1,a2,a3})-min({a1,a2,a3});
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	string s; cin >> s;
	bool dp[1000][4] = {};
	dp[0][0] = true;
	for(int i = 0; i < n; ++i) {
		int num = s[i] - '0';
		vector<pair<int, int>> v;
		for(int j = 0; j < 1000; ++j) {
			for(int k = 3; k >= 0; --k) {
				if(dp[j][k]) {
					int nxt = (j * 10 + num) % 1000;
					v.emplace_back(nxt, min(k + 1, 3));
				}
			}
		}
		for(auto x : v) {
			dp[x.first][x.second] = true;
		}
	}
	int ans = 0;
	for(int i = 0; i < 1000; ++i) {
		if(dp[i][3]) {
			++ans;
			// cerr << i << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> d(m, 0);
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int a;
      cin >> a;
      d[--a]++;
    }
  }
  int cnt = 0;
  for (int i = 0; i < m; ++i) if (d[i] == n) cnt++;
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>
#define vvl vector<vector<long long>>
#define all(A) A.begin(), A.end()

int main() {
    ll n;
    cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];

    ll ans = 0;
    xrep(i,1,n){
        if(a[i] < a[i-1]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    string a,b;
    while(cin>>a>>b)
    {
        l=a.sz;
        if(a.sz>b.sz) l=b.sz;
        rep(i,l)
        {
            cout<<a.at(i)<<b.at(i);
        }
        if(a.sz>b.sz)
        {
            cout<<a.at(a.sz-1);
        }
        cout<<en;
    }
}

Measured memory_bytes: 3516
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
mid = A[-1]/2
Aj = A[0]
for i in range(1, N-1):
    if abs(A[i] - mid) < abs(Aj - mid):
        Aj = A[i]
print(A[-1], Aj)

Measured memory_bytes: 14060
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N = 100010;
int a[N],b[N],c[N],x,y,z,n,p[N];
ll ans,sum;
bool cmp(int x,int y){
	return b[x]>b[y] || b[x]==b[y] && c[x]<c[y];
}
ll f[2][N];
int g[2][N];
set<PII> S;
set<PII>::iterator it;
int pos[2][N];
inline int find(int t,int k){
	if(k==0) return 0;
	int now = 1<<16;
	int ret =0,tmp = 0;
	while(now){
		if(ret+now<N && g[t][ret+now]+tmp<k) {
			tmp+=g[t][ret+now];
			ret+=now;
		}
		now>>=1;
	}
	return ret+1;
}
inline void add(int t,int x,int v){
	while(x<N){
		f[t][x]+=v;
		x+=x&-x;
	}
}
inline void add2(int t,int x,int v){
	while(x<N){
		g[t][x]+=v;
		x+=x&-x;
	}
}
inline ll Sum(int t,int x){
	ll ret = 0;
	while(x){
		ret+= f[t][x];
		x-=x&-x; 
	}
	return ret;
}
int main(){
	scanf("%d%d%d",&x,&y,&z);
	n  =x+y+z;
	for(int i =1;i<=n;i++){
		scanf("%d%d%d",a+i,b+i,c+i);
		sum += a[i];
		b[i] -= a[i];
		c[i] -= a[i];
	}
	S.clear();
	for(int i =1;i<=n;i++){
		S.insert(mp(c[i],i));
	}
	int cnt = 0;
	for(it = S.end();it!=S.begin();){
		it--;
		pos[0][it->Y] = ++cnt;
	}
	//cout<<cnt<<endl;
	S.clear();
	for(int i =1;i<=n;i++){
		S.insert(mp(c[i]-b[i],i));
	}
	cnt = 0;
	for(it = S.end();it!=S.begin();){
		it--;
		pos[1][it->Y] = ++cnt;
	}
	//cout<<cnt<<endl;
	ans = 0;
	for(int i =1;i<=n;i++) p[i] = i;
	sort(p+1,p+n+1,cmp);
	ll tmp = 0;
	//puts("YYY");
	for(int i  =1;i<=y;i++) {
		tmp+= b[p[i]];
		add(1,pos[1][p[i]],c[p[i]]-b[p[i]]);
		add2(1,pos[1][p[i]],1);
	}
	//puts("YYY");
	for(int i =y+1;i<=n;i++){
		add(0,pos[0][p[i]],c[p[i]]);
		add2(0,pos[0][p[i]],1);
	}
	//puts("YY");
	int k = find(0,z);
	ans= max(ans,sum+tmp+Sum(0,k));
	for(int i =1;i<=z;i++){
		tmp += b[p[y+i]];
		add(0,pos[0][p[i+y]],-c[p[i+y]]);
		add2(0,pos[0][p[i+y]],-1);
		add(1,pos[1][p[i+y]],c[p[i+y]]-b[p[i+y]]);
		add2(1,pos[1][p[i+y]],1);
		int k = find(0,z-i);
		int k2 = find(1,i);
		ans = max(ans,sum+tmp+Sum(1,k2)+Sum(0,k));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9600
h,w=map(int,input().split())
A=[input() for i in range(h)]
B=[]
for i in range(h):
    if '#' in A[i]:
        B.append(A[i])
def rot(X):
    C=[]
    for l in range(len(X[0])):
        C_row=[]
        for m in X:
            C_row.append(m[l])
        C.append(C_row)
    return C
D=rot(B)
E=[]
for i in range(w):
    if '#' in D[i]:
        E.append(D[i])
F=rot(E)
for f in F:
    print(''.join(f))

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
int n, a[N], len;
pair<int, int> f[N];
void upd(pair<int, int> &tar, pair<int, int> &src) {
    int val[4] = { tar.first, tar.second, src.first, src.second };
    sort(val, val + 4);
    tar = make_pair(val[3], val[2]);
}
int main() {
    scanf("%d", &n), len = 1 << n;
    for(int i = 0 ; i < len ; ++ i) scanf("%d", &a[i]), f[i] = make_pair(a[i], -1);
    for(int j = 0 ; j < n ; ++ j) {
        for(int i = 0 ; i < len ; ++ i) {
            if(((i >> j) & 1) == 0) {
                int t = i | (1 << j);
                upd(f[t], f[i]);
            }
        }
    }
    for(int i = 1, ans = -1 ; i < len ; ++ i) {
        ans = max(ans, f[i].first + f[i].second);
        printf("%d\n", ans);
    }
}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/24  Problem: code-festival-2017-final_b / Link: https://cf17-final.contest.atcoder.jp/tasks/cf17_final_b?lang=en  ----- */
/* ------問題------

すぬけ君は a、b、c の 3 種類の文字のみからなる文字列 S を持っています。
回文恐怖症のすぬけ君は S の文字を自由に並び替えて、2 文字以上の回文を部分文字列として含まないようにしようと思いました。 これが可能かどうかを判定して下さい。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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


	string s;
	cin >> s;

	VI a(3, 0);
	FOR(i, 0, SZ(s)) {
		a[s[i] - 'a']++;
	}
	int m = INF;
	int M =- INF;
	FOR(i, 0, 3) {
		M = max(M, a[i]);
		m = min(m, a[i]);
	}
	if (M - m < 2) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 512
sx,sy,tx,ty = map(int,input().split())
x=tx-sx
y=ty-sy

S=''
S+='R'*x
S+='U'*y
S+='L'*x
S+='D'*y

S+='D'
S+='R'*(x+1)
S+='U'*(y+1)
S+='L'

S+='U'
S+='L'*(x+1)
S+='D'*(y+1)
S+='R'

print(S)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<int,ll> P;
typedef pair< pair<int,ll>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

vector<P> V[510];
P d[510][510];
ll L;



//s…始点
void dijkstra(int s){
  // greater<P>を指定することでfirstが小さい順に取り出せる
  priority_queue<p,vector<p>,greater<p>> que;
  
  que.push(p(P(0,0),s));
  for(int i=0;i<510;i++){
      d[s][i].first=310;
  }
  d[s][s]=P(0,0);

  while(!que.empty()){
    p x=que.top(); que.pop();
    int v=x.second;
    //cout<<s<<" "<<v<<endl;
    if(d[s][v]<x.first) continue;

    for(int i=0;i<(int)V[v].size();i++){
        P e=V[v][i];
        int sum1;
        ll sum2;
        if(e.second>L) continue;
        if(d[s][v].second+e.second>L){
            sum1=d[s][v].first+1;
            sum2=e.second;
        }else{
            sum1=d[s][v].first;
            sum2=e.second+d[s][v].second;
        }
        if(d[s][e.first]>P(sum1,sum2)){
            d[s][e.first]=P(sum1,sum2);
            que.push(p(d[s][e.first],e.first));
        }
    }
    //if(d[v]<p.first) continue;
  }
}


int main(){
    int N,M,a,b;
    ll c;
    cin>>N>>M>>L;
    for(int i=0;i<M;i++){
        cin>>a>>b>>c;
        a--; b--;
        V[a].push_back(P(b,c));
        V[b].push_back(P(a,c));
    }
    for(int i=0;i<N;i++){
        dijkstra(i);
    }
    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        int s,t;
        cin>>s>>t;
        s--; t--;
        if(d[s][t].first==310) cout<<-1<<endl;
        else cout<<d[s][t].first<<endl;
    }
}

Measured memory_bytes: 6632
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    bool flag = false;
    for (int i = 0; i < s.length(); i++)
    {
        //cout << "i + 1 is :" << i + 1 << " s(i) :" << s.at(i) << endl;
        if ((i + 1) % 2 == 0)
        {
            if (s.at(i) != 'L' && s.at(i) != 'U' && s.at(i) != 'D')
            {
                cout << "No";
                flag = true;
                break;
            }
        }
        else
        {
            if (s.at(i) != 'R' && s.at(i) != 'U' && s.at(i) != 'D')
            {
                cout << "No";
                flag = true;
                break;
            }
        }
    }
    if (!flag)
        cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));

		}
	}

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

	return 0;
}


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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> L(N);
    REP(i, N) cin >> L[i];

    sort(L.begin(), L.end());
    int maxL = L[L.size()-1];
    int total = 0;
    REP(i, N-1) total += L[i];
    if (maxL < total) {
        print("Yes");
    } else {
        print("No");
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using lint=int64_t;
using namespace std;

int main()
{
	int N,K;

	cin >> N >> K;

	double ans=0;
	int Min=min(N,K);
	double NN=1/(double)N;
	for(int i=1;i<=N;i++)
	{
		double tans=0;
		tans+=((double)1/(double)N);
		
		int cnt=0;
		int x=i;
		while(x<K)
		{
			x*=2;
			cnt++;
		}

		tans*=1/(double)pow(2,cnt);
		ans+=tans;
	}

	printf("%.10f\n",ans);
	return 0;
}



Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
bool cmp(pair<int, int> a, pair<int, int> b)
{
	if (a.first < b.first) {
		return true;
	} else if (a.first == b.first) {
		if (a.second < b.second) {
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}

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

	int mMax = 1000 * 1000;
	map<int, bool> mp;
	int fn = S;
	mp[S] = true;
	int res = 1;
	REP(i, mMax - 1) {
		if (IsOdd(fn)) {
			fn = 3 * fn + 1;
		} else {
			fn /= 2;
		}
		res++;
		if (mp.find(fn) == mp.end()) {
			mp[fn] = true;
		} else {
			cout << res << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

void solve() {
  vector<int> v;
  int n, l;
  cin >> n >> l;
  v.resize(n);
  int orig = 0;
  for(int i = 0; i < n; i++) {
    v[i] = l + i;
    orig += v[i];
  }
  int ret = 1e9;
  for(int i = 0; i < n; i++) {
    int curr = 0;
    for(int j = 0; j < n; j++) {
      if(j == i) continue;
      curr += v[j];
    }
    if(abs(curr - orig) < abs(ret - orig)) ret = curr;
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  ll t;
  cin >> t;
  for(ll i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  ll mc = 0;
  ll zero = 0;
  vector<ll> a(n);
  rep(i,n) {
    ll t;
    cin >> t;
    if (t < 0) ++mc;
    if (t == 0) ++zero;
    a[i] = abs(t);
  }
  sort(All(a));
  ll ans = 0;
  if (zero > 0 || mc%2 == 0) {
    rep(i,n) {
      ans += a[i];
    }
  }
  else {
    rep(i,n-1) {
      ans += a[i+1];
    }
    ans -= a[0];
  }
  cout << ans << '\n';


  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    double sol = 0;
    for (int x = 1; x <= n; ++x)
    {
        int y = x, j = 0;
        while (y < k)
            y *= 2, j++;
        sol += 1 / pow(2, j);
    }
    cout << setprecision(15) << fixed << sol / n;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);
  char S[11];
  scanf("%s", S);
  int K;
  scanf("%d", &K);

  for(int i = 0; i < N; i++) {
    if((i != (K-1)) && (S[K-1] != S[i])) {
      S[i] = '*';
    }
  }
  printf("%s\n", S);
  return 0;
}


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

int main()
{
	int n, k = 0;

	cin >> n;

	for (int i = 1; i <= n; i = i + 2) {
		int m = 0;
		for (int j = 1; j <= i; j = j + 2) {
			if (i % j == 0)
				m++;
		}
		if (m == 8)
			k++;
	}

	cout << k << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

const int MOD = 998244353;
inline int add(int a, int b){ return (a+b)%MOD; }
inline int sub(int a, int b){ return ((a-b)%MOD + MOD)%MOD; }
inline int mul(int a, int b){ return ((ll)a*b)%MOD; }
int pwr(int a, int b){
    if(!b) return 1;
    int temp = pwr(a, b/2);
    if(b%2) return mul(mul(temp, temp), a);
    return mul(temp, temp);
}
inline int dvd(int a, int b){ return mul(a, pwr(b, MOD-2)); } // MOD SHOULD BE PRIME 
int choose(int n, int k){
    if(k > n) return 0;
    if(k*2 > n) k = n-k;
    if(!k) return 1;

    int ans = n;
    for(int i = 2; i <= k; ++i){
        ans = mul(ans, (n-i+1));
        ans = dvd(ans, i);
    }
    return ans;
}
int fact(int n){
    int ans = 1;
    for(int i = 2; i <= n; ++i){
        ans = mul(ans, i);
    }
    return ans;
}

int n, k;

void solve(){
    cin >> n>>k;
    vector<pair<int, int>> a(k);
    for(int i = 0; i < k; ++i){
        cin >> a[i].F>>a[i].S;
    }

    vector<int> dp(n, -1);
    vector<int> pref(n, -1);

    dp[0] = 1;
    pref[0] = 1;

    for(int i = 1; i < n; ++i){
        dp[i] = 0;
        for(int j = 0; j < k; ++j){
            int p1 = i-a[j].F >= 0 ? pref[i-a[j].F] : 0;
            int p2 = i-a[j].S-1 >= 0 ? pref[i-a[j].S-1] : 0;
            int toAdd = sub(p1, p2);
            dp[i] = add(dp[i], toAdd);
        }

        pref[i] = add(pref[i-1], dp[i]);
    }

    cout << dp[n-1] << "\n";
}

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

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

double cubicRoot( double ab )
{
	double cr,a;
	double i;
	
	if( 0==ab ) { return 0; }
	
	for( i=0.00001; ; i+=0.00001 ) {
		if( ab<=(i*i*i)  ) {
			a=i-0.00001;
			break;
		}
	}
	
	cr = a+(ab-(a*a*a))/(3*a*a);
	
	return cr;
}
int main( void ) 
{
	int n;
	int i;
	double x[1001],y[1001];
	double tmp;
	double Dxy,Dxy2,Dxy3,Dmax;
	
	scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
    	scanf( "%lf", &x[i] );
    }
    Dxy=Dxy2=Dxy3=Dmax=0;
	for( i=0; i<n; i++ ) {
    	scanf( "%lf", &y[i] );
    	tmp=fabs( x[i]-y[i] );
    	Dxy+=tmp;
    	Dxy2+=(tmp*tmp);
    	Dxy3+=(tmp*tmp*tmp);
    	if( Dmax < tmp ) {
    		Dmax=tmp;
    	}
    }
	printf( "%.5lf\n", Dxy );
	printf( "%.5lf\n", sqrt( Dxy2 ) );
	printf( "%.5lf\n", cubicRoot( Dxy3 ) );
	printf( "%.5lf\n", Dmax );

	return 0;
}

Measured memory_bytes: 668
criteria =
  [["AAA", 35.5, 71.0],
   ["AA",  37.5, 77.0],
   ["A",   40.0, 83.0],
   ["B",   43.0, 89.0],
   ["C",   50.0, 105.0],
   ["D",   55.0, 116.0],
   ["E",   70.0, 148.0]]

while (line = gets)
  t500, t1000 = line.chomp.split(" ").map{|s| s.to_f}

  rank = "NA"

  for cr in criteria
    if t500 < cr[1] && t1000 < cr[2]
      rank = cr[0]
      break
    end
  end

  puts rank
end

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

bool win(char a, char b) {
    if (a == 'r' and b == 's') return true;
    if (a == 's' and b == 'p') return true;
    if (a == 'p' and b == 'r') return true;
    return false;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> v(3);
    rep(i, 3) cin >> v[i];
    string T;
    cin >> T;

    ll ans = 0;
    string hand = "";
    string rsp = "rsp";
    rep(i, T.size()) {
        if (hand.size() < K) {
            rep(j, 3) {
                if (win(rsp[j], T[i])) {
                    ans += v[j];
                    hand += rsp[j];
                    break;
                }
            }
        }
        else {
            bool act = false;
            rep(j, 3) {
                if (hand[hand.size()-K] == rsp[j]) continue;
                if (win(rsp[j], T[i])) {
                    ans += v[j];
                    hand += rsp[j];
                    act = true;
                    break;
                }
            }
            if (!act) {
                hand += 'x';
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  string s;
  int count=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<s.size();j++){
      if(s[i]==s[j])
        count++;
    }
  }
  if(count==s.size())
    cout<<"yes"<<endl;
  else
    cout<<"no"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var x = ReadLong();
		Console.WriteLine(10 - (x / 200));
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


Measured memory_bytes: 27408
import math

a,b,c,k=map(int,input().split())
ans=0
xx=min(a,k)
a-=xx
k-=xx
ans+=xx 
yy=min(b,k)
b-=yy
k-=yy
zz=min(c,k)
c-=zz
k-=zz
ans-=zz
print(ans)


Measured memory_bytes: 61932
from collections import deque
import heapq

def dijkstra(s,g,m):
    color=[0]*n
    dis=[float('inf')]*n
    dis[s]=0
    heapq.heappush(pq,[0,s])
    while len(pq)!=0:
        t,u=heapq.heappop(pq)
        color[u]=2
        if dis[u]<t:
            continue
        for v in g[u]:
            if color[v]!=2:
                if dis[u]+m[u][v]<dis[v]:
                    dis[v]=dis[u]+m[u][v]
                    color[v]=1
                    heapq.heappush(pq,[dis[v],v])
    return dis

n,k=map(int,raw_input().split())
cr=[map(int,raw_input().split()) for _ in xrange(n)]
g=[[]*n for _ in xrange(n)]
for i in xrange(k):
    a,b=map(int,raw_input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    
d=[[0]*n for _ in xrange(n)]
for i in xrange(n):
    q=deque([i])
    visited=[0]*n
    visited[i]=1
    while len(q)!=0:
        p=q.popleft()
        for j in g[p]:
            if visited[j]==0:
                visited[j]=1
                q.append(j)
                d[i][j]=d[i][p]+1

cost=[[float('inf')]*n for _ in xrange(n)]
newg=[[]*n for _ in xrange(n)]
for i in xrange(n):
    for j in xrange(n):
        if d[i][j]<=cr[i][1]:
            cost[i][j]=cr[i][0]
            newg[i].append(j)

pq=[]
dis=dijkstra(0,newg,cost)
print(dis[n-1])

Measured memory_bytes: 921344
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;

	int ans = 0;
	int keta = 0;


	for (int i = 1; i <= n; i++)
	{
		int tmp = i;
		while (tmp != 0)
		{
			tmp /= 10;
			keta++;
		}
		if (keta % 2 == 1)
		{
			ans++;
		}
		keta = 0;
	}

	cout << ans << endl;

}

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

typedef long long ll;
using namespace std;


int main(void) {
   ll N;
   cin>>N;
   ll W[N];
   rep(i,N) {
      cin>>W[i];
   }
   ll sum[N];
   sum[0] = W[0];
   rep(i,N-1) sum[i+1] = sum[i] + W[i+1];
   ll ans = (ll)1e12;
   rep(i,N) {
      ll diff = sum[N-1] - sum[i] - sum[i];
      // cout<<diff<<endl;
      ans = min(ans,abs(diff));
   }
   cout<<ans<<endl;

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
#define what(x) cerr << #x << " is " << x << endl;

int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ok = true;
    for(int i = 0; i < a; ++i) {
        if (s[i] < '0' || s[i] > '9')
            ok = false;
    }
    if(s[a] != '-')
        ok = false;
    for(int i = a+1; i < a+b+1; ++i) {
         if (s[i] < '0' || s[i] > '9')
            ok = false;       
    }
    if(ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll sum = a+b ;
    ll re = n/sum;
    ll ans= re * a;
    ll amari;
    if(n%sum>a) amari = a;
    else amari = n%sum;
    
    ans+=amari;
    cout << ans << endl;
    return 0;
}


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

ans = 1
l = [0] * N
for i in range(N):
  n = A[i]
  if 0 < n:
    ans *= l[n-1] - l[n]
  else:
    ans *= 3 - l[n]
  l[n] += 1
  ans %= 1000000007
print(ans)

Measured memory_bytes: 20544
from sys import stdin


def main():
    lines = stdin.readlines()
    N, M = map(int, lines[0].split())
    X = [sum(1 << int(j) - 1 for j in i.split()[1:]) for i in lines[1:-1]]
    Z = lines[-1].split()
    ans = 0
    for i in range(1 << N):
        tmp = 0
        for x, y in zip(X, Z):
            if bin(i & x).count("1") % 2 == int(y):
                tmp += 1
        if tmp == M:
            ans += 1
    print(ans)

    return


main()


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
using namespace std;
long long h[100000];
int main(void){
	long long n,b,a,low,high,i,sum,ave,d;
	cin>>n>>a>>b;
	high=0;
	for(i=0;i<n;i++){
		cin>>h[i];
		high+=h[i];
	}
	low=1; high=high/b;
	while(1){
		if(low>high) break;
		ave=(high+low)/2;
		sum=0;
		for(i=0;i<n;i++){
			d=h[i]-b*ave;
			if(d<0) d=0;
			sum+=d/(a-b);
			if(d%(a-b)>0) sum++;
		}
		if(sum<=ave) high=ave-1;
		if(sum>ave) low=ave+1;
	}
	cout<<low<<endl;
}

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

using namespace std;

using ll = long long;

int Solve() {
    int n;
    cin >> n;
    vector<int> s(n);

    for (int i = 0; i < n; ++i) cin >> s[i];

    bool is_all_ten = true;
    for (int i = 0; i < n; ++i)
        if (s[i] % 10 != 0) {
            is_all_ten = false;
            break;
        }

    if (is_all_ten) return 0;

    sort(s.begin(), s.end());
    int sum = accumulate(s.begin(), s.end(), 0);
    if (sum % 10 != 0) return sum;
    for (int i = 0; i < n; ++i)
        if (s[i] % 10 != 0) return sum - s[i];

    return 0;
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{	
	int n,a,v,mx,mn,i;
	scanf("%d",&n);
	mx=-1;
	for(i=0;i<n;i++)	{
		scanf("%d %d",&a,&v);
		if(mx<v || (mx==v && mn>a))	{
			mx=v;	mn=a;
		}
	}
	printf("%d %d\n",mn,mx);
	return 0;
}


Measured memory_bytes: 1028
n = int(input())
x = []
y = []
for i in range(n):
    x1,y1=[i for i in input().split()]
    x.append(x1) #x += [x1]
    y.append(y1) #y += [y1]
ans = 0
for i in range(n):
    if y[i] == "JPY":
        ans += int(x[i])
    else:
        ans += float(x[i])*380000
print(ans)

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

#define oo 100000000
#define maxn 1005

using namespace std;
typedef long long ll;

int n;
int x[maxn];
vector < int > g[maxn];

int dp[maxn][maxn * 5];

int get(int m, vector < pair < int, int > >& a) {
  fill(dp[0], dp[0] + m + 1, 0);
  dp[0][0] = 1;

  int sum = 0;

  for (int i = 0; i < a.size(); ++i) {
    sum += a[i].first + a[i].second;

    fill(dp[i + 1], dp[i + 1] + m + 1, 0);
    for (int j = 0; j <= m; ++j) {
      if (j >= a[i].first)
        dp[i + 1][j] |= dp[i][j - a[i].first];
      if (j >= a[i].second)
        dp[i + 1][j] |= dp[i][j - a[i].second];
    }
  }

  for (int i = m; i >= 0; --i)
    if (dp[a.size()][i])
      return sum - i;

  return -1;
}

int dfs(int u) {
  vector < pair < int, int > > a(0);

  for (auto v : g[u]) {
    int ret = dfs(v);

    if (ret == -1) return -1;

    a.push_back({x[v], ret});
  }

  return get(x[u], a);
}

int main(){
  #define TASK "ABC"
 // freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);
  ios_base::sync_with_stdio(0);

  cin >> n;

  for (int i = 2; i <= n; ++i) {
    int p;
    cin >> p;
    g[p].push_back(i);
  }

  for (int i = 1; i <= n; ++i)
    cin >> x[i];

  if (dfs(1) == -1)
    cout << "IM";

  cout << "POSSIBLE";
  return 0;
}


Measured memory_bytes: 17408
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << 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; }
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 << 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; }




double q;

int main() {
    while (cin >> q) {
        if ( abs(q + 1.0) < 1e-5 ) break;
        
        double x = q/2;
        for (int i = 0; i < 10000000; ++i) {
            if ( abs(x*x*x - q) < 0.00001 * q ) break;
            x -= (x*x*x - q) / (3.0 * x*x);
        }
        cout << fixed << setprecision(9) << x << endl;
    }
    return 0;
}


Measured memory_bytes: 1276
N, Y = map(int, input().split())

man = -1
gosen = -1
sen = -1
for m in range(N + 1):
    for g in range(N - m +1):
        s = N - m - g
        if m*10000 + g*5000 + s*1000 == Y:
            man = m
            gosen = g
            sen = s
print(man, gosen, sen)


Measured memory_bytes: 2940
n = input()
list_height = list(map(int, input().split()))
pre = 0
max_chair = 0
list_chair = list()
for i in list_height:
    if i < pre:
        max_chair = pre - i
        pre = i + max_chair
        list_chair.append(max_chair)
    else:
        pre = i
print(sum(list_chair))

Measured memory_bytes: 32256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int n, m;
    cin >> n;
    cin >> m;
    int hsum = 0;
    for (int i = 0; i < m; i++)
    {
        int ai;
        cin >> ai;
        hsum += ai;
    }
    int result = n - hsum;
    if (result < 0)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << result << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define pr pair<int,int>
#define N 100005
#define mod 1000000007
#define INF 2147483647
using namespace std;
int main() {
	IOS;
	ll n;
	cin >> n;
	ll k = sqrt(n + 0.5);
	for (ll i = k; i >=1; i--) {
		if (n % i == 0) {
			cout << i + n / i - 2;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 13;
int n, sz[maxN], cur[maxN];
bool win;
vector<int> adj[maxN];
void dfs (int x, int par) {
    sz[x] = 1;
    for (auto a : adj[x]) {
	if (a != par) {
	    dfs(a, x);
	    sz[x] += sz[a];
	    if (sz[a] % 2 == 1)
		cur[x]++;
	}
    }
    if (cur[x] >= 2)
	win = 1;
}

int main () {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
	int a, b;
	cin >> a >> b;
	adj[a].push_back(b);
	adj[b].push_back(a);
    }
    if (n % 2 == 1) 
	return cout << "First" << endl, 0;
      
    dfs(1, 1);
    if (win)
	cout << "First" << endl;
    else
	cout << "Second" << endl;
}


Measured memory_bytes: 6656
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        
        //三平方の定理
        System.out.println(Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)));

    }

}



Measured memory_bytes: 28112
m,K,D = input().split()
m = int(m)
K = int(K)
D = int(D)
if K < 0 or D < 0:
  print('error')
if m < 0:
  m *= -1
a = (m - m % D) / D
if a > K:
  m -= D*K
  K = 0
else:
  K -= a
  if K % 2 == 0:
    m %= D
  else:
    m = (m % D - D) * -1
print(m)

Measured memory_bytes: 9248
while True:
    n = int(input())
    if n == 0:
        break
    a = 0
    b = 0
    for i  in range(n):
        cardnum = [int(i) for i in input().split()]
        if cardnum[0] < cardnum[1]:
            b += sum(cardnum)
        elif cardnum[0] > cardnum[1]:
            a += sum(cardnum)
        else:
            a += cardnum[0]
            b += cardnum[1]
    print(a,b)



Measured memory_bytes: 5624
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<(a<b?a:b)+(c<d?c:d);

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double eps = 1e-9;


void solve()
{
    /*
    I fear not the man who has practiced 10,000 kicks once,
    but I fear the man who has practiced one kick 10,000 times.
    */

    int s, w;
    cin >> s >> w;
    if(w >= s)
        cout << "unsafe\n";
    else
        cout << "safe\n";
}

int main()
{
    //BOOST;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int t = 1;
    //cin >> t;
    while(t--)
        solve();

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


Measured memory_bytes: 3812
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  map<pll,ll> ans;
  vector<vll> t(n,vll(0));
  vector<pll> p(n-1);
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    t[a].pb(b);
    t[b].pb(a);
    p[i]=pll(min(a,b),max(a,b));
    ans[pll(min(a,b),max(a,b))]=INF;
  }
  vll ch(n,-1);
  ch[0]=0;
  queue<ll> que;
  que.pu(0);
  while(sz(que)){
    ll now=que.front();que.pop();
    ll color=1;
    for(auto p:t[now]){
      if(ans[pll(min(p,now),max(p,now))]!=INF) continue;
      if(color==ch[now]) color++;
      ans[pll(min(p,now),max(p,now))]=color;
      ch[p]=color;
      color++;
      que.pu(p);
    }
  }
  ll an=0;
  for(auto p:ans){
    chmax(an,p.S);
  }
  COUT(an);
  rep(i,n-1){
    COUT(ans[p[i]]);
  }
}

Measured memory_bytes: 17776
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int n, ans;
string s, t;

signed main()
{
    cin >> n;
    ans = 3ll;
    cin >> s >> t;
    for(int i = 1; i < n; i++){
        if(s[i] == t[i]){
            if(s[i - 1] == t[i - 1]){
                ans = (ans * 2) % mod;
            }
        }
        else if(s[i] != t[i]){
            if(s[i - 1] != t[i - 1] && s[i] == s[i - 1] && t[i] == t[i - 1]){
                if(i > 1 && s[i - 2] != t[i - 2]){
                    ans = (ans * 3) % mod;
                }
                else{
                    ans = (ans * 2) % mod;
                }
            }
        }
    }
    cout << ans << endl;


    return 0;
}
/*


*/


Measured memory_bytes: 256
//(・ω・)
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
using namespace std;

int main(){
   int x,y,z;
   cin >> x >> y >> z;
   cout << z << " " <<  x  << " " << y << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int A;
int B;
int C;
int D;
int main(){
  rd(A);
  rd(B);
  rd(C);
  rd(D);
  for(;;){
    C -= B;
    if(C <= 0){
      wt_L("Yes");
      wt_L('\n');
      break;
    }
    A -= D;
    if(A <= 0){
      wt_L("No");
      wt_L('\n');
      break;
    }
  }
  return 0;
}
// cLay varsion 20200430-1

// --- original code ---
// int A, B, C, D;
// {
//   rd(A,B,C,D);
//   for(;;){
//     C -= B;
//     if(C <= 0) wt("Yes"), break;
//     A -= D;
//     if(A <= 0) wt("No"), break;
//   }
// }


Measured memory_bytes: 3632