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

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.size();
    set<string> dic;
    for (int i = 1; i <= k; i++) {
        rep(j, n-i+1) {
            string c;
            rep(l, i) {
                c.push_back(s[j+l]);
            }
            dic.insert(c);
        }
    }
    // int i = 0;
    // for (string word : dic) {
    //     i++;
    //     if (i == k) {
    //         cout << word << endl;
    //     }
    // }
    auto itr = dic.begin();
    rep(i, k-1) {
        itr++;
    }
    cout << *itr << endl;
}

Measured memory_bytes: 4808
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define itmin(x,y) (x) = min((x),(y));
#define itmax(x,y) (x) = max((x),(y));
#define cotu cout
#define itn int
const int INF = 1e9 + 7;

vector<vi> edges;
vector<bool> used;
vi inDegree, dist;

void dfs(int a){
    used[a] = true;
    for(int b: edges[a]){
        itmax(dist[b],dist[a]+1);
        inDegree[b]--;
        if(inDegree[b]==0) dfs(b);
    }
}

int main(){
    int n,m; cin>>n>>m;
    edges = vector<vi>(n+1,vi());
    used = vector<bool>(n+1,false);
    inDegree = vi(n+1);
    dist = vi(n+1);
    for(int i = 0; i < m; i++){
        int a,b; cin>>a>>b;
        edges[a].pb(b);
        inDegree[b]++;
    }
    for(int i = 1; i <= n; i++){
        if(!used[i] && inDegree[i]==0) dfs(i);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        itmax(ans,dist[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 2000000000
#define PI 3.14159265358979323846
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++)
		if(s[i]=='?')
			s[i]='D';
	cout << s << '\n';
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;




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


int n,m,p;
	
int win(int ba[8][8][8],int win){
	for(int i = 0 ; i < 8 ; i++){
		for(int j = 0 ; j < 8 ; j++){
			for(int k = 0 ; k < 8 ; k++){
				for(int l = 0 ; l < 17 ; l++){
					int cnt = 0;
					for(int x = 0 ; x < 8 ; x++){
						int tx = i + x*dx[l];
						int ty = j + x*dy[l];
						int tz = k + x*dz[l];
						if( tx >= n || ty >= n || tz >= n || tx < 0 || ty < 0 || tz < 0 ) break;
						if( win == ba[tx][ty][tz] ) cnt++;
						else cnt = 0;
						if( cnt >= m ) return 1;
					}
				}
			}
		}
	}
	return 0;
}

int main(){
	while(cin >> n >> m >> p && n){
		int ba[8][8][8]={};
		int sz[8][8]={};
		
		int flag = 0;
		for(int i = 1 ; i <= p ; i++){
			int x,y;
			cin >> x >> y;
			x--,y--;
			if(flag)continue;
			ba[x][y][sz[x][y]++] = (i&1?2:1);
			if( win(ba,(i&1?2:1)) ){
				if( i % 2 == 0 ) cout << "White";
				else cout << "Black";
				
				cout << " " << i << endl;
				flag=1;
			}
		}
		if(!flag)cout << "Draw" << endl;
	}
}

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

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

int main(){
	int n,i,a[200000],max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>a[max])max=i;
	}
	qsort(a,n,sizeof(int),compare_int);
	for(i=0;i<n;i++){
		if(i==max)printf("%d\n",a[n-2]);
		else printf("%d\n",a[n-1]);
	}
	return 0;
}

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

int main() {
	//マス目数を取得。縦はH、横はW
	int H, W;
	cin >> H >> W;

	//マスの色を入力。白なら'.'、黒なら'#'
	vector<vector<char>> trout(H, vector<char>(W));
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> trout.at(i).at(j);
		}
	}

	//マス目を圧縮して出力
	//縦の白マスを検出
	vector<int> Hwhite(W, -1);
	for(int i = 0; i < W; i++){
		int white = 0;
		for(int j = 0; j < H; j++){
			if(trout.at(j).at(i) == '#') break;
			white++;
		}
		if(white == H)
			Hwhite.at(i) = i;
	}
	//横の白マスを検出
	vector<int> Wwhite(H, -1);
	for(int i = 0; i < H; i++){
		int white = 0;
		for(int j = 0; j < W; j++){
			if(trout.at(i).at(j) == '#') break;
			white++;
		}
		if(white == W)
			Wwhite.at(i) = i;
	}

	for(int i = 0; i < H; i++){
		//横がすべて白なら次に行く
		if(Wwhite.at(i) == i)
			continue;
		for(int j = 0; j < W; j++){
			//（縦の要素が）白なら描画しない
			if(Hwhite.at(j) == j)
				continue;
			else
				cout << trout.at(i).at(j);
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))

ans = 0
even = v[::2]
nums_e = {}
for e in even:
    if not e in nums_e.keys():
        nums_e[e] = 1
    else:
        nums_e[e] += 1

e_sorted = []
for key, value in nums_e.items():
    e_sorted.append([value, key])
e_sorted = sorted(e_sorted, reverse = True) + [[0, 0-1]]
        

odd = v[1::2]
nums_o = {}
for o in odd:
    if not o in nums_o.keys():
        nums_o[o] = 1
    else:
        nums_o[o] += 1
        
o_sorted = []
for key, value in nums_o.items():
    o_sorted.append([value, key])
o_sorted = sorted(o_sorted, reverse = True) + [[-1, 0]]

if e_sorted[0][1] != o_sorted[0][1]:
    print(n - e_sorted[0][0] - o_sorted[0][0])
else:
    ans1 = n - e_sorted[1][0] - o_sorted[0][0]
    ans2 = n - e_sorted[0][0] - o_sorted[1][0]
    print(min(ans1, ans2))


Measured memory_bytes: 25392
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main(void){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<>());
    if(s.compare(t)>=0)cout << "No";
    else cout << "Yes";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n, m; cin >> n >> m;
  vector<vector<int>> jobs(m+1);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if(a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for(int i = m-1; i >= 0; --i) {
    for(int b : jobs[i]) {
      q.push(b);
    }
    if(!q.empty()) {
      ans += q.top(); q.pop();
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5632
A = gets.to_i
B = gets.to_i
C = gets.to_i
D = gets.to_i
E = Array.new
E[0] = A+C
E[1] = A+D
E[2] = B+C
E[3] = B+D
min = 1000000000000
for k in 0..3
 if min > E[k]
  min = E[k]
 end
end
puts(min) 

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;


int main(){
	string s;cin >> s;
	int ans = 0;
	rep(i,s.size()) {
		if(i%2==0) {
			if(s[i]=='p') ans--;
		}
		else {
			if(s[i]=='g') ans++;
		}
	}
	cout << ans << endl;

} 


Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[4];
		for (int i = 0; i < n; i++) {
			switch (sc.next().charAt(0)) {
				case 'A':
					++array[0];
					break;
				case 'W':
					++array[1];
					break;
				case 'T':
					++array[2];
					break;
				case 'R':
					++array[3];
					break;
			}
		}
		System.out.println("AC x " + array[0]);
		System.out.println("WA x " + array[1]);
		System.out.println("TLE x " + array[2]);
		System.out.println("RE x " + array[3]);
	}
}


Measured memory_bytes: 58264
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	cin >> n;
	vi mi(n);
	vi ma(n);
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		a--;
		mi[i]=a;
		ma[i] = b;
	}
	SORT(mi);
	SORT(ma);
	int cnt = 0;
	int iidx = 0;
	int aidx = 0;
	int ans = 0;
	REP(i, 100001) {
		while (iidx<n&&mi[iidx] == i) {
			cnt++;
			iidx++;
		}
		while (aidx<n&&ma[aidx] == i) {
			cnt--;
			aidx++;
		}
		if (i <= cnt)
			ans = i;
	}
	cout << ans << endl;
}

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

/*約数の個数を求める関数*/
int div(int n) {
  int ans=0;
  for(int i=1;i<n+1;i++) {
    if(n%i==0) {
      ans++;
    }
  }
  return ans;
}
     /*実行*/
int main() {
  int n;
  cin>>n;
  int ams=0;
  for(int i=1;i<n+1;i++) {
    if(i%2==1) {
      if(div(i)==8) {
        ams++;
      }
    }
  }
  cout<<ams<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll>> 
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define rep(i,start,end) for(int i=start;i<end;i++)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()  
#define sz(x) (ll)(x).size()
//////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
	fast;
  	int a,b,t;
  	cin>>a>>b>>t;
  	cout<<(t/a)*b;
  return 0;
}

Measured memory_bytes: 256
/*
  This C++ Source Is
  Writen By syksykCCC
  (2020)
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for(register int i = x; i < y; i++)
#define REP(i, x, y) for(register int i = x; i <= y; i++)
#define per(i, x, y) for(register int i = x; i > y; i--)
#define PER(i, x, y) for(register int i = x; i >= y; i--)
#define repl(i, x, y) for(register long long i = x; i < y; i++)
#define REPL(i, x, y) for(register long long i = x; i <= y; i++)
#define perl(i, x, y) for(register long long i = x; i > y; i--)
#define PERL(i, x, y) for(register long long i = x; i >= y; i--)
#define LLL __int128
#define int128 __int128
#define DEBUG(x) cerr << #x << " : " << x << endl
using namespace std;
typedef unsigned int uint;
typedef long long int64;
typedef long long LL;
typedef unsigned long long uint64;
typedef long long ULL;
typedef long double LLF;
template<typename T> inline void read(T &val)
{
	val = 0; char c = getchar(); int f = 1;
	while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)) { val = (val << 3) + (val << 1) + (c ^ 48); c = getchar(); }
	val *= f;
}
template<typename T> void write_(T val) { if(!val) return; write_(val / 10); putchar(val % 10 + 48); }
template<typename T> inline void write(T val)
{
	if(val == 0) putchar(48);
	else if(val < 0) { putchar('-'); write_(-val); }
	else write_(val);
}

int main()
{
#ifdef LOCAL
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	int k, a, b;
	cin >> k >> a >> b;
	REP(i, a, b)
	{
		if(i % k == 0)
		{
			cout << "OK\n";
			return 0;
		}
	}
	cout << "NG\n";
	return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
import itertools
N = int(input())
P = input().split(" ")
Q = input().split(" ")
perm = itertools.permutations(P, len(P))
a = b = 0
for i in perm:
    if int("".join(P)) >= int("".join(i)):
        a += 1
    if int("".join(Q)) >= int("".join(i)):
        b += 1
print(abs(a-b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
  int a,b,c;cin>>a>>b>>c;
  cout<<max(c+b-a,0)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<cmath>
#include<tuple>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define MMAX 7368795

int main()
{
	int m,n;
	while(scanf("%d%d",&m,&n),m|n)
	{
		int memo[MMAX] = {};
		bool flag = false;
		int i,Mcount = 0;
		for(i = m;i < MMAX;i++)
		{
			if(memo[i] == 0)
			{
				if(Mcount == n)flag = true;

				for(int j = i;j < MMAX;j += i)
				{
					memo[j] = 1;
				}
				Mcount++;
				
			}
			if(flag)break;
		}
		
		printf("%d\n",i);
		
		
	}
	return 0;
}

Measured memory_bytes: 31984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int n, l; cin >> n >> l;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	sort(all(s));
	string ans;
	for(auto e:s)ans+=e;
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		String[] S = new String[N];
		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}
		Arrays.sort(S);
		String current = "";
		int streak = 0;
		int max = 0;
		for (String s : S) {
			if (!s.equals(current)){
				max = Math.max(max, streak);
				streak = 1;
				current = s;
			} else {
				streak += 1;
			}
		}
		max = Math.max(max, streak);
		current = "";
		streak = 0;
		for (String s : S) {
			if (!s.equals(current)){
				if (streak == max){
					System.out.println(current);
				}
				streak = 1;
				current = s;
			} else {
				streak += 1;
			}
		}
		if (streak == max){
			System.out.println(current);
		}
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 79544
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;

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

typedef pair<int, int> pii;

int a[100000];
int maxer[100000], miner[100000];

int main() {
	int n, t;
	cin >> n >> t;
	REP(i, n) scanf("%d", &a[i]);
	
	REP(i, n) {
		maxer[i] = a[i];
		miner[i] = a[i];
	}
	
	for (int i = n - 2; i >= 0; i--) maxer[i] = max(maxer[i + 1], maxer[i]);
	for (int i = 1; i < n; i++) miner[i] = min(miner[i - 1], miner[i]);
	
	int diff = 0;
	REP(i, n) diff = max(diff, maxer[i] - miner[i]);
	
	set<pii> s;
	REP(i, n) if (maxer[i] - miner[i] == diff) s.insert(pii(maxer[i], miner[i]));
	cout << s.size() << endl;
	
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi B(n-1);
  vi A(n);
  for(auto &a:B)cin>>a;
  A[0]=B[0];
  for(int i=1;i<n-1;i++){
    A[i]=min(B[i],B[i-1]);
  }
  A[n-1]=B[n-2];
  ll ans=0;
  for(auto a:A)ans+=a;
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    int k,s;
    cin >> k >> s;
    int ans = 0;
    rep(x,k+1) {
        if(x > s) break;
        if(s-x > 2*k) continue;
        int rem = s-x;
        if(rem > k) ans += k-(rem-k)+1;
        else ans += rem+1;
    }
    cout << ans << endl;
}

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		int x = Integer.parseInt(tmpArray[0]);
		int a = Integer.parseInt(tmpArray[1]);
		int b = Integer.parseInt(tmpArray[2]);
		
		int xa = Math.abs(x-a);
		int xb = Math.abs(x-b);
		
		if(xa < xb){
			System.out.println("A");
		}
		else {
			System.out.println("B");
		}
	}

}


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

int main(){
    int count[5][4][11];
    int n,b,f,r,v;

    for(int i=0;i<5;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<11;k++){
                count[i][j][k]=0;
            }
        }
    }

    cin >> n;
    for(int s=0;s<n;s++){
        cin >> b >> f >> r >> v;
        count[b][f][r]+=v;
    }

    for(int i=1;i<5;i++){
        if(i>1)  cout << "####################\n";
        for(int j=1;j<4;j++){
            for(int k=1;k<11;k++){
                cout <<" "<< count[i][j][k];
            }
            cout << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

int main(){
	int m, n, x, y;
	vector< complex< int > > c, s;
	
	while(cin >> m, m){
		c.RS(m);
		REP(i, m){
			cin >> x >> y;
			c[i] = complex< int >(x, y);
		}
		
		cin >> n;
		s.RS(n);
		REP(i, n){
			cin >> x >> y;
			s[i] = complex< int >(x, y);
		}
		
		REP(i, n){
			
			complex< int > d = s[i] - c[0];
			bool check = true;
			
			FOR(j, 1, m){
				bool check2 = false;
				REP(k, n){
					if(c[j] + d == s[k]){
						check2 = true;
						break;
					}
				}
				if(!check2){
					check = false;
					break;
				}
			}
			
			if(check){
				cout << d.real() << " " << d.imag() << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
int n,a[2][555],b[2][555],is[2][555],dd[555][555],ans[555][555];
void jh()
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<i;j++)
		{
			swap(dd[i][j],dd[j][i]);
		}
	}
}
bool sl()
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			dd[i][j]=-1;
		}
	}
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<n;j++)
		{
			int nw=is[i][j];
			if(a[i][j]!=nw)
			{
				for(int k=0;k<n;k++)
				{
					if(dd[j][k]==!nw)
					{
						return false;
					}
					dd[j][k]=nw;
				}
			}
		}
		jh();
	}
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<2;j++)
		{
			for(int k=0;k<n;k++)
			{
				int nw=is[j][k];
				if(a[j][k]==nw)
				{
					vector<int>vv;
					bool ok=false;
					for(int l=0;l<n;l++)
					{
						if(dd[k][l]==-1)
						{
							vv.push_back(l);
						}
						if(dd[k][l]==nw)
						{
							ok=true;
						}
					}
					if(ok)
					{
						continue;
					}
					if(vv.size()==0)
					{
						return false;
					}
					if(vv.size()==1)
					{
						dd[k][vv[0]]=nw;
					}
				}
			}
			jh();
		}
	}
	vector<int>v1,v2;
	for(int i=0;i<n;i++)
	{
		bool fl=true;
		for(int j=0;j<n;j++)
		{
			if(dd[i][j]==-1)
			{
				fl=false;
			}
		}
		if(!fl)
		{
			v1.push_back(i);
		}
	}
	for(int j=0;j<n;j++)
	{
		bool fl=true;
		for(int i=0;i<n;i++)
		{
			if(dd[i][j]==-1)
			{
				fl=false;
			}
		}
		if(!fl)
		{
			v2.push_back(j);
		}
	}
	for(int i=0;i<v1.size();i++)
	{
		for(int j=0;j<v2.size();j++)
		{
			dd[v1[i]][v2[j]]=(i+j)%2;
		}
	}
	return true;
}
signed main()
{
	cin>>n;
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>b[i][j];
		}
	}
	for(int bt=0;bt<64;bt++)
	{
		for(int i=0;i<2;i++)
		{
			for(int j=0;j<n;j++)
			{
				is[i][j]=b[i][j]>>bt&1;
			}
		}
		if(!sl())
		{
			cout<<-1<<endl;
			return 0;
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				ans[i][j]|=1LL*(dd[i][j])<<bt;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cout<<ans[i][j]<<' ';
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 9848
def main():
    n, m, x = map(int, input().split())
    book_list = [list(map(int, input().split())) for _ in range(n)]
    ans = 12 * 10 ** 5 + 1

    for i in range(2 ** n):
        money = 0
        level = [0] * m
        for j in range(n):
            if (i >> j) & 1:
                money += book_list[j][0]
                for k in range(m):
                    level[k] += book_list[j][k + 1]
        for j in range(m):
            if level[j] < x:
                break
        else:
            ans = min(ans, money)

    if ans == 12 * 10 ** 5 + 1:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73508
#include <bits/stdc++.h>
using namespace std;
queue <pair<int,int> > q;
int main() {
    int n,m;
    cin>>n>>m;
    char ch[n+1][m+1];
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            cin>>ch[i][j];
    int ans=0;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            if (ch[i][j]=='.') {
                int fix[n+1][m+1];
                for (int a=1;a<=n;a++)
                    for (int b=1;b<=m;b++)
                        fix[a][b]=-1;
                fix[i][j]=0;
                q.push({i,j});
                while (q.size()) {
                    int x=q.front().first;
                    int y=q.front().second;
                    q.pop();
                    if (x>1 && ch[x-1][y]=='.' && fix[x-1][y]==-1) {
                        fix[x-1][y]=fix[x][y]+1;
                        ans=max(ans,fix[x-1][y]);
                        q.push({x-1,y});
                    }
                    if (x<n && ch[x+1][y]=='.' && fix[x+1][y]==-1) {
                        fix[x+1][y]=fix[x][y]+1;
                        ans=max(ans,fix[x+1][y]);
                        q.push({x+1,y});
                    }
                    if (y>1 && ch[x][y-1]=='.' && fix[x][y-1]==-1) {
                        fix[x][y-1]=fix[x][y]+1;
                        ans=max(ans,fix[x][y-1]);
                        q.push({x,y-1});
                    }
                    if (y<m && ch[x][y+1]=='.' && fix[x][y+1]==-1) {
                        fix[x][y+1]=fix[x][y]+1;
                        ans=max(ans,fix[x][y+1]);
                        q.push({x,y+1});
                    }
                }
            }
    cout<<ans<<endl;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> h;
    int in;
    int max = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> in;
        h.emplace_back(in);
    }

    int cnt = 0;
    for (int i = 1; i <= *max_element(h.begin(), h.end()); i++)
    {
        if (h[0] >= i) cnt += 1;
        for (int j = 1; j < h.size(); j++)
        {
            if (h[j - 1] < i && h[j] >= i)
            {
                cnt += 1;
            }
            
        }
           
    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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 ll = long long;
const ll mod = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//


class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int n, a[21][21];
mint dp[22][1<<21];

int main(){
    cin>>n;
    rep(i,0,n) rep(j,0,n) cin>>a[i][j];

    dp[0][0]=1;
    rep(i,0,n) rep(msk,0,1<<n) if(i==__builtin_popcount(msk)){
        rep(j,0,n) if(!(msk&(1<<j))) if(a[i][j]){
            dp[i+1][msk|(1<<j)]+=dp[i][msk];
        }
    }
    cout<<dp[n][(1<<n)-1]<<endl;
}


Measured memory_bytes: 360704
numTest = int(input())

value = numTest % 10

if value == 2 or value == 4 or value == 5 or value == 7 or value == 9 :
	print('hon')
elif value == 0 or value == 1 or value == 6 or value == 8 :
	print('pon')
elif value == 3 :
	print('bon')

Measured memory_bytes: 9112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
vector<int> divisor (int n) {
    vector<int> ret;
    for (int i=1; i*i<=n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i*i != n) {
                ret.push_back(n/i);
            }
        }
    }
    sort(ret.rbegin(), ret.rend());
    return ret;
}

int main(void){
    int n;
    long long int k;
    cin >> n >> k;
    vector<int> vecA(n);
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        vecA[i] = a;
    }
    
    vector<int> divisors = divisor(accumulate(vecA.begin(), vecA.end(), 0));
    vector<int> vecRem(n);
    for (auto x : divisors) {
        int SOR = 0; //sum of remainder
        for (int i=0; i<n; i++) {
            vecRem[i]=(vecA[i] % x);
        }
        sort(vecRem.rbegin(), vecRem.rend());
        int sumPlus = accumulate(vecRem.begin(), vecRem.end(), 0);
        int sumMinnus = 0;
            // cout << x << ":" << sumMinnus << ":" << sumPlus << endl;
        for (auto y : vecRem) {
            if (sumPlus == sumMinnus && sumMinnus <= k){
                cout << x;
                return 0;
            }
            sumMinnus += x - y;
            sumPlus -= y;
            // cout << x << ":" << sumMinnus << ":" << sumPlus << endl;
        }
    }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, M = NMI()
    KS = [NLI() for _ in range(M)]
    P = NLI()
    
    ans = 0
    
    for m in range(M):
        for x in range(1,len(KS[m])):
            KS[m][x] -= 1

    bit_len = N
    for i in range(2**bit_len):
        switch = [0 for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                switch[j] = 1
        
        light = [0 for _ in range(M)]
        
        for m in range(M):
            cnt = 0
            for y in KS[m][1:]:
                if switch[y] == 1:
                    cnt += 1
            if cnt % 2 == P[m]:
                light[m] = 1
        
        if light.count(1) == M:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9220
import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args){
		long n = sc.nextLong();
		long k = sc.nextLong();
		long ans = 0L;
		
		long kMulNum = n / k;
		ans += kMulNum * kMulNum * kMulNum;
		
		if(k % 2L == 0L){
			long rHalfKNum = (k * kMulNum + k / 2 <= n) ? kMulNum : kMulNum - 1;
			ans += (rHalfKNum + 1) * (rHalfKNum + 1) * (rHalfKNum + 1);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	string s;
	cin >> s;
	rep(i,s.size())
		cout << (s[i] == ',' ? ' ' : s[i]);
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rrep(i, N) for (int i = (int)(N)-1; i >= 0; --i)
#define debug(x) cout << #x << "=" << x << endl;
constexpr int MOD=1000000007;
constexpr ll INF = (1LL << 61) - 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;}
template <typename T> void fail(T v){cout << v << endl;exit(0);}
//templte
const int P=1<<9;
int N;
int V[1<<18],W[1<<18],dp[P][100100];

void pre(int i){
    if (i >= P or i > N) return;
    int p = i >> 1;
    for (int j = 0; j < 100001; j++)
    {
        dp[i][j] = dp[p][j];
        if (j - W[i-1] >= 0) chmax(dp[i][j], dp[p][j - W[i-1]] + V[i-1]);
    }
    pre(i << 1);
    pre((i << 1) | 1);
}
void solve(){
    scanf("%d",&N);
    rep(i,N){
        scanf("%d %d",&V[i],&W[i]);
    }
    int Q;scanf("%d",&Q);
    pre(1);
    while(Q--){
        int i,l;
        scanf("%d %d",&i,&l);
        vector<int> s;
        int res=0;
        while(i>=P){
            s.push_back(i);i>>=1;
        }
        rep(j,1<<s.size()){
            int w=0,v=0;
            rep(k,s.size())if(1&j>>k){
                w+=W[s[k]-1];v+=V[s[k]-1];
                if(w>l)goto END;
            }
            chmax(res,v+dp[i][l-w]);

            END:;
        }
        printf("%d\n",res);
    }
}

int main()
{
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    solve();
    return 0;
}

Measured memory_bytes: 205624
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <math.h>
#include <numeric>

using namespace std;

typedef long long ll;
typedef long double ld;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int n = 0; n < N; ++n) {
        cin >> A[n];
    }
    
    set<ll, greater<ll>> Cand;
    for (int k = 0; k < 2; ++k) {
        ll Tmp = A[k];
        for (int i = 1; i * i <= Tmp; ++i) {
            if (Tmp%i == 0) {
                Cand.insert(i);
                Cand.insert(Tmp/i);
            }
        }
    }
    
    for (auto tmp : Cand) {
        int NG = 0;
        for (int n = 0; n < N; ++n) {
            if (A[n]%tmp != 0) {
                ++NG;
                if (NG >= 2) {
                    break;
                }
            }
        }
        if (NG <= 1) {
            cout << tmp << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1024
/*
 * ARC081_C.cpp
 *
 *  Created on: Jun 5, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int a[100000];

int pile[100000];

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

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

	sort(a, a+N, greater<int>());

	REP(i, N) {
		if(i==0 || a[i] != a[i-1]) {
			pile[i] = 1;
		}
		else {
			pile[i] = pile[i-1] + 1;
			pile[i-1] = 0;
		}
	}

	vector<lng> ans;
	REP(i, N) {
		if(pile[i] >= 2) {
			ans.pb(a[i]);
		}
		if(pile[i] >= 4) {
			ans.pb(a[i]);
		}
	}

	if(SZ(ans) < 2) cout << 0 << endl;
	else {
		cout << ans[0]*ans[1] << endl;
	}


}






Measured memory_bytes: 1660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()

	mai := N % 1000
	if mai == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1000 - mai)
	}

}


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

bool solve(string S){
  vector<string> A = {"maerd", "remaerd", "esare", "resare"};

  int L = S.length();
  reverse(S.begin(), S.begin()+L);

  while(S != ""){
    //cout << S << endl;
    if(S.length() < 5) return false;

    bool flag = true;
    for(int i=0; i<4; i++){
      if(S.substr(0, A[i].length()) == A[i]){
        S = S.substr(A[i].length());
        flag = false;
      }
    }
    if (flag) return false;
  }

  return true;
}

int main(){
  string S; cin >> S;

  if(solve(S)){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int a,b,c; cin>>a>>b>>c;
	int ans=0;
	for(int i=a;i<=b;i++){
		if(c%i==0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	string K = "keyence";
	string s;
	cin >> s;
	int n = s.size();
	bool ans = false;
	if (s == K)ans = true;
	rep(i, 0, n) {
		rep(j, 0, n - i) {
			string P="";
			rep(l,0,n){
				if (l < j || l > i + j)P.push_back(s[l]);
			}
			if (P == K)ans = true;
		}
	}
	YES(ans)
	return 0;
}

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

public class Program
{

	public void Proc()
	{
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int userCount = inpt[0];
        int connectionCount = inpt[1];
        for (int i = 0; i < connectionCount; i++) {
            inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            inpt.ToList().ForEach(a =>
            {
                if (!Conn.ContainsKey(a))
                {
                    Conn.Add(a, new List<int>());
                }
            });
            this.Conn[inpt[0]].Add(inpt[1]);
            this.Conn[inpt[1]].Add(inpt[0]);
        }
        this.Group = new int[userCount];
        SetDic();
        int queryCount = int.Parse(Reader.ReadLine());
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        for (int i = 0; i < queryCount; i++) {
            inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            if(this.Group[inpt[0]] == this.Group[inpt[1]]) {
                ans.AppendLine("yes");
            } else {
                ans.AppendLine("no");
            }
        }
        Console.Write(ans.ToString());
    }

    private void SetDic() {
        int grpNum = 1;
        for (int i = 0; i < this.Group.Length; i++) {
            if(this.Group[i] == 0) {
                this.SetDicSub(i, grpNum);
                grpNum++;
            }
        }
    }
    private void SetDicSub(int userId, int groupId) {
        Stack<int> stk = new Stack<int>();
        this.Group[userId] = groupId;
        stk.Push(userId);
        while(stk.Count>0) {
            int current = stk.Pop();
            if(!Conn.ContainsKey(current)) {
                continue;
            }
            foreach(int next in Conn[current]) {
                if(this.Group[next] == 0) {
                    this.Group[next] = groupId;
                    stk.Push(next);
                }
            }
        }
    }

    private int[] Group;

    private Dictionary<int, List<int>> Conn = new Dictionary<int, List<int>>();


	public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



10 5
0 1
1 2
2 9
3 4
6 7
12
0 1
0 2
0 9
3 4
6 7
7 6
0 5
0 6
3 7
3 5
5 8
8 5


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 28568
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int ok[213456], test[213456];
signed main() {
	int n, m, a, b, c, ans = 0; string s, t; cin >> s >> t;
	for (int h = 0; h < s.size(); h++) {
		if (ok[(int)s[h]] == 0) { ok[(int)s[h]] = (int)t[h]; }
		else if (ok[(int)s[h]] != (int)t[h]) { cout << "No" << endl; return 0; }
		if (test[(int)t[h]] == 0) { test[(int)t[h]] = (int)s[h]; }
		else if (test[(int)t[h]] != (int)s[h]) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	char poke[6][6]={{"abcde"},{"fghij"},{"klmno"},{"pqrst"},{"uvwxy"},{"z.?! "}};
	while(cin>>str){
		if(str.size()%2!=0)cout<<"NA"<<endl;
		else {
			string ans;
			bool kawa=0;
			for(int i=1;i<str.size();i+=2){
				if(str[i-1]-'1'<0||str[i-1]-'1'>5||str[i]-'1'<0||str[i]-'1'>4){
					kawa=1;
					break;
				}
				else ans+=poke[str[i-1]-'1'][str[i]-'1'];
			}
			if(kawa)cout<<"NA"<<endl;
			else cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1188
<?php
fscanf(STDIN, "%d %d", $N, $X);
$L = explode(' ', trim(fgets(STDIN)));
$Ls = [];
foreach ($L as $v) {
 $Ls[] = (int) $v;
}
// var_dump($Ls);
$ans = 1;
$sum = 0;
for ($i = 0; $i < $N; $i++) {
 $sum += $Ls[$i];
//  echo $sum . "\n";
 if ($sum <= $X) {
  $ans++;
 }
}
echo $ans;


Measured memory_bytes: 4604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int d,n;
		d = sc.nextInt();
		n = sc.nextInt();

		if(n == 100)
			n = 101;
		if(d == 0){
			System.out.println(n);
		}
		if(d == 1)
				System.out.println(n*100);
		if(d == 2)
			System.out.println(n *10000);
		}
	
	}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  int Nkai,Mkai;
cin >> N >> M;
  Nkai = N*(N-1);
  Mkai = M*(M-1);
  cout << Nkai/2 + Mkai/2;
  
  

}

Measured memory_bytes: 256
import java.util.Scanner;

//0305
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            int r = sc.nextInt();
            int t = sc.nextInt();
            String a = "";
            for (int y = 0; y < ( t % 30 > 0 ? 2 : 1); y++) {
                for (int x = 0; x < (r % 100 > 0 ? 2 : 1); x++) {
                    if ((x | y) == 1) {
                        a += " ";
                    }
                    a += (t / 30 + y) * 5 + r / 100 + x;
                }
            }
            System.out.println(a);
        }
    }
}


Measured memory_bytes: 26532
n = int(input())
if n == 1:
    print('! 1')
    exit()
elif n == 2:
    print('! 1 2')
    exit()

print('? 1 2')
m = int(input())
d = []

for i in range(3,n+1):
    print('? 1',i)
    p = int(input())
    print('? 2',i)
    q = int(input())
    d.append((p+q,p,q,i))

d = sorted(d)[::-1]
left = []
right = []
i = 0

flag = True
for i in range(len(d)):
    p = d[i][1]
    q = d[i][2]
    j = d[i][3]
    if d[i][0] <= m:
        if flag:
            right.append(2)
            flag = False
        right.append(j)
        continue
    if q > p:
        left.append(j)
    else:
        right.append(j)
if flag:
    right.append(2)

ans = left + [1] + right[::-1]

print('!',' '.join([str(u) for u in ans]))


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

//---------------------------------------------------------------

int main(){
  ll N,K,ans;
  cin>>N>>K;
  ans = 1;
  while(N>K-1){
    ans++;
    N/=K;
  }

  cout<<ans<<endl;

}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a;

    a.emplace_back(3);
    a.emplace_back(5);
    a.emplace_back(7);
    int count=0;

    while(true) {
        vector<int> oa;
        swap(oa,a);
        for(int x = 0; x < oa.size(); x++) {
            for(int i = 0; i < 3; i++) {
                int tmp=oa[x]*10+3+2*i;
                a.emplace_back(tmp);
                if(tmp>n){
                    cout << count << "\n";
                    return 0;
                }
                bool tj=false;
                bool fj=false;
                bool sj=false;
                bool wj=true;
                int tfj=tmp;
                while(tfj>0) {
                    int d=tfj%10;
                    if(d==3)      tj=true;
                    else if(d==5) fj=true;
                    else if(d==7) sj=true;
                    else          wj=false;
                    tfj/=10;
                }
                if(tj*fj*sj*wj) count++;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){


int W,H,x,y,r;


scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);


if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){


printf("Yes\n");


}


else{


printf("No\n");


}


return 0;


}

Measured memory_bytes: 584