akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>

using namespace std;
using Int = long long;

int main(){
    Int N, M, Q;
    cin >> N >> M >> Q;

    vector<int> paths[501];

    for (int i=0; i<M; i++){
        int L, R;
        cin >> L >> R;
        paths[L].push_back(R);
    }

    for (int i=0; i<501; i++)  
        sort(begin(paths[i]), end(paths[i]));

    for (int i=0; i<Q; i++){
        int L, R;
        cin >> L >> R;

        int cnt = 0;
        for (int j=L; j<=R; j++){
            cnt += upper_bound(begin(paths[j]), end(paths[j]), R) - begin(paths[j]);
        }
        cout << cnt << endl;
    }

}

Measured memory_bytes: 2176
#include <cstdio>

int main(){
	int s[2];
	s[0] = 0;
	s[1] = 0;
	int a;
	for(int i = 0;i<8;i++){
		scanf("%d",&a);
		s[i / 4] += a;
	}
	printf("%d\n", s[0] > s[1] ? s[0] : s[1]);
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <sstream>
#include <numeric>
#include <complex>

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

#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)


//低優先度


#include <list>
#include <stack>
#include <iomanip>
#include <fstream>
#include <cassert>
#define REP(i, n) rep (i, n)
#define min3(a,b,c) min((a),min((b),(c)))
#define min4(a,b,c,d) min((a),min3((b),(c),(d)))
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) memset((a),0,sizeof(a))
#define EPS (1e-8)
template<class T,class U>ostream&operator<<(ostream&o,pair<T,U>&v){return o<<"("<<v.F<<","<<v.S<<")";}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){o<<"{";rep(i,SZ(v))o<<(i?",":"")<<v[i];return o<<"}";}
string i2s(int a){stringstream ss;ss<<a;return ss.str();};
typedef double FP;
typedef complex<FP> pt;
typedef pt P;
typedef pair<pt,pt> line;
FP dot(P a,P b){return real(conj(a)*b);}
FP crs(P a,P b){return imag(conj(a)*b);}
P ortho(P a){return a*P(0,1);}
P ortho(line a){return ortho(a.S-a.F);}
P crspt(P a,P b,P c,P d){b-=a,d-=c;return a+b*crs(d,c-a)/crs(d,b);}
P crspt(line a,line b){return crspt(a.F,a.S,b.F,b.S);}
bool onl(P a1,P a2,P b){return abs(b-a1)+abs(b-a2)<abs(a1-a2)+EPS;}
bool onl(line a,P b){return onl(a.F,a.S,b);}
bool iscrs(line a,line b){P c=crspt(a,b);return onl(a,c)&&onl(b,c);}
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
enum{TOP,BTM,LFT,RGT,FRT,BCK};
int dxdy2ce[]={RGT,FRT,LFT,BCK};
template<class T> T shift(T a,int b,int c,int d,int e){
 __typeof(a[0])t=a[b];a[b]=a[c];a[c]=a[d];a[d]=a[e];a[e]=t;
 return a;}
template<class T> T rgt(T a){return shift(a,TOP,LFT,BTM,RGT);}
template<class T> T lft(T a){return shift(a,TOP,RGT,BTM,LFT);}
template<class T> T frt(T a){return shift(a,TOP,BCK,BTM,FRT);}
template<class T> T bck(T a){return shift(a,TOP,FRT,BTM,BCK);}
line mkl(P a,P v){return line(a,a+v);}
FP lpdist(line a,P b){return abs(b-crspt(a,mkl(b,ortho(a))));}
FP spdist(line a,P b){
  P c(crspt(a,mkl(b,ortho(a))));
  return onl(a,c)?abs(b-c):min(abs(a.F-b),abs(a.S-b));
}
FP ssdist(line a,line b){
 return
  iscrs(a,b)?0.:
   min4(spdist(a,b.F),spdist(a,b.S),
        spdist(b,a.F),spdist(b,a.S));
}
namespace std{
  bool operator<(const P&a,const P&b){
    return mp(real(a),imag(a))<mp(real(b),imag(b));
  }
}

int main(int argc, char *argv[])
{
  int a,b;
  ofstream fout("out.txt");
  rep(i,9)rep(j,9) printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
  fout << a+b << endl;
  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9+5;
int32_t main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    int n;
    cin>>n;
    vector<int> dp(3,0);
    for(int day = 0; day < n; day++){
        vector<int> new_dp(3,0);
        vector<int> c(3);
        for(int i = 0; i < 3; i++) cin>>c[i];
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(i != j) new_dp[j] = max(new_dp[j],dp[i]+c[j]);
            }
        }
        dp = new_dp;
    }
    cout<<max(dp[0],max(dp[1],dp[2]));

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char INS[10] = "insert";
char PRT[10] = "print";
typedef struct{
  int data;
  int *right;
  int *left;
  int *parent;
}node;

node *root;

void preorder(node *);

void insert(int k){
node *y = NULL;
node *x = root;
node *z;
 
z = (node *)malloc(sizeof(node));
z->data = k;
z->left = NULL;
z->right = NULL;

while(x != NULL){
y = x;
if(z->data < x->data){
x = x->left;
}else{
x = x->right;
}
}

z->parent = y;

if(y == NULL){
root = z;
}else{
if(z->data < y->data){
y->left = z;
}else{
y->right = z;
}
}
}
void inorder(node *u){
if(u == NULL)return;
inorder(u->left);
printf(" %d",u->data);
inorder(u->right);
}

void preorder(node *u){
if(u == NULL)return;
printf(" %d",u->data);
preorder(u->left);
preorder(u->right);
}



int main(){
  int i,datanum,input;
  char com[11];

  scanf("%d",&datanum);

  for(i=0;i<datanum;i++){
    scanf("%s",com);
    if(strcmp(com,INS) == 0){
      scanf(" %d",&input);
      insert(input);
    }else if(strcmp(com,PRT) == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else{
      continue;
    }
  }
return 0;
}



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

using namespace std;
const long long MOD = 1'000'000'007;

int main(void) {
  int N; cin >> N;
  string S; cin >> S;
  
  int c[26];
  memset(c, 0, sizeof(c));

  for (int i = 0; i < N; i++) {
    c[(S[i]-'a')]++;
  }
  
  long long ans = 1;
  for (int i = 0; i < 26; i++) {
    ans *= c[i] + 1;
    ans %= MOD;
  }

  ans = ans == 0 ? MOD-1 : ans-1; 

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll n,k=0;
    string s;
    cin >>s;
    n=s.size();
    rep(i,n/2){
        if(s[i]!=s[n-1-i]){
            k=1;
        }
    }
    rep(i,n/4){
        if(s[i]!=s[n/2-1-i]){
            k=1;
        }
        if(s[n/2+1+i]!=s[n-1-i]){
            k=1;
        }
    }
    if(k==1){
        cout <<"No";
    }else{
        cout << "Yes";
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=1;
    cerr<<s<<endl;
    rep(i,n){
        //cin>>vec[i];
        if(i!=0&&s[i]!=s[i-1])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  ull n, m;
  cin >> n >> m;
  
  vector<pair<ull, ull>> drinks;
  
  while (n--) {
    ull amount, cost;
    cin >> cost >> amount;
    
    drinks.pb(mp(cost, amount));
  }
  
  ull total = 0;
  
  sort(drinks.begin(), drinks.end());
  
  for (int i = 0; i < drinks.size() && m > 0; ++i) {
    total += drinks.at(i).first * min(drinks.at(i).second, m);
    
    m -= min(drinks.at(i).second, m);
  }
  
  cout << total << endl;

  return 0;
}

Measured memory_bytes: 5260
#include <iostream>
using namespace std;
#include <math.h>
int main(void){
    // Your code here
    int a, b;scanf("%d%d",&a,&b);
    double ret = 0;
    for (int i=1; i<=a;i++){
        double tmp=1.0/a;
        int now=i;
        while(now < b){
            now*=2;
            tmp/=2;
        }
        ret+=tmp;
    }
    printf("%.12f\n",ret);
}

Measured memory_bytes: 3832
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static string[] _target;
        private static int N;
        static void Main(string[] args)
        {
            N = Console.ReadLine().ToInt();
            _target = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" };
            var s = new string[N];
            Create(0, 1, s);
            Console.ReadLine();
        }

        private static void Create(int currentNum, int useNum, string[] s)
        {
            if (currentNum == N)
            {
                Console.WriteLine(string.Join(string.Empty, s));
                return;
            }
            for (int i = 0; i < useNum; i++)
            {
                s[currentNum] = _target[i];
                if (useNum - 1 == i)
                {
                    Create(currentNum + 1, useNum + 1, s);
                }
                else
                {
                    Create(currentNum + 1, useNum, s);
                }
            }
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 16460
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 

int main() {
    ll n,a,b,ans=0;
    cin >> a >>b;
    while(ans<=1010){
        if (ans*8/100==a&&ans*10/100==b){
            cout << ans << endl;
            break;
        }
        ans++;
    }
    if (ans==1011) cout << -1 << endl;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
   

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

    li a,b,c;

    cin>>a>>b>>c;

    map<li,li> m;

    m[a]++;
    m[b]++;
    m[c]++;

    if(m[5]==2 && m[7]==1)
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>




using namespace std;



using ll = long long;
const ll INF = 1e18L + 5;
const int mod = 1e9 + 7;

ll dp[2100000];// < 2^21
ll n;
int tab[40][40];

int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> tab[i][j];
        }
    }
    
    dp[0] = 1;
    //for(int a = 0; a < n; a++){
    for(int mask = 0; mask < (1 << n) - 1; mask++){// 1 << n all possibilities
        int a = __builtin_popcount(mask);
        for(int b = 0; b < n; b++){
            if(tab[a][b] && !(mask & (1 << b))){
                int m2 = mask | (1 << b);//sprawdzic czy & tez bd dzialac
                
                dp[m2] += dp[mask];
                if(dp[m2] >= mod){
                    dp[m2] -= mod;
                }
            }
        }
    }
    
    
    cout << dp[(1 << n) - 1];
}



Measured memory_bytes: 16640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef vector<vector<pair<int, int>>> GRA;

int i,j,N,c[3][3];

int main() {
	cin >> c[0][0];
	cin >> c[0][1];
	cin >> c[0][2];
	cin >> c[1][0];
	cin >> c[1][1];
	cin >> c[1][2];
	cin >> c[2][0];
	cin >> c[2][1];
	cin >> c[2][2];
	
	if ((c[0][0] - c[0][1]) != (c[1][0] - c[1][1])) {cout << "No";return 0;} 
	if ((c[1][0] - c[1][1]) != (c[2][0] - c[2][1])) {cout << "No";return 0;} 
	if ((c[2][0] - c[2][1]) != (c[0][0] - c[0][1])) {cout << "No";return 0;} 
	if ((c[0][1] - c[0][2]) != (c[1][1] - c[1][2])) {cout << "No";return 0;} 
	if ((c[1][1] - c[1][2]) != (c[2][1] - c[2][2])) {cout << "No";return 0;} 
	if ((c[2][1] - c[2][2]) != (c[0][1] - c[0][2])) {cout << "No";return 0;} 

	if ((c[0][0] - c[1][0]) != (c[0][1] - c[1][1])) {cout << "No";return 0;} 
	if ((c[0][1] - c[1][1]) != (c[0][2] - c[1][2])) {cout << "No";return 0;} 
	if ((c[0][2] - c[1][2]) != (c[0][0] - c[1][0])) {cout << "No";return 0;} 
	if ((c[1][0] - c[2][0]) != (c[1][1] - c[2][1])) {cout << "No";return 0;} 
	if ((c[1][1] - c[2][1]) != (c[1][2] - c[2][2])) {cout << "No";return 0;} 
	if ((c[1][2] - c[2][2]) != (c[1][0] - c[2][0])) {cout << "No";return 0;} 
	
	cout << "Yes";
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

const intMax = 2147483647

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	ps := make([]int, n)
	for i := 0; i < n; i++ {
		var p int
		_, _ = fmt.Scan(&p)
		ps[i] = p
	}
	min := intMax
	res := 0
	for _, v := range ps {
		if min > v {
			min = v
		}
		if v <= min {
			res++
		}
	}
	fmt.Println(res)
}


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

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    int sum = 0;
    rep(i, n) {
        int x = 1;
        sum++;
        while(x + a.at(i) <= d) {
            sum++;
            x += a.at(i);
        }
    }
    cout << sum + x << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n;
    cin>>n;
    
    vector<pii> ans;
    for(int i=n-1;i>=0;i--){
        for(int j=n-1;j>=i+1;j--){
            string s = string(n,'0');
            s[i] = s[j] = '1';
            cout<<"? "<<s<<endl;
            
            int res;
            cin>>res;
            if(res){
                ans.pb(pii(i,j));
            }
            if(ans.size()==n-1)goto end;
        }
    }
end:;
    cout<<"!";
    rep(i,ans.size()){
        cout<<" (";
        cout<<ans[i].first<<","<<ans[i].second;
        cout<<")";
    }
    cout<<endl;
}

Measured memory_bytes: 848
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N; cin>>N;
    vector<vector<ll>>a(N,vector<ll>(2));
    rep(i,N){
        ll A,B;
        cin>>A>>B;
        a[i][0]=B;
        a[i][1]=A;
    }
    sort(a.begin(),a.end());
    ll sum =0;
    rep(i,N){
        sum+=a[i][1];
        if(sum>a[i][0]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
void solve(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "No";
    if (a >= c || b >= c || (a + b) >= c)
        ans = "Yes";
    cout << ans << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include<bitset>
#include <utility>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
//const ll M=1e9+7;
//const ll maxn=2e5+7;
//const int MAXN=1005;
const int MAX=1e5+5;
const int MAX_N=MAX;
//const int N=55;
const ll MOD=998244353;
//const double eps=0.00000001;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
    freopen("1004.in","r",stdin);
    freopen("out.txt","w",stdout);
}
int n;
int a[MAX];
map<int,bool>re;
int main()
{
    int cnt=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if(re[x])
        {
//            printf("!\n");
            a[cnt++]=x;
            re[x]=false;
        }
        else
            re[x]=true;
    }
    if(cnt<2)
        printf("0\n");
    else
    {
        sort(a,a+cnt);
        printf("%lld\n",(ll)a[cnt-1]*a[cnt-2]);
    }

    return 0;
}


Measured memory_bytes: 4992
import math
while True:
    a,b,c=map(float,input().split())
    if a==-1 and b==-1 and c==-1:break
    elif a==-1 or b==-1:
        print("F")
    elif (a+b)>=80:
        print("A")
    elif 80>(a+b) and (a+b)>=65:
        print("B")
    elif 65>(a+b) and (a+b)>=50:
        print("C")
    elif c>=50:print("C")
    elif 50>(a+b) and (a+b)>=30:
        print("D")
    elif 30>(a+b):
        print("F")


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <sstream>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    char c[h][w];
    int b = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>c[i][j];
            if(c[i][j] == '#'){
                b++;
            }
        }
    }

    if(k > b){
        cout<<0<<endl;
        return 0;
    }

    int ans = 0;
    for(int bits1 = 0; bits1 < (1<<h); bits1++){
        for(int bits2 = 0; bits2 < (1<<w); bits2++){
            int black = 0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if((bits1 >> i) & 1) continue;
                    if((bits2 >> j) & 1) continue;
                    if(c[i][j] == '#') black++;
                }
            }
            if(black == k) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int a[3];
int gcd(int a, int b){
  if(a < b)swap(a, b);
  if(a % b == 0)return b;
  return gcd(b, a % b);
}
vector<int> res;

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    scn(n, a);

    int x = gcd(a[0], a[1]);
    if(n == 3)x = gcd(x, a[2]);

    for(i = 1;i * i < x;++i)if(x % i == 0){
      res.pb(i);
      res.pb(x / i);
    }
    if(i * i == x)res.pb(i);
    sort(all(res));
    rep(i, res.size())pri(res[i]);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3228
// Never let them see you bleed...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;

vector<int> v[2][maxn];
bool mark[maxn];
int numb[maxn];

bool IS = 0;
int cnt[3], M;

void dfs(int u){
    M+= sz(v[0][u]);
    cnt[ numb[u] ]++;
    mark[u] = 1;
    for(int y : v[0][u]){
	if(mark[y])
	    IS|= numb[y] != (numb[u] + 1) % 3;
	else
	    numb[y] = (numb[u] + 1) %3, dfs(y);
    }
    for(int y : v[1][u]){
	if(mark[y])
	    IS|= numb[y] != (numb[u] + 2) % 3;
	else
	    numb[y] = (numb[u] + 2) %3, dfs(y);
    }
}

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

    ll ans = 0;
    
    int n, m;
    cin >> n >> m;
    while(m--){
	int a, b;
	cin >> a >> b;
	v[0][a].PB(b);
	v[1][b].PB(a);
    }
    for(int i = 1; i <= n; i++){
	if(mark[i] == 0){
	    IS = 0, cnt[0] = cnt[1] = cnt[2] = M = 0;
	    dfs(i);
	    if(IS)
		ans+= 1ll * (cnt[0] + cnt[1] + cnt[2]) * (cnt[0] + cnt[1] + cnt[2]);
	    else if(min({cnt[0], cnt[1], cnt[2]}) > 0)
		ans+= 1ll * cnt[0] * cnt[1] + 1ll * cnt[1] * cnt[2] + 1ll * cnt[2] * cnt[0];
	    else
		ans+= M;
	}
    }
    return cout << ans << endl, 0;
}


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

int main() {
	char S[4];
	string T;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> A >> B >> C;
	if (A == 5 && B == 5 &&C == 7) {
		cout << "YES";
	}else if (A == 5 && B == 7 && C == 5) {
		cout << "YES";
	}else if (A == 7 && B == 5 && C == 5) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

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

int main(){
  int k;
  cin >> k;
  ll ans = 0;
  for (int i = 1; i <= k; i++){
    for (int j = i; j <= k; j++){
      for (int l = j; l <= k; l++){
        ll tmp = gcd(i, gcd(j, l));
        int c = 0, d;
        if (i != j) c++;
        if (j != l) c++;
        if (l != i) c++;
        if (c == 0) d = 1;
        else if (c == 1 || c == 2) d = 3;
        else d = 6;
        ans += tmp * d;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
	static final long MOD = 1000000007L;

	public static void main(String[] args){
		Main main = new Main();
		main.solveC();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int five = 0;
		int seven = 0;
		for (int i = 0; i < 3; i++) {
			switch (sc.nextInt()) {
			case 5:
				five++;
				break;
			case 7:
				seven++;
				break;
			default:
			}
		}
		if (five == 2 && seven == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		List<String> list = new ArrayList<String>();
		for (int i = 0; i < N; i++) {
			list.add(sc.next());
		}
		Collections.sort(list);
		for (String str : list) {
			System.out.print(str);
		}
		System.out.println();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int K = sc.nextInt();
		boolean[] forbid = new boolean[10];
		int[] next = new int[10];
		for (int i = 0; i < 10; i++) {
			forbid[i] = false;
			next[i] = i;
		}
		for (int i = 0; i < K; i++) {
			forbid[sc.nextInt()] = true;
		}
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (!forbid[(i + j) % 10]) {
					next[i] = i + j;
					break;
				}
			}
		}

		int L = N.length();
		String answer = "";
		boolean lift = false;
		for (int i = 0; i < N.length(); i++) {
			char c = N.charAt(L - i - 1);
			int ctoi = c - '0' + (lift ? 1 : 0);
			int ni = next[ctoi % 10] % 10;
			if (ctoi == ni) {
				answer = ni + answer;
			} else {
				int AL = answer.length();
				answer = "" + ni;
				for (int j = 0; j < AL; j++) {
					answer = answer + next[0];
				}
			}
			lift = (ctoi >= 10 || next[ctoi] >= 10);
		}
		if (lift) {
			System.out.print(next[1]);
		}
		System.out.println(answer);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();

		long startRowIndex = H - A;
		long startColIndex = B + 1;
		long answer = 0L;
		for (long shiftIndex = 0; startRowIndex - shiftIndex > 0 && startColIndex + shiftIndex <= W; shiftIndex++) {
			answer += pointComb(H, W, H - A - shiftIndex, B + 1 + shiftIndex);
			answer %= MOD;
		}
		System.out.println(answer);
	}

	/**
	 * h行w列の格子について点(r, c)を通る組み合わせを求めます
	 * @param h 格子の行数
	 * @param w 格子の列数
	 * @param r 通る点の行index
	 * @param c 通る点の列index
	 * @return C(r + c - 2, c - 1) * C(h - r + w - c, w - c)
	 */
	private long pointComb(long h, long w, long r, long c) {
		return combination(r + c - 2, c - 1) * combination(h - r + w - c, w - c);
	}

	/**
	 * n個からm個選ぶ組み合わせの数を求めます
	 * @param n 全体の数
	 * @param m 選ぶ数
	 * @return C(n, m)
	 */
	private long combination(long n, long m) {
		if (n / 2 < m) {
			return combination(n , n - m);
		}
		if (m <= 0) {
			return 1;
		}
		return (combination(n, m - 1) * (n - m + 1) / m) % MOD;
	}
}

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


int main(){
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    rep(i,h) cin >> grid[i];
    bool f = false;
    rep(i,h){
        rep(j,w){
            if(grid[i][j] == '#'){
                deque<bool> flag(4, true);
                if(i-1 >= 0){
                    if(grid[i-1][j] == '#') flag[0] = false;
                }
                if(i+1 < h){
                    if(grid[i+1][j] == '#') flag[1] = false;
                }
                if(j-1 >= 0){
                    if(grid[i][j-1] == '#') flag[2] = false;
                }
                if(j+1 < w){
                    if(grid[i][j+1] == '#') flag[3] = false;
                }
                if(flag[0] && flag[1] && flag[2] && flag[3]){
                    f = true;
                    break;
                }
            }
        }
    }
    cout << (f ? "No\n" : "Yes\n");
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int x = scan.nextInt();
		int t = scan.nextInt();
		
		if(n%x == 0) {
			System.out.println((n/x)*t);
		}else {
			System.out.println(((n/x)+1)*t);
		}
		
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 





Measured memory_bytes: 35648
def func1(lst, value):
    return [i for i, x in enumerate(lst) if x == value]

n = int(input())
box = []
box.append(list(map(int, input().split())))
box1 = box[0]  
tibi = min(box1)
ans = 0

#判定
if tibi!=1:
  print(-1)
else:  
  num = 0
  for i in range(len(box1)):
    if box1[i]==(num+1):
      num += 1
      continue
    else:
      ans += 1
  print(ans)

Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll m, d; cin >> m >> d;
    
    // 22日以降が対象
    // 1の桁と10の桁の積が月だったらOK
    // 制約が小さいので愚直にシミュレーションする。

    ll ans = 0;
    for(ll i=1; i<=m; i++){
        for(ll j=1; j<=d; j++){
            ll m10 = j/10;
            ll m1 = j%10;
            if(m1 >= 2 && m10 >= 2 && m1*m10 == i) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3552
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace Atcoder.Abc
{
    //https://atcoder.jp/contests/abc177/tasks/abc177_b
    public class Abc177_B
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var S = Console.ReadLine();
            var T = Console.ReadLine();

            var ans = T.Length;

            for (int start = 0; start <= S.Length - T.Length; start++)
            {
                int diff = 0;
                for (int i = 0; i < T.Length; i++)
                {
                    if (S[start + i] != T[i]) diff++;
                }
                ans = Math.Min(ans, diff);
            }
            WriteLine(ans);


            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 17340
N = int(input())
A = [int(a) for a in input().split()]

A.sort()
B = [abs(a-b) for a,b in zip(range(N-1,-1,-1),range(N))]
B.sort()

if A==B:
    print(pow(2,N//2,10**9+7))
else:
    print(0)


Measured memory_bytes: 13812
#include<stdio.h>
#include<math.h>
int main()
{  long long a,b,c,k;
   scanf("%lld%lld%lld",&a,&b,&c);
   if(a+b<c)
   {  k=c-a-b;
      if(4*a*b<k*k) printf("Yes");
      else printf("No");
   }
   else
   printf("No");
}

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

int main(){
  long long X, Y;
  cin >> X >> Y;
  int doubleT = Y-2*X;
  if(doubleT < 0){
    cout << "No";
    return 0;
  }
  int doubleC = 4*X - Y;
  if(doubleC < 0){
    cout << "No";
    return 0;
  }
  if(Y%2 != 0){
    cout << "No";
    return 0;  
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	firstSymbol  = "#"
	secondSynbol = "."
)

var scan = bufio.NewScanner(os.Stdin)

func main() {
	scanWords()
	for {
		height := readNextInt()
		width := readNextInt()

		if height == 0 && width == 0 {
			break
		}

		printChessboard(height, width)
		fmt.Println()
	}
}

func printChessboard(height, width int) {
	for h := 0; h < height; h++ {
		for w := 0; w < width; w++ {
			if (h+w)%2 == 0 {
				fmt.Print(firstSymbol)
			} else {
				fmt.Print(secondSynbol)
			}
		}
		fmt.Println()
	}
}

func scanWords() {
	scan.Split(bufio.ScanWords)
}

func readNextInt() int {
	scan.Scan()

	input, err := strconv.Atoi(scan.Text())
	if err != nil {
		panic(err)
	}
	return input
}



Measured memory_bytes: 1124
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

bool flag[5000];

int N;
bool check(const std::string& S, std::size_t len) {
    for (std::size_t i = 0; i < N - len - 1; ++i) {
        if (flag[i]) {
            continue;
        }

        const std::string sub1 = S.substr(i, len); 
        for (std::size_t j = i + len; j < N - len + 1; ++j) {
            const std::string sub2 = S.substr(j, len);
            if (sub1 == sub2) {
                return true;
            }
        }

        flag[i] = true;
    }

    return false;
}

int main() {
    std::string S;
    std::cin >> N >> S;
        
    std::size_t len = 1;
    while (check(S, len)) {
        ++len;
    }

    std::cout << (len - 1) << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
         while(true) {
        	 int n = sc.nextInt();
        	 if(n==0) break;
        	 int [] s = new int[n];
        	 for(int i=0;i<n;i++) {
        		 s[i] = sc.nextInt();
        	 }
        	 int sum = 0;
        	 int max = 0;
        	 int min = 1000;
        	 for(int i=0;i<n;i++) {
        		 if(s[i]>max) max=s[i];
        		 if(s[i]<min) min=s[i];
        		 sum += s[i];
        	 }
        	 System.out.printf("%d", (sum-max-min)/(n-2));
        	 System.out.println();
         }
        }
    }
}



Measured memory_bytes: 29620
#include<stdio.h>
int main(void)
{
	int n,m,a[1000],b,max,box[1000],i,j,max1;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		box[i]=0;
	}
	for(i=0;i<m;i++){
		scanf("%d",&b);
		for(j=0;j<n;j++){
			if(a[j]<=b){
				box[j]++;
				break;
			}
		}
	}
	for(i=0;i<n;i++){
		if(max<box[i]){
			max1=i+1;
			max=box[i];
		}
	}
	printf("%d\n",max1);
	return 0;
}


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

string f(int n) {
  int x = n;
  string s = to_string(x);
  int keta = 0;
  while(x>0) {
    keta++;
    x /= 10;
  }
  if(keta==1) s = "00000" + s;
  if(keta==2) s = "0000" + s;
  if(keta==3) s = "000" + s;
  if(keta==4) s = "00" + s;
  if(keta==5) s = "0" + s;
  return s;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> vec(100010, vector<ll>());
  vector<P> ve(m);
  rep(i,m) {
    ll p, y;
    cin >> p >> y;
    ve[i].first = p;
    ve[i].second = y;
    vec[p].push_back(y);
  }
  rep(i,100010) sort(vec[i].begin(), vec[i].end());
  rep(i,m) {
    string s = f(ve[i].first);
    int d;
    d = lower_bound(vec[ve[i].first].begin(), vec[ve[i].first].end(), ve[i].second) - vec[ve[i].first].begin();
    string t = f(d+1);
    cout << s + t << endl;
  }
  return 0;
}


Measured memory_bytes: 7808
import numpy as np
import math
n = int(input())
li = list(map(int,input().split()))
half = sum(li) / 2

res = np.cumsum(li)
idx = np.abs(res - half).argmin()
if res[idx] == half:
    ans = 0
else:
    ans = abs(res[idx] - (res[-1] - res[idx]))
print(int(ans))

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

int main(void)
{
	int n, x1, y1, z1, w1, x2, y2, z2, w2;

	while (cin >> n, n)
	{
		for (int i = 0; i < n; ++i)
		{
			cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;

			cout << x1*x2 - y1*y2 - z1*z2 - w1*w2 << " "
				 << x1*y2 + y1*x2 + z1*w2 - w1*z2 << " "
				 << x1*z2 - y1*w2 + z1*x2 + w1*y2 << " "
				 << x1*w2 + y1*z2 - z1*y2 + w1*x2 << endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
#define PI (3.14159265358979)
int main(void) {
  int A, B, H, M;
  cin >> A >> B >> H >> M;

  double h_rad = (H*60.+M)/(12*60)*(2*PI);
  double h_x = sin(h_rad)*A;
  double h_y = cos(h_rad)*A;

  double m_rad = M/60.*(2*PI);
  double m_x = sin(m_rad)*B;
  double m_y = cos(m_rad)*B;

  double dist = sqrt((m_x-h_x)*(m_x-h_x) + (m_y-h_y)*(m_y-h_y));

  cout << fixed << setprecision(10) << dist << endl; 
  return 0;
}


Measured memory_bytes: 4124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> a[i][j];
        }
    }
    vector<tuple<int, int, int, int>> ans;
    for(int i = 0; i < h - 1; ++i){
        for(int j = 0; j < w; ++j){
            if(a[i][j] % 2 == 0)    continue;
            if(j + 1 < w){
                --a[i][j];
                ++a[i][j + 1];
                ans.emplace_back(i + 1, j + 1, i + 1, j + 2);
            }
            else{
                --a[i][j];
                ++a[i + 1][j];
                ans.emplace_back(i + 1, j + 1, i + 2, j + 1);
            }
        }
    }
    for(int j = 0; j + 1 < w; ++j){
        if(a[h - 1][j] % 2 == 0)    continue;
        --a[h - 1][j];
        ++a[h - 1][j + 1];
        ans.emplace_back(h, j + 1, h, j + 2);
    }
    cout << ans.size() << '\n';
    for(auto t : ans){
        cout << get<0>(t) << ' ' << get<1>(t) << ' ' << get<2>(t) << ' ' << get<3>(t) << '\n';
    }
}

Measured memory_bytes: 6324
# coding: utf-8
# Your code here!
# map(int, input().split())

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

height = A[0]
ans = 0
for i in range(1,N):
    if A[i] < height:
        ans += height - A[i]
    else:
        height = A[i]

print(ans)
        

Measured memory_bytes: 32380
#include<stdio.h>

int main()
{
  int x, y, key1, key2;

  scanf("%d%d",&x,&y);

  if(x < y)
    {
      key1 = x;
      x = y;
      y = key1;
    }

  key2 = x % y;

  while(key2 != 0)
    {
      x = y;
      y = key2;
      key2 = x % y;
    }

  printf("%d\n",y);

  return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)(1e18)

signed main(){
  int N, T, K, i, j, k, l;
  scanf("%lld%lld", &N, &T);
  vector<int> h(N + 1, 0), sum(N + 1, 0);
  for(i = 1; i <= N; i++){
    scanf("%lld", &h[i]);
    sum[i] = sum[i - 1] + h[i];
  }
  vector<int> ans(N + 1, 1);
  int Torigin = T;
  int A;
  for(i = 1; i <= N; i += K){
    T = Torigin - sum[i - 1];
    for(k = 0; i + k <= N && h[i] >= h[i + k]; k++);
    K = k;
//    printf("(i, T, K) = (%lld, %lld, %lld)\n", i, T, K);
    j = T / h[i] + 1;
//    printf("j = %lld\n", j);
    for(l = j, k = 0; l >= max(0ll, j - K - 1); l--){
      if(l == 0){
        A = inf;
      }
      else{
        A = T - h[i] * (l - 1);
      }
//      printf("(l, A) = (%lld, %lld)\n", l, A);
      while(k < K && A >= sum[i + k] - sum[i - 1]){
//        printf("k = %lld\n", k);
        ans[i + k] = l + 1;
        k++;
      }
    }
  }
  for(i = 2; i <= N; i++){
    if(ans[i - 1] == 1){
      ans[i] = 1;
    }
  }
  for(i = 1; i <= N; i++){
    printf("%lld\n", ans[i]);
  }
  return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vll b;
	ll a[200];
	ll n;
	cin >> n;
	rep(i, n){
		ll temp; cin >> temp;
		b.pb(temp);
	}
	rep(i, n){
		for(int j=b.size()-1; j>=0; j--){
			if (j+1 == b[j]){
				b.erase(b.begin()+j);
				a[b.size()] = j+1;
				break;
			}
		}
	}
	if (b.size()){
		cout << "-1\n";
	}else{
		rep(i, n) cout << a[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, l, ans;
   cin >> n >> l;
   ans = n * l + n * (n - 1) / 2;
   if (l > 0)
      ans -= l;
   else
      ans -= l + min(-l + 1, n) - 1;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  int mx = (N-1)*(N-2)/2;
  if(mx < K){
    cout << "-1" << endl;
    return 0;
  }
  vector<pair<int, int>> ans;
  for(int i=0;i<N-1;i++){
    ans.push_back(pair<int, int>(i+1,N));
  }
  int add = mx - K;
  vector<pair<int, int>> edge;
  for(int i=0;i<N-1;i++){
    for(int j=0;j<i;j++){
      edge.push_back(pair<int, int>(i+1, j+1));
    }
  }
  for(int i=0;i<add;i++){
    ans.push_back(edge.at(i));
  }
  cout << ans.size() <<endl;
  for(int i=0;i<ans.size();i++){
    cout << ans.at(i).first << " " << ans.at(i).second << endl;
  }
  return 0;
}

Measured memory_bytes: 384
void main(){
	int n, a, b;
	readf("%d %d %d", &n, &a, &b);
	min(n*a, b).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2784
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = next().toList()
    println(if ('9' in n) "Yes" else "No")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

vector<int> countingSort(vector<int> a, int k, int n) {
  vector<int> res(n), c(k+1);
  
  rep(j,n) c[a[j]]++;

  for (int i=1; i<=k; i++) {
    c[i] = c[i] + c[i-1];
  }
  rep(i,k+1) c[i]--;

  for (int j=n-1; j>=0; j--) {
    res[c[a[j]]] = a[j];
    c[a[j]]--;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> ans;
  ans = countingSort(a, *max_element(a.begin(), a.end()), n);
  rep(i,n) printf("%d%c", ans[i], (i == n-1?'\n':' '));
  return 0;
}



Measured memory_bytes: 26328
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

constexpr lli inf = 10000 * 10000;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli s, w;
	cin >> s >> w;

	if (s <= w) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}

	return 0;
}


Measured memory_bytes: 3128
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

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

    sort(a.begin(), a.end());

    int ans = 0;
    for(int i = 1; i < 3; i++) ans += abs(a[i - 1] - a[i]);

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


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

	UnionFind uf(N);

	vector<int> countOfFriends(N, 0);

	for (int i = 0; i < M; i++) {
		int Ai, Bi;
		cin >> Ai >> Bi;
		countOfFriends[Ai - 1]++;
		countOfFriends[Bi - 1]++;

		uf.unite(Ai - 1, Bi - 1);
	}

	vector<int> validBlock(N, 0);
	for (int i = 0; i < K; i++) {
		int Ci, Di;
		cin >> Ci >> Di;
		if (uf.same(Ci - 1, Di -1)) {
			validBlock[Ci - 1]++;
			validBlock[Di - 1]++;
		}
	}

	for (int i = 0; i < N; i++) {
		int result = uf.size(i) - countOfFriends[i] - validBlock[i] - 1;
		cout << result;
		if (i != N - 1) {
			cout << ' ';
		}
		else {
			cout << endl;
		}
	}
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    long long res=0;
    for(int i=1;i<=n;i++)
        res+=1LL*i*(n-i+1);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        if(u>v)swap(u,v);
        res-=1LL*u*(n+1-v);
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 3816