akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int x = sc.nextInt();
        pw.println(x < 30 ? "No": "Yes");
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c) {
        cout << "Yes" << "\n";
    } else if (c == b && b != a) {
        cout << "Yes" << "\n";
    } else if (c == a && b != a) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }


}















Measured memory_bytes: 3544
n , m = map(int,input().split())
x = [0]
y = [0]
z = [0]

for i in range(m):
    s , c = map(int,input().split())
    if s ==1:
        x.append(c)
    elif s==2:
        y.append(c)
    elif s == 3:
        z.append(c)


if n ==1:
    if len(set(x)) > 2:
        print('-1')
    else:
        print(max(x))
if n == 2 :
    if (len(x) > 1 and x[-1] == 0) or len(set(x)) > 2 or len(set(y)) >2:
        print('-1') 
    else:
        if len(x) ==1 :
            x.append(1)
            print(max(x)*10+max(y))
        else:
            print(max(x)*10+max(y))
if n ==3 :
    if (len(x) > 1 and x[-1] ==0 ) or len(set(x)) > 2 or len(set(y)) > 2 or len(set(z)) > 2:
        print('-1')
    else:
        if len(x) == 1:
            x.append(1)
        if len(y) ==1 :
            y.append(0)
        print(max(x)*100+ max(y)*10 + max(z))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define il inline
#define rg register
using namespace std;
const int O=100010;
il int gi(){
	int o=0,fl=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')fl=-1,ch=getchar();
	while(isdigit(ch))o=o*10+ch-'0',ch=getchar();
	return fl*o;
}
int n,l,x[O],f[31][O];
int main(){
	n=gi();
	for(int i=1;i<=n;++i)x[i]=gi();
	l=gi();
	for(int i=1;i<=n;++i)f[0][i]=upper_bound(x+1,x+n+1,x[i]+l)-x-1;
	for(int j=1;j<31;++j)
		for(int i=1;i<=n;++i)
			f[j][i]=f[j-1][f[j-1][i]];
	for(int Q=gi();Q--;){
		int x=gi(),y=gi(),ans=0;
		if(x>y)x^=y^=x^=y;
		for(int j=30;~j;--j)
			if(f[j][x]<y)ans+=1<<j,x=f[j][x];
		printf("%d\n",ans+1);
	}
	return 0;
}


Measured memory_bytes: 13312
#include <stdio.h>
int main()
{
  int N,A[100],i,j,flag,a,count=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  flag = 1;
  i=0;
  while(flag){
    flag=0;
    for(j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	a = A[j];
	A[j] = A[j-1];
	A[j-1]=a;
	count++;
	flag=1;
      }
    }
    i++;
  }

  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);

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

  return 0;
}

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	vint x(n), y(n);
	vint p(n);
	rep(i, n){
		cin>>x[i]>>y[i];
		p[i] = i;
	}
	double sum = 0;
	int cou = 0;
	do{
		int sx = x[p[0]];
		int sy = y[p[0]];
		rep(i, n-1){
			sum += sqrt((sx-x[p[i+1]])*(sx-x[p[i+1]])+(sy-y[p[i+1]])*(sy-y[p[i+1]]));
			sx = x[p[i+1]];
			sy = y[p[i+1]];
		}
		cou++;
	}while(next_permutation(all(p)));
	//cout << sum/(double)cou << endl;
	printf("%.10f\n", sum/(double)cou);
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();
			int x = in.nextInt() * 2;
			int y = in.nextInt() * 2;
			int ans = Integer.MAX_VALUE;
			for (int numC = 0; numC <= Math.max(x, y); numC++) {
				int cur = numC * c;
				cur += (Math.max(0, x - numC) + 1) / 2 * a;
				cur += (Math.max(0, y - numC) + 1) / 2 * b;
				ans = Math.min(ans, cur);
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979

//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int N;
    cin >> N;
    int a = 6, b = 9;
    vector<int> D = {1};
    while(a <= N){
        D.push_back(a);
        a *= 6;
    }
    while(b <= N){
        D.push_back(b);
        b *= 9;
    }
    int s = D.size();
    vector<vector<int>> dp(s + 10, vector<int>(N + 10, INF));
    rep(j, 0, s) dp.at(j).at(0) = 0;
    rep(j, 0, N + 1) dp.at(0).at(j) = j;
    rep(i, 0, s - 1){
        rep(n, 0, N + 1){
            dp.at(i + 1).at(n) = min(dp.at(i).at(n), dp.at(i + 1).at(n));
            if (n >= D.at(i + 1)){
                dp.at(i + 1).at(n) = min(dp.at(i + 1).at(n - D.at(i + 1)) + 1, dp.at(i + 1).at(n));
            }
        }
    }
    cout << dp.at(s - 1).at(N) << endl;
}

Measured memory_bytes: 9216
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    double r,g;
    cin >> r >> g;
    cout << (int)(g*2-r) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

struct state{
    int ly, lx, ry, rx;
};
int w, h;
bool contain(int y, int x){
    return (0 <= y && y < h && 0 <= x && x < w);
}
int dy[4] = {1, -1, 0, 0};
int dx[4] = {0, 0, 1, -1};
bool f[51][51][51][51];

signed main(){
    while(1){
        cin >> w >> h;
        if(w + h == 0) break;
        vector<string> s(h), t(h);
        bool ans = false;
        int lsy, lsx, lgy, lgx, rsy, rsx, rgy, rgx;
        rep(i, 0, h){
            cin >> s[i] >> t[i];
            rep(j, 0, w){
                if(s[i][j] == 'L'){ lsy = i; lsx = j;}
                if(s[i][j] == '%'){ lgy = i; lgx = j;}
                if(t[i][j] == 'R'){ rsy = i; rsx = j;}
                if(t[i][j] == '%'){ rgy = i; rgx = j;}
            }
        }
        queue<state> q;
        q.push((state){lsy, lsx, rsy, rsx});
        rep(i, 0, 51) rep(j, 0, 51) rep(k, 0, 51) rep(l, 0, 51) f[i][j][k][l] = false;
        f[lsy][lsx][rsy][rsx] = true;
        while(!q.empty()){
            state p = q.front(); q.pop();
            // cout << p.ly << " " << p.lx << " " << p.ry << " " << p.rx << endl;
            rep(i, 0, 4){
                int nly = p.ly + dy[i];
                int nlx = p.lx + dx[i];
                int nry = p.ry + dy[i];
                int nrx = p.rx - dx[i];
                if(!contain(nly, nlx) || s[nly][nlx] == '#'){ nly = p.ly; nlx = p.lx;}
                if(!contain(nry, nrx) || t[nry][nrx] == '#'){ nry = p.ry; nrx = p.rx;}
                if(f[nly][nlx][nry][nrx]) continue;
                f[nly][nlx][nry][nrx] = true;
                if(s[nly][nlx] == '%' && t[nry][nrx] == '%'){ ans = true; break;}
                else if(s[nly][nlx] == '%' || t[nry][nrx] == '%') continue;
                q.push((state){nly, nlx, nry, nrx});
            }
            if(ans == true) break;
        }
        cout << (ans ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 11400
using System;

public class Test
{
	public static void Main()
	{
		int n = int.Parse( Console.ReadLine() );
		
		bool[] s = new bool[13];
		bool[] h = new bool[13];
		bool[] c = new bool[13];
		bool[] d = new bool[13];
		
		for(int i = 0; i < n; i++) {
			string[] str = Console.ReadLine().Split(' ');
			
			switch(str[0]) {
				case "S":
					s[int.Parse(str[1]) - 1] = true;
					break;
				case "H":
					h[int.Parse(str[1]) - 1] = true;
					break;
				case "C":
					c[int.Parse(str[1]) - 1] = true;
					break;
				case "D":
					d[int.Parse(str[1]) - 1] = true;
					break;
			}
		}
		
		for(int i = 0; i < 13; i++) {
			if(!s[i])	Console.WriteLine("S " + (i+1) );
		}
		for(int i = 0; i < 13; i++) {
			if(!h[i])	Console.WriteLine("H " + (i+1) );
		}
		for(int i = 0; i < 13; i++) {
			if(!c[i])	Console.WriteLine("C " + (i+1) );
		}
		for(int i = 0; i < 13; i++) {
			if(!d[i])	Console.WriteLine("D " + (i+1) );
		}
	}
}

Measured memory_bytes: 9228
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
int A,B,C,D;
int main() {
	cin>>A>>B>>C>>D;

	if((A+B)>(C+D))cout<<"Left"<<endl;
	if((A+B)==(C+D))cout<<"Balanced"<<endl;
	if((A+B)<(C+D))cout<<"Right"<<endl;

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 105; i <= n; i+=2){
        int cnt=0;
        for(int j = 1; j <=i; j++){
            if(i%j==0)cnt++;
        }
        if(cnt == 8){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
m=[0]*5
for i in range(n):
    s=input()
    if s[0]=='M':
        m[0]+=1
    elif s[0]=='A':
        m[1]+=1
    elif s[0]=='R':
        m[2]+=1
    elif s[0]=='C':
        m[3]+=1
    elif s[0]=='H':
        m[4]+=1
ans=0
for a in range(5):
    for b in range(a+1,5):
        for c in range(b+1,5):
            ans+=m[a]*m[b]*m[c]
print(ans)



Measured memory_bytes: 45800
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
 
int main()
{
  int64 N;
  cin >> N;
  ++N;
 
  int64 sq = 1;
  while(sq < N) sq *= 2;
 
  int64 ret = N;
  for(int64 i = sq; i > 0; i >>= 1) {
    const int64 head = (N + i - 1) / i * i;
    const int64 rev_width = i / 2;
    if(head - N <= 0) continue;
    ret = min(ret, head - N);
 
  }
  cout << ret << endl;
 
 
}

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

int main(){
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  bool ans=true;
  int x=a,y=b;
  while(x<c){
    if(s[x+1]=='.'&&x+2<=c) x+=2;
    else if(s[x]=='.') x++;
    else{
      ans=false;
      x=c;
    }
  }
  while(y<d){
    if(s[y+1]=='.'&&y+2<=d) y+=2;
    else if(s[y]=='.') y++;
    else{
      ans=false;
      y=d;
    }
  }
  if(c>d){
    bool check=false;
    for(int i=b-2;i<d-1;i++){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
        check=true;
      }
    }
    if(!check){
      ans=false;
    }
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include <vector>
#include <map>

using namespace std;

long long int MOD = 1000000007;

int N, a[200005], b[200005];

vector<int> Adj[200005];

long long int dp[200005];

long long int p[200005], p_inv[200005];
int used[200005];
int num_child[200005];

map<pair<int, int>, long long int> memo;
map<pair<int, int>, int > NC;

long long int POW(long long int a, long long int k) {
	if (k == 0) { return 1; }
	if (k % 2 == 1) { return (POW(a, k - 1)*a) % MOD;  }
	long long int tmp = POW(a, k / 2);

	return (tmp*tmp) % MOD;
}

long long int INV(long long int a) {
	return POW(a, MOD - 2);
}

long long int CALL(int par, int u) {

	if (memo[make_pair(par, u)] > 0) {return memo[make_pair(par, u)];}

	//cout << "call" << endl;

	long long int ret = 1;
	int num_c = 0;
	for (auto y : Adj[u]) {
		if (y==par) { continue; }
		ret *= CALL(u, y); 
		ret %= MOD;
		num_c += NC[make_pair(u,y)];
		ret *= p_inv[NC[make_pair(u,y)]]; ret %= MOD;
		//cout << "ret= " << ret << endl;
	}

	//cout << "num_child= " << num_child[u] << endl;
	ret *= p[num_c];
	ret %= MOD;

	memo[make_pair(par, u)] = ret;
	NC[make_pair(par, u)] = num_c+1;

	return ret;

}

void PROC(int par, int u) {

	long long int val=memo[make_pair(0, par)];

	int num_c = NC[make_pair(par, u)];

	val *= INV(p[N - 1]); val %= MOD;
	val *= p[num_c]; val %= MOD;
	val *= INV(memo[make_pair(par, u)]); val %= MOD;


	NC[make_pair(u, par)] = N - num_c;

	val *= p[N - 1 - num_c]; val %= MOD;

	memo[make_pair(u, par)] = val;


	long long int wal = memo[make_pair(par, u)];

	//cout << "wal= " << wal << endl;
	wal *= INV(p[num_c-1]); wal %= MOD;
	wal *= INV(p[N - num_c]); wal %= MOD;
	wal *= p[N - 1]; wal %= MOD;
	wal *= memo[make_pair(u, par)]; wal %= MOD;
	memo[make_pair(0, u)] = wal;

	for (auto y : Adj[u]) {
		if (y != par) { PROC(u, y); }
	}

}

int main(void) {

	cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		cin >> a[i] >> b[i];
		Adj[a[i]].push_back(b[i]);
		Adj[b[i]].push_back(a[i]);
		NC[make_pair(a[i], b[i])] = -1;
		NC[make_pair(b[i], a[i])] = -1;
	}

	p[0] = 1;
	for (long long int i = 1; i <= N; i++) {
		p[i] = p[i - 1] * i;
		p[i] %= MOD;
		p_inv[i] = INV(p[i]);
	}

	


	/*cout << CALL(-1, 2) << endl;

	cout << NC[make_pair(-1, 2)] << endl;
	cout << NC[make_pair(2, 1)] << endl;
	cout << memo[make_pair(2, 1)] << endl;
	cout << memo[make_pair(1, 3)] << endl;
	*/
	
	CALL(0, 1);

    for (auto y : Adj[1]) {
				 PROC(1, y);
			 }
	
	 for (int i = 1; i <= N; i++) {
		 cout << memo[make_pair(0, i)] << endl;
	 }


	return 0;
}

Measured memory_bytes: 82676
N = gets.to_i
S = Hash.new {|h, k| h[k] = 0 }

N.times do |i|
  S[gets.chomp[0]] += 1
end

count = 0
%w(M A R C H).combination(3) do |c|
  count += c.inject(1) {|tmp, i| tmp *= S[i] }
end

puts count

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

#define CL(N) cout << N << endl
#define DCT(N) cout << "debug " << N << endl
#define REP(i, N) for (int i = 0; i < N; i++)

int main()
{
	int a[3];

    REP(i, 3){
        cin >> a[i];
    }

    sort(a, a + 3);

    a[2] == a[0] + a[1] ? CL("Yes") : CL("No");

	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<vector<int>> G(n);
    rep(i,m){
        int a,b;
        cin >>a >>b;
        --a;
        --b;
        G[a].pb(b);
        G[b].pb(a);
    }

    int ans = 0;
    vector<bool> vis(n);
    rep(i,n)if(!vis[i]){
        int cc = 0;
        queue<int> que;
        que.push(i);
        vis[i] = true;
        ++cc;
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int e:G[v]){
                if(!vis[e]){
                    que.push(e);
                    vis[e] = true;
                    ++cc;
                }
            }
        }

        if(cc==1) ++ans;
        else --ans;
    }
    cout << abs(ans) << endl;
    return 0;
}



Measured memory_bytes: 3200
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(W, H);
  GI2(x, y);
  printf("%.10f %d\n", (double)W * H / 2.0, (x * 2 == W && y * 2 == H));
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c = 0;
    scanf("%d %d",&a,&b);;
    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
//
// Created on 2020/05/17.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>>edge(n,vector<int>());

    for (int i = 0; i < m; ++i) {
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    queue<int>q;
    vector<int>ans(n,-1);//++すること
    ans[0] = 0;
    q.push(0);
    while(!q.empty()){
        int now_room = q.front();
        q.pop();
        for (int i = 0; i < edge[now_room].size(); ++i) {
            if(ans[edge[now_room][i]] == -1){
                ans[edge[now_room][i]] = now_room + 1;
                q.push(edge[now_room][i]);
            }
        }
    }

    int cnt;
    cnt = count(all(ans),-1);
    if(cnt == 0){
        cout<<"Yes"<<endl;
        for (int i = 1; i < ans.size(); ++i) {
            cout<<ans[i]<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 10160
from collections import defaultdict
import collections
N=int(input())
ss = []
for i in range(N):
  ss.append(input())
#d = defaultdict(lambda: 0)
c = collections.Counter(ss)
d_=c.most_common()
mx = d_[0][1]
d_.sort()
#print(d_)
m=len(d_)
for i in range(m):
  if d_[i][1] == mx:
    print(d_[i][0])
  else:
    pass

Measured memory_bytes: 46904
#include<stdio.h>

int main(){
 int i,H,W,j;
 scanf("%d%d",&H,&W);
 while(H*H+W*W){
  for(j=0;j<H;j++){
   if(j*(H-1-j)){
    printf("#");
    for(i=2;i<W;i++){
     printf(".");}
    printf("#");}
   else{ 
    for(i=0;i<W;i++){
     printf("#");}}
   printf("\n");}
  printf("\n");
  scanf("%d%d",&H,&W);}
 return 0;}

Measured memory_bytes: 572
#include <iostream>

using namespace std;

class Dice {
public:
	int top, face[6];
	void East() {
		top = face[0];
		face[0] = face[3];
		face[3] = face[5];
		face[5] = face[2];
		face[2] = top;
	}
	void West() {
		top = face[0];
		face[0] = face[2];
		face[2] = face[5];
		face[5] = face[3];
		face[3] = top;
	}
	void North() {
		top = face[0];
		face[0] = face[1];
		face[1] = face[5];
		face[5] = face[4];
		face[4] = top;
	}
	void South() {
		top = face[0];
		face[0] = face[4];
		face[4] = face[5];
		face[5] = face[1];
		face[1] = top;
	}
};


int main() {
	int i, j, k, l, q, x, y, m, n;
	Dice dice[100]; 
	cin >> n;
	for (i = 0; i < n; i++){
		for (k = 0; k < 6; k++)
			cin >> dice[i].face[k];
	}
	for (k = 0; k < n; k++){
		for (i = 0; i < 6; i++){
			if (i == 4) dice[k].North();
			else if (i == 5) {
				dice[k].South();
				dice[k].South();
			}
			else dice[k].East();
			for (j = 0; j < 4; j++){
				l = dice[k].face[1];
				dice[k].face[1] = dice[k].face[2];
				dice[k].face[2] = dice[k].face[4];
				dice[k].face[4] = dice[k].face[3];
				dice[k].face[3] = l;
				
				for (m = k + 1; m < n;m++) {
						if (dice[k].face[0] == dice[m].face[0] && dice[k].face[1] == dice[m].face[1] && dice[k].face[2] == dice[m].face[2] && dice[k].face[3] == dice[m].face[3] && dice[k].face[4] == dice[m].face[4] && dice[k].face[5] == dice[m].face[5]){
							cout << "No" << endl;
							goto end;
						}
					}
			}
		}
	}
		cout << "Yes" << endl;
	end:;
	}

Measured memory_bytes: 1160
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.IntStream;

public class Main {
	
	public Main() {
		FastScanner scanner = new FastScanner();
		long N = scanner.nextLong();
		long X = scanner.nextLong();
		long M = scanner.nextLong();
		
		int[] det = new int[(int)M];
		
		IntStream.range(0, (int)M).forEach( i -> det[i] = -1);
		
		int sIndex;
		long A = X;
		while ( true ) {
			if ( det[ (int)(A*A%M) ] != -1) {
				det[(int)A] = (int)(A*A%M);
				sIndex = (int)(A*A%M);
				break;
			}
			
			det[(int)A] = (int)(A*A%M);
			A = A*A%M;
		}
		
		long loopSUM  = 0L;
		long loopSize = 0L;
		int index = sIndex;
		while ( true ){
			loopSize++;
			loopSUM += index;
			index = det[index];
			if (index == sIndex) break;
		}
		
		long Ans = 0L;
		A = X;
		while (true) {
			if ( A == sIndex ) {
				break;
			}
			N--;
			Ans += A;
			A = A*A%M;
		}
		
		Ans += loopSUM * (N / loopSize);
		
		N = N % loopSize;
		A = sIndex;
		while( N > 0){
			Ans += A;
			A = A*A%M;
			N--;
		}
		
		System.out.println(Ans);
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 34232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
    static int MOD = 1000000007;

    void solve() throws IOException {

    	int a = ni();
    	int b = ni();
    	int c = ni();
    	int d = ni();

    	int ans = 0;
    	if(a*b >= c*d){
    		ans = a*b;
    	}else{
    		ans = c*d;
    	}

    	out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    int k(int n) throws IOException {
        if(n == 0) return 1;
        else return n * k(n-1);
    }

    long s(int a, int n) throws IOException {
        return (a+n) * (n-a+1) / 2;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8272
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

int main(){
  int n,t;
  cin >> n >> t;
  int ans=inf;
  rep(i,n){
    int c,ti; cin>>c>>ti;
    if(ti<=t){ ans=min(ans,c);}
  }
  if(ans==inf){  cout << "TLE" << endl; return 0; }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vecll = vector<long long>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(n) (n).begin(), (n).end()

int main()
{
    ll n, k;
    cin >> n >> k;
    for (ll bit = 0; bit <(1<< n);bit++) {
        bitset<18> bitcnt = bit;
        vector<ll> S;
        if ((int)(bitcnt.count())==k) {
            for (ll i=0;i<n;i++)
            {
                if (bit & (1<<i))
                    S.push_back(i);
            }

            cout << bit << ":";
            for (ll i=0;i<(int)(S.size());i++)
            {
                cout << " " << S[i];
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3160
#include <stdio.h>

int main(void)
{
	int i1, i2, c = 0, n = 0, N1 = 0, N2 = 0;
	
	for(i1 = 0; i1 < 3; i1++){
		c = getchar();
		n = (c - '0');
		for(i2 = 0; i2 < i1; i2++){
			n *= 10;
		}
		N1 += n;
		n = (c - '0');
		for(i2 = 2; i1 < i2; i2--){
			n *= 10;
		}
		N2 += n;
	}
	
	if(N1 == N2){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    X, t = inputMap()
    
    print(max(0, X-t))
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var count = 0;
            if (ab[0] == 2) count = ab[1] - 1;
            else count = ab[1] / (ab[0] - 1) + (ab[1] % (ab[0] - 1) > 1 ? 1 : 0);
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
using namespace std;

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

const int INF = 1e9;
int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

int main() {
  char a[9], s;
  rep(i, 9) {
    cin >> s;
    a[i] = s;
  }

  cout << a[0] << a[4] << a[8] << endl;
}


Measured memory_bytes: 256
import copy

n, W = map(int, input().split())
product = [[0] for _ in range(4)]

w, v = map(int, input().split())
w_0 = w
product[0].append(v)
for i in range(n-1):
  w, v = map(int, input().split())
  product[w-w_0].append(v)

product[0].sort()
product[1].sort()
product[2].sort()
product[3].sort()

for i in range(len(product[0])-1):
  product[0][i+1] = product[0][i+1]+product[0][i]
for i in range(len(product[1])-1):
  product[1][i+1] = product[1][i+1]+product[1][i]
for i in range(len(product[2])-1):
  product[2][i+1] = product[2][i+1]+product[2][i]
for i in range(len(product[3])-1):
  product[3][i+1] = product[3][i+1]+product[3][i]

ans = 0
for a in range(len(product[0])):
  for b in range(len(product[1])):
    for c in range(len(product[2])):
      for d in range(len(product[3])):
        weight = w_0*(len(product[0])-a-1)+(w_0+1)*(len(product[1])-b-1)+(w_0+2)*(len(product[2])-c-1)+(w_0+3)*(len(product[3])-d-1)
        if weight > W:
          continue
        sub = 0
        sub += (product[0][len(product[0])-1]-product[0][a])
        sub += (product[1][len(product[1])-1]-product[1][b])
        sub += (product[2][len(product[2])-1]-product[2][c])
        sub += (product[3][len(product[3])-1]-product[3][d])
        if ans < sub:
          ans = sub
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main(){
    int n;
    string s;
    cin>>n>>s;
    vector<vector<int>>dp(n+1,vector<int>(n+1));
   ll ans=0;
   for (int i = 2; i <= n; i++)
   {
       for (int j = 1; j<i; j++)
       {
           if(s[i-1]!=s[j-1]) continue;
            dp[i][j]=min(i-j,dp[i-1][j-1]+1);
            ans=max(ans,dp[i][j]);
   }
   }
    cout<<ans<<endl;

    return 0;
}

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

int main(void) {
    std::string s;
    int ans = 0;

    std::cin >> s;
    if(s[0] == '1') ans++;
    if(s[1] == '1') ans++;
    if(s[2] == '1') ans++;

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;  cin >> n >> x;
    vector<int> m(n);
    int count = 0;
    rep(i, n) {
      cin >> m[i];
      x -= m[i];
      count++;
    }
    sort(m.begin(), m.end());
    count += x / m[0];
    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>

using namespace std;

const int maxx=100050;
int n,m,k;
int a[maxx];
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;
queue<int> q;
//int dist[maxx];


const int INF = 0x3f3f3f3f;
const int MAXN = 1000010;
struct qnode{
    int v;
    int c;
    qnode(int _v=0,int _c=0):v(_v),c(_c){}
    bool operator < (const qnode &r) const
        {
            return c > r.c;
        }
};
struct Edge
{
    int v,cost;
    Edge(int _v=0,int _cost=0):v(_v),cost(_cost){}
};
vector<Edge>E[MAXN];
bool vis[MAXN];
int dist[MAXN];
void Dijkstra(int n,int start)//点的编号从1开始
{
    memset(vis,false,sizeof(vis));
    for(int i = 1; i <= n; i++) dist[i] = INF;
    priority_queue <qnode> que;
    while(!que.empty()) que.pop();
    dist[start] = 0;
    que.push(qnode(start,0));
    qnode tmp;
    while(!que.empty())
    {
        tmp = que.top();
        que.pop();
        int u = tmp.v;
        if(vis[u]) continue;
        vis[u] = true;
        for(int i = 0; i < E[u].size(); i++)
        {
            int v = E[tmp.v][i].v;
            int cost = E[u][i].cost;
            if(!vis[v]&&dist[v]>dist[u] + cost)
            {
                dist[v] = dist[u] + cost;
                que.push(qnode(v,dist[v]));
            }
        }
    }
}
void addedge(int u,int v,int w)
{
    E[u].push_back(Edge(v,w));
}

void init()
{
    for(int i = 1; i < maxx; i++)
    {
        addedge(i,(i+1-1)%n+1,1);
        addedge(i,(i*10-1)%n+1,0);
    }
}

int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
    scanf("%d",&n);
    init();
    Dijkstra(n,1);
    printf("%d\n",dist[n]+1);
    return 0;
}


Measured memory_bytes: 30972
N = int(input())
A = list(map(int, input().split()))

A_sorted = sorted([A[i] - (i+1) for i in range(N)])

if len(A) != 1:
    b = A_sorted[int((len(A)-1)/2)]
    b2 = A_sorted[int((len(A)-1)/2 + 1)]
    sad_1 = sum([abs(A_sorted[i] - b) for i in range(N)])
    sad_2 = sum([abs(A_sorted[i] - b2) for i in range(N)])
    print(min(sad_1, sad_2))
else:
    print('0')


Measured memory_bytes: 27720
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;

int a[N];

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(s.size()<=n) cout<<s<<endl;
	else {
		for(int i=0;i<n;i++){
			cout<<s[i];
		}
		cout<<"...\n";
	}
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	set<string> st;
	for(int i=0;i<n;i++)
	{
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;




}

Measured memory_bytes: 19148
// #define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h,w,n; cin >> h >> w >> n;
    vector<Pll> vec(n);
    rep(i,n){
        cin >> vec[i].second >> vec[i].first;
        vec[i].second--;vec[i].first--;
        vec[i].second = vec[i].second - vec[i].first;
        debug(vec[i]);
    }
    sort(all(vec));
    ll ans = INF;
    ll xmin = 0, xmax = h;
    ll id = 0;
    rep(y,min(h,w)){
        while(id < n && vec[id].first <= y){
            debug(vec[id], ans, y, xmin, xmax);
            if(vec[id].second < 0){
                id++;
                continue;
            }
            if(vec[id].second <= xmin){
                chmax(xmin, vec[id].second + 1);
                id++;
                continue;
            }
            chmin(ans, vec[id].second + vec[id].first - 1);
            debug(vec[id], ans);
            id++;
        }
        chmin(ans, y + xmax - 1);
        xmax--;
    }

    cout << ans + 1 << endl;
}

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

int main() {
  int N;
  cin >> N;
  if ((N % 1000) % 111 == 0 || (N - N % 10) % 111 == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
import java.util.Scanner;
public class Main { 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//４棟それぞれ別に配列を設ない（）
		int[][][]house = new int[4][3][10];
		//データ入力数をnとする。
		int n = sc.nextInt();
		//データ入力数n回分forを回す(　˙-˙　)
		for(int i=0;i<n;i++) {
			int b = sc.nextInt();//棟番号
			int f = sc.nextInt();//階数
			int r = sc.nextInt();//部屋番号
			int v = sc.nextInt();//人数
			//？？
			house [b-1][f-1][r-1] += v;
		}
		for (int i=0;i<4;i++) {
			for (int j=0;j<3;j++) {
				for(int k=0;k<10;k++) {
					System.out.print(" "+house[i][j][k]);
				}
				System.out.println();
                                }
				if(i!=3) {
					System.out.println("####################");
				
			}
		}
	}
}




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

int main(){
  int n;
  char s[9];
  long l,m;
  cin>>n;
  while(n--){
    cin>>s;
    sort(s,s+sizeof(s)-1);
    l=atol(s);
    sort(s,s+sizeof(s)-1,greater<char>());
    m=atol(s);
    cout<<m-l<<endl;
  }
  return 0;
}

Measured memory_bytes: 1188