akhauriyash/Code-Regression huggingface dataset:
n = int(input())
name = ""
dig_num = 0
sum_num = 0
pow26 = {0: 1}
while n > sum_num:
    dig_num += 1
    pow26[dig_num] = 26**dig_num
    sum_num += pow26[dig_num]
# print(dig_num)
i = dig_num-1
while i >= 1:
    n -= pow26[i]
    i -= 1

for i in range(dig_num):
    now_dig = ((n-1)//pow26[i])%26
    name = chr(ord("a")+now_dig) + name

print(name)

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

int main() {
    //変数宣言
    int N;
    cin >> N;


    if (N >= 64) cout << 64 << endl;
    else if ((N >= 32) && (N <= 63)) cout << 32 << endl;
    else if ((N >= 16) && (N <= 31)) cout << 16 << endl;
    else if ((N >= 8) && (N <= 15)) cout << 8 << endl;
    else if ((N >= 4) && (N <= 7)) cout << 4 << endl;
    else if ((N >= 2) && (N <= 3)) cout << 2 << endl;
    else cout << 1 << endl;
}

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

using namespace std;

string substrBack(string str, size_t pos, size_t len) {

	const size_t strLen = str.length();

	return str.substr(strLen - pos, len);
}

int main(void) {

	string s;
	string t;

	cin >> s >> t;

	for (int i = 0; i < s.length(); i++) {

		if (s[i] == t[i]) {

			continue;

		}
		else {

			cout << "No";
			return 0;

		}

	}

	cout << "Yes";
	
}

Measured memory_bytes: 2956
#include <cstdio>
#include <unordered_map>
#define rr register
using namespace std;
const int mod=1e9+7;
unordered_map<long long,int>dp; long long n;
inline signed modd(int x1,int x2,int x3){
    rr int ans=x1+x2>=mod?x1+x2-mod:x1+x2;
    return ans+x3>=mod?ans+x3-mod:ans+x3;
}
inline signed dfs(long long n){
    if (dp[n]) return dp[n];
    else return dp[n]=modd(dfs(n>>1),dfs((n-1)>>1),dfs((n-2)>>1));
}
signed main(){
    dp[dp[0]=1]=2; scanf("%lld",&n);
    return !printf("%d\n",dfs(n));
}

Measured memory_bytes: 256
#include <cstdio>

int a,b,c,k;

int main()
{
	scanf("%d %d %d %d",&a,&b,&c,&k);
	int tot=0;
	while(b<=a)b*=2,tot++;
	while(c<=b)c*=2,tot++;
	if(tot<=k)printf("Yes");
	else printf("No");
}

Measured memory_bytes: 1732
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

a,b=MI()
ans=1
c=a
while c<b:
    c+=a-1
    ans+=1
print(ans if b!=1 else 0)


Measured memory_bytes: 38512
#include<iostream>
using namespace std;
int main(){
	int space[10],sum;
	char dummy;
	while(cin>>space[0]){
		sum=space[0];
		for(int i=1;i<10;++i){
			cin>>dummy>>space[i];
			sum+=space[i];
		}
		int speed1,speed2;
		cin>>dummy>>speed1>>dummy>>speed2;
		double time,distance;
		time=(double)sum/(speed1+speed2);
		distance=speed1*time;
		int answer;
		for(answer=0;distance>0.0;distance-=space[answer++]);
		cout<<answer<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(M+1),B(M+1);
    vector<vector<int>> graph(N+1, vector<int>());
    for(int i=1; i<=M; i++){
        cin >> A.at(i) >> B.at(i);
        graph.at(A.at(i)).push_back(B.at(i));
        graph.at(B.at(i)).push_back(A.at(i));
    }
    int INF = 100000000;
    queue<int> que;
    vector<int> d(N+1,INF);
    que.push(1);
    d.at(1)=0;
    
    while(que.size()){
        int p=que.front();
        que.pop();
        int b=graph.at(p).size();
        for(int i=0; i<b; i++){
            int c=graph.at(p).at(i);
            if(d.at(c)==INF){
                que.push(c);
                d.at(c)=p;
            }
        }
    }
    bool result=true;
    for(int i=1; i<=N; i++){
        if(d.at(i)==INF) result=false;
    }
    if(result){
        cout << "Yes" << endl;
        for(int i=2; i<=N; i++) cout << d.at(i) << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 11824
str = list(input())  # 一文字ずつ格納
last = str[0]
ans = 0

for i in range(1, len(str)):
    if last == str[i]:
        ans += 1
        if last == "0":
            last = '1'
        else:
            last = '0'
    else:
        last = str[i]


print(ans)


Measured memory_bytes: 3956
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int r, d, x;
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++) {
    x = r * x - d;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 628
# うまいことやる せいぜいopは2^3なので愚直にやってもいいけど
# evalを使ってもいいけどevilなので使わない方針

a, b, c, d = list(map(int, list(input())))
op1, op2, op3 = [True, False], [True, False], [True, False]
for o1 in op1:
    for o2 in op2:
        for o3 in op3:
            ab = a + b if o1 else a - b
            abc = ab + c if o2 else ab - c
            abcd = abc + d if o3 else abc - d
            if abcd == 7:
                opr1 = "+" if o1 else "-"
                opr2 = "+" if o2 else "-"
                opr3 = "+" if o3 else "-"
                print("{}{}{}{}{}{}{}=7".format(a, opr1, b, opr2, c, opr3, d))
                exit()


Measured memory_bytes: 38256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


/* TopologicalSort */

vector<int> TopologicalSort(vector<vector<int> > G,int n= -1){
  if(n==-1) n=(int)G.size();
  
  int u;
  vector<int> ret,ret2;
  queue<int> que;
  vector<int> indeg(n+1,0);
  
  for(int i=0;i<n;i++){
    for(int j=0;j<G[i].size();j++){
      indeg[G[i][j]]++;
    }
  }
  
  for(int i=0;i<n;i++){
    if(indeg[i]==0){
      que.push(i);
    }
  }
  
  while(!que.empty()){
    u = que.front();
    que.pop();
    
    ret.push_back(u);
    
    for(int i=0;i<G[u].size();i++){
      indeg[G[u][i]]--;
      if(indeg[G[u][i]]==0){
        que.push(G[u][i]);
      }
    }
  }
  
  if(n==(int)ret.size()){
    return ret;
  }else{
    return ret2;
  }
}


int main(){
  int n,a[SIZE],b[SIZE];

  scanf("%d",&n);
  
  vector<vector<int> > G(n,vector<int>());


  a[0] = n;
  for(int i=1;i<n;i++){
    scanf("%d",a+i);
    a[i]--;
    G[i].push_back(a[i]);
    
  }

  vector<int> vec = TopologicalSort(G);
  vector<int> p[SIZE];
 
  
  for(int i=0;i<n;i++){
    int q = vec[i],m = 0;

    sort(p[q].begin(),p[q].end());

    for(int j=0;j<p[q].size();j++){
      m = max(m,((int)p[q].size()-j) + p[q][j]);
    }

    p[a[q]].push_back(m);
  }

  printf("%d\n",p[n][0]);
  
  return 0;
}


Measured memory_bytes: 13056
#include <stdio.h>
int main(void){
    
    double r, area, circumference;
     scanf("%lf", &r);
     area=3.141592653589*r*r;
     circumference=2*3.141592653589*r;
     printf("%lf %lf\n", area, circumference);

    return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,i=0,j,s,ans[100010],c,nagasa,ou=0,keta;
    cin >> n >> m;
    string z;
    pair<int, int> p[10000];
    for(i=0;i<m;i++)
    {
        cin >> s >> c;
        p[i]=make_pair(s,c);
    }
    for(i=0;i<1000;i++)
    {
        z=to_string(i);
        nagasa=z.size();
        if(nagasa==n)
        {
            for(j=0;j<m;j++)
            {
                if(z[p[j].first-1]-'0'!=p[j].second)
                {
                    ou++;
                    break;
                }
            }
            if(ou==0)
            {
                cout << i << endl;
                return 0;
            }
            ou=0;
        }
    }
    cout << "-1" << endl;
    return 0;

}


Measured memory_bytes: 3748
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    BigDecimal ans = BigDecimal.ONE;

    BigDecimal top = new BigDecimal(10).pow(18);

    BigDecimal num[] = new BigDecimal[n];

    for (int  i = 0; i < n; i++) {
      num[i] = new BigDecimal(sc.next());
      if (num[i].compareTo(BigDecimal.ZERO) == 0) {
        System.out.println("0");
        return;
      }
    }

    for (int  i = 0; i < n; i++) {
      ans = ans.multiply(num[i]);
      if (ans.compareTo(top) > 0) {
        System.out.println("-1");
        return;
      }
    }

    System.out.println(ans.setScale(0, RoundingMode.FLOOR).toPlainString());


  }

}

Measured memory_bytes: 66056
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var k = next();
  var t = 7;
  for(var i = 1; i <= k; i++){
    t = t % k;
    if(t === 0)return i;
    t = t*10+7;
  }
  return -1;
}

Measured memory_bytes: 32512
#include <iostream>
using namespace std;
int main()
{
	int i = 0, ii = 0;
	scanf("%d %d", &i, &ii);
	int a = i + ii;
	int b = i - ii;
	int c = i * ii;
	int Q = a < b ? b : a;
	Q = Q < c ? c : Q;
	cout << Q;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(tx, ty, w, h) (0 <= tx && tx <= w && 0 <= ty && ty <= h)

/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;

/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}

/* general_method */
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 (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int a, b, c;
void in(){
    cin >> a >> b >> c;
}

void solve(){

    print(a * b / 2);

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
def gcd(a, b):
    r = a % b
    if r == 0:
        return b
    return gcd(b, r)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    L = [A[0]]
    R = [A[-1]]
    for i in range(1, N - 1):
        L.append(gcd(L[-1], A[i]))
    for j in range(N - 2, 0, -1):
        R.append(gcd(R[-1], A[j]))
    ans = R[-1]
    for k in range(1, N - 1):
        ans = max(ans, gcd(L[k - 1], R[N - 2 - k]))
    print(max(ans, L[-1]))
    
main()


Measured memory_bytes: 14432
//#include<bhaai.h>
#include<bits/stdc++.h>
using namespace std;
#define to int64_t
#define mo 1000000007
#define fr(a,e) for(int i=a;i<=e;i++)
#define yah_faster_baby ios_base::sync_with_stdio(0);cin.tie(0);

to ans,n,k,m,r[200005];
vector <int> v;
char s[200005];
double d,x;
int main()
 {  yah_faster_baby
    cin>>n;
    cin>>s;
    fr(0,n-1)
    {if(s[i]=='R')
     r[i+1]=1;
     else
     v.push_back(i+1);
    } 
    
    k=n;
    while(k>0&&s[k-1]=='W')
    k--;

    fr(1,n)
    r[i]+=r[i-1];
    
    ans=min(r[k],k-r[k]);
    m=0;
    for(auto i:v)
    if(i<k)
    {m++;
     k--;
     while(k>i&&s[k-1]=='W')
     k--;
     ans=min(ans,m+r[k]-r[i]);
     ans=min(ans,m+k-i-r[k]+r[i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5924
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 3624
/*** Brave Force Story***/

#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define CX 60  // Center of x
#define CY 60  // Center of y

int main(){
	int t, n;
	int dx[6]={1, 1, 0, -1, -1, 0};
	int dy[6]={0, 1, 1, 0, -1, -1};
	
	while(cin>>t>>n, t||n){
		int sx, sy;
		int hist[121][121];
		bool obs[121][121];
		memset(hist, -1, sizeof hist);
		memset(obs, false, sizeof obs);
		
		REP(i, 0, n){
			int x, y;
			cin >> x >> y;
			obs[y+CY][x+CX]=true;
		}
		cin >> sx >> sy;
		
		queue<pair<int, int>> qu;
		qu.push(make_pair(sy+CY, sx+CX));
		hist[sy+CY][sx+CX]=0;
		
		while(!qu.empty()){
			pair<int, int> q=qu.front();
			qu.pop();
			
			int y=q.first, x=q.second;
			REP(k, 0, 6){
				int yy=y+dy[k], xx=x+dx[k];
				if(hist[yy][xx]!=-1 || obs[yy][xx]) continue;
				hist[yy][xx]=hist[y][x]+1;
				if(hist[yy][xx]<t) qu.push(make_pair(yy, xx));
			}
		}
		
		int ans=0;
		REP(i, 0, 121){
			REP(j, 0, 121){
				if(hist[i][j]!=-1) ans++;
			}
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void)
{
    int x,a,b;
    while(cin>>x>>a>>b)
    {
        if(fabs(x-a)>fabs(x-b))
            cout<<"B"<<endl;
        else
            cout<<"A"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  string s1;
  rep(i, 0, s.sz) {
    if (s[i] != 'B') {
      s1 += s[i];
    }
    else {
      if (s1.sz != 0) {
        s1.erase(s1.begin() + s1.sz - 1);
      }
    }
  }
  cout << s1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 51
using namespace std;
int h,w,p=0;
string A,mp[N];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int x,y,dir;
void start();

void Forward(){
  int nx = x+dx[dir],ny = y+dy[dir];
  if(nx>=0&&ny>=0&&nx<w&&ny<h&&mp[ny][nx]!='#') x=nx,y=ny;
}
 
void Back(){
  int nx = x+dx[(dir+2)%4],ny = y+dy[(dir+2)%4];
  if(nx>=0&&ny>=0&&nx<w&&ny<h&&mp[ny][nx]!='#') x=nx,y=ny;
}
 
void getIdx(){
  char ch = A[p];
  assert(ch=='['||ch=='{');
  int cnt=0;
  while(1){
    if(ch=='{')cnt+=(A[p]=='{')-(A[p]=='}');
    if(ch=='[')cnt+=(A[p]=='[')-(A[p]==']');
    p++;
    if(cnt==0) return;
  } 
}

bool kabe(){
  int nx = x+dx[dir],ny = y+dy[dir];
  if(nx<0||ny<0||nx>=w||ny>=h) return 1;
  return mp[ny][nx] == '#';
}
 
int getCheck(){
  char P = A[p];
  if(P=='N')return dir == 0;
  if(P=='E')return dir == 1;
  if(P=='S')return dir == 2;
  if(P=='W')return dir == 3;
  if(P=='C')return kabe();
  if(P=='T')return 1;
  assert(P&&0);
}

//{ 
void While(){
  int tmp = p;
  int f = A[++p]=='~';p+=f;
  int l = p;
  while(1){
    bool con = getCheck();p++;
    if(f) con = !con;
    if(con==0) break;
    start();
    p = l;
  }
  p = tmp;
  getIdx();
}
 
//[
void If(){
  assert(A[p]=='[');
  int tmp = p;
  int f = A[++p]=='~';p+=f;
  int l = p;
  bool con = getCheck();p++;
  if(f) con = !con;
  if(con) start();
  p = tmp;
  getIdx();
}
 
int ans,cnt;
void start(){
  while(1){
    if(cnt++>1e7)cout<<-1<<endl,exit(0);
    char P = A[p];
    if(P == '{') While();      
    else if(P == '[')If();
    else if(P =='^'||P=='v'){
      (P=='^')? Forward():Back(),ans++,p++;
      if(mp[y][x] == 'g')cout<<ans<<endl,exit(0);
    }
    else if(P=='<'||P=='>') dir=(P=='>')?(dir+1)%4:(dir+3)%4,ans++,p++;
    else break;
  }
}
 
int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>mp[i];
  cin>>A;

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) if(mp[i][j] == 's')y = i,x = j;

  start();
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 3152
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
    }
    let ans = if s.contains("RRR") {
        3
    } else if s.contains("RR") {
        2
    } else if s.contains("R") {
        1
    } else {
        0
    };
    println!("{}", ans);
}


Measured memory_bytes: 2128
url = "https://atcoder.jp//contests/abc156/tasks/abc156_b"


def base_10_to_n(X, n):
    if int(X/n):
        return base_10_to_n(int(X/n), n)+str(X % n)
    return str(X % n)


def main():
    n, k = list(map(int, input().split()))
    print(len(base_10_to_n(n, k)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){ 
  ll a, b, x;
  cin >> a >> b >> x;

  ll l = (a + x - 1ll) / x;
  l *= x;

  ll r = b / x;
  r *= x;

  cout << (r - l)/x + 1ll;




}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 



*/

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

typedef long long ll;

int N,M;
int A[20];
ll mod = 1000000007;
ll dp[20][100010];
ll mem[100010];
ll F[100010] = {1},R[100010];

ll pow_mod(ll a,ll b)
{
    if(b == 0)return 1;
    ll res = pow_mod(a * a % mod,b / 2);
    if(b & 1)res = res * a % mod;
    return res;
}

ll con(int a,int b)
{
    return F[a] * R[a - b] % mod * R[b] % mod;
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 1; i <= M; i++)scanf("%d",A + i);

    for(int i = 1; i < 100010; i++)F[i] = F[i - 1] * i % mod;
    for(int i = 0; i < 100010; i++)R[i] = pow_mod(F[i],mod - 2);

    dp[M][0] = 1;
    for(int i = M; i > 0; i--)
    {
        for(int j = 0; j < (1 << N); j++)
        {
            int rest = (1 << N) - A[i] + 1;
            int num = 0;
            for(int k = 0; k < N; k++)if((j >> k) & 1)
            {
                num++;
                rest -= (1 << k);
            }
            for(int k = 0; k < N; k++)if(((j >> k) & 1) == 0 && rest >= (1 << k))
            {
                dp[i - 1][j | (1 << k)] += dp[i][j] * con(rest - 1,(1 << k) - 1);
                dp[i - 1][j | (1 << k)] %= mod;
            }
            dp[i - 1][j] += dp[i][j];
            dp[i - 1][j] %= mod;
        }
    }

    ll ans = 0;
    for(int i = 0; i < (1 << N); i++)
    {
        int rest = (1 << N) - 1;
        int num = 0;
        for(int j = 0; j < N; j++)if((i >> j) & 1)
        {
            num++;
            rest -= (1 << j);
        }
        for(int j = 0; j < N; j++)if(((i >> j) & 1) == 0)
        {
            dp[0][i] *= con(rest,(1 << j));
            dp[0][i] %= mod;
            rest -= (1 << j);
        }
        if(num % 2)ans -= dp[0][i];
        else ans += dp[0][i];
        ans = (ans + mod) % mod;
    }
    for(int i = 0; i < N; i++)ans = ans * F[(1 << i)] % mod;
    printf("%lld\n",ans * (1 << N) % mod);
    return 0;
}





Measured memory_bytes: 16128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

int main(){
    int a,b,c;cin>>a>>b>>c;
    set<int> d;
    d.insert(a);
    d.insert(b);
    d.insert(c);
    cout << d.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 100000
#define MOD 1000000007
typedef long long ll;
 
int main(){
    int N,T,a[MAX_N];
    cin >> N >> T;
    for(int i = 0 ; i < N ; i++){
	cin >> a[i];
    }
    sort(a,a+N);
    ll res = 1;
    for(int i = 0 ; i < N ; i++){
	res *= upper_bound(a+i,a+N,a[i]+T)-(a+i);
	res %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3476
#!/usr/bin/env python3
import sys


def solve(x: int):
    amari = x%11
    answer = x//11*2
    if amari>6:
        answer+=2
    elif amari>0:
        answer+=1
    
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    solve(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    V vec(n);
    rep(i,n-1){
        ll x;
        cin>>x;
        x--;
        vec[x]++;
    }
    for(auto i:vec){
        cout<<i<<endl;
    }
}


Measured memory_bytes: 4768
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max(0, min(B, D) - max(A, C)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}





int main(){
  int a,b,K;
  cin >> a >> b >> K;
  if(b-a+1<=2*K) for(int i=a;i<=b;i++) cout << i << endl;
  else{
    rep(i,K) cout << a+i << endl;
    rep(i,K) cout << b-K+i+1 << endl;
  }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 vector<int> a(4);
  int sum=0;
  for(int i=1;i<4;i++){
  cin >> a.at(i); 
  }
  
  sort(a.begin(),a.end());
  a.at(0) = a.at(1);
 
  for(int i=1;i<4;i++){
  sum += a.at(i) - a.at(i-1); 
  }
  
   
  
  cout << sum << endl;
  
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll n, ans;
int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (ll i = sqrt(n) + 1; i >= 1; i--)
	{
		if (n % i == 0)
		{
			ans = i + n / i - 2;
			cout << ans << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3700
#include <stdio.h>
#include <stdlib.h>

#define MAX_N 101000
#define SWAP( a, b ) do { int tmp; tmp = a; a = b; b = tmp; } while( 0 )

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

void insertionSort( int *, int );
void quickSort( int *, int );
void quickSort_body( int *, int, int );
int median( int, int, int );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( isPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		quickSort( sum, 253 );
	}

	return 0;
}

void insertionSort( int *data, int n ) {
	int i, j, tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		if ( data[ i - 1 ] > tmp ) {
			j = i;
			do {
				data[ j ] = data[ j - 1 ];

				j--;
			} while ( j && data[ j - 1 ] > tmp );

			data[ j ] = tmp;
		}
	}
}

void quickSort( int *data, int n ) {
	quickSort_body( data, 0, n - 1 );
}

void quickSort_body( int *data, int l, int r ) {
	if ( l < r ) {
		int i = l, j = r, pivot = median( data[ i ], data[ ( i + j ) / 2 ], data[ j ] );

		while ( 1 ) {
			for ( ; data[ i ] < pivot; i++ ) ;
			for ( ; pivot < data [ j ]; j-- ) ;
			if ( i >= j )
				break;

			SWAP( data[ i ], data[ j ] );

			i++;
			j--;
		}

		if ( i - l < 20 )
			insertionSort( data + l, i - l );
		else
			quickSort_body( data, l, i - 1 );

		if ( r - j < 20 )
			insertionSort( data + j + 1, r - j );
		else
			quickSort_body( data, j + 1, r );
	}
}

int median( int x, int y, int z ) {
	if ( x < y )
		if ( y < z )
			return y;
		else if ( z < x )
			return x;
		else
			return z;
	else if ( z < y )
		return y;
	else if ( x < z )
		return x;
	else
		return z;
}

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

#define ff first
#define ss second
#define ll long long
#define pq priority_queue
#define mii map<int,int>

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;

double tb[3005][1500];
int calc[3005][1500];
int n;
vector<double> v;

double dp(int i, int t) {
    if(i == n and t <= n/2) return 1;
    if(i == n) return 0;
    if(calc[i][t]) return tb[i][t];
 
    double ans = 0;
    ans += dp(i+1, t)*v[i];
    if(t+1 <= n/2) ans += dp(i+1, t+1)*(1-v[i]); 
 
    calc[i][t] = 1;
    tb[i][t] = ans;
    return ans;
}

int main() {
    cin >> n;
    
    v.resize(n+5);
    for(int i = 0; i < n; i++)
    {
        scanf("%lf", &v[i]);
    }

    printf("%.12lf\n", dp(0, 0));



    return 0;
}

Measured memory_bytes: 52736
#include <cstdio>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int a, b;

int main(){
	while(scanf("%d%d", &a, &b) != EOF){
		printf("%d\n", a + b);
	}
	return 0;
}

Measured memory_bytes: 1028
N,A,B,K=gets.split.map &:to_i;M=998244353;I=[1,1];*F=I;*R=I;2.upto(N){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;R<<z*R[-1]%M};r=0;0.upto(N){|a|b=(K-A*a)/B;0<=b&&b<=N&&A*a+B*b==K&&r=(r+F[N]**2*R[a]*R[N-a]*R[b]*R[N-b])%M};p r

Measured memory_bytes: 8988
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    if n >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2140
A,B = [int(x) for x in input().split()]

number1 = A*100/8
number2 = B*100/10
if number1 != number1//1:
    number1 = number1//1 + 1
if number2 != number2//1:
    number2 = number2//1 + 1
number1 = int(number1)
number2 = int(number2)

if number1//10 == B:
    if number2*8//100 == A:
        if number1 <= number2:
            print(number1)
        else:
            print(number2)
    else:
        print(number1)
else:
    if number2*8//100 == A:
        print(number2)
    else:
        print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int &c:a)cin>>c;
    sort(a.begin(),a.end());
    queue<int>q;
    for(int i= n-1 ; i>=0 ; i--){
        q.push(a[i]);
    }
    int x=q.front();
    q.pop();
    while(!q.empty()){
        int y=q.front();
        q.pop();
        if( x == y || y % x ==0 )continue;
        else if( y < x ){
            q.push(x);
            x=y;
        }
        else {
            q.push(y%x);
        }
    }
    cout<<x;




    /*
    for(int c:s){
        auto r=s.begin();
        if((*r)!=c){
            if(c%(*r)==0)s.erase(c);
            else {
                s.insert(c%(*r));
                s.erase(c);
                }
            }
        }
    */
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.next());
		int g = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		if ( (r*100 + g*10 + b)%4 == 0) System.out.println("YES");
		else System.out.println("NO");
		sc.close();
	}
}


Measured memory_bytes: 23764
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

bool data[1000001] = {};

int main ()
{
	data[0] = 1;
	data[1] = 1;
	vector<long long int>data2;
	for( size_t i = 2; i < 1000001; i++ )
	{
		if( !data[i] )
		{
			long long int j = i * 2;
			data2.push_back ( i );
			for( ; j < 1000001; j += i )
			{
				data[j] = 1;
			}
		}
	}
	for( size_t i = 1; i < data2.size(); i++ )
	{
		data2[i] += data2[i-1];
	}
	int N;
	while( cin >> N , N )
	{
		cout << data2[N-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 2956
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


vector<long long> calc_next(const vector<long long> &ar) {
    vector<long long> res;
    for (auto val : ar) {
        for (int j = -1; j <= 1; j++) {
            int add = (val % 10) + j;
            if (add >= 0 && add <= 9) res.push_back(val * 10 + add);
        }
    }
    return res;
}


void solve() {
    int K; cin >> K;
    vector<long long> all;
    
    vector<long long> cur;
    for (int v = 1; v < 10; v++) cur.push_back(v), all.push_back(v);

    for (int d = 1; d < 10; d++) {
        cur = calc_next(cur);
        for (auto val : cur) all.push_back(val);
    }

    cout << all[K-1] << endl; 
}


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

Measured memory_bytes: 6408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
ll pow(ll x,ll y)
{
	ll ans=1;
	for(int i=0;i<y;i++)
	ans=ans*x;
	return ans;
}
int main()
{
	IOS;
	ll n;
	cin>>n;
	vll v1,v2,v3;
	map<ll,ll>m;
	rep(i,0,n)
	{
		ll x;
		cin>>x;
		v1.pb(x);
		v2.pb(i+1-x);
		m[i+1+x]++;
		v3.pb(i+1+x);
	}
	ll ans=0;
	for(int i=0;i<v2.size();i++)
	{
		ans+=m[v2[i]];
		if(v3[i]==v2[i])
		ans--;
	}
	cout<<ans;
}



Measured memory_bytes: 30616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int a = Integer.parseInt(strlist[0]);
		int b = Integer.parseInt(strlist[1]);

		String answer = "Positive";
		int dif = 0;

		if(a <= 0 && b >= 0){
			answer = "Zero";
		}else if(b < 0){
			dif = b - a;
			if(dif % 2 == 0){
				answer = "Negative";
			}
		}else{
			dif = 0 - a;
			if(dif % 2 == 0){
				answer = "Negative";
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 21076
import java.util.Scanner;

public class Main {

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

		while (sc.hasNext()) {
			int num = sc.nextInt();

			if (num == 0) {
				break;
			}
			int sum = sc.nextInt();
			int max = sum;

			for (int i = 1; i < num; i++) {
				int n = sc.nextInt();

				if (sum + n < n) {
					sum = n;
				} else {
					sum = sum + n;
				}
				max = Math.max(max, sum);
			}
			System.out.println(max);
		}

	}

}

Measured memory_bytes: 34100
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i641) => {
        read_value!($next, i64) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn solve(start: i64, cities: Vec<i64>) {
    let distance = {
        let mut v = vec![];
        for point in cities.iter() {
            v.push((point - start).abs());
        }
        v
    };
    let mut ans = *&distance[0];
    for (i, point) in distance.iter().enumerate() {
        let a = point;
        if let Some(b) = distance.get(i+1) {
            let gc = gcd(*a, *b);
            if gc < ans {
                ans = gc;
            }
        } else {
            break;
        }
    }
    println!("{}", ans);
}

fn main() {
    input! {
        n: i64,
        x: i64,
        cities: [i64; n]
    }
    solve(x, cities);
}


Measured memory_bytes: 6396
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    ll _X;
    ull K, D, X;
    scanf("%lld %llu %llu", &_X, &K, &D);
    X = abs(_X);
    if(X/D >= K){
        printf("%llu\n", X - K*D);
        return 0;
    }
    if(K&1 && X < D){
        printf("%llu\n", D - X);
        return 0;
    }
    if(K&1) X -= D;
    if(!X){
        printf("0\n");
        return 0;
    }
    D <<= 1;
    printf("%llu\n", min(X % D, ((X-1)/D + 1)*D - X));
	return 0;
}

Measured memory_bytes: 1724
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.chomp
puts "ABC"+n

Measured memory_bytes: 1788
/*;

THE BEST IS YET TO COME

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i, s, l) for (int i = s; i < l; i++)
#define rr(i,s,l) for(int i=s;i>=l;i--)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<int,int>
#define ss second
#define ff first
#define INF 1e18
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
#define vi vector<int>
#define vip vector<pair<int,int> >
#define endl "\n"
#define ln length()
#define sz size()
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
signed main()
{

    int n,q;
    cin>>n;
    vector<int> a(n);
    unordered_map<int,int> mp;
    int sum = 0;
    r(i,0,n)
    {
        cin>>a[i];
        sum += a[i];
        mp[a[i]]++;
    }
    cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;

        int x = mp[b];
        if(x == 0)
        {
           cout<<sum<<endl;
           continue;
        }

        sum -= mp[c]*c;
        mp[c] = mp[c] + mp[b];
        sum = sum - mp[b]*b + mp[c]*c;
        mp[b] = 0;
        //cout<<c<<" "<<mp[c]<<" "<<b<<" "<<mp[b]<<endl;
        cout<<sum<<endl;
    }


	return 0;
}




Measured memory_bytes: 7724
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 5e3 + 5;

ll n,k,p[N],c[N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=1;i<=n;i++) cin>>c[i];
    ll ans=-1e18;
    for(int i=1;i<=n;i++){
    	ll s=c[i];
    	vector<ll> V;
    	V.emplace_back(s);
    	for(int j=p[i];j!=i;j=p[j]) s+=c[j],V.emplace_back(s);
    	int len=V.size();
    	for(int j=0;j<len;j++){
    		ll rest=k-j-1;
    		if(rest<0) break;
    		ans=max(ans,V[j]+(rest/len)*max(s,0ll));
    	}
    }
    cout<<ans;
    return 0;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	vector <vector <char>> p(h + 2, vector <char>(w + 2, '#'));
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			cin >> p[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			cout << p[i][j];
		}
		cout << " " << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
   
public class Main{
  public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        String[] spl=s.split(" ");
        int a=Integer.parseInt(spl[0]);
        int b=Integer.parseInt(spl[1]);
        int c=Integer.parseInt(spl[2]);
   
        Arrays.sort(spl);
        System.out.println(spl[0]+" "+spl[1]+" "+spl[2]);
   
    }
}

Measured memory_bytes: 24184
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll se=0;
ll sume(vector<int> a,int n){

}
int main(){
    string s;cin>>s;
    int ans=0;
    for(int i=0;i<6;i++)if(s[i]=='1'){
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long,long long>P;
vector<P>vec;

int main(){
  long long n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    vec.push_back(P(a,b));
  }
  sort(vec.begin(),vec.end());
  
  long long cnt=0;
  for(int i=0;i<n;i++){
    cnt+=vec[i].second;
    if(cnt>=k){
      cout<<vec[i].first<<endl;
      return(0);
    }
  }
  return(0);
}


Measured memory_bytes: 2420
def min(a, b)
  a < b ? a : b
end


n = gets.chomp.to_i
s = gets.chomp

# 右のEの数
right_e_count = s.count('E') - s[0].count('E')
left_w_count = 0

ans = right_e_count + left_w_count

1.upto(n-1) do |i|
  right_e_count -= 1 if s[i] == 'E'
  left_w_count += 1 if s[i-1] == 'W'

  ans = min(ans, right_e_count + left_w_count)
end

p ans

Measured memory_bytes: 2436
n,m = gets.split.map(&:to_i)
mod = 10 ** 9 + 7

a = []
m.times{a << gets.to_i}
a.sort!
a << 0

dp = Array.new(n+1, 0)
dp[0] = 1

ai = 0
1.upto(n) do |dpi|
    if a[ai] == dpi
        ai += 1
        next
    end

    if dpi == 1
        dp[dpi] = dp[0]
    else
        dp[dpi] = dp[dpi-1] + dp[dpi-2]
    end

    dp[dpi] %= mod
end

puts dp[n]

Measured memory_bytes: 3712
#include<stdio.h>
int A[2000001],B[2000001],C[10000];

int main(){

  int n,i,j,k=0;

  scanf("%d",&n);

  for(i = 1; i <= n; i ++){
    scanf("%d",&A[i]);
    if (k < A[i]){
      k = A[i];
    }  
  }
  for(j = 1; j <= n; j ++){
    C[A[j]] = C[A[j]] + 1;  
  }
  for(i = 1; i <= k; i ++){
    C[i] = C[i] + C[i - 1];
  }
  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]] - 1;
  }
 for(i = 1; i < n; i ++){
   printf("%d ",B[i]);
  }
 printf("%d\n",B[n]);

 return 0;
}

Measured memory_bytes: 16264
from collections import defaultdict, Counter


def main():
    N = int(input())
    counter = defaultdict(list)
    for _ in range(N):
        S = input()
        cnt = Counter(S)
        for c, v in cnt.items():
            counter[c].append(v)
    chars = list(counter.keys())
    chars.sort()
    ans = ''
    for c in chars:
        n = 0 if len(counter[c]) < N else min(counter[c])
        ans += c * n
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3316