akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;
	vector<int> blackcum(1);
	for(int i=0; i<N; i++){
		if(S[i]=='#') blackcum.push_back(blackcum[i]+1);
		else blackcum.push_back(blackcum[i]);
	}

	int ans = 1e8;
	for(int i=0; i<=N; i++){
		//cout << blackcum[i] << " " << N-i-blackcum[N]+blackcum[i] << endl;
		ans = min(ans, blackcum[i]+(N-i-blackcum[N]+blackcum[i]));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<long long> vl;

signed main() {

  int S, W;
  
  cin >> S >> W;
  
  if( S <= W ) {
    puts("unsafe");
  } else {
    puts("safe");
  }

}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(i , L , R) for( i = L ; i < R ; i++)
#define per(i,L,R) for( i = L; i >= R; i--)
#define all(con) (con).begin(),(con).end()
#define fi first
#define se second
#define foreach(iter,con) for(auto iter=(con).begin(); iter!=(con).end(); iter++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] << (i==R?'\n':' ')
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}

int main()
{
   SPEED
//   ll q,i,l,r;
//   string s;
//   cin>>s;
//   ll n = s.length();
//   ll a[n+1]={0};
//   rep(i,0,n-1)
//   {
//       if(s[i]==s[i+1])
//        a[i+1]=1;
//   }
//   printa(a,0,n+1);
//   cout<<"\n";
//   rep(i,1,n+1)
//   {
//       a[i]=a[i]+a[i-1];
//   }
//
//  // printa(a,0,n);
//   cin>>q;
//   while(q--)
//   {
//       cin>>l>>r;
//       cout<<a[r-1]-a[l-2]<<"\n";
//   }
     ll n,a;
     cin>>n;
     if(n%2==0)
        cout<<"0.50000000\n";
     else
        cout<<fixed<<setprecision(7)<<((ld)n-(ld)(n-1)/2)/n<<"\n";

}












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

using namespace std;

const int MAX_N = 2e3 + 5;
const int MAX_L = 20;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;



void solve() {
    ll a, b; cin >> a >> b;
    if (a % 2 != b % 2) cout << "IMPOSSIBLE";
    else cout << (a + b) / 2;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int tc; tc = 1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>
#include<set>
 
#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000
 
typedef long long int ll;
typedef unsigned long long int ull;
 
using namespace std;
 
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
 
 
int main() {

	ll N;
	cin >> N;

	vector<pair<ll,ll>> A(N);
	rep(i, N) {
		cin >> A[i].first;
		A[i].second = i+1;
	}

	Sort(A);


	rep(i, N) {
		cout << A[i].second << " ";
	}


	return 0;
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = sc.nextInt();



        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            if (i < k) {
                a[i] = s;
            } else {
                if (s == 1000000000) {
                    a[i] = 1;
                } else {
                    a[i] = s + 1;
                }
            }
        }

        for (int i = 0 ; i < n ; i++) {
            System.out.print(a[i]);
            if (i < n - 1) {
                System.out.print(" ");
            } else {
                System.out.print("\n");
            }
        }
    }

}

Measured memory_bytes: 44204
#define FILEIO(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout);
#include <stdio.h>
#include <queue>
#include <algorithm>
#define N 10005
using namespace std;
int n,k,q,a[N],b[N],c[N];
inline void smin(int &a,int b){b<a?a=b:0;}
inline int read() {
	char c=getchar();int x=0;
	while(c<48||c>57) c=getchar();
	while(c>47&&c<58) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x;
}
int solve(int x) {
	static int i,j,ans,m,t,p;
	ans=0;m=0;
	for(i=0;i<n;++i) {
		for(j=i;j<n&&a[j]>=x;++j);
		if(j-i>=k) {
			p=j-i-k;
			for(t=0;i<j;) b[t++]=a[i++];
			sort(b,b+t);
			while(~p) c[m++]=b[p--];
		}
	}
	if(m<q) return 1<<30;
	sort(c,c+m);
	return c[q-1]-x;
}
int main() {
//	FILEIO("operation");
	int i,ans=1<<30;
	n=read();k=read();q=read();
	for(i=0;i<n;++i) a[i]=read();
	for(i=0;i<n;++i) smin(ans,solve(a[i]));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
use std::io::*;

const MOD: usize = 998244353;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    let c: usize = itr.next().unwrap().parse().unwrap();
    let d: usize = itr.next().unwrap().parse().unwrap();

    let mut dp = vec![vec![0; d + 1]; c + 1];
    dp[a][b] = 1usize;
    for i in a..=c {
        for j in b..=d {
            dp[i][j] += dp[i - 1][j] * j % MOD;
            dp[i][j] += dp[i][j - 1] * i % MOD;
            dp[i][j] += MOD - dp[i - 1][j - 1] * (i - 1) * (j - 1) % MOD;
            dp[i][j] %= MOD;
        }
    }
    println!("{}", dp[c][d]);
}


Measured memory_bytes: 72488
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

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

    vector<ll> sum(N, 0);
    sum[0] = A[0];
    for (ll i = 1; i < N; i++) {
        sum[i] = sum[i - 1] + A[i];
    }

    for (ll i = N - 1; i >= 0; i--) {
        auto index = upper_bound(A.begin(), A.end(), sum[i] * 2) - A.begin();
        if (i != N - 1 && index == i + 1) {
            cout << N - 1 - i << endl;
            return 0;
        }
    }

    cout << N << endl;
}

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

c = 0
for i in range(N):
  mat = i
  for j in range(i, N):
    if A[j] < A[mat]:
      mat = j
  if i != mat:
    t = A[i]
    A[i] = A[mat]
    A[mat] = t
    c += 1

print(" ".join(map(str, A)))
print(c)


Measured memory_bytes: 5596
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		System.out.println((int) Math.ceil(N * 0.5));
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S = in<string>();
    string mae = "",ushiro = "";
    bool on = 0;
    int Q = in();
    REP(i,Q){
        if(in() == 1){
            on = (on ? 0 : 1);
        }else{
            int tmp = in();
            if(on)tmp = (tmp == 1 ? 2 : 1);
            if(tmp == 1){
                mae = in<string>() + mae;
            }else{
                ushiro = ushiro + in<string>();
            }
        }
    }
    S = mae + S + ushiro;
    if(on)reverse(ALL(S));
    cout << S << "\n";
}


Measured memory_bytes: 1320
// Aizu Vol-10 1006:   Boring Commercials
// 2017.8.19 bal4u@uu

#include <stdio.h>
#include <string.h>

int tbl[1500];

int d2t(int d) { return (d / 100) * 60 + (d % 100); }

int main()
{
	int n, p, q, k, t1, t2;
	int i, j, t, max;

	while (scanf("%d%d%d", &n, &p, &q) && n) {
		memset(tbl, 0, sizeof(tbl));
		p = d2t(p), q = d2t(q);
		for (i = 0; i < n; i++) {
			scanf("%d", &k);
			for (j = 0; j < k; j++) {
				scanf("%d%d", &t1, &t2);
				t1 = d2t(t1), t2 = d2t(t2);
				for (t = t1; t < t2; t++) tbl[t]++;
			}
		}
		for (max = 0, k = 0, t = p; t < q; t++) {
			if (tbl[t] < n) k++;
			else if (k > 0) { if (k > max) max = k; k = 0; }
		}
		if (k > max) max = k;
		printf("%d\n", max);
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  string s[n];
  rep(i,0,n){
    cin>>s[i];
  }
  vector<P> left;
  vector<P> right;
  rep(i,0,n){
    int worst=0;
    int las=0;
    rep(j,0,s[i].size()){
      if(s[i][j]=='(') las++;
      else las--;
      worst=min(worst,las);
    }
    if(las>0){
      left.push_back(P(worst,las));
    }
    else{
      right.push_back(P(worst-las,-las));
    }
  }
  sort(left.begin(),left.end());
  reverse(left.begin(),left.end());
  sort(right.begin(),right.end());
  reverse(right.begin(),right.end());
  bool p=true;
  int curl=0;
  rep(i,0,left.size()){
    if(curl+left[i].first<0){
      p=false;
    }
    curl+=left[i].second;
  }
  int curr=0;
  rep(i,0,right.size()){
    if(curr+right[i].first<0){
      p=false;
    }
    curr+=right[i].second;
  }
  if(p && curl==curr) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 42480
N = int(input())
R = []
for _ in range(N):
    X, L = map(int, input().split())
    l, r = X-L, X+L
    R.append([l, r])

R = sorted(R, key=lambda x: x[1])
tmp = R[0]
ans = [R[0]]
for i in range(1, N):
    v = R[i]
    if tmp[1] <= v[0]:
        ans.append(v)
        tmp = v

print(len(ans))

Measured memory_bytes: 22104
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		LL a, b, c; cin >> a >> b >> c;
		LL t = c - a - b;
		if (t < 0) { cout << "No" << endl; return; }
		if (t * t > 4 * a * b) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int main (){
    int n;
    cin >> n;
    long long sum =0;
    vector <long long>L(n);
    for (int i=0;i<n;i++){
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    
    for(int i=0;i<n;i++){
        int s=i;
        for(int k=i+1;k<n;k++){
            while(s<n&&L[s]<L[i]+L[k]){
                s++;
            }
                sum+=s-(k+1);
            }
        }

    cout << sum << endl;


   return 0;
}


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

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

	map<int, int>a;
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		a[tmp]++;
		a[tmp + 1]++;
		a[tmp - 1]++;
	}

	int maxi = 0;
	for (auto& x : a) {
		maxi = max(maxi, x.second);
	}
	cout << maxi << endl;

	return 0;
}

Measured memory_bytes: 4736
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B&lang=jp
#??????????????????????????????
#?????§??¬?´???°???????????????????????????????????¨????????¨?¨????????????????
def gcd(x,y):
    
    if y > x:
        x, y = y, x

    while not y == 0:
        x, y = y, x % y
    
    return x
def main():
    target = [int(a) for a in input().split()]
    print(gcd(target[0], target[1]))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 7716
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int res=1;
	for(int i=0;i<n;i++){
		if(a[i]==res){res++;}
	}
	if(res==1) cout<<-1<<endl;
	else cout<<n-res+1<<endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p, m, y;
string s, t;
ld w;
ll a,b;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s; 
	string t1 = s.substr(0,3);
	string t2 = s.substr(1,3);
	
	for(ll i=0;i<=9;i++) {
		string I ;
		I += ('0' + i) ;I+= ('0' + i); I += ('0' + i);
		//cout<<I;newl;
		if(t1 == I || t2 == I) {
			cout<<"Yes\n";
			return;
		}
	}
	cout<<"No\n";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

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

int cnt_s[100005], cnt_t[100005];
string S, T;

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

    for(int i=0;i<S.size();i++){
        cnt_s[i+1] = cnt_s[i];
        if(S[i] == 'B') cnt_s[i+1]++;
    }
    for(int i=0;i<T.size();i++){
        cnt_t[i+1] = cnt_t[i];
        if(T[i] == 'B') cnt_t[i+1]++;
    }

    for(int i=0;i<q;i++){
        int a, b, c, d; cin >> a >> b >> c >> d;
        int len1 = b - a + 1 + cnt_s[b] - cnt_s[a-1];
        int len2 = d - c + 1 + cnt_t[d] - cnt_t[c-1];
        if(len1 % 3 == len2 % 3) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1;
  cin >> s2;

  ll ans = 1;
  int i = 0;
  int state = 0;
  if (s1[i] == s2[i]) {
    ans *= 3;
    i += 1;
    state = 1;
  } else {
    ans *= 6;
    i += 2;
    state = 2;
  }
  for ( ; i < n; ) {
    if (state == 1) {
      if (s1[i] == s2[i]) {
        ans = ans * 2 % mod;
        i += 1;
        state = 1;
      } else {
        ans = ans * 2 % mod;
        i += 2;
        state = 2;
      }
    } else {
      if (s1[i] == s2[i]) {
        ans = ans * 1 % mod;
        i += 1;
        state = 1;
      } else {
        ans = ans * 3 % mod;
        i += 2;
        state = 2;
      }
    }
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 888
r, g, b, n = map(int, input().split())
l = [r, g, b]
l.sort(reverse=True)
r, g, b = l

mr = n // r
mg = n // g
mb = n // b
cnt = 0
com = []
for ir in range(mr + 1):
    cr = ir * r
    for ig in range(mg + 1):
        cg = ig * g
        if cr + cg > n:
            break
        if (n - (cr + cg)) % b == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
using System;

namespace AOJ.Volume2
{
    public class PerfectScorer
    {
        public static int Main()
        {
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var ans = int.Parse(input);
                for(int i = 1; i <= 9; i++)
                {
                    ans += int.Parse(Console.ReadLine());
                }

                Console.WriteLine(ans);
            }
            return 0;
        }
    }
}

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

int x[10000];

int main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    int count = 0;
    for(int i = 0; i < n; i++){
        count += (min(abs(x[i]), abs(x[i] - k))) * 2;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> x(5);
    rep(i,0,5) cin >> x[i];
    rep(i,0,5){
        if(x[i]==0){
            cout << i+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3604
use std::cmp::max;
use std::io::Read;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: i64 = itr.next().unwrap().parse().unwrap();
    let a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut dp: Vec<Vec<i64>> = vec![vec![-1; 2]; 44];

    dp[0][1] = 0;
    for i in 0..41 {
        let now: i64 = k >> (40 - i) & 1;
        let mut cnt: i64 = 0;
        let power: i64 = 1i64 << (40 - i);
        for j in a.iter() {
            cnt += j >> (40 - i) & 1;
        }

        if dp[i][0] != -1 {
            dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + cnt * power);
            dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + (n as i64 - cnt) * power);
        }

        if dp[i][1] != -1 {
            if now == 0 {
                dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + cnt * power);
            } else {
                dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + cnt * power);
                dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + (n as i64 - cnt) * power);
            }
        }
    }
    println!("{}", max(dp[41][0], dp[41][1]));
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define            ll              long long
#define            pb              push_back
#define            mp              make_pair
#define            loop(i,a,n)     for(int i=a;i<=n;++i)
#define            clr(x)          memset(x,0,sizeof x)
#define            min3(a,b,c)     min(a,min(b,c))
#define            max3(a,b,c)     max(a,max(b,c))
#define            min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define            max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define            fast            ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define            pii             pair<int,int>
#define            pll             pair<ll,ll>
#define            pli             pair<ll,int>
#define            pil             pair<int,ll>
#define            FF              first
#define            SS              second
#define            PI              acos(-1.0)
#define            bug             cout<<"ok"<<endl;

using namespace std;
using namespace __gnu_pbds;

typedef tree<int , null_type,less<int>,
       rb_tree_tag, tree_order_statistics_node_update> anik;

const int MOD = 1e9 + 7;
const ll MX= 1e9;
const ll INF = 1e9;

main()
{
   int n,x;
    cin>>n>>x;
    int a[n+9];

    loop(i,1,n)
    cin>>a[i];
    ll ans=0;
    a[0]=0;
    a[n+1]=0;
    loop(i,1,n)
    {
        if(a[i]+a[i+1]>x)
        {
            int kor=a[i]+a[i+1]-x;
            if(kor<=a[i+1])
            {
                a[i+1]-=kor;
                ans+=kor;
            }
            else
            {
                ans+=kor;
                a[i+1]=0;
                kor-=a[i+1];
                a[i]-=kor;
            }
        }
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3956
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
inline int read(){
	int f=1,ans=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return f*ans;
}
priority_queue<int> que;
const int MAXN=2001;
int vis[MAXN],n,a[MAXN],v[MAXN][MAXN];
int gcd(int a,int b){
	if(!b) return a;
	return gcd(b,a%b);
}
struct node{
	int u,v,nex;
}x[MAXN<<1];
int cnt,d[MAXN],head[MAXN];
void add(int u,int v){
	x[cnt].u=u,x[cnt].v=v,x[cnt].nex=head[u],head[u]=cnt++;
	d[v]++;
}
void dfs(int u){
	vis[u]=1;
	for(int i=1;i<=n;i++){
		if(!v[u][i]) continue;
		if(vis[i]) continue;
		add(u,i);dfs(i);
	}return;
}
int main(){
	memset(head,-1,sizeof(head));
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++) if(gcd(a[i],a[j])!=1) v[i][j]=v[j][i]=1;
	for(int i=1;i<=n;i++) if(!vis[i]) dfs(i);
	for(int i=1;i<=n;i++) if(!d[i]) que.push(i);
	while(!que.empty()){
		int xx=que.top();que.pop();
		printf("%d ",a[xx]);
		for(int i=head[xx];i!=-1;i=x[i].nex) que.push(x[i].v);
	}
}


Measured memory_bytes: 16128
var
	n,A,i,j,k,x:Longint;
	dp:array[0..9999]of int64;
begin
	read(n,A);
	dp[n*A]:=1;
	for k:=1 to n do begin
		read(x);
		for j:=0 to 4999 do begin
			dp[5000-i+j]:=dp[i+j];
			if(j-x+A>=0)and(j-x+A<5000)then inc(dp[5000-i+j],dp[i+j-x+A]);
		end;
		i:=5000-i;
	end;
	writeln(dp[i+n*A]-1);
end.


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a>=b*2-1)
		System.out.println("YES");
		else System.out.println("NO");
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>
using namespace std;

namespace {

}

int main()
{
	long long N = 0;
	cin >> N;
	
	// vector<long long> A(N, 0);

	int countEvn = 0;
	int countOdd = 0;

	for (int i = 0; i < N; ++i){
		int curValue = 0;
		cin >> curValue;
		if (curValue % 2 == 0) {
			++countEvn;
		}
		else {
			++countOdd;
		}
	}

	int rest = 0;
	if (countOdd % 2 != 0){
		// 奇数個なら奇数は残る。
		++rest; // 奇数個
	}
	else{
		++countEvn; // 偶数が1つ増える。 
	}

	if (countEvn > 0){
		// 1個残る。
		++rest;
	}

	if (rest == 1){
		cout << "YES" << endl;
		return 0;
	}


	cout << "NO" << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[MAX];
int main(){
	int d, n, m, q, t;
	while(1){
		scanf("%d", &d);
		if(!d)break;
		scanf("%d%d", &n, &m);
		rrep(i,n-1)scanf("%d", &a[i]);a[n] = d;
		sort(a+1, a+n);
		
		ll ans = 0, t1, t2;
		for(int i = 0;i < m;i++){
			scanf("%d", &q);
			t1 = t2 = INF;
			t = lower_bound(a, a+n+1, q)-a;
			t1 = a[t]-q;
			if(t)t2 = q-a[t-1];
			ans += min(t1, t2);
		}
		
		printf("%lld\n", ans);
	}
	return 0;
}

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


int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;

	stack<char> st;
	string final;
	for(int i=0;i<n;i++){
		if(st.empty()) st.push(s[i]);
		else if(st.top() == '(' && s[i] == ')') st.pop();
		else st.push(s[i]);
	}
	int l = 0;
	int r = 0;
	while(!st.empty()){
		if(st.top() == '(') r++;
		else l++;
		st.pop();
	}

	for(int i=0;i<l;i++) final+='(';
	final+=s;
	for(int i=0;i<r;i++) final+=')';
	cout<<final;

}

Measured memory_bytes: 256
//입출력
#include <iostream>
#include <stdio.h>
//머리쓰는 아이들
#include <algorithm>
#include <cmath>
//STL이거나 문자열
#include <cstring>
#include <string>
#include <stack>
#include <queue>
//사실 필요없는 것들
#include <stdlib.h>
#include <sstream>
#include <time.h>

//std::ios_base::sync_with_stdio(false); 필살기!
using namespace std;
#define mx  5500005
#define mx2 1000

typedef stack<int>      SI;
typedef stack<char>     SC;
typedef stack<double>   SD;
typedef queue<char>     QC;
typedef queue<int>      QI;
typedef queue<double>   QD;
typedef vector<int>     VI;
typedef vector<char>    VC;
typedef vector<double>  VD;


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=0,b=0;
  for(int i=0;i<(int)s.size();++i){
    if(s.at(i)=='0') a++;
    else b++;
  }
  cout << min(a,b)*2 << endl;
}

Measured memory_bytes: 512
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        x: usize,
        y: usize,
        z: usize,
        n: usize,
        m: usize,
        src: usize1,
        dst: usize1,
        a: [(usize1, usize1); n],
        b: [(usize1, usize1); m],
    }
    let mut g = vec![vec![]; n + m + x + y + z];
    let dst = n + dst;
    for (i, &(a, b)) in a.iter().enumerate() {
        let a = a + n + m;
        let b = b + n + m + x;
        g[i].push((a, 1));
        g[i].push((b, 1));
        g[a].push((i, 0));
        g[b].push((i, 0));
    }
    for (j, &(c, d)) in b.iter().enumerate() {
        let j = n + j;
        let c = c + n + m + x;
        let d = d + n + m + x + y;
        g[j].push((c, 1));
        g[j].push((d, 1));
        g[c].push((j, 0));
        g[d].push((j, 0));
    }
    let mut dp = vec![std::u32::MAX; n + m + x + y + z];
    dp[src] = 0;
    let mut deq = std::collections::VecDeque::new();
    deq.push_back(src);
    while let Some(v) = deq.pop_front() {
        let d = dp[v];
        for &(u, c) in g[v].iter() {
            if dp[u] > d + c {
                dp[u] = d + c;
                if c == 0 {
                    deq.push_front(u);
                } else {
                    deq.push_back(u);
                }
            }
        }
    }
    let ans = dp[dst];
    if ans == std::u32::MAX {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

fn main() {
    run();
}



Measured memory_bytes: 54144
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

int leapYear(int year)
{
  if(year%4==0 && year%100!=0)
    return 1;
  else if(year%400==0)
    return 1;
  else
     return 0;  
}
queue<int> q;
int main(void)
{
  int a,b;
  int i=-1;

  while(1){
    bool ans=true;
    cin>>a>>b;
    if(a==0 && b==0)break;
    if(i>=0)
      cout<<endl;
    for(i=a;i<=b;i++)
      if(leapYear(i)){
	cout<<i<<endl;
	ans=false;
      }
    if(ans)
      cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(int i=a; i<n; i++)
#define loop(i,a,n)	for(int i=a; i>=n; i--)

int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int a;
	cin>>a;
	long long int b=a/500,e=a-(b*500),d=e/5,ct=0;
	ct+=(b*1000);
	ct+=(d*5);
	cout<<ct;
	
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,v[20],p=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&v[i]);
    }
    for(int k=2;k<=(n-1);k++){
        if(v[k-1]<v[k] && v[k]<v[k+1]||v[k-1]>v[k] && v[k]>v[k+1]){
            p+=1;
        }
    }
    printf("%d",p);

    return 0;
}

Measured memory_bytes: 128
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

#にぶたんサーチ
def search(arr, num):
    l = 0
    r = len(arr) - 1
    while r - l > 1:
        c = (r + l) // 2
        if arr[c] > num:
            r = c
        elif arr[c] < num:
            l = c
        else:
            r = c
            l = c
    if arr[l] == num:
        return l
    elif arr[r] == num:
        return r
    else:
        return -1

n = INT()
a = LIST()

l = [i + 1 + a[i] for i in range(n)]
r = [i + 1 - a[i] for i in range(n)]
b = Counter(r)
c = list(set(r))
c.sort()
ans = 0
for i in l:
    if search(c, i) < 0:
        continue
    ans += b[i]

print(ans)


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

int main(){
  string s;
  string t;
  cin >> s >> t;
  int sum = 0;
  for (int i = 0; i < s.length(); i++){
    if (s[i] == t[i]){
      sum += 1;
    }
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> //可変長配列
#include <queue> //キュー
#include <unordered_map> //ハッシュ連想配列
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int n,a; cin>>n>>a;
    cout<<((n%500-a)<=0?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back

int main(){

//	freopen("in.txt","r",stdin);

	int n, a, b;
	cin >>n >>a >>b;
	if ((abs (a - b) -1)&1)puts("Alice");
	else puts("Borys");

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

template<typename T>
T in(){
	T val;
	cin >> val;
	return val;
}

template<typename T>
vector<T> inv(ll num) {
	vector<T> val(num);
	rep(i,num) cin >> val[i];
	return val;
}

//----------------------------------------------------------------------
void solve() {

	ll n;
	cin >> n;
	set<ll> SET;
	rep(i,n) {
		ll tmp;
		cin >> tmp;
		SET.insert(tmp);
	}

	if (SET.size() == n) {
		cout << "YES";
	} else {
		cout << "NO";
	}

}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


Measured memory_bytes: 12976
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;
    vector<int> cnt(n+3);
    rep(i,m) {
        int l,r;
        cin >> l >> r;
        ++cnt[l];
        --cnt[r+1];
    }
    int ans=0;
    rep(i,n) {
        cnt[i+1]+=cnt[i];
        if (cnt[i+1]==m) ++ans;
    }
    cout << ans << endl;


    return 0;
}


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

using namespace std;

void rec(int N)
{
  int sum[26] = {};
  char C[100];
  for(int i = 0; i < N; i++) {
    cin >> C[i];
    C[i] -= 'A';
  }

  for(int i = 0; i < N; i++) {
    int odd = sum[C[i]]++;
    for(int j = 0; j < 26; j++) {
      bool end = true;
      for(int k = 0; k < 26; k++) {
        if(j == k) continue;
        end &= sum[j] > sum[k] + N - i - 1;
      }
      if(end) {
        cout << (char) (j + 'A') << " " << i + 1 << endl;
        return;
      }
    }
  }
  cout << "TIE" << endl;
}

int main()
{
  int N;
  while(cin >> N, N) rec(N);
}

Measured memory_bytes: 3052
unittest
{
	assert( [ "3", "1 2 3", "5 2 2" ].parse.expand.solve == "Yes" );
	assert( [ "5", "3 1 4 1 5", "2 7 1 8 2" ].parse.expand.solve == "No" );
	assert( [ "5", "2 7 1 8 2", "3 1 4 1 5" ].parse.expand.solve == "No" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	return tuple( as, bs );
}

auto solve( long[] as, long[] bs )
{
	auto ac = 0L;
	auto bc = 0L;
	foreach( a, b; lockstep( as, bs ) )
	{
		if( a == b ) continue;
		if( a < b )
		{
			auto r = ( b - a ) % 2;
			ac += r + ( b - a ) / 2;
			bc += r;
			a  += r + ( b - a );
			b  += r;
		}
		else
		{
			bc += a - b;
			b  += a - b;
		}
	}
	return ( bc <= ac ) ? "Yes" : "No";
}


Measured memory_bytes: 3196
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

vector <vi> dp(26,vi(100005));
int n;

int fun(int l,int r){
	if (r<l)  return  r+(n-l+1); 
	else  return  (r-l+1); 
}

inline void solve(){ 
    string  s, t; 
    cin >> s >> t ; 
    n = sz(s);
    for (int i=0;i<n;i++) {
    	dp[s[i]-'a'][i+1] = i+1 ; 
    }
    for (int i=0;i<26;i++){ 
    	for (int j=n-1;j>=0;j--) 
    		if ( !dp[i][j] )  dp[i][j] = dp[i][j+1]; 
    	dp[i][n+1]= dp[i][0]; 
    	for (int j=n;j>=0;j--) 
    		if ( !dp[i][j] ) dp[i][j] = dp[i][j+1]; 
    } 
    int ans=0; 
    for (int  i=0, idx= 1 ; i < sz(t) ; i++ ){ 
    	int  p = dp[t[i]-'a'][idx] ; 
    	ans += fun(idx,p); 
    	idx = p+1; 
    	if (p == 0){
    		ans = -1;
    		break;
    	}
    } 
    cout << ans << endl; 
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}

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

int main(){
  vector<vector<int>> A(3, vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for(int i=0; i<N; i++){
    cin >> b[i];
  }
  vector<vector<bool>> X(3, vector<bool>(3,false));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<N; k++){
        if (b[k]==A[i][j]) X[i][j]=true; 
      }
    }
  }
  
  for(int i=0; i<3; i++){
    
    int h=0;
    int w=0;
    for(int j=0; j<3; j++){
      if (X[i][j]==true) w++;
      if (X[j][i]==true) h++;
    }
    if (w==3 || h==3){
      cout << "Yes" << endl;
      return 0;
    }
    
  }
  
  int m=0,n=0;
  for(int i=0; i<3; i++){
    if (X[i][i]==true) m++;
    if (X[i][2-i]==true) n++;
  }
  if (m==3 || n==3){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

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


void main(){
	int n,d;
	scanf("%d%d",&n,&d);
	int point[n+1][d+1];
	
	for (int i=1;i<=n ; i++){
		for (int j=1; j<=d; j++){
			scanf("%d",&point[i][j]);
		}
	}
	
	int count=0;
	for (int i=1; i<=n-1; i++){
		for (int j=i+1; j<=n; j++){
			
			int sum=0;
			for (int k=1; k<=d; k++){
				sum = sum+ (point[i][k] - point[j][k])*(point[i][k] - point[j][k]);
			}
			double kyori = sqrt(sum);
			if (ceil(kyori) == floor(kyori)){
				count++;
			}
		}
	}
	
	printf("%d\n",count);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
const int N=10000005,M=5005;
const int MOD=1000000007;
int n,m;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long fac[N],inv[N];
void init(int n=10000000)
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	return;
}
long long C(int n,int m)
{
	if(m>n) return 0;
	else return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main()
{
	scanf("%d%d",&n,&m);
	init();
	long long ans=0;
	for(int i=1;i<=m+1;i++)
		for(int j=0;j<i;j++)
		{
			int a=i-1-j,b=n-m,c=max(m-i,0);
			long long res=C(i-1,j);
			res=(res*fac[a])%MOD;
			res=(res*fac[a+b-1]%MOD*inv[a-1]%MOD)%MOD;
			res=(res*fac[a+b+c]%MOD*inv[a+b]%MOD)%MOD;
			if(j&1) ans=(ans-res+MOD)%MOD;
			else ans=(ans+res)%MOD;
		}
	printf("%lld",ans);
	return 0;
}

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

public class Main{
	public static int count = 0;
	public static int depthmax = 0;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] fib = new int[n+1];
		fib[0] = 1;
		fib[1] = 1;
		for (int i = 2; i < (n+1) ; i++ ) {
			fib[i] = fib[i-2] + fib[i-1]; 
		}
		System.out.println(fib[n]);
	}


	public static StringBuilder createStringBuilder(int[] node,int[] parent,int[] sibling,int[] degree,int[] depth,int[] height){

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i<node.length ; i++ ) {
			sb.append("node ").append(node[i]).append(": ");
			sb.append("parent = ").append(parent[i]).append(", ");
			sb.append("sibling = ").append(sibling[i]).append(", ");
			sb.append("degree = ").append(degree[i]).append(", ");
			sb.append("depth = ").append(depth[i]).append(", ");
			sb.append("height = ").append(height[i]).append(", ");
			sb.append(root(parent[i],degree[i])).append("\n");
		}


		return sb;

	}


	public static void heightset(int[] depth,int[] height,int maxdepth){
		for (int i = 0; i<depth.length ; i++ ) {
			height[i] = maxdepth - depth[i];
		}
	}

	public static void depthset(int[] node,int[] depth,int[] parent,int[][] childnode,int child){
		for (int i = 0; i<node.length ; i++ ) {
			if (node[i] == child) {
				depth[i] = (depth[parent[i]]+1);
				if (childnode[i][0] >= 0) {
					depthset(node,depth,parent,childnode,childnode[i][0]);
				}
				if (childnode[i][1] >= 0) {
					depthset(node,depth,parent,childnode,childnode[i][1]);
				}
			}
			depthmax = Math.max(depthmax,depth[i]);
		}


	}


	public static void parentdepthset(int[] node,int[] parent,int[] depth,int[][] childnode,int parentnode,int child){
		for (int i = 0; i<node.length ; i++ ) {
			if (node[i] == child) {
				parent[i] = parentnode;
				depth[i] = (depth[parentnode]+1);
				if (childnode[i].length > 0) {
					for (int j = 0; j<childnode[i].length ; j++ ) {
						parentdepthset(node,parent,depth,childnode,node[i],childnode[i][j]);
					}
				}
			}

		}


	}
	public static String root(int parent,int degree){
		if (parent == -1) {
			return "root";
		}else if (degree == 0) {
			return "leaf";
		}else{
			return "internal node";
		}
	}


	public static StringBuilder toStringBuilder(int[] a){
		StringBuilder sb = new StringBuilder();
		sb.append(a[0]);
		for (int i = 1; i<a.length ; i++ ) {
			sb.append(" ").append(a[i]);
		}

		return sb;
	}

	public static void countingSort(int[] a,int[] b,int max){
		int[] c = new int[max+1];

		for (int j = 0; j<a.length ; j++ ) {
			c[a[j]]++;
		}

		for (int i = 1; i<=max ; i++ ) {
			c[i] = c[i] + c[i-1];
		}

		for (int j = a.length-1; j>=0 ; j-- ) {
			b[c[a[j]]-1] = a[j];
			c[a[j]]--;
		}


	}
}

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

int main(){
    string s;
    cin >> s;

    sort(s.begin(), s.end());
    if (s[0] == s[1]){
        if (s[1] == s[2]){
            cout << "No" << endl;
            return 0;
        }
        else if (s[2] == s[3]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256