akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//#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>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=10005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	int f[N];
	int n;
	mem(f,0);
	cin>>n;
	FORQ(1,205){
		for(int j=1;j<=205;j++){
			for(int k=1;k<=205;k++){
				int sm=i*i+j*j+k*k+i*j+i*k+j*k;
				if(sm<=n) f[sm]++;
			}
		}
	}
	FORQ(1,n) cout<<f[i]<<endl;
}



Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x;
    cin >> x;
    ll y=x/11;
    x-=y*11;
    y*=2;
    if(0<x&&x<=6){
        y++;
    }
    else if(x>6){
        y+=2;
    }
    cout << y << endl;
}

Measured memory_bytes: 3660
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val a=(1..n).map { readLine()!!.toInt()-1 }
    val visited = BooleanArray(n){ false }
    visited[0]=true

    var light=0
    var count=0
    while (light!=1){

        light=a[light]
        count++
        if(visited[light]){
            println(-1)
            return
        }else{
            visited[light]=true
        }
    }
    println(count)
}

Measured memory_bytes: 41016
/* ***********************************************
Author        :yang12138
Created Time  :2017/11/12 19:36:26
File Name     :D.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;

const int N=2005;
int a[N];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

	int n,z,w;
	scanf("%d%d%d",&n,&z,&w);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	if(n==1){
		printf("%d\n",abs(w-a[1]));
	}
	else{
		printf("%d\n",max(abs(a[n-1]-a[n]),abs(a[n]-w)));
	}
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}


//深さ優先探索
void dfs(vector<string> &m,vector<vector<bool>> &seen, ll x, ll y, ll h, ll w){

	seen[y][x]=true;

	
	for(ll i=0;i<4;i++){
		ll nx=x,ny=y;
		if(i==0){ //up
			ny=y-1;
		}
		else if(i==1){ //down
			ny=y+1;
		}
		else if(i==2){ //right
			nx=x+1;
		}
		else{ //left
			nx=x-1;
		}

		if(nx<0 || nx>=w || ny<0 || ny>=h){
			continue;
		}
		if(seen[ny][nx]){
			continue;
		}
		
		if(m[ny][nx]=='#'){
			continue;
		}

		dfs(m,seen,nx,ny,h,w);
	}
}


void solve(){
	
	ll h,w;
	cin>>h>>w;

	ll sy=0,sx=0,gy=h-1,gx=w-1;
	

	vector<string> m(h);
	for(ll i=0;i<h;i++){
		cin>>m[i];
	}

	ll b=0;

	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(m[i][j]=='#'){
				b++;
			}
		}
	}
	
	queue<pair<ll,ll>> que;
	que.push({sy,sx});

	vector<vector<ll>> dis(h,vector<ll> (w,-1)); //-1：未訪問
	dis[sy][sx]=0;

	ll dx[4]={1,-1,0,0};
	ll dy[4]={0,0,1,-1};

	while(que.size()){
		ll y=que.front().first;
		ll x=que.front().second; //先頭を見る

		for(ll i=0;i<4;i++){
			ll nx=x+dx[i];
			ll ny=y+dy[i];

			if(ny>=h || ny<0 || nx>=w ||nx<0){
				continue;
			}
			if(m[ny][nx]=='#'){
				continue;
			}
			if(dis[ny][nx]!=-1){
				continue;
			}

			dis[ny][nx]=dis[y][x]+1;

			que.push({ny,nx});

		}

		que.pop();

	}

	if(dis[gy][gx]==-1){
		cout<<-1<<endl;
	}
	else{
		cout<<h*w-b-(dis[gy][gx]+1)<<endl;
	}
	
}

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


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

using namespace std;
using ll = long long;

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

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

  int n = s.size();
  int ans = 0;
  rep(i, n / 2) {
    if (s[i] != s[n - i - 1]) ++ans;
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int main() {
	// your code goes here
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	n = s.size();
	vector<int> cnt(n + 1);
	vector<int> ans(n);
	for (int i = 0; i < n; i++) cnt[i] = (s[i] == 'L');
	
	int cntL = 0 , cntR = 1;
	for (int i = 1; i <= n; i++){
	    if (!cnt[i] && cnt[i - 1]){
	        ans[i - cntL] = (cntL + 1)/2 + cntR/2;
	        ans[i - cntL - 1] = (cntR + 1)/2 + cntL/2;
	        //cout << i << ' '<< cntL << ' ' << cntR << '\n';
	        cntR = 0, cntL = 0;
	    }
	    cntR += !cnt[i]; cntL += cnt[i];
	}
	for (int i = 0; i < n; i++) cout << ans[i] << ' ';
	return 0;
}


Measured memory_bytes: 1488
import math
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

operation_num = sum(b) - sum(a)
x = 0 # 操作回数
y = 0
z = 0
for i in range(n):
    x += b[i]-a[i]
    y += max(a[i]-b[i], 0)
    z += max(math.ceil((b[i]-a[i])/2), 0)
# print(x, y)
if x - y < 0 or x - z < 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 10472
#include<stdio.h>
#include<string.h>
int main(void){
    char s[101], x[101];
    int n, i;
    scanf("%s",&s);
    n = strlen(s);
    for(i=0;i<n;i++){
        x[i] = 'x';
    }
    x[n] = '\0';
    printf("%s\n", x);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String n = sc.next();
        int count = n.charAt(0) == 'o' ? 1 : 0;
        count += n.charAt(1) == 'o' ? 1 : 0;
        count += n.charAt(2) == 'o' ? 1 : 0;
        System.out.println(count * 100 + 700);
    }
}

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

struct E {
  int w;
  int l;
  char c;
  const bool operator<(const E &obj) const {
    if (w > obj.w) {
      return true;
    } else if (w < obj.w) {
      return false;
    } else {
      if (l < obj.l) {
        return true;
      } else {
        return false;
      }
    }
  }
};

int N;
E a[10];

bool input() {
  cin >> N;
  if (!N) {
    return false;
  }
  for (int k = 0; k < N; ++k) {
    E e;
    cin >> e.c;
    e.w = e.l = 0;
    for (int i = 0; i < N - 1; ++i) {
      int t;
      cin >> t;
      if (t == 0) {
        ++e.w;
      } else if (t == 1) {
        ++e.l;
      }
    }
    a[k] = e;
  }
  return true;
}

int main() {
  while (input()) {
    stable_sort(a, a + N);
    for (int i = 0; i < N; ++i) {
      cout << a[i].c << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3052
N, A, B, C = map(int, input().split())
l = []
for i in range(N):
    x = int(input())
    l.append(x)
ans = float("inf")
def dfs(depth, li):
    if depth == N:
        if len(li[0]) > 0 and len(li[1]) > 0 and len(li[2]) > 0:
            global ans
            x = abs(sum(li[0]) - A) + abs(sum(li[1]) - B) + abs(sum(li[2]) - C) + max(0, 10*(len(li[0])-1)) + max(0, 10*(len(li[1])-1)) + max(0, 10*(len(li[2])-1))
            if x < ans:
                ans = x

    else:
        dfs(depth + 1, [li[0]+[l[depth]]]+li[1:])
        dfs(depth + 1, li[:1]+[li[1]+[l[depth]]]+li[2:])
        dfs(depth + 1, li[:2]+[li[2]+[l[depth]]]+li[3:])
        dfs(depth + 1, li[:3]+[li[2]+[l[depth]]])


dfs(0, [[],[],[],[]])
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
ll INF=1000000000000000;
ll mod=1000000007;
ll i,j,k,l;

vector<ll> sum;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return (s[j]-s[i]);
}

int main(){
    ll n,m;cin>>n>>m;
    vector<ll> a(n);
    for(i=0;i<n;i++){
        cin>>a[i];
    }

    pre_process(a,sum);//累積和の作成→2つsumを選んだときにあまりが同じなら条件を満たす
    
    //mod mで分類
    for(i=0;i<=n;i++){
        sum[i]%=m;
    }

    sort(sum.begin(),sum.end());//同じあまりのものを数えたいのでsort
    
    ll same_mod=1;
    vector<ll> same;
    for(i=0;i<n;i++){//同じあまりのものを探す
        if(sum[i]==sum[i+1]){
            same_mod++;//同じあまりのものの個数
            if(i==n-1){same.push_back(same_mod);}
        }else{
            same.push_back(same_mod);
            same_mod=1;
        }
    }

    ll ans=0;
    for(i=0;i<same.size();i++){//同じあまりのものから2つとるのでnC2
        ans+=same[i]*(same[i]-1)/2;
    }

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

Measured memory_bytes: 2428
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

vector<int> ans;
void f(vector<int> a)
{
    if(a.empty()) return;
    int max_num = 0;
    REP(i, a.size())
    {
        if(i+1 == a[i]) max_num = i+1;
    }

    vector<int> b;
    ans.push_back(max_num);
    REP(i, a.size())
    {
        if(i+1 != max_num) b.push_back(a[i]);
    }
    if(max_num == 0)
    {
        ans.clear();
        return;
    }
    f(b);
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    
    REP(i, n) cin >> a[i];
    f(a);

    if(ans.empty())
    {
        cout << -1 << endl;
        return 0;
    }

    reverse(all(ans));
    REP(i, n)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int n;
	long long int a = 1;
	
    cin >> n;
    
    for(int i = 1;i<=n;i++){
	   a*=i;
       a%=1000000007;
    }
    cout << a << endl;
    
	return 0;
}


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

#include <limits.h>
#include <math.h>

using namespace std;

typedef long long ll;

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

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

void list_candidate(const int N, const vector<int> &A, vector<int> &cands) {
    int sum = 0;
    for (int i = 0; i < (int) A.size(); i++) {
        sum += A[i];
    }

    cands.push_back(1);
    cands.push_back(sum);
    for (int i = 2; i <= (int) sqrt(sum); i++) {
        if (sum % i == 0) {
            cands.push_back(i);
            cands.push_back(sum / i);
        }
    }
    // descending order
    sort(cands.begin(), cands.end(), [](const int &a, const int &b) {
            return a > b;
            });
}

bool try_division(const int N, const int K, const vector<int> &A, const int cand) {
    // cout << "try_division: " << cand << endl;

    vector<int> B(N);
    for (int i = 0; i < N; i++) {
        B[i] = A[i] % cand;
    }
    sort(B.begin(), B.end());

    vector<ll> acc_minus(N);
    acc_minus[0] = B[0];
    for (int i = 1; i < N; i++) {
        acc_minus[i] = acc_minus[i - 1] + B[i];
    }

    // for (int i = 0; i < N; i++) {
    //     cout << acc_minus[i] << " ";
    // }
    // cout << endl;

    vector<ll> acc_plus(N);
    acc_plus[N - 1] = cand - B[N - 1];
    for (int i = N - 2; i >= 0; i--) {
        acc_plus[i] = acc_plus[i + 1] + (cand - B[i]);
    }

    // for (int i = 0; i < N; i++) {
    //     cout << acc_plus[i] << " ";
    // }
    // cout << endl;

    ll min = LONG_LONG_MAX / 2;
    for (int i = 0; i < N - 1; i++) {
        chmin(min, max(acc_minus[i], acc_plus[i + 1]));
        // if (acc_minus[i] == acc_plus[i + 1]) {
        //     if (min > acc_minus[i]) {
        //         min = acc_minus[i];
        //     }
        // }
    }

    return min <= K;
}

int main(void) {
    int N, K;
    cin >> N >> K;

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

    vector<int> cands;
    list_candidate(N, A, cands);
    // for (int i = 0; i < (int) cands.size(); i++) {
    //     cout << cands[i] << endl;
    // }

    for (int i = 0; i < (int) cands.size(); i++) {
        if (try_division(N, K, A, cands[i])) {
            cout << cands[i] << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
w,h,n=[int(x) for x in input().split()]
p=[[int(x) for x in input().split()] for _ in range(n)]

minx=0
maxx=w
miny=0
maxy=h

for i in range(n):
    if p[i][2]==1:
        minx=max(minx,p[i][0])
    if p[i][2]==2:
        maxx=min(maxx,p[i][0])
    if p[i][2]==3:
        miny=max(miny,p[i][1])
    if p[i][2]==4:
        maxy=min(maxy,p[i][1])
w=maxx-minx
h=maxy-miny
print(w*h if w>0 and h>0 else 0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int ans[11];
  if(a<=b)
  {
    while(b--)
    {
      cout<<a;
    }
  }
  else

    {
      while(a--)
      {
        cout<<b;
      }
    }
return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()

#define pb         push_back

#define rotate_swap(x,a,b,c,d) swap(x.a,x.b);swap(x.b,x.c);swap(x.c,x.d);

class Dice{
public:
  int top,front,right,left,back,bottom;
};

void rotate_r(Dice &x){
  rotate_swap(x,top,left,bottom,right);
}

void rotate_l(Dice &x){
  rotate_swap(x,top,right,bottom,left);
}

void rotate_f(Dice &x){
  rotate_swap(x,top,back,bottom,front);
}

void rotate_cw(Dice &x){
  rotate_swap(x,back,left,front,right);
}

void rotate_ccw(Dice &x){
  rotate_swap(x,back,right,front,left);
}

Dice data[24];

void generate_all(Dice x){
  rep(i,6){
    rep(j,4){
      data[i*4+j]=x;
      rotate_cw(x);
    }
    if (i%2 == 0)rotate_r(x);
    else rotate_f(x);
  }
}


Dice ini[3][3][3];
Dice now[3][3][3];
int dx[]={-1, 0,0};
int dy[]={ 0,-1,0};
int dz[]={ 0, 0,-1};

bool isok(int index,int z,int y,int x){
  if (y == 0){//top
    if (ini[z][y][x].top ==0 ||
	ini[z][y][x].top == now[z][y][x].top);
    else return false;
  }else {
    if (now[z][y-1][x].bottom+now[z][y][x].top != 7)return false;
  }

  

  if (z == 0){//front
    if (ini[z][y][x].front ==0||
	ini[z][y][x].front == now[z][y][x].front);
    else return false;
  }else {
    if (now[z-1][y][x].back+now[z][y][x].front != 7)return false;
  }
  
  if (x == 0){
  }else {
    if (now[z][y][x-1].right+now[z][y][x].left != 7)return false;
  }
  return true;
}

int compute_sum(){
  int sum=0;
  rep(i,3){
    rep(j,3){
      sum+=now[i][j][2].right;
    }
  }
  return sum;
}

void search(int level,int cur,vector<int>&ans){
  if (level == 3){
    ans.pb(compute_sum());
    return;
  }


  if (cur == 9){
    search(level+1,0,ans);
    return;
  }
  int y=cur/3,x=cur%3;

  rep(i,24){
    now[level][y][x]=data[i];
    if (isok(i,level,y,x)){
      search(level,cur+1,ans);
    }
    now[level][y][x]=ini[level][y][x];
  }
}


main(){
  Dice a=(Dice){1,2,3,4,5,6};
  generate_all(a);
  rep(i,3){
    rep(j,3){
      rep(k,3){
	ini[i][j][k]=(Dice){0,0,0,0,0,0};
      }
    }
  }

  int te;
  cin>>te;
  while(te--){
    vector<int> ans;
    rep(i,3){
      rep(j,3){
	cin>>ini[i][0][j].top;
      }
    }
    rep(i,3){
      rep(j,3){
	cin>>ini[0][i][j].front;
      }
    }

    search(0,0,ans);
    sort(ALL(ans));
    ans.erase(unique(ALL(ans)),ans.end());
    if (ans.size()== 0){
      cout <<0<<endl;
    }else {
      rep(i,ans.size()){
	if (i)cout <<' ';
	cout << ans[i];
      }
      cout << endl;
    }
  }
  return false;
}

Measured memory_bytes: 1036
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int N, K;

    cin >> N >> K;

    cout << N-K+1 << endl;

    return 0;
}

Measured memory_bytes: 256
def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

h = int(arr_data[0][0])
w = int(arr_data[0][1])

arr=[]
for i in range(1,1+h):
    
    arr_temp=[]
    for v in arr_data[i][0]:
        
        arr_temp.append(v)
    
    arr.append(arr_temp)

chkflg=True

for i in range(0,h):
    
    for j in range(0,w):

        if arr[i][j]=="#":
         
            if i==0 and j==0:
                
                if not(arr[i+1][j]=="#" or arr[i][j+1]=="#"):
                    
                    chkflg=False
                    break

            elif i==0 and j==w-1:

                if not(arr[i+1][j]=="#" or arr[i][j-1]=="#"):
                    
                    chkflg=False
                    break


            elif i==0 and 0<j<w-1:

                if not(arr[i+1][j]=="#" or arr[i][j-1]=="#" or arr[i][j+1]=="#"):
                    
                    chkflg=False
                    break

            elif i==h-1 and j==0:
                
                if not(arr[i-1][j]=="#" or arr[i][j+1]=="#"):
                    
                    chkflg=False
                    break

            elif i==h-1 and j==w:

                if not(arr[i-1][j]=="#" or arr[i][j-1]=="#"):
                    
                    chkflg=False
                    break
                    
            elif i==h and 0<j<w-1:
                
                if not(arr[i-1][j]=="#" or arr[i][j-1]=="#" or arr[i][j+1]=="#"):
                    
                    chkflg=False
                    break

            elif 0<i<h-1 and j==0:
                
                if not(arr[i-1][j]=="#" or arr[i+1][j]=="#" or arr[i][j+1]=="#"):
                    
                    chkflg=False
                    break

            elif 0<i<h-1 and j==w:

                if not(arr[i-1][j]=="#" or arr[i+1][j]=="#" or arr[i][j-1]=="#"):
                    
                    chkflg=False
                    break
                    
            elif 0<i<h-1 and 0<j<w-1:

                if not(arr[i-1][j]=="#" or arr[i+1][j]=="#" or arr[i][j-1]=="#" or arr[i][j+1]=="#"):
                    
                    chkflg=False
                    break
                    
print("Yes" if chkflg else "No")

        
            
            

Measured memory_bytes: 3192
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

for i in range(N):
  ans += B[A[i]-1]
  
  
for j in range(0, N-1):
  if A[j+1] == A[j] + 1:
    ans = ans + C[A[j]-1]
    
print(ans)
  


Measured memory_bytes: 9128
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(A[K-1])

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define HASHSIZE 5000

typedef struct word{
  char *str;
  struct word *next;
}Word;

Word *hashtable[HASHSIZE] = {0};

int hash(char *key) {
  unsigned int hash = 0;
  int length = strlen(key);
  int i;
  for(i = 0; i < length; i++) hash += key[i] * pow(7,i);
  
  return hash%HASHSIZE;
}

void put_word(char *str) {
  Word *a;
  int l = strlen(str);
  a = (Word*)malloc(sizeof(Word));
  a->str = (char*)malloc(sizeof(char)*(l+1));
  strcpy(a->str,str);
  int h = hash(a->str);
  a->next = hashtable[h];
  hashtable[h] = a;
}


int main() {
  long n,i;
  scanf("%ld", &n);
  
  for(i = 0; i < n; i++) {
    char command[7];
    scanf("%s", command);
    if(strcmp(command, "insert") == 0) {
      char str1[13];
      scanf("%s", str1);
      put_word(str1);
    }
    if(strcmp(command, "find") == 0) {
      char str2[13];
      scanf("%s", str2);
      Word *a = hashtable[hash(str2)];
      while(a != NULL){
	if(strcmp(a->str,str2) == 0) break;
	a = a->next;
      }
      if(a != NULL) {
	printf("yes\n");
      }else{
	printf("no\n");
      }      
    }
  }

  return 0;
}

Measured memory_bytes: 36352
from itertools import permutations, combinations,combinations_with_replacement,product
s = input()
t = product(["+","-"],repeat=3)

for i in t:
    calc = s[0]+i[0]+s[1]+i[1]+s[2]+i[2]+s[3]
    sum = eval(calc)
    if(sum==7):
        print(calc+"=7")
        break

Measured memory_bytes: 3060
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

INF = float("inf")

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

#処理内容
def main():
	A, B = getlist()
	if A < 10 and B < 10:
		print(A * B)
	else:
		print(-1)

if __name__ == '__main__':
	main()

Measured memory_bytes: 38448
month1 = ["0" + str(i) for i in range(1,10)]
month2 = ["10","11","12"]

s = input()
a = 0
b = 0
if s[0] + s[1] in month1 + month2:
    a = 1
if s[2] + s[3] in month1 + month2:
    b = 1
if a and b:
    print("AMBIGUOUS")
elif a:
    print("MMYY")
elif b:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=1e6+5;
int n,ans,a[N],b[N],m;

signed main(){
	read(m);read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<n;i++) b[i]=a[i+1]-a[i];
	b[n]=m-a[n]+a[1];
	write(m-*max_element(b+1,b+1+n));
}


Measured memory_bytes: 6016
def examB():
    D, N = LI()
    ans = (100**D)*N
    if N==100:
        ans += 100**D
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 38256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll i) { cout << N - i + 1 << endl; }

int main() {
  ll N;
  cin >> N;
  ll i;
  cin >> i;
  solve(N, i);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int n;
int a[2][101];
int max_v = 0,v;
int x;
int main(void){
    cin >> n;
    a[0][0] = a[1][0] = 0;
    for(int i=1;i<=n;i++)
            {cin >> x;
            a[0][i] = a[0][i-1] + x;}
    for(int i=1;i<=n;i++)
            {cin >> x;
            a[1][i] = a[1][i-1] + x;}

    
    for(int k=1;k<=n;k++)
        {
            v = a[0][k] + a[1][n] - a[1][k-1];
            if(v > max_v) max_v = v;
        }
    cout << max_v;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10,M=5e5+10;
int n,m,d[M],cnt;
map<int,int>g[N];
deque<int>Q;
int head[M],to[M<<2],nxt[M<<2],w[M<<2],tot;

inline int rd()
{
	char ch=getchar();int x=0,f=1;
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+(ch^48);ch=getchar();}
	return x*f;
}

inline int get(int x,int y)
{
	if(g[x].find(y)!=g[x].end()) return g[x][y];
	else return (g[x][y]=++cnt);
}

inline void lk(int u,int v,int cc)
{to[++tot]=v;nxt[tot]=head[u];head[u]=tot;w[tot]=cc;}

int main(){
	int i,j,x0,y0,xc,yc,ix,iy,iz;
	memset(d,0x3f,sizeof(d));
	n=rd();m=rd();
	for(i=1;i<=n;++i) g[i][0]=++cnt;
	///
	for(;m;m--){
	    ix=rd();iy=rd();iz=rd();
	    x0=get(ix,0);y0=get(iy,0);
	    xc=get(ix,iz);yc=get(iy,iz);
	    lk(xc,yc,0);lk(yc,xc,0);
	    lk(x0,yc,1);lk(yc,x0,1);
	    lk(xc,y0,1);lk(y0,xc,1);
	}
	///
	d[1]=0;
	Q.push_back(1);
	for(;!Q.empty();){
		ix=Q.back();Q.pop_back();
		for(i=head[ix];i;i=nxt[i]){
			j=to[i];
			if(d[j]>d[ix]+w[i]){
				d[j]=d[ix]+w[i];
				if(w[i]==1) Q.push_front(j);
				else Q.push_back(j);
			}
		}
	}
	if(d[n]>M) puts("-1");
	else printf("%d\n",d[n]>>1);
}

Measured memory_bytes: 54144
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, m, k;
vector <string> a;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int calc(int x, int y){
    int ret = 1e9;
    ret = min(ret, (x + k - 1) / k);
    ret = min(ret, (y + k - 1) / k);
    ret = min(ret, (n - x - 1 + k - 1) / k);
    ret = min(ret, (m - y - 1 + k - 1) / k);
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    a.resize(n);
    for(auto &i : a) cin >> i;
    int sx, sy;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
            if(a[i][j] == 'S'){
                sx = i; sy = j;
                break;
            }
        }
    }
    queue <pair <int, int> > q;
    vector <vector <int> > dis(n, vector <int>(m, -1));
    q.push(make_pair(sx, sy));
    dis[sx][sy] = 0;
    int ans = 1e9;
    while(q.size()){
        auto top = q.front();
        q.pop();
        ans = min(ans, 1 + calc(top.first, top.second));
        for(int i = 0 ; i < 4 ; i++){
            int nx = top.first + dx[i];
            int ny = top.second + dy[i];
            if(nx < 0 || nx >= n || ny < 0 || ny >= m || a[nx][ny] == '#') continue;
            if(dis[nx][ny] != -1 || dis[top.first][top.second] + 1 > k) continue;
            dis[nx][ny] = dis[top.first][top.second] + 1;
            q.push(make_pair(nx, ny));
        }
    }
    cout << ans << endl; 
}


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

using namespace std;

bool palindrome(string& s, int st, int en) {
    for (int i = 0, j = en - 1; i < j; i++, j--) {
        if (s[i] != s[j]) {
            return false;
        }
    }
    return true;
}

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

    string s;
    cin >> s;

    int n = s.length();

    if (palindrome(s, 0, n) && palindrome(s, 0, n / 2) && palindrome(s, (n + 1) / 2, n)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

struct Block {
    int a, b, x;
    friend istream& operator>>(istream& in, Block& block) {
        int s, t;
        in >> s >> t >> block.x;
        block.a = 2*s-1-2*block.x;
        block.b = 2*t-1-2*block.x;
        return in;
    }
};

bool first_start(const Block& b1, const Block& b2) {
    return tuple<int, int, int>{b1.a, b1.b, b1.x} < tuple<int, int, int>{b2.a, b2.b, b2.x};
}

bool first_end(const Block& b1, const Block& b2) {
    return tuple<int, int, int>{b1.b, b1.a, b1.x} < tuple<int, int, int>{b2.b, b2.a, b2.x};
}

bool first_x(const Block& b1, const Block& b2) {
    return tuple<int, int, int>{b1.x, b1.a, b1.b} < tuple<int, int, int>{b2.x, b2.a, b2.b};
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<Block> blocks(n);
    for (auto& block : blocks) {
        cin >> block;
    }
    set<Block, function<bool (const Block&, const Block&)>> blocks_by_a(first_start);
    set<Block, function<bool (const Block&, const Block&)>> blocks_by_b(first_end);
    set<Block, function<bool (const Block&, const Block&)>> blocks_by_x(first_x);
    blocks_by_a.insert(blocks.begin(), blocks.end());
    while (q --> 0) {
        int d;
        cin >> d;
        d *= 2;
        while (blocks_by_a.size() > 0 && blocks_by_a.begin()->a < d) {
            blocks_by_b.insert(*blocks_by_a.begin());
            blocks_by_x.insert(*blocks_by_a.begin());
            blocks_by_a.erase(blocks_by_a.begin());
        }
        while (blocks_by_b.size() > 0 && blocks_by_b.begin()->b < d) {
            blocks_by_x.erase(*blocks_by_b.begin());
            blocks_by_b.erase(blocks_by_b.begin());
        }
        if (blocks_by_x.size() == 0) {
            cout << -1 << "\n";
        } else {
            cout << blocks_by_x.begin()->x << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 28672
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",if a==b {c}else if b==c{a}else{b})
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    string s; cin >> s;
    int ans = 0;
    REP(i, 1, s.size()-1){
        if(s[0] == s[1]){
            ans = 2;
        }
    }
    REP(i, 1, s.size()-1){
        int count = 0;
        REP(l, i+1, s.size()-1){
            if(s[l] != s[l%(i+1)]){
                break;
            }
            if((l+1) % (i+1) == 0){
                count++;
                break;
            }
        }
        if(count != 0){
            ans = max(ans, (count+1)*(i+1));
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;

int n;
const ll mod=1000000007;

mat id()
{
    mat res(n,vector<ll>(n,0));
    for(int i=0;i<n;i++) res[i][i]=1;
    return res;
}

mat operator*(const mat &a,const mat &b)
{
    mat res(n,vector<ll>(n,0)); //j=ob=ia
    for(int ib=0;ib<n;ib++)
    {
        for(int j=0;j<n;j++)
        {
            for(int oa=0;oa<n;oa++)
            {
                res[oa][ib]=(res[oa][ib]+a[oa][j]*b[j][ib])%mod;
            }
        }
    }
    return res;
}

mat fpow(mat b,ll e)
{
    mat res=id();
    while(e)
    {
        if(e&1) res=res*b;
        b=b*b;
        e/=2;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll k;
    cin >> n >> k;
    mat a(n,vector<ll>(n,0));
    for(int i=0;i<n;i++) for(int o=0;o<n;o++) cin >> a[o][i];
    mat m=fpow(a,k);
    ll res=0;
    for(int o=0;o<n;o++) for(int i=0;i<n;i++) res=(res+m[o][i])%mod;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define ll long long int

typedef struct{
	ll t;
	ll d;
}data;

int compare(const void *a, const void *b){return (((data*)b)->d - ((data*)a)->d);}

int main(void){
	int n,k,i;
	scanf("%d %d",&n,&k);
	data neta[n];
	ll ans=0,sum=0;
	for(i=0;i<n;i++)scanf("%lld %lld",&neta[i].t,&neta[i].d);
	int used[100001]={0},sushiTypes=0,stack[100000],top=0;
	qsort(neta, n, sizeof(data), compare);
	
	for(i=0;i<k;i++){
		sum += neta[i].d;
		if(used[neta[i].t]){//かぶってるネタはスタックにおいしさをメモ
			stack[top]=neta[i].d;
			top++;
		}else{
			used[neta[i].t] = 1;
			sushiTypes++;
		}
	}
	ans = sum+(ll)sushiTypes*sushiTypes;
	for(i=k;i<n && top>0;i++){//美味しさソートのk個目以降 and スタックが存在
		if(used[neta[i].t])continue;//すでに使っているネタは見ない
		used[neta[i].t] = 1;
		top--;//スタックは下にdが大きいもの上（top）にdが小さいもので入っている
		sum += neta[i].d -stack[top];
		sushiTypes++;
		ans = sum+(ll)sushiTypes*sushiTypes>ans?sum+(ll)sushiTypes*sushiTypes:ans;
	}
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a),i##_end_ = (b);i<=i##_end_;i++)
#define ROF(i,a,b) for(int i = (a),i##_end_ = (b);i>=i##_end_;i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 100005
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-8
#define DEBUG_
#ifdef DEBUG_
#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
#else
#define DEBUG(...)
#endif // DEBUG
using namespace std;

ll a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,c,k;
    while(cin>>n>>c>>k)
    {
        FOR(i,1,n)cin>>a[i];
        sort(a+1,a+n+1);
        a[n+1] = INF;
        ll ans = 0;
        ll pre = 1;
        FOR(i,1,n)
        {
            if(a[i+1]-a[pre]>k)
            {
                int num = 0;
                for(int j = pre;j<=i;j++)if(a[i+1]-a[j]>k)num++;
                ll bus = num/c+(num%c!=0);
                ans+=bus;
                pre = min(i+1LL,pre+bus*c);
            }
            //cout<<i<<" "<<pre<<" "<<ans<<endl;
        }
        int lft = n+1-pre;
        if(lft>0)ans+=lft/c+(lft%c!=0);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

long long sharp[17];
long long ten[19];

long long func(long long x){
    //xは何桁か？
    int d;
    for(d = 0;d <= 18;d++){
        if(ten[d] > x)break;
    }
    
    long long res = 0;
    //1,2,...,d-1桁は全部加算しておく
    for(int i = 1;i <= d-1;i++){
        res += sharp[i];
    }
    //1e(d-1)からxまで
    ll other = x - ten[d-1] + 1;
    ll three = (x / 3) - (ten[d-1] - 1)/3;
    ll five = (x / 5) - (ten[d-1] - 1)/5;
    ll fifteen = (x / 15) - (ten[d-1] - 1)/15;
    other -= (three + five - fifteen);
    
    res += d * other + (three + five) * 4;
    return res;
}
string get_last(long long x){
    string s = "";
    for(long long i = x;i <= x + 10;i++){
        if(i % 3 == 0)s += "Fizz";
        if(i % 5 == 0)s += "Buzz";
        if(i%3 != 0 and i%5 != 0) s += to_string(i);
    }
    return s;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;cin >> s;
    //1.d桁の整数全部を繋げたときの長さを前計算する（ullで、16桁までやれば十分だと思う)
    ten[0] = 1;
    for(int i = 1;i <= 18;i++){
        if(!i)ten[i] = 10LL;
        else ten[i] = ten[i-1] * 10LL;
    }
    for(long long d = 1;d <= 16;d++){
        long long three,five,fifteen,other;
        other = ten[d] - ten[d-1];
        three = (ten[d] - 1)/3 - (ten[d-1] - 1)/3;
        five = (ten[d] - 1)/5 - (ten[d-1] - 1)/5;
        fifteen = (ten[d] - 1)/15 - (ten[d-1] - 1)/15;
        other -= (three + five - fifteen);
        sharp[d] = (other * d + 4 * (five + three) );
    }
    //2.二分探索する：string[s]は何番目の整数の途中であるかを二分探索する
    ll l = 0,r = 1e17;
    while(l+1 != r){
        ll m = (l + r)/2;
        if(func(m) < s)l = m;
        else r = m;
    }
    //3.l番目の整数の末尾がy文字めだったとすると、get_sで得られた文字列の
    //s[x - (y+1)],...,s[x - (y+1) + 19]を出力すれば良い
    string ans = get_last(l+1);
    for(ll i = s - (func(l)+1);i <= s - (func(l)+1) + 19;i++){
        cout << ans[i];
    }
    cout << '\n';
}



Measured memory_bytes: 3296
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define p 1000000007
using namespace std;
#define MAXN 200000
long long fac[MAXN+5],inv[MAXN+5],n,m,aa,bb,ans;
long long kasumi(long long a,long long b){
    long long ans=1;
    while(b){
        if(b&1) ans=(ans*a)%p;
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}
long long cc(int a,int b){
    if(a==b||b==0) return 1;
    return ((fac[a]*inv[b])%p*inv[a-b]%p);
}
long long get(int x1,int y1,int x2,int y2){
    return cc(x2-x1+y2-y1,x2-x1);
}
int main()
{
    fac[1]=1;
    for(int i=2;i<=MAXN;i++)
        fac[i]=(fac[i-1]*i)%p;
    inv[MAXN]=kasumi(fac[MAXN],p-2);
    for(int i=MAXN-1;i>=1;i--)
        inv[i]=(inv[i+1]*(i+1))%p;
    scanf("%d%d%d%d",&n,&m,&aa,&bb);
    for(int i=1;i<=n-aa;i++){
        ans+=(get(1,1,i,bb)*get(i,bb+1,n,m))%p;
        ans%=p;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int w = sc.nextInt();

		if(s <= w) {
			System.out.println("unsafe");
		}else {
			System.out.println("safe");
		}
		sc.close();
	}

}

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

int main(){
  string S;
  cin >> S;
  for(int i=0; i<4; i++){
    cout << S.at(i);
  }
  cout << " ";
  for(int i=4; i<12; i++){
    cout << S.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, s; cin >> n >> s;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  vector<vector<ll>> dp(n+1, vector<ll>(s+1));
  dp[0][0] = 1;
  rep(i, n) {
    rep(j, s+1) {
     (dp[i+1][j] += dp[i][j] * 2) %= mod;
     if(j+A[i]<=s) (dp[i+1][j+A[i]] += dp[i][j]) %= mod;
    }
  }
  cout << dp[n][s] << endk;
  return 0;
}


Measured memory_bytes: 73620
#include<bits/stdc++.h>
using namespace std;
int  main (){
  int a;
  int b[5]={};
  cin>>a;
  for(int i=0;i<4;i++){
    b[i]=a%10;
    a/=10;
  }
  if(b[0]==b[1]&&b[1]==b[2]||b[1]==b[2]&&b[2]==b[3]||b[0]==b[1]&&b[1]==b[2]&&b[2]==b[3]){
    cout<<"Yes"<<"\n";
    return(0);
  }
  cout<<"No"<<"\n";
  return(0);
}


Measured memory_bytes: 256
n = int(input())
x = []
y = []
h = []
ot = []
for i in range(n):
    xi, yi, hi = [int(_) for _ in input().split()]
    if hi != 0:
        x.append(xi)
        y.append(yi)
        h.append(hi)
    else:
        ot.append([xi, yi, hi])

ans = []
for cxi in range(101):
    for cyi in range(101):
        flag = True
        for i in range(len(h)):
            if i == 0:
                height = h[i] + abs(x[i]-cxi) + abs(y[i]-cyi)
            else:
                if height != h[i] + abs(x[i]-cxi) + abs(y[i]-cyi):
                    flag = False
                    continue
        if flag:
            ans.append([cxi, cyi, height])

if len(ans) == 1:
    print(ans[0][0], ans[0][1], ans[0][2])
else:
    for a in ans:
        flag = True
        for o in ot:
            if max((a[2] - abs(o[0]-a[0]) - abs(o[1]-a[1])), 0) != o[2]:
                flag = False
                continue
        if flag:
            print(a[0], a[1], a[2])

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int p,q,r;
  cin >> p  >> q >> r;
  int ans = INF;
  ans = min(p+q,ans);
  ans = min(q+r,ans);
  ans = min(r+p,ans);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.000000001
#define ld long double
#define inf 5e18
#define N 3000
 
 
 
int32_t main()
{
    IOS;

    int n;
    cin >> n;
    if(floor(ceil(n / 1.08) * 1.08) == n)
        cout << ceil(n / 1.08);
    else
        cout << ":(";
    return 0;
 
}

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

using namespace std;

int c[222][222], f[222][222];
int main()
{
	int n, r = 0;
	cin >> n;
	int a[111], b[111];
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		for (int j = 0; j < n; j++)
			if (a[j] < x&&b[j] < y)
				c[j][i + n] = 1;
		c[i][n + n] = c[n + n][i + n] = 1;
	}
	for (;;) {
		int p[222], i;
		fill(p, p + 222, -1);
		queue<int> q;
		for (int i = 0; i < n; i++)
			if (f[i][n + n] < c[i][n + n])
				q.push(i), p[i] = n + n;
		while (!q.empty()) {
			i = q.front();
			q.pop();
			if (f[n + n][i] < c[n + n][i])
				goto pnz;
			int k = n - i / n * n;
			for (int j = k; j < k + n; j++)
				if (f[i][j] < c[i][j] && p[j] < 0)
					q.push(j), p[j] = i;
		}
		break;
	pnz:
		r++;
		f[n + n][i]++;
		for (; p[i] < n + n; i = p[i]) {
			f[p[i]][i]++;
			f[i][p[i]]--;
		}
		f[i][n + n]++;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
m = 0
e = []
for i in range(n-1):
    e.append((1, i+2))
    m += 1

rep = (n-1)*(n-2)//2 - k
if rep < 0:
    print(-1)
    exit()
e_list = []
for i in range(2, n+1):
    for j in range(i+1, n+1):
        if rep == 0:
            print(m)
            for edge in e:
                print(*edge)
            exit()
        e.append((i, j))
        m += 1
        rep -= 1

if rep == 0:
    print(m)
    for edge in e:
        print(*edge)







Measured memory_bytes: 74040
/*    BAJUKA     */
#include<bits/stdc++.h>
#define lld long long int
#define ve vector
#include<ios>
#define rep(i,a,b) for(i=a;i<b;i++) 
#define per(i,a,b) for(i=b;i>=a;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define Max 10000000000000000
#define M 1000000007 
using namespace std;




int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    lld i,n,x,t;
    ve<lld> v;
    cin>>n>>x;
    rep(i,0,n)
    {
    	cin>>t;
    	v.pb(t-x);
    }
    sort(all(v));
    lld mi = *(min_element(all(v)));
    lld gc = abs(v[0]);
    rep(i,0,n)
    {
    	gc = __gcd(gc,abs(v[i]));
    }
    cout<<gc;




	return(0);
}

Measured memory_bytes: 1400
from collections import Counter 

N = int(input())
A = list(map(int,input().split()))
Q = int(input())

tot = sum(A)
A = Counter(A)

for i in range(Q):
    B,C = map(int,input().split())
    tot +=(C - B) * A[B]
    A[C] += A[B]
    A[B] = 0
    print(tot)

Measured memory_bytes: 23356