akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,ans=1e18;
int main(){
	scanf("%lld",&n);
	for(long long i=1;i*i<=n;i++)
		if(n%i==0) ans=min(ans,(i+n/i));
	printf("%lld",ans-2);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
	int r, c;
	cin >> r >> c;
	
	int **sp = new int*[r+1];
	for (int i = 0; i < r+1; i++)
	{
		sp[i] = new int[c+1];
		memset(sp[i], 0, sizeof(int) * (c+1));
	}
	
	// input.
	for (int i = 0; i < r; i++)
		for (int j = 0; j < c; j++)
			cin >> sp[i][j];
	
	// column sum.
	for (int i = 0; i < r; i++)
	{
		int csum = 0;
		for (int j = 0; j < c; j++)
		{
			csum += sp[i][j];
		}
		sp[i][c] = csum;
	}
	
	// row sum.
	for (int j = 0; j < c; j++)
	{
		int rsum = 0;
		for (int i = 0; i < r; i++)
		{
			rsum += sp[i][j];
		}
		sp[r][j] = rsum;
	}
	
	// all sum.
	int sum = 0;
	for (int i = 0; i < c; i++)
	{
		sum += sp[r][i];
	}
	sp[r][c] = sum;

	
	// pri
	for (int i = 0; i < r+1; i++)
		for (int j = 0; j < c+1; j++)
		{
			cout << sp[i][j];
			if (j == c)
				cout << endl;
			else
				cout << " ";
		}

	for (int i = 0; i < r+1; i++)
		delete[] sp[i];
	delete[] sp;
	

	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	string a, b;
	cin >> a >> b;
	int n = a.size(), m = b.size();
	vector<vector<int>> dp(n + 1, vector<int> (m + 1, 0));
	vector<vector<char>> pointers(n + 1, vector<char> (m + 1, 'X'));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i - 1] == b[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
				pointers[i][j] = 'D';
			}
			else {
				dp[i][j] = dp[i - 1][j];
				pointers[i][j] = 'U';
				if (dp[i][j - 1] > dp[i][j]) {
					dp[i][j] = dp[i][j - 1];
					pointers[i][j] = 'L';
				}
			}
		}
	}
	string LCS; int i = n, j = m;
	while (pointers[i][j] != 'X') {
		if (pointers[i][j] == 'D') {
			LCS += a[i - 1];
			i--; j--;
		}
		else if (pointers[i][j] == 'L') {
			j--;
		}
		else if (pointers[i][j] == 'U') {
			i--;
		}
	}

	// for (int i = 0; i <=n; i++) {
	// 	for (int j = 0; j <= m; j++) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	// for (int i = 0; i <= n; i++) {
	// 	for (int j = 0; j <= m; j++) {
	// 		cout << pointers[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	reverse(LCS.begin(), LCS.end());
	cout << LCS << endl;;

	return 0;
}

Measured memory_bytes: 82592
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int num = 0;
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
	for(int i = 1; i < n+1; i++){
    	for(int j = 0; j < n-i; j++){
      		if(a[j] > a[j+1]){
        		int work = a[j];
        		a[j] = a[j+1];
        		a[j+1] = work;
       			num++;
      		}
    	}
	}
    for(int i = 0; i < n-1; i++){
      System.out.print(a[i] + " ");
    }
    System.out.println(a[n-1] + "\n" + num);
  }
}



Measured memory_bytes: 26408
#include<iostream>

using namespace std;

int main(){
    int n,k;    cin >> n >> k;
    int a[n];

    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    for(int i=0; i+k<n; i++){
                        if(a[i+k] > a[i]){
                                cout << "Yes" << endl;
                        }else{
                                cout << "No" << endl;
                        }
                }

                return 0;
}

Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];a[i]--;
    }
    int b[n];
    rep(i,n){
        cin>>b[i];
    }
    int c[n];
    rep(i,n-1){
        cin>>c[i];
    }
    int ans=0;
    rep(i,n){
        ans+=b[a[i]];
        if(i==0) continue;
        if(a[i]-a[i-1]==1){
            ans+=c[a[i-1]];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int MOD = 998244353;
    
	struct Edge{
		int from;
		int to;
		int id;
	};
	vector<Edge>revs;

	bool dfs(int now,int from,const vector<int>&sums,vector<int>&comes,const vector<vector<Edge>>&graph){
		bool flag=sums[now]%2;
		comes[now]=true;
		for(auto e:graph[now]){
			if(e.to==from)continue;
			else{
				if(!comes[e.to]){
					auto aflag=dfs(e.to,e.from,sums,comes,graph);
					if(aflag){
						swap(revs[e.id].from,revs[e.id].to);
					}
					flag^=aflag;
				}
			}
		}
		return flag;
	}
     
    int main() {
    	ios::sync_with_stdio(false);
    	int N;cin>>N;
    	vector<vector<Edge>>graph(N);
		int M;cin>>M;
		if(M%2){
			cout<<-1<<endl;
			return 0;
		}else{
			vector<int>sums(N);
			for(int i=0;i<M;++i){
				int a,b;cin>>a>>b;a--;b--;
				graph[a].push_back(Edge{a,b,i});
				graph[b].push_back(Edge{b,a,i});
				revs.push_back(Edge{a,b,i});
				sums[a]++;
			}
			vector<int>comes(N);
			dfs(0,-1,sums,comes,graph);
			for(int i=0;i<M;++i){
				cout<<revs[i].from+1<<' '<<revs[i].to+1<<endl;
			}
		}
		

    	return 0;
    }	

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, K;
string S;

char part(int idx, int shift) {
    char ret;
    if (idx + shift < N)ret = S[idx + shift];
    else ret = (idx + shift - N) % 2 == 0 ? 'B' : 'A';
    if (shift % 2 == 1)ret = 'A' + 'B' - ret;
    return ret;
}
signed main() {
    cin >> N >> K >> S;
    int shift = 0;
    bool turned = false;
    for (int i = 0; i < N; i++) {
        if (S[i] == (i % 2 == 0 ? 'A' : 'B'))K--, turned = true;
        if (K == 0)break;
        K--;
        turned = false;
        shift++;
        if (K == 0)break;
    }
    if (K > 0) {
        if (N % 2 == 0) {
            turned = false;
            shift += K;
        } else {
            turned = K % 2 == 1;
            shift += K / 2;
        }
    }
    if (turned)cout << (char)('A' + 'B' - part(0, shift));
    else cout << part(0, shift);
    for (int i = 1; i < N; i++)cout << part(i, shift);
    cout << endl;
}


Measured memory_bytes: 772
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+10;
const int mod=1e9+7;
main(){
    int x;
    cin>>x;
    if(x<600)cout<<(8)<<endl;
    else if(x<800)cout<<(7)<<endl;
    else if(x<1000)cout<<(6)<<endl;
    else if(x<1200)cout<<(5)<<endl;
    else if(x<1400)cout<<(4)<<endl;
    else if(x<1600)cout<<(3)<<endl;
    else if(x<1800)cout<<(2)<<endl;
    else cout<<(1)<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
struct mzls
{
	int v,t;
}a[100005];
bool operator<(mzls a1,mzls b1)
{
	return a1.v==b1.v?a1.t>b1.t:a1.v>b1.v;
}
int n,m,la[100005];
bool f[100005];
inline int Find(int x)
{
	if(x<0)
		return x;
	return la[x]==x?x:la[x]=Find(la[x]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].t,&a[i].v);
	for(int i=1;i<=m;i++)
		la[i]=i;
	long long ans=0;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		int x=m-a[i].t;
		if(x<0)
			continue;
		x=Find(x);
		if(x<0)
			continue;
		la[x]=x-1,ans+=a[i].v;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1408
x = int(input())

if 400 <= x < 600:
    print("8")
elif 600 <= x < 800:
    print("7")
elif 800 <= x < 1000:
    print("6")
elif 1000 <= x < 1200:
    print("5")
elif 1200 <= x < 1400:
    print("4")
elif 1400 <= x < 1600:
    print("3")
elif 1600 <= x < 1800:
    print("2")
elif 1800 <= x < 2000:
    print("1")


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

typedef long long ll;
typedef long double ld;

int main(){
	static int n;
	static ll a[200010];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		ld A;
		scanf("%Lf",&A);
		A*=1000000000;
		A+=0.5;
		a[i]=(ll)(A);
	}
	static int b[200010],c[200010];
	for(int i=0;i<n;i++){
		b[i]=c[i]=0;
		while(a[i]%2==0){
			a[i]/=2;
			b[i]++;
		}
		while(a[i]%5==0){
			a[i]/=5;
			c[i]++;
		}
	}
	static ll cnt[20][20]={};
	for(int i=0;i<n;i++){
		cnt[min((int)b[i],18)][min((int)c[i],18)]++;
	}
	ll ret=0;
	for(int i=0;i<=18;i++)for(int j=0;j<=18;j++)for(int k=0;k<=18;k++)for(int l=0;l<=18;l++){
		if(i+k>=18&&j+l>=18)ret+=cnt[i][j]*cnt[k][l];
	}
	for(int i=9;i<=18;i++)for(int j=9;j<=18;j++){
		ret-=cnt[i][j];
	}
	cout<<ret/2<<endl;
}

Measured memory_bytes: 6960
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    int n=nxt();
    cin>>s>>t;
    for(int i=0;i<n;i++)
    cout<<s[i]<<t[i];
cout<<endl;
    
    

    return 0;   
}


 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod 1000000007
using namespace std;
vector<ll> prime,sfac;
vector<ll>ps;
void sieve(ll n)
{
	prime.assign(n+1,1);
	sfac.assign(n+1,1);    
    for (int p=2; p*p<=n; p++) 
    {         
        if (prime[p] == 1) 
        { 	sfac[p]=p;  			  
            for (int i=p*p; i<=n; i += p) 
              {  prime[i] = 0; sfac[i]=p;}
        } 
    } 
	for(ll i=2;i<=n;i++)
	{
		if(prime[i])
			ps.push_back(i);
	}
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll power(ll x, ll y) 
{ 
    ll res = 1;    
    while (y > 0) 
    { 
        ll k=y&1LL;
        if (k) 
            res = res*x;      
        y = y>>1LL;
        x = x*x;  
    } 
    return res; 
}
 
int isPrime(ll n) 
{ 
    if (n <= 1)  return 0; 
    if (n <= 3)  return 1; 
    if (n%2 == 0 || n%3 == 0) 
        return 0;   
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return 0;  
    return 1; 
} 
int main()
{
    sync
    ll tt;
    cin>>tt;
    cout<<(tt+(tt*tt)+(tt*tt*tt))<<endl;
}

Measured memory_bytes: 3636
int printf(const char * restrict, ...) __attribute__((__format__ (__printf__, 1, 2)));
int scanf(const char * restrict format, ...);
int strlen(const char *s);
int strcmp(const char *s1, const char *s2);

int main(void){
    int n,ans=1;
    scanf("%d",&n);
    char w[n][120];
    for (int i=0; i<n; i++){
        scanf("%s",w[i]);
    }
    for (int i=0; i<n-1; i++){
        if (w[i][strlen(w[i])-1]!=w[i+1][0]){
            ans=0;
        }
    }
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            if (i!=j && strcmp(w[i],w[j])==0){
                ans=0;
            }
        }
    }
    if (ans==1){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0 ;
}

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

bool judge(string S) {
  bool result = true;
  for (char x : S) {
    if (x != 'A' && x != 'G' && x != 'C' && x != 'T') {
      result = false;
      break;
    }
  }
  return result;
}

int main() {
  string S;
  cin >> S;
  int max_S=0;
  for (int i=0;i<S.size();i++) {
    string T="";
    for (int j=i;j<S.size();j++) {
      T += S.at(j);
      if (judge(T) && max_S<T.size()) max_S = T.size();
    }
  }
  cout << max_S << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter

# sys.stdin = open('c1.in')


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    possible = 'POSSIBLE'
    impossible = 'IMPOSSIBLE'
    n, m = read_int_list()
    c = Counter()
    res = impossible
    for i in range(m):
        a, b = read_int_list()
        if a == 1:
            c[b] += 1
        if b == n:
            c[a] += 1
        if c[a] == 2 or c[b] == 2:
            res = possible
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

int main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<bool> is_ok(n + 1, true);
    for (int i = 0; i < m; i++) {
        int temp;
        std::cin >> temp;

        is_ok[temp] = false;
    }

    std::vector<long long> dp(n + 1, 0);
    dp[0] = 1;
    if (is_ok[1]) {
        dp[1] = 1;
    }

    for (int i = 2; i <= n; i++) {
        if (is_ok[i]) {
            const int mod = 1000000007;
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= mod;
        }
    }

    std::cout << dp[n] << std::endl;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

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

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

ll ans=0;

void solve()
{
	int n,i;
	cin>>n;
	int u,v;
	for(i=1;i<=n;i++)
	ans += 1LL*i*(n-i+1);
	for(i=1;i<n;i++)
	{
		cin>>u>>v;
		if(u>v) swap(u,v);
		ans -= 1LL*u*(n-v+1);
	}
	cout<<ans<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

using namespace std;

int strcmp(string s, string t) {
	if (s[0] < t[0]) {
		return 1;
	}
	else if (s[0] == t[0]) {
		if (s.length() == 1 && t.length() == 1) {
			return 0;
		}
		else if (s.length() == 1) {
			return 1;
		}
		else if (t.length() == 1) {
			return -1;
		}
		else {
			return strcmp(s.substr(1), t.substr(1));
		}
	}
	else {
		return -1;
	}
}
int main() {
	int n, e = 0, f = 0;
	cin >> n;
	vector<string> a, b;

	for (int i = 0;i < n;i++) {
		string t, h;
		cin >> t >> h;
		a.push_back(t);
		b.push_back(h);
	}
	for (int i = 0;i < n;i++) {
		int c = strcmp(a[i], b[i]);
		switch (c) {
		case 1:
			f += 3;
			break;
		case 0:
			f++;
			e++;
			break;
		case -1:
			e += 3;
			break;
		default:
			cout << "hoge" << endl;
		}
	}
	cout << e << " " << f << endl;
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
set<ll> st;
map<char, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

typedef pair<Weight, Edge> P;

int V, E, r;
bool isdone[100005];
vector<Weight> dist(100005, INF);
priority_queue<P, vector<P>, greater<P>> pq;

void dijkstra(Graph &g, int r)
{
	dist[r] = 0;
	isdone[r] = true;
	for (auto e : g[r])
	{
		pq.emplace(e.cost, e);
	}
	while (!pq.empty())
	{
		Edge te = pq.top().second;
		pq.pop();
		if(dist[te.to]>dist[te.from]+te.cost)
		{
			dist[te.to] = dist[te.from] + te.cost;
			isdone[te.to] = true;
			for(auto e: g[te.to])
			{
				pq.emplace(e.cost, e);
			}
		}
	}
}

int main()
{
	cin >> V >> E >> r;
	Graph g(V);
	REP(i, E)
	{
		ll a, b, c;
		cin >> a >> b >> c;
		add_edge(g, a, b, c);
	}
	dijkstra(g, r);
	REP(i, V) {
		if (dist[i] == INF) cout << "INF" << endl;
		else cout << dist[i] << endl;
	}
}

Measured memory_bytes: 47548
def main():
    n = int(input())
    b = list(map(int, input().split()))
    
    arr = [0] * n
    arr[0] = b[0]
    arr[-1] = b[-1]
    for i in range(1, n - 1):
        arr[i] = min(b[i], b[i - 1])
    
    print(sum(arr))
    
    return 0

main()


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

int main(){
    int N,i,arare;
    char s;

    arare = 0;

    cin >> N;
    
    rep(i,N){
        cin >> s;
        if(s == 'Y'){
            arare = 1;
        }
    }
    if(arare == 1){
        cout << "Four";
    }
    else{
        cout << "Three";
    }
}


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

int main(void) {
	int N;
	scanf("%d", &N);
	long ans = 0;
	for (int i = 1; i <= N - 1; i++) {
		ans += i;
	}
	printf("%ld", ans);
	return 0;
}


Measured memory_bytes: 3692
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

int main()
{
    int H,W,h,w;
    cin >> H >> W >> h >> w ;

    p((H-h)*(W-w))
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    string day[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s; cin >> s;
    rep(i, 7){
        if(s == day[i]){
            cout << 7-i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int res = n;
    for(int i=0; i<=n; ++i){
        int cnt = 0;
        int t = i;
        while(t>0){
            cnt += t % 6;
            t /= 6;
        }
        t = n - i;
        while(t>0){
            cnt += t % 9;
            t /=9;
        }
        if(res > cnt) res = cnt;
    }
    cout << res << "\n";
    return 0;
}



Measured memory_bytes: 256
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

const INF: i64 = std::i64::MAX;

fn main() {
   input! {
      n: usize,
      m: usize,
      abc: [(usize, usize, i64); m]
   }
   let mut d = vec![-INF; n];
   d[0] = 0;
   for _ in 0..n {
      for &(a, b, c) in abc.iter() {
         if d[a - 1] != -INF && d[a - 1] + c > d[b - 1] {
            d[b - 1] = d[a - 1] + c;
         }
      }
   }
   for _ in 0..n {
      for &(a, b, c) in abc.iter() {
         if d[a - 1] != -INF && (d[a - 1] == INF || d[a - 1] + c > d[b - 1]) {
            d[b - 1] = INF;
         }
      }
   }
   if d[n - 1] == INF {
      println!("inf");
   } else {
      println!("{}", d[n - 1]);
   }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
	int k,n;
	cin>>k>>n;
	int a[n];
	REP(i,n)cin>>a[i];
	int max_len=0;
	for(int i=1;i<n;i++){
		max_len=max(max_len, a[i]-a[i-1]);
	}
	max_len=max(max_len, a[0]+(k-a[n-1]));
	cout<<k-max_len<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c;cin>>a>>b>>c;
    cout << b+(b-a) << ednl;
}

Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]
d = 0
for i in range(2, n):
    a, b, c = p[i - 2], p[i - 1], p[i]
    if (a < b < c) or (c < b < a):
        d += 1
print(d)


Measured memory_bytes: 2940
# coding:utf-8
list=[0]*1000
for i in range(1,201,1):
    m=1
    while m*i<=200:
        list[m*i]+=1
        m+=1
n=int(input())
ct=0
for i in range(1,n+1,2):
    if list[i]==8:
        ct+=1
print(ct)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

    long double odds = N / 2 + N % 2;

    long double ans = odds / N;
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n, r[200000];
    int i, j, maxv, minv;
    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d", &r[i]);

    maxv = r[1] - r[0];
    minv = r[0];
    for(j=1;j<n;j++){
        if(r[j]-minv > maxv) maxv = r[j]-minv;
        if(r[j] < minv) minv = r[j];
    }
    /* for(i=n-1;i>0;i--){ */
    /*     #<{(| if(r[i] < max) break; |)}># */
    /*     for(j=i-1;j>=0;j--){ */
    /*         if(r[i]-r[j] > max){ */
    /*             max = r[i]-r[j]; */
    /*         }  */
    /*     } */
    /* } */
    printf("%d\n", maxv);
    return 0;
}

Measured memory_bytes: 1376
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int lli;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
lli n;
cin>>n;
string s=" ";
while(n>0)
{
    lli x,y;
    x=n/26;
    y=n%26;
    if(y==0)
    {
        x--;
        s=s+(char)('z');
    }
    else
    {
        s=s+(char)(('a'+y-1));
    }
    n=x;
}
reverse(s.begin(),s.end());
cout<<s<<"\n";
}

Measured memory_bytes: 3616
n = int(input())
A = list(map(int, input().split()))
c = 0

for i in range(n-1):
    minj = i
    for j in range(i, n):
        if A[j] < A[minj]:
            minj = j
    if minj != i:
        A[i], A[minj] = A[minj], A[i]
        c += 1
print(*A, sep=' ')
print(c)


Measured memory_bytes: 5608
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var ans = 0
for _ in 0..<N {
    let person = readIntSplit(by: " ")
    ans += person[1] - person[0] + 1
}
print(ans)


Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

ll mod=1000000007;
ll com[2010][2010];

void comInit(int max){
  int i,j;
  for(i=0;i<max;i++)com[i][0]=com[i][i]=1;
  for(i=2;i<max;i++){
    for(j=1;j<i;j++){
      com[i][j]=com[i-1][j-1]+com[i-1][j];
      com[i][j]%=mod;
    }
  }
  return;
}

int main(void){
  ll n,k,i;
  cin>>n>>k;

  comInit(2010);

  for(i=1;i<=k;i++){
    cout<<com[k-1][i-1]*com[n-k+1][i]%mod<<endl;
  }

	return 0;
}


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

using namespace std;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int A, B; cin >> A >> B; string S; cin >> S;
    bool no = false;
    for (int i = 0; i <= A+B; i++)
        if ((S[i] == '-' && i != A) || (S[i] != '-' && i == A)) {
            cout << "No" << endl; no = true; break;
        }
    if (!no)
        cout << "Yes" << endl;

    return 0;
}

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

using ll = long long;
using namespace std;

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    int ans = 0;
    for (ll i = 1; i * i <= g; i++) {
        if (g % i == 0 && is_prime(i)) {
            ans++;
        }
        ll rest = g/i;
        if (g % rest == 0 && is_prime(rest)) {
            ans++;
        }
        if (g == i * i && is_prime(i)) {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0){
            ans++;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3540
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int a,b,c;
  	cin >>a >> b>> c;
  	if(c % gcd(a,b) == 0)cout << "YES" <<endl;
  	else cout << "NO" <<endl;
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

#define ll long long

using namespace std;

//bool isPal(string s) {
//    string s2 = s;
//    reverse(s.begin(), s.end());
//    if (s2 == s) {
//        return true;
//    } else {
//        return false;
//    }
//}

string s[11];

int mp[12];

int main() {

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

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

    int best = 1000000;

    for (int i = 0; i < n; i ++) {
        cin >> s[i];
    }

    for (int i = 0; i < (1 << (n - 1)); i ++) {
//        cout << i << "\n";

        int now = 0;
        int num = 0;
        for (int j = 0; j < n; j ++) {
//            cout << j << "/" << now << " ";
            mp[j] = now;
            if (i & (1 << j)) {
                num ++;
                now ++;
            }
        }
//        cout << "\n";
//        cout << "pred num : " << num << "\n";

        vector<int> cnt(n);




        for (int j = 0; j < m; j ++) {
            bool z = true;
            for (int l = 0; l < n; l ++)
            if (s[l][j] == '1')
            {
                cnt[mp[l]] ++;
                if (cnt[mp[l]] > k) {
                    z = false;
                }

            }

//            cout << z << " ";

            if (!z) {
                z = true;
//                cout << "|";
                num ++;
                cnt.clear();
                cnt.resize(n);
                for (int l = 0; l < n; l ++)
                    if (s[l][j] == '1')
                {
                    cnt[mp[l]] ++;
                    if (cnt[mp[l]] > k) {
                        num = 1000000000;
                    }
                }
            }

        }
//        cout << "\n";
//        cout << num << "!\n";
        best = min(best,num);
    }
    cout << best;

}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	vector<int> G[610];
	int n,m,a[200000],b[200000];
	scanf("%lld %lld",&n,&m);
	for(int i = 0;i < m;i++){
		scanf("%lld %lld",&a[i],&b[i]); a[i]--;b[i]--;
		G[a[i]].push_back(b[i]);
	}
	double p[610] = {1},e[610] = {};
	for(int i = 0;i < n;i++){
		for(int to : G[i]){
			p[to] += p[i] / G[i].size();
		}
	}
	for(int i = n - 1;i >= 0;i--){
		for(int to : G[i]){
			e[i] += (e[to] + 1) / G[i].size();
		}
	}
	double mi = e[0];
	for(int i = 0;i < n;i++){
		if(G[i].size() == 1) continue;
		double ea = 0,ma = 0;
		for(int to : G[i]){
			double add = (e[to] + 1) / (G[i].size() - 1);
			ea += add;
			ma = max(ma,add);
		}
		chmin(mi,e[0] + p[i] * (ea - ma - e[i]));
	}
	printf("%.12lf\n",mi);
}


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

int main(void){
	int N;
	cin >> N;
	vector<int> L(2*N);
	for(int i=0;i<2*N;i++){
		cin >> L[i];
	}
	sort(L.begin(),L.end());
	int ret = 0;
	for(int i=0;i<2*N;i+=2){
		ret += L[i];
	}
	cout << ret << endl;
	return 0;
}

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

long long mod = 1000000007;

long long pow_kai(long long a, long long n){//aのn乗を計算します。
  long long x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
      x %= mod;
    }
    a = a*a;
    a %= mod;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}


int main() {
  long long N,K;
  cin >> N >> K;
  long long nu;
  vector<long long> ans(K+1);
  for (int i=K; i>=1; i--) {
    nu = K/i;
    ans[i] = pow_kai(nu,N);
    for (int j=2; j>0; j++) {
      if (i*j > K) {
        break;
      }
      ans[i] += mod;
      ans[i] -= ans[i*j];
      ans[i] %= mod;
    }
  }
  
  long long total = 0;
  for (int i=1; i<=K; i++) {
    total += i * ans[i];
    total %= mod;
  }
  
  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 3968
import collections

n = int(input())
s = [input() for i in range(n)]
if n == 1:
    print("".join(sorted(s[0])))
else:
    c = []
    for i in s:
        c.append(collections.Counter(i))
    a = c[0] & c[1]
    for i in range(2, n):
        a &= c[i]
    ans = []
    a = a.most_common()
    for i in a:
        for j in range(i[1]):
            ans.append(i[0])
    print("".join(sorted(ans)))

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in(), k = in();
    vint x = in(n);
    int ans = 0;
    rep(i, n)
    {
        ans += min(abs(k - x[i]) * 2, x[i] * 2);
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;

int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n , m;
    cin >> n >> m;

    vector<vector<int> > a(m , vector<int>());
    for(int i = 0 ; i < m ; ++i){
        int sz;
        cin >> sz;
        while(sz--){
            int x;
            cin >> x;
            x--;
            a[i].pb(x);
        }
    }

    vector<int> p(m);
    for(int &x : p)
        cin >> x;

    int ans = 0;

    for(int msk = 0 ; msk < (1 << n) ; ++msk){

        int cnt = 0;
        for(int i = 0 ; i < m ; ++i){
            int c = 0;
            for(int j : a[i]){
                c += ((msk & (1 << j)) > 0);
            }
            cnt += (c % 2 == p[i]);
        }
        if(cnt == m)++ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  std::vector<int > s(M), c(M);
  std::map<int, int> mp;
  bool ng = false;
  for (int i=0; i<M; i++){
    scanf("%d", &s[i]);
    scanf("%d", &c[i]);
    for (auto entry : mp){
      if (entry.first==s[i] && entry.second!=c[i]){
        ng = true;
      }
    }
    mp[s[i]]=c[i];
  }
  if (ng){
    printf("-1\n");
    return 0;
  }
  if (M==0 && N==1){
    printf("0\n");
    return 0;
  } else if (M==0){
    int ans = (int)pow(10, N-1);
    printf("%d\n", ans);
    return 0;
  }
  int mp_max = 0;
  int N_value;
  bool Nset = false;
  for (auto entry : mp){
    mp_max = std::max(mp_max, entry.first);
    if (entry.first==1){
      Nset=true;
      N_value = entry.second;
    }
  }
  if (mp_max>N){
    printf("-1\n");
  } else if (Nset && N_value==0 && N!=1){
    printf("-1\n");
  }else {
    int ans = 0;
    for (int i=1; i<=N; i++){
      for (auto entry : mp){
        //std::cout << entry.first << "," << entry.second << std::endl;
        if (entry.first == i){
          ans += (int)pow(10,N-i)*entry.second;
        }
        if (i==1 && ans==0 && N!=1){
          ans += (int)pow(10,N-1);
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}


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

int main() {
	// your code goes here
      string a,b;
      getline(cin,a);
      getline(cin,b);
      int i;
      int f=0;
      for(i=0;i<3;i++)
      {
          if(a[i]!=b[2-i])
          {
              f=1;
              break;
          }
      }
      if(f==1)
      printf("NO\n");
      else
      printf("YES\n");
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner input = new Scanner(System.in);
    int a = input.nextInt();
    int b = input.nextInt();
    int c = input.nextInt();
    
    if(b/a>=c)
      System.out.println(c);
    else
      System.out.println(b/a);
  }
}

Measured memory_bytes: 22740
// date: 22/08/20 17:35:34 // 
#include <bits/stdc++.h>
using namespace std;

#define iterall(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vd;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vd> vvd;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;
typedef vector <pll> vpll;

const ll INF = 1e9+5;
const double EPS = 1e-9;


int main()
{
    string s;
    cin >> s;
    ll res = 0;
    for(auto i: s)
    {
        res = (res+(i-'0'))%9;
    }
    cout << (res == 0? "Yes": "No") << endl;
}

Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#include<math.h>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	bool flag = false;
	string sub_1 = s.substr(0, n / 2);
	string sub_2 = s.substr(n / 2, n / 2);
	if (sub_1 == sub_2)flag = true;
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {

    var N = Number(lines[0].split(" ")[0])
    var K = Number(lines[0].split(" ")[1])

    if (N % K === 0) { console.log(0) }
    else { console.log(1) }
});

Measured memory_bytes: 22964
import itertools
import math
n = int(input())                    #n = 町の個数
l = [list(map(int,input().split())) for i in range(n)]
x,y = [list(i) for i in zip(*l)]    #x,y = 町の座標
l = list(range(n))                  
z = list(itertools.permutations(l)) #z = 経路の組み合わせ
m = math.factorial(n)               #m = 経路の個数
t = 0                               #t = 長さの合計

for i in range(m):
    for j in range(n - 1):
        t += math.sqrt((x[z[i][j]] - x[z[i][j+1]]) ** 2 + (y[z[i][j]] - y[z[i][j+1]]) ** 2)

print(t / m)

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

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

    if (s >= "2019/05/01")
    {
        cout << "TBD";
    }
    else 
    {
        cout << "Heisei";
    }
        
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;
    s += 'R';
    int n = s.size();

    std::vector<int> ret(n - 1);
    std::vector<int> a { 0, 0 };
    int st = 0, midr, midl;
    for (int i = 0; i < n; i++) {
        if (st == 0) {
            if (s[i] == 'R') {
                a[i & 1]++;
            } else {
                ret[i] += a[i & 1];
                ret[i - 1] += a[!(i & 1)];
                midr = i - 1;
                midl = i;
                a[i & 1] = 1;
                a[!(i & 1)] = 0;
                st = 1;
            }
        } else {
            if (s[i] == 'R') {
                ret[midl] += a[midl & 1];
                ret[midr] += a[midr & 1];
                a[i & 1] = 1;
                a[!(i & 1)] = 0;
                st = 0;
            } else {
                a[i & 1]++;
            }
        }
    }

    for (auto e : ret) std::cout << e << " ";
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <functional>

typedef long long ll;


#define V vector
#define pb push_back


#include <math.h>


typedef long long ll;
using namespace std;


class Solution {
public:
    void solve(int num, std::istream& in, std::ostream& out) {
		int n; in >> n; ll k; in >> k;
		vector<int> arr(n);
		for(int i = 0;i < n;i++) {
			in >> arr[i]; arr[i]--;
		}
		if (arr[0] == 0) {
			out << 1; return;
		}

		V<bool> used(n); V<int> path;
		int from = -1;
		for (int i = 0;;) {
			if (!used[i]) {
				used[i] = true;
				path.pb(i);
				i = arr[i];
			}
			else {
				from = i;
				break;
			}
		}
		if (k < path.size()) {
			out << 1 + path[k]; return;
		}

		int lo = 0, len = 0;
		for (int i = 0; i < path.size(); i++) {
			if (path[i] == from) {
				lo = i;
				len = path.size() - lo;
				break;
			}
		}

		ll rest = (k - lo) % len;

		out << 1 + path[lo + rest];
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
	//int T; in >> T;
	//for(int i = 0;i < T;i++)
		//solution.solve(i+1, in, out);
	solution.solve(0, in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 4720