akhauriyash/Code-Regression huggingface dataset:
/*6_2 hightierra*/
#include <stdio.h>
#include <string.h>
#define SIZE 101

int main(void){
    char sentence[SIZE];
    int wordcount;

    // 標準入力で文字列を取得
    scanf("%s",sentence);

    // 文字数の取得
    wordcount = strlen(sentence);
    
    printf("%c%d%c\n",sentence[0],wordcount-2,sentence[wordcount-1]);
    
    return 0;
}

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

using namespace std;

int main(void)
{
    while(1){
        int N, M, P; cin >> N >> M >> P;
        if(N == 0) break;
        int sum = 0;
        int win;
        for(int i = 1; i <= N; i++){
            int input;
            cin >> input;
            sum += input;
            if(i == M) win = input;
            
        }
        if(win == 0){
            cout << 0 << endl;
            continue;
        }
        sum = sum*(100 - P);

        cout << sum/win << endl;
    }
    return 0;

}    

Measured memory_bytes: 3024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    int N = Integer.parseInt(br.readLine());
	    String[] line = br.readLine().split(" ");
	    int[] data = new int[line.length];

	    for (int i = 0; i < line.length; i++) {
	    	data[i] = Integer.parseInt(line[i]);
	    }

	    StringBuilder sb = new StringBuilder();
	    sb.append(disp(data)).append("\n");

	    for (int i = 1; i <= N - 1; i++) {
	    	int v = data[i];
	    	int j = i - 1;
	    	while (j >= 0 && data[j] > v) {
	    		data[j + 1] = data[j];
	    		j--;
	    	}
	    	data[j + 1] = v;
		    sb.append(disp(data)).append("\n");
	    }
	    System.out.print(sb.toString());
	}

	public static String disp(int[] data) {
	    StringBuilder sb = new StringBuilder();
    	for (int k = 0; k < data.length; k++) {
	    	sb.append(data[k]);
    		if (k != data.length - 1) {
    			sb.append(" ");
    		}
    	}
	    return sb.toString();
	}
}

Measured memory_bytes: 26376
n = int(input())
sl = [input() for _ in range(n)]

c = 0
ca = 0
cb = 0
cab = 0

for s in sl:
  c += s.count('AB')
  if s[-1] == 'A':
    ca += 1
  if s[0] == 'B':
    cb += 1
  if s[-1] == 'A' and s[0] == 'B':
    cab += 1

t = min(ca, cb)
if ca == cb and cb == cab and ca > 0:
  t -= 1
print(c + t)


Measured memory_bytes: 44376
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	cin >> N;
	double res = 0;
	rep(i, 0, N) {
		double a; cin >> a;
		res += 1.0 / a;
	}
	cout << 1.0 / res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from collections import deque

def main(): 
    N = int(input())
    SP=[]
    for i in range(N):
        key,value=input().split()
        SP.append([key, int(value), i+1])
    SP.sort(key=lambda x: (x[0],-x[1]))
    for i in range(N):
        print(SP[i][2])


if __name__ == "__main__":
    main()
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, a, b, c[3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> a >> b;
  FOR(i, 0, n){
    int p;
    cin >> p;
    if(p <= a){
      c[0]++;
    }else if(p <= b){
      c[1]++;
    }else{
      c[2]++;
    }
  }
  cout << min(c[0], min(c[1], c[2])) << endl;
}

Measured memory_bytes: 256
import collections
n = int(input())
S = [input() for _ in range(n)]
abc = list("abcdefghijklmnopqrstuvwxyz")
dic = dict(zip(abc,[10**9]*26))
for i in range(n):
    tmp = collections.Counter(list(S[i]))
    for j in abc:
        if dic[j] > tmp[j]:
            dic[j] = tmp[j]
ans = []
for k in abc:
    for l in range(dic[k]):
        ans.append(k)
print(*ans,sep="")

Measured memory_bytes: 3316
A,B,C,X,Y=map(int,input().split())
result=0
if A+B>=C*2:
  min_pizza=min(X,Y)
  min_pizza//2*2
  X-=min_pizza
  Y-=min_pizza
  result+=C*2*min_pizza
for i,j in zip((A,B),(X,Y)):
  if i>=C*2:
    result+=C*2*(max(0,j-2))
  else:
    result+=i*(max(0,j-2))
X-=max(0,X-2)
Y-=max(0,Y-2)
cnd=[C*2*2]
for i in range(3):
  for j in range(3):
    if X<=i and Y<=j:
      cnd.append(A*i+B*j)
result+=min(cnd)
print(result)

Measured memory_bytes: 9132
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    abc = list(map(str, sys.stdin.readline().split()))
    abc.sort(reverse=True)
    print(int(abc[0]+abc[1])+int(abc[2]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
/*
  AOJ 0576
  Title:
  @kankichi573
*/
#include <stdio.h>
// #include <stdlib.h>
// #include <string.h>
// #include <math.h>
// #include <float.h>
// #include <stdlib.h>
int L,A,B,C,D;
int max(int a,int b)
{
        return (a>b)?a:b;

}
main()
{
        int i,j,ret;

        scanf("%d",&L);
        scanf("%d",&A);
        scanf("%d",&B);
        scanf("%d",&C);
        scanf("%d",&D);

        ret=L-max(A/C+((A%C)?1:0),B/D+((B%D)?1:0));
        printf("%d\n",ret);
  return(0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
 char  x;
  for (int i=0 ; i< N ; i++){
    cin >> x ;
    if ( x == 'Y' ){
      cout << "Four" << endl;
      return 0 ;
    }
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
string a;
long long ans;
int main()
{
     cin>>a;
	 for(int i=0;i<6;i++)
	 {
		 if(a[i]=='1')ans++;
	 }
	 cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>


int main(){
    long N;
    std::cin >> N;
    std::string S;
    std::cin >> S;
    long count1=0,count2=0,count3=0;
    for(long i=0; i<N; i++){
        if(S[i]=='R'){
            count1++;
        }else{
            count2++;
        }
    }

    long left=0,right=N-1;
    while(left<right){
        if(S[left]=='W' && S[right]=='R'){
            count3++;
            right-=1;
            left++;
        }else if(S[left]=='W' && S[right]!='R'){
            right-=1;
        }else if(S[left]!='W' && S[right]=='R'){
            left++;
        }else{
            right-=1;
            left++;
        }
    }
    std::cout << std::min(std::min(count1,count2),count3) << std::endl;
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <cfenv>
using namespace std;
typedef long long i64;
const int MAXN = 400 + 5;
const int MAXM = 1e5 + 10;

i64 answer;

int N, M;
int A[MAXM], B[MAXM];

bool eatenWith[MAXN][MAXN];
bool certainDeath[MAXN];

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

	cin >> N >> M ;
	for(int i = 1; i <= M; i++)
		cin >> A[i] >> B[i];
	for(int k = 1; k <= N; k++)
	{
		eatenWith[k][k] = true;
		for(int i = M; i >= 1; i--)
		{
			const bool & a = eatenWith[k][A[i]];
			const bool & b = eatenWith[k][B[i]];

			if(a && b)
				certainDeath[k] = true;
			else if(a)
				eatenWith[k][B[i]] = true;
			else if(b)
				eatenWith[k][A[i]] = true;
		}
	}

	for(int i = 1; i <= N; i++)
	{
		if(certainDeath[i])
			continue;
		for(int j = i + 1; j <= N; j++)
		{
			if(certainDeath[j])
				continue;

			bool isSelectable = true;
			for(int k = 1; k <= N; k++)
				if(eatenWith[i][k] && eatenWith[j][k])
				{
					isSelectable = false;
					break;
				}

			answer += isSelectable;
//			answer += (!eatenWith[i][j]);
		}
	}

	cout << answer << endl ;
	return 0;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;
const int MAX = 1e5 + 5;

int main(void){

	int N; cin >> N;
	
	map<int, int> mp;
	REP(i,N){
		int A; cin >> A;
		mp[A]++;
	}

	int ans = 0;
	for(auto a: mp){
		int idx = a.first;
		int cnt = a.second;
		
		if(idx < cnt) ans += cnt - idx;
		else if(cnt < idx) ans += cnt;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 4736
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

string s, t;

int n;

void solve() {                   
	scanf("%d", &n);
	cin >> s >> t;

	for (int i = 0; i < n; ++i) {
		if (s.substr(i, s.size() - i) == t.substr(0, s.size() - i)) {
			printf("%d\n", n + i);
			return;
		}
	}

    printf("%d\n", n * 2);               
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)
#define INF 2000

int main() {
    int D, G; cin >> D >> G;
    vector<int> p(D), c(D);
    rep(i, D) cin >> p[i] >> c[i];
    int ans = INF, tmp, cnt;
    rep(i, 1<<D) {
        cnt = 0; tmp = 0;
        rep(j, D) {
            if (i&(1<<j)) {
                cnt += p[j];
                tmp += p[j]*(j+1)*100 + c[j];
            }
        }
        rep(j, D) {
            if (tmp >= G) break;
            if (i&(1<<(D-j-1))) continue;
            if (G-tmp >= (p[D-j-1]-1)*(D-j)*100) {
                cnt += p[D-j-1]-1;
                tmp += (p[D-j-1]-1)*(D-j)*100;
            }
            else {
                int div = ((G-tmp)%((D-j)*100) ? (G-tmp)/((D-j)*100)+1 : (G-tmp)/((D-j)*100));
                cnt += div;
                tmp += div * (D-j)*100;
            }
        }
        if (tmp >= G) chmin(ans, cnt);
    }
    cout << ans << endl;
}



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

#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
#define _cos(xxxx) cos(xxxx*acos(-1)/180)
#define _sin(xxxx) sin(xxxx*acos(-1)/180)
#define _tan(xxxx) tan(xxxx*acos(-1)/180)
#define PE cout<<fixed

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;

const ld pi=acos(-1);

ld a,b,h,m,anga,angb,ang,res;

int main(){
    IO;
    cin>>a>>b>>h>>m;
    anga=(h*60+m)*0.5f;
    angb=m*6.0f;
    ang=abs(anga-angb);
    if (ang>180.0) {
        ang=360.0-ang;
    }
    res=sqrt(a*a+b*b-2*a*b*_cos(ang));
    PE;
    cout<<sp(12)<<res<<'\n';
    //cout<<sp(12)<<anga<<'\n';
    //cout<<sp(12)<<angb<<'\n';
    //cout<<sp(12)<<ang<<'\n';
    //cout<<sp(12)<<_cos(ang)<<'\n';
}

Measured memory_bytes: 4176
N,M=map(int,input().split())
TOT=[0]*M
for i in range(N):
  List=[int(i) for i in input().split()]
  List.pop(0)
  List_N=[]
  for j in range (M):    
    if j+1 in List:
      List_N.append(1)
    else:
      List_N.append(0)
  TOTAL=[]
  for k in range(M):
    TOTAL.append(TOT[k]+List_N[k])
  TOT=TOTAL
print(TOT.count(N))

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  int n,x,y,h,w,size,total;
  int sizelist[6]={60,80,100,120,140,160},weightlist[6]={2,5,10,15,20,25},pricelist[6]={600,800,1000,1200,1400,1600};

  while(1){
    scanf("%d",&n);
    if(n==0) break;

    total=0;
    while(n-->0){
      scanf("%d %d %d %d",&x,&y,&h,&w);
      size=x+y+h;
      for(int i=0;i<6;i++){
        if(sizelist[i]>=size && weightlist[i]>=w){ total+=pricelist[i]; break; }
      }
    }
    printf("%d\n",total);

  }
  return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n+1], b[n];
  for(int i= 0; i<= n ;++i) cin >> a[i];
  for(int i= 0; i< n ;++i) cin >> b[i];
  long num = 0;
  int rem_ai = 0;
  int rem_b = 0;
  for(int i = 0; i < n; ++i){
    if(rem_b <= a[i]){
      num += rem_b;
      rem_ai = a[i] - rem_b;
      rem_b = 0;
    }else{
      num += a[i]; 
      rem_ai = 0;
      rem_b = 0;
    }
    if(b[i] <= rem_ai){
      num += b[i];
      rem_ai= 0;
      rem_b = 0;
    }else{
      num += rem_ai;
      rem_b = b[i] - rem_ai;
      rem_ai= 0;
    }
    //printf("num %d\n", num);
    //printf("rem_b %d\n", rem_b);
  }
  if(rem_b <= a[n]){
    num += rem_b;
  }else{
    num += a[n];
  }
 
  printf("%ld\n", num);
  
  return 0;
}


Measured memory_bytes: 1024
n,Y=map(int,input().split())
for x in range(n+1):
    for y in range(n+1-x):
        z=n-x-y
        if z>=0:
            if (10000*x + 5000*y + 1000*z) == Y:
                print(x,y,z)
                exit(0)
print(-1,-1,-1)


Measured memory_bytes: 3060
n,m=map(int,input().split())
ltmp=1
rtmp=n
for i in range(m):
  l,r=map(int,input().split())
  ltmp=max(l,ltmp)
  rtmp=min(r,rtmp)
if ltmp>rtmp:
  print(0)
else:
  print(rtmp-ltmp+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;
//i>jで考えると絶対値が外れてiのみの辺とjのみの辺に変形でき楽
//ここで厄介なのがi>jという制約、しかし、添え字iで小さい順に処理をすることで大丈夫になる

//まとめ　i-A_i=j-A_jとなる(i,j)i>j
//j+A_jの値を残しておく
//i=0~n-1
//i-A_i=j+A_jとなるjの個数をansに加算する
//i+A_iの値を残しておく
//j+A_j=Xとなるjの個数が高速に求められればよい
//map dict
int main()
{
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    map<long long, long long> cnt;
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += cnt[i - a.at(i)];
        cnt[i + a[i]]++;
    }

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

Measured memory_bytes: 27440
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  if(sz(s)==3) {
    reverse(rng(s));
  }
  cout << s << endl;
  return 0;
}

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

using namespace std;

long long solve(long long n, long long s){
	long long res = -1;
	long long b = 2;
	for(;b*b <= n;b++){
		long long sum = 0;
		for(long long t=n;t;t/=b) sum += t%b;
		if(sum == s) return b;
	}
	for(long long a = b;a > 0;a--){
		long long c = s - a;
		if(c < 0) continue;
		if(n - c < 0) continue;
		if((n - c) % a != 0) continue;
		long long x = (n - c) / a;
		if(a < x && c < x) return x;
	}
	if(n == s) return n + 1;
	return -1;
}

int main(){
	long long n, s;
	while(cin >> n >> s){
		cout << solve(n, s) << endl;
	}
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t1,t2;
  ll a1,a2;
  ll b1,b2;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;

  // sabun
  ll xx = (t1*a1 + t2*a2);
  ll yy = (t1*b1 + t2*b2);
  if(xx == yy){
    cout << "infinity" << endl;
    return 0;
  }

  if(xx < yy){
    swap(a1,b1);
    swap(a2,b2);
  }

  if(a1 > b1 && a2 > b2){
    cout << 0 << endl;
    return 0;
  }

  if(a1 < b1 && a2 > b2){
    ll diff = abs(b1-a1)*t1;
    ll ans = diff/(abs(xx-yy));
    ans*=2;
    if(diff % (abs(xx-yy)) > 0) ans++;
    cout << ans << endl;
  }

  if(a1 > b1 && a2 < b2){
     cout << 0 << endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    map<int, int> M;
    for (int a : A) M[a]++;
    Int t = 0;
    for (auto &p : M) {
        Int n = p.second;
        t += n * (n - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
        Int n = M[A[i]];
        cout << t - n * (n - 1) / 2 + (n - 1) * (n - 2) / 2 << '\n';
    }
    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
// constexpr long double EPS = 1e-15;
// const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int n,a,b,c;
    string s,sa,sb,sc;
    cin >> a >> b;
    if (a < 10 && b < 10) cout << a * b << endl;
    else cout << -1 << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

int main(){
    int ans=10000000000000,N,dist=0;
    cin >> N;
    vector<int> X(N,0);
    for (int i = 0; i < N; i++){
        cin >> X[i];
    }
    sort(X.begin(),X.end());
    for (int j = 0; j < 1000; j++){
        dist = j;
        int tmp = 0;
        for (int i = 0; i < N; i++){
            tmp += (dist - X[i])*(dist - X[i]);
        }
        ans = min(tmp,ans);
    }
    cout << ans << endl;
    // cout << dist << endl;
}

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

using namespace std;

int main() {
	int ans = 0;
	for (int i = 1; i <= 5; ++i) {
		int x;
		cin >> x;
		if (x == 0) { ans = i; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <deque>

using namespace std;

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

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

    deque<int> b;

    for (int i = 0; i < n; i++)
        if (i % 2 == 0)
            b.push_back(a[i]);
        else
            b.push_front(a[i]);

    if (n % 2 == 1)
        reverse(b.begin(), b.end());

    for (int i = 0; i < n; i++) {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=21,M=(1<<21)+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline 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;
}

inline ll readll()
{
    ll x=0;int 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 n,k,f[N][M],tr[M][2],low[M];
char s[M];

int main()
{
    n=read();k=read();
    rep(i,0,n)
    {
        scanf("%s",s);int tmp=(1<<i);
        rep(j,0,(1<<i)-1) f[i][tmp|j]=(s[j]-'0');
    }
    low[0]=-1;
    rep(i,2,(2<<n)-1) low[i]=low[i>>1]+1;
    rep(i,2,(2<<n)-1)
    {
        if ((i>>(low[i]-1))&1)
        {
            tr[i][1]=i^(1<<low[i]);
            tr[i][0]=tr[tr[i][1]][0];
        }
        else
        {
            tr[i][0]=i^(3<<(low[i]-1));
            tr[i][1]=tr[tr[i][0]][1];
        }
        //cout << i << " " << tr[i][0] << " " << tr[i][1] << endl;
    }
    //rep(i,1,(2<<n)-1) cout << low[i] << " ";cout << endl;
    per(i,n,1)
    {
        rep(j,(1<<i),(2<<n)-1)
        {
            if (!f[i][j]) continue;
            int s=(j>>i),t=(j&((1<<i)-1))^(1<<i);
            if (tr[t][0])
            {
                f[low[tr[t][0]]][(((s<<1)^1)<<low[tr[t][0]])^tr[t][0]]+=f[i][j];
            }
            if (tr[t][1])
            {
                f[low[tr[t][1]]][(((s<<1)^0)<<low[tr[t][1]])^tr[t][1]]+=f[i][j];
            }
            f[0][s]+=f[i][j];
        }
    }
    int ans=1;
    rep(i,2,(2<<n)-1)
        if ((f[0][i]>=k) && (low[i]>low[ans])) ans=i;
    //cout << ans << endl;
    per(i,low[ans]-1,0) printf("%d",(ans>>i)&1);
    return 0;
}
        

Measured memory_bytes: 195840
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end
  attr_reader :heap
 
  def push(x)
    i = @node_num # 自分のノード番号
    @node_num += 1
    while i > 0
      par = (i - 1) / 2 # 親のノード番号
      break if @comp.call(@heap[par], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end
 
  alias_method(:<<, :push)
 
  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while i * 2 + 1 < @node_num
      # 子どうしを比較
      a, b = i * 2 + 1, i * 2 + 2
      a = b if b < @node_num && @comp.call(@heap[b], @heap[a])
      break unless @comp.call(@heap[a], x)
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    return ret
  end
 
  def get
    @node_num == 0 ? nil : @heap[0]
  end
 
  def empty?
    return get.nil?
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
q = PriorityQueue.new { |x, y| x > y }
a.each do |e|
  q.push e
end

m.times do
  q.push(q.pop / 2)
end
puts q.heap.inject(:+)


Measured memory_bytes: 9556
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long int;
int main(){
    ll N, T;
    cin >> N >> T;
    vector<ll> t(N);
    for(int i=0; i<N; i++) cin >> t[i];
    ll ans = 0;
    int s;
    for(int i=0; i<N; i++){
        if(i==N-1){
            s = T;
        }else{
            s = min(T, t[i+1]-t[i]);
        }
        ans += s;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;


int main()
{
	cin >> a >> b;
	cout << (a - 1) * (b - 1) << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		int n,f=0,i,max,min,s,gap=0,m_gap=0;
		int flie[] = new int[10000];
		Scanner scan = new Scanner(System.in);
		while(true){
			gap = 0;
			n = scan.nextInt();
			int data[] = new int[n];
			for(i=0;i<n;i++){
				data[i]=0;
			}
			min = scan.nextInt();
			max = scan.nextInt();
			if(n==max && max==min){
				break;
			}
			for(i=0;i<n;i++){
				data[i] = scan.nextInt();
			}
			for(i=min;i<=max;i++){
				s=data[i]-data[i-1];
				if(s<0){
					s=s*-1;
				}if(gap<=s){
					gap=s;
					flie[f]=i;
				}
			}
		f++;
		}
		for(i=0;i<f;i++){
			m_gap=flie[i];
			System.out.println(m_gap);
		}
	}
}

Measured memory_bytes: 56864
#include<stdio.h>
#include<iostream>
using namespace std;

char c;
int main (){
    cin >> c;
    if( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back
const int N=1e6+1;
int prime[N];

void seive()
{
    memset(prime,-1,sizeof(prime));
    for(int i=2;i<=N;i++)
    {
        if(prime[i]==-1)
        {
            prime[i]=i;
            for(int j=i*i;j<=N;j+=i)
                prime[j]=i;
        }
    }
}
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}

void solve()
{
    seive();
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int g=a[0];
    for(int i=1;i<n;i++)
    {
        g=gcd(g,a[i]);
    }
    if(g!=1)
    {
        cout<<"not coprime\n";
        return;
    }
    set<int> s;bool f=1;
    for(int i=0;i<n;i++)
    {
        set<int> temp;
        int x=a[i];
        while(prime[x]!=-1)
        {
            int d=prime[x];
            temp.insert(d);
            x/=d;
        }
        for(auto it:temp)
        {
            if(s.find(it)!=s.end())
            {
                f=0;
                break;
            }
            s.insert(it);
        }
    }
    if(f)
        cout<<"pairwise coprime\n";
    else
        cout<<"setwise coprime\n";
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

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


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

ll func(ll a) {
  a++;
  ll res = 0;
  rep(i,50) { // 10^12は2進数で大体40桁くらい（らしい）
    ll loop = (1LL<<i) * 2;
    ll cnt = (a/loop) * (loop/2);
    if(a % loop) cnt += max(0LL, (a%loop) - (loop/2));
    if(cnt % 2) res += 1LL<<i;
  }
  return res;
}

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

  ll a, b;
  cin >> a >> b;
  ll ans = func(a-1) ^ func(b);
  cout << ans << endl;
} 

Measured memory_bytes: 256
#include <stdio.h>
#define N 500000

typedef struct Node_tbl{
	int key;
	int parent;
	int left;
	int right;
} Node;

const int nil = -1;
Node t[N];
int root;
int room;
int ix;

int tmin(int u){

  while (t[u].left != nil)
		u = t[u].left;

	return u;
}

int find(int u, int k){
	while (u != nil && k != t[u].key){
		if (k < t[u].key)
			u = t[u].left;
		else
			u = t[u].right;
	}

	return u;
}

int trees(int u){
	if (t[u].right != nil){
		return tmin(t[u].right);
  }

	int y = t[u].parent;
	while (y != nil && u == t[y].right){
		u = y;
		y = t[y].parent;
	}

	return y;
}

void delete(int z){
	int y;
	int x;

	if (t[z].left == nil || t[z].right == nil){
		y = z;
  }
	else{
		y = trees(z);
  }

	if (t[y].left != nil)	x = t[y].left;
	else{
		x = t[y].right;
  }

	if (x != nil) t[x].parent = t[y].parent;

	if (t[y].parent == nil) root = x;
	else{
		if (y == t[t[y].parent].left){
			t[t[y].parent].left = x;
    }
		else{
			t[t[y].parent].right = x;
    }
	}

	if (y != z)
		t[z].key = t[y].key;

	t[y].right = room;
	room = y;
}

void insert(int k){
	int z;
	int y = nil;
	int x = root;

	if (room == nil) z = ix++;
	else{
		z = room;
		room = t[room].right;
	}

	t[z].key = k;
	t[z].left = nil;
	t[z].right = nil;

	while (x != nil){
		y = x;
		if (t[z].key < t[x].key)
			x = t[x].left;
		else
			x = t[x].right;
	}

	t[z].parent = y;
	if (y == nil)
		root = z;

	else{
		if (t[z].key < t[y].key)
			t[y].left = z;
		else
			t[y].right = z;
	}
}

void
inorder(int u)
{
	if (u == nil)
		return;

	inorder(t[u].left);
	printf(" %d", t[u].key);
	inorder(t[u].right);
}

void preorder(int u){
	if (u == nil) return;

	printf(" %d", t[u].key);

	preorder(t[u].left);
	preorder(t[u].right);
}

int main(int argc, char** argv){
	char com[8];
	int n;
	int x;
	int i;

	root = nil;
	room = -1;
	ix = 0;

	scanf("%d", &n);

	for (i = 0; i < n; ++i){
		scanf("%s", com);

		switch (com[0]){
		case 'd':
			scanf("%d", &x);
			delete(find(root, x));
			break;

		case 'f':
			scanf("%d", &x);
			printf("%s\n", find(root, x) != nil ? "yes" : "no");
			break;

		case 'i':
			scanf("%d", &x);
			insert(x);
			break;

		case 'p':
		default:
			inorder(root);
			printf("\n");

			preorder(root);
			printf("\n");
			break;
		}
	}

  return 0;
}



Measured memory_bytes: 7956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  in(s);
  if(s[0] == s[1] && s[2] == s[3]){
    if(s[1] != s[2])
      out("Yes");
    else
      out("No");
  }
  else if(s[0] == s[2] && s[1] == s[3]){
    if(s[1] != s[2])
      out("Yes");
    else
      out("No");
  }
  else if(s[0] == s[3] && s[1] == s[2]){
    if(s[0] != s[1])
      out("Yes");
    else
      out("No");
  }
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=2e6+5;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	/*freopen(".in", "r", stdin);
	freopen(".out", "w", stdout); 
    */
	ll a;cin >> a;
	cout << a  + a*a + a*a*a << endl;
    
}
	


Measured memory_bytes: 3652
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val c = Array.fill(3, 3)(sc.nextInt())
  val b = c(0)
  val a = Array.fill(3)(0)
  a(1) = c(1)(0) - c(0)(0)
  a(2) = c(2)(0) - c(0)(0)

  var ok = true
  for {
    i <- 0 until 3
    j <- 0 until 3
    if c(i)(j) != a(i) + b(j)
  } {
    ok = false
  }
  println(if (ok) "Yes" else "No")
}


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

int main()
{
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s == u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
    return 0;
}


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

int main(){

  char str[11][11];

  
  while(scanf("%s",str[0]) != EOF){
    for(int i=1;i<8;i++){
      scanf("%s",str[i]);
    }
    
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
	if(str[i][j]=='1'){
	  if(i<8 && j<8 && str[i][j+1]=='1' && str[i+1][j]=='1' && str[i+1][j+1]=='1'){
	    printf("A\n");
	    goto end;
	  }
	  if(i<6 && str[i+1][j]=='1' && str[i+2][j]=='1' && str[i+3][j]=='1'){
	    printf("B\n");
	    goto end;
	  }
	  if(j<6 && str[i][j+1]=='1' && str[i][j+2]=='1' && str[i][j+3]=='1'){
	    printf("C\n");
	    goto end;
	  }
	  if(i<7 && j>0 && str[i+1][j-1]=='1' && str[i+1][j]=='1' && str[i+2][j-1]=='1'){
	    printf("D\n");
	    goto end;
	  }
	  if(i<8 && j<7 && str[i][j+1]=='1' && str[i+1][j+1]=='1' && str[i+1][j+2]=='1'){
	    printf("E\n");
	    goto end;
	  }
	  if(i<7 && j<8 && str[i+1][j]=='1' && str[i+1][j+1]=='1' && str[i+2][j+1]=='1'){
	    printf("F\n");
	    goto end;
	  }
	  if(i<8 && j<8 && j>0 && str[i][j+1]=='1' && str[i+1][j-1]=='1' && str[i+1][j]=='1'){
	    printf("G\n");
	    goto end;
	  } 
	  
	}
      }
    }
    
  end: int a;
    
  }
  
  return  0;
}

Measured memory_bytes: 1112
s = str(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
inv_alpha = 'zyxwvutsrqponmlkjihgfedcba'
if len(s) == 26:
    if s == inv_alpha:
        print(-1)
    else:
        for i in reversed(range(25)):
            for j in reversed(range(i+1, 26)):
                if s[i] < s[j]:
                    print(s[:i] + s[j])
                    break
            else:
                continue
            break
else:
    S = sorted(set(alpha) - set(s))
    print(s + S[0])


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

int main() {
  int n;
  cin >> n;
  if (n / 100 == 7 || (n - n / 100 * 100) / 10 == 7 || n - n / 100 * 100 - (n - n / 100 * 100) / 10 * 10 == 7)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

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

int main(){
	int N; cin>>N;
	int n = 0, r = 0;
	vector<int> A(N);
	rep(i, N){ cin>>A[i]; n = max(n, A[i]); }
	// rep(i, N) if(abs(n - r*2) >= abs(n - A[i]*2)) r = A[i];
	rep(i, N) if(abs(n - r*2) > abs(n - A[i]*2)) r = A[i];
	// rep(i, N) if(abs(n/2 - r) > abs(n/2 - A[i])) r = A[i];
	cout<< n <<" "<< r <<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;
	if (n == 1) cout << "Hello World\n";
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << '\n';
	}

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

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

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

    int x, a, b;
    cin >> x >> a >> b;
    int d1 = abs(x - a), d2 = abs(x - b);
    if (d1 < d2)
        cout << "A" << endl;
    else
        cout << "B" << endl;
}

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

ll dp[55][55][2510];

int main()
{
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  for(int i=0; i<N; i++){
    cin >> x[i];
  }
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (int i=0; i<N; i++) {
    for (int j=0; j<=i; j++) {
      for (int k=0; k<=N*A; k++) {
        if (k >= x[i]) {
          dp[i+1][j+1][k] = dp[i][j+1][k] + dp[i][j][k-x[i]];
        } else {
          dp[i+1][j][k] = dp[i][j][k];
        }
      }
    }
  }
  ll ans = 0;
  for (int i=1; i<=N; i++) {
    ans += dp[N][i][i*A];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 59520
#include<bits/stdc++.h>
using namespace std;
struct query{
	int a,b,c,d;
} qu[51];
int n,m,q;
vector<vector<int> > V[11];
int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
		cin>>qu[i].a>>qu[i].b>>qu[i].c>>qu[i].d;
	for(int i=1;i<=m;i++)
	{
		vector<int> v;
		v.push_back(i);
		V[1].push_back(v);
	}
	for(int i=1;i<n;i++)
		for(int l=0;l<V[i].size();l++)
		{
			int last=V[i][l][V[i][l].size()-1];
			for(int j=last;j<=m;j++)
			{
				vector<int> v=V[i][l];
				v.push_back(j);
				V[i+1].push_back(v);
			}
		}
	int ans=0,res=0;
	for(int i=0;i<V[n].size();i++)
	{
		res=0;
		for(int l=1;l<=q;l++)
			if(V[n][i][qu[l].b-1]-V[n][i][qu[l].a-1]==qu[l].c)
				res+=qu[l].d;
		ans=max(ans,res);
	}
	cout<<ans;
	return 0;		
}

Measured memory_bytes: 18848
#include<cstdio>
#include<iostream>
using namespace std;
bool d[55][55][55];
bool f[55][55][55];
int n,a[55],b[55];
int main(){
	for(int i=0; i<=50; i++)
		d[0][i][i] = true;
	for(int i=1; i<=50; i++)
		for(int A=0; A<=50; A++)
		for(int B=0; B<=50; B++){
			if(d[i-1][A][B] || d[i-1][A%i][B])
				d[i][A][B] = true;
		}
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
		f[50][i][a[i]] = true;
	}
	for(int i=1; i<=n; i++)scanf("%d",&b[i]);
	for(int i=1; i<=n; i++)if(!d[50][a[i]][b[i]]){
		puts("-1");
		return 0;
	}
	long long int res = 0;
	for(int k=50; k>0; k--){
		bool flag = false;
		for(int i=1; i<=n; i++){
			bool ff = false;
			for(int j=0; j<=50; j++)
				if(f[k][i][j] && d[k-1][j][b[i]]){
					ff = true;
					break;
				}
			if(!ff){
				flag = true;
				break;
			}
		}
		if(!flag){
			for(int i=1; i<=n; i++)
				for(int j=0; j<=50; j++)
					if(f[k][i][j])
						f[k-1][i][j] = true;
		}else{
			for(int i=1; i<=n; i++)
				for(int j=0; j<=50; j++)
					if(f[k][i][j]){
						f[k-1][i][j] = true;
						f[k-1][i][j%k] = true;
					}
			res += 1LL<<k;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

template<typename T, typename U> istream & operator>>(istream & s, pair<T, U> & p) { return (s >> p.FI >> p.SE); }
template<typename T, typename U> ostream & operator<<(ostream & s, pair<T, U> const & p) { return (s << p.FI << " " << p.SE); }

int main() {
	IN(int, h, w, n);
	vector<pair<int, int>> v(n);
	cin >> v;
	v.EB(h + 1, 1);
	sort(ALL(v));
	
	int z = 0;
	RF(e, v) {
		if(e.FI - e.SE >  z) { OUT(e.FI - 1); exit(0); }
		if(e.FI - e.SE == z) { z++; }
	}
	UR;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi d(n); for(auto& e : d) cin >> e;
    sort(_all(d));

    int lb = d[n/2 - 1];
    int ub = d[n/2];

    cout << ub - lb << endl;

    return 0;
}


Measured memory_bytes: 640