akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	
	public static int[] G = new int[9];
	public static int[] J = new int[9];
	public static int[] G2 = new int[9];
	public static boolean[] used = new boolean[9];
	public static int win = 0;
	public static int lose = 0;
	public static int draw = 0;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		doIt();

	}
	
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		for(int i = 0; i < num; i++){

			for(int j = 0; j < 9; j++){
				G[j] = sc.nextInt();
			}
			for(int j = 0; j < 9; j++){
				J[j] = sc.nextInt();
			}
			win = 0;
			lose = 0;
			draw = 0;
			setOrder(0);
			//System.out.println("win = " + win + ", lose = " + lose + ", draw = " + draw);
			double g = (double)win / (double)(win + lose + draw);
			double j = (double)lose / (double)(win + lose + draw);
			//System.out.println(g + " " +  j);
			System.out.printf("%.5f %.5f\n", g, j);
			
		}
	}
	
	public static void battle(){
		int g = 0,j = 0;
		for(int i = 0; i < 9; i++){
			if(G2[i] < J[i]){
				j += G2[i] + J[i];
			}
			else{
				g += G2[i] + J[i];
			}
		}
		if(j > g){
			lose++;
		}
		else if(g > j){
			win++;
		}
		else{
			draw++;
		}
	}
	
	public static void setOrder(int depth){
		if(depth == 9){
			battle();
		}
		for(int i = 0; i < 9; i++){
			if(used[i] == false){
				used[i] = true;
				G2[depth] = G[i];
				setOrder(depth + 1);
				used[i] = false;
			}
		}
	}

}

Measured memory_bytes: 12000
n = int(input())
a, b = map(int, input().split())
listP = list(map(int, input().split()))

listQ1=[]
listQ2=[]
listQ3=[]

index=0
while index< len(listP):
    if listP[index]<a+1:
        listQ1.append(listP[index])
    elif listP[index]<b+1:
        listQ2.append(listP[index])
    else:
        listQ3.append(listP[index])
    index+=1

print(min(len(listQ1), len(listQ2), len(listQ3)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n],dp[k+1]={0};
	for(int i=0;i<n;i++)
		cin>>arr[i];
	dp[0]=0;
	for(int i=1;i<=k;i++)
	{
		int h[3]={0},flag=0;
		vector <int> v;
		for(int j=0;j<n;j++)
		{
			if(i-arr[j]>=0)
			{
				v.push_back(dp[i-arr[j]]);
			}
		}
		if(v.size())
		{
			for(int j=0;j<v.size();j++)
			{
				if(v[j]==0)
				{
	//				cout<<i<<" ";
					flag=1;
					dp[i]=1;
					break;
				}
				h[v[j]]++;
			}
			if(flag==0)
			{
				if(h[2]!=0)
				{
					dp[i]=1;
				}
				else 
					dp[i]=2;	
			}
		}
	//	cout<<dp[i]<<endl;
	}
	if(dp[k]==1)
		cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct mint {
    const int mod = 1e9 + 7;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> cnt(60, 0);
    rep(i, n) {
        rep(j, sz(cnt)) {
            if ((a[i] & (1LL << j)) != 0) {
                cnt[j]++;
            }
        }
    }
    mint ans = 0;
    rep(i, n) {
        rep(j, sz(cnt)) {
            ll v = 1LL << j;
            bool f = ((a[i] & v) != 0);
            if (f) cnt[j]--;
            mint tmp = f ? (n - 1 - i - cnt[j]) : cnt[j];
            tmp *= v;
            ans += tmp;
        }
    }
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 2560
k = int(input())
l = list(map(int, input().split()))
import collections
z = []
n = collections.Counter(l)
y = [x* (x -1) / 2 for x in n.values()]
mai = {}
plus = {}
for k in n.keys():
  plus.setdefault(k, ((n[k] - 1) * (n[k]) / 2) )
  mai.setdefault(k, ((n[k] - 1) * (n[k] -2) / 2) )

base = sum(y)
q = [base - (plus[i] - mai[i]) for i in l]
for i in range(len(q)):
  print(int(q[i]))

Measured memory_bytes: 51232
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(void){
    int a,b,n;
    cin >> a >> b >> n;
    cout << (a+b)*n/2 << endl;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
 int n,sum=0;
 cin>>n;
 vector<int> v(n),c(n);
 r(i,n)cin>>v.at(i);
 r(i,n)cin>>c.at(i);
 r(i,n){
   if(v.at(i)-c.at(i)>0)sum+=v.at(i)-c.at(i);
 }
 cout<<sum<<endl;

return 0;}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  
  int answer = 1;
  for (int i = 0; i < N-1; i++) {
    if (d.at(i) > d.at(i+1)) answer++;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define sd second
#define ll long long

using namespace std;

const int maxn = 200100;
const int C = 27;
const int oo = 1e9;

int n,t[4*maxn];
ll ans;
vector<int> a[C];
vector<pair<int,int> > p;
string st;

void update(int i) {
    i++;
    while (i<=maxn) {
        t[i] = t[i] + 1;
        i += i&-i;
    }
}

ll get(int i) {
    i++;
    ll res=0;
    while (i>0) {
        res+=t[i];
        i -= i&-i;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
  //  freopen("in.txt","r",stdin);
    cin>>st;
    for (int i=0;i<st.length();i++) {
        a[st[i] - 'a'].push_back(i);
    }
    int id = -1;
    for (int i=0;i<C;i++)
        if (a[i].size()%2) {
            if (id!=-1) {
                cout<<-1;
                return 0;
            }
            id = i;
        }

    if (id!=-1) {
        int pos = a[id][a[id].size()/2];
        for (int i=0;i<C;i++)
            for (int j=0;j<a[i].size()/2;j++) {
                if (a[i][j] > pos) ans++;
                if (a[i][a[i].size()-j-1] < pos) ans++;
            }
    }

    for (int i=0;i<C;i++) {
        for (int j=0;j<a[i].size()/2;j++) p.push_back(mp(a[i][j],a[i][a[i].size()-j-1]));
    }
    sort(p.begin(),p.end());
    //for (int i=0;i<p.size();i++) cout<<p[i].fi<<" "<<p[i].sd<<endl;

    for (int i=0;i<p.size();i++) {
        ans += 2*(get(p[i].fi-1) - get(-1)) + get(p[i].sd-1) - get(p[i].fi-1);
        update(p[i].sd);
    }

    cout<<ans;

}


Measured memory_bytes: 3468
// 2011/11/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	for(int i=0; i<3; i++){
		int h1, m1, s1, h2, m2, s2;
		cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;

		// 00ª0b©çÌoßb
		int t1 = h1*3600+m1*60+s1;
		int t2 = h2*3600+m2*60+s2;

		int t3 = t2-t1;

		int h3 = t3/3600;
		int m3 = t3%3600/60;
		int s3 = t3%60;

		cout << h3 << ' ' << m3 << ' ' << s3 << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    char tmp[10001];

    while(1){
        //0 0?????\?????????????????§??\???????¶???????
        fgets(tmp,sizeof(tmp),stdin);
        int num[2];
        //??????
        num[0]=atoi(strtok(tmp," "));
        num[1]=atoi(strtok(NULL,"\n"));
        //?°???????????????????????????????
        if(num[0]==num[1]&&num[0]==0)break;
        if(num[0]>num[1]){
            printf("%d %d\n",num[1],num[0]);
        }else{
            printf("%d %d\n",num[0],num[1]);
        }
    }
    
    
return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, a[100000];
map<ll, ll> cnt;

int main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	ll ans = 0;
	each(it,cnt) {
		ll x = it.fi;
		ll y = it.se;
		if (x<y) ans += y - x;
		else if (y<x) ans += y;
	}
	cout << ans << ln;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    string s; cin >> s;
    int n = (int) s.length();
    reps(i,1,n/2){
        if(s.substr(0,n/2-i) == s.substr(n/2-i,n/2-i)){
            cout << n - i*2 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define sqr(x) (x)*(x)
using namespace std;

int main(){
#ifdef LOCAL
    freopen("inp.txt", "r", stdin );
    freopen("ans.txt", "w", stdout);
#endif
    string t = "ABC";
    int n; cin >> n;
    string s; cin >> s;
    int c = 0;
    for(int i=0; i<=n-3; i++){
    	if(s.substr(i,3)==t) c++;
    }
    cout << c << '\n';
}


Measured memory_bytes: 3608
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int n,y;
    bool flag = false;
    cin >> n >> y;
    y /= 1000;
    
    for(int i = 0; i <= n; i++){
        for(int j = 0; i + j <= n; j++){
            if((y - i*10 - j*5) == n - i - j){
                cout << i << " " << j << " " << n-i-j;
                flag = true;
                break;
            }
            if(flag) break;
        }
        if(flag) break;
    }

    if(!flag){
        cout << -1 << " " << -1 << " " << -1;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

signed main(){
    ll n,m,x=-1,y=-1,ans=1;
    cin>>n>>m;
    vector<ll> fib(n+1);
    fib.at(0)=1;
    fib.at(1)=1;

    for(ll i=2;i <= n;i++)
    {
        fib.at(i)=fib.at(i-1)%mod+fib.at(i-2)%mod;
        fib.at(i)%=mod;
    }

    for(ll i=0;i < m;i++)
    {
        cin>>y;
        if(y==x+1){
            cout << 0 << endl;
            return 0;
        }
        ans*=fib.at(y-x-2);
        ans%=mod;
        x=y;
    }
    ans*=(fib.at(n-y-1)%mod);
    cout << ans%mod << endl;
}
//入力がない時初期値が効いてくるので、初期値はちゃんと考えて置くこと

Measured memory_bytes: 1024
#include<cstdio>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int inf=1<<28;
int n,m,C;
int d[100][100],e[100][100];
bool v[100];

int main()
{
	while(scanf("%d%d%d",&n,&m,&C),n){
		rep(i,n)rep(j,n)e[i][j]=d[i][j]=inf;
		rep(i,m){
			int a,b,c; scanf("%d%d%d",&a,&b,&c);
			e[a-1][b-1]=c;
		}
		d[0][0]=0;
		rep(i,n){
			rep(j,n)v[j]=0;
			rep(j,n){
				int mn=inf,c=0;
				rep(k,n)if(!v[k]&&d[i][k]<mn)mn=d[i][k],c=k;
				v[c]=1;
				if(c==n-1&&mn<=C){
					printf("%d\n",i); goto END;
				}
				rep(k,n)if(e[c][k]!=inf){
					if(!v[k]&&d[i][k]>d[i][c]+e[c][k])d[i][k]=d[i][c]+e[c][k];
					if(d[i+1][k]>d[i][c])d[i+1][k]=d[i][c];
				}
			}
		}
		END:;
	}
	return 0;
}

Measured memory_bytes: 840
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll x;
    cin >> x;
    vector<ll> V;
    V.push_back(0);
    ll cnt = 1;
    ll c = 1;
    while(c <= 1000000000000000000){
        c = pow(cnt, 5);
        V.push_back(c);
        cnt++;
    }
  
    rep(i,V.size() + 1) {
        rep(j, V.size() + 1) {
            if(V[i] + V[j] == x) {
                cout << i << " " << -1 * j << endl;
                return 0;
            } 
            if(V[i] - V[j] == x) {
                cout << i << " " <<  j << endl;
                return 0;
            }
            if(-V[i] + V[j] == x) {
                cout << -1 * i << " " << -1 * j << endl;
                return 0;
            }
            if(-V[i] - V[j] == x) {
                cout << -1 * i << " " <<  j << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

 using namespace std;

 int main() {
   int N, A, B, ans;

   cin >> N >> A >> B;

   ans = 0;
   for (int i = 1; i <= N; i++) {
     if (i / 10000 + i % 10000 / 1000 + i % 1000 / 100 + i % 100 / 10 + i % 10 >= A && i / 10000 + i % 10000 / 1000 + i % 1000 / 100 + i % 100 / 10 + i % 10 <= B) {
       ans += i;
     }
   }

   cout << ans << endl;

 }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vp in(n);
	rep(i,n)cin>>in[i].first;
	rep(i,n)cin>>in[i].second;
	int sum=0;
	rep(i,n)sum+=in[i].first;
	vd T(sum*2+1);
	double t=0;
	int tim=0;
	rep(i,n){
		t=min(t,(double)in[i].second);
		rep(j,2*in[i].first){
			t=min(t+0.5,(double)in[i].second);
			T[++tim]=t;
		}
	}
	T[sum*2]=0;
	t=0,tim=sum*2;
	rep(i,n){
		t=min(t,(double)in[n-1-i].second);
		rep(j,2*in[n-1-i].first){
			t=min(t+0.5,(double)in[n-1-i].second);
			tim--;
			T[tim]=min(T[tim],t);
		}
	}
//	rep(i,T.size())cout<<" "<<T[i];cout<<endl;
	double out=0;
	rep(i,T.size()-1){
		out+=(T[i]+T[i+1])/4.;
	}
	cout<<shosu(9)<<out<<endl;
}










Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
const int MAXN = 2e5 + 5, MAXM = 2e3 + 5, BOUND = 2e5, MOD = 1e9 + 7, INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-3;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define rc(x) ch[x][1]
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int a, b, c;
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> a >> b >> c;
	if (a == b && b == c)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i,tei;
	int st[31];
	for(i=1;i<31;i++)st[i]=0;
	for(i=0;i<28;i++){
		scanf("%d",&tei);
		st[tei]+=tei;
	}
	for(i=1;i<32;i++){
		if(st[i]==0)
			printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

def main():
    N = II()
    li = []
    for i in range(N):
        S, P = LS()
        li.append([S, int(P), i])

    li = sorted(li, key= lambda x: (x[0], -x[1]))
    for j in li:
        print(j[2]+1)

main()

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll m,n;
  while(cin >> m >> n && m && n){
    string s;
    ll pl[m] = {};
    ll k = 0,cnt = m;
    REP(i,1,n+1){
      cin >> s;
      if(cnt != 1){
        while(pl[k]){
          ++k;
          k %= m;
        }
        if(i % 15 == 0 && s != "FizzBuzz"){
          pl[k] = 1;
          --cnt;
        }
        else if(i % 15 != 0 && i % 5 == 0 && s != "Buzz"){
          pl[k] = 1;
          --cnt;
        }
        else if(i % 15 != 0 && i % 3 == 0 && s != "Fizz"){
          pl[k] = 1;
          --cnt;
        }
        else if(i % 3 != 0 && i % 5 != 0 && to_string(i) != s){
          pl[k] = 1;
          --cnt;
        }
        ++k;
        k %= m;
      }
    }
    ll f = false;
    rep(i,m){
      if(!pl[i]){
        if(f) cout << " ";
        cout << i+1 ;
        f = true;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3172
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=5000;

int n,nops;
char s[MAXLEN+1];
char ans[MAXLEN+1];

char t[2*MAXLEN+1];

void solve() {
	REP(i,n) t[i]=s[i]; REP(i,n) t[n+i]=t[n-i-1]; t[2*n]='\0';
	string best=string(t,t+n); FOR(i,1,n) best=min(best,string(t+i,t+n+i));
	//printf("t=%s best=%s\n",t,best.c_str());
	char c=best[0]; int cnt=0; while(cnt<n&&best[cnt]==c) ++cnt;
	int nc=cnt; REP(i,nops-1) nc=min(n,2*nc);
	REP(i,nc) ans[i]=c; REP(i,n-nc) ans[nc+i]=best[cnt+i];
}

void run() {
	scanf("%d%d",&n,&nops);
	scanf("%s",s); assert(strlen(s)==n);
	solve();
	printf("%s\n",ans);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  int N = s.length();
  per(i,N/2){
    if(s.substr(0,i) == s.substr(i,i)){
      cout << 2*i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func bubbleSort(a []int, n int) ([]int, int) {
	var cnt int
	flag := true
	for flag {
		flag = false
		for i := n-1; i > 0; i-- {
			if a[i-1] > a[i] {
				a[i-1], a[i] = a[i], a[i-1]
				cnt++
				flag = true
			}
		}
	}
	return a, cnt
}

func main() {
	var n, cnt int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	a, cnt = bubbleSort(a, len(a))
	for i, v := range a {
		if i == len(a) - 1 {
			fmt.Printf("%d\n", v)
		} else {
			fmt.Printf("%d ", v)
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int n, m;

int en(int v, int i) {
    return i * n + v;
}

pii de(int x) {
    int v = x % n;
    int i = x / n;
    return {v, i};
}

void solve() {
    cin >> n >> m;
    vector<int> G[n * 3];
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[en(u, 0)].push_back(en(v, 1));
        G[en(u, 1)].push_back(en(v, 2));
        G[en(u, 2)].push_back(en(v, 0));
    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    vector<int> dist(3 * n, INF);
    dist[s] = 0;
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push({0, s});
    while(!pq.empty()) {
        int v = pq.top().se;
        pq.pop();
        for (auto u : G[v]) {
            if (chmin(dist[u], dist[v] + 1)) {
                pq.push({dist[u], u});
            }
        }
    }
    cout << (dist[t] == INF ? -1 : dist[t] / 3) << endl;
}

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


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

ll N;
int ans = 0;

bool judge(ll x)
{
  string s = to_string(x);
  bool f3 = false, f5 = false, f7 = false;
  rep(i, 0, s.size())
  {
    if (s[i] == '3')
      f3 = true;
    if (s[i] == '5')
      f5 = true;
    if (s[i] == '7')
      f7 = true;
    if (f3 && f5 && f7)
      return true;
  }
  return false;
}

void dfs(ll x)
{
  if (x > N)
    return;
  if (judge(x))
    ans++;
  dfs(10 * x + 3);
  dfs(10 * x + 5);
  dfs(10 * x + 7);
}

int main()
{
  cin >> N;
  dfs(0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    cout << (N-K <= 0 ? 1 : 0) << ln;
}


Measured memory_bytes: 3216
#include<stdio.h>

int main(void) {

	int m, f, b, kari;
	scanf("%d %d %d", &m, &f, &b);
	if (m >= b) {
		printf("0\n");
	}
	else if(m + f < b){
		printf("NA\n");
	}
	else {
		kari = b - m;
		printf("%d\n", kari);
	}

	return 0;
}


Measured memory_bytes: 2072
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int> v(N), w(N); rep(i, 0, N) { cin >> v[i] >> w[i]; }
	vector<int>dp(100 * 110, INF);
	dp[0] = 0;
	rep(i, 0, N)rrep(j, v[i], 100 * 110)
		chmin(dp[j], dp[j - v[i]] + w[i]);
	int ans(0);
	rep(i, 0, 100 * 110)if (dp[i] <= W)chmax(ans, i);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3204
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	cla := b / c
	csm := a / c
	csum := cla - csm
	if a%c == 0 {
		csum++
	}
	dla := b / d
	dsm := a / d
	dsum := dla - dsm
	if a%d == 0 {
		dsum++
	}
	lc := lcm(c, d)
	ela := b / lc
	esm := a / lc
	esum := ela - esm
	if a%d == 0 {
		esum++
	}
	fmt.Println(b - a + 1 - csum - dsum + esum)
}

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

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}


Measured memory_bytes: 512
#include <stdio.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int main(){
    int n;
    ll ans=1,x;
    scanf("%d",&n);
    rep(i,n){
        scanf("%lld",&x);
        ans=ans/gcd(ans,x)*x;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
a,b,k = gets.chomp.split.map(&:to_i)
an = []
bn = []
(1..a).each do |i|
  if a % i == 0
    an << i
  end
end
(1..b).each do |i|
  if b % i == 0
    bn << i
  end
end
c = an & bn
puts c[-k]


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

int main(void){
  int N,SUM;
  cin >> N;
  vector<int> time(N);
  for(int i=0;i<N;i++) {
    int A;
    cin >> A;
    time.at(i)=A;
    SUM+=A;
  }
  
  int M;
  cin >> M;
  for(int i=0;i<M;i++){
    int B,C;
    cin >> B >> C;
    cout << SUM - time.at(B-1) + C << endl;
  }
}
  
  
    

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>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b, k, c = 0; cin >> a >> b >> k;
  for(int i = min(a, b); i; --i) {
    if(!(a%i||b%i)) ++c;
    if(c == k) {
      cout << i; return 0;
    }
  }
}
    


Measured memory_bytes: 256
# DFS(再帰） v:頂点
def DFS(v,dis,fin):
  global time
  # 訪問したので発見時刻を記入
  dis[v] = time
  time += 1
  
  # vに隣接している頂点をみる
  for u in V[v]:
    if dis[u] is None:
      DFS(u,dis,fin)
  
  # 処理が完了したので完了時刻を記入
  fin[v] = time
  time += 1
  
n = int(input())
# 0番目を始点として初期化
V = [[i for i in range(n)]]

for i in range(n):
  _, __, *a = map(int, input().split())
  V.append(a)

dis = [None]*(n+1)# 頂点を発見した時刻
fin = [None]*(n+1)# 頂点の完了時刻
time = 0
DFS(0,dis,fin)

for i in range(1,n+1):
  print(i, dis[i], fin[i])


Measured memory_bytes: 5712
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    while(n%111!=0) n++;
    cout<<n;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
int main()
{
	ll n,m;
	cin>>n;
	if(n&1)
	printf("%lld\n",n/2+1);
	else
	printf("%lld\n",n/2); 


}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int culc(int x)
{
	int res = 0;
	while (x) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

int N;

void init()
{
	cin >> N;
}

void solve()
{
	int mi = 1000000;
	reps(i, 1, N) {
		int t = culc(N-i) + culc(i);
		mi = min(mi, t);
	}
	cout << mi << endl;
}


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

struct Node {
	int key;
	Node *parent, *left, *right;
};

Node *NIL, *root;

void printPreOrder(Node *u);
void printInOrder(Node *u);
void insertTree(int k);
void isFound(int k);
void deleteNode(int k);
Node* getSuccessor(Node *u);
Node* getMinimum(Node *u);

int main() {
	int i, j, n, k;
	char com[10];
	cin >> n;
	
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'i') {
			cin >> k;
			insertTree(k);
		} else if (com[0] == 'f') {
			cin >> k;
			isFound(k);
		} else if(com[0] == 'd'){
			cin >> k;
			deleteNode(k);
		} else {
			printInOrder(root);
			cout << endl;
			printPreOrder(root);
			cout << endl;
		}
	}
	return 0;
}

void printPreOrder(Node *u) {
	if (u == NIL)return;
	cout << " " << u->key;
	printPreOrder(u->left);
	printPreOrder(u->right);
}

void printInOrder(Node *u) {
	if (u == NIL)return;
	printInOrder(u->left);
	cout << " " << u->key;
	printInOrder(u->right);
}

void insertTree(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	z = new Node;
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if (y == NIL)root = z;
	else if (z->key < y->key)y->left = z;
	else y->right = z;
}

void isFound(int k) {
	Node *x = root;
	while (x != NIL) {
		if (x->key == k) {
			cout << "yes\n";
			return;
		}
		else if (x->key < k)x = x->right;
		else x = x->left;
	}
	cout << "no\n";
	return;
	return;
}

void deleteNode(int k) {
	Node *x, *y, *z = root;
	while (z != NIL && z->key != k) {
		if (k < z->key)z = z->left;
		else z = z->right;
	}
	if (z == NIL)return;

	if (z->left == NIL || z->right == NIL)y = z;
	else y = getSuccessor(z);

	if (y->left != NIL)x = y->left;
	else x = y->right;

	if (x != NIL)x->parent = y->parent;

	if (y->parent == NIL)root = x;
	else if (y == y->parent->left)y->parent->left = x;
	else y->parent->right = x;

	if (y != z)z->key = y->key;

	delete y;

}

Node* getSuccessor(Node *u) {
	if (u->right != NIL)return getMinimum(u->right);
	Node *y = u->parent;
	while (y != NIL && u == y->right) {
		u = y;
		y = y->parent;
	}
	return y;
}

Node* getMinimum(Node *u) {
	while (u->left != NIL) {
		u = u->left;
	}
	return u;
}

Measured memory_bytes: 21836
/*input
bcbc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=500005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int fa[maxn];
int ff[maxn];
int main(){
	IOS;
	string s;
	cin>>s;
	int n=SZ(s);
	{
		string tmp=s;
		sort(ALL(tmp));
		if(tmp[0]==tmp.back()){
			cout<<SZ(s)<<'\n'<<1<<'\n';
			return 0;
		}
	}
	fa[0]=-1;
	for(int i=1,j=-1;i<SZ(s);i++){
		while(j>=0&&s[j+1]!=s[i]){
			j=fa[j];
		}
		if(s[j+1]==s[i]) j++;
		fa[i]=j;
	}
	// REP(i,SZ(s)) cout<<fa[i]<<" \n"[i==SZ(s)-1];
	if(fa[SZ(s)-1]==-1){
		cout<<"1\n1\n";
		return 0;
	}
	int per=fa[SZ(s)-1]+1;
	per=n-per;
	if(n%per){
		cout<<"1\n1\n";
		return 0;
	}
	string t=s;
	reverse(ALL(t));

	ff[0]=-1;
	for(int i=1,j=-1;i<SZ(t);i++){
		while(j>=0&&t[j+1]!=t[i]) j=ff[j];
		if(t[j+1]==t[i]) j++;
		ff[i]=j;
	}
	// REP(i,SZ(s)) cout<<ff[i]<<" \n"[i==SZ(s)-1];
	int ans=0;
	for(int i=1;i<n;i++){
		if((fa[i-1]!=-1&&i%(i-fa[i-1]-1)==0)||(ff[n-i-1]!=-1&&(n-i)%(n-i-ff[n-i-1]-1)==0)) continue;
		ans++;
	}
	cout<<"2\n"<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 5168
n, x = map(int, input().split())
a = list(map(int, input().split()))
k = 0
cnt = 0

if a[1] + a[0] > x and x >= a[0] :
    k = x - a[0]
    cnt += a[1] + a[0] - x

elif a[1] + a[0] > x and x < a[0] :
    k = 0
    cnt += a[1] + a[0] - x

else :
    k = a[1]

for i in range(1, n - 1) :
    if k + a[i + 1] <= x :
        k = a[i + 1]     

    elif x >= k :
        cnt += k + a[i + 1] - x
        k = x - k

    else :
        cnt += k + a[i + 1] - x
        k = 0
    

print(cnt)

Measured memory_bytes: 20056
while True :
	H, W = map(int, input().split())
	if H == 0 and W == 0 :
		break
	for i in range(H) :
		if i%2 == 0 :
			#シャープから始まる
			for j in range(W) :
				if j%2 == 0 :
					print("#", end="")
				else :
					print(".", end="")
			print("")
		else :
			#ピリオドから始まる
			for j in range(W) :
				if j%2 == 0 :
					print(".", end="")
				else :
					print("#", end="")
			print("")
		if i == H-1 :
			print("")



Measured memory_bytes: 7012
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> counts(26, -1);

  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    vector<int> cnt(26, 0);
    for (auto c: s) ++cnt[c - 'a'];
    for (int j = 0; j < counts.size(); ++j) {
      if (counts[j] < 0 or counts[j] > cnt[j]) counts[j] = cnt[j];
    }
  }

  for (int i = 0; i < counts.size(); ++i) {
    for (int j = 0; j < counts[i]; ++j) cout << static_cast<char>('a' + i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

s = input()
nums = list(map(int, list(s)))
operators = ['+', '+', '+']

def exec(nums, operators):
    num = 0
    num += nums[0]        
    i = 1
    for op in operators:
        if op == '+':
            num += nums[i]
        elif op == '-':
            num -= nums[i]

        i += 1

    return num

def output(nums, operators):
    string = ''
    i = 0
    for n in nums:
        string += str(n)
        if i < len(operators):
            string += operators[i]

        i += 1

    string += '=7'
    print(string)


length = len(operators)

for i in range(2 ** length):
    _operators = operators
    for j in range(length):
        if ((i >> j) & 1):
            _operators[length - 1 - j] = '+'
        else: 
            _operators[length - 1 - j] = '-'

    if exec(nums, _operators) == 7:
        output(nums, _operators)
        break


Measured memory_bytes: 9156
using System;

namespace ABC122B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int i = 0;
            int iTmp = 0;
            for (int inum = 0; inum < input[0].Length; inum++)
            {
                string word = input[0];
                if (word[inum] == 'A' || word[inum] == 'C' || word[inum]=='G'||word[inum]=='T') {
                    if (iTmp == i)
                    {
                        i = i + 1; ;
                    }
                    iTmp = iTmp + 1;
                }
                else
                {
                    iTmp = 0;
                }
            }
            Console.WriteLine(i);
        }
    }
}


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

int main(){
    int x ;
    cin >> x ;
    if ( x >= 30){
        cout << "Yes" << endl ;
    }
    else {
        cout << "No" << endl ;
    }
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ll long long
#define pii pair <int,int>
#define fr first
#define sc second

using namespace std;

const int N = 200200;
const int Mod = 1e9 + 7;

int Fact[N];
int iFact[N];

int add(int x,int y){
    if((x += y) >= Mod) x -= Mod;
    return x;
}
int sub(int x,int y){
    if((x -= y) < 0)    x += Mod;
    return x;
}
int mul(int x,int y){
    return (ll) x*y % Mod;
}
void add_self(int& x,int y){
    x = add(x,y);
}
void sub_self(int& x,int y){
    x = sub(x,y);
}
void mul_self(int& x,int y){
    x = mul(x,y);
}
int fp(int x,int y){
    if(!y)  return 1;
    if(y&1) return mul(x,fp(x,y-1));
    return fp(mul(x,x),y>>1);
}
int inv(int y){
    return fp(y,Mod-2);
}
int C(int n,int r){
    if(n<0||r<0||n<r)   return 0;
    return mul(Fact[n],mul(iFact[r],iFact[n-r]));
}
int binomial(int n,int m){
    return C(n+m-2,n-1);
}
int Go(int x1,int y1,int x2,int y2){
    if(x1>x2||y1>y2)    return 0;
    return binomial(x2-x1+1,y2-y1+1);
}

bool Cmp(const pii& p1,const pii& p2){
    return p1.fr + p1.sc < p2.fr + p2.sc;
}

int Dp[N];

int main()
{
    Fact[0] = iFact[0] = 1;
    for(int i=1;i<N;i++)    Fact[i] = mul(i,Fact[i-1]) , iFact[i] = inv(Fact[i]);

    int n,m,k;  cin>>n>>m>>k;

    vector <pii> black;

    for(int i=0;i<k;i++)
    {
        int x,y;    scanf("%d%d",&x,&y);
        black.emplace_back(x,y);
    }

    black.emplace_back(n,m);
    k++;

    sort(black.begin(),black.end(),Cmp);

    for(int i=0;i<k;i++)
    {
        Dp[i] = Go(1,1,black[i].fr,black[i].sc);

        for(int j=0;j<i;j++)    sub_self(Dp[i],mul(Dp[j],Go(black[j].fr,black[j].sc,black[i].fr,black[i].sc)));
    }

    cout << Dp[k-1];
}


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

A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum = 0
for i in range(N):
    if A[N-i] >= B[N-1-i]:
        sum += B[N-1-i]
        A[N-i] = A[N-i] - B[N-1-i]
        B[N-1-i] = 0
    else:
        sum += A[N-i]
        B[N-1-i] = B[N-1-i] - A[N-i]
        A[N-i] = 0
    if A[N-1-i] >= B[N-1-i]:
        sum += B[N-1-i]
        A[N-1-i] = A[N-1-i] - B[N-1-i]
        B[N-1-i] = 0
    else:
        sum += A[N-1-i]
        B[N-1-i] = B[N-1-i] - A[N-1-i]
        A[N-1-i] = 0

print(sum)

Measured memory_bytes: 18752
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	int n;
	cin >> n;
	int stage[2][101];
	int answer = 0;

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> stage[i][j];
		}
	}

	for (int i = 0; i < n; i++) {
		int temp = 0;
		for (int j = 0; j <= i; j++) {
			temp += stage[0][j];
		}
		for (int j = i; j < n; j++) {
			temp += stage[1][j];
		}
		answer = max(answer, temp);
	}

	cout << answer;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    int n;
    cin >> n;
    map<pair<int, int>, int> mp;
    rep(i, n) {
        double x;
        cin >> x;
        ll y = llround(x * 1e9);
        int two = 0, five = 0;
        while (y % 2 == 0) {
            two++;
            y /= 2;
        }
        while (y % 5 == 0) {
            five++;
            y /= 5;
        }
        mp[{two, five}]++;
    }

    ll ans = 0;
    for (auto p1 : mp) {
        for (auto p2 : mp) {
            if (p1.first.first + p2.first.first >= 18 && p1.first.second + p2.first.second >= 18) {
                if (p1 < p2) {
                    ans += 1LL * p1.second * p2.second;
                } else if (p1 == p2) {
                    ans += 1LL * p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    cout << ans << '\n';
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int n,p;
    cin >> n >> p;
    vector<int> a(n);
    int od=0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i]%2) od++;
    }
    int ev=n-od;

    ll ch[od+1];
    ch[0]=1;
    for(ll i = 1; i <= od; i++) {
        ch[i]=ch[i-1]*(od-i+1)/i;
    }
    for(ll i = 0; i <= od; i++) cerr << od << " C " << i << " : " << ch[i] << "\n";
    ll ans=0;
    for(int i = 0; i <= od; i+=2) {
        ans+=ch[i];
    }
    ans*=pow(2,ev);
    if(p==1) ans=pow(2,n)-ans;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4032
<?php
fscanf(STDIN, "%d%d", $L, $N);
$P = array_map("intval", explode(" ", fgets(STDIN)));
$P[] = $P[0]+$L;
$maxDistance = 0;
for($i = 0; $i < $N; $i++){
  $maxDistance = max($maxDistance, $P[$i+1]-$P[$i]);
}
echo $L - $maxDistance;

Measured memory_bytes: 27124
n=int(input())
a=[]
s=0
t=0
d=0
for i in input().split():
  a.append(int(i))
  s=s+int(i)
for i in range(n):
  t=t+a[i]
  if t<=s//2:
    d=(s-t)-t
  elif t>s//2:
    if (t-(s-t))<d:
      d=t-(s-t)
    break
print(d)

Measured memory_bytes: 3064