akhauriyash/Code-Regression huggingface dataset:
//implement the sieve of eratos
import java.util.Scanner;


//we will use the filter method to construct the prime table from 1 to n


public class Main {
	//we can thus use binary search to check whether i is in the table
	static final int N = 100000000;
	
	
	
	// this is no good for java, so slow
	public static boolean[] eratos(int n){
		// the original value should be false
		boolean [] table = new boolean[n+1];
		
		table[0] = table[1] = true;
		
		int k = (int)Math.sqrt(n);
		for(int i = 2; i <= k; i++) {
			if(!table[i]) {
				for(int j = 2*i; j <= n; j+=i) {
					table[j] = true;
				}
			}
		}
		
		return table;
	}
	
	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		boolean[] table = eratos(N);
		
		int len = cin.nextInt();
		int count = 0;

		
		while(len > 0) {
			count += (!table[cin.nextInt()])? 1:0;
			len--;
		}
		System.out.println(count);
	}


}

Measured memory_bytes: 138844
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s, t;
    cin >> s >> t;
    vector<ll> tmp;
    vector<vector<ll>> ind(26, tmp);
    ll slen = s.size(), tlen = t.size();
    rep(i, slen){
        ind[s[i]-'a'].push_back(i+1);
    }
    ll res=0;
    rep(i, tlen){
        int now = res % slen;
        if(ind[t[i]-'a'].empty()){
            res = -1;
            break;
        }
        auto it = upper_bound(ind[t[i]-'a'].begin(), ind[t[i]-'a'].end(), now);
        if(it!=ind[t[i]-'a'].end()){
            res += *it - now;
        }else{
            res += slen - now;
            res += ind[t[i]-'a'][0];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4556
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn =  233;
int d[maxn][maxn];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
char g[maxn][maxn];
queue<pair<int,int> > q;
int main()
{
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;i++)scanf("%s",g[i]+1);
	int ans = 0;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)if(g[i][j]=='.'){
		memset(d,-1,sizeof(d));
		d[i][j] = 0;
		q.push(mp(i,j));
		while(!q.empty()){
		
			int x = q.front().fi;
			int y = q.front().se;
			q.pop();
			for(int i=0;i<4;i++){
				int nx = x+dx[i];
				int ny = y+dy[i];
				if(nx<1||ny<1||nx>n||ny>m)continue;
				if(d[nx][ny]!=-1)continue;
				if(g[nx][ny]=='#')continue;
				d[nx][ny] = d[x][y] + 1;
				q.push(mp(nx,ny));
				ans = max(ans,d[x][y]+1);
			}
			
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn to_str(s: State) -> String {
    return match s {
        State::Delicious => String::from("delicious"),
        State::Safe => String::from("safe"),
        State::Dangerous => String::from("dangerous"),
    };
}

enum State {
    Delicious,
    Safe,
    Dangerous,
}

fn solve(x: i32, a: i32, b: i32) -> String {
    let state = if -a + b <= 0 {
        State::Delicious
    } else {
        if 0 < -a + b && -a + b <= x {
            State::Safe
        } else {
            State::Dangerous
        }
    };
    return to_str(state);
}

fn main() {
    let s = getline();
    let vec: Vec<i32> = s.trim().split(' ').map(|s| s.parse().unwrap()).collect();
    let x = vec[0];
    let a = vec[1];
    let b = vec[2];

    let ans = solve(x, a, b);
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] order = new int[n + 1][n + 1];
		for(int i = 1; i < n + 1; i++) {
			for(int j = 1; j < n; j++) {
				order[i][j] = sc.nextInt();
			}
		}
		int[] num = new int[n + 1];
		for(int i = 1; i < n + 1; i++) {
			num[i] = 1;
			order[i][0] = 0;
			order[i][n] = 0;
		}
		int[] cnt = new int[n + 1];
		for(int i = 1; i < n + 1; i++) {
			cnt[i] = 0;
		}
		int player = 1;
		int change = 0;
		while(true) {
			int enemy = order[player][num[player]];
			if(enemy != 0 && player == order[enemy][num[enemy]]) {
				num[player]++;
				num[enemy]++;
				int max = Math.max(cnt[player], cnt[enemy]);
				max++;
				cnt[player] = max;
				cnt[enemy] = max;
				change = 0;
			} else if(enemy == 0) {
				if(player != n)
					player++;
				else
					player = 1;
				change++;
			} else {
				player = enemy;
				change++;
			}
			if(change > n)
				break;
		}

		boolean flag = true;
		int ans = 0;
		for(int i = 1; i < n + 1; i++) {
			if(num[i] != n) {
				flag = false;
			} else {
				ans = Math.max(ans, cnt[i]);
			}
		}
		if(flag) {
			System.out.println(ans);
		} else {
			System.out.println(-1);
		}

	}

}


Measured memory_bytes: 242784
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int n;
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		int out = 0;
		int score = 0;
		unsigned char data = 0;
		while(1)
		{
			string event;
			cin >> event;
			if(event == "HIT")
			{
				data <<= 1;
				data |= 0x01;
				if(data & 0x08)
				{
					data &= ~0x08;
					score++;
				}
			}
			else if(event == "HOMERUN")
			{
				for(int i = 0;i < 3;i++)
				{
					if(data & (0x01 << i)) score++;
				}
				score++;
				data = 0;
			}
			else if(event == "OUT")
			{
				out++;
				if(out >= 3) break;
			}
		}
		cout << score << endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    deque<ll> ng, po;
    int nc = 0;
    ll tmp;
    ll minng = INF, maxng = -INF, minpo = INF, maxpo = -INF;
    int minngidx, maxngidx, minpoidx, maxpoidx;
    ll x = 0;
    rep(i, n){
        cin >> tmp;
        if(tmp < 0) {
            nc++;
            ng.push_back(tmp);
            if(minng > tmp){
                minngidx = ng.size() - 1;
                minng = tmp;
            }
            if(maxng < tmp){
                maxngidx = ng.size() - 1;
                maxng = tmp;
            }
        }else{
            po.push_back(tmp);
            if(minpo > tmp){
                minpoidx = po.size() - 1;
                minpo = tmp;
            }
            if(maxpo < tmp){
                maxpoidx = po.size() - 1;
                maxpo = tmp;
            }
        }
        x += abs(tmp);
    }
    if(nc != n && nc != 0){
        cout << x << endl;
    }else if(nc == 0){
        ll x1 = minpo;
        ll x2 = maxpo;
        if(minpoidx > maxpoidx) {
            po.erase(po.begin() + minpoidx);
            po.erase(po.begin() + maxpoidx);
        }else{
            po.erase(po.begin() + maxpoidx);
            po.erase(po.begin() + minpoidx);
        }
        ng.push_back(-abs(x1 - x2));
        x += abs(x1 - x2) - abs(x1 + x2);
        cout << x << endl;
        cout << x1 << ' ' << x2 << endl;
    }else if(nc == n){
        ll x1 = minng;
        ll x2 = maxng;
        if(minngidx > maxngidx) {
            ng.erase(ng.begin() + minngidx);
            ng.erase(ng.begin() + maxngidx);
        }else{
            ng.erase(ng.begin() + maxngidx);
            ng.erase(ng.begin() + minngidx);
        }
        po.push_back(abs(x1 - x2));
        x += abs(x1 - x2) - abs(x1 + x2);
        cout << x << endl;
        cout << x2 << ' ' << x1 << endl;
    }
    int f = 0, N, P;
    while(!((ng.size() == 0 && po.size() == 1)||(ng.size() == 1 && po.size() == 0))){
        if(ng.size() < po.size()) f = 0;
        else f = 1;
        N = ng.front();
        P = po.front();
        ng.pop_front();
        po.pop_front();
        if(f == 0) {
            ng.push_back(-abs(N - P));
            cout << N << ' ' <<  P << '\n';
        }
        else {
            po.push_back(abs(N - P));
            cout << P << ' ' << N << '\n';
        }
    }
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
long long int x,y,z,n;
int main()
{
	scanf("%lld",&x);
	long long int temp=x;
	long long int cnt=0;
	while(temp)
	{
		long long int k=temp%10;
		cnt+=k;
		temp/=10;
	}
	while(x!=1)
	{
		if(x%10!=0)
		{
			printf("%lld",cnt);
			return 0;
		}
		x/=10;
	}
	printf("10");
}

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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;
int t[100005], x[100005], y[100005];
int main()
{
	int N;
	cin >> N;
	t[0] = 0; x[0] = 0; y[0] = 0;
	FOR(i, N + 1, 1)
	{
		cin >> t[i] >> x[i] >> y[i];
	}
	FOR(i, N + 1, 1)
	{
		int time = t[i] - t[i - 1];
		int dx = abs(x[i] - x[i - 1]), dy = abs(y[i] - y[i - 1]);
		time -= (dx + dy);
		if (time < 0 || time % 2 == 1)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
#define SIZE 4097
ll dp[SIZE+1];
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n,m;
	cin>>n>>m;
	pll arr[m];
	for(ll i=0;i<m;++i){
		ll cost,num;
		cin>>cost>>num;
		ll mask=0;
		for(ll j=0;j<num;++j){
			ll t;
			cin>>t;
			t--;
			mask=(mask|(1<<t));
		}
		arr[i]=mp(mask,cost);
		// cout<<i<<" "<<mask<<endl;
	}
	for(ll i=1;i<=SIZE;++i){
		dp[i]=INT_MAX;
	}
	n=(1<<n)-1;
	// cout<<n<<endl;
	for(ll mask=0;mask<=n;mask++){
		for(ll i=0;i<m;++i){
			ll s=mask|arr[i].first;
			dp[s]=min(dp[s],dp[mask]+arr[i].second);
		}
		// cout<<mask<<" "<<dp[mask]<<endl;

	}
	if(dp[n]<INT_MAX){
		cout<<dp[n];
	}
	else
		cout<<-1<<endl;
}

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

#define big(a,b) ((a)>(b)?(a):(b))

int compare_int(const void *a, const void *b)
{
    return *(long*)b - *(long*)a;
}

int main(){
	int n,k,i;
	long td[100000][3]={0},max[100001]={0};
	long long ans=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)scanf("%ld%ld",&td[i][0],&td[i][1]);
	for(i=0;i<=n;i++)max[i]=-1;
	for(i=0;i<n;i++){
		if(max[td[i][0]]==-1){
			td[i][2]=1;
			max[td[i][0]]=i;
		}else 
		if(td[max[td[i][0]]][1]<td[i][1]){
			td[max[td[i][0]]][2]=0;
			max[td[i][0]]=i;
			td[i][2]=1;
		}
	}
	long kot[2][100000]={0},k0c=0,k1c=0;
	for(i=0;i<=n;i++){
		if(td[i][2]==1){
			kot[1][i]=td[i][1];
			k1c++;
		}
		if(td[i][2]==0){
			kot[0][i]=td[i][1];
			k0c++;
		}
	}
	qsort(kot[0],100000,sizeof(long),compare_int);
	qsort(kot[1],100000,sizeof(long),compare_int);
	int c=k1c;
	long long x=0,y=big(0,k-c);
	for(i=0;i<y;i++)x+=kot[0][i];
	for(i=0;i<k-y;i++)x+=kot[1][i];
	while(1){
//		printf("%lld\n",x+(k-y)*(k-y));
		ans=big(ans,x+(k-y)*(k-y));
		if(y>=k||y>=k1c)break;
		x+=kot[0][y];
		x-=kot[1][k-y-1];
		y++;
	}
//	for(i=0;i<k1c;i++)printf("%ld\n",kot[1][i]);
	printf("%lld\n",ans);
	return 0;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

vector<vector<int>> g;
vector<int> lp; /// longest Directed path starting at i
vector<bool> vis;

void dfs(int v){
    int &mx = lp[v];
    vis[v] = 1;
    for(auto u: g[v]){
        if(!vis[u])
            dfs(u);
        mx = max(lp[u] + 1, mx);
    }
}

void solve(){
    int n, m, u, v;
    cin>>n>>m;
    g.resize(n+1);
    lp.resize(n+1, 1);
    vis.resize(n+1, false);

    fr(i, m){
        cin>>u>>v;
        g[u].push_back(v);
    }

    rep(i, 1, n){
        if(!vis[i]){
            dfs(i);
        }
    }

    cout<<*max_element(lp.begin() + 1, lp.end()) - 1;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

int main() {
    int n, k, c;
    string s;

    cin >> n >> k >> c >> s;

    int l[k + 1], r[k + 1];
    for (int i = 1; i <= k; i++) {
        int d;
        if (i == 1) d = 1;
        else d = l[i - 1] + c + 1;
        while(1) {
            if (s[d - 1] == 'o') {
                l[i] = d;
                break;
            }
            d++;
        }
    }
    for (int i = k; i >= 1; i--) {
        int d;
        if (i == k) d = n;
        else d = r[i + 1] - c - 1;
        while(1) {
            if (s[d - 1] == 'o') {
                r[i] = d;
                break;
            }
            d--;
        }
    }
    
    for (int i = 1; i <= k; i++) {
        if (l[i] == r[i]) cout << l[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3332
#include<stdio.h>
#define MAX 10000
#define NIL -1
 
struct Node{
  int p, l, r;
};
 
struct Node A1[MAX];
int num;
int A2[MAX], A3[MAX];
 
int getDepth(int m){
  int d = 0;
  while(1){
    m = A1[m].p;
    if ( m == NIL ) break;
    d++;
  }
  return d;
}
 
int getSibling(int m){
  if ( A1[m].p == NIL ) return NIL;
  if ( A1[A1[m].p].l != m && A1[A1[m].p].l != NIL )return A1[A1[m].p].l;
  if ( A1[A1[m].p].r != m && A1[A1[m].p].r != NIL )return A1[A1[m].p].r;
  return NIL;
}
 
void print(int m){
  printf("node %d: ", m);
 
  printf("parent = %d, ", A1[m].p);
  printf("sibling = %d, ", getSibling(m));
  int deg = 0;
   
  if ( A1[m].l != NIL )
    deg++;
  if ( A1[m].r != NIL )
    deg++;
   
  printf("degree = %d, ", deg);
  printf("depth = %d, ", A2[m]);
  printf("height = %d, ", A3[m]);
 
  if ( A1[m].p == NIL ){
    printf("root\n");
  } else if ( A1[m].l == NIL && A1[m].r == NIL ){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}
 
int main(){
  int i, v, l, r;
  scanf("%d", &num);
 
  for ( i = 0; i < num; i++ ) {
    A1[i].p = NIL;
  }
 
  for ( i = 0; i < num; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    A1[v].l = l;
    A1[v].r = r;
    if ( l != NIL ) A1[l].p = v;
    if ( r != NIL ) A1[r].p = v;
  }
 
  for ( i = 0; i < num; i++ ){
    A2[i] = getDepth(i);
    A3[i] = 0;
  }
 for ( i = 0; i < num; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    A1[v].l = l;
    A1[v].r = r;
    if ( l != NIL ) A1[l].p = v;
    if ( r != NIL ) A1[r].p = v;
  }
 
  for ( i = 0; i < num; i++ ){
    A2[i] = getDepth(i);
    A3[i] = 0;
  }
 
  for ( i = 0; i < num; i++ ){
    if ( A1[i].l == NIL && A1[i].r == NIL ) { // is leaf
      A3[i] = 0;
      int p = A1[i].p;
      int c = 1;
      while(1){
        if ( p == NIL ) break;
        if ( A3[p] < c ) A3[p] = c;
        c++;
        p = A1[p].p;
      }
    }
  }
 
  for ( i = 0; i < num; i++ ) print(i);
  return 0;
}

Measured memory_bytes: 620
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN],b[MAXN];
vector<int> v;
int main()
{
    scanf("%d",&n);
    ll ans=INF,suma=0,sumb=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        suma+=a[i];sumb+=b[i];
        v.push_back(a[i]);v.push_back(b[i]);
    }
    ans=min(ans,suma);ans=min(ans,sumb);
    sort(v.begin(),v.end());
    ll sum=0;
    for(int i=0;i<n-2;i++) sum+=v[i];
    for(int i=0;i<n;i++)
    {
        int id1=lower_bound(v.begin(),v.end(),a[i])-v.begin();
        int id2=lower_bound(v.begin(),v.end(),b[i])-v.begin();
        if(id1>=n-1&&id2>=n-1) ans=min(ans,sum+a[i]+b[i]);
        else if(id1<n&&id2<n) ans=min(ans,sum+v[n-2]+v[n-1]);
        else if(id1<n-1) ans=min(ans,sum+v[n-2]+b[i]);
        else ans=min(ans,sum+v[n-2]+a[i]);
    }
    printf("%lld\n",ans);
    return 0;
}



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

int main() {
    ios::sync_with_stdio(false);
    int a, b, t;
    cin >> a >> b >> t;

    int cnt = 0;
    for (int i = 1; i * a <= t; ++i) cnt += b;
    cout << cnt << endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, M; cin >> N >> M;
  string result = N==M ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	static int c = 0;

	public static void selectionSort(int[] A, int n) {

		for (int i = 0; i < n; i++) {

			int minj = i;

			for (int j = i; j < n; j++) {
				if (A[j] < A[minj]) {
					minj = j;
				}
			}

			if( i != minj ){
				int tmp = A[i];
				A[i] = A[minj];
				A[minj] = tmp;
				c++;
			}
		}
	}

	public static void printArray(int[] A, int n) {

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

			System.out.print(A[i] + " ");
		}
		System.out.println(A[n - 1]);
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int A[] = new int[n];

		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}
		sc.close();

		selectionSort(A, n);

		printArray(A, n);

		System.out.println(c);

	}

}



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

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    const int mxn = 3000000;
    atcoder::segtree<int, op, e> st(mxn);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        int q = st.prod(max(x - m, 0), min(x + m + 1, mxn));
        st.set(x, q + 1);
    }
    cout << st.all_prod() << '\n';
    return 0;
}

Measured memory_bytes: 47816
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>

using namespace std;

int a,b,c=0,q;

int main(){
    scanf("%d %d",&a,&b);
    for(int x=1;x<=9;x++){
        for(int y=0;y<=9;y++){
            for(int z=0;z<=9;z++){
                q=x*10001+y*1010+z*100;
                c+=a<=q and b>=q;
            }
        }
    }
    printf("%d\n",c);
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a,b,j,v;
    cin>>a;
    int A[a];
    for(int i=0;i<a;i++){
        cin>>A[i];
    }
    for(int i=0;i<a;i++){
        if(i==a-1){
            cout<<A[i]<<endl;
        }else{
        cout<<A[i]<<" ";
        }
    }
    for(int i=1;i<a;i++){
        b=A[i];
        j=i-1;
        while(j>=0&&A[j]>b){
            A[j+1]=A[j];
            j--;
            //A[j+1]=b;
        }
        A[j+1]=b;
        for(int i=0;i<a;i++){
            if(i==a-1){
                cout<<A[i]<<endl;
            }else{
            cout<<A[i]<<" ";
            }
        }
    }
    /*for(int i=0;i<a;i++){
        if(i==a-1){
            cout<<A[i]<<endl;
        }else{
        cout<<A[i]<<" ";
        }
    }*/
    return 0;
}



Measured memory_bytes: 3104
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    X,Y = LMIIS()
    if Y % 2 == 1:
        print('No')
        return
    if X*4 >= Y >= X*2:
        print('Yes')
        return
    else:
        print('No')
    
main()

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

int main() {
  priority_queue<int> q;
  string s;
  while ( cin >> s, s != "end" ) {
    if ( s == "insert" ) {
      int n;
      cin >> n;
      q.push(n);
    } else {
      cout << q.top() << endl;
      q.pop();
    }
  }
  return 0;
}



Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T, typename E> struct Segtree {
    inline T merge(const T &a, const T &b) { return min(a, b); }
    inline void act(E &a, const E &b) { a = b; }
    inline void comb(T &a, const E &b) { a = b; }
    int n;
    T et;
    E ee;
    vector<T> dat;
    vector<E> laz;
    Segtree(int n_, T et, E ee) : et(et), ee(ee) {
        n = 1;
        while (n < n_) {
            n <<= 1;
        }
        dat.resize(2 * n, et);
        laz.resize(2 * n, ee);
    }
    void eval(int k) {
        if (laz[k] == ee) {
            return;
        }
        comb(dat[k], laz[k]);
        if (k < n) {
            act(laz[k << 1], laz[k]);
            act(laz[k << 1 | 1], laz[k]);
        }
        laz[k] = ee;
    }
    void upd(const int &a, const int &b, const E &x, int k, int l, int r) {
        eval(k);
        if (b <= l || r <= a) {
            return;
        }
        if (a <= l && r <= b) {
            act(laz[k], x);
            eval(k);
            return;
        }
        upd(a, b, x, k << 1, l, (l + r) >> 1);
        upd(a, b, x, k << 1 | 1, (l + r) >> 1, r);
        dat[k] = merge(dat[k << 1], dat[k << 1 | 1]);
    }
    inline void upd(const int &a, const int &b, const E &x) {
        if (a >= b) {
            return;
        }
        upd(a, b, x, 1, 0, n);
    }
    T get(const int &a, const int &b, int k, int l, int r) {
        if (b <= l || r <= a) {
            return et;
        }
        eval(k);
        if (a <= l && r <= b) {
            return dat[k];
        }
        return merge(get(a, b, k << 1, l, (l + r) >> 1),
                     get(a, b, k << 1 | 1, (l + r) >> 1, r));
    }
    inline T get(const int &a, const int &b) {
        if (a >= b) {
            return et;
        }
        return get(a, b, 1, 0, n);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    Segtree<int, int> seg(n, (1LL << 31) - 1LL, (1LL - 31) - 1LL);
    for (int k = 0; k < q; k++) {
        int t, l, r;
        cin >> t >> l >> r;
        ++r;
        if (t == 0) {
            int x;
            cin >> x;
            seg.upd(l, r, x);
        } else {
            cout << seg.get(l, r) << "\n";
        }
    }
}


Measured memory_bytes: 4968
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	char c;cin>>c;
	if(c>='a')cout<<'a'<<endl;
	else cout<<"A"<<endl;
}


Measured memory_bytes: 3628
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    import copy
    h,w = map(int, input().split())
    s = [list(input().rstrip()) for _ in range(h)]

    #始点(i,j)から最短で行ける一番遠い距離
    def bfs(i, j):
        dxy = [[0,1],[0,-1],[1,0],[-1,0]]
        q = deque([[i,j]])
        d[i][j] = 0
        while q:
            x, y = q.popleft()
            for dx, dy in dxy:
                nx, ny = x+dx, y+dy
                if 0<=nx<=h-1 and 0<=ny<=w-1:
                    if d[nx][ny]=='.':
                        d[nx][ny] = d[x][y] + 1
                        q.append([nx,ny])
        res = 0
        for a in range(h):
            for b in range(w):
                if d[a][b] != '#':
                    res = max(res, d[a][b])
        return res

    res = 0
    for i in range(h):
        for j in range(w):
            if s[i][j] == '.':
                d = copy.deepcopy(s)
                res = max(res, bfs(i, j))
    print(res)

if __name__ == '__main__':
    main()

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

#define pb push_back
#define ff first
#define ss second

const int MAXN = 2e3 + 21;

long long n, x;
long long ans;
long long a[MAXN], mn[MAXN][MAXN];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> x;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        mn[0][i] = a[i];
        ans += a[i];
    }

    for(int i = 1; i < n; i++) {
        long long sum = 0;
        for(int j = 0; j < n; j++) {
            int chk = j - i;
            if(chk < 0)
                chk = n + chk;
            mn[i][j] = min(mn[i - 1][j], a[chk]);
            sum += mn[i][j];
        }
        ans = min(ans, sum + i * x);
    }

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



Measured memory_bytes: 31872
#include<iostream>
using namespace std;
int main(){
  string s,t;
  int ans=0;
  cin>>s>>t;
  for (int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      ans+=1;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  for(int p=1;p<=1000;p++){
    if((int)(p*0.08)==A && (int)(p*0.1)==B){
      cout << p << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
  return 0;
}

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

using namespace std;

const int MAX_N = 1e5 + 5;

vector<int> adj [MAX_N];
bool vis [MAX_N][12];
int color [MAX_N];

void paint (int v, int d, int c) {
  if (vis[v][d]) return;
  vis[v][d] = 1;
  if (color[v] == 0) color[v] = c;

  if (d != 0) {
    for (int nxt : adj[v]) {
      paint(nxt, d - 1, c);
    }
  }
}

int main () {
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  vector<pair<int, pair<int, int>>> queries;
  int qc;
  cin >> qc;

  for (int i = 0; i < qc; i++) {
    int v, d, c;
    cin >> v >> d >> c;
    queries.push_back(make_pair(v, make_pair(d, c)));
  }

  reverse(queries.begin(), queries.end());
  for (auto pr : queries) {
    paint(pr.first, pr.second.first, pr.second.second);
  }

  for (int i = 1; i <= n; i++) {
    cout << color[i] << '\n';
  }
}


Measured memory_bytes: 12348
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>

using namespace std;
using ll = long long;
const ll res = 1000000007;


int main() {
	ll N, M, cnt;
	cin >> N >> M;
	if (N <= 1 and M <= 1)
		cout << 0 << endl;
	else {
		cnt = N * (N - 1) / 2 + M * (M - 1) / 2;
		cout << cnt << endl;
	}
}

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;

const long long MOD = 1000000007;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

void solve(long long X, long long Y){
  if((2*Y-X)%3 != 0 or (2*X-Y)%3 != 0) {
    std::cout << 0 << std::endl;
    return;
  }
  ll d = (2*Y-X) / 3;
  ll r = (2*X-Y) / 3;
  combination c = combination(r+d);
  std::cout << c(r+d, d) << std::endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 13884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const ll mod = 1000000007;

void solve() {
    string s;
    cin >> s;
    bool flag = 0;
    rep(i, 3) flag += s[i] == '7';
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return;
}

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


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

int main()
{
    int N;
    cin >> N;
    int a[N];
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a, a + N);
    reverse(a, a + N);
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            ans += a[i];
        }
        else
        {
            ans -= a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
q = I()
que = [S() for i in range(q)]
#print(que)

st = []
en = []
f = 0
for i in range(q):
  n = que[i]
  if n == "1":
    f += 1
  else:
    t,ff,c = list(n.split())
    if (f+int(ff))%2 == 0:
      st.append(c)
    else:
      en.append(c)

#print(st)
#print(en)

if f%2 == 0:
  print("".join(en[::-1]) + s + "".join(st))
else:
  print("".join(st[::-1]) + s[::-1] + "".join(en))


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

cnt = 0
for i in range(n):
  if a[i] >= b[i]:
    cnt += b[i]
  else:
    extra = b[i] - a[i]
    if extra > a[i+1]:
      cnt += a[i] + a[i+1]
      a[i+1] = 0
    else:
      cnt += b[i]
      a[i+1] -= extra

print(cnt)

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

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >>m2 >>k;

   int S, G;
   S = (h1*60)+m1;
   G = (h2*60)+m2;

   if(G-S-k > 0) {
     cout << (G-S-k) << endl;
   }
    else{
         cout << "0" << endl;
       }
    }

Measured memory_bytes: 3640
#include<iostream>
typedef long long ll;

using namespace std;
int main()
{
	int n;
	cin >> n;

	int a;
	
	if (n < 105) {
		a = 0;
	}
	else if (n < 135) {
		a = 1;
	}
	else if (n < 165) {
		a = 2;
	}
	else if (n < 189) {
		a = 3;
	}
	else if (n < 195) {
		a = 4;
	}
	else {
		a = 5;
	}

	cout <<a<< endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long n,i,p,s1,s2;
cin>>n;
for(s1=s2=i=0;i<n;i++){
cin>>p;
s1+=p/n;
s2+=p%n;
}
cout<<s1+s2/n<<endl;
return 0;
}

Measured memory_bytes: 1160
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 1e5+5;
const ll MOD = 1e9+7;
using namespace std;

int a[MAX_N][3];
int dp[MAX_N][3];
int n;

int main()
{
    cin >> n;
    for(int i = 1;i<=n;++i)
        for(int j = 0;j<3;++j)
            cin >> a[i][j];
    for(int i = 1;i<=n;++i)
    {
        for(int j = 0;j<3;++j)
        {
            for(int k = 0;k<3;++k)
            {
                if (k==j)
                    continue;
                dp[i][j] = max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>

using namespace std;
typedef long long ll;

ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);

    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    ll gc=A[0];
    for(int i=0;i<N;i++){
        gc=euclidean_gcd(gc,A[i]);
    }
    cout << gc << endl;

}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Set Operation - Set Difference
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_9_C&lang=jp

"""
_ = input()
A = set([int(a) for a in input().split()])
_ = input()
B = set([int(b) for b in input().split()])
C = sorted([d for d in (A - B)])
if C:
    print(*C, sep='\n')




Measured memory_bytes: 53032
#include <cstdio>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int ts[110];
int vs[110];

struct S { // v = at+b
  int a, b;
  int area2(int t) const {
    return (a*t+b + a*(t+1)+b);
  }
  int v(int t) const {
    return a*t+b;
  }
};

S min(const S& s1, const S& s2, double t) {
  return s1.a*t+s1.b < s2.a*t+s2.b ? s1 : s2;
}

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &ts[i+1]);
    ts[i+1] *= 2;
    ts[i+1] += ts[i];
  }
  REP(i, n) {
    scanf("%d", &vs[i+1]);
    vs[i+1] *= 2;
  }
  int res = 0;
  int v = 0;
  REP(t, ts[n]) {
    double tt = t + 0.5;
    S mini = {1, v-t}; 
    // if(t <= 10) {
    //   cerr << "> " << t << endl;
    // }
    REP(i, n+1) {
      if(ts[i] <= tt && tt <= ts[i+1]) {
        S s = {0, vs[i+1]};
        // cerr << t << " " << s.a << " " << s.b << endl;
        mini = min(mini, s, tt);
      }
    }
    REP(i, n+1) { // 右肩下がり
      if(tt <= ts[i]) {
        S s = {-1, ts[i]+vs[i+1]};
        // cerr << t << " " << s.a << " " << s.b << endl;
        mini = min(mini, s, tt);
      }
    }
    // REP(i, n+1) { // 右肩上がり
    //   if(ts[i] <= tt) {
    //     S s = {1, -ts[i]+vs[i]};
    //     cerr << t << " " << s.a << " " << s.b << endl;
    //     mini = min(mini, s, tt);
    //   }
    // }

    // cerr << "[" << t << "," << t+1 << "] : a=" << mini.a << " b=" << mini.b << ", area2=" << mini.area2(t) << endl;
    res += mini.area2(t);
    v = mini.v(t+1);
  }
  printf("%.2f\n", res / 8.0);
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools

def solve(n: int, a: "List[int]"):
    a_sum = list(itertools.accumulate(a))
    ## 一個目をマイナスにするバージョン
    dif1 = 0
    answer1 = 0
    for i in range(0,n):
        if i%2==0:
            if a_sum[i]+dif1>-1:
                answer1 += abs(-1-(a_sum[i]+dif1))
                dif1 += -1-(a_sum[i]+dif1)
        else:
            if a_sum[i]+dif1 <1:
                answer1 += abs(1-(a_sum[i]+dif1))
                dif1 += 1-(a_sum[i]+dif1)

    ## 一個目をプラスにするバージョン
    dif2 = 0
    answer2 = 0
    for i in range(0,n):
        if i%2==0:
            if a_sum[i]+dif2<1:
                answer2 += abs(1-(a_sum[i]+dif2))
                dif2 += 1-(a_sum[i]+dif2)
        else:
            if a_sum[i]+dif2>-1:
                answer2 += abs(-1-(a_sum[i]+dif2))
                dif2 += -1-(a_sum[i]+dif2)
        
    print(min(answer1,answer2))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp15
{
    public class Program
    {
       static void Main(string[] args)
        { List<int> b = new List<int>();
            for (int f = 0; f < 10; f++)
            {
                int a = int.Parse(Console.ReadLine());
                b.Add(a);
            }
            b.Sort();
            Console.Write(b[9] + "\n");
            Console.Write(b[8] + "\n");
            Console.Write(b[7] + "\n");
        }
    }
}

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

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

    int ans = 0;

    for (int k = N-1; k >= 0; --k) {
        int tmp = 0;
        int i = 0;
        for (i = 0; i < N - k; ++i) {
            tmp += A[0][i];
        }
        for (int j = i-1; j < N; ++j) {
            tmp += A[1][j];
        }
        ans = max(ans, tmp);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n, m, ans = -1;
  cin >> n >> m;
  int sc[m][2];
  bool flag = 1;
  vector<int> c(3);
  for(int i = 0; i < m; i++){
    cin >> sc[i][0] >> sc[i][1];
  }
  
  for(int i = 0; i < m; i++){
    if((sc[i][0] == 1) && (sc[i][1] == 0)){
      ans = 0;
    }
    for(int j = i + 1; j < m; j++){
      if(ans == 0 && sc[j][0] != 1){
        flag = 0;
        break;
      }
      if(sc[i][0] == sc[j][0] && sc[i][1] != sc[j][1]){
        flag = 0;
        break;
      }
    }
  }
  
  if(flag){
    for(int i = 0; i < m; i++){
      c[sc[i][0] - 1] = sc[i][1];
    }
    if(n == 3){
      if(ans == 0){
        ans = -1;
      }else{
        if(c[0] == 0){
          if(c[1] == 0){
            ans = 100 + c[2];
          }else{
            ans = 100 + c[1]*10 + c[2];
          }
        }else{
          ans = c[2] + c[1]*10 +c[0]*100;
        }
      }
    }else if(n == 2){
      if(ans == 0){
        ans = -1;
      }else{
        if(c[0] == 0){
          ans = c[1] + 10;
        }else{
          ans = c[1] + c[0]*10;
        }
      }
    }else{
      ans = c[0];
    }
  }else{
    ans = -1;
  }
  
  
  cout << ans <<endl;
}


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

#define REP(i, n) for(ll i=0;i<ll(n); i++)

void debug_print(int N, vector<int> &A){
    int i;
    for(i=1;i<N+1;i++){
        cout << A[i] << endl;
    }
}
void tansaku(int N, vector<int> &A){
    int i, j, k;
    int n;
    for(i=1;i<=100;i++){ 
        for(j=i;j<=100;j++){ 
            for(k=j;k<=100;k++){ 
                n = i*i + j*j + k*k + i*j + j*k + k*i;
                if(n>N){break;}
                if((i == j) and (j == k)){A[n] += 1;}
                if((i == j) and (j != k)){A[n] += 3;}
                if((i != j) and (j == k)){A[n] += 3;}
                if((i != j) and (j != k)){A[n] += 6;}
    }}}
                
}

int main(){
    int N;
    cin >> N;
    int i;
    vector<int> A(N+1, 0);
    tansaku(N, A);
    for(i=1;i<N+1;i++){
        cout << A[i] << endl;
    }

    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
// cin.eof() 入力個数の問題

int main() {
   int n;
   cin>>n;
   string s[n];
   map<string,int> m;
   rep(i,n){
       cin>>s[i];
m[s[i]]++;
   }
cout<<"AC"<<" x "<<m["AC"]<<endl;
cout<<"WA"<<" x "<<m["WA"]<<endl;
cout<<"TLE"<<" x "<<m["TLE"]<<endl;
cout<<"RE"<<" x "<<m["RE"]<<endl;
   return 0;
}


Measured memory_bytes: 6764
from collections import deque
import bisect

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

A.sort()
A
P, Q = 0, 0
for i in range(N):
    if A[i] >= 0:
        P += 1
    else:
        Q += 1

if P == 0:
    P, Q = 1, N-1
if Q == 0:
    P, Q = N-1, 1

A_p = deque(A[Q:])
A_q = deque(A[:Q])
ans = []
while len(A_p) > 1:
    x = A_q.popleft()
    y = A_p.popleft()
    ans.append([x, y])
    z = x - y
    A_q.appendleft(z)

while A_q:
    x = A_p.pop()
    y = A_q.popleft()
    ans.append([x, y])
    A_p.append(x - y)

M = A_p.pop()
print(M)
for i in range(N-1):
    print(*ans[i])
    

        
    

Measured memory_bytes: 26676
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	char a;
	cin >> a;
	if (a >= 'A' && a <= 'Z')cout << 'A';
	else cout << 'a';
}

Measured memory_bytes: 3592
package main

import (
	"fmt"
)

func main() {
	var X int
	fmt.Scan(&X)
	expo := make(map[int]bool, X+1)
	expo[1] = true
	for b := 2; b <= X; b++ {
		v := b * b
		for v <= X {
			expo[v] = true
			v *= b
		}
	}
	for i := X; i >= 1; i-- {
		if expo[i] {
			fmt.Println(i)
			return
		}
	}
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
const int MAXN=int(2e5+5);
typedef long long LL;
int n;
int A[MAXN],B[MAXN];
struct QueNode {
    int w,id;
    QueNode() {}
    QueNode(int W,int I):
        w(W),id(I){}
    bool operator < (QueNode a) const {
        return w<a.w;
    }
    bool operator > (QueNode a) const {
        return w>a.w;
    }
};
priority_queue<QueNode>Q;
int main()
{
    //freopen("hopeless.in","r",stdin);
    //freopen("hopeless.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&A[i]);
    for(int i=1;i<=n;i++) {
        scanf("%d",&B[i]);
        Q.push(QueNode(B[i],i));
    }
    LL Ans=0;
    while(!Q.empty()) {
        int i=Q.top().id;Q.pop();
        int j=(i-2+n)%n+1,k=i%n+1;
        int del=B[j]+B[k],Min=max(max(B[j],B[k]),A[i]);
        int x=(B[i]-Min+del-1)/del;
        Ans+=x;
        B[i]-=del*x;
        if(B[i]<A[i]) {
            puts("-1");
            return 0;
        }
        if(B[i]>A[i])
            Q.push(QueNode(B[i],i));
    }
    for(int i=1;i<=n;i++)
        if(A[i]!=B[i]) {
            puts("-1");
            return 0;
        }
    printf("%lld",Ans);
}


Measured memory_bytes: 3700
#include <iostream>
#include <queue>

int main()
{
	int n; // number of items
	int m; // number of discount tickets
	std::priority_queue<long> a;
	
	std::cin >> n >> m;
	for (int i {}; i < n; i++)
	{
		long temp;
		std::cin >> temp;
		a.push(temp);
	}
	
	for (int i {}; i < m; i++)
	{
		long temp;
		temp = a.top();
		a.pop();
		temp /= 2;
		a.push(temp);
	}
	
	long ans {};
	while (!a.empty())
	{
		ans += a.top();
		a.pop();
	}
	
	std::cout << ans;
}

Measured memory_bytes: 1400
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let a: u32 = read();
    let b: u32 = read();
    let mut ans: u32 = 0;
    for i in 1..(n + 1) {
        let m: u32 = i.to_string().chars().map(|c| (c as i32 - 48) as u32).sum();
        if a <= m && m <= b {
            ans += i;
        }
    }
    println!("{}", ans);
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i,a+1) rep(j,b+1) rep(k,c+1){
    if(500*i+100*j+50*k == x) ans++;
  }
  cout << ans << endl;
			     
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

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

	vector<string> S(N + 1);
	repn(i, N) cin >> S[i];
	sort(++S.begin(), S.end());
	repn(i, N) cout << S[i];


	system("PAUSE");
}

Measured memory_bytes: 504