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

public class Main {

	public static void main(String[] args) {

		Map<Character, List<Integer>> charIndexMap = new HashMap<Character, List<Integer>>();
		Map<Integer, Integer> golemMap = new HashMap<Integer, Integer>();

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		if (e-a > k) {

			System.out.println(":(");
			return;
		}


		System.out.println("Yay!");
	}

}

Measured memory_bytes: 21972
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    ll q=in();

    string ans(3000000,'\0');
    ll b=1000000,e=b+s.length();
    for(int i=0;i<s.length();++i)ans[b+i]=s[i];
    bool forward=true;

    for(int i=0;i<q;++i){
        if(in()==1){
            forward^=true;
        }else{
            ll f;char c;cin>>f>>c;
            ans[forward^f==2?--b:e++]=c;
        }
    }

    if(!forward)reverse(ans.begin(),ans.end());
    for(int i=0;i<ans.length();++i)if(ans[i]!='\0')cout<<ans[i];
    cout<<endl;
}


Measured memory_bytes: 3712
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    int a[m];
    ll dayForPaper=0;
    FOR(i,0,m){
        cin >> a[i];
        dayForPaper += a[i];
    }
    if(n >= dayForPaper)cout << n-dayForPaper << endl;
    else cout << -1 << endl;

    return 0;
}

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

int main()
{
  ll N;cin>>N;
  vector<ll> D;
   
  for(ll i=1;i*i<=N;i++)
  {
    if (N % i==0)
      D.push_back(i);
  }
  ll min = pow(10,13);
  for(int i=0;i<(int)D.size();i++)
  {
    if (min > D[i]+(N/D[i]))
      min = D[i]+(N/D[i]);
  }
  cout<<min-2<<endl;
  
}

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



int main() {
    int n, k;
    cin >> n >> k;
    
    int cnt = 0;
    rep(i,n) {
        int h;
        cin >> h;
        
        if(h >= k)
            cnt++;
    }
    
    cout << cnt << endl;
    
    
    
    return 0;
}




Measured memory_bytes: 3584
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static boolean solve() {
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int x = in.nextInt();
		if (n + a + b + c + x == 0) return false;

		int f = 0;
		boolean flag = false;
		for (int i=0; i<n; i++) {
			int y = in.nextInt();
			if (i == 0 && x == y) continue;
			while (!flag) {
				x = (a*x+b)%c;
				f++;
				if (x == y) break;
				if (f >= 10000) {
					out.println("-1");
					flag = true;
				}
			}
		}

		if (flag) return true;

		out.println(f);
		out.flush();

		return true;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 40716
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,M; cin >> N >> M;
    vector<ll> A(N),B(N);
    for(int i = 0; i < N;i++) cin >> A[i] >> B[i];

    vector<vector<ll>> G(100005);
    for(int i = 0; i < N;i++){
        G[A[i]].push_back(B[i]);
    }
    
    priority_queue<ll> pq;
    for(ll L = 0; L <= M;L++){
        for(auto a:G[L]){
            pq.push(a);
        }
        if(pq.size()){
            res += pq.top(); pq.pop();
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 7296
N, A, B, C, *l = map(int, open(0).read().split())
ans = 10 ** 9


def dfs(a, b, c, cur, cost):
    if cur == N:
        if not a or not b or not c:
            return
        global ans
        ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + cost - 30)
    else:
        dfs(a, b, c, cur + 1, cost)
        dfs(a + l[cur], b, c, cur + 1, cost + 10)
        dfs(a, b + l[cur], c, cur + 1, cost + 10)
        dfs(a, b, c + l[cur], cur + 1, cost + 10)


def solve():
    dfs(0, 0, 0, 0, 0)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <stdio.h>

void swap (int *x, int *y);
int partition (int array[], int left, int right);
void quick_sort (int array[], int left, int right);

int main(void){
  int i;
  int n;
  int L,R;

  scanf("%d", &n);
  int d[n];

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

  quick_sort(d, 0, n-1);

  // for(i=0; i<n; i++) printf("d[%d]=%d\n", i,d[i]);
  L=d[n/2-1];
  R=d[n/2];

  if(L==R){
    printf("0\n");
  }else{
    printf("%d\n", R-L);
  }

  return 0;
}

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.lang.Math;

public class Main {
	
	public static int lcs(String firstStr, String secStr) {
		int len1 = firstStr.length();
		int len2 = secStr.length();
		char[] char1 = firstStr.toCharArray();
		char[] char2 = secStr.toCharArray();
		
		int[][] seqTable = new int[len1+1][len2+1];
		
		for (int i = 0; i <= len1;i++) {
			seqTable[i][0] = 0; // fill the first col with zeros
		}
		
		for (int i = 1; i <= len2;i++) {
			seqTable[0][i] = 0;  // fill the first row with zeros
		}		
		
		for (int i = 1; i<=len1;i++) {
			for (int j = 1; j<=len2;j++) {
				if (char1[i-1] == char2[j-1]) {
					seqTable[i][j] = seqTable[i-1][j-1]+1;
				} else {
					seqTable[i][j] = Math.max(seqTable[i-1][j], seqTable[i][j-1]);
				}
			}
		}
		
		return seqTable[len1][len2];
	}
	
	public static void main(String[] argv) {
		Scanner input =  new Scanner(System.in);
		int setNum = input.nextInt();
		input.nextLine();
		for (int i=0; i<setNum; i++) {
			String firstStr = input.nextLine();
			String secStr = input.nextLine();
			
			System.out.println(lcs(firstStr,secStr));
			
			// System.out.println(firstStr);
			// System.out.println(secStr);
		}
		input.close();
	}
}



Measured memory_bytes: 63772
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 26700
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
struct edge {
     int to, num;
};
vector<edge>g[50];
int n, m, ans = 0;
bool used[50];
void search(int a, int num) {
     used[a] = true;
     for (int i = 0; i < g[a].size(); i++) {
          if (g[a][i].num != num && !used[g[a][i].to]) {
               search(g[a][i].to, num);
          }
     }
}
int main() {
     cin >> n >> m;
     for (int i = 0; i < m; i++) {
          int a, b;
          cin >> a >> b;
          g[a - 1].push_back(edge{ b - 1, i });
          g[b - 1].push_back(edge{ a - 1, i });
     }
     for (int i = 0; i < m; i++) {
          for (int j = 0; j < n; j++)used[j] = false;
          search(0, i);
          bool flag = false;
          for (int j = 0; j < n; j++)if (!used[j])flag = true;

          if (flag) {
               ans++;
          } else {
          }
     }
     cout << ans << endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void solve() {
    int n; scanf("%d", &n);
    printf("%.10lf", n*2*3.1415926535);
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

map <int,int> M[200005] ;

int main()
{
    int i , j , k , l , m , n , u , v ;

    scanf("%d %d",&n,&m) ;

    for(i=1 ; i<=m ; i++)
    {
        scanf("%d %d",&u,&v) ;
        M[u][v] = 1 ;
        M[v][u] = 1 ;
    }
    int fl = 0 ;
    for(i=2 ; i<n ; i++)
    {
        if( M[i].find(1)!=M[i].end() && M[i].find(n)!=M[i].end() ) fl = 1 ;
    }
    if(fl) printf("POSSIBLE\n") ;
    else printf("IMPOSSIBLE\n") ;

    return 0 ;
}


Measured memory_bytes: 28416
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

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

int main(void) {
  int a, b;
  cin >> a >> b;


  if(a>b){
    prt(a+max(a-1,b));
  } else {
    prt(b+max(a,b-1));
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
int stk[100010],tp;
char query(int x,int y){char s[10];printf("? %d %d\n",x,y);fflush(stdout);scanf("%s",s);return s[0]=='Y';}
char ans[100010];
int main(){
	int a,b;std::cin>>a>>b;
	int n=a+b;
	if(a<=b)return std::cout<<"Impossible",0;
	for(int i=0;i<n;++i){
		if(!tp)stk[++tp]=i;
		else{
			if(query(stk[tp],i))stk[++tp]=i;
			else--tp;
		}
	}
	for(int i=0;i<n;++i)ans[i]=query(stk[tp],i)+'0';
	printf("! %s",ans);
	return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	int ans = (n - m) * 100 + m * 1900;
	cout << ans * (int)pow(2, m) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n, a[100], cnt=0;
  cin >> n;
  for(int i=0; i<n; i++)cin >> a[i];
  for(int i=1; i<n-1; i++){
    if(a[i] - min(a[i-1], a[i+1]) > 0 && a[i] - max(a[i-1], a[i+1]) < 0){
      cnt ++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
lastweek_contest = input()
thisweek_contest = ""

if lastweek_contest == "ABC":
    thisweek_contest = "ARC"
elif lastweek_contest == "ARC":
    thisweek_contest = "ABC"
else:
    thisweek_contest = "InputError: please enter correct contest name."

print(thisweek_contest)

Measured memory_bytes: 9100
#include<bits/stdc++.h>
        using namespace std;
        int main(){
          int n, W;
          cin >> n >> W;
          long long v[n], w[n], dp[n + 1][W + 1];
          for(int i = 0; i < n; i++)
            cin >>  w[i] >> v[i];
          for(int i= 0; i <= n; i++)for(int  j =0; j <=W; j++){
            if(i == 0 || j == 0)
              dp[i][j] = 0;
            else if(j >= w[i - 1])
              dp[i][j] = max(v[i-1] + dp[i-1][j- w[i-1]], dp[i - 1][j]);
            else dp[i][j] = dp[i -1][j];
          }

      cout<<dp[n][W ]<<"\n";
    }

Measured memory_bytes: 82372
import math
import cmath

def area(b,c):
    theta = cmath.phase(b)
    C = (c)*complex(math.cos(-theta),math.sin(-theta))
    return abs(b)*C.imag/2

n = int(input())
P = []
for i in range(n):
    x,y = map(float,input().split())
    P.append(complex(x,y))
P.append(P[0])
N = len(P)
total = 0.0
for i in range(0,N-1):
    b,c = P[i],P[i+1]
    total += area(b,c)

print(round(total,1))


Measured memory_bytes: 5844
function main(input) {
  const inputs =input.split('\n')
  const [S] = inputs[0].split(' ')
  const N = S.length
  const h = S.slice(0, (N-1)/2)
  const t = S.slice((N+2)/2, N)

  if (h !== t) {
    console.log('No')
    return
  }
  for (let i = 0; i < (h.length-1)/2; i++) {
    if (h[i] !== h[h.length-1-i]) {
      console.log('No')
      return
    }
  }
  console.log('Yes')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a,b;

        while(true){
            a = sc.nextInt();
            b = sc.nextInt();

            if(a == 0 && b == 0)break;

            System.out.printf("%d %d\n", Math.min(a, b),Math.max(a, b));
        }

    }
}





Measured memory_bytes: 40288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

struct BFS{

    vector<vector<int>> data;
    vector<bool> ch;
    vector<int> dis, bef;
    queue<int> q;

    void set(int n){
        rep(i, n+1){
            data.push_back(vector<int>());
            ch.push_back(false);
            dis.push_back(0);
            bef.push_back(0);
        }
        return;
    }

    void cn(int a, int b){
        data[a].push_back(b);
        data[b].push_back(a);
        return;
    }

    void root(int x){
        dis[x]=dis[bef[x]]+1;
        for(int i: data[x]){
            if(!ch[i]){
                q.push(i);
                bef[i]=x;
                ch[i]=true;
            }
        }
        return;
    }

    void search(int x){
        bef[x]=0;
        dis[0]=-1;
        ch[x]=true;
        for(int i: data[x]){
            if(!ch[i]){
                q.push(i);
                bef[i]=x;
                ch[i]=true;
            }
        }
        while(!q.empty()){
            root(q.front());
            q.pop();
        }
        return;
    }

    int dtc(int x){
        return dis[x];
    }

    int bfr(int x){
        return bef[x];
    }

};

int main(){

    cout<<"Yes"<<endl;

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

    BFS bfs;
    bfs.set(n);

    rep(i, m){
        int a, b; cin>>a>>b;
        bfs.cn(a, b);
    }

    bfs.search(1);

    FOR(i, 2, n){
        cout<<bfs.bfr(i)<<endl;
    }

}

Measured memory_bytes: 10732
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, p[100] = {}, r[100] = {};
    string s[100];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> p[i];
        r[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (s[i]<s[j] || s[i] == s[j] && p[i]>p[j]) {
                int tmp = r[i];
                r[i] = r[j];
                r[j] = tmp;
                string str = s[i];
                s[i] = s[j];
                s[j] = str;
                int in = p[i];
                p[i] = p[j];
                p[j] = in;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << r[i] << endl;
    }
}

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

#ifdef LOCAL
  #define debug_echo(expr) cout << expr << "\n";
#else
  #define debug_echo(expr)
#endif

using namespace std;

#define at ,<=,
#define to ,<,
#define in ,
#define forrange(...)  forrange1(forrange2, (__VA_ARGS__))
#define forrange1(X, A) X A
#define forrange2(i, s, op, e) for (int i = (s); i op (e); i++)

int main() {
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  vector<int> v;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(v.begin(), v.end());
  cout << v[0] + v[1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{

    lint n;
    scanf("%lld", &n);

    std::vector<lint> prime;

    prime.push_back(2);
    prime.push_back(3);
    lint num = 5;

    while (num <= 55555)
    {
        lint is_prime = 1;

        for (auto p : prime)
        {
            if (p > sqrt(num))
                break;
            if (num % p == 0)
            {
                is_prime = 0;
                break;
            }
        }

        if (is_prime)
            prime.push_back(num);

        num += 2;
    }

    std::vector<lint> prime_51;

    for (auto p : prime)
    {
        if (p % 5 == 1)
            prime_51.push_back(p);
    }

    for (int i = 0; i < n; ++i)
    {
        printf("%lld ", prime_51[i]);
    }

    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;


int main(int argc, char *argv[])
{
	int n, k;

	//input
	cin >> n >> k;


	//calc
	int ans = 0;
	while (0 < n){
		n /= k;
		ans++;
	}


	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    s, k = input(), int(input())

    if len(s) == 1 or k == 1:
        print(s[0])
        exit()

    idx = 0
    for i in range(len(s)):
        if s[i] != "1":
            idx = i
            break

    if k < idx + 1:
        print("1")
    else:
        print(s[idx])


if __name__ == '__main__':
    main()


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

  
int main () 
{ 
    //stack <int> s; 
    double n;
    cin>>n;
    double c=2*3.14159*n;
    cout<<c<<endl;
         
    
     /*for(int i=1;i<=n;i++)
     cout<<a[i]<<" ";
     cout<<endl;*/
  
    return 0; 
} 

Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    s.push_back('T');

    vector<int> yoko, tate;
    bool flag = true;
    int cnt = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == 'T'){
            if(flag) yoko.push_back(cnt);
            else tate.push_back(cnt);
            flag = !flag;
            cnt = 0;
        }else{
            cnt++;
        }
    }

    set<int> st1, st2;
    if(yoko[0] > 0){
        st1.insert(yoko[0]);
    }else st1.insert(0);
    st2.insert(0);
    for(int i=1; i<yoko.size(); i++){
        int k = yoko[i];
        set<int> st;
        for(auto j : st1){
            st.insert(j+k);
            st.insert(j-k);
        }
        st1 = st;
    }
    for(auto i : tate){
        set<int> st;
        for(auto j : st2){
            st.insert(j+i);
            st.insert(j-i);
        }
        st2 = st;
    }

    if(st1.find(x) != st1.end() && st2.find(y) != st2.end()) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
using namespace std;
using ll = long long int;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N + 1, 0);
    map<ll, ll> B;
    B[0] = 1;
    for (int i = 1; i <= N; i++)
    {
        ll tmp;
        cin >> tmp;
        A[i] = A[i - 1] + tmp;
        B[A[i]]++;
    }
    ll ans = 0;
    for (auto i : B)
    {
        ans += (i.second * (i.second - 1)) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    string S1,S2;
    cin >> N >> S1 >> S2;
    ll ans = 1;
    int i = 0;
    if(S1[0] == S2[0]){
        ans = 3;
        i += 1;
    }else{
        ans = 6;
        i += 2;
    }
    for(;i < N;){
        if(S1[i] == S2[i]){
            if(S1[i-1] == S2[i-1]){
                ans *= 2;
            }
            i++;
        }else{
            if(S1[i-1] == S2[i-1]){
                ans *= 2;
            }else{
                ans *= 3;
            }
            i+=2;
        }
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int X;
    cin >>X;
    if(X%7==1){
        cout<<"fri"<<endl;
    }else if(X%7==2){
        cout<<"sat"<<endl;
    }else if(X%7==3){
        cout<<"sun"<<endl;
    }else if(X%7==4){
        cout<<"mon"<<endl;
    }else if(X%7==5){
        cout<<"tue"<<endl;
    }else if(X%7==6){
        cout<<"wed"<<endl;
    }else{
        cout<<"thu"<<endl;
    }
}



Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 
#define debugP(vec) for(auto v : vec) cout << "(" << v.first << "," << v.second << ") "; cout << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << "(" << v.first << "," << v.second << ") "; cout << endl; } 

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

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

	if (k == 0) {
		cout << 2 << endl;
		cout << 1 << " " << 1 << endl;
	}
	else if (k == 1) {
		cout << 3 << endl;
		cout << 1 << " " << 0 << " " << 3 << endl;
	}
	else {
		cout << 50 << endl;
		rep(j, k % 50) cout << 2 * 50 - k % 50 + k / 50 << " ";
		rep(i, 50 - k % 50) cout << 50 - k % 50 - 1 + k / 50 << " ";
		cout << endl;
	}
}


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

int main( )
{
    int a, b;
    cin >>  a>> b;
    if (a >= 13)
    {
        cout << b << "\n";
    }
    else if (a >= 6 && a <= 12)
    {
        cout << b / 2 << "\n";
    }
    else
    {
        cout << "0\n";
    }

    return 0;
}


Measured memory_bytes: 256
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn quit() {
}

fn main() {
    let mut ret = 0;

    for _ in 1.. {
        from_line!(a: i32, op: String, b: i32);
        match &op[..] {
            "+" => ret = a + b,
            "-" => ret = a - b,
            "*" => ret = a * b,
            "/" => ret = a / b,
            "?" => break,
            _ => quit(),
        }
        println!("{}", ret);
    }

}



Measured memory_bytes: 5020
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		 while(sc.hasNextLine()) {
			
			int n = sc.nextInt();
			if(n == 0) break;
			
			ArrayList<Game> games = new ArrayList<Game>(n);
			
			for (int i = 0; i < n; i++) {
				games.add((new Game(sc.nextInt(), sc.nextInt())));
			}
			
			int point_a = 0;
			int point_b = 0;
			
			Iterator<Game> it = games.iterator();
			while (it.hasNext()) {
				Game now = it.next();
				if (now.winner() == Winner.A)
					point_a += now.sum();
				else if (now.winner() == Winner.B)
					point_b += now.sum();
				else if(now.winner() == Winner.draw){
					point_a += now.a;
					point_b += now.b;
				}

			}
			System.out.println(point_a + " " + point_b);
		}
		
	}

	

}

class Game{
	int a;
	int b;
	
	public  Winner winner() {
		if(this.a > this.b) return Winner.A;
		else if(this.a == this.b) return Winner.draw;
		else return Winner.B;
	}
	
	public int sum() {
		return a + b;
	}

	public Game(int a, int b) {
		this.a = a;
		this.b = b;
	}
}

enum Winner{
	A, B, draw
}

Measured memory_bytes: 55700
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

map<int,int> mp;

signed main() {
  INIT;
	VAR(int,n,m);
	REP(i,n){
		VAR(int,k);
		REP(j,k){
			VAR(int, a);
			mp[a]++;
		}
	}

	int ans = 0;
	EACH(mi,mp){
		if (mi.second == n) ++ans;
	}
	OUT(ans)BR;
  
  return 0;
}


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

a=n//100
n=n-a*100

if a==1:
	a=9
elif a==9:
	a=1

b=n//10
n=n-b*10

if b==1:
	b=9
elif b==9:
	b=1
	
if n==1:
	n=9
elif n==9:
	n=1

ans=a*100+b*10+n

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdint.h>

int n;
int a[15];
int x[15][15];
int y[15][15];

int check(char *testcase) {
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (testcase[i]) {
      for (int j = 0; j < a[i]; j++) {
        int p = x[i][j];
        if (testcase[p] != y[i][j]) return 0;
      }
      count++;
    }
  }
  return count;
}

int main() {
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    int k = 0;
    scanf("%d", &k);
    a[i] = k;
    for (int j=0; j<k; j++) {
      scanf("%d %d", &(x[i][j]), &(y[i][j]));
      x[i][j]--;
    }
  }

  int len = 1 << n, max = 0;
  for (int i = 0; i < len; i++) {
    char testcase[15];
    int l = i;
    for (int j = 0; j < n; j++) {
      testcase[j] = (l & 1); l >>= 1;
      //printf("%d ", testcase[j]);                                             
    }
    int r = check(testcase);
    //printf(" -> %d\n", r);                                                    
    if (max < r) max = r;
  }
  printf("%d\n", max);
  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>

#define S_SIZE 100000

using namespace std;

int S[S_SIZE];

bool isContain(int left,int right,int number){
	int m = (left + right)/2;
	if(left == right){
		if(S[m] == number){
			return true;
		}else{
			return false;
		}
	}else if(S[m] == number){
		return true;
	}else if(S[m] < number){
		return isContain(m + 1,right,number);
	}else{	//S[m] > number
		if(right - left == 1){
			return isContain(left,m,number);
		}else{
			return isContain(left,m-1,number);
		}
	}
}

int main(){

	int tmp;
	int n,q,count = 0;

	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&S[i]);
	}

	int left,right;
	scanf("%d",&q);
	for(int i = 0; i < q; i++){
		scanf("%d",&tmp);
		left = 0;
		right = n-1;
		if(isContain(left,right,tmp))
		{
			count++;
		}
	}
	printf("%d\n",count);
}

Measured memory_bytes: 1576
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n, x, y = LI()
    d = [0]*n
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            d[min(j - i, abs(x - i) + 1 + abs(j - y)) - 1] += 1
    for k in range(n-1):
        print(d[k])


if __name__ == "__main__":
    main()


Measured memory_bytes: 27284
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pii pair <int, int>
#define F first
#define S second
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846
const int N = 1000005;
const int mod = 1e9 + 7;
int main() {
    io;
    int n, a[N];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int x = a[0];
    for(int i = 1; i < n; i++){
        x = __gcd(x, a[i]);
    }
    if(x != 1) {
        cout << "not coprime" << endl;
        return 0;
    }
    map <int, int> mp;
    for(int i = 0; i < n; i++){
        for(int j = 2; j * j <= a[i]; j++){
            if(a[i] % j == 0){
                if(mp[j]){
                    cout << "setwise coprime";
                    return 0;
                }
                mp[j]++;
                while(a[i] % j == 0) a[i] /= j;
            }
        }
        if(a[i] != 1){
            if(mp[a[i]]){
                cout << "setwise coprime";
                return 0;
            }
            mp[a[i]]++;
        }
    }
    cout << "pairwise coprime";
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N, M;
    cin >> N >> M;
    vector<ll> wacnt(N, 0), accnt(N, 0);
    ll pena = 0;
    REP(i, M){
        ll p;
        string S;
        cin >> p >> S;
        p--;
        if(S=="AC"){
            if(accnt[p]==0) pena += wacnt[p];
            accnt[p]++;
        }else{
            wacnt[p]++;
        }
    }

    ll sei = 0;
    REP(i, N) if(accnt[i]>0) sei++;

    cout << sei << " " << pena << endl;

    return 0;
}

Measured memory_bytes: 4776
fn main() {
    let nk = read_vec::<u64>();
    let _ = nk[0];
    let k = nk[1];

    let mut v = read_vec::<u64>();
    v.sort();

    for _ in 0..k {
        if v.is_empty() {
            println!("0");
            return;
        } else {
            let _ = v.pop();
        }
    }

    let total: u64 = v.iter().sum();
    println!("{}", total);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 10492
s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if 0<s1<13 and 0<s2<13:
    print("AMBIGUOUS")

elif not(0<s1<13) and 0<s2<13:
    print("YYMM")

elif 0<s1<13 and not(0<s2<13):
    print("MMYY")

else:
    print("NA")

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;
using ll = long long;

// inf
const ll infl = 1LL << 60;
const int inf = 1 << 30;

int digitNum(int N) {
    int d = 0;
    while (N > 0) {
        ++d;
        N /= 10;
    }
    return d;
}

void enumCand(int d, vector<int>& out) {
    if (d == 1) {
        out.push_back(3);
        out.push_back(5);
        out.push_back(7);
    }
    else {
        vector<int> t;
        enumCand(d - 1, t);
        for (int x : t) {
            out.push_back(x * 10 + 3);
            out.push_back(x * 10 + 5);
            out.push_back(x * 10 + 7);
        }
    }
}

bool is753(int N) {
    bool c = false, g = false, s = false;
    while (N > 0) {
        int d = N % 10;
        if (d == 3) s = true;
        else if (d == 5) g = true;
        else if (d == 7) c = true;
        N /= 10;
    }
    return c && g && s;
}

int main() {
    int N; cin >> N;
    int D = digitNum(N);
    if (D <= 2) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> cand;
    for (int i = 3; i <= D; ++i) {
        enumCand(i, cand);
    }
    int ans = 0;
    for (int c : cand) {
        if (is753(c) && c <= N) {
            ++ ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());

            var ans = 0;
            for (int i = 1; i <= K; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    for (int k = 1; k <= K; k++)
                    {
                        ans += GCD(GCD(i, j), k);
                    }
                }
            }
            Console.WriteLine(ans);
            //Console.ReadKey();
        }

        public static int GCD(int p, int q)
        {
            if (p % q == 0) return q;
            return GCD(q, p % q);
        }
    }
}


Measured memory_bytes: 27504
n = int(input())
b = list(map(int, input().split()))
ans = []
ng = False
while len(b) > 0 and not ng:
    ng = True
    for i in range(len(b) - 1, -1, -1):
        if b[i] == i + 1:
            ans.append(i + 1)
            del b[i]
            ng = False
            break
    # print(b, ng)
if ng:
    print(-1)
else:
    print('\n'.join(map(str, reversed(ans))))


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


int main() {
  int n;
  cin >> n;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3608
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np
import collections as col

# main code
D,T,S = int_map()

if D <= S*T:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27092
#include "bits/stdc++.h"
using namespace std;

int Ask(string s) {
  cout << "? " + s << endl << flush;
  int ld;
  cin >> ld;
  return ld;
}

int len;  // パスワードの文字数

void insert(string& a, string b) {
  int pos = 0;
  for (int i = 0; i < (int)b.size(); ++i) {

    while (true) {
      string s = a.substr(0, pos) + b[i] + a.substr(pos);
      int ld = Ask(s);
      pos++;
      if (ld == len - (int)s.size()) {
        a = s;
        break;
      }
    }
  }
}

string Solve() {
  vector<string> ss;

  string chars;
  for (char c = 'a'; c <= 'z'; c++) chars.push_back(c);
  for (char c = 'A'; c <= 'Z'; c++) chars.push_back(c);
  for (char c = '0'; c <= '9'; c++) chars.push_back(c);

  len = 0;
  for (int i = 0; i < (int)chars.size(); ++i) {
    int charCnt = 128 - Ask(string(128, chars[i]));
    ss.emplace_back(charCnt, chars[i]);
    len += charCnt;
  }

  while (ss.size() > 1) {
    sort(ss.begin(), ss.end(), [](const string& l, const string& r) {
      return l.size() < r.size();
      });

    insert(ss[1], ss[0]);
    ss.erase(ss.begin());
  }

  return ss[0];
}

signed main() {
  string pass = Solve();
  cout << "! " << pass << endl;
  return 0;
}


Measured memory_bytes: 3724
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

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

    int x=753,ans=1000;
    REP(i,s.length()-2){
        int y=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
        if(ans>abs(x-y)){
            ans=abs(x-y);
        }
    }

    cout<<ans<<endl;



	return 0;
}


Measured memory_bytes: 256
def get_i
    gets.to_i
  end

  def get_ia(delimiter = ' ')
    gets.split(delimiter).map(&:to_i)
  end
    n = get_i
    c = 0
    bb = 0
    ea = 0
    bo = 0
    for i in 1..n
      t = gets.chomp.gsub("AB", "-")
      c += t.count("-")
      b = 0
      if t[0] == "B"
        bb += 1
        b += 1
      end
      if t[-1] == "A"
        ea += 1
        b += 1
      end
      if b == 2
        bo += 1
      end
    end
    a = [ea, bb].min
    if ea == bo && bb == bo
      c += [a - 1, 0].max
    else
      c += a
    end
    puts c

Measured memory_bytes: 1788
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
using namespace std;

typedef long long ll;
const int N = 2e5+ 7;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;

int a[60], b[60], c[60];
int main()
{
   int a,b;
   scanf("%d%d",&a,&b);
   printf("%d\n",a*b);
}


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

int main() {
    int a, b, c, d, e;
    int k;
    cin >> a >> b >> c >> d >> e >> k;

    string ans;
    if (e - a > k || d - a > k || c - a > k || b - a > k) ans = ":(";
    else ans = "Yay!";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#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() {
		ULL K, A, B; cin >> K >> A >> B;
		ULL N = 1;
		if (A - 1 > K) { cout << (K + 1) << endl; return; }
		if (B < A + 2) { cout << (K + 1) << endl; return; }
		K -= (A - 1);
		N += (A - 1);

		if (K % 2 == 1) { K--; N++; }
		K /= 2;
		N += (B - A) * K;
		cout << N << 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 <bits/stdc++.h>

using namespace std;

const int md = 1000000007;


int main() {
	long long n, m;
	scanf("%lld %lld", &n, &m);
	long long res = 0;
	if (n * 2 > m) {
		res = m / 2;
		printf("%lld\n", res);
		return 0;
	}
	res += n;
	m -= (n * 2);
	m /= 4;
	res += m;
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
  int n,m,ans=0,x,y;	
  cin>>n;
  for(register int i=1;i<=n;i++)
  {
    cin>>a[i];
    ans+=a[i];
  }
  cin>>m;
  while(m--)
  {
    cin>>x>>y;
    cout<<ans-a[x]+y<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int kai = min(a, b);
	int ans = max(a, b);
	for (int i = 0; i < ans; i++) {
		cout << kai;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
""" tutorial03
    https://atcoder.jp/contests/abc122/tasks/abc122_b
"""
import sys
import math

def main(s):
    """ main
    """
    result = 0
    count = 0

    for c in s:
        if c in ["A", "T", "C", "G"]:
            count += 1
        else:
            if result < count:
                result = count
            count = 0

    if result < count:
        result = count

    return result

if __name__ == "__main__":
    S = sys.stdin.readline()

    print(main(S))

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b;

int main(void) {
  // Here your code !
  scanf("%d %d", &a, &b);
  
  printf("%d\n", ((a + b - 1) / 2) + 1);

  return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);

$sum = 0;

for ($i = 1; $i <= $n; ++$i) {
    if (
        ($i % 5 === 0 && $i % 3 === 0 )
        || ($i % 3 === 0)
        || ($i % 5 === 0)
    ) {
        continue;
    }

    $sum += $i;
}
echo $sum;


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

using namespace std;

int main()
{
	int X, N;
	cin >> X >> N;

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

	int Y = X;
	bool flag1 = false;
	bool flag2 = false;
	while (true)
	{
		flag1 = false;
		flag2 = false;
		for (int i = 0; i < N; ++i)
		{
			if (X == p[i]) flag1 = true;
			if (Y == p[i]) flag2 = true;
		}
		if (!flag2)
		{
			cout << Y;
			return 0;
		}
		if (!flag1) {
			cout << X;
			return 0;
		}
		X++;
		Y--;
	}
}

Measured memory_bytes: 3628