akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

#pragma region remove(vector, index)
template<typename T>
void remove(vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<pair<int, int>> a(n), b(n);
	rep(i, 0, n - 1)
	{
		cin >> a[i].second >> a[i].first;
	}
	rep(i, 0, n - 1)cin >> b[i].first >> b[i].second;
	sort(all(a));
	reverse(all(a));
	sort(all(b));
	int ans = 0;
	rep(i, 0, n - 1)
	{
		int x = b[i].first, y = b[i].second;
		rep(j, 0, a.size() - 1)
		{
			if (x > a[j].second && y > a[j].first)
			{
				++ans;
				remove(a, j);
				break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static class Tree {
		public class Edge {
			int to, rev;

			public Edge(int to, int rev) {
				this.to = to;
				this.rev = rev;
			}
		}
		
		int V;
		ArrayList<ArrayList<Edge>> G;
		int root;
		int[] p;
		
		public Tree(int[] a, int[] b) {
			this.V = a.length+1;
			p = new int[V];
			
			G = new ArrayList<ArrayList<Edge>>();
			for(int i=0; i<V; i++) {
				G.add(new ArrayList<Edge>());
			}
			
			for(int i=0; i<V-1; i++) {
				G.get(a[i]).add(new Edge(b[i], G.get(b[i]).size()));
				G.get(b[i]).add(new Edge(a[i], G.get(a[i]).size()-1));
			}
			setRoot(0);
		}
		
		public void setRoot(int root) {
			this.root = root;
			setRoot(root, -1);
		}
		public void setRoot(int cur, int parent) {
			p[cur] = parent;
			for(int i=0; i<G.get(cur).size(); i++) {
				int next = G.get(cur).get(i).to;
				if(next!=parent) {
					setRoot(next, cur);
				}
			}
		}
		public int countPath() {
			int ans = 0;
			for(ArrayList<Edge> node : G) {
				ans += node.size()%2;
			}
			return ans/2;
		}
		
		public boolean check(int B) {
			if(G.get(root).size()%2==0)
				return dp(root, B)==0;
			else
				return dp(root, B)<=B;
		}
		
		int dp(int cur, int B) {
			ArrayList<Integer> dp = new ArrayList<>();
			for(int i=0; i<G.get(cur).size(); i++) {
				int next = G.get(cur).get(i).to;
				if(next!=p[cur]) {
					dp.add(dp(next, B)+1);
				}
			}
			Collections.sort(dp);
			if(dp.size()>0 && dp.get(dp.size()-1)>B)
				return B+1;

			if(dp.size()%2==0) {
				if(validatePairing(dp, B, -1)) {
					return 0;
				} else {
					dp.remove(dp.size()-1);
					return leaveShortestPath(dp, B);
				}
			} else {
				return leaveShortestPath(dp, B);
			}
		}
		
		int leaveShortestPath(ArrayList<Integer> v, int B) {
			int N = v.size();
			int min = -1;
			int max = N;
			while(min+1<max) {
				int skip = (min+max)/2;
				if(validatePairing(v, B, skip))
					max = skip;
				else
					min = skip;
			}
			if(max<N)
				return v.get(max);
			else
				return B+1;
		}
		
		boolean validatePairing(ArrayList<Integer> v, int B, int skip) {
			for(int i=0,j=v.size()-1; i<j; i++,j--) {
				if(i==skip)
					i++;
				if(j==skip)
					j--;
				if(v.get(i) + v.get(j) > B)
					return false;
			}
			
			return true;
		}
	}
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N-1];
		int[] b = new int[N-1];
		for(int i=0; i<N-1; i++) {
			a[i] = sc.nextInt()-1;
			b[i] = sc.nextInt()-1;
		}
		Tree tree = new Tree(a, b);
		
		int A = tree.countPath();
		int min = 0;
		int max = N-1;
		while(min+1 < max) {
			int mid = (min+max)/2;
			if(tree.check(mid))
				max = mid;
			else
				min = mid;
		}
		
		System.out.println(A + " " + max);
		sc.close();
	}
}


Measured memory_bytes: 139800
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	char S[200010];
	fread(S, 1, 200010, stdin);

	int L = 0, R = 200000;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (S[M] >= '?') L = M;
		else R = M;
	}

	int r = R / 8 * 8;
	ll* kaki = (ll*)S;
	for (char* ci = S; ci < S + r; ci += 8) {
		ll tmp = *((ll*)ci);
		tmp += 0x0303030303030303;
		tmp ^= 0x0101010101010101;
		tmp += 0x0101010101010101;
		tmp &= 0xfcfcfcfcfcfcfcfc;
		*kaki++ = tmp;
	}
	for (int i = r; i < R; i++) {
		if (S[i] == '?') S[i] = 'D';
	}
	fwrite(S, 1, R, stdout);

	Would you please return 0;
}

Measured memory_bytes: 1724
def main():
	s = input()
	ans = solve(s[0], s[1:])
	print(ans)

def solve(left, right):
	if len(right) == 0:
		return eval(left)
	return solve(left + right[0], right[1:]) + solve(left + '+' + right[0], right[1:])

if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
import fractions
A,B,C,D=map(int,input().split())
A=A-1
AS=A//(C*D//fractions.gcd(C,D))
BS=B//(C*D//fractions.gcd(C,D))
AC=A//C
AD=A//D
BC=B//C
BD=B//D
print(B-A-(BC+BD-BS)+(AC+AD-AS))

Measured memory_bytes: 5304
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;

template<class T1, class T2> inline int chkmin(T1 &x, const T2 &y) {
    if (x > y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T1, class T2> inline int chkmax(T1 &x, const T2 &y) {
    if (x < y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define mp make_pair
#define pb push_back
#define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout);

template<class iterator> void output(iterator begin, iterator end, ostream &out = cerr) {
    while (begin != end) {
        out << (*begin) << " ";
        begin++;
    }
    out << endl;
}

template<class T> void output(const T &x, ostream &out = cerr) {
    output(x.begin(), x.end(), out);
}

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
}

const int MAXN = 100228;


int n, m;
bool used[MAXN];
int deg[MAXN];
vector<int> g[MAXN];
int deep[MAXN];


void dfs(int u, int pr = -1) {
    used[u] = true;
    for (auto h: g[u]) {
        if (!used[h]) {
            deep[h] = deep[u] + 1;
            dfs(h, u);
        } else {
            if (h != pr && deep[h] < deep[u]) {
                deg[h]++;
                cout << h << ' ' << u << '\n';
            }
        }
    }
    if (deg[u] % 2 == 1) {
        cout << u << ' ' << pr << '\n';
        deg[u]++;
    } else {
        if (pr != -1) {
            cout << pr << ' ' << u << '\n';
            deg[pr]++;
        }
    }
}


int main() {
    fast_io();
    //read("input");
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    if (m % 2 == 1) {
        cout << -1 << endl;
        exit(0);
    }
    dfs(1, -1);
    return 0;
}   
    

Measured memory_bytes: 14080
import java.util.*;
import java.util.stream.*;

class Main{
  static int sum(int[] arr){
    int n = IntStream.of(arr).sum();
    int min = Integer.MAX_VALUE;
    for(int i:arr){
      if(n-i<min){
        min = n-i;
      }
    }
    return min;
  }
  public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int[] arr = new int[3];
    	for(int i=0;i<3;i++){
          arr[i] = scan.nextInt();
        }
    System.out.println(sum(arr));
  }}

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

int ret[10][110];
int main(){
  ret[0][0]=1;
  for(int i=9;i>=0;i--){
    for(int j=8;j>=0;j--){
      for(int k=0;k<100;k++){
        if(i+k<=100) ret[j+1][i+k] +=ret[j][k];
      }
    }
  }
  int n,s;
  while(true){
    cin>>n>>s;
    if(n==0) return 0;
    cout<<ret[n][s]<<endl;
  }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, x, sum = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x < K - x) {
      sum += x * 2;
    } else {
      sum += (K - x) * 2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>

using namespace std;

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

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const int PI = acos(-1);
const int INF = numeric_limits<int>::infinity() / 2;
const ll INFLL = numeric_limits<ll>::infinity() / 2;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X, Y;
  cin >> X >> Y;
  cout << (X % Y == 0 ? -1 : X) << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    n = input()
    
    if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9':
        print('hon')
    elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
        print('pon')
    elif n[-1] == '3':
        print('bon')


if __name__ == '__main__':
    main()


Measured memory_bytes: 61692
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

struct edge{int to,cost;};
vector<int> G[100005];
 
ll n,m,ans=0;
ll i,j;
ll a[100005];
ll x,num;
char s[14],t[14];

int main(){
	cin>>s;
	n=strlen(s);
	for(i=0;i<n-1;i++){
		if(s[i]!=s[i+1])ans+=1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair



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

    double r; cin>>r;
    cout<<2*M_PI*r;

}


Measured memory_bytes: 3804
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class SegmentTree():
    '''
    RMQ　の実装
    '''

    def __init__(self, n, inf=float('inf')):
        '''
        木の高さhとすると,
        n:h-1までのノード数。h段目のノードにアクセスするために使う。
        data:ノード。
        parent:k->child k*2+1とk*2+2
        '''
        self.n = 2**(n-1).bit_length()
        self.inf = inf
        self.data = [inf]*(2*self.n)

    def set(self, k, v):
        '''
        あたいの初期化
        '''
        self.data[k+self.n-1] = v

    def build(self):
        for k in reversed(range(self.n-1)):
            self.data[k] = gcd(self.data[k*2+1], self.data[k*2+2])

    def update(self, k, a):
        '''
        list[k]=aに更新する。
        更新ぶんをrootまで更新
        '''
        k += self.n-1
        self.data[k] = a

        while k > 0:
            k = (k-1)//2
            self.data[k] = gcd(self.data[k*2+1], self.data[k*2+2])

    def query(self, l, r):
        '''
        [l,r)のminを求める
        '''
        L = l+self.n
        R = r+self.n
        ret = self.inf
        while L < R:
            if R & 1:
                R -= 1
                ret = gcd(ret, self.data[R-1])
            if L & 1:
                ret = gcd(ret, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return ret


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


N = int(input())
L = list(map(int, input().split()))
T = SegmentTree(N, 0)
for i, l in enumerate(L):
    T.set(i, l)
T.build()

ans = 0
for i in range(N):
    l = i
    r = i+1
    ans = max(ans, gcd(T.query(0, l), T.query(r, N)))
print(ans)


Measured memory_bytes: 14200
#include <iostream>
 
int main()
{
  int N;
  std::cin >> N;
  int d;
  long int sum=0, sq_sum=0;
  for (int i=0; i<N; i++){
    std::cin >> d;
    sum += d;
    sq_sum += d * d;
  }
  
  std::cout << ((sum * sum - sq_sum) / 2);
  
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
n,m=map(int,input().split())
d={i+1:[] for i in range(n)}
for i in range(m):
    x,y=map(int,input().split())
    d[x].append(y)
    d[y].append(x)
 
visit=set()
ans= 0 
for i in range(1,n+1):
    if i not in visit:
        ans+=1
        stack = [i]
        while stack:
            c=stack.pop()
            visit.add(c)
            for i in d[c]:
                if i not in visit:
                    stack.append(i)
print(ans-1)

Measured memory_bytes: 96952
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int H, W;
	cin >> H >> W;
	vector<string> S;
	for (int i = 0; i < H; i++) {
		string temp;
		cin >> temp;
		S.emplace_back(temp);
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {

			if (S[i][j] == '#') {
				int count = 0;
				for (int k = 0; k < 4; k++) {
					if (0 <= i + DX[k] && i + DX[k] < H && 0 <= j + DY[k] && j + DY[k] < W) {
						if (S[i + DX[k]][j + DY[k]] == '#') {
							count++;
						}
					}
				}

				if (count == 0) {
					cout << "No";
					return 0;
				}
			}


		}
	}



	cout << "Yes";








}	


Measured memory_bytes: 256
k = int(input())
isono = [input() for _ in range(k)]
nakajima = [input() for _ in range(k)]
isono_power = 0
nakajima_power = 0
for isono_hand, nakajima_hand in zip(isono, nakajima):
  if isono_hand == "mamoru":
    if nakajima_hand == "mamoru":pass
    elif nakajima_hand == "tameru":nakajima_power = min(nakajima_power + 1, 5)
    elif nakajima_hand == "kougekida":
      if nakajima_power <= 0:print("Isono-kun");break
      elif nakajima_power > 5 :print("Nakajima-kun");break
      elif nakajima_power <= 4:nakajima_power = 0
  
  elif isono_hand == "tameru":
    isono_power = min(5, isono_power + 1)
    if nakajima_hand == "mamoru":pass
    elif nakajima_hand == "tameru":nakajima_power = min(nakajima_power + 1, 5)
    elif nakajima_hand == "kougekida":
      if nakajima_power <= 0:print("Isono-kun");break
      else:print("Nakajima-kun");break

  if isono_hand == "kougekida":
    if nakajima_hand == "mamoru":
      if isono_power <= 0:print("Nakajima-kun");break
      elif isono_power >= 5:print("Isono-kun");break
      else:isono_power = 0
    elif nakajima_hand == "tameru":
      if isono_power <= 0:print("Nakajima-kun");break
      else:print("Isono-kun");break
    elif nakajima_hand == "kougekida":
      if isono_power == nakajima_power:isono_power = nakajima_power = 0
      elif isono_power < nakajima_power:print("Nakajima-kun");break
      elif isono_power > nakajima_power:print("Isono-kun");break
else:
  print("Hikiwake-kun")


Measured memory_bytes: 5616
class Main {
    public static void main(String[] args) {
        java.util.Scanner sc = new java.util.Scanner(System.in);

        final int N = sc.nextInt();
        final int L = sc.nextInt();

        int output = 0;

        if (-1 <= L - 1) {
            output -= L;
        } else if (L - 1 <= -N) {
            output -= L + N - 1;
        }

        output += N * (L - 1) + N * (N + 1) / 2;

        System.out.println(output);
    }
}

Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int N, M;
int main() {
	scanf("%d%d", &N, &M);
	printf("%d", N*(N - 1) / 2 + M*(M-1)/2);
	return 0;
}

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

using namespace std;

typedef long long ll;

const int M = (int) 1e9 + 7;

int add(int a, int b) {
        a += b;
        if (a >= M)
                a -= M;
        if (a < 0)
                a += M;
        return a;
}

int mul(int a, int b) {
        return a * (ll) b % M;
}

int n, k;
int func(int i) {
        return n / (n / i);
}

const int N = (int) 1e5 + 7;
int dp[2][N];
int sum[N];

int get_sum(int l, int r) {
        if (l == 0)
                return sum[r];
        return sum[r] - sum[l - 1];
}

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

        cin >> n >> k;
        vector <int> a;
        vector <int> b;
        int i = 1;
        while (i <= n) {
                int j = func(i);
                a.push_back(i);
                b.push_back(j);
                i = j + 1;
        }

        int sz = (int) a.size();
        for (int i = 0; i < sz; i++) {
                int l = a[i], r = b[i];
                dp[1][i] = (r - l + 1);
        }

        for (int ln = 2; ln <= k; ln++) {
                int now = ln % 2, last = 1 - now;
                int cur = 0;
                for (int i = 0; i < sz; i++) {
                        cur = add(cur, dp[last][i]);
                        sum[i] = cur;
                }
                for (int i = 0; i < sz; i++) {
                        int l = a[i], r = b[i];
                        dp[now][i] = mul(r - l + 1, sum[sz - i - 1]);
                }
        }

        int res = 0, cur = k % 2;
        for (int i = 0; i < sz; i++)
                res = add(res, dp[cur][i]);
        cout << res << "\n";

        return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	map<string, int> mp;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	int MAX = 0;
	for (auto p : mp) {
		MAX = max(MAX, p.second);
	}
	for (auto p : mp) {
		if (p.second != MAX) continue;
		cout << p.first << endl;
	}
	return(0);
}

Measured memory_bytes: 27136
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
using ll = long long int;
int main() {
  int n;
  bool b=false;
  cin >>n;
  vector<char> s(n);
  for (int i=0;i<n;i++) cin >>s.at(i);
	for (int i=0;i<n;i++) {
	  if (s.at(i) == 'Y') b=true;
	}
	if(b) cout<<"Four";
	else cout<<"Three";
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  int n, k;
  cin >> n >> k;
  set<int> d;
  REP(i, k) { int tmp; cin >> tmp; d.insert(tmp); }
  int res = 0;
  for(int target=n; ;target++){
    if(res!=0) break;
    int tmpres=target;
    while(target>0){
      int tmp=target%10;
      auto it = d.find(tmp);
      if(it!=d.end()) break;
      target /= 10;
      if(target==0) res=tmpres;
    }
    target=tmpres;
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1e9;

void print(vector<int> &A) {
	for (int i = 0; i < A.size(); i++)
		printf("%d ", A[i]);
	printf("\n");
}

void print_matrix(vector< vector<int> > &m) {
	for (int i = 0; i < m.size(); i++)
		print(m[i]);
}

void input(vi &a, vi &b, vvi &c, int N, int M) {
	a = vi(M);
	b = vi(M);
	c = vvi(M);
	for (int m = 0; m < M; m++) {
		scanf("%d %d", &a[m], &b[m]);

		c[m] = vi(b[m]);
		for (int i = 0; i < b[m]; i++) {
			int key;
			scanf("%d", &key);
			c[m][i] = key - 1;
		}
	}
}

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

	vi a;
	vi b;
	vvi c;
	input(a, b, c, N, M);

	vi dp(1 << N, inf);
	dp[0] = 0;
	for (int m = 0; m < M; m++) {
		int curr = 0;
		for (int i = 0; i < b[m]; i++)
			curr |= (1 << c[m][i]);

		for (int bits = 0; bits < (1 << N); bits++)
			dp[bits | curr] = min(dp[bits | curr], dp[bits] + a[m]);
	}

	if (dp[(1 << N) - 1] == inf )
		dp[(1 << N) - 1] = -1;

	cout << dp[(1 << N) - 1] << endl;

	// print(dp);

	return 0;
}

Measured memory_bytes: 384
n=int(input())
a=input()
b=input()
c=input()
cnt=0
for i in range(n):
    if(a[i]!=b[i] and b[i]!=c[i] and a[i]!=c[i]):
        cnt+=2
    elif(a[i]==b[i] and a[i]==c[i] and b[i]==c[i]):
        continue
    else:
        cnt+=1
print(cnt)     

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
using namespace std;
long double p[3000];
long double dp[3000][3000];
int main() {
	int N; cin >> N;
	for (int i = 1; i <= N; i++) cin >> p[i];
	dp[0][0] = 1;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; i + j <= N; j++) {
			if (i > 0) dp[i][j] += dp[i - 1][j] * p[i + j];
			if (j > 0) dp[i][j] += dp[i][j - 1] * (1. - p[i + j]);
		}
	}
	long double pb = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j < i; j++) {
			if (i + j == N) pb += dp[i][j];
		}
	}
	cout.precision(10);
	cout << fixed << pb << endl;
}


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

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

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,d;
    cin >> h >> w >> d;
    int a[h*w];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            int tmp;
            cin >> tmp;
            tmp--;
            a[tmp]=i*w+j;
        }
    }
    int q;
    cin >> q;
    int l[q],r[q];
    for(int i = 0; i < q; i++) {
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }

    vector<int> cost(h*w+5,0);
    for(int i = d; i <= h*w; i++) {
        int pc=a[i-d]%w;
        int pr=a[i-d]/w;
        int nc=a[i]%w;
        int nr=a[i]/w;
        int tc=(abs(pc-nc)+abs(pr-nr));
        cost[i]=cost[i-d]+tc;
    }

    for(int i = 0; i < q; i++) {
        cout << cost[r[i]]-cost[l[i]] << "\n";
    }

    return 0;
}

Measured memory_bytes: 4788
def merge(A,left,mid,right):
    n1=mid-left
    n2=right-mid
    L = A[left:mid]
    R = A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    """
    L=[0]*(n1+1)
    R=[0]*(n2+1)
    for i in range(n1):
        L[i]=A[left+i]
    for i in range(n2):
        R[i]=A[mid+i]
    L[n1]=float("inf")
    R[n2]=float("inf")
    """
    i=0
    j=0
    for k in range(left,right):
        global cnt
        cnt+=1
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1

def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=list(input().split())
for i in range(n):
    S[i]=int(S[i])
cnt=0
mergeSort(S,0,n)
for i in range(n):
    if i==n-1:
        print(S[i])
    else:
        print(S[i],end=" ")
print(cnt)



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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int v[100001][4]={0},n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    int t=0,x=0,y=0;
    for(int i=0;i<n;i++){
        int dis=abs(x-v[i][1])+abs(y-v[i][2]);
        if(dis==(v[i][0]-t)){
            t=v[i][0];
            x=v[i][1];
            y=v[i][2];
        }else if(dis>(v[i][0]-t)){
            cout<<"No"<<endl;
            return 0;
        }else if(dis<(v[i][0]-t)){
            if(((v[i][0]-t)-dis)%2==0){
                t=v[i][0];
                x=v[i][1];
                y=v[i][2];
            }else{
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

namespace P0013_SwitchingRailroadCars
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> lines = new List<string>();
            string readLine;

            do
            {
                readLine = Console.ReadLine();
                if (readLine != null)
                {
                    lines.Add(readLine);
                }
            }
            while (readLine != null);

            List<string> rail = new List<string>();

            foreach (string line in lines)
            {

                if (line == "0")
                {
                    Console.WriteLine(rail[0]);
                    rail.RemoveAt(0);
                }
                else 
                {
                    rail.Insert(0, line);
                }

            }

        }

    }
}

Measured memory_bytes: 5392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

//Atcoder用


/*
 * BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] abc = br.readLine().split(" ");
		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);
 */
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		List<String> sir = new ArrayList<String>();
		boolean isCorrect = true;
		String lastWord="";
		for(int n=0;n<N;n++){
			String word = br.readLine();
			String[] chr = word.split("");

			if(n==0)lastWord = chr[chr.length-1];
			else{
				if(!lastWord.equals(chr[0])){
					isCorrect = false;
					//System.out.println("lastword");
					break;
				}else{
					if(sir.contains(word)){
						isCorrect = false;
						//System.out.println("sameword");
						break;
					}
					sir.add(word);
					lastWord = chr[chr.length-1];
				}
			}

			sir.add(word);
		}
		if(isCorrect)System.out.println("Yes");
		else System.out.println("No");


	}

}

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

int main() {
  int N; cin >> N;
  bool isnine = false;
  if (N % 10 == 9) {
    isnine = true;
  }
  if (N / 10 == 9) {
    isnine = true;
  }
  if (isnine) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

using Data = tuple<int, int, int, int>;

int main() {
    int H, W;
    cin >> H >> W;
    vector2d<int> a(H, vector<int>(W, 0));
    for(auto &r : a) {
        for(auto &x : r) {
            cin >> x;
        }
    }
    vector<Data> ans;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W - 1; j++) {
            if(a[i][j] & 1) {
                ans.push_back(make_tuple(i + 1, j + 1, i + 1, j + 2));
                a[i][j + 1]++;
            }
        }
    }
    for(int i = 0; i < H - 1; i++) {
        if(a[i][W - 1] & 1) {
            ans.push_back(make_tuple(i + 1, W, i + 2, W));
            a[i + 1][W - 1]++;
        }
    }
    cout << ans.size() << endl;
    for(auto &x : ans) {
        cout << x << endl;
    }
    return 0;
}

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

int main(){
  
 long long int n,a,b;
  
  cin>>n>>a>>b;
  
 long long d=b-a;
  
  if(d%2==0){
  cout<<d/2;
  }
  else{
    cout<<(d/2+1+min(a-1,n-b));
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
/**==Info==
*Program:1
*Problem:すぬけ君の地下鉄旅行 / Snuke's Subway Trip
*Date:2018-7-14
*Algorithm:BFS Tourist's
*Stats:Unknown*/

bool debug=false;



template<typename T> struct undispose_queue{
	vector<T> v;
	int s;
	
	undispose_queue(){
		s=0;
		v.clear();
	}
	
	void push(T value){
		v.push_back(value);
	}
	void pop(){
		s++;
	}
	
	T front(){
		return v[s];
	}
	
	void clear(){
		v.clear();
		s=0;
	}
	
	bool empty(){
		return s==v.size();
	}
	
	int size(){
		return v.size()-s;
	}
	
	vector<T> getData(){
		return v;
	}
};

const int A=2e6+1;
const int B=2e5+1;
int n,m;

map<int,vector<int>> nei[B];

int col[B];

set<int> cols;
vector<int> on[A];

vector<int> nnei[A];

int dis[A];

int main(int argc,char* argv[]){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;b--;
		nei[a][c].push_back(b);
		nei[b][c].push_back(a);
		on[c].push_back(a);
		on[c].push_back(b);
		cols.insert(c);
	}
	
	if(debug)cout<<"ok"<<endl;
	
	memset(col,-1,sizeof(col));
	
	int stpos=n;
	
	for(set<int>::iterator it=cols.begin();it!=cols.end();it++){
		int thscol=*it;
		if(debug)cout<<thscol<<endl;
		
		for(int i=0;i<on[thscol].size();i++){
			int thspos=on[thscol][i];
			if(col[thspos]==thscol){
				continue; //In the same block
			}
			
			undispose_queue<int> uq;
			col[thspos]=thscol;
			uq.push(thspos);
			
			while(!uq.empty()){
				
				int last=uq.front();
				uq.pop();
				
				for(int j=0;j<nei[last][thscol].size();j++){
					int nxtpos=nei[last][thscol][j];
					if(col[nxtpos]!=thscol){
						col[nxtpos]=thscol;
						uq.push(nxtpos);
					}
				}
			}
			
			vector<int> v=uq.getData();
			
			for(int j=0;j<v.size();j++){
				nnei[v[j]].push_back(stpos);
				nnei[stpos].push_back(v[j]);
				
				if(debug)cout<<"connected "<<v[j]<<" and "<<stpos<<endl;
			}
			
			stpos++;
		}
		
	}
	
	
	if(debug)cout<<"bfs"<<endl;
	
	queue<int> q;
	
	fill(dis,dis+A,-2);
	dis[0]=0;
	q.push(0);
	while(!q.empty()){
		int last=q.front();
		q.pop();
		
		for(int i=0;i<nnei[last].size();i++){
			if(dis[nnei[last][i]]==-2){
				dis[nnei[last][i]]=dis[last]+1;
				q.push(nnei[last][i]);
			}
		}
	}
	
	cout<<dis[n-1]/2;
	return 0;
}



Measured memory_bytes: 180224
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int a, b,ans;
    cin >> a >> b;
    ans = a + b;
    if (ans % 2 == 0)cout << ans / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

char S[101010];

int main() {
	scanf("%s",S);

	bool app[26];
	for (int i = 0; i < 26; ++i) {
		app[i] = false;
	}
	for (int i = 0; S[i] != '\0'; ++i) {
		app[S[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	puts("None");
  
	return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int a, b; std::cin >> a >> b;
  int mi = min(a, b), ma = max(a, b);
  rep(i, ma) std::cout << mi;
  std::cout << "\n";
}


Measured memory_bytes: 256
from math import gcd, sqrt, cos, radians, pi
from collections import defaultdict as d

n = int(input())
tab = list(map(int, input().split()))
S = sum(tab)
dico = d(int)
for i in tab:
	dico[i] += 1
q = int(input())
for i in range(q):
	b, c = map(int, input().split())
	s = S - (b * dico[b]) + (c * dico[b])
	dico[c] += dico[b]
	dico[b] = 0
	S = s
	print(S)

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

const int N = 2e5 + 233;

int n, tot, qwq; std::pair<int, int> ans[N];

int main() {
  std::cin >> n;
  for (int i = 0; i < 30; ++i)
    if (n == (1 << i)) {
      puts("No"); return 0;
    }
  puts("Yes");
  qwq = n & 1 ? n : n - 1;
  /*
  ans[1] = { 1, 2 };
  ans[2] = { 2, 3 };
  ans[3] = { 1, n + 3 };
  ans[4] = { n + 2, n + 3 };
  ans[5] = { n + 1, n + 2 };
  */
  ans[1] = { 1, 2 };
  ans[2] = { 2, n + 3 };
  ans[3] = { 1, 3 };
  ans[4] = { 3, n + 2 };
  ans[5] = { n + 2, n + 1 };
  tot = 5;
  for (int i = 4; i <= qwq; i += 2) {
    ans[++tot] = { 1, i };
    ans[++tot] = { i, n + i + 1 };
    ans[++tot] = { 1, i + 1 };
    ans[++tot] = { i + 1, n + i };
  }
  if (qwq != n) {
    /*
    qwq = n ^ 1; int qaq = (n & -n) ^ 1;
    ans[++tot] = { qaq + n, n };
    ans[++tot] = { qwq ^ qaq, n * 2 };
    */
    for (int i = 2; i < n; ++i) {
      int j = n ^ i ^ 1;
      if (j >= 2 && j < n) {
        ans[++tot] = { i, n };
        ans[++tot] = { j, n * 2 };
        break;
      }
    }
  }
  for (int i = 1; i <= tot; ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}


Measured memory_bytes: 3840
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
		int n = sc.nextInt();
		if(n == 0) break;
		boolean[] taro = new boolean[2*n+1], hanako = new boolean[2*n+1];
		fill(hanako, true);
		hanako[0] = false;
		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			taro[a] = true; hanako[a] = false;
		}
		
		int t = n, h = n, v = 0;
		int tp = 0, hp = 0;
		boolean isTaro = true;
		for(;t>0 && h>0;) {
			int i = v + 1;
			if(isTaro) {
				for(;i<=2*n;i++) if(taro[i]) {
					taro[i] = false;
					v = i;
					isTaro ^= true;
					t--;
					break;
				}
			}
			else {
				for(;i<=2*n;i++) if(hanako[i]) {
					hanako[i] = false;
					v = i;
					isTaro ^= true;
					h--;
					break;
				}
			}
			if(i == 2*n+1) {
				isTaro ^= true;
				v = 0;
			}
		}
		System.out.println(h);
		System.out.println(t);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20424
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 2e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll n, k, a[N];

void solve()
{
    cin >> n >> k;
    for (int i=0; i<n; ++i) cin >> a[i];
    for (int i=k; i<n; ++i) {
        if (a[i]>a[i-k]) nout("Yes");
        else nout("No");
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5256
n = int(input())
t=x=y=0
ans = 'Yes'
for _ in range(n):
    nt, nx, ny = map(int, input().split())
    dis = abs(nx - x) + abs(ny - y)
    time = nt - t
    if dis <= time and dis%2 == time%2:
        t = nt
        x, y = nx, ny
        continue
    else:
        ans = 'No'
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
	x*=p;
}
int n,k;
int ban[10];
bool ok(int x)
{
	int sum=x;
	while(sum) { if(ban[sum%10])return false; sum/=10; }
	return true;
}
int main()
{
	read(n);read(k);
	for(int i=1;i<=k;i++) { static int x; read(x);ban[x]=1; }
	for(int i=n;i;i++)
		if(ok(i)){ printf("%d\n",i); break; }
	return 0;
}

Measured memory_bytes: 256
a[100][100],t;main(T,i,j,k){for(scanf("%d",&T);t<T;t++)for(scanf("%d%d",&i,&k);k--;a[i-1][j-1]=1)scanf("%d",&j);for(i=0;i<t;i++)for(j=0;j<t;j++)printf(j<t-1?"%d ":"%d\n",a[i][j]);exit(0);}

Measured memory_bytes: 632
/* WORK HARD MAN ! IT DEFINETELY AIN'T EASY FOR THE PRIZE IT HOLDS .... */
/* GET YOUR ASS TO WORK ALREADY */
/* FALTU HI LIKH ... BUT KHALI NI BAITHNA */
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define mod 1000000007
#define inf 1e15
#define pii pair<int,int>
#define ff first
#define ss second
// #define N --

using namespace std;

/* if not able to handle the ques.. see up */
int32_t main() {
	fast
	int t_c = 1;
//	cin >> t_c;
	while (t_c--) {
		int n;
		cin >> n;
		vector<int> a(n);
		for (int &i : a)
			cin >> i;
		vector<int> dp(n);
		dp[0] = 0, dp[1] = abs(a[1] - a[0]);
		for (int i = 2; i < n; i++)
			dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));

		cout << dp[n - 1] << endl;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

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

  puts(1 <= n && n <= 999 ? "ABC" : 1000 <= n && n <= 1998 ? "ABD" : "error");

  return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;
//ダイクストラ
//LINFにしてあるよ
struct edge
{
  ll to, cost;
};
typedef pair<ll, ll> P;
struct graph
{
  ll V;
  vector<vector<edge>> G;
  vector<ll> d;
  //vector<ll> count;経路の本数
  //vector<ll> prev; // prev[v] := v から復元できる辺たち
  graph(ll n)
  {
    init(n);
  }

  void init(ll n)
  {
    V = n;
    G.resize(V);
    d.resize(V);
    //count.resize(V);
    rep(i, V)
    {
      d[i] = LINF;
      //count[i] = 0;
    }
  }

  void add_edge(ll s, ll t, ll cost)
  {
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s)
  {
    rep(i, V)
    {
      d[i] = LINF;
      //count[i] = 0;
    }
    d[s] = 0;
    //count[s] = 1;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    while (!que.empty())
    {
      P p = que.top();
      que.pop();
      ll v = p.second;
      if (d[v] < p.first)
        continue;
      for (auto e : G[v])
      {
        if (d[e.to] > d[v] + e.cost)
        {
          d[e.to] = d[v] + e.cost;
          que.push(P(d[e.to], e.to));
          //count[e.to] = count[v];
          // 復元のための
          //prev[e.to]=v;
        }
        /*
        else if (d[e.to] == d[v] + e.cost)
                {
                    count[e.to] += count[v];
                    count[e.to] %= MOD;
                }
                */
      }
    }
  }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin >> n>>x>>y;
    graph g(n);
    x--;
    y--;
    g.add_edge(x,y,1);
    g.add_edge(y,x,1);
    for (int i = 0; i < n-1; i++)
    {
        g.add_edge(i,i+1,1);
        g.add_edge(i+1,i,1);
    }
    vector<int> count(n+1,0);
    rep(i,n-1){
        g.dijkstra(i);
        for(int j=i+1;j<n;j++){
            count[g.d[j]]++;
        }
    }
    for(int i=1;i<n;i++){
        cout<<count[i]<<"\n";
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int n = t.length();
    string p = "";
    for(int i=0;i<n-1;i++)
    {
		p.push_back(s[i]);
	}
		long long int out = pow(2,31);
		int  m  = s.length();
		for(int i=n-1;i<m;i++)
		{
			int count=0;
			if(i!=n-1)
			p.erase(0,1);
			p.push_back(s[i]);
			//cout<<p<<" "<<t<<endl;
			for(int j=0;j<n;j++)
			{
				if(p[j]!=t[j])
				{
					count++;
				}
			}
			//cout<<count<<" "<<out<<endl;
			if(count<out)
			out = count;
		}
		cout<<out<<endl;
    return 0;
}


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

int main(){

    while(1){
        string s; cin >> s;
        if(s == "#") break;
        int y, m, d; cin >> y >> m >> d;
        string ans;
        if(y <= 30) ans = "HEISEI";
        else if(y >= 32){
            ans = "?";
            y -= 30;
        }
        else{
            if(m <= 4) ans = "HEISEI";
            else{
                ans = "?";
                y -= 30;
            }
        }

        cout << ans << " " << y << " " << m << " " << d << endl;
    }
    return 0;
}


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

constexpr int MAX=2000000;
constexpr int INFTY=(1<<30);

int H, A[MAX+1];

int left(int i){ return i*2; }
int right(int i){ return i*2+1; }
int parent(int i){ return i/2; }

void maxHeapify(int i){
   int l=left(i);
   int r=right(i);
   int largest;
   if(l<=H && A[i]<A[l])
      largest=l;
   else
      largest=i;
   if(r<=H && A[largest]<A[r])
      largest=r;

   if(largest!=i){
      swap(A[largest], A[i]);
      maxHeapify(largest);
   }
}

int extract(){
   int maxv;
   if(H<1) return -INFTY;
   maxv=A[1];
   A[1]=A[H--];
   maxHeapify(1);
   return maxv;
}

void IncreaseKey(int i, int key){
   if(key<A[i]) return;
   A[i]=key;
   while(i>1 && A[parent(i)]<A[i]){
      swap(A[i], A[parent(i)]);
      i=parent(i);
   }
}

void insert(int key){
   H++;
   A[H]=-INFTY;
   IncreaseKey(H, key);
}

int main(){
   int key;
   string com;
   while(true){
      cin >> com;
      if(com=="end") break;
      if(com=="insert"){
         cin >> key;
         insert(key);
      }
      else
         cout << extract() << endl;
   }
}


Measured memory_bytes: 6972
import sys
input = sys.stdin.readline

N = int(input())
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    if (t < x + y) or (x + y + t) % 2:
        flag = False


if flag:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum = 0;
	cin>>n;
	int gem[n],cost[n],diff[n];
	for(int i=0;i<n;i++){
		cin>>gem[i];
    }
	for(int i=0;i<n;i++){
		cin>>cost[i];
		diff[i] = gem[i] - cost[i];
		if(diff[i]>0) sum = sum + diff[i];
	}
	cout<<sum;
}
	


Measured memory_bytes: 256
function ts() {
    local mat;mat=(`dd`)
    local H;H=${#mat[@]}
    local W;W=${#mat[0][@]}
    for ((w=0;w<W;++w))
    do
        local tmp;tmp=''
        for ((h=0;h<H;++h))
        do
            tmp=$tmp${mat[h]: w: 1}
        done
        echo $tmp
    done
}

grep '#' | ts | grep '#' | ts


Measured memory_bytes: 1176
import fractions
a,b,c,d = map(int, input().split())

x = (c*d)//fractions.gcd(c,d)
A = (a-1) - (a-1)//c - (a-1)//d + (a-1)//x
B = b - b//c - b//d + b//x
print(int(B-A))

Measured memory_bytes: 5048