akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#define maxn 1000006
#define INF 1000000000
using namespace std;
struct node{ int l, r, mn; }tree[maxn * 4];
void build(int rt, int l, int r){
    tree[rt].l = l, tree[rt].r = r;
    tree[rt].mn = INF;
    if (l == r)
        return;
    int m = l + r >> 1;
    build(rt << 1, l, m);
    build(rt << 1 | 1, m + 1, r);
}
void update(int rt, int x, int y){
    if (tree[rt].r < x || x < tree[rt].l)
        return;
    if (tree[rt].l == tree[rt].r){
        tree[rt].mn = y;
        return;
    }
    update(rt << 1, x, y);
    update(rt << 1 | 1, x, y);
    tree[rt].mn = min(tree[rt << 1].mn, tree[rt << 1 | 1].mn);
}
int query(int rt, int l, int r){
    if (tree[rt].r < l || r < tree[rt].l)
        return INF;
    if (l <= tree[rt].l && tree[rt].r <= r)
        return tree[rt].mn;
    return min(query(rt << 1, l, r), query(rt << 1 | 1, l, r));
}
int p[maxn], d[maxn], ans[maxn];
vector <int> G[maxn];
priority_queue <int> q;
int read(){
    int cnt = 0;
    char ch = getchar();
    while (ch < '0' || '9' < ch)
        ch = getchar();
    while ('0' <= ch && ch <= '9'){
        cnt = cnt * 10 + ch - '0';
        ch = getchar();
    }
    return cnt;
}
int main(){
    int n = read(), k = read();
    for (int i = 1; i <= n; ++ i){
        int a = read();
        p[a] = i;
    }
    build(1, 1, n);
    for (int i = n; i; -- i){
        int id1 = query(1, max(1, p[i] - k + 1), p[i] - 1);
        int id2 = query(1, p[i] + 1, min(p[i] + k - 1, n));
        if (id1 != INF){
        //    cout <<i << " " << id1 << endl;
            G[p[id1]].push_back(p[i]);
            ++ d[p[i]];
        }
        if (id2 != INF){
        //    cout << i << " " <<id2 << endl;
            G[p[id2]].push_back(p[i]);
            ++ d[p[i]];
        }
        update(1, p[i], i);
    }
    for (int i = 1; i <= n; ++ i)
        if (d[i] == 0)
            q.push(i);
    for (int i = n; ! q.empty(); -- i){
        int u = q.top();
        q.pop();
        ans[u] = i;
        for (int j = 0; j < G[u].size(); ++ j){
            int v = G[u][j];
            if (-- d[v] == 0)
                q.push(v);
        }
    }
    for (int i = 1; i <= n; ++ i)
        printf("%d\n", ans[i]);
}


Measured memory_bytes: 68864
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        System.out.println(Math.max(Math.max(Math.max(a * c, b * d), a * d), b * c));
	}
}

Measured memory_bytes: 35632
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
const int N = 5000 + 5;
 
ll dp[N][N]; 
 
int main() { 
    ios_base::sync_with_stdio(false); 
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = n; i >= 1; i--) {
        for (int j = 1; j <= n; j++) {
            if (i == j) dp[i][j] = a[i];
            else dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
        }
    }
    cout << dp[1][n] << '\n';
}


Measured memory_bytes: 118528
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b) { 
   if (b == 0) 
      return a; 
   return gcd(b, a % b);  
} 


void solve(){
   int a,b;
  cin >> a >> b;
  int ans  = 6 - (a+b);
  cout << ans << endl;
}

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

void solve(string X){
	int ans=X.length();
	int cnt=0;
	for(auto i:X) {
		if (i=='S')  {
			++cnt;
		} else {
			if (cnt>0) {
				--cnt;
				ans-=2;
			} else {
				cnt=0;
			}
		}
	}	
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	string X;
	cin >> X;
	solve(X);
	return 0;
}



Measured memory_bytes: 772
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<List<Integer>> result = new ArrayList<List<Integer>>();
		
		int n = stdIn.nextInt(), m = stdIn.nextInt();
		while( n != 0 || m != 0 ){
			List<Integer> list = new ArrayList<Integer>();
			for(int i = n; i <= m; i++){
				if( i%4 == 0 ){
					if( i%100 != 0 || i%400 == 0 ){
						list.add(i);
					}
				}
			}
			result.add(list);
			n = stdIn.nextInt();
			m = stdIn.nextInt();
		}
		for(int i = 0; i < result.size()-1; i++){
			if( result.get(i).size() == 0 ){
				System.out.println("NA");
			} else {
				for(Integer year : result.get(i)){
					System.out.println(year);
				}
			}
			System.out.println();
		}
		if( result.get(result.size()-1).size() == 0 ){
			System.out.println("NA");
		} else {
			for(Integer year : result.get(result.size()-1)){
				System.out.println(year);
			}
		}
	}
}

Measured memory_bytes: 12000
import math

n = int(input())
points = []
for _ in range(n):
    x, y = [int(s) for s in input().split()]
    points.append((x, y))

total = 0.0
for start in range(n):
    for end in range(start+1, n):
        dx = points[start][0] - points[end][0]
        dy = points[start][1] - points[end][1]
        dist = math.sqrt(dx*dx+dy*dy)
        total += dist / n
print(total*2)


Measured memory_bytes: 3064
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]

# 壊れた階段が2つ以上連続しているとき、0を出力して終了
for i in range(1,M):
    if a[i]-a[i-1] == 1:
        print(0)
        exit()
        
# 壊れた階段が連続していないならば、ゴールする方法が少なくとも1通り存在する
# stair[i]を、i段目の階段に到達する方法の数とする。ただし、i段目が壊れた階段であるときstair[i] = 0
stair = [-1]*(N+1)
stair[0] = 1
stair[1] = 1

for i in range(M):
    stair[a[i]] = 0
    
for i in range(2,N+1):
    if stair[i] != 0:
        stair[i] = stair[i-1] + stair[i-2]

print(stair[-1]%1000000007)

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

int main() {
    string s, ans;
    cin >> s;
    if(s == "Sunny") ans = "Cloudy";
    else if(s == "Cloudy") ans = "Rainy";
    else ans = "Sunny";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n=0;
	int num;
	int sum;
	while(cin>>sum,sum){
		n=0;
		rep(i,9){
			cin>>num;
			n+=num;
		}
		cout<<sum-n<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n;
int p[810],d[810];
vector<pii> G[810];
int dp1[810],dp2[810];

void dfs(int v, int pv) {
  vector<pii> A,B;
  for (auto e : G[v]) if (e.first != pv) {
    if (G[e.first].size() == 1) A.push_back(e);
    else B.push_back(e);
  }
  dp1[v] = dp2[v] = 0;
  for (int i = 0; i < A.size(); i++) {
    dp1[v] += A[i].second;
    dp2[v] += A[i].second;
  }
  pii tmp(-1,-1);
  for (int i = 0; i < B.size(); i++) {
    dfs(B[i].first,v);
    dp1[v] += dp1[B[i].first]+3*B[i].second;
    dp2[v] += dp1[B[i].first]+3*B[i].second;
    if (tmp.first < 0 || -dp1[B[i].first]+dp2[B[i].first]-B[i].second < -dp1[tmp.first]+dp2[tmp.first]-tmp.second) {
      tmp = B[i];
    }
  }
  if (!(tmp.first < 0)) {
    dp2[v] += -dp1[tmp.first]+dp2[tmp.first]-tmp.second;
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> n, n) {
    REP(i,n) G[i].clear();
    REP(i,n-1) cin >> p[i], p[i]--;
    REP(i,n-1) cin >> d[i];
    REP(i,n-1) {
      G[p[i]].emplace_back(i+1,d[i]);
      G[i+1].emplace_back(p[i],d[i]);
    }
    int ans = INF;
    REP(i,n) {
      dfs(i,-1);
      CHMIN(ans,dp2[i]);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3408
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]

#print()
T = 0
A = 0
for i in range(n):
    t, a = p[i]
    if t >= T and a >= A:
        T, A = t, a
    else:
        d1 = T // t
        d2 = A // a
        if T % t != 0: d1 += 1
        if A % a != 0: d2 += 1
        d = max(d1, d2)
        T, A = d * t, d * a
    #print(T, A)

print(T+A)  

Measured memory_bytes: 3188
//
//  main.cpp

#include <iostream>
using namespace std;
using ll = long long;

int main(){	
	int N,Q;
	ll T;
	cin >> N >> T >> Q;
	
	ll people[1001];
	ll A[100001];
	int D[100001];
	for(int i=0;i<N;i++){
		cin >> A[i] >> D[i];
	}
	for(int i=0;i<Q;i++){
		cin >> people[i];
		people[i]--;
	}
	
	ll east = 0;
	ll west = 0;
	ll t = 0;
	for(int i=0;i<Q;i++){
		if(D[people[i]] == 1){
			east = A[people[i]];
			for(ll j=people[i]+1;j<N;j++){
				if(D[j] == 1){
					east = A[j];
				}else{
					t = (east + A[j])/2;
					break;
				}
			}
			if(T < abs(t - A[people[i]])){
				cout << A[people[i]] + T << endl;
			}else{
				cout << t << endl;
			}
		}else{
			west = A[people[i]];
			for(ll j=people[i]-1;j>=0;j--){
				if(D[j] == 1){
					t = (west + A[j])/2;
					break;
				}else{
					west = A[j];
				}
			}
			if(T < abs(A[people[i]] - t)){
				cout << A[people[i]] - T << endl;
			}else{
				cout << t << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 4232
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int sum=a+b;
	if(b+c<sum)
	{
		sum=b+c;
	}
	if(a+c<sum)
	{
		sum=a+c;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> vec(N);
    int sum=0;
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
        sum += vec.at(i);
    }

    int count = 0;
    for(int i=0; i<N; i++){
        if(vec.at(i) * M >= 0.25* sum){
            count++;
        }
    }

    if(count >= M){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main () {
    int A, B;
    cin >> A >> B;

    if(A >= 13){
        cout << B << endl;
    }
    else if(A >= 6){
        cout << B/2 <<endl;
    }
    if (A < 6){
        cout << 0 <<endl;
    }

}

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

int main()
{
  int ans,book,sum,show = 0;

  for(int j=1; j>0;){
  cin >> ans;
  
  sum = 0;

  if(ans == 0){
      break;
      }

  for(int i=0; i<9; i++){
    cin >> book;
    sum += book;
    // cout << sum << endl;
  }
  ans -= sum;
  
  cout << ans  << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 500101
	#define mod 1000000007ll
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
int a[sz];
int cnt[sz];

vector<int>V[1<<20]; 
ll dp[sz];
ll calc(int w)
{
	vector<int>V=::V[w];dp[1]=1;
	ll s1=1,s2=cnt[V[1]];
	rep(i,2,(int)V.size()-1) 
		dp[i]=(1+s1*cnt[V[i]]%mod-s2+mod)%mod,(s1+=dp[i])%=mod,(s2+=dp[i]*cnt[V[i]]%mod)%=mod;
//	rep(j,1,i-1) (dp[i]+=dp[j]*(cnt[V[i]]-cnt[V[j]])%mod)%=mod;
	if (w==a[n]) return dp[V.size()-1];
	ll ret=0;
	rep(i,1,(int)V.size()-1) (ret+=dp[i])%=mod;
	return ret;
}

int main()
{
	file();
	rep(i,0,(1<<20)-1) V[i].push_back(0);
	read(n);
	rep(i,1,n) read(a[i]),a[i]^=a[i-1],V[a[i]].push_back(i),cnt[i]=cnt[i-1]+(a[i]==0);
	if (a[n]) return cout<<calc(a[n]),0;
	ll ans=ksm(2,cnt[n-1]);
	rep(i,1,(1<<20)-1) (ans+=calc(i))%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 68712
#include<stdio.h>
#include<stdlib.h>
int top,s[1000];
void op(int n){
    s[++top] = n;
}
int pop(void){
    top--;
    return s[top+1];
}
int main(){
    char s[100];
    top = 0;
    int a,b,i;
    i=0;
  while(scanf("%s",s)!=EOF){
    if(s[i]=='+'){
        a = pop();
        b = pop();
        op(a+b);
    }
    else if(s[0]=='-'){
        b = pop();
        a = pop();
        op(a-b);
    }
    else if(s[0]=='*'){
        a = pop();
        b = pop();
        op(a*b);
    }
    else {
        op(atoi(s));
    }
    }
  
    printf("%d\n",pop());
    return 0;
}






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

using namespace std;

const int MX = 200000;

bool solve(int w, int n, int x, int* ds, int* dt) {
	int L = 1, R = w;
	for (int i = n - 1; i >= 0; i--) {
		if (dt[i] == 1) L = max(L - 1, 1);
		if (dt[i] == -1) R = min(R + 1, w);
		
		if (ds[i] == 1) R--;
		if (ds[i] == -1) L++;
		
		if (L > R) return false;
	}
	
	return L <= x && x <= R;
}

char s[MX + 1], t[MX + 1];
int ds[MX], dt[MX];

int main() {
	int h, w, n, x, y;
	ignore = scanf("%d %d %d %d %d %s %s", &h, &w, &n, &x, &y, s, t);
	
	bool ans = true;
	
	auto getX = [](char c) {
		if (c == 'U') return -1;
		if (c == 'D') return 1;
		return 0;
	};
	
	for (int i = 0; i < n; i++) {
		ds[i] = getX(s[i]);
		dt[i] = getX(t[i]);
	}
	
	ans = ans && solve(h, n, x, ds, dt);
	
	auto getY = [](char c) {
		if (c == 'L') return -1;
		if (c == 'R') return 1;
		return 0;
	};
	
	for (int i = 0; i < n; i++) {
		ds[i] = getY(s[i]);
		dt[i] = getY(t[i]);
	}
	
	ans = ans && solve(w, n, y, ds, dt);
	
	printf("%s\n", ans ? "YES" : "NO");
	
	return 0;
}


Measured memory_bytes: 2176
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll MOD = 2038077799;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

ll inv(ll base) {
    int g = MOD, r = base, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x+MOD : x;
}

ll mul(ll A, ll B) {
	return (A*B)%MOD;
}

ll add(ll A, ll B) {
	return (A+B)%MOD;
}

ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}

ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vl A(N), B(N); F0R(i, N) cin >> A[i];
    F0R(i, N) cin >> B[i];
    vl dA(N), dB(N);
    F0R(i, N) {
        dA[i] = A[(i+1)%N] ^ A[i];
        dB[i] = B[(i+1)%N] ^ B[i];
    }

    ll hashB = 0;
    ll base = 1400312813;	
    F0R(i, N) {
        hashB *= base;
        hashB %= MOD;
        hashB += dB[i];
        hashB %= MOD;
    }

    ll hashA = 0;
    F0R(i, N) {
        hashA *= base; hashA %= MOD; hashA += dA[i]; hashA %= MOD;
    }
    vi ans;
    ll exp = modExp(base, N-1);
    F0R(i, N) {
        if (hashA == hashB) {
            ans.pb(i);
        }
        ll val = exp * dA[i]; val %= MOD;
        hashA += MOD - val; hashA %= MOD;
        hashA *= base; hashA %= MOD;
        hashA += dA[i]; hashA %= MOD;
    }

    F0R(i, sz(ans)) {
        cout << ans[i] << " " << (A[0] ^ B[(N-ans[i])%N]) << endl;
    }
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 10612
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 500+5;

int D[MN][MN];
bool ch[MN][MN];

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    int N;
    cin >> N;
    for(int i=1; i<=N; i++){
    	for(int j=1; j<=N; j++){
    		D[i][j] = min(min(i-1,N-i),min(j-1,N-j));
       	}
    }
    int ans = 0,x,y;
    queue<pii> Q;
    int c;
    for(int i=1; i<=N*N; i++){
    	cin >> c;
    	x = (c+N-1)/N;
    	y = (c-1)%N+1;
    	ans += D[x][y];
    	ch[x][y] = 1;
    	Q.push({x,y});
    	while(Q.size()){
    		tie(x,y) = Q.front();
    		Q.pop();
    		int d = D[x][y];
    		if(!ch[x][y]) d++;
    		if(D[x-1][y]>d){
    			D[x-1][y] = d;
    			Q.push({x-1,y});
    		}
    		if(D[x+1][y]>d){
    			D[x+1][y] = d;
    			Q.push({x+1,y});
    		}
    		if(D[x][y-1]>d){
    			D[x][y-1] = d;
    			Q.push({x,y-1});
    		}
    		if(D[x][y+1]>d){
    			D[x][y+1] = d;
    			Q.push({x,y+1});
    		}
    	}
    }
    cout << ans;
}


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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		
		for(int i=0;i<=n;i++) {
			for(int j=0;j<=n-i;j++) {
				int k = n-i-j;
				int total = i*10000 + j*5000 + k*1000;
				if(total==x) {
					System.out.println(i+" "+j+" "+k);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int check_prime(long long x) {
	for(int i = 2; i <= sqrt(x); ++i) {
      if(x % i == 0) return 0;
    }
  	return 1;
}
int main() {
int found = 0;
long long x; cin >> x;
  while(!found) {
  	if(check_prime(x)) {
      found = 1; break;
    }
    ++x;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define y1 asjdlfaskavslbcjasndscf
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter vector< pair<int,int> >::iterator
#define iter1 multiset<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=1e6+7;
const int inf=1e18+1e9;
int mod=2;
const ld eps=1e-9;

//const int MAX_MEM=1e8;
//int mpos=0;
//char mem[MAX_MEM];
//
//inline void * operator new(size_t n){
//    char *res=mem+mpos;
//    mpos+=n;
//    assert(mpos<=MAX_MEM);
//    return (void*)res;
//}
//
//inline void operator delete(void *) {}

int f[N];
int a[N];

int st(int n,int k)
{
    int res=1;
    while(k){
        if (k%2==1){
            res=(res*n)%mod;
        }
        n=(n*n)%mod;
        k/=2;
    }
    return res;
}

int kol(int l,int r,int x)
{
    int f=r/x-(l-1)/x;
    return f;
}

int C(int n,int k)
{
    int res=0;
    int st=2;
    while(st<=n){
        res+=kol(n-k+1,n,st);
        res-=kol(1,k,st);
        st*=2;
    }
    if (res)return 0;
    return 1;
}

int solve(vector<int>p)
{
//    for (int i=0;i<p.size();++i){
//        cout<<p[i]<<' ';
//    }
//    cout<<endl;
    int m=p.size();
    bool f1=1;
    vector<int>p1=p;
    for (int i=0;i<p.size();++i){
        if (p[i]!=0)f1=0;
    }
    if (f1)return 0;
    for (int i=0;i<p.size();++i){
        p[i]%=2;
    }
    int res=0;
    for (int i=0;i<m;++i){
        if (C(m-1,i)==1){
            res^=p[i];
        }
    }
    if (res==1){
        return 1;
    }
    else {
        bool g=0;
        for (int i=0;i<p.size();++i){
            if (p[i]==1)g=1;
        }
        if (g){
            return 0;
        }
        for (int i=0;i<p1.size();++i){
            p1[i]/=2;
        }
        return solve(p1)*2;
    }
}

main ()
{
    ios;
    f[0]=1;
    for (int i=1;i<N;++i){
        f[i]=(f[i-1]*i)%mod;
    }
    int n;
    string s;
    cin>>n>>s;
    for (int i=0;i<n;++i){
        a[i]=s[i]-'0';
    }
    vector<int>c;
    for (int i=0;i<=n-2;++i){
        c.pb(abs(a[i]-a[i+1]));
    }
//    for (int i=0;i<c.size();++i){
//        cout<<c[i]<<' ';
//    }
//    cout<<endl;
    if (c.size()==1){
        cout<<c[0]<<endl;
    }
    else {
        cout<<solve(c)<<endl;
    }
}


Measured memory_bytes: 57104
#!/usr/bin/env python
"""AtCoder Beginner Contest 085: B - Kagami Mochi
https://atcoder.jp/contests/abc086/tasks/abc085_b
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    N = int(input())

    array = set()
    for _ in range(N):
        d = int(input())
        array.add(d)

    print(len(array))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
	int w = 0;
	int m = 1150;
	int t;
	while(scanf("%d", &w) != -1){
		if(w == -1){
			break;
		}else if(w > 30){
			t = w - 30;
			m += 10 * 125 + 10 * 140 + t * 160;
		}else if(w > 20){
			t = w - 20;
			m += 10 * 125 + t *140;
		}else if(w > 10){
			t = w - 10;
			m += t * 125;
		}
	printf("%d\n", 4280 - m);
	m = 1150;
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int c[n],s[n],f[n];
	for(int i=0; i<n; i++){
		cin >> c[i] >> s[i]>> f[i];
	}
	
	
	for(int station=0; station<n; station++){
	int t=0;
	for(int i=station; i<n-1; i++){
		

		if(t<=s[i]){
			t=s[i]+c[i];
		}else if(t%f[i]==0){
			t+=c[i];
		}else{
			t=t+f[i]-(t%f[i])+c[i];
		}

	}
	cout << t <<endl;
	}	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m,k,ans=0;
void Main(){
    cin>>n>>m>>k;
    if(n>k){
        cout<<n-k<<" "<<m<<endl;
    }
    else if(n+m>k){
        cout<<0<<" "<<m-(k-n)<<endl;
    }
    else{
        cout<<"0 0"<<endl;
    }
}
int main(){
    Main();
    return 0;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int sum=0;
    for (int i=0;i<k;i++)
    {
        sum+=arr[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3648
S=input()

if S=="SUN":
    print('7')
elif S=="MON":
    print('6')
elif S=="TUE":
    print('5')
elif S=="WED":
    print('4')
elif S=="THU":
    print('3')
elif S=="FRI":
    print('2')
elif S=="SAT":
    print('1')


Measured memory_bytes: 2940
#include<stdio.h>
int main(){
    unsigned int inact[100][100];
    unsigned int act[100];
    unsigned int ans[100];
    unsigned int row, col;
    unsigned int i, j;
    for(i = 0;i < 100;i++){
        for(j = 0;j < 100;j++){
            inact[i][j] = 0;
        }
        act[i] = 0;
        ans[i] = 0;
    }
    scanf("%d %d", &row, &col);
    for(i = 0;i < row;i++){
        for(j = 0;j < col;j++){
            scanf("%d", &inact[i][j]);
        }
    }
    for(i = 0;i < col;i++){
        scanf("%d", &act[i]);
    }
    for(i = 0;i < row;i++){
        for(j = 0;j < col;j++){
            ans[i] += inact[i][j] * act[j];
        }
    }
    for(i = 0;i < row;i++){
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

struct UnionFind{
    vector<long long> par;
    vector<long long> size;

    UnionFind(long long n) : par(n){
        for(long long i = 0; i < n; i++){
            par[i] = i;
        }
        size.resize(n, 1);
    }

    long long root(long long x){
        if(par[x] == x){
            return x;
        }
        return par[x] = root(par[x]);
    }

    void unite(long long x, long long y){
        long long rx = root(x);
        long long ry = root(y);
        if(rx == ry){
            return;
        }

        par[rx] = ry;
        size[ry] += size[rx]; 
    }

    bool same(long long x, long long y){
        long long rx = root(x);
        long long ry = root(y);
        return rx == ry;
    }

    long long treeSize(long long x){
        return size[root(x)];
    }
};

int main(){
    long long n, m, k;
    cin >> n >> m >> k;

    set<pair<long long, long long> > friend_list;
    vector<set<long long> > list(n);

    UnionFind tree(n);
    for(long long i = 0; i < m; i++){
        long long a, b;
        cin >> a >> b;
        a--;
        b--;
        list[a].insert(b);
        list[b].insert(a);
        tree.unite(a, b);
    }
    set<pair<long long, long long> > block_list;

    for(long long i = 0; i < k; i++){
        long long c, d;
        cin >> c >> d;
        c--;
        d--;
        if(tree.same(c, d) == true){
            list[c].insert(d);
            list[d].insert(c);
        }
    }

    for(long long i = 0; i < n; i++){
        cout << tree.treeSize(i) - 1 - list[i].size() << " ";
    }
    cout << endl;

    return 0;
}

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

using namespace std;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    int p1 = n / 2;
    int p2 = 0;
    int c1 = 2;
    int w1 = 1;
    int c2 = 5;
    int w2 = 1;
    n /= 2ll;
    while (c1 <= n)
    {
        p1 += (n / c1);
        c1 *= 2ll;
        ++w1;
    }
    while (c2 <= n)
    {
        p2 += (n / c2);
        c2 *= 5ll;
        ++w2;
    }
    cout << min(p1, p2) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int[,] c = new int[3, 3];
        

        public static void Input()
        {
            var cin = new Scanner();
            for(var i = 0; i < 3; i++)
            {
                var input = cin.SplitReader();
                for(var j = 0; j < 3; j++)
                {
                    c[i, j] = input[j];
                }
            }
        }

        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            for(var a1 = 0; a1 <= 100; a1++)
            {
                int b1 = c[0, 0] - a1;
                int b2 = c[0, 1] - a1;
                int b3 = c[0, 2] - a1;
                int a2 = c[1, 0] - b1;
                int a3 = c[2, 0] - b1;
                bool ok = true;
                if (c[1, 1] != a2 + b2) { ok = false; }
                if (c[1, 2] != a2 + b3) { ok = false; }
                if (c[2, 1] != a3 + b2) { ok = false; }
                if (c[2, 2] != a3 + b3) { ok = false; }

                if (ok) { Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
           

            //Console.Out.Flush();

        }

       
    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 13396
n,k = map(int,input().split())
arr = [int(i) for i in input().split()]
dp = [float("inf")] * n
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j < n:
            dp[j] = min(dp[j],abs(arr[i]-arr[j]) + dp[i])
print(dp[n-1])

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

int main(){
    int a,b; cin >> a >> b;
    if(a == b){
        for(int i = 0; i < a; i++) cout << a;
    }else if(a < b){
        for(int i = 0; i < b; i++) cout << a;
    }else{
        for(int i = 0; i < a; i++) cout << b;
    }
    cout << endl;
}

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




int main(){
    int n;cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    vector<int> ans;
    for (int i = 0; i < n; i++) {
        int t=-1;
        for (int j = 0; j < b.size(); j++) {
            if(b[j]==j+1) t=j;
        }
        if(t==-1){
            puts("-1");
            return 0;
        }
        ans.pb(b[t]);
        b.erase(b.begin()+t);
    }
    reverse(ALL(ans));
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        bool isFirst = true;
        int[] coins = new int[] { 10, 50, 100, 500 };
        int range = coins.Length;
        int bill, ownedMoney, changeMoney;
        int[] ownedCoins = new int[range], changeCoins = new int[range], paymentCoins = new int[range];

        while (true)
        {
            bill = int.Parse(Console.ReadLine());
            if (bill == 0) break;
            if (isFirst) { isFirst = false; } else { Console.WriteLine(); }
            ownedCoins = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            ownedMoney = 0;
            for (int i = range - 1; i >= 0; i--)
                ownedMoney += coins[i] * ownedCoins[i];

            changeMoney = ownedMoney - bill;

            for (int i = range - 1; i >= 0; i--)
            {
                changeCoins[i] = changeMoney / coins[i];
                changeMoney = changeMoney % coins[i];
                paymentCoins[i] = ownedCoins[i] - changeCoins[i];
            }
            for (int i = 0; i <= range - 1; i++)
                if (paymentCoins[i] > 0) Console.WriteLine("{0} {1}", coins[i], paymentCoins[i]);
        }
    }
}


Measured memory_bytes: 9380
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h,w,n;
    cin >> h >> w >> n;

    vector<pair<ll,ll>> p;
    for(int i = 0; i < n; i++){
        ll a,b;
        cin >> a >> b;
        p.push_back(make_pair(b,a));
    }
    for(ll i = 1; i <= w; i++){
        p.push_back(make_pair(i,h+1));
    }

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

    ll ans = INF;
    ll next = 1;

    for(ll i = 1; i <= w; i++){
        if(next > h){
            break;
        }
        auto itr = lower_bound(p.begin(),p.end(),make_pair(i,next));
        if((*itr).second == next){
            bool flag = true;
            while(flag){
                if(itr != p.end() && (*itr).second == next){
                    next++;
                    itr++;
                }else{
                    flag = false;
                }
            }
        }
        if(next > h){
            break;
        }
        auto itr2 = upper_bound(p.begin(),p.end(),make_pair(i,next));
        ans = min(ans,(*itr2).second-1);
        next++;
    }

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

Measured memory_bytes: 10604
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int H, W;
        {int[] a = in.ii(); H = a[0]; W = a[1];}
        boolean[][] s = new boolean[H+2][W+2];
        for(int i = 1; i <= H; i++){
            char[] c = in.s().toCharArray();
            for(int j = 1; j <= W; j++){
                s[i][j] = c[j-1] == '#'; 
            }
        }
        boolean flag = true;
        for(int i = 1; i <= H; i++){
            for(int j = 1; j <= W; j++){
                if(s[i][j] && !s[i][j-1] && !s[i][j+1] && !s[i+1][j] && !s[i-1][j]){
                    flag = false;
                    break;
                }
            }
        }
        out.println(flag ? "Yes" : "No");
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 22484
n = gets.chomp.to_i
array = gets.split(' ')
 
if array.include?("0")
  puts 0
  exit
end
 
num = 10 ** 18
answer = 1
 
n.times do |i|
  answer = answer * array[i].to_i
  if num < answer
    puts "-1"
    exit
  end
end
 
puts answer

Measured memory_bytes: 20860
#include <bits/stdc++.h>
#define SE second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define ll long long
#define LLI long long int
#define REP(i,a,b) for(long long i=a;i<b;i++)
#define PER(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define Arrays(a, size) sort((a), (a)+(size))
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
using namespace std;

ll A[100001];
vector<pair<ll,ll>> pairs;
ll n,m;
int main(){
    cin>>n>>m;
    for(ll i=0;i<n;i++) cin>>A[i];
    sort(A,A+n);
    for(ll i=0;i<m;i++) {
        ll b, c;
        cin >> b >> c;
        pairs.pb(make_pair(c, b));
    }
    RSORT(pairs);
    ll inserted=0,move=0;
    for(ll i=0;i<m;i++){
        ll c=pairs[i].first,b=pairs[i].second;
        for(ll j=0;j<b;j++){
            if(A[j+move]>=c||j+move>n)break;
            A[j+move]=c;
            inserted++;
        }
        move=inserted;
    }
    ll sum=0;
    for(ll i=0;i<n;i++)sum+=A[i];
    cout<<sum<<endl;
};

Measured memory_bytes: 3188
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using P = pair<double, string>;

int main() {
	for (int N; (N = in());) {
		vector<P> l(N);
		for (P &p: l) {
			int P, A, B, C, D, E, F, S, M;
			scan(p.second, P, A, B, C, D, E, F, S, M);
			p.first = (double) -((F * S * M) - P) / (A + B + C + (D + E) * M);
		}
		sort(l.begin(), l.end());
		for (P p :l)
			outl(p.second);
		outl('#');
	}
}


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

void solve(long long N, long long T, std::vector<long long> c,
           std::vector<long long> t) {
  long long ans = 1e9;
  for(int i = 0 ; i < N ; i++){
    if( t[i] <= T ){
      ans = min(ans, c[i]);
    }
  }
  if( ans == 1e9 ) cout << "TLE" << endl;
  else cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long T;
  scanf("%lld", &T);
  std::vector<long long> c(N);
  std::vector<long long> t(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &c[i]);
    scanf("%lld", &t[i]);
  }
  solve(N, T, std::move(c), std::move(t));
  return 0;
}


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

int main()
{
    int n, d, x;
    std::cin >> n >> d >> x;

    for (int i = 0; i < n; i++) {
        int temp;
        std::cin >> temp;

        if (d % temp == 0) {
            x += d / temp;
        } else {
            x += d / temp + 1;
        }
    }

    std::cout << x << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define llin(a) cin >> a
#define llpr(a) cout << a << " "
#define llout(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define DEBUG(x) cout << #x << " : " << x << endl;
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define M 998244353
#define N 1000005
typedef long long int ll;
int cnt[N];
ll fun[N];
int isprime[N],mob[N];
void develop()
{
    fill(isprime+2,isprime+N,1);
    fill(mob+1,mob+N,1);
    int i,a,p;
    for(i=2;i<N;i++)
    {
        if(isprime[i])
        {
            mob[i]*=(-1);
            for(a=2*i;a<N;a+=i)
            {
                isprime[a]=0,mob[a]*=(-1);
                if((a/i)%i==0)
                    mob[a]=0;
            }
        }
    }
}
ll bit(ll a,ll b,ll m)
{
    ll x=1;
    while(b>0)
    {
        if(b&1)
            x=(x*a)%m;
        b=b>>1;
        a=(a*a)%m;
    }
    return x;
}
ll inv(ll a,ll m)
{
    return bit(a,m-2,m);
}
int main()
{
    int i,n,a,d;
    develop();
    in(n);
    rep(i,n)
        in(a),cnt[a]++;
    ll sum,sq,temp;
    lp(i,1,N)
    {
        sum=0,sq=0;
        for(a=i;a<N;a+=i)
            temp=cnt[a],temp*=a,sum+=temp,temp*=a,sq+=temp;
        sum%=M,sq%=M;
        sum*=sum;
        sum+=(M-sq);
        fun[i]=sum%M;
    }
    ll ans=0;
    lp(i,1,N)
    {
        temp=0,d=1;
        for(a=i;a<N;a+=i,++d)
            temp+=(mob[d]*fun[a]);
        temp%=M;
        if(temp<0)
            temp+=M;
        temp*=inv(i,M);
        temp%=M;
        ans+=temp;
    }
    ans%=M;
    ans*=inv(2,M);
    llout(ans%M);
}
// read the constraint properly (ll vs int)


Measured memory_bytes: 19712
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}




int main() {

  string s;
  cin >> s;
  long n = s.size();


  long tmp = 0;
  for(int i=0;i<n;i++){
    if (i%2 ==0){
      if (s[i] == '0')tmp++;
    }else{
      if (s[i] == '1')tmp++;
    }
  }

  long tmp2=0;
  for(int i=0;i<n;i++){
    if (i%2 ==1){
      if (s[i] == '0')tmp2++;
    }else{
      if (s[i] == '1')tmp2++;
    }
  }

  long ans = 0;

  ans = min(tmp,tmp2);

  cout << ans << endl;

}




















Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int ati[]=new int[sc.nextInt()];
		int max=-10000000,min=10000000;
		long sum=0;
		for(int i=0;i<ati.length;i++) {
			ati[i]=sc.nextInt();
			if(ati[i]>max) {
				max=ati[i];
			}
			if(ati[i]<min) {
				min=ati[i];
			}
			sum+=ati[i];
		}
			System.out.println(min+" "+max+" "+sum);
			sc.close();
	}
}



Measured memory_bytes: 41092
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#define INF 1<<28
#define F first
#define S second
using namespace std;
 
int sx, sy, gx, gy;
typedef pair < int, int > P;
vector < P > p[5];
int memo[5][5][1111];

int dist(P a, P b){
  return abs(a.F - b.F) + abs(a.S - b.S);
}


int solve(int k, int t, int q){
 
  if(k == 4) return abs(p[t][q].F-gx) + abs(p[t][q].S-gy);
  if(memo[k][t][q]) return memo[k][t][q];
 
  int ans = INF, d = (t+1)%5, c;
  for(int i=0;i<p[d].size();i++){
    if(!k) c = abs(sx-p[d][i].F) + abs(sy-p[d][i].S);
    else c = abs(p[t][q].F-p[d][i].F) + abs(p[t][q].S-p[d][i].S);
    ans = min(ans, solve(k+1, d, i) + c);
  }
 
  return memo[k][t][q] = ans;
}
 
int main(){
 
  int w, h;
  char c;
 
  while(scanf("%d %d", &w, &h), w){
    
    for(int i=0;i<5;i++) p[i].clear();
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	scanf(" %c", &c);
	if(c == '.') continue;
	else if(c == 'S') sx = j, sy = i;
	else if(c == 'G') gx = j, gy = i;
	else p[c-'1'].push_back(P(j,i));
      }
    }
    
    int a, b = INF;
    for(int i=0;i<5;i++){
      memset(memo, 0, sizeof(memo));
      if(b > solve(0,i,0)) a = i+1, b = solve(0,i,0);
    }
 
    if(b == INF) puts("NA");
    else printf("%d %d\n", a, b);
 
  }
}

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

//やったぜ。日本語入力できた
int main()
{
    int ans = 0;
    int n, k;
    int dummy;

    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> dummy;
    }

    n -= k;
    ans++; k--;

    while (n > 0) {
        n -= k;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256