akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int x,y;
	cin>>x>>y;
	rep(i,x+1){
		int j=x-i;
		if(i*2+j*4==y){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

int par[100005];//master
int rnk[100005];//depth

//initialization
void init(int n) {
	FOR(i, 0, n) {
		par[i] = i;//master is itself
		rnk[i] = 0;
	}
}

//search for root
int find(int x) {
	if (par[x] == x)return x;
	else return par[x] = find(par[x]);
}

//union
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rnk[x] < rnk[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
int N, M, ans;
int a[100000];


int main() {


	cin >> N >> M;
	init(N);
	FOR(i, 0, N) { cin >> a[i]; a[i]--; }
	FOR(i, 0, M) {
		int x, y;
		cin >> x >> y;
		unite(x - 1, y - 1);
	}

	FOR(i, 0, N) {
		if (same(i, a[i])) { ans++; }
	}
	ct(ans);

	return 0;
}

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

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int K = 100*100+123;
const int N = 300+5;
const int LG = 20;
const int MOD = 1000*1000*1000+7;

int n;
int a[5];


double memo[N][N][N];

double solve(int c0, int c1, int c2, int c3){
    if(memo[c1][c2][c3] >= 0) return memo[c1][c2][c3];
    if(c1 + c2 + c3 == 0) return 0;

    double res = 0;


    if(c1) res += (c1+0.0)/(n) * (solve(c0+1,c1-1, c2,c3));
    if(c2) res += (c2+0.0)/(n) * (solve(c0,c1+1, c2-1,c3));
    if(c3) res += (c3+0.0)/(n) * (solve(c0,c1, c2+1,c3-1));

    res+= 1;


    res /= 1.0 - (c0+0.0)/n;

    return memo[c1][c2][c3] = res;

}

int main() {
    loop(i,N) loop(j,N) loop(k,N) memo[i][j][k] = -1;

    cin >> n;
    loop(i,n){
        int e;
        cin >> e;
        a[e]++;
    }

    double res = solve(a[0],a[1],a[2],a[3]);


    printf("%.15lf\n",res);
    return 0;
}


Measured memory_bytes: 221952
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int x;
    string s;
    cin >> x >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        int kam = s[i] - 'A' + x;
        kam %= 26;
        cout << (char) ('A' + kam);
    }

    return 0;
}


Measured memory_bytes: 3628
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  for(var i = 0, len = input.length - 1; i < len; i++){
    console.log(primeNumbers[input[i] - 0]);
  }

  
}

function calcPrimeNumbers(){
  var max = 999999;
  var primeNumbers = new Int8Array(max + 1);

  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
    
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }

  var primeNums = new Int32Array(max + 1);
  var sum = 0;
  for(var i = 1; i <= max; i++){
    primeNums[i] += sum + (1 - primeNumbers[i]);
    sum = primeNums[i];
  }
  
  return primeNums;
}

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

int fst[400010], nxt[400010], lst[400010], des[400010];
int q[400010], s[400010][2], vis[400010], cnt = 0;
char st[400010];

void add(int u, int v) {
	if (!fst[u]) fst[u] = ++cnt;
	else nxt[lst[u]] = ++cnt;
	lst[u] = cnt, des[cnt] = v;
}

int main() {

	int n, m; scanf("%d%d", &n, &m);
	scanf("%s", st + 1);
	for (int i = 1; i <= m; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		add(u, v), add(v, u);
		s[u][st[v] - 'A'] ++;
		s[v][st[u] - 'A'] ++;
	}
	int sum = 0, r = 0, l = 0;
	for (int i = 1; i <= n; ++i)
		if (!s[i][0] || !s[i][1]) 
			q[++r] = i, vis[i] = 1, sum ++;
	while (l <= r) {
		for (int i = fst[q[l]]; i; i = nxt[i])
			if (!vis[des[i]]) {
				s[des[i]][st[q[l]] - 'A'] --;
				if (!s[des[i]][0] || !s[des[i]][1]) {
					vis[des[i]] = 1;
					q[++r] = des[i];
					sum ++;
				}
			}
		++ l;
	}
	if (sum < n) puts("Yes");
	else puts("No");
	return 0;

}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)

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

    ll A[N], tmpMax = 0, sum = 0;
    REP(i, N) {
        cin >> A[i];
        if(A[i] <= tmpMax) {
            sum += tmpMax - A[i];
        } else {
            tmpMax = A[i];
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 5084
#include <bits/stdc++.h>
using namespace std;
int a[8];
int main (){
	for (int i=1;i<=7;i++) scanf ("%d",&a[i]);long long ans=0;
	if (((a[1]&1)+(a[4]&1)+(a[5]&1)>=2)&&(a[1]&&a[4]&&a[5])) ans+=3,a[1]--,a[4]--,a[5]--;
	printf ("%lld",ans+a[2]+a[1]/2*2ll+a[4]/2*2+a[5]/2*2);
	return 0;
}


Measured memory_bytes: 256
s = gets.chomp
if (s =~ /^.*keyence$/ ||
    s =~ /^k.*eyence$/ ||
    s =~ /^ke.*yence$/ ||
    s =~ /^key.*ence$/ ||
    s =~ /^keye.*nce$/ ||
    s =~ /^keyen.*ce$/ ||
    s =~ /^keyenc.*e$/ ||
    s =~ /^keyence.*$/)
  puts "YES"
else
  puts "NO"
end

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

int main(void){
  
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    
    if(B < D){
        if(C <= A && B <= D) cout << B - A << endl;
        else if(B < C) cout << 0 << endl;
        else cout << B - C << endl;
    }
    else{
        if(A <= C && D <= B) cout << D - C << endl;
        else if(D < A) cout << 0 << endl;
        else cout << D - A << endl;
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  for(int i = 0;i <= 7;i++) {
    string bef = S.substr(0,i);
    string aft = S.substr(S.size()-7+i,7-i);
    if(bef + aft == "keyence") {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int r = in.nextInt();
            out.println(r * r * 3);
        }

    }
}



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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vl a(n);
    const int DMX = 40;
    vector<vl> digitcnt(2,vl(DMX,0)); //[0 or 1][桁] = 個数
    REP(i,n){
        cin>>a[i];
        REP(j,DMX){
            //if(a[i] >= (1LL<<j))
                digitcnt[(a[i]>>j) & 1][j]++;
        }
    }

    //DEBUG_VEC(digitcnt[0]);
    //DEBUG_VEC(digitcnt[1]);

    ll x=0;
    FORR(i,0,DMX){
        ll dval = 1LL<<i;
        //DEBUG2(i, dval);
        //0を置くことを優先する
        if(digitcnt[0][i] > digitcnt[1][i] && (x | dval) <= k){
            x += dval;
        }
        //DEBUG(x);
    }

    ll ans=0;
    REP(i,n) ans+=a[i]^x;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    int N,K,A[200010]={},b[200010]={},c=0;
    cin>>N>>K;

    for(int i=0;i<N;i++){
        cin>>A[i];
        if(b[A[i]]==0)c++;
        b[A[i]]++;
    }

    sort(b,b+200010,greater<int>());

    int sum=0;
    int x=0;

    while(1){
        x++;
        if(x>=K){
            sum+=b[x];
        }

        if(b[x]==0)break;
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795


typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 100500

int n, k;
int f[MAXN];
int h[MAXN];


int main() {
    scanf("%i%i", &n, &k);
    for(int i = 0; i < n; ++i) scanf("%i", &h[i]);
    fill(f + 1, f + n, 2000000000);


    for(int i = 0; i < n; ++i) {
        for(int j = 1; j <= k; ++j)
            f[i + j] = min(f[i + j], f[i] + abs(h[i] - h[i + j]));
    }

    printf("%i\n", f[n - 1]);

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include <stdlib.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
	int w,h,n,x[102],y[102],a[102];
	scanf("%d %d %d",&w,&h,&n);
//	int *tbl = (int*)malloc(sizeof(int)*w*h);
	int tbl[w][h];
	FOR(i,0,w) FOR(j,0,h) tbl[i][j] = 0;
	FOR(i,0,n){
		scanf("%d %d %d",&x[i],&y[i],&a[i]);
		if(a[i] == 1) FOR(k,0,x[i]) FOR(j,0,h) 	  tbl[k][j] = 1;
		if(a[i] == 2) FOR(k,x[i],w) FOR(j,0,h) 	  tbl[k][j] = 1;
		if(a[i] == 3) FOR(k,0,w)    FOR(j,0,y[i]) tbl[k][j] = 1;
		if(a[i] == 4) FOR(k,0,w)    FOR(j,y[i],h) tbl[k][j] = 1;
	}

	int ans = 0;
	FOR(i,0,w) FOR(j,0,h) if(tbl[i][j] == 0) ans++;
	printf("%d\n",ans);
//	FOR(j,0,h){
//		FOR(i,0,w){
//			printf("%d",tbl[i][j]);
//		}
//		printf("\n");
//	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

int main() {

	int a, b, c;

	cin >> a >> b >> c;
	
	if(a<=5){
		cout << 0;
	}
	else if(a>=13){
		cout << b;
	}
	else cout << b / 2;
	
	

}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int H ,W,i,j;

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

    for (j=1; j<=H; j++) {
      for(i=1; i<=W; i++) {
	if(j == 1 || j == H) {
	  printf("#");
	} else if (j !=1 && j !=H && i==1 || i==W) {
	  printf("#");
	} else {
	  printf(".");
	}
      }

      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
# https://atcoder.jp/contests/abc144/tasks/abc144_a
# -*- coding: utf-8 -*-

input_val = list(map(int, input().strip().split()))

if input_val[0] < 10 and input_val[1] < 10:
    cal_val = input_val[0] * input_val[1]
else:
    cal_val = -1

print(cal_val)



Measured memory_bytes: 2940
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-3-4 20:56:04
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int N;
  cin >> N;
  cout << N / 3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;


int main(void){
    int d;
    cin >> d;
    if(d == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    }else if(d == 24){
        cout << "Christmas Eve" << endl;
    }else if(d == 25){
        cout << "Christmas" << endl;
    }
}


Measured memory_bytes: 256
import sys, math

n,m = [int(x) for x in sys.stdin.readline().split()]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

s = [LI() for _ in range(n)]
p = [LI() for _ in range(m)]

def manhattan(a,b):
	return math.fabs(a[0]-b[0]) + math.fabs(a[1]-b[1])

def nearest(a):
	r = 1
	d = manhattan(a,p[0])
	for (i,x) in enumerate(p):
		pd = manhattan(a,x)
		if pd<d:
			r = i+1
			d = pd
	return r

for (i,x) in enumerate(s):
	print(nearest(x))

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

int main(){
   
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    vector<long long int> A(X,0),B(Y,0),C(Z,0);
    for(int i=0;i<X;i++){
        cin>>A[i];
    }
    /*sort(A.begin(),A.end());
    reverse(A.begin(),A.end());*/
    for(int i=0;i<Y;i++){
        cin>>B[i];
    }
    /*sort(B.begin(),B.end());
    reverse(B.begin(),B.end());*/
    for(int i=0;i<Z;i++){
        cin>>C[i];
    }
    /*sort(C.begin(),C.end());
    reverse(C.begin(),C.end());*/
    vector<long long int> D(X*Y,0);
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            D[i*Y+j]=A[i]+B[j];
        }
    }
    sort(D.begin(),D.end());
    reverse(D.begin(),D.end());
    vector<long long int> E((min(X*Y,K))*Z,0);
    for(int i=0;i<min(X*Y,K);i++){
        for(int j=0;j<Z;j++){
            E[i*Z+j]=D[i]+C[j];
        }
    }
    sort(E.begin(),E.end());
  reverse(E.begin(),E.end());
    for(int i=0;i<K;i++){
        cout<<E[i]<<endl;
    }
}


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

int main() {
  int N,T;
  cin >> N >> T;
  vector<int> map(N);
  int now = 0;
  int big = 0;
  int ans = 0;
  cin >> map[0];
  for (int i=1; i<N; i++) {
    cin >> map[i];
    now += (map[i] - map[i-1]);
    now = max(now,0);
    big = max(big,now);
  }
  now = 0;
  for (int i=1; i<N; i++) {
    now += (map[i] - map[i-1]);
    now = max(now,0);
    cerr << now << endl;
    if (big == now) {
      ans++;
    }
  }
  cout << ans << endl;
  cerr << big << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)					(a).begin(),(a).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(1000 * 1000 * 1000 * 2)
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	ll x;
	cin >> x;
	ll ans = (x / 11) * 2;
	ll amari = x % 11;
	if (7 <= amari) {
		ans += 2;
	} else if (1 <= amari) {
		ans += 1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <functional>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#ifndef M_PI
#define M_PI 3.141592653589793238462643383279
#endif

#define int long long

#define mp make_pair
#define mt make_tuple
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()
#define get0 get<0>
#define get1 get<1>
#define get2 get<2>
#define get3 get<3>

#define debug(x) cerr << #x << " = " << x << ", line = " << __LINE__ << endl

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef tuple<long long, long long, long long> tlll;
typedef tuple<int, int, int> tiii;
typedef tuple<int, int, int, int> tiiii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MOD = 1e9 + 7;



int32_t main()
{
#ifdef chikibambony
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int j = 0; j < n; ++j) {
        cin >> b[j];
    }
    reverse(all(b));
    int c = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i] == b[i]) {
            c = a[i];
            break;
        }
    }
    int l = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == c && b[i] == c) {
            l = i;
            break;
        }
    }
    int r = -1;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] == c && b[i] == c) {
            r = i;
            break;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (a[i] != c && b[i] != c && l <= r) {
            swap(b[i], b[l]);
            ++l;
        }
    }

    if (l <= r) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";

    for (int i = 0; i < n; ++i) {
        cout << b[i] << ' ';
        assert(b[i] != a[i]);
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 6376
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  1000005
#define endl "\n"
using namespace std;
vector<ll>g[MAXN];
vector<ll>visit(MAXN);
ll dfs(ll node){
    if(visit[node]!=0)
        return visit[node];
    //cout<<node<<endl;
    visit[node]=1;
    ll ans=0;
    for(auto it=g[node].begin();it!=g[node].end();it++){
      ans=max(ans,1+dfs(*it));
    }
    return visit[node]=ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,a,b;
    cin>>n>>m;
    for(ll i=0;i<m;i++){
        cin>>a>>b;
        g[a].pb(b);
    }
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans=max(ans,dfs(i));
        //cout<<"v="<<visit[i]<<endl;
    }
    cout<<ans<<endl;



    return 0;
}



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

int main() {
    int n, sum;
    cin >> n;
    int x = n;
    while (x > 0) {
        sum += x % 10;
        x /= 10;
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f[200005];
int main()
{
    ll a,b,i;
    cin>>a;
    b=1;
    ll c=0;
    for(i=0;i<a;i++)
    {
        cin>>f[i];
        if(f[i]==b)
        {b++;
        c=1;}
    }
    if(c==0)cout<<"-1"<<endl;
    else cout<<a+1-b<<endl;


    return 0;
}


Measured memory_bytes: 1792
import qualified Data.ByteString.Char8 as BC

main = do
  stone <- BC.getLine
  let white = length . filter (/="") . map BC.unpack . BC.split 'B' $ stone
      black = length . filter (/="") . map BC.unpack . BC.split 'W' $ stone
  print $ white + black - 1



Measured memory_bytes: 1148
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
  char buf[100000];
  scanf("%s", buf);
  int i, count1=0, count2=0;
  for(i=0; i<strlen(buf); i++) {
    if(i % 2 == 0) {
      if(buf[i] != '0') {
        count1++;
      }
      else {
        count2++;
      }
    }
    else {
      if(buf[i] != '1') {
        count1++;
      }
      else {
        count2++;
      }
    }
  }
  if(count1 <= count2) {
    printf("%d\n", count1);
  }
  else {
    printf("%d\n", count2);
  }
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
H, W, N = map(int, input().split())
c = Counter()
for _ in range(N):
    a, b = map(int, input().split())
    for i in range(3):
        for j in range(3):
            if 1 <= a - i <= H - 2 and 1 <= b - j <= W - 2:
                c[a - i, b - j] += 1
ans = Counter(c.values())
print((H - 2) * (W - 2) - sum(ans.values()))
for i in range(1, 10):
    print(ans[i])

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

template <typename T>
void print_vector(vector<T>& vec) {
    cout << "print_vector -> ";
    for(int i=0; i<vec.size(); i++) {
        if(i == vec.size()-1) {
            cout << vec[i] << endl;
        }
        else {
            cout << vec[i] << " ";
        }
    }
    return;
}

int n, m, q;

vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

void dfs(vector<int> A, unsigned long long *ans) {

    if(A.size() == n+1) {

        unsigned long long temp_ans = 0;
        for(int i=0; i<q; i++) {
            if(A[b[i]] - A[a[i]] == c[i]) temp_ans += d[i];
        }
        if(temp_ans > *ans) {
            *ans = temp_ans;
        }

        return;
    }

    A.push_back(A.back());
    while(A.back() <= m) {
        dfs(A, ans);
        A.back()++;
    }

}

int main() {

    cin >> n >> m >> q;

    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    for(int i=0; i<q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    
    unsigned long long ans = 0;
    dfs(vector<int>(1,1), &ans);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define xh1(a,b) for(int i=a;i<b;i++)
#define xh2(a,b) for(int j=a;j<b;j++)
#define stlbl(a) for(it=a.begin();it!=a.end();it++)
#define dzkt int T;cin>>T;while(T--)
#define mst(a,i) memset(a,i,sizeof(a))
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=2e5+10,inf=1e9+10,mod=1e9+7;
ll pow2(ll a,ll b) {ll s=1; while(b) {if(b&1) s=(s*a); a=(a*a); b/=2; } return s;}
int gcd(int a,int b) {return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) {return a/gcd(a,b)*b; }
ll prime(ll x) {for(ll i=2;i<=sqrt(x+0.5);i++) if(x%i==0) return 0; return 1; }

char ch[N];
vector<ll> vec;

ll a[N],n,x;
int main()
{
    iosks;
    cin>>n>>a[0];x=a[0];
    xh1(1,n) cin>>a[i],x^=a[i];
    xh1(0,n) cout<<(x^a[i])<<' ';cout<<endl;
    return 0;
}

Measured memory_bytes: 5220
N, X, Y = map(int, input().split())

X -= 1
Y -= 1
d = [0]*10000
for i in range(N):
  for j in range(i+1, N):
    c = min(j-i, abs(X-i) + 1 + abs(Y-j))
    d[c] += 1
    
for i in range(1, N):
  print(d[i])

Measured memory_bytes: 3444
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
// #define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const ll maxn = 2e5 + 5;
ll f[maxn],Count,n;
ll popcount[maxn];
char s[maxn];
ll k[2];
void get(ll ss)
{
	ll p = 1;
	if(ss == 0)
	{
		p = -1;
	}
	if(Count + p == 0)
	{
		return;
	}
	ll ret = 0;
	for(ll i = 0;i < n; ++i)
	{
		ret = (ret << 1) + s[i] - '0';
		ret %= (Count + p);
	}
	k[ss] = ret;
}
ll mypow(ll a,ll b,ll c)
{
	ll ret = 1;
	for(;b;b >>= 1,a = a * a % c)
	{
		if(b & 1)
		{
			ret = ret * a % c;
		}
	}
	return ret;
}
int main(int argc, char const *argv[])
{
	//pre f(x) between 1 and 2e5
	popcount[0] = 0;
	for(ll i = 1;i < maxn; ++i)
	{
		popcount[i] = popcount[i >> 1] + (i & 1);
	}
	for(ll i = 1;i < 10; ++i)
	{
		debug("pop[%lld] = %lld\n",i,popcount[i]);
	}
	f[0] = 0;
	for(ll i = 1;i < maxn; ++i)
	{
		f[i] = 1 + f[i % popcount[i]];
	}
	for(ll i = 1;i < 10; ++i)
	{
		debug("f[%lld] = %lld\n",i,f[i]);
	}
	scanf("%lld%s",&n,s);
	debug("%s\n",s);
	for(ll i = 0;i < n; ++i)
	{
		Count += s[i] - '0';
	}
	get(0);
	get(1);
	debug("ok\n");
	for(ll i = 0;i < n; ++i)
	{
		if(s[i] == '0')
		{
			printf("%lld\n",f[(k[1] + (mypow(2,n - i - 1,Count + 1))) % (Count + 1)] + 1);
		}
		else
		{
			if(Count == 1)
			{
				printf("0\n");
			}				
			else
			{
				printf("%lld\n",f[(k[0] - (mypow(2,n - i - 1,Count - 1)) + Count - 1) % (Count - 1)] + 1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 7048
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define LD long double

LL MOD = 1000000007;

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

    int red_ = 0;

    for(int i = 0; i < n; ++i){
        if(s[i] == 'R'){
            red_++;
        }
    }

    int Lwhite = 0;

    for(int i = 0; i < red_; ++i){
        if(s[i] == 'W'){
            Lwhite++;
        }
    }

    cout << Lwhite << endl;

    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const int mod=1000000007;    
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

vector<int> v[100001],res[100001];
int dp(int x){
  if(v[x].empty())return 0;
  rep(i,v[x].size()){
    res[x].push_back(dp(v[x][i]));
    }
  sort(res[x].begin(),res[x].end());
  reverse(res[x].begin(),res[x].end());
  int ret=0;
  rep(i,res[x].size())
    ret=max(res[x][i]+1+i,ret);
  return ret;
  }

int main(){
  int n;cin>>n;
  rep(i,n-1){
    int a;cin>>a;
    v[a-1].push_back(i+1);
    }
  cout<<dp(0)<<endl;
  return 0;                     
  }


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

int main()
{
	int n;
	std::vector<int> vec;
	std::cin >> n;

	for (int i = 0; i < n; i++) {
		int m;
		std::cin >> m;
		vec.push_back(m);
	}

	for (int j = n - 1; j >= 0; j--) {
		std::cout << vec[j];
		if (j != 0)
			std::cout << " ";
	}
	std::cout << std::endl;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,n,a;
	cin >> h >> n;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		h-=a;
	}
	if(h>0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;

const ll MOD = 1000 * 1000 * 1000 + 7;


ll f(int n) {
    ll res = 1;
    for (int i = 1; i <= n; i++)
        res = res * i % MOD;
    return res;
}

int main() {
#ifdef LOCAL
    // freopen("input", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(12);
    int n, m;
    cin >> n >> m;
    if (n < m)
        swap(n, m);
    if (n > m + 1) {
        cout << 0 << '\n';
        return 0;
    }
    ll res = n == m ? 2 : 1;
    res *= f(n);
    res %= MOD;
    res *= f(m);
    res %= MOD;
    cout << res << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using namespace std;
using pii=pair<int,int>;

const int MOD=1e9+7;

int n,m,dp[2][301][301];
vector<pii> a[301];

int main() {
	scanf("%d%d",&n,&m);
	for(int i=0,l,r,v;i<m;i++) {
		scanf("%d%d%d",&l,&r,&v);
		a[r].push_back({l,v});
	}

	int cur=1,pr=0;
	dp[0][0][0]=1;
	
	for(int i=1;i<=n;i++) {
		for(int j=0;j<=i;j++) for(int k=0;k<=i;k++) dp[cur][j][k]=0;
		for(int j=0;j<i;j++) for(int k=0;k<i;k++) {
			dp[cur][j][k] = (dp[cur][j][k] + dp[pr][j][k])%MOD;
			dp[cur][i-1][j] = (dp[cur][i-1][j] + dp[pr][j][k])%MOD;
			dp[cur][i-1][k] = (dp[cur][i-1][k] + dp[pr][j][k])%MOD;
		}
		for(int j=0;j<i;j++)for(int k=0;k<i;k++) {
			for(auto &v:a[i]) {
				int c=1;
				if(j >= v.fi) c++; 
				if(k >= v.fi) c++;
				if(c!=v.se) dp[cur][j][k]=0;
			}
		}
		swap(cur,pr);
	}

	int ans=0;
	for(int j=0;j<n;j++) for(int k=0;k<n;k++) ans=(ans+dp[pr][j][k])%MOD;
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>


int main(void)
{
  int r, c;
  scanf("%d %d", &r, &c );
  
  int a[r+1][c+1];
  int i, j;
  
  for( j = 0; j <= c; j++ ){
    a[r][j] = 0;
  }
  
  for( i = 0; i < r; i++ ){
    a[i][c] = 0;
    for( j = 0; j < c; j++ ){
      scanf("%d", &a[i][j] );
      a[i][c] += a[i][j];
      a[r][j] += a[i][j];
    }
    
    a[r][c] += a[i][c];
  }
  
  for( i = 0; i <= r; i++ ){
    for( j = 0; j <= c; j++ ){
      if( j ) printf(" %d", a[i][j]);
      else {  printf("%d", a[i][j] );}
    }
    puts("");
  }
  
  
 
  return 0;

 
}       

Measured memory_bytes: 652
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp> //__gnu_pbds::priority_queue
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 200000;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

char st[N + 5];
int n;

bool chk(int x) {
    for(int i = n - x + 1; i < x; ++i) {
        if(st[i] != st[i-1]) return false;
    }
    return true;
}

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif 

    scanf("%s", st);
    n = strlen(st);

    int l = 1, r = n, ans = -1;
    while(l <= r) {
        int mid = (l + r) / 2; 
        if(chk(mid)) l = mid + 1, ans = mid; else r = mid - 1;
    }
    printf("%d\n", ans);

    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i];}cerr << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, x;
    cin >> n >> x;

    ll a[n];
    rep(i, n) cin >> a[i];

    sort(a,a+n);

    ll cnt = 0;
    ll i = 0;
    while(x >= a[i]){
        if(i == n-1){
            if(a[i] == x) ++cnt;
            break;
        }
        else{
            x -= a[i];
            ++cnt;
            ++i;
        }
    }


    ppp(cnt);

    return 0;
}


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

int main(){
    int card[4][13],n,rank;
    char suit;
    cin>>n;
    
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            card[i][j]=0;
        }
    }
            
    for(int i=0; i<n; i++){
        cin>>suit>>rank;
        if(suit=='S') card[0][rank-1]=1;
        if(suit=='H') card[1][rank-1]=1;
        if(suit=='C') card[2][rank-1]=1;
        if(suit=='D') card[3][rank-1]=1;
    }
    
    for(int i=0; i<4; i++ ){
        for(int j=0; j<13; j++){
            if ( card[i][j] == 1 ) continue;
            if(i==0) cout<<'S';
            if(i==1) cout<<'H';
            if(i==2) cout<<'C';
            if(i==3) cout<<'D';
            cout<<' '<<j+1<<endl;
        }
    }
    
    
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)

int main(){
    int n; string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n-2){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var i = 0;
 var tmp = 0;
 while(true){
   var num = lines[i].split(' ');
   if(num[0] == 0 && num[1] == 0){
     break;
   }
   var newnum = num.map(function(str) { return Number(str)});

   if(newnum[0] > newnum[1]){
     tmp = newnum[0];
     newnum[0] = newnum[1];
     newnum[1] = tmp;
   }
   console.log(newnum.join(' '));
   
   i++;
 }
});


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

using namespace std;

int main(){
    int l;
    long long ans,sum;
    string S,s_num;

    const int nmax = 10;
    cin >> S;
    l = (int)S.length();

    ans = 0;
    for(int i = 0;i < (1 << (l-1));i++){
        bitset<nmax> bit(i);
        sum = 0;
        s_num = "";
        int j = 0;
        while(j < l){
            s_num += S[j];
            if(bit.test(j)){
                sum += atol(s_num.c_str());
                s_num = "";
            }
            j++;
            if(j == l){
                sum += atol(s_num.c_str());
            }
        }
        ans += sum;
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int m;
  cin>>m;
  ll D=0, S=0;
  rep(i,m){
    ll d,c;
    cin>>d>>c;
    S+=d*c;
    D+=c;
  }
  ll ans=(D-1)+(S-1)/9;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main(){

    int N;
    cin>>N;

    while(N>9) N-=10;

    if(N==3)    cout<<"bon"<<endl;
    else if(N==0||N==1||N==6||N==8) cout<<"pon"<<endl;
    else if(N==2||N==4||N==5||N==7||N==9)   cout<<"hon"<<endl;

    
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int digit = 0;
    int n=0;
    for(int i=0;i<s.size();i++){
        n *=10;
        n += s[i]-'0';
        digit += s[i]-'0';
    }
    //cout << n <<endl;
    //cout << digit << endl;
    if(n%digit == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = [ int(x) for x in input().split() ]
ab_s = [ [ int(x) for x in input().split() ] for _ in range(N) ]
cds = [ [ int(x) for x in input().split() ] for _ in range(M) ]

ans = []
for i in range(N):
    a, b = ab_s[i]
    r = -1
    d_min = -1
    for j in range(M):
        c, d = cds[j]
        distance = abs(a - c) + abs(b - d)
        if d_min < 0 or d_min > distance:
            r = j
            d_min = distance
    ans.append(r + 1)

print("\n".join(map(str, ans)))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  string S; cin>>S;
  int s_size=S.size();
  for(int i=0;i<s_size;i++){
    S.pop_back();
    if(S.size()%2!=0) continue;
    int temp=S.size()/2;
    string A=S.substr(0,temp),B=S.substr(temp,temp);
    if(A==B) break;
  }

  cout<<S.size()<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	double r;
	cin>>r;
	cout<<fixed<<showpoint<<setprecision(1919)<<r * r * 3.141592653589793238462643383279<<" "<<2 * r * 3.141592653589793238462643383279<<endl;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll ans = 0;
  rep(i, n-1) {
    if (v.at(i) == v.at(i+1)) {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
#define pi 3.1415926
int main(void)
{
    int n, m,sum=0;
    cin >> n >> m;
    while(m--){
        int q;
        cin >> q;
        sum += q;
    }
    if(sum>n)
        cout << -1 << endl;
    else
        cout << n - sum << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define N 13
#define pi M_PI

int main(){
   double a,b,rad;
   scanf("%lf %lf %lf ",&a,&b,&rad);
   double S,L,h;
   h=b*sin(rad*pi/180);
   S=a*h/2;
   L=a+b+sqrt(a*a+b*b-2*a*b*cos(rad*pi/180));
   printf("%f\n",S);
   printf("%f\n",L);
   printf("%f\n",h);
   return 0;
}


Measured memory_bytes: 2100
$%{0}=0;$A=<>,map($C|=1<<$_-1,glob<>),$C=!map+($%{$_|$C}//=9e9)-=$-=$%{$_|$C}-$A-$%{$_},keys%%for<>=~$"..$';print$%{2**$`-1}//-1

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<int>());
  map<int, int> mp;
  mp[A[0]]++;
  queue<int> que;
  que.push(A[0]);
  int64_t res = 0;
  for (int i = 1; i < N; i++) {
    if (mp[A[i]] == 0) que.push(A[i]);
    if (mp[que.front()] != 0) {
      if (que.front() == A[i]) {
        mp[que.front()]++;
      } else {
        mp[que.front()]--;
        mp[A[i]] += 2;
      }
      res += que.front();
    } else {
      que.pop();
      i--;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 14284
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.nextLine();
    String b = sc.nextLine();
    if (a.equals(b.substring(0,a.length())) && a.length() +1 == b.length()){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }

}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int t,p,r;
  while(true){
    cin >> t >> p >> r;//???????????°???????????°?????¬???????????°
    if(t==0) break;
    int seikai[t+1]={0},penalty[t+1]={0},gotou[t+1][p+1]={0};
    for(int i=0;i<r;i++){
      int tID,pID,time;
      string s;
      cin >> tID >> pID >> time >> s;
      if(s=="CORRECT"){
        seikai[tID]++;
        penalty[tID] += gotou[tID][pID]*1200+time;
      }
      else{
        gotou[tID][pID]++;
      }
    }
    bool checked[t+1]={false};
    for(int i=1;i<=t;i++){
      int team,seikaimax=-1,pena=INF;
      for(int j=1;j<=t;j++){
        if(!checked[j]){
          if(seikaimax<seikai[j]){
            seikaimax=seikai[j];
            team=j;
            pena=penalty[j];
          }
          else if(seikaimax==seikai[j]){
            if(pena>penalty[j]){
              team=j;
              pena=penalty[j];
            }
          }
        }
      }
      checked[team]=true;
      cout << team <<" " << seikaimax <<" " << pena << endl;
    }
  }
}

Measured memory_bytes: 3228