akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

namespace parser{

typedef string::const_iterator state;
class parse_error{};

int number(state&);
int factor(state&);
int term(state&);
int expression(state&);

// 数字の列をパースして、その数を返す。
int number(state &begin){
    int res=0;
    while(isdigit(*begin)){
        res*=10;
        res+=*begin-'0';
        ++begin;
    }
    return res;
}

// 括弧か数をパースして、その評価結果を返す。
int factor(state &begin){
    if(*begin=='('){
        ++begin;
        int res=parser::expression(begin);
        ++begin;
        return res;
    }else return parser::number(begin);
}

// 乗算除算の式をパースして、その評価結果を返す。
int term(state &begin){
    int res=parser::factor(begin);
    while(true){
        if(*begin=='*'){
            ++begin;
            res*=parser::factor(begin);
        }else if(*begin=='/'){
            ++begin;
            res/=parser::factor(begin);
        }else break;
    }
    return res;
}

// 四則演算の式をパースして、その評価結果を返す。
int expression(state &begin){
    int res=parser::term(begin);
    while(true){
        if(*begin=='+'){
            ++begin;
            res+=parser::term(begin);
        }else if(*begin=='-'){
            ++begin;
            res-=parser::term(begin);
        }else break;
    }
    return res;
}
}

void solve(){
    int n;
    cin >> n;
    cin.ignore();
    rep(i,0,n){
        string s;
        getline(cin,s);
        
        parser::state begin=s.begin();
        int ans=parser::expression(begin);
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 1208
from fractions import gcd
n,m=map(int,input().split())
a=[i//2 for i in set(list(map(int,input().split())))]
b=[]
for i in a:
    c=i
    p=0
    while c%2==0:
        c//=2
        p+=1
    b.append(p)
l=1
if len(set(b))==1:
    for i in a:
        l=l*i//gcd(i,l)
        if m<l:
            print(0)
            break
    else:
        print((m//l+1)//2)
else:
    print(0)

Measured memory_bytes: 16320
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define eps 1e-7
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
const int INF = 1<<29;
typedef unsigned long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n,x;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	
    
    cin >> n >> x;

    int A[n],cc=0;

    FOR(i,0,n)
        cin >> A[i];
    sort(A,A+n);

    FOR(i,0,n){
        x-=A[i];
        if(x<0)
            break;
        cc++;
    }

    if(x>0)
        cc--;

    cout << cc << endl;

	return 0;
}


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

using namespace std;

#define LL long long 
#define FOR(i,l,r) for(int i = l; i <= r; ++i)

const LL oo = 1e18;

LL A,B;
int C[5001],N;
LL F[5001][5001];

void minimize(LL &x,LL y){
    x = min(x,y);
}
void update(int i,int j){
    if(C[i + 1] < C[j]) minimize(F[i + 1][j],F[i][j] + B);
    else{
        minimize(F[i + 1][i + 1],F[i][j]);
        minimize(F[i + 1][j],F[i][j] + A);
    }
}
int main(){

    cin >> N >> A >> B;
    FOR(i,1,N) cin >> C[i];

    FOR(i,1,N) FOR(j,0,i) F[i][j] = oo;

    update(0,0);
    FOR(i,1,N - 1) FOR(j,0,i) if(F[i][j] < oo) update(i,j);

    LL res = oo;
    FOR(i,1,N) res = min(res,F[N][i]);

    cout << res;
    return 0;
}

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

int main() {
  long long int N;
  cin >> N;
  
  int A[N];
  long long int step = 0;
  long long int sum = 0;
  
  for (long long int i = 0; i < N; i++) cin >> A[i];
  
  for (long long int i = 1; i < N; i++){  
    if(A[i-1]>A[i]){
    step = A[i-1]-A[i];
    A[i] = A[i-1];
    sum += step;
    }
  }
  
    cout <<sum<<endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 n;
	cin >> n;
	while(n >= 0){
		if(n%7 == 0){
			cout << "Yes" << endl;
			return 0;
		}
		n -= 4;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int main() {
  IOS;
  string s;
  cin >> s;
  int cnt = 0;
  int cur = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'R')
      cur++;
    else {
      cnt = max(cnt, cur);
      cur = 0;
    }
  }
  cnt = max(cnt, cur);
  cout << cnt << endl;
}


Measured memory_bytes: 3584
S = input()
T = input()
if len(S) < len(T):
    print("UNRESTORABLE")
    exit(0)

def compare(s,t):
    if len(s) != len(t):
        return False
    else:
        for k in range(len(s)):
            if s[k] == "?" or t[k] == "?":
                pass
            else:
                if s[k] != t[k]:
                    return False
    return True
ans = []
for k in range(len(S)-len(T)+1):
    if compare(S[k:k+len(T)],T) == True:
        ans.append(S[:k].replace("?","a")+T+S[k+len(T):].replace("?","a"))

if len(ans) > 0:
    print(sorted(ans)[0])
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int i, a, b, c, n = 0;
  cin >> a >> b >> c;
  for(i = a;i <= b;i++){
    if(c % i == 0) n += 1;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  vvi dp(3005,vi(3005,0));
  dp[a][b]=1;
  REP(i,a,c+1){
    REP(j,b,d+1){
      if(i==a&&j==b) continue;
      ll p=0;
      if(i>a) p+=dp[i-1][j]*j;
      if(j>b) p+=dp[i][j-1]*i;
      if(i>a&&j>b) p-=(dp[i-1][j-1]*(i-1)*(j-1))%mod;
      dp[i][j]=p%mod;
    }
  }
  out(dp[c][d]);
  //outvv(dp);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 73948
N,M = map(int,input().split())
if N ==1 and M ==1:
    print(0)
elif N ==1 and M != 1:
    print(int(M*(M-1)/2))
elif N != 1 and M ==1:
    print(int(N*(N-1)/2))
else:    
    a = N*(N-1)
    b = M*(M-1)
    print(int((a+b)/2))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.rbegin(), a.rend());
    for (int i = 0; i < m; i++)
    {
        if (a[i] * 4 * m < sum)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  cout << 180 * (N - 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 10000

int main(void) {
  ll a[4];

  FOR(i, 0, 4) {
	cin >> a[i];
  }

  ans = min(a[0], a[1]);

  n = min(a[2], a[3]);

  ans += n;

  cout << ans << endl;

  return 0;
}

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

int main(){
  int m,f,r;
  char grade;
  while(1){
    cin>>m>>f>>r;
    if(m==-1 && f==-1 &&r==-1) break;
    if(m ==-1 | f==-1){
      grade ='F';
    }else if(m+f >= 80){
      grade = 'A';
    }else if(m+f>=65){
      grade = 'B';
    }else if(m+f>=50){
      grade = 'C';
    }else if(m+f>=30){
      if(r>=50){
        grade = 'C';
      }else{
        grade = 'D';
      }
    }else{
      grade = 'F';
    }

    cout<<grade<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    string N; cin>>N;
    vector<int> vec(N.length()+1);
    for (int i = 0; i < N.length() ; i++) {
        vec[i+1] = N[i]-'0';
    }
    ll ans = 0;

    for (ll i = N.length(); i >= 0; --i) {

        if(vec[i]>=10) { // 繰り上げ処理
            vec[i-1]++;
            vec[i] %= 10;

        }

        if(vec[i]<5){
            ans += vec[i];
        }else if(vec[i]==5){
            if(vec[i-1]>=5){
                ans += 10-vec[i];
                vec[i-1]++;
            }else{
                ans += vec[i]++;
            }
        }else{
            ans += 10-vec[i];
            vec[i-1]++;
        }

    }
    cout<<ans<<endl;

}


Measured memory_bytes: 5252
import numpy as np

N, K = map(int, input().split())
H = np.array(list(map(int, input().split())) + [0] * (K + 2), dtype = np.int64) 

INF = 10 ** 9
cost = np.array([INF] * (N + K + 2), dtype = np.int64)
cost[0] = 0
for i in range(N):
    cost[i + 1: i + K + 1] = np.minimum(cost[i + 1: i + K + 1], cost[i] + np.abs(H[i + 1: i + K + 1] - H[i]))


# print (cost)
print (cost[N - 1])

Measured memory_bytes: 22820
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int tdis[214514], adis[214514];
vector<int> nex[214514];
signed main(){
	int n,u,v;
	cin>>n>>u>>v;
	for(int i=1;i<=n;i++){
		tdis[i] = LINF;
		adis[i] = LINF;
	}
	tdis[u] = 0;
	adis[v] = 0;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		nex[x].pb(y);
		nex[y].pb(x);
	}
	queue<int> que;
	que.push(u);
	while(!que.empty()){
		int cid = que.front(); que.pop();
		for(int i=0;i<nex[cid].size();i++){
			int nx = nex[cid][i];
			if( tdis[nx] == LINF ){
				tdis[nx] = tdis[cid] + 1;
				que.push( nx );
			}
		}
	}
	que.push(v);
	while(!que.empty()){
		int cid = que.front(); que.pop();
		for(int i=0;i<nex[cid].size();i++){
			int nx = nex[cid][i];
			if( adis[nx] == LINF ){
				adis[nx] = adis[cid] + 1;
				que.push( nx );
			}
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if( nex[i].size() == 1 ){
			if( adis[i] > tdis[i] ){
				if( adis[i] - 1 > ans ){
					ans = adis[i] - 1;
				}
			}
		}
	}
	cout<<ans<<Endl;
	return 0;
}

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

int ng = 0;
int v0;

void dfs(int x, long long value, int o, vector<int>& odd, vector<long long>& diff, vector<vector<int> >& from_edge, vector<int>& u, vector<int>& v, vector<int>& s) {
	if (odd[x] != -1) {
		if (ng == 1) {
			return;
		}
		if (odd[x] == o) {
			if (diff[x] != value) {
				ng = 1;
			}
		} else {
			int v0_2 = (value - diff[x]) * (o == 0 ? -1 : 1);
			if (v0_2 % 2 == 1) {
				ng = 1;
			} else if (ng == -1 && v0_2 / 2 != v0) {
				ng = 1;
			} else {
				ng = -1;
				v0 = v0_2 / 2;
			}
		}
		return;
	}
	odd[x] = o;
	diff[x] = value;
	for (int i = 0; i < from_edge[x].size(); i++) {
		int e = from_edge[x][i];
		int dest = x == u[e] ? v[e] : u[e];
		dfs(dest, s[e] - value, 1 - o, odd, diff, from_edge, u, v, s);
	}
}

int main() {
	int n, m; cin >> n >> m;
	vector<int> u(m), v(m), s(m);
	for (int i = 0; i < m; i++) cin >> u[i] >> v[i] >> s[i], u[i]--, v[i]--;
	vector<vector<int> > from_edge(n);
	for (int i = 0; i < m; i++) {
		from_edge[u[i]].push_back(i);
		from_edge[v[i]].push_back(i);
	}

	vector<int> odd(n, -1);
	vector<long long> diff(n);

	dfs(0, 0, 0, odd, diff, from_edge, u, v, s);
	// cerr << ng << "," << v0 << endl;
	// for (int i = 0; i < n; i++) cerr << odd[i] << " "; cerr << endl;
	// for (int i = 0; i < n; i++) cerr << diff[i] << " "; cerr << endl;


	if (ng == 1) {
		cout << 0 << endl;
	} else if (ng == -1) {
		bool ok = true;
		for (int i = 0; i < n; i++) {
			if (diff[i] + v0 < 1) {
				ok = false;
			}
		}
		cout << (ok ? 1 : 0) << endl;
	} else {
		long long mn = 1;
		long long mx = 1000000000;
		for (int i = 0; i < n; i++) {
			if (odd[i] == 0) {
				mn = max(mn, 1 - diff[i]);
			} else {
				mx = min(mx, diff[i] - 1);
			}
		}
		long long ans = max(0LL, mx - mn + 1);
		cout << ans << endl;
	}
}

Measured memory_bytes: 20608
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || abs(a - b) <= d && abs(b - c) <= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
X = [list(map(int, input().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N + 1)]
for u, v, w in X:
    graph[u].append((v, w))
    graph[v].append((u, w))

colors = [-1] * (N + 1)
colors[1] = 0
q = deque([1])
while q:
    u = q.popleft()
    for v, w in graph[u]:
        if colors[v] >= 0:
            continue

        if w % 2 == 0:
            colors[v] = colors[u]
        else:
            colors[v] = 1 - colors[u]
        q.append(v)

print(*colors[1:], sep="\n")


Measured memory_bytes: 111992
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> v(n);
    for (int i=0; i<n; i++)
        cin >> v[i];
    cout << "AC x " << count(v.begin(), v.end(), "AC") << endl;
    cout << "WA x " << count(v.begin(), v.end(), "WA") << endl;
    cout << "TLE x " << count(v.begin(), v.end(), "TLE") << endl;
    cout << "RE x " << count(v.begin(), v.end(), "RE") << endl;
    return 0;
}


Measured memory_bytes: 6396
#include <stdio.h>
#include <string.h>
int main(void){
    int ap,bp,cp,t;
    char a[999],b[999],c[82];
    scanf("%d",&t);
    while(~scanf("%s%s",&a,&b)){
        ap=strlen(a);
        bp=strlen(b);
        c[cp=(ap>80||bp>80)?0:81]='\0';
        t=0;
        while((t||ap||bp)&&cp>0){
            t+=(ap?a[--ap]-'0':0)+(bp?b[--bp]-'0':0);
            c[--cp]='0'+t%10;
            t/=10;
        }
        if(cp>0)puts(&c[cp]);
        else puts("overflow");
    }
    return 0;
}

Measured memory_bytes: 1012
// Stones
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod=1e9+7;
const int inf = (1<<30);
string toBin(ll a);

int dp[100005];
void solve(){
	int i, j, n, k;
	cin>>n>>k;
	memset(dp, 0, sizeof(dp));
	vector<int> arr;
	for(i=0;i<n;i++){
		int x;
		cin>>x;
		arr.push_back(x);
	}
	sort(arr.begin(), arr.end());
	/*for(i=arr[0];i<=k;i++){
		dp[0][i]=!dp[0][i-arr[0]];
	}*/
	/*
	// original Solution
	for(i=1;i<=n;i++){
		for(j=1;j<=k;j++){
			if(j>=arr[i-1]){
				dp[j]=(dp[j] || (!dp[j-arr[i-1]]));
			}
		}
	}*/

	// Edited solution
	for(i=0;i<=k;i++){
		for(j=0;j<n;j++){
			if(i>=arr[j]){
				dp[i]=dp[i]||(!dp[i-arr[j]]);
			}
		}
	}
	/*for(i=0;i<n;i++){
		for(j=0;j<=k;j++){
			cout<<dp[i][j]<<" ";
		}cout<<endl;
	}*/
	cout<<(dp[k]?"First\n":"Second\n");
}

int main()
{
	solve();
	return 0;
}
string toBin(ll a){
	string s="";
	while(a>0){
		if(a&1){
			s="1"+s;
		}else{
			s="0"+s;
		}
		a>>=1;
	}
	return s;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long A = Long.parseLong(sc.next());
		Long B = Long.parseLong(sc.next());
		Long K = Long.parseLong(sc.next());
		sc.close();

		if(K <= A) {
			A -= K;
			System.out.println(A + " " + B);
			return;
		}else {
			K -= A;
			if(K <= B) {
				B -= K;
				System.out.println(0 + " " + B);
				return;
			}else {
				System.out.println(0 + " " + 0);
				return;
			}
		}

	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>

using namespace std;
int main()
{
    int d[5];
    int t = 10;
    int index = 0;
    string str;
    for(int i = 0;i<5;i++)
    {
        cin>>str;
        d[i] = stoi(str);
        if((d[i]%10 < t) and ((d[i] % 10) !=0) )
        {   t = d[i] % 10;
            index = i;
        }
    }

    int ext = 0;
    for(int i=0;i<5;i++)
    {
        if(i!=index)
        {
            ext = ext + d[i];
            if( d[i] % 10 != 0 )
            {
                ext += 10-(d[i]%10);
            }        
        }
    }
    ext += d[index];
    cout<<ext;
}

Measured memory_bytes: 256
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])

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

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

bool solve() {
    ll n;
    cin >> n;
    if(n == 1) {
        return false;
    }
    auto v = divisor(n);
    vector<ll> ans;
    for(auto a : v) {
        if(a == 1) {
            continue;
        }
        if(!(a % 7 == 1 || a % 7 == 6)) {
            continue;
        }
        auto vv = divisor(a);
        bool f = true;
        for(auto b : vv) {
            if(b == 1 || b == a) {
                continue;
            }
            if(b % 7 == 1 || b % 7 == 6) {
                f = false;
            }
        }
        if(f) {
            ans.emplace_back(a);
        }
    }
    cout << n << ": ";
    for(int i = 0; i < ans.size(); i++) {
        if(i + 1 == ans.size()) {
            cout << ans[i] << endl;
        } else {
            cout << ans[i] << " ";
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        if(!solve()) {
            return 0;
        }
    }
}


Measured memory_bytes: 3188
n = int(input())

x1,y1 = 0,0
t1 = 0
for _ in range(n):
    t,x,y = map(int,input().split())
    if abs(x1-x) + abs(y1-y) <= t - t1 and (abs(x1-x) + abs(y1-y) - (t - t1)) % 2 == 0:
        x1 = x
        y1 = y
        t1 = t
        continue
    else:
        print("No")
        import sys
        sys.exit()

print("Yes")

Measured memory_bytes: 3064
#include <stdio.h>

int n, list[100][100] = {-1};
int v_unused[100] = {-1}, v_used[100] = {-1};

int check1(int x){
  if (v_used[x] == 1) {
    return 1;
  }
  else {
    return 0;
  }
}

int check2(int x){
  if (v_unused[x] == 1) {
    return 1;
  }
  else {
    return 0;
  }
}

int main(void){
  int sum, i, j, k, min, v_min;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    v_unused[i] = 1;
    for (j = 0; j < n; j++) {
      scanf("%d", &list[i][j]);
    }
  }

  sum = 0;
  v_unused[0] = -1;
  v_used[0] = 1;
  min = 9999;
  for (i = 0; i < n; i++) {
    if (min > list[0][i] && list[0][i] != -1) {
      min = list[0][i];
      v_min = i;
    }
  }
  v_unused[v_min] = -1;
  v_used[v_min] = 1;
  sum += min;

for (k = 1; k < n; k++) {
  min = 9999;
  for (i = 0; i < n; i++) {
    if (check1(i)) {
      for (j = 0; j < n; j++) {
        if (min > list[i][j] && list[i][j] != -1 && check2(j)) {
          min = list[i][j];
          v_min = j;
        }
      }
    }
  }
  if (min != 9999){
    v_unused[v_min] = -1;
    v_used[v_min] = 1;
    sum += min;
  }
}


  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2040
#include<stdio.h>
#define N 100

main(){
  int n,i,j,t,A[N],flag,x,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  } 
  flag=1;
  i=0;
  while(flag){
    flag=0;
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	x = A[j];
        A[j]= A[j-1];
	A[j-1]= x;
        flag=1; 
	count++;     
      }   
    }
    i++;  
  }  
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i==n-1)
      printf("\n");
    else
      printf(" ");
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
import sys
from bisect import bisect

n = int(input())
xxx = list(map(int, input().split()))
l = int(input())

reachable = [[bisect(xxx, x + l) - 1 for x in xxx]]
while reachable[-1][0] < n - 1:
    rp = reachable[-1]
    reachable.append(list(map(rp.__getitem__, rp)))

q = int(input())
buf = []
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    if a > b:
        a, b = b, a
    ans = 0
    for i in range(len(reachable) - 1, -1, -1):
        ria = reachable[i][a]
        if ria >= b:
            continue
        ans += 1 << i
        a = ria
    if a != b:
        ans += 1
    buf.append(ans)

print('\n'.join(map(str, buf)))


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

int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i,N){cin >> h.at(i);}

    int ans = 0;
    rep(i,N){if(h.at(i)>=K)ans++;}

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
struct Node{
	int l,r;
	int a[50];
	bool operator <(const Node &other)const{
	    return (l*other.r<r*other.l);
	}
}q[maxn];
int n,m;
bool check(int x,int y){
	double k=0;
	for(int i=0;i<m;i++){
		k+=(q[x].a[i]-q[y].a[i])*(q[x].a[i]-q[y].a[i]);
	}
	k=sqrt(k);
	int t=(int) k;
	if(k-t<=1e-9) return 1;
	return 0;
}
int main(){
	cin>>n>>m;
	long long  ans=1e9;
    if(m-n>2019) cout<<0;
	else {
		for(int i=n;i<=m;i++){
			for(int j=i+1;j<=m;j++){
               ans=min(ans,1ll*i*j%2019);		
	        }
		}
		cout<<ans;
	}	
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            StringBuilder sb = new StringBuilder();
            int n = in.nextInt();
            int[][] zahyou = new int[n][2];
            double res = 0;
            double[][] kyori = new double[n][n];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 2; j++) {
                    zahyou[i][j] = in.nextInt();
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    kyori[i][j] = Math.sqrt(Math.pow((zahyou[i][0] - zahyou[j][0]), 2) + Math.pow((zahyou[i][1] - zahyou[j][1]), 2));
                    res += kyori[i][j] * 2 / n;
                }
            }

            out.println(res);
        }

    }
}



Measured memory_bytes: 23764
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def mniejsze_elementy(): 
    N = wczytaj_liste()[0]
    P = wczytaj_liste()
    odp = 1 
    najmniejszy_dotychczas = P[0]
    for i in range(1,N):
        if P[i]< najmniejszy_dotychczas: 
            odp += 1
            najmniejszy_dotychczas = P[i]
    print(odp)
    
mniejsze_elementy()

Measured memory_bytes: 75472
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		var A = new long[N];
		Arrays.setAll(A, $ -> Long.parseLong(sc.get()));
		int MOD = 1000000000 + 7;

		var cum = new long[N];
		cum[0] = A[0];
		for (int i = 1; i < A.length; i++) {
			cum[i] = A[i] + cum[i - 1];
			cum[i] %= MOD;
		}

		long ans = 0;
		for (int i = 0; i < A.length; i++) {
			ans += Math.floorMod(cum[N - 1] - cum[i], MOD) * A[i];
			ans %= MOD;
		}
		System.out.println(ans);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 56896
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <sstream>
#include <regex>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

#pragma region Combination
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
#pragma endregion

int main()
{
	int s; cin >> s;
	int res = 0;
	COMinit();
	for (int i = 1; i <= s / 3; ++i)
	{
		res += COM(s - i * 2 - 1, s - i * 3);
		res %= MOD;
	}
	cout << res << endl;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<p> v(n);
  priority_queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    // cin >> v[i].second >> v[i].first;
  }
  ll res = 0;
  sort(ALL(v));
  int now = 0;

  for (int i = 1; i <= m; i++) {
    while(now < n && v[now].first <= i){
      q.push(v[now].second);
      now++;
    }
    if(q.size() == 0) continue;
    int tmp = q.top();
    q.pop();
    // cout << now << endl;
    // cout << tmp << endl;
    res += tmp;
  }

  cout << res << endl;

}


Measured memory_bytes: 1660
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
    string S;
    cin >> S;
    int l = S.length();
    int count = 0;
    for (int i = 0; i < l / 2; ++i) {
        if (S[i] != S[l - 1 - i]) count++;
    }
    cout << count;
    return 0;
}


Measured memory_bytes: 256
def print_fig(h, w):
    print("#"*w)
    for _ in range(h-2):
        print("#{}#".format("."*(w-2)))
    print("#"*w)
    print("")

while True:
    x = input().split()
    w, h = int(x[0]), int(x[1])
    if (w, h) == (0, 0): break
    print_fig(w, h)


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

typedef long long ll;

ll N;
vector<ll> A;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin >> N;
    ll a;
    for(int i=1; i<=N; i++){
        cin >> a;
        A.push_back(a-i);
    }
    sort(A.begin(), A.end());
    ll mid = A[N/2];
    ll ans = 0;
    // cout << "mid " << mid << endl;
    for(int i=0; i<N; i++){
        ans += abs(A[i] - mid);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
using System;
using System.Numerics;

    class Program
    {
        static void Main(string[] args)
        {
            var N = BigInteger.Parse(Console.ReadLine());
            long result = N.ToString().Length;

            for (BigInteger A =1;A*A<=N;A++)
            {
                if (N % A != 0) continue;
                var B = N / A;
                var tmpCount = Math.Max(A.ToString().Length, B.ToString().Length);
                if (result > tmpCount) result = tmpCount;
            }
            Console.WriteLine(result);
        }
    }

Measured memory_bytes: 15572
# -*- coding: utf-8 -*-
def vanish_golem(pos, n, s, spells):
    for t, d in spells:
        if pos < 0:
            return -1
        if pos >= n:
            return 1

        if s[pos] == t:
            pos += 1 if d == 'R' else -1

    if pos < 0:
        return -1
    elif pos >= n:
        return 1
    else:
        return 0


def search_vanish_golem(n, s, spells, th):
    l = 0
    h = n-1

    while l <= h:
        t = l + (h - l) // 2
        v = vanish_golem(t, n, s, spells)
        if v < th:
            l = t + 1
        else:
            h = t - 1

    return l


n, q = map(int, input().split())
s = input()

td = [input().split() for _ in range(q)]

l_cnt = search_vanish_golem(n, s, td, 0)
r_cnt = n - search_vanish_golem(n, s, td, 1)

print(n - l_cnt - r_cnt)


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

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	map<string, int> mp;
	for(int i = 0; i < N; i++){
		string s;
		cin >> s;

		sort(s.begin(), s.end());

		auto itr = mp.find(s);
		if(itr == mp.end()) mp[s] = 0;
		mp[s]++;
	}

	ll ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		ll x = itr->second;
		ans += x * (x - 1) / 2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    string s;
    cin>>n>>s>>k;
    for(int i=0;i<n;i++){
        if(s[i]==s[k-1]) cout<<s[i];
        else cout<<"*";
    }
    cout<<endl;
    return 0;
}



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

vector<pair<ll, ll>> prime_factorize(ll N) {
  vector<pair<ll, ll>> res;
  for (ll a = 2; a * a <= N; a++) {
    if (N % a != 0) continue;
    ll ex = 0;
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main() {
  ll N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  auto vec = prime_factorize(N);
  int ans = 0;
  for (auto p : vec) {
    // cout << p.first << ' ' << p.second << endl;
    int n = 0;
    while (true) {
      if (p.second * 2 < (n + 1) * (n + 2)) {
        break;
      }
      n++;
    }
    ans += n;
  }
  cout << ans << endl;
}


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,p;
  cin >> a >> p;
  cout << (a*3+p)/2 << endl;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b;
  cin >> a >> b;
  int t = abs(a - b);
  if (t <= 1) cout << "Yay!" << '\n';
  else cout << ":(" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3572
def parse(i):
    l = input().strip().split()
    m = l.pop(0)
    return (-l.count('0'), l.count('1'), i, m)


n = int(input())

while n:
    print('\n'.join(str(t[3]) for t in sorted([parse(_) for _ in range(n)])))
    n = int(input())

Measured memory_bytes: 7620
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 



int n ;

 
int main()
{
	
   // ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
    
    scanf("%d", &n);
    pii a[N];
    for(int i = 0 ; i < n ; ++i){
        scanf("%d", &a[i].first);
        a[i].second = i+1;
    }
    sort(a , a+n);
    for(int i = 0 ; i < n ; ++i)
        printf("%d ", a[i].second);
    puts("");


    return 0;
}

Measured memory_bytes: 1536
# https://beta.atcoder.jp/contests/abc108/tasks/abc108_a
def solve():
    i = int(input())

    if i % 2 == 0:
        print((i // 2) ** 2)
    else:
        print((i // 2) * (i // 2 + 1))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
n,m = list(map(int,input().strip().split()))

# 2次元配列
student = []
for i in range(n):
    array = list(map(int, input().strip().split()))
    student.append(array)

cp = []
for i in range(m):
    array = list(map(int, input().strip().split()))
    cp.append(array)

result = [0] * n
for i in range(n):
  dis_min = 10**9
  for j in range(m):
    dis = abs(student[i][0]-cp[j][0]) + abs(student[i][1] - cp[j][1])
    if dis < dis_min:
      dis_min = dis
      result[i] = j+1

for i in result:
  print(i)

Measured memory_bytes: 39280
import numpy as np
import math
n=int(input())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
a=np.array(a, dtype=object)
ans=0
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    else:
      x= (a[i]-a[j])**2
      hei=math.sqrt(sum(x))
      ans+= hei/n
print(ans)


Measured memory_bytes: 27104
#include <iostream>
#include <cstdlib>
#include <vector>

int main()
{
   int N;
   std::cin >> N;
   std::cin.ignore();
   int n = N;
   std::vector<int> A;
   A.reserve(N);
   while(n-->0) {
    int a;
    std::cin >>a;
    A.push_back(a);
   }
   
   std::vector<int> ans(N,0);
   int m =0;
   for(int i = N-1; i>=0;--i) {
    int total = 0;
    for(int j=2; j*(i+1) <=N;++j) {
        total+= ans[j*(i+1) -1];
    }
    if((total%2 ==0 && A[i] ==1) || (total%2 == 1 && A[i]==0)) {
        m++;
        ans[i]=1;
    }
   }
   std::cout<< m << std::endl;
   for(int i = 0; i <N;++i) {
      if(ans[i]) std::cout << i+1 << " ";
   }
    
}

Measured memory_bytes: 2432
from math import sqrt
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N-1):
    for j in range(i+1, N):
        dis = 0
        for d in range(D):
            dis += (X[j][d] - X[i][d]) ** 2
        if sqrt(dis).is_integer():
            cnt += 1
print(cnt)

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

#define INF ll_MAX

typedef long long ll;

using namespace std;

int main(void){
	ll n;
	cin >> n;
	vector<ll> a(n,0);

	vector<bool> odd(100,true);

	for(ll i = 0;i < n;i++){
		cin >> a[i];
		if(a[i]%2 == 0)odd[i] = false;
	}

	ll ans = 0;
	for(ll i = 0;i < n;i++){
		ll temp = 1;
		for(ll j = 0;j < n;j++){
			if(j < i){
				if(a[j] == 10000){
					continue; 
				}else if(odd[j]){
					continue;
				}else{
					temp *= 2;
				}
			}else if(j == i){
				if(a[j] == 100000){
					continue; 
				}else if(odd[j]){
					temp *= 2;;
				}else{
					continue;
				}
			}else{
				if(a[j] == 100000){
					temp *= 2; 
				}else{
					temp *= 3;;
				}				
			}
		}
	ans += temp;
	}



	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
    H, W =map(int,input().split())
    if H == W == 0:
    	break
    elif W == 1:
    	for i in range(H):
    	    print("#")
    else:
    	print("#" * W)
    	for i in range(H - 2):
    		print("#" + "." * (W - 2) + "#")
    	print("#" * W)
    print()


Measured memory_bytes: 5612
#include <cstdio>
#include <cmath>
#include <vector>

// double
struct P{
    P(){}
    P(double _r, double _i):r(_r), i(_i){}
    void real(const double& v){r = v;}
    void imag(const double& v){i = v;}
    double r, i;
};

double real(const P& p){return p.r;}
double imag(const P& p){return p.i;}
double norm(const P& p){double r = real(p), i = imag(p); return r * r + i * i;}
double dist(const P& p){return std::sqrt(norm(p));}

P operator+(const P& lhs, const P& rhs){
    return P(real(lhs)+real(rhs), imag(lhs)+imag(rhs));
}
P operator-(const P& lhs, const P& rhs){
    return P(real(lhs)-real(rhs), imag(lhs)-imag(rhs));
}
P operator-(const P& p){
    return P(-real(p), -imag(p));
}

double cross(const P& lhs, const P& rhs){
    return real(lhs)*imag(rhs) - imag(lhs)*real(rhs);
}

double dot(const P& lhs, const P& rhs){
    return real(lhs)*real(rhs) + imag(lhs)*imag(rhs);
}

const double EPS = 1e-9, D_THETA = 0.06, D_R = 0.06;

int N;
P ps[100];
std::vector<P> is;

void addIntersection(int i, int j){
    if(dist(ps[i]-ps[j]) > 2.0){return;}
    
    P m{(real(ps[j])-real(ps[i])) / 2, (imag(ps[j])-imag(ps[i])) / 2}, n{-imag(m), real(m)};
    {
        double d = dist(n);
        n.real(real(n) / d);
        n.imag(imag(n) / d);
    }

    double t = std::sqrt(1 - norm(m));
    for(int k=-1;k<=1;k+=2){
        P p{t * k * real(n), t * k * imag(n)};
        P q = ps[i] + m + p;
        // printf("%.6f, %.6f\n", real(q), imag(q));
        if(-10.0 <= real(q) && real(q) <= 10.0 &&
           -10.0 <= imag(q) && imag(q) <= 10.0){
            is.push_back(q);
        }
    }
}

int count(P p){
    int res = 0;
    for(int i=0;i<N;i++){
        if(dist(ps[i]-p) < 1.0 + EPS){res++;}
    }
    return res;
}

int main(){
    while(scanf("%d", &N), N){
        is.clear();
        
        for(int i=0;i<N;i++){
            double x, y;
            scanf("%lf,%lf", &x, &y);

            ps[i].real(x);
            ps[i].imag(y);
        }

        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                addIntersection(i, j);
            }
        }
        
        int res = 1;
        for(auto i : is){
            res = std::max(res, count(i));
        }

        printf("%d\n", res);
    }
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0;
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k];
int main(){
	bool num[1000001];
	init(num,1000001);
	int n;
	cin>>n;
	int a[n+1];
	in(a,n);
	a[n]=1000001;
	sort(a,a+n+1);
	int count=0;
	for(int i=0;i<n;i++){
		if(num[a[i]]==0){
			if(a[i]!=a[i+1])count++;
			for(int j=1;a[i]<=1000000/j;j++)num[a[i]*j]=1;
		}
	}
	cout << count;
}


Measured memory_bytes: 5360
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;
typedef long long ll;

ll num_bits(ll x){
    ll ret = 0;
    for(ret = 0; x > 0; ret++, x /= 2){}
    return ret;
}

int main(){
    ll n, k;
    cin >> n >> k;

    ll nb = num_bits(k);
    vector<ll> n1(nb, 0);
    vector<ll> as(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> as.at(i);
        ll a = as.at(i);
        for(int j = 0; j < nb; ++j){
            n1.at(j) += a % 2;
            a /= 2;
        }
    }

    ll ans = 0;
    for(ll a : as){ ans += k ^ a; }

    for(int i = 0; i < nb; ++i){
        if(!(k & (1LL << i))){ continue; }

        ll x = 0;
        for(int j = 0; j < nb; ++j){
            if((j > i) && (k & (1LL << j))){
                x += 1LL << j;
            }else if((j < i) && (2 * n1.at(j) < n)){
                x += 1LL << j;
            }
        }
        assert(x < k);
        ll tmp = 0;
        for(ll a : as){ tmp += x ^ a; }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024