akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
    while (1) {
        char n;
        int num[10][10];
        for (int i = 0; i < 10; i++) {
            if (!(cin >> n)) {
                return 0;
            }
            num[0][i] = n - '0';
        }
        for (int i = 1; i < 10; i++) {
            for (int j = 0; j < 10 - i; j++) {
                num[i][j] = (num[i - 1][j] + num[i - 1][j + 1]) % 10;
            }
        }
        cout << num[9][0] << endl;
    }

    return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int a,b,c;
        cin>>a>>b>>c;
        cout<<c-max(0,min(a-b,c));
      r0   
     }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1046527/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
if ( ch == 'A') return 1;
 else if ( ch == 'C') return 2;
 else if ( ch == 'G') return 3;
 else if ( ch == 'T') return 4;
 else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
long long sum = 0, p = 1, i;
for ( i = 0; i < strlen(str); i++ ){
sum += p*(getChar(str[i]));
p *= 5;
}
return sum;
}

int h1(int key){ return key%M;/* your task */ }
int h2(int key){ return 1+(key%(M-1));/* your task */ }

int find(char str[]){
/* your task */
long long key,i,h;
key=getKey(str);
for(i=0;;i++){
h=(h1(key)+i*h2(key))%M;
if(strcmp(H[h],str)==0)return 1;
 else if(strlen(H[h])==0)return 0;
}
return 0;
}

int insert(char str[]){
/* your task */
long long key ,i,h;
key=getKey(str);
for(i=0;;i++){
h=(h1(key)+i*h2(key))%M;
if(strcmp(H[h],str)==0)return 1;
 else if(strlen(H[h])==0){
strcpy(H[h],str);
return 0;
}
}
return 0;
}

int main(){
int i, n, h;
char str[L], com[9];
for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
scanf("%d", &n);
    
for ( i = 0; i < n; i++ ){
scanf("%s %s", com, str);
	
if ( com[0] == 'i' ){
insert(str);
} else {
if (find(str)){
printf("yes\n");
} else {
printf("no\n");
}
}
}

return 0;
}



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

int main () {
     int a;
     int b;
     int c;
     cin >> a;
     cin >> b;
     cin >> c;
     if ( a < b && b < c ) {
          cout << "Yes" << endl;
     } else {
          cout << "No" << endl;
     }
     return 0;
}


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

using namespace std;

//#define FILE_IO

typedef pair<int, int> pii;

int N, f[100005], sz[100005];
queue <pii> q;
multiset <int> edg[100005];

int F(int x)
{
    if(f[x] == x)   return x;
    return f[x] = F(f[x]);
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= 2 * N - 2; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);

        edg[x].insert(y);
        edg[y].insert(x);

        if(edg[x].count(y) == 2)    q.push({x, y});
    }

    for(int i = 1; i <= N; i++)
        f[i] = i, sz[i] = 1;

    while(!q.empty())
    {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();

        int fx = F(x), fy = F(y);
        if(fx == fy)    continue;
        if(fx != x || fy != y)  continue;

        if(sz[x] > sz[y]) swap(x, y);

        f[x] = y;
        sz[y] += sz[x];

        edg[y].erase(x);
        edg[x].erase(y);

        for(auto nxt: edg[x])
        {
            edg[nxt].erase(x);

            edg[y].insert(nxt);
            edg[nxt].insert(y);

            if(edg[y].count(nxt) == 2)
                q.push({y, nxt});
        }
    }

    if(sz[F(1)] == N)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


Measured memory_bytes: 24960
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const long double INF = (1e10);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[55],dp[55];

int main(void){
	int n,i,j,l,r;
	ll m,ans=INFLL;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i+1];
		a[i+1] += a[i];
	}
	for(r=0; r<=n; ++r){
		for(l=0; l<r; ++l){
			if(r==n&&l==0){
				continue;
			}
			m = a[r]-a[l];
			for(i=0; i<=n; ++i){
				dp[i] = (a[i]<m)?INFLL:a[i];
				if(i==n){
					dp[i] = INFLL;
				}
				for(j=1; j<i; ++j){
					if(a[i]-a[j]<m){
						continue;
					}
					dp[i] = min(dp[i],max(dp[j],a[i]-a[j]));
				}
			}
			ans = min(ans,dp[n]-m);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3112
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]

for i in range(10**n):
  i2=str(i)
  if len(i2)==n and all([i2[s-1]==str(c) for s,c in sc]):
      print(i2)
      exit()
print(-1)


Measured memory_bytes: 3060
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

bool chmin(ll &a, ll b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll Min = LINF;
  chmin(Min, x * a + y * b);
  chmin(Min, max(x, y) * c * 2);
  if (x > y)
    chmin(Min, y * c * 2 + (x - y) * a);
  else
    chmin(Min, x * c * 2 + (y - x) * b);
  cout << Min << endl;
  return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
signed main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	ll m,k;
	cin>>m>>k;
	rep(i,n-1)in[n-i-1]-=in[n-i-2];
	vi t(n-1);
	rep(i,n-1)t[i]=i;
	while(m--){
		int a;cin>>a;
		swap(t[a-2],t[a-1]);
	}
	while(k){
		if(k%2){
			vi w=in;
			rep(i,n-1)w[i+1]=in[t[i]+1];
			in=w;
		}
		vi nt(n-1);
		rep(i,n-1)nt[i]=t[t[i]];
		t=nt;
		k/=2;
	}
	rep(i,n-1)in[i+1]+=in[i];
	rep(i,n)cout<<in[i]<<endl;
}







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

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

using namespace std;

int main(){
	int n,m,d; scanf("%d%d%d",&n,&m,&d);

	double e;
	if(d>0) e=2*(n-d);
	else    e=n;
	e/=n;
	e/=n;
	e*=m-1;
	printf("%.9f\n",e);

	return 0;
}


Measured memory_bytes: 3820
#include <iostream>
#include <cstdio>
#define N 3002
using namespace std;
int n,m,k,l,r,u,d,i,j,ans[N][N];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			int x=i+j,y=i-j+m-1;
			l=min(l,y);r=max(r,y);
			u=min(u,x);d=max(d,x);
		}
	}
	for(i=u;i<=d;i++){
		for(j=l;j<=r;j++){
			int x=i+1,y=j+1;
			if(((x-1)/k)%2==0){
				if(((y-1)/k)%2==0) ans[i][j]=1;
				else ans[i][j]=2;
			}
			else{
				if(((y-1)/k)%2==0) ans[i][j]=3;
				else ans[i][j]=4;
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			int x=i+j,y=i-j+m-1;
			if(ans[x][y]==1) printf("R");
			else if(ans[x][y]==2) printf("Y");
			else if(ans[x][y]==3) printf("G");
			else printf("B");
		}
		puts("");
	}
	return 0;
}


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

using int64 = long long;

int64 solve(const int64 h, const int64 w) {
  if (h == 1 || w == 1)
    return 1;
  int64 ret = (h / 2) * w;
  if (h % 2 == 1)
    ret += (w + 1) / 2;
  return ret;
}

int main() {
  int64 h, w;
  cin >> h >> w;
  cout << solve(h, w) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 92233720ll;
bool mywish(const pair<pair<string,int>,int> &a,const pair<pair<string,int>,int> &b)
  {
    if(a.ff.ff == b.ff.ff)
       return a.ff.ss > b.ff.ss;
    else
       return a.ff.ff < b.ff.ff;
  }
  
void solve()
 { 
  int n;
  cin>>n;
  vector<pair<pair<string,int>,int>> v(n);
  loop(i,0,n)
   {
    string s;
    int p;
    cin>>s>>p;
    v[i] = {{s,p},i+1};
   }
  sort(v.begin(), v.end(),mywish);
  loop(i,0,n)
   cout<<v[i].ss<<END;
 }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 256
import static java.lang.System.*;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner s = new Scanner(in);
		int total = 0;
		total+= s.nextInt()*100;
		total+= s.nextInt()*10;
		total+= s.nextInt();
		
		if(total%4==0)
			out.println("YES");
		else
			out.println("NO");
	}
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nab = br.readLine().split(" ");
        int n = Integer.parseInt(nab[0]);
        int a = Integer.parseInt(nab[1]);
        int b = Integer.parseInt(nab[2]);
        System.out.println(problem133a(n, a, b));
    }

    private static int problem133a(int n, int a, int b) {
        return Math.min((n * a), b);
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<cmath>
#include<ctype.h>
#include<vector>
#include<cstdlib>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<time.h>

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
const ll INF = -10000000000;

using namespace std;

int tmp[100] = {};

int main()
{
	char w[100];
	cin >> w;
	for (int i = 0; i < strlen(w); i++){
		tmp[w[i] - 97]++;
	}
	int flag=0;

	for (int i = 0; i < 50; i++){
		if (tmp[i] % 2 != 0){
			flag = 1;
			break;
		}
	}

	if (flag == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2 != 0)cout << "No" <<endl;
    else{
        int p = n/2;
        bool pos = true;
        for(int i = 0 ; i < p ; i++){
            if(s[i] != s[i+p]){
                pos = false;
                break;
            }
        }
        if(pos)cout << "Yes" <<endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,k;
    cin >> n >> k;
    int v[n];
    REP(i,n){
        cin >> v[i];
    }
    int ans = 0;
    for(int a = 0; a <= k; a++){
        for(int b = 0; a + b <= k && a + b <= n; b++){
            priority_queue<int, vector<int>, greater<int>> que;
            REP(i,a){
                que.push(v[i]);
            }
            for(int i = n - 1; i > n - 1 - b; i--){
                que.push(v[i]);
            }
            for(int c = 1; a + b + c <= k; c++){
                if(que.size() == 0 || que.top() >= 0){
                    break;
                }
                que.pop();
            }
            int sum = 0;
            while(que.size()){
                sum += que.top();
                que.pop();
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int s[100001];
	int cnt=0;
	for (int i=0;i<m;i++)
	{
		cin>>s[i];
		cnt+=s[i];
    }
    if (cnt>=n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ff(i, x, y) for(int i = x;i <= y;i++)
using namespace std;
typedef long long ll;
int n, pre[100010], mes[100010], ans, bit[200010], cnt;
ll sum;
//map<int, int>mp;
int lowbit(int x)
{
    return x&(-x);
}
void add(int i,int x)
{
    while(i<=n + 100005)
    {
        bit[i]+=x;
        i+=lowbit(i);
    }
	return;
}
void sub(int i,int x)
{
    while(i<=n + 100005)
    {
        bit[i]-=x;
        i+=lowbit(i);
    }
	return;
}
int qsum(int i)
{
    int s=0;
    while(i>0)
    {
        s+=bit[i];
        i-=lowbit(i);
    }
    return s;
}
bool check(int x) {
	ll tmp = 0;
	ff(i, 1, n) {
		if(mes[i] <= x)
			pre[i] = -1;
		else
			pre[i] = 1;
		pre[i] += pre[i - 1];
	//	bit[i] = bit[i + 100005] = 0;
	}
	ff(i, 1, 200005)
		bit[i] = 0;
	add(100005, 1);
	ff(i, 1, n) {
		tmp = tmp + i - qsum(pre[i] + 100005);
		add(pre[i] + 100005, 1);
	//	cout << tmp << endl;
	}
	//cout << "     " << x << "     " << tmp << endl;
	//cout << tmp << endl;
	if(tmp >= sum / 2 + 1)
		return true;
	return false;
}
int main() {
	scanf("%d", &n);
	sum = (n + 1);
	sum = sum * n / 2;
	ff(i, 1, n) {
		scanf("%d", &mes[i]);
		//pre[i] = mes[i];
	}
	int l = 1, r = 1e9 + 10, mid = (l + r) / 2;
	//cout << mid << endl;
	while(l <= r) {
		mid = (l + r) / 2;
		if(check(mid)) {
			ans = mid;
			r = mid - 1;
		}
		else 
			l = mid + 1;
	}
	printf("%d\n", ans);
	return 0;	
}

Measured memory_bytes: 1792
using System;
using System.IO;
using System.Collections.Generic;

namespace AGC024A
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var A = ss.Next(long.Parse);
            var B = ss.Next(long.Parse);
            var C = ss.Next(long.Parse);
            var K = ss.Next(long.Parse);

            if (K % 2 == 0) sw.WriteLine(A - B);
            else sw.WriteLine(B - A);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    map <int,int> color;
    int crown = 0;
    int n;
    cin >> n;
    REP(i,n){
        int tmp;
        cin >> tmp;
        if(tmp / 400 > 7)crown ++;
        else{
            color[tmp/400]++;
        }
    }
    if(color.size() == 0){
        cout << 1 << " " << crown << endl;
    }
    else 
    cout << color.size() << " " << color.size()+crown << endl;
    return 0;
}

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

int N, M;
std::string S;

int main() {
  std::cin >> N >> M >> S;
  int cur = N;
  std::stack<int> ans;
  for(;;) {
    if(cur <= M) { ans.push(cur); break; }
    int k = M;
    while(k > 0) {
      if(S[cur-k] == '0') break;
      --k;
    }
    if(k == 0) {
      std::cout << "-1" << std::endl;
      return 0;
    }
    ans.push(k); cur -= k;
  }
  while(ans.size() > 1) {
    std::cout << ans.top() << " ";
    ans.pop();
  }
  std::cout << ans.top() << std::endl;
  return 0;
}


Measured memory_bytes: 876
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>

using namespace std;

const int MAX = 35;
const int INF = (1<<25);
int n,m;

struct Edge{
  int to;
  double dis,lim;
  Edge(int a, double b, double c):to(a),dis(b),lim(c){}
};

struct State{
  int pos,from;
  double speed,t;
  State(int a, double b, double c, int f):pos(a),speed(b),t(c),from(f){}
  bool operator < (const State& s) const{ return t > s.t;}
};

vector<Edge> E[MAX];
double T[MAX][MAX][MAX];
//T[i][j][k] := shortest time from i to j with speed k.


void init(){
  for(int i = 0; i < MAX; i++){
    for(int j = 0; j < MAX; j++)
      for(int k = 0; k < MAX; k++) T[i][j][k] = INF;
    E[i].clear();
  }
}

void input(){
  for(int i = 0; i < m; i++){
    int x,y;
    double d,c;
    cin >> x >> y >> d >> c;
    //   cout << x << " " << y << " " << d << " " << c << endl;
    E[x].push_back(Edge(y,d,c));
    E[y].push_back(Edge(x,d,c));
  }
}

void solve(int s, int g){

  priority_queue<State> Q;
  T[0][s][0] = 0;
  Q.push(State(s,0,0,0));

  while(!Q.empty()){
    State sta = Q.top();
    Q.pop();

    if(sta.t > T[sta.from][sta.pos][(int)sta.speed]) continue;

    for(int i = 0; i < E[sta.pos].size(); i++){
      int np = E[sta.pos][i].to;

      if(np == sta.from) continue;

      double sp[] = {-1,0,1};
      
      for(int j = 0; j < 3; j++){
	double ns = sta.speed+sp[j];
	if(ns <= 0 || ns > E[sta.pos][i].lim) continue;
	double nt = sta.t+E[sta.pos][i].dis/ns;
	if(T[sta.pos][np][(int)ns] > nt){
	  T[sta.pos][np][(int)ns] = nt;
	  Q.push(State(np,ns,nt,sta.pos));
	}
      }
    }
  }

  double ans = INF;

  for(int i = 0; i < MAX; i++)
    ans = min(ans,T[i][g][1]);
  

  if(ans == INF) cout << "unreachable" << endl;
  else printf("%.5f\n",ans);
}

int main(){

  while(cin >> n >> m && n+m){
    init();
    int s,g;
    cin >> s >> g;
    input();
    solve(s,g);
  }
  return 0;
}

Measured memory_bytes: 2124
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n, cnt[N], mn = oo, mx;
bool bad;

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

    cin >> n;
    forn(i, 1, n) {
        int x;
        cin >> x;
        cnt[x]++;
        mx = max(mx, x);
        mn = min(mn, x);
    }

    if ((mx + 1) / 2 > mn || cnt[(mx + 1) / 2] > 1 + (mx & 1)) bad = 1;

    forn(i, (mx + 1) / 2, mx)
        if (!cnt[i]) bad = 1;

    cout << (bad ? "Impossible" : "Possible") << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static char[] N;
    private static int K;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.next().toCharArray();
        K = sc.nextInt();
        int ans = dfs(0,true,0);
        System.out.println(ans);
    }

    private static int dfs(int pos, boolean same, int k) {
        if (k == K) {
            return 1;
        }
        if (pos == N.length) {
            return 0;
        }

        int ret = 0;
        int last = same ? N[pos]-'0' : 9;
        for (int i = 0; i <= last; i++) {
            int nextK = i == 0 ? k : k+1;
            boolean nextSame = same && i == last;
            ret += dfs(pos+1, nextSame, nextK);
        }
        return ret;
    }
}



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

int main() {
  int N;
  cin >> N;
 
  if ( N == 1 ){
	cout << "ACL" << endl;
  }
  
  else if ( N == 2 ){
 	cout << "ACLACL" << endl;
  }
  else if ( N == 3 ){
 	cout << "ACLACLACL" << endl;
  }
  
  else if ( N == 4 ){
 	cout << "ACLACLACLACL" << endl;
  }
    

   else if ( N == 5 ){
 	cout << "ACLACLACLACLACL" << endl;
  }



}


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

int main() {
	int n;cin>>n;
	vector<int> x(n),y(n),h(n);
	vector<vector<int>> ha(101,vector<int>(101));
	int empty=1;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>h[i];
//		cout<<i<<endl;
		if(h[i]==0)continue;
		for(int j=0;j<=100;j++){
			for(int k=0;k<=100;k++){
				int dx=j-x[i];
				int dy=k-y[i];
				if(dx<0)dx*=-1;
				if(dy<0)dy*=-1;
				if(empty==1){
					ha[j][k]=h[i]+dx+dy;
				}else{
					if(ha[j][k]!=h[i]+dx+dy){
						ha[j][k]=0;
					}
				}
//				cout<<ha[j][k]<<' ';
			}
//			cout<<endl;
		}
		if(empty==1)empty=0;
	}
	for(int j=0;j<=100;j++){
		for(int k=0;k<=100;k++){
			if(ha[j][k]){
				int flag=1;
				for(int i=0;i<n;i++){
					int dx=j-x[i];
					int dy=k-y[i];
					if(dx<0)dx*=-1;
					if(dy<0)dy*=-1;
					if(ha[j][k]>h[i]+dx+dy){
						flag=0;
					}
				}


				if(flag==0)continue;
				cout<<j<<' '<<k<<' '<<ha[j][k]<<endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (va[i] % 2 == 1 && (i + 1) % 2 == 1) {
      ans++;
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3624
x,y=map(int,input().split())

if x==2 or y==2:
    print('No')
elif x==4 or x==6 or x==9 or x==11:
    if y==4 or y==6 or y==9 or y==11:
        print('Yes')
    else:
        print('No')
else:
    if y == 4 or y == 6 or y == 9 or y == 11:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
const int INF = 1e9;
//|S|,|T| <= 50 なので全探索. Sのi番目からTを作れることができるか見ていく
//Tを作れるなら残った？はaに置換する.
int main(){
  string s,t;
  cin >> s >> t;
  int N = s.length(), M = t.length();
  
  vector<string> res;

  if(M > N){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  rep(i,N-M+1) {
    bool ok = true;
    string sub = s;
    rep(j,M){
      if(sub[i+j] == '?') sub[i+j] = t[j];
      else if(sub[i+j] != t[j]) {
        ok = false;
        break;
      }
    }
    if(ok){
      for(auto &e : sub){
        if(e == '?')e = 'a';
      }
      res.push_back(sub);
    }
  }
  sort(res.begin(),res.end());

  if(!res.empty())cout << res.front() << endl;
  else cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
  
  public static void main(String[] args){
  
  	Scanner scan = new Scanner(System.in);
    int input = Integer.parseInt(scan.nextLine());
	int cur = 1000;
    while(cur<input){
    	cur+= 1000;
    }
    System.out.println(cur-input);
  }
  
}

Measured memory_bytes: 35684
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007
//#define MOD 7

using namespace std;

int main(void){
    // Your code here!
    long long n, d, count = 0;
    long long x[10][10] = {};
    
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j]; 
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            long long value = 0;
            for(int k = 0; k < d; k++){
                value += pow(x[i][k] - x[j][k], 2);
            }
            
            if(pow((long long)sqrt(value), 2) == value)
                count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<vector <int>> f(n,vector<int> (10));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < 10; j++)
    {
      cin >> f[i][j];
    }
  }
  vector<vector <int>> p(n,vector<int> (11));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < 11; j++)
    {
      cin >> p[i][j];
    }
  }

  int ans = -1000000007;
  for (int bit = 1; bit < (1<<10); bit++)
  {
    vector<int> vec(n,0);
    int res=0;
    for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < 10; j++)
      {
        if((bit & (1<<j)) && f[i][j]) vec[i]++;
      }
    }

    for (int i = 0; i < n; i++)
    {
      res+=p[i][vec[i]];
    }
    ans = max(ans,res);
  }

  cout << ans << endl;
}

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

int main(){
    string s; cin >> s;
    int N=s.size(), cnt=0;
    for(int i=0;i<N;i++){
        if(s[i]=='p') cnt++;
    }
    cout << N/2-cnt << endl;
    return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
 
int main()
{
    long long a, b, c, k, sum = 0;
    cin >> a >> b >> c >> k;
    if (k > 0) {
       sum += min(k, a);
       k -= a;
    }
    if (k > 0) {
       k -= b;
    }
    if (k > 0) {
       sum -= min(k, c);
       k -= c;
    }
    cout << sum << endl;
    return 0;
}

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

template <class T>
inline void read(T &x)
{
	static char ch; 
	static bool opt; 
	while (!isdigit(ch = getchar()) && ch != '-'); 
	x = (opt = ch == '-') ? 0 : ch - '0'; 
	while (isdigit(ch = getchar()))
		x = x * 10 + ch - '0'; 
	if (opt)
		x = ~x + 1; 
}

const int MaxN = 16; 
const int MaxM = 155; 
const int MaxS = 1 << 15;
const int mod = 1e9 + 7; 

inline bool in(int s, int i)
{
	return (s >> (i - 1)) & 1; 
}

inline void add(int &x, const int &y)
{
	x += y;
	if (x >= mod)
		x -= mod; 
}

inline void dec(int &x, const int &y)
{
	x -= y; 
	if (x < 0)
		x += mod; 
}

struct edge
{
	int u, v;
	inline void scan()
	{
		read(u), read(v); 
	}
}e[MaxM]; 

int n, m, type, all, pw2[MaxM]; 
int f[MaxS], has[MaxS], touch[MaxS]; 

int main()
{
	read(n), read(m); 
	all = (1 << n) - 1, pw2[0] = 1; 
	for (int i = 1; i <= m; ++i)
	{
		pw2[i] = 2LL * pw2[i - 1] % mod; 
		e[i].scan(); 
	}

	for (int s = 1; s <= all; ++s)
	{
		for (int i = 1; i <= m; ++i)
			if (in(s, e[i].u) && in(s, e[i].v))
				++has[s]; 
			else
			{
				if (in(s, e[i].u))
					touch[s] |= 1 << (e[i].v - 1); 
				if (in(s, e[i].v))
					touch[s] |= 1 << (e[i].u - 1); 
			}
	}

	for (int s = 1; s <= all; ++s)
		if (in(s, 1) || in(s, 2))
		{
			if (in(s, 1) && in(s, 2))
				continue; 

			f[s] = pw2[has[s]]; 
			for (int t = (s - 1) & s; t; t = (t - 1) & s)
				dec(f[s], 1LL * f[t] * pw2[has[s ^ t]] % mod); 

		//	std::cout << s << ':' << f[s] << ' ' << touch[s] <<  '\n'; 
		}

	int ans = pw2[m]; 
	for (int s = 1; s <= all; ++s)
	{
		for (int sl = (all ^ s ^ touch[s]), t = sl; t; t = (t - 1) & sl)
		{
			if (in(s, 1) && in(t, 2))
				dec(ans, 1LL * f[s] * f[t] % mod * pw2[has[all ^ s ^ t]] % mod); 
		}
	}
	std::cout << ans << std::endl; 

	return 0; 
}

Measured memory_bytes: 768
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 3 "../../library/debug.hpp"

// https://codeforces.com/blog/entry/68809
void debug_print(int x) {cerr << x;}
void debug_print(long x) {cerr << x;}
void debug_print(long long x) {cerr << x;}
void debug_print(unsigned x) {cerr << x;}
void debug_print(unsigned long x) {cerr << x;}
void debug_print(unsigned long long x) {cerr << x;}
void debug_print(float x) {cerr << x;}
void debug_print(double x) {cerr << x;}
void debug_print(long double x) {cerr << x;}
void debug_print(char x) {cerr << '\'' << x << '\'';}
void debug_print(const char *x) {cerr << '\"' << x << '\"';}
void debug_print(const string &x) {cerr << '\"' << x << '\"';}
void debug_print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V> void debug_print(const pair<T, V> &x) {cerr << '{'; debug_print(x.first); cerr << ','; debug_print(x.second); cerr << '}';}
template<typename T> void debug_print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), debug_print(i); cerr << "}";}

void debug_print_() {cerr << "]\n";}
template <typename T, typename... V>
void debug_print_(T t, V... v) {debug_print(t); if (sizeof...(v)) cerr << ", "; debug_print_(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; debug_print_(x)
#else
#define debug(x...)
#endif
#line 3 "e.cpp"

int main() {
  ll n, m;
  cin >> n >> m;

  auto f = [&n](ll l, ll r) {
    if (r >= l) {
      return r-l;
    } else {
      return n-(l-r);
    }
  };
  vl a(m), b(m);

  ll ki = (m+1)/2;
  ll gu = m/2;
  debug(ki, gu);

  ll cnt = 1;
  rep(i, ki) {
    a[i] = cnt++;
  }
  per(i, ki) {
    b[i] = cnt++;
  }
  rep(i, gu) {
    a[i+ki] = cnt++;
  }
  cnt++;
  per(i, gu) {
    b[i+ki] = cnt++;
  }

  rep(i, m) {
    debug(f(a[i], b[i]), f(b[i], a[i]));
    cout << a[i] << " " << b[i] << el;
  }
}


Measured memory_bytes: 4384
H,W = map(int,input().split())
base = []
for _ in range(H):
  base.append(list(input()))
counter = 0
for i in range(H):
  for j in range(W):
    if base[i][j] == '#':
      counter += 1
      break
if counter == 0:
  print('Yes')
  exit()
TB = ['.']*(W+1)
WIDE = []
WIDE.append(TB)
for i in range(H):
  WIDE.append(['.'] + base[i] + ['.'])
WIDE.append(TB)
Answer = 'Yes'
for i in range(1,H+1):
  for j in range(1,W+1):
    if WIDE[i][j] == '#' and WIDE[i-1][j] == '.' and WIDE[i][j-1] == '.' and WIDE[i][j+1] == '.' and WIDE[i+1][j] == '.':
      Answer = 'No'
      break
print(Answer)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		char cf = s.charAt(0);
		char cl = s.charAt(s.length()-1);
		int n = s.length()-2;
		System.out.print(cf);
		System.out.print(n);
		System.out.println(cl);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    bool rate[8] = {};
    int stgr_cnt = 0;
    cin >> n;
    REP(i, n){
        int a;
        cin >> a;
        a /= 400;
        if(a >= 8)stgr_cnt++;
        else rate[a] = true;
    }

    int cnt_min = 0;
    int cnt_max = 0;
    REP(i, 8){
        if(rate[i] == true) cnt_min++;
    }
    cnt_max = 8 - cnt_min;
    cnt_max = stgr_cnt;
    cnt_max += cnt_min;
    if(cnt_min == 0) cnt_min = 1;

    cout << cnt_min << " " << cnt_max << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static int minFee(int n, int a, int b) {
        return n * a < b ? n * a : b;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(minFee(n, a, b));
    }

}


Measured memory_bytes: 21972
N, M = map(int, input().split())
s = []
k = []
for _ in range(M):
    x = list(map(int, input().split()))
    k.append(x.pop(0))
    s.append(x)
p = list(map(int, input().split()))
# print(s, k, p)
ans = 0
for i in range(2**N):
    Switches = [0]*N
    for j in range(N):
        if (i >> j) & 1:
            Switches[j] = 1
    # print(Switches)
    Lamps = [0]*M
    for j in range(M):
        for l in range(k[j]):
            if Switches[s[j][l] - 1] == 1:
                Lamps[j] += 1

    # print(Lamps)
    ok = True
    for j in range(M):
        # if Lamps[j] == 0:
        #     ok = False
        #     break
        if Lamps[j] % 2 != p[j]:
            ok = False
            break

    if ok:
        ans += 1
    
print(ans)



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

int main()
{
   string s, t, u; cin >> s >> t;
   int a, b; cin >> a >> b;
   cin >> t;
   if ( s == t)
   {
       a--;
   }
   else
   {
       b--;
   }
   cout << a << ' ' << b;
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);

	cout << (N == M ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
num = [0]*100100

n = int(input())
sum = 0
for A in map(int, input().split()):
  num[A] += 1
  sum += A

for _ in range(int(input())):
  b, c = map(int, input().split())
  sum += (c-b)*num[b]
  num[c] += num[b]
  num[b] = 0
  print(sum)

Measured memory_bytes: 17912
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

ll modpow(ll a, ll n, ll p){
  if(n == 0){
    return 1;
  }
  if(n%2 == 0){
    ll root = modpow(a,n/2,p);
    return root * root %p;
  }
  else{
    return a*modpow(a,n-1,p)%p;
  }
}


int main(void){
  int k;
  cin >> k;
  if(k <= 9){
    cout << k << endl;
    return 0;
  }
  ll ans = 0;
  ll work[10][100];
  rep(i,10){
    rep(j,100){
      work[i][j] = 0;
    }
  }

  int total = 0;
  
  for(int i=0;i<10;i++){
    work[i][0] = 1;
  }
  rep(j,10){
    //cout << work[j][0] << " ";
  }
  //cout << endl;

  int digit;
  total = 9;
  for(int i=1;i<100;i++){
    work[0][i] += work[0][i-1];
    work[1][i] += work[0][i-1];
    work[8][i] += work[9][i-1];
    work[9][i] += work[9][i-1];
    total += work[0][i-1] + work[9][i-1]*2;
    for(int j=1;j<9;j++){
      work[j-1][i] += work[j][i-1];
      work[j][i] += work[j][i-1];
      work[j+1][i] += work[j][i-1];
      total += work[j][i-1]*3;
      if(j==1)total -= work[j][i-1];
    }
    rep(j,10){
      //cout << work[j][i] << " ";
    }
    //cout << endl << "total = " << total << endl;
    
    if(total >= k){
      digit = i;
      break;
    }
  }

  int min = 0,max = total,cur;
  for(int i=9;i > 0;i--){
    min = max-work[i][digit]+1;
    //cout << "check " << i << ", min = " << min << ", max = " << max << endl; 
    if(min <= k){
      cout << i;
      cur = i;
      break;
    }
    max = min-1;
  }


  for(int i=digit-1;i > -1;i--){
    if(cur == 0){
      if(min+work[cur][i] > k){
	cout << cur;
	continue;
      }
      cur = cur+1;
      cout << cur;
      min += work[cur-1][i];
      continue;
    }
    if(cur == 9){
      if(min+work[8][i] > k){
	cout << 8;
	cur = 8;
	continue;
      }
      cout << 9;
      min += work[8][i];
      continue;
    }
    for(int j=-1;j<2;j++){
      //      cout << min+work[cur+j][i] << ", k = "<< k << endl;
      if(min+work[cur+j][i] > k){
	cout << cur+j;
	cur += j;
	break;
      }
      min += work[cur+j][i];
    }
  }

  cout << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    masu = [input().split() for i in range(H)]
    alpha = "abcdefghijklmnopqrstuvwxyz"

    for i in range(H):
        for j in range(W):
            if masu[i][j] == "snuke":
                print(alpha[j].upper() + str(i+1))
                exit()

if __name__ == "__main__":
    main()

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
	string s;
	int x,y;
	bool isy=false,is1st=true;
	set<int> dpx,dpy;
	set<int> buf;
	cin>>s;
	cin>>x>>y;
	dpx.insert(0);
	dpy.insert(0);
	REP(i,sz(s)){
		if(s[i]=='F'){
			int cnt=0;
			while(s[i]=='F'&&i<sz(s)){
				cnt++;
				i++;
			}i--;
			//cout<<cnt<<"Forward\n";
			if(isy){
				buf=dpy;
				dpy.clear();
				for(auto a:buf){
					dpy.insert(a+cnt);
					dpy.insert(a-cnt);
				}
			}else{
				buf=dpx;
				dpx.clear();
				for(auto a:buf){
					dpx.insert(a+cnt);
					if(!is1st)dpx.insert(a-cnt);
				}
			}
		}else if(s[i]=='T'){
			isy=!isy;
			is1st=false;
			//cout<<"Turn\n";
		}else{
			//cout<<s[i]<<"ERROR\n";
		}
	}

	//for(auto a:dpx)cout<<a<<" ";cout<<"\n";
	//for(auto a:dpy)cout<<a<<" ";cout<<"\n";

	if(dpx.count(x)&&dpy.count(y)){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 768
n = int(input())
X = [list(input().split()) for i in range(n)]

ans = 0
for i in range(len(X)):
  if X[i][1] == "JPY":
    ans += float(X[i][0])
  else:
    ans += 380000.0 * float(X[i][0])
    
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<vector>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<utility>
#include<climits>
#include<set>
using namespace std;
#define ll long long


int main(){ 
	ios_base::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
	    
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif

	int x;cin>>x;
	if(x==1)
		cout<<0;
	else
		cout<<1;
	
    
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

struct sieve {
  int n;
  vector<int> f, primes;
  sieve(int n) : n(n), f(n+1, 0) {
    /* O(n log log n) */
    f[0] = f[1] = -1;
    for(int i=2; i<=n; i++) {
      if(f[i]) continue;
      primes.push_back(i); f[i] = i;
      for(long long k=(long long)i*i; k<=n; k+=i) if(!f[k]) f[k] = i;
    }
  }
  bool is_prime(int x) {return f[x]==x;}
  template <typename T>
  vector<pair<T,int>> factors(T x) {
    assert((long long)n*n >= x);
    vector<pair<T,int>> fc;
    /* O(log x) */
    while (x != 1) {
      if (fc.size()!=0 && fc.back().first == f[x]) fc.back().second++;
      else fc.emplace_back(f[x], 1);
      x /= f[x];
    }
    return fc;
  }
};

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

  sieve s(1000001);

  set<int> pp;
  rep(i,n) {
    int ai = a[i];
    auto ff = s.factors(ai);
    for(auto f : ff) {
      if(pp.count(f.first)) {
        goto OUT;
      }
      pp.insert(f.first);
    }
    
  }
  puts("pairwise coprime");
  return 0;
OUT:

  ll ggg = a[0];
  rep(i,1,n) ggg = gcd(ggg, a[i]);
  if(ggg==1) puts("setwise coprime");
  else puts("not coprime");

}


Measured memory_bytes: 11728