akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)

#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<ll> vi;
typedef set<ll> seti;
typedef vector<string> vs;

const ll MOD = 1e9+7;
const ll INF = 1e9;

int main() {
	ll N,M;
	cin>>N>>M;
	vector<tuple<ll , ll>> AB(N);
	rep(i,N){
		ll A,B;
		cin>>A>>B;
		AB[i]=make_tuple(A,B);
	}
	sort(all(AB));
	//rep(i,N){
		//cout<<get<0>(AB[i])<<get<1>(AB[i])<<endl;
	//}
	ll ans = 0;
	rep(i,N){
		ll Ai = get<0>(AB[i]);
		ll Bi = get<1>(AB[i]);
		if(M==0)break;
		else{
			if(M>=Bi){
				ans+=Ai*Bi;
				M-=Bi;
				}
			else{
				ans+=Ai*min(Bi,M);
				M-=min(Bi,M);
				}
			}
	}

	cout<<ans<<endl;
}

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

using namespace std;

#define ll long long

int main(void){
    double a, b;
    cin >> a >> b;

    double ans;
    int flag = 0;
    for(ans = 1.0;ans < 1001.0;ans += 1.0){
        if(floor(ans * 0.08) == a && floor(ans * 0.1) == b){
            flag = 1;
            break;
        }
    }

    if(flag == 1){
        cout << ans << endl;
    }else{
        cout << "-1" << endl;
    }
    

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int n, x; cin >> n >> x;
    vint d(n + 1);
    d[0] = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        d[i + 1] = d[i] + a;
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if (d[i] <= x) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n, a;
	long long sum = 0;
	long long min = 1000000;
	long long max = -1000000;

	cin >> n;

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

		cin >> a;
		if(a < min) min = a;
		if(a > max) max = a;
		sum = sum + a;

	}
	cout << min << " " << max << " " << sum << endl;

	return 0; 

}


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

int main() {
    char a, b;
    cin >> a >> b;
    if (a == 'H' && b == 'H') cout << 'H' << endl;
    else if (a == 'H' && b == 'D') cout << 'D' << endl;
    else if (a == 'D' && b == 'H') cout << 'D' << endl;
    else if (a == 'D' && b == 'D') cout << 'H' << endl;
}

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


    class Program
    {


        static void Main(string[] args)
        {
            Solve();
        }

        static void Solve()
        {
        Scan sc = new Scan();
        write wr = new write();

        var p1 = sc.longarr;
        long n = p1[0];
        var a = sc.longarr;

        Array.Sort(a);
        Array.Reverse(a);
        long ans1 = 0, ans2 = 0; ;


        for(int i = 0; i < a.Length; ++i)
        {
            if (i % 2 == 0) ans1 += a[i];
            else ans2 += a[i];
        }

        wr.wri(ans1 - ans2);
            
        }
    }


    class Scan
    {
    public string str => Console.ReadLine();

    public string[] strarr => str.Split(' ');

    public long[] longarr => strarr.Select(long.Parse).ToArray();

   
    }
    
    class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int a[13]={0,2,5,5,4,5,6,3,7,6};
int dp[10007],vis[13],w[10007],p[10007];
int main(){
	memset(w,-1,sizeof(w));
	int n,m;cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x;cin>>x;vis[x]=1;
	}
	w[0]=0;
	for(int i=1;i<=n;i++){
		for(int k=1;k<=9;k++){
			if(vis[k]&&i>=a[k]){
				if(w[i-a[k]]+1>=w[i]) w[i]=w[i-a[k]]+1,p[i]=k; 
			}
		}
	}
	int x=n;
	while(x){
		printf("%d",p[x]);x=x-a[p[x]];
	}
	return 0;
}


Measured memory_bytes: 384
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
//#define MOD 1000000007
#define MOD 998244353
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    string S;
    cin >> N >> S;
    ll mwcnt = 0;
    ll mbcnt = 0;
    ll mi = MOD;
    S += "#";
    rep(i, N) {
        if (S[i] == '.') mwcnt++;
        else if (S[i] == '#') mbcnt++;
    }
    ll wcnt = 0;
    ll bcnt = 0;
    rep(i, N+1) {
        mi = min(mi, bcnt + mwcnt - wcnt);
        if (S[i] == '.') wcnt++;
        else if (S[i] == '#') bcnt++;
    }
    print(mi);
    return 0;
}

Measured memory_bytes: 640
M = 2**15+1
isPrime = [True]*M
isPrime[0],isPrime[1]=False,False
p = []; ans = [0]*M;
for i in xrange(M):
    if isPrime[i]:
        for j in xrange(i*i,M,i):
            isPrime[j] = False
        p.append(i)
for i in xrange(len(p)):
    for j in xrange(i,len(p)):
        if p[i]+p[j]>=M: break
        ans[p[i]+p[j]]+=1
while 1:
    n = input()
    if n==0: break
    print ans[n]

Measured memory_bytes: 4732
#include <stdio.h>

int main(void)
{
	long int a, b; //???????????´??°
	long int d, r;
	double f;
	scanf("%ld %ld", &a, &b);
	d = a/b;
	r = a%b;
	f = (double)a/(double)b;
	printf("%ld %ld %f\n", d, r, f);
	return 0;
}

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

int main(){
  int n,a,b,x[200];
  while(1){
    cin>>n>>a>>b;
    if(n==0 && a==0 && b==0) break;
    for(int i =0;i<n;i++){
      cin>>x[i];
    }
    int j=0,k=a;
    for(int i=a-1;i<b;i++){
      if(x[i]-x[i+1]>=j){
	j=x[i]-x[i+1];
	k=i+1;
      }
    }
    cout<<k<<endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>

using namespace std;

int main() {
  char s[5];
  scanf("%s", s);

  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
using namespace std;
typedef unsigned long long inter;
const inter m=1e9+7;
map<inter,inter> dick;
inter f(inter x)
{
    if(dick[x])
        return dick[x];
    else
    return dick[x]=((f(x/2)+f((x-1)/2)+f((x-2)/2)))%m;
}
void work()
{
	dick[0]=1;
	dick[1]=2;
	inter n;
	cin>>n;
	cout<<f(n);
}
int main()
{
    work();
}

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

char map[16][16];

void island(int x, int y){
    int v[4][2] = {{1,0}, {0,1}, {-1,0}, {0, -1}};
    map[x][y] = '0';
    for(int i = 0; i < 4; i++){
        int xx = x + v[i][0], yy = y + v[i][1];
        if( 0 <= xx && xx < 12 && 0 <= yy && yy < 12 && map[xx][yy] == '1'){
            island(xx, yy);
        }
    }
}

int main(){
    while( true ){
        if( scanf("%s", map[0]) == EOF ) break;
        for(int i = 1; i < 12; i++){
            scanf("%s", map[i]);
        }
        int count = 0;
        for(int i = 0; i < 12; i++){
            for(int j = 0; j < 12; j++){
                if( map[i][j] == '1' ){
                    count++;
                    island(i, j);
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 976
n = int(input())
f0, f1 = [0] * n, [0] * n
for i in range(n):
    x, y = map(int, input().split())
    f0[i] = x - y
    f1[i] = x + y
print(max(max(f0) - min(f0), max(f1) - min(f1)))


Measured memory_bytes: 24608
//2017-10-22
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define N (200000+5)

int n, a[N], bl[N], br[N];
int tp, st[N];

void Init(){
	For(i, 1, n){
		while(tp && a[st[tp]] > a[i]) --tp;
		bl[i] = tp? st[tp]+1: 1; st[++tp] = i;
	}

	tp = 0;
	Forr(i, n, 1){
		while(tp && a[st[tp]] > a[i]) --tp;
		br[i] = tp? st[tp]-1: n; st[++tp] = i;
	}
}

int main(){
	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &a[i]);
	
	Init();

	int ml, mr;
	LL ans = 0;
	For(i, 1, n){
//		printf("bl[%d] = %d br[%d] = %d\n", i, bl[i], i, br[i]);
		ml = i - bl[i] + 1; mr = br[i] - (i-1);
//		printf("ml = %d mr = %d\n", ml, mr);
		
		ans += 1ll * ml * mr * a[i];
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ar array
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)
 
using namespace __gnu_pbds;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > iil;
typedef pair<ll,int> li;
typedef pair<int,int> ii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;

inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
}
ll pMod(ll x,ll n,ll mod)
{ ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
 
}
 
//think recursively also;
ll dp[102][100002];
void solve()
{ 
  
  ll n,w;
  cin>>n>>w;
  ll wv[n+1][2];
  ll mx=0;
  for(int i=1;i<=n;i++)
  {
    cin>>wv[i][0]>>wv[i][1];
    mx+=wv[i][1];
  }  
  ll ans=0;
  for(int i=0;i<=n;i++)
  {for(int j=0;j<=mx;j++)
  {
       dp[i][j]=1e18;
       
       if(j==0)
        dp[i][j]=0;

  }
  }
  for(int i=1;i<=n;i++)
  {for(int j=1;j<=mx;j++)
  {
   
       if(j-wv[i][1]>=0)
       {
         dp[i][j]=min(dp[i][j],dp[i-1][j-wv[i][1]]+wv[i][0]);
       }
       
        dp[i][j]=min(dp[i][j],dp[i-1][j]);
       
  }
  }
  for(int j=mx;j>=0;j--)
  {
     if(dp[n][j]<=w){
      cout<<j<<endl;
      return;
     }
  }
  //cout<<ans<<endl;
}
int main()
{
  fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {//cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

Measured memory_bytes: 82416
import java.util.Scanner;

public class Main {
	static int []a  = new int[5];
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<5;i++)a[i] = Integer.parseInt(sc.next());
		sc.close();

		int fanc = 10;
		int sum = 0;
		for(int i=0;i<5;i++) {
			if(fanc>a[i]%10&&a[i]%10>0)fanc=a[i]%10;
			if(a[i]%10==0) {
				sum += a[i];
			}else {
				a[i]/=10;
				sum+=a[i]*10+10;
			}
		}
		sum -= 10-fanc;
		System.out.println(sum);
	}

}


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

vector<bool> visit_edges(10,false);
vector<int> to[30];

int dfs(int v,int n,vector<bool> visit_edges){
    int ans = 0;
    bool finish = true;
    visit_edges[v] = true;
    rep(i,n){
        if(!visit_edges[i]) finish = false;
    }
   
    if (finish) return 1;
    for( int e: to[v]){
        if (visit_edges[e]) continue;
        ans += dfs(e,n,visit_edges);
    }
    return ans;
}

int main(){
    int n,m,ans;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans = dfs(0,n,visit_edges);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}

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

    int r;
    cin >> r;
    ll ans = 3 * r * r;
    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    W, H, N = mi()
    p = [[0]*W for _ in range(H)]
    for i in range(N):
        xi, yi, ai = mi()
        if ai == 1:
            for x in range(xi):
                for y in range(H):
                    p[y][x] = 1
        if ai == 2:
            for x in range(xi, W):
                for y in range(H):
                    p[y][x] = 1
        if ai == 3:
            for x in range(W):
                for y in range(yi):
                    p[y][x] = 1
        if ai == 4:
            for x in range(W):
                for y in range(yi, H):
                    p[y][x] = 1
    print(W*H-sum(sum(p[i]) for i in range(H)))

if __name__ == '__main__':
    main()


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


int main()
{
   
    ll i,j,n,p,m=1000000007,flag=0,temp=0;
   cin>>n;
   ll arr[n];

   for(i=0;i<n;i++)cin>>arr[i];

    for(i=1;i<n-1;i++)
    {
      if(arr[i]>arr[i-1]&&arr[i]<arr[i+1])
      {
        temp++;

      }
      else if(arr[i]<arr[i-1]&&arr[i]>arr[i+1])
      {
        temp++;
        
      }
    }

   cout<<temp<<endl;
    return 0;

  }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;


int d[100003] = {};
ll lb[100003] = {}, m[100003];
vector<int> g[100003];

void dfs(int p) {
	int i, x;

	x = 0;
	m[p] = 1;
	for (i = 0; i < g[p].size(); i++) {
		if (d[g[p][i]] > d[p]) {
			dfs(g[p][i]);
			m[p] = m[p] * m[g[p][i]] % mod;
			x++;
		}
	}

	if (p == 0) {
		m[p] = m[p] * lb[x - 1] % mod;
	}
	else {
		m[p] = m[p] * lb[x] % mod;
	}

}

int main(void) {
	int n, k, i, a, b, p;
	ll ans;
	queue<int> q;

	scanf("%d%d", &n, &k);

	if (n == 1) {
		printf("%d\n", k);
		return 0;
	}

	for (i = 0; i < n - 1; i++) {
		scanf("%d%d", &a, &b);
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}

	q.push(0);
	d[0] = 1;
	while (!q.empty()) {
		p = q.front();
		q.pop();
		for (i = 0; i < g[p].size(); i++) {
			if (d[g[p][i]] == 0) {
				d[g[p][i]] = d[p] + 1;
				q.push(g[p][i]);
			}
		}
	}

	lb[0] = 1;
	lb[1] = k - 2;
	for (i = 2; i <= k - 1; i++) {
		lb[i] = lb[i - 1] * (k - i - 1) % mod;
	}

	dfs(0);

	ans = m[0] * (k - 1) % mod * k % mod;

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define REP(name, stop) for (ll(name) = 0; (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll x;
    cin >> x;
    ll m = 100;
    ll year = 0;
    while (m < x) {
        m += m * 0.01;
        year++;
    }
    cout << year << endl;

    return 0;
}


Measured memory_bytes: 3580
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

class Edge{
public:
    int s;
    int t;
    int w;
    Edge() = default;
    Edge(int vi,int ei,int wi):s(vi),t(ei),w(wi){;}
    bool operator <(const Edge &o){return w < o.w;}
};

class UF{
public:
    int V;
    vector<int> a;
    vector<int> weight;
    UF(int num):V(num){
        a.resize(V);weight.resize(V);
        for(int i = 0; i < V;i++){
            a[i] = i;weight[i] = 1;
        }
    }
    int root(int i){
        while(a[i] != i) i = a[i];
        return i;
    }
    void Union(int i,int j);
    bool find(int i,int j){return root(i) == root(j);}
};

void UF::Union(int i,int j){
    i = root(i);
    j = root(j);
    if(weight[i] > weight[j]){
        a[j] = a[i];
        weight[i] += weight[j];
    }
    else{
        a[i] = a[j];
        weight[j] += weight[i];
    }
}

int main(){
    int V,E,s,t,w;
    scanf("%d %d",&V,&E);
    vector<Edge> earr;
    UF u(V);
    for(int i = 0; i < E;i++){
        scanf("%d %d %d",&s,&t,&w);
        earr.push_back(Edge(s,t,w));
    }
    sort(earr.begin(),earr.end());
    int i , k;
    long long result = 0;
    for(i = 0, k = 0;i < V && k < E;k++){
        if(!u.find(earr[k].s,earr[k].t)){
            result += earr[k].w;
            u.Union(earr[k].s,earr[k].t);
            i++;
        }
    }
    printf("%lld\n",result);
}



Measured memory_bytes: 4168
#include<stdio.h>
int a[10001];
int map[101][101];
int main() {
	int h, w, n, x, y;
	scanf("%d%d%d", &h, &w, &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	x = y = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= a[i]; j++) {
			map[x][y] = i;
			if (x % 2 == 1) y++;
			else y--;
			if (y == w + 1) {
				y = w;
				x++;
			}
			else if (y == 0) {
				y = 1;
				x++;
			}
		}
	}
	for (int i = 1; i <= h; printf("\n"),i++) for (int j = 1; j <= w; j++) printf("%d ", map[i][j]);
	return 0;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int N;
  cin >> N;
  
  vector<tuple<int,int,int>> xy(N);
  UnionFind tree(N);
  
  long long ans = 0;
  
  for (int i=0; i<N; i++) {
    cin >> get<0>(xy[i]) >> get<1>(xy[i]);
    get<2>(xy[i]) = i;
  }
  
  sort(xy.begin(),xy.end());
  
  for (int i=0; i<N-1; i++) {
    if (get<0>(xy[i]) == get<0>(xy[i+1])) {
      tree.unite(get<2>(xy[i]),get<2>(xy[i+1]));
    }
  }
  for (int i=0; i<N; i++) {
    swap(get<0>(xy[i]),get<1>(xy[i]));
  }
  
  sort(xy.begin(),xy.end());

  for (int i=0; i<N-1; i++) {
    if (get<0>(xy[i]) == get<0>(xy[i+1])) {
      tree.unite(get<2>(xy[i]),get<2>(xy[i+1]));
    }
  }
  
  int p;
  for (int i=0; i<N; i++) {
    p = get<2>(xy[i]);
    get<2>(xy[i]) = tree.root(p);
    swap(get<0>(xy[i]),get<2>(xy[i]));
  }
  
  sort(xy.begin(),xy.end());
  
  long long num = 0;
  vector<pair<int,int>> can(N);
  vector<long long> ansn1(N,1);
  vector<long long> ansn2(N,1);
  vector<long long> ansn3(N,0);

  for (int i=0; i<N; i++) {
    ansn3[get<0>(xy[i])]++;
    if (i == N-1) {
      break;
    }
    if (get<0>(xy[i]) == get<0>(xy[i+1])) {
      if (get<1>(xy[i]) != get<1>(xy[i+1])) {
        ansn1[get<0>(xy[i])]++;
      }
    }
  }
      
  for (int i=0; i<N; i++) {
    swap(get<2>(xy[i]),get<1>(xy[i]));
  }
  sort(xy.begin(),xy.end());
  
  for (int i=0; i<N; i++) {
    if (i == N-1) {
      break;
    }
    if (get<0>(xy[i]) == get<0>(xy[i+1])) {
      if (get<1>(xy[i]) != get<1>(xy[i+1])) {
        ansn2[get<0>(xy[i])]++;
      }
    }
  }
  
  for (int i=0; i<N; i++) {
    if (ansn1[i] != 1 && ansn2[i] != 1) {
      ans += ansn1[i] * ansn2[i] - ansn3[i];
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        String s = scn.nextLine();
        String t = scn.nextLine();
        String ans = "Yes";
        for(int i=0;i<s.length();i++){
            if(s.charAt(i) != t.charAt(i)){
                ans = "No";
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35680
while True:
    n,x=map(int,input().split())
    if n==x==0:
        break
    ans = 0
    for n1 in range(1, n+1):
        if n1 > x:
            break
        for n2 in range(n1+1, n+1):
            for n3 in range(n2+1, n+1):
                if n1 + n2 + n3 == x:
                    ans += 1
    print(ans)



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

typedef long long ll;

int main() {
    vector<ll> A(200, 1);
    rep(i, 200) {
        rep(j, 5) {
            A[i] *= i;
        }
    }
    ll X;
    cin >> X;
    rep(A, 200) {
        rep(B, 200) {
            ll A5 = 1, B5 = 1;
            rep(i, 5) {
                A5 *= A;
                B5 *= B;
            }
            if (A5 - B5 == X) {
                cout << A << " " << B << "\n";
                return 0;
            }
            if (A5 + B5 == X) {
                cout << A << " " << -B << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define pow5(x) x*x*x*x*x

int main()
{
  long long x;
  cin >> x;
  
  int a, b = 0;
  int max_a = 200;
  
  bool signeture = (x > 0);
  x = abs(x);
  
  for(long long i = -max_a; i <= max_a; i++)
  {
    for(long long j = -max_a; j <= max_a; j++)
    {
      if(pow5(i) - pow5(j) == x)
      {
        a = i;
        b = j;
        break;
      }
    }
  }
  if(signeture) cout << a << " " << b << endl;
  else cout << b << " " << a << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int a[1000];
int main(){
	int n, m;
	while (cin >> n >> m, n) {
		int ma = -1;
		rep(i, n) {
			cin >> a[i];
		}
		rep(i, n) {
			Rep(j,i+1, n) {
				if (a[i] + a[j] > m)continue;
				ma = max(ma, a[i] + a[j]);
			}
		}
		if (ma == -1)cout << "NONE" << endl;
		else cout << ma << endl;
	}
	return 0;
}


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

int main(){
  int n,m;
  while(cin >> n, n){
    cin >> m;
    string s;
    cin >> s;
    
    int ans = 0;
    for(int i=0;i<m;i++){
      if(s[i] == 'I'){
	int len = 0;
	while(i+2<m && s[i+1] == 'O' && s[i+2] == 'I'){
	  i+=2; len++;
	}
	ans += max(0,len-n+1);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2108
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

#define lson rt<<1
#define rson rt<<1|1
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("D://code//in.txt","r",stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0)

const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;

int n, x;

int main(){
    scanf("%d", &n);
    int ans = 0;
    while(n--) {
        scanf("%d", &x);
        ans = __gcd(ans, x);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+5;
const int inf=0x3f3f3f3f;
int c[maxn],vis[maxn],ans[maxn],tree[maxn];
vector<pair<int,int> >v[maxn];
int n,q;
int lowbit(int x)
{
	return x&(-x);
}
void add(int x,int k)
{
	while(x<=n)
	{
		tree[x]+=k;
		x+=lowbit(x);
	}
}
int sum(int x)
{
	int ans=0;
	while(x!=0)
	{
		ans+=tree[x];
		x-=lowbit(x);
	}
	return ans;
}
int main()
{
	cin>>n>>q;
	for(int i=1;i<=n;i++)
		cin>>c[i];
	for(int i=1;i<=q;i++)
	{
		int l,r;
		cin>>l>>r;
		v[r].push_back(make_pair(i,l));
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[c[i]]!=0)
			add(vis[c[i]],-1);
		vis[c[i]]=i;
		add(i,1);
		for(auto j:v[i])
			ans[j.first]=sum(i)-sum(j.second-1);
	}
	for(int i=1;i<=q;i++)
		cout<<ans[i]<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    int n, W;
    cin>>n>>W;
    int w[n];
    int v[n];
    for(int i = 0; i < n; i++) cin>>w[i]>>v[i];
    long long dp[n+1][W+1];
    for (int i = 0; i <= n; i++) dp[i][0] = 0;
    for(int i = 0; i <= W; i++) dp[0][i] = 0;
    
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= W; j++)
        {
            if(w[i-1] <= j)
            {
                dp[i][j] = max(dp[i-1][j], v[i-1] + dp[i-1][j-w[i-1]]); 
            }
            else
                dp[i][j] = dp[i-1][j];
            
        }
    }
    cout<<dp[n][W];
    return 0;

    
}

Measured memory_bytes: 82332
#include<bits/stdc++.h>
using namespace std;
const int mod = 2019;
int main()
{
	string s;
	cin >> s;
	vector<int> cnt(mod,0);
	int val=0,ten=1;
	cnt[val]++;
	long long ans = 0;
	for(int i=s.size()-1;i>=0;i--)
	{
		int digit = s[i]-'0';
		val = (val+digit*ten)%mod;
		ten = (ten*10)%mod;
		ans += cnt[val];
		cnt[val]++;
	}
	cout << ans;
}

Measured memory_bytes: 3732
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    if(n.charAt(0)==n.charAt(1) && n.charAt(1)==n.charAt(2)){
      System.out.println("Yes");
    }else if(n.charAt(1)==n.charAt(2) && n.charAt(2)==n.charAt(3)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21716
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
a = [None]*n
for i in range(n):
    a[i] = list(map(int, input().split()))
    sum = c
    for j in range(m):
        sum += a[i][j]*b[j]
    if sum > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
  int i,max=0,c;
  char a[4];
  scanf("%s",a);
  for(i=0;i<3;i++)
  {
  if(a[i]=='S')
    c=0;
  else
    c++;
  if(c>max)
  max=c;
  }
  printf("%d\n",max);
return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main(){
    int a, p;
    cin >> a >> p;
    cout << (3*a + p)/2 << endl;

}

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

int main() {
    int A[3][3];
    int N;
    int B[10];
    for (int i = 0;i <= 2;i++){
        for (int j = 0;j <= 2;j++){
            cin >> A[i][j];
        }
    }
    cin >> N;
    for(int i = 0;i < N;i++)
    cin >> B[i];
    for (int i = 0;i < N;i++){
        for(int j = 0;j <= 2;j++){
            for(int k = 0;k <= 2;k++){
                if (B[i] == A[j][k]){
                    A[j][k] = 200;
                }
            }
        }
    }
    for (int i = 0;i <= 2;i++){
        if(A[i][0] == A[i][1] && A[i][1]== A[i][2]){
            cout << "Yes" << endl;
            return 0;
        }
        if(A[0][i] == A[1][i] && A[1][i]== A[2][i]){
            cout << "Yes" << endl;
            return 0;
        }
    }

    if((A[0][0] == A[1][1] && A[1][1]== A[2][2]) || (A[0][2] == A[1][1] && A[1][1] == A[2][0]))
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	int n;
	cin>>n;
	VI a(n+1);
	rep(i,1,n+1){
		cin>>a[i];
	}
	vector<ll> dp(n+1,0);
	dp[1] = 0;
	vector<ll> prefix(n+1);
	prefix[1] = a[1];
	for(int i=3;i<=n;i+=2){
		prefix[i] = prefix[i-2]+a[i];
	}
	for(int i=2;i<=n;i++){
		if(i&1){
			dp[i]=max(dp[i-1],dp[i-2]+a[i]);
		}else{
			dp[i] = a[i] + dp[i-2];
			dp[i] = max(dp[i],prefix[i-1]);
		}
	}
	cout<<dp[n];
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






Measured memory_bytes: 7144
/* ALDS1_11_B: Depth First Search */

#include <iostream>
#include <cstdio>
#include <vector>
using std::vector;

vector<int> *graph;
int elapsed = 1;

// Search the graph recursively by depth-first search.
void traverse(int id, int found[], int finished[]) {
    if (0 < found[id]) {
        return;
    }

    found[id] = elapsed++;
    vector<int> degrees = graph[id];
    for (int i = 0; i < degrees.size(); i++) {
        traverse(degrees[i], found, finished);
    }
    finished[id] = elapsed++;
}

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

    int max_v = n_v + 1;
    graph = new vector<int>[max_v];

    for (int i = 0; i < max_v; i++) {
        int id, n_degrees;
        scanf("%d %d", &id, &n_degrees);

        for (int j = 0; j < n_degrees; j++) {
            int deg_id;
            scanf("%d", &deg_id);
            graph[id].push_back(deg_id);
        }
    }

    int found[max_v];
    int finished[max_v];
    std::fill_n(found, max_v, 0);
    std::fill_n(finished, max_v, 0);

    for (int id = 1; id < max_v; id++) {
        traverse(id, found, finished);
    }

    for (int id = 1; id < max_v; id++) {
        printf("%d %d %d\n", id, found[id], finished[id]);
    }
    return 0;
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

int n,m;

int p2(int x){
  REP(i,20){
    if(x % (1<<i) != 0)return i-1;
  }
  return 0;
}

int main(){
  cin>>n>>m;
  REP(i,(1<<n)-1){
    REP(j,(1<<m)-1){
      if(p2(i+1)!=0 && p2(i+1) == p2(j+1))cout<<0;
      else cout<<1;
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll s,w;
 	cin>>s>>w;
 	if(w>=s)
 	{
 		cout<<"unsafe"<<endl;
 	}
 	else
 	{
 		cout<<"safe"<<endl;
 	}
    return 0;
}

Measured memory_bytes: 3648
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
signed main()
{
    fast;
    int n,m;
    cin>>n>>m;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    vector<pii> v;
    for(int i=1;i<=m;i++)
    {
        int b,c;
        cin>>b>>c;
        v.pb({c,b});
    }
    sort(all(v),greater<pii>());
    int idx = 0;
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(idx>=m)
            ans+=a[i];
        else
        {
            ans+=max(a[i],v[idx].first);
            v[idx].second--;
            if(v[idx].second==0)
                idx++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3188
a,b=map(int,input().split())

aa=[]
bb=[]

for i in range(a):
    aa.append(str(b))

for i in range(b):
    bb.append(str(a))

str1="".join(aa)
str2="".join(bb)

result=[str1,str2]

result=sorted(result)

print(result[0])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
    long int n;
    cin>>n;

    long int d = n % 10;

    if(d == 3){
        cout<<"bon";
    }
    else if(d == 0 || d == 1 || d == 6 || d == 8){
        cout<<"pon";
    }
    else{
        cout<<"hon";
    }
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int exist = 0;
    for(int i = 0; i < n-2; i++){
        if(s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C') exist++;
    }
    cout << exist << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


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

    vector<int>H(N);
    rep(i,N)cin >> H[i] ;

    reverse(H.begin(),H.end());

    rep(i,N-1){
        int sa = H[i+1] -H[i];
        if(sa <= 0 )continue;
        else if (sa == 1)H[i+1] -= 1;
        else{
             cout << "No" << endl;
             return 0;
        }
    }
    cout << "Yes" << endl;

}

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

namespace abc065b
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = new int[N];
            bool[] AB = new bool[N];
            for(int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }
            int j = 0;
            int count = 0;
            while (j != 1)
            {
                if (AB[j] == true)
                {
                    Console.WriteLine(-1);
                    return;
                }
                AB[j] = true;
                count++;
                j = A[j] - 1;
            }
            Console.WriteLine(count);
        }
    }
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int x;
  cin >> x;
  for (int i = x; i <= 300000; ++i) {
    int n = i;
    bool ok = true;
    for (int j = 2; j * j <= n; ++j) {
      if (n % j == 0) ok = false;
    }
    if (ok) {
      cout << n << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
D = list(map(int, input().split()))
def xInD(x):
    while x > 0:
        lsd = x % 10
        if lsd in D:
            return False
        x //= 10
    return True
while True:
    if xInD(n):
        print (n)
        break
    else:
        n += 1

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

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

const int MAXK = 1e5;
const int MAXN = 100;

int n, k, arr[MAXN+10];
bool dp[MAXK+10];

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

    scanf("%d%d", &n, &k);
    for(i=1; i<=n; i++) scanf("%d", &arr[i]);

    dp[0]=true;
    for(i=1; i<=k; i++)
    {
        bool now=false;
        for(j=1; j<=n; j++)
        {
            if(i-arr[j]<0) continue;
            now|=dp[i-arr[j]];
        }
        if(!now) dp[i]=true;
    }

    printf("%s", dp[k]?"Second":"First");
    return 0;
}


Measured memory_bytes: 384
N=int(input())
lis=[0,0,0,0]
for _ in range(N):
    S=str(input())
    if S=="AC":
        lis[0]+=1
    elif S=="WA":
        lis[1]+=1
    elif S=="TLE":
        lis[2]+=1
    elif S=="RE":
        lis[3]+=1
print("AC x "+str(lis[0]))
print("WA x "+str(lis[1]))
print("TLE x "+str(lis[2]))
print("RE x "+str(lis[3]))

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

typedef vector<int> vi;
typedef long long int ll;
#define clr(v, d)           memset(v, d, sizeof(v))
#define all(v)   (v.begin()),(v.end())
#define lp(i,n)     for(int i=0;i<n;i++)
#define sz(v)       v.size()
#define F           first
#define S           second
#define pb          push_back
#define MP          make_pair
#define pii         pair<int, int>

int main() {
    int n;
    cin>>n;
    vi v(n);
    lp(i,n){
        cin>>v[i];
    }
    lp(i,n){
        if(v[i]%2==0){
            if(v[i]%3==0||v[i]%5==0){
                //nothing
            }
            else{
               cout<<"DENIED";
               return 0;
            }
        }
    }
    cout<<"APPROVED";

    return 0;
}


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

long long solve(long long A, long long B) {
    if(A + 2 > B) {
        return 2 * A - 2;
    } else {
        long long C = sqrt(A * B) - 1;
        while((C + 1) * (C + 1) < A * B) ++C;
        return (C * (C + 1) < A * B ? (2 * C - 1) : (2 * C - 2));
    }
}

int main() {
    int Q; cin >> Q;
    while(Q--) {
        long long A, B;
        cin >> A >> B;
        cout << solve(min(A, B), max(A, B)) << endl;
    }
}

Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A[]=$a[0];
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->A[]=$a[0];
  }
}
printf("%s\n",strtoupper(solve('a',$key)));

function solve($player,$key) {
  switch($player) {
  case 'a':
    $len = strlen($key->A[0]);
    if ($len == 0) return 'a';
    $r = substr($key->A[0],0,1);
    $key->A[0] = substr($key->A[0],1,$len-1);
    break;
  case 'b':
    $len = strlen($key->A[1]);
    if ($len == 0) return 'b';
    $r = substr($key->A[1],0,1);
    $key->A[1] = substr($key->A[1],1,$len-1);
    break;
  case 'c':
    $len = strlen($key->A[2]);
    if ($len == 0) return 'c';
    $r = substr($key->A[2],0,1);
    $key->A[2] = substr($key->A[2],1,$len-1);
    break;
  default:
    printf("err\n");
  }
  return solve($r,$key);
}


Measured memory_bytes: 4472
def main():
    # 制約条件
    MAX_RESULT = 1000000000000000000
    
    N = int(input())
    A = [int(x) for x in input().split()]
    
    if 0 in A:
        result = 0
        print(result)
        return
    
    result = 1
    
    for x in A:
        result *= x
        if result > MAX_RESULT:
            print(-1)
            return
    print(result)
main()

Measured memory_bytes: 21656
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    int diga = a.length();
    int digb = b.length();
    if(diga > digb){
        cout << "GREATER" << endl;
        return 0;
    }else if(diga < digb){
        cout << "LESS" << endl;
        return 0;
    }else{
        for(int i = 0; i < diga; i++){
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;               
            }
        }
        cout << "EQUAL" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (i * j == N)
                    {
                        Console.Write("Yes");
                        return;
                    }
                }
            }
            Console.Write("No");
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13140
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vi ab(4000+1);
	FOR(a, 0, 1000) {
		FOR(b, 0, 1000) {
			ab[a+b]++;
		}
	}
	
	int n;
	while(cin >> n) {
		ll ans = 0;
		FOR(i, 0, n) {
			ans += ab[i] * ab[n-i];
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------
vector<vector<int>> G(10);
int N,M;
vector<bool> visited(10,false);
int dfs(int v, int cnt = 0){
  cnt++;
  if(cnt == N){
    return 1;
  }
  int res = 0;
  for(auto nv: G[v]){
    if(visited[nv]) continue;
    visited[nv] = true;
    res += dfs(nv,cnt);
    visited[nv] = false;
  }
  return res;
}

int main(){
  cin >> N >> M;
  for(int i=0; i<M; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  visited[0] = true;
  cout << dfs(0) << endl;
  return 0;
}


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

int main(int argc, const char * argv[]) {
    int K, X;
    cin >> K;
    cin >> X;
    
    int plus = X + K - 1;
    int minus = X - (K - 1);
    
    for (int i = minus; i <= plus; i++) {
        cout << i << " ";
    }
    
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(void) {
  int inp;
  set<int> s;

  for (size_t i = 0; i < 3; i++) {
    scanf("%d",&inp);
    s.insert(inp);
  }

  printf("%d\n",s.size());

  return 0;
}


Measured memory_bytes: 256