akhauriyash/Code-Regression huggingface dataset:
main :: IO ()
main = do
  input1 <- getLine
  input2 <- getLine
  putStrLn $ check (read input1 :: Integer) (read input2 :: Integer)

check :: Integer -> Integer -> String
check n1 n2 | n1 == n2 = "EQUAL"
            | n1 > n2 = "GREATER"
            | otherwise = "LESS"


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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  ll t1, t2;
  cin >> t1 >> t2;
  ll a1, a2, b1, b2;
  cin >> a1 >> a2 >> b1 >> b2;
  if (a1 < b1) {
    swap(a1, b1);
    swap(a2, b2);
  }

  if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
    cout << "infinity" << endl;
    return 0;
  }
  if (t1 * a1 + t2 * a2 > t1 * b1 + t2 * b2) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  int x1 = (t1 * a1 + t2 * a2), x2 = t1 * b1 + t2 * b2;
  ans++;
  
  ll ok = (a1 - b1) * t1;
  ll sa = t1 * b1 + t2 * b2 - (t1 * a1 + t2 * a2);
  if (sa > ok) {
    cout << ans << endl;
    return 0;
  }
  DEBUG(pll(ok, sa));
  if ((ok - sa) % (x2 - x1) == 0) {
    ans += (ok - sa) / (x2 - x1) * 2 + 1;
  }
  else {
    ans += (ok - sa) / (x2 - x1) * 2 + 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
 
int main() {
int n;
cin >> n;
int arr [n-1];
int brr[n];
for(int i=0;i<n;i++)
{
    brr[i]=0;
}
for(int i=0;i<n-1;i++)
{
    cin>> arr[i];
    brr[arr[i]-1]++;
}
for(int i=0;i<n;i++)
{
    cout<<brr[i]<<endl;
}
}

Measured memory_bytes: 5160
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <vector>
#include <stack>
#define Clear( x , y ) memset( x , y , sizeof(x) );
#define Qcin() std::ios::sync_with_stdio(false);
using namespace std;
typedef long long LL;
const int Maxn = 1e6 + 7;
const int Inf = 1e9 + 7;
int N , M;
int main()
{
	while( ~scanf(" %d",&N) ){
		if( N < 1200 )	cout << "ABC" << endl;
		else if( N >= 1200 && N < 2800 )	cout << "ARC" << endl;
		else	cout << "AGC" << endl;
	}
}

Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
N = gets.to_i
a = gets.split.map(&:to_i)
s = a.map.with_index(1) { |n, i| [i] * n }.flatten

map = Array.new(H) { Array.new(W) }
H.times.each_with_index do |h,i|
  W.times do |w|
    if i.even?
      map[h][w] = s.shift
    else
      map[h][W-1-w] = s.shift
    end
  end
end

H.times {|i| puts map[i].join(" ") }


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	long long int n,a,b,i,k,ans=0;
	long long int num[100000];
    
	for (i = 0; i < 100000; i++) {
		num[i] = 0;
	}
	cin >> n >> k;
	for (i = 0; i < n;i++) {
		cin >> a >> b;
		num[a-1] += b;
	}
	for (i = 0; i < 100000; i++) {
		ans += num[i];
		if (ans >= k) {
			cout << i+1 << endl;
            break;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  int n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n)cin >> a[i];
  ll ans = 0;
  ll maxd = a[0];
  REP(i,1,n){
    if(maxd > a[i]){
      ans += maxd - a[i];
      maxd = maxd;
    }
    else maxd = a[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, fact = 1;
    double dist = 0;
    vector<pair<int, int>> cord;
    cin >> n;
    
    for (int i = 2; i <= n; i++)
        fact *= i;
    
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cord.push_back(make_pair(x, y));
    }
    
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            dist += (double)sqrt( pow( cord[i].first-cord[j].first, 2 ) + pow( cord[i].second-cord[j].second, 2 ) );
            //cout << (double)sqrt( pow( cord[i].first-cord[j].first, 2 ) + pow( cord[i].second-cord[j].second, 2 ) ) << endl;
        }
    }

    dist *= (fact*2)/n;
    cout << fixed << setprecision(10) << (double)dist/fact;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <stack>
#define MAXN 100010
using namespace std;

int w,h,n;
vector< pair<int,int> > a;
stack<int> S;
bool visit[MAXN];

int trans(int x,int y){
	if(x==0) return y;
	if(y==w) return x+w;
	if(x==h) return w+h+w-y;
	if(y==0) return w+h+w+h-x;
	return -1;
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(trans(x1,y1)==-1 || trans(x2,y2)==-1) continue;
		a.push_back(make_pair(trans(x1,y1),i));
		a.push_back(make_pair(trans(x2,y2),i));
	}
	sort(a.begin(),a.end());
	for(int i=0;i<=a.size();i++){
		int x=a[i].second;
		if(!visit[x]){
			visit[x]=1;
			S.push(x);
		}else{
			if(S.top()!=x){
				puts("NO");
				return 0;
			}
			S.pop();
		}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 2420
#include<iostream>
int main(){
  int m,f,r,t;
  while(1){
    std::cin >> m >> f >> r;
    t = m + f;
    if(m == -1 && f == -1 && r == -1) return 0;
    if((m == -1 || f == -1) || t < 30) std::cout << "F\n";
    else if(t >= 80) std::cout << "A\n";
    else if(t >= 65) std::cout << "B\n";
    else if(t >= 50) std::cout << "C\n";
    else std::cout << (t >= 30 && r >= 50 ? "C\n" : "D\n");
  }
}

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

using namespace std;

int main() {
    long long N=0, W=0;
    cin>>N>>W;
    
    long long dp[N+1][W+1];

    vector<long long> weight;
    vector<long long> val;
    for(int I=0; I<N; I++) {
        long long wt=0, value=0;
        cin>>wt>>value;
        weight.push_back(wt);
        val.push_back(value);
    }

    for(int I=0; I<=N; I++) {
        for(int w=0; w<=W; w++) {
            if(I==0 || w==0) {
                dp[I][w] = 0;
            }
            else if(weight[I-1] > w) {
                dp[I][w] = dp[I-1][w];
            }
            else {
                dp[I][w] = max(dp[I-1][w-weight[I-1]] + val[I-1] , dp[I-1][w]);   
            }
        }
    }
    
    cout<<dp[N][W]<<endl;

    return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  
  auto fin=[](){
    cout<<-1<<endl;
    exit(0);
  };
  
  reverse(a.begin(),a.end());
  if(a[0]!=2) fin();
  
  Int c=2,d=2;
  for(Int i=0;i<n-1;i++){
    if(c*2<=a[i+1]) fin();
    
    c=(c+a[i+1]-1)/a[i+1]*a[i+1];
    d=(d+a[i]-1)/a[i+1]*a[i+1];
    
    if(c>d) fin();
  }
  
  d+=a.back()-1;
  cout<<c<<" "<<d<<endl;
  return 0;
}


Measured memory_bytes: 1024
//key2020_c.cpp
//Sat Mar 28 17:15:21 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

int main(){
	int n,k,s;
	cin >> n >> k >> s;

	for (int i=0;i<n;i++){
		if (i<k){
			cout << s << " ";
		}else {
			if (s==1000000000){
				cout << 999999999 << " ";
			}else {
				cout << s+1 << " ";
			}
		}
	}
	printf("\n");
}

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

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

  vector<int> a(n - 1);
  vector<int> ans(n);

  for (auto&& e : a) {
    cin >> e;
    e--;
  }

  reverse(begin(a), end(a));

  for (auto&& e : a) {
    ans[e]++;
  }

  for (auto&& e : ans) {
    cout << e << endl;
  }
}


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

st = set()

for i in range(0, k):
    if a+i <= b:
        st.add(a+i)
    else:
        break

for i in range(0, k):
    if b-i >= a:
        st.add(b-i)
    else:
        break

ls = list(sorted(st))

for i in ls:
    print(i)

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

int main(){
  string S;
  cin >> S;
  string output = "";
  for(int i = 0; i < S.size(); ++i){
    if(S[i] == '0'){
      output += '0';
    }else if(S[i] == '1'){
      output += '1';
    }else if(S[i] == 'B' && !output.empty()){
      output.pop_back();
    }
  }
  cout << output << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here   
        Scanner sc = new Scanner(System.in);
        StringBuilder builder = new StringBuilder();
        String s = sc.next();
        for(int i = 0 ; i < s.length(); i += 2){
            builder.append(s.charAt(i));
        }
        
        System.out.println(builder.toString());
    }
    
}


Measured memory_bytes: 26656
while True:
    n,x=map(int,input().split())
    if n == x == 0:
        break
    count = 0
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    count+=1
    print(count)


Measured memory_bytes: 5596
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = [LIST() for i in range(N-1)]
color = [0] * N
color[0] = 1
graph = defaultdict(list)
for u, v, w in L:
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, w))

q = [0]

while q:
    a = q.pop()
    for node, w in graph[a]:
        if color[node] == 0:
            if w % 2 == 0:
                color[node] = color[a]
            else:
                color[node] = -1 * color[a]
            q.append(node)
for c in color:
    print(1 if c == -1 else 0)
    





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

int d(ll a) {
  int res = 0;
  while (a) {
    a /= 10;
    ++res;
  }
  return res;
}

int f(ll a, ll b) {
  return max(d(a), d(b));
}

int main() {
  ll n;
  cin >> n;
  int ans = 100;
  for (ll a = 1; a * a <= n; ++a) {
    if (n % a) continue;
    ll b = n / a;
    ans = min(ans, f(a, b));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int c[26]={};
	string w;
	cin>>w;
	for(int i=0;i<w.size();i++){
		int n=w[i]-'a';
		c[n]++;
	}
	for(int i=0;i<26;i++){
		if(c[i] % 2 != 0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : beginner077.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : atcorder ABC077 in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

inline int main001();
inline int main002();
inline int main003();
inline int main004();

int main() {

	main001();

	return 0;
}

inline int main001() {

	string input1, input2;

	int i;
	bool flag = true;

	cin >> input1 >> input2;

	for (i = 0; i < 3; i++)
		if (input1[i] != input2[2 - i])
			flag = false;

	if (flag) {
		cout << "YES";
	} else {
		cout << "NO";
	}

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

class unionfind {
	vector<int> par;
	vector<int> sz;
public:
	vector<vector<int>> rev;
	unionfind(int n) {
		par = vector<int>(n);
		rev = vector<vector<int>>(n, vector<int>());
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rev[i].push_back(i);
		}
		sz = vector<int>(n, 1);
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	int si(int x) { return sz[find(x)]; }
	bool same(int x, int y) { return find(x) == find(y); }
	int unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return -1;
		if (sz[x] < sz[y]) {
			par[x] = y;
			sz[y] += sz[x];
			while (!rev[x].empty()) {
				rev[y].push_back(rev[x].back());
				rev[x].pop_back();
			}
			return x;
		}
		else {
			par[y] = x;
			sz[x] += sz[y];
			while (!rev[y].empty()) {
				rev[x].push_back(rev[y].back());
				rev[y].pop_back();
			}
			return y;
		}
	}
};

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

	int n;
	cin >> n;
	unionfind uni(n);
	map<P, int> mp;
	queue<P> que;
	vector<vector<int>> pl(n, vector<int>());
	rep(i, n - 1) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		if (u > v) swap(u, v);
		mp[{u, v}]++;
		pl[u].pb(v);
		pl[v].pb(u);
	}
	rep(i, n - 1) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		if (u > v) swap(u, v);
		mp[{u, v}]++;
		pl[u].pb(v);
		pl[v].pb(u);
	}
	for (auto i : mp) {
		if (i.second == 2) {
			que.push(i.first);
		}
	}
	int cnt = 0;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		int u = p.first, v = p.second;
		int change = uni.unite(u, v);
		if (change == -1) continue;
		cnt++;
		int use = uni.find(change);
		while (!pl[change].empty()) {
			int q = pl[change].back();
			q = uni.find(q);
			mp[{min(change, q), max(change, q)}]--;
			if (use != q) mp[{min(use, q), max(use, q)}]++;
			if (mp[{min(use, q), max(use, q)}] == 2) {
				que.push({ use,q });
			}
			pl[use].pb(q);
			pl[change].pop_back();
		}
	}
	cout << (cnt + 1 == n ? "YES" : "NO") << '\n';
}

Measured memory_bytes: 46824
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ld long double
#define ff first
#define ss second
using namespace std;

ll fact(ll a)
{
    if(a==0) return 1;
    else return a*fact(a-1);
}

vl<ll> divisor(ll n)
{
    vl<ll> v;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) 
        {
            if(n/i==i) v.pb(i);
            else
            {
                v.pb(i);
                v.pb(n/i);
            }
        }
    }
    return v;
}

int main()
{
    ll i,j,n,k,t,m,a,b;
    cin>>n;
    vl<ll> v;
    v=divisor(n);
    ll mn=n-1;
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
        for(j=0;j<v.size();j++)
        {
            a=v[i];
            b=v[j];
            if((a*b)==n) mn=min(a+b-2,mn);
        }
    }
    cout<<mn;
}

Measured memory_bytes: 3732
import sys
readline = sys.stdin.readline

def main():
    A, B, C, D = map(int, readline().rstrip().split())
    for i in range(1000):
        if C <= B:
            print('Yes')
            return
        C -= B
        if A <= D:
            print('No')
            return
        A -= D


if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;

int atcoder(){
    //入力
    int n;
    cin >> n;
    string ans;
    if(n==0){cout << 0; return 0;}
    for(int i=0; true; ++i){
        if(n==0) break;
        else if(n%2!=0){
            ans = "1"+ans;
            if(i%2==0) n = (n-1)/2;
            else n = (n+1)/2;
        }else{
            ans = "0"+ans;
            n = n/2;
        }
    }
    
    //出力
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 256
n = int(input())
s = str(n)

if s[-1] == '2' or s[-1] == '4' or s[-1] == '5' or s[-1] == '7' or s[-1] == '9':
    print('hon')
elif s[-1] == '0' or s[-1] == '1' or s[-1] == '6' or s[-1] == '8':
    print('pon')
else:
    print('bon')     


Measured memory_bytes: 9184
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << '\n';
 	return 0; 
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

int n;
int f[101][11];
int p[101][11];
int main() {
    cin>>n;
    REP(i, 0, n) REP(j, 0, 10){
        cin>>f[i][j];
    }
    REP(i, 0, n) REP(j, 0, 11){
        cin>>p[i][j];
    }

    int ans=-INF;
    REP(bit, 1, 1<<10){
        int sum=0;
        REP(i, 0, n){
            int cnt=0;
            REP(j, 0, 10){
                if((bit>>j & 1) && f[i][j]) cnt++;
            }
            sum+=p[i][cnt];
        }
        ans=max(ans, sum);
    }
    cout<<ans<<endl;
    return 0;
}

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


int main(void){
  char s[6];
  int k = 1;
  for(int i= 0; i < 6; i++){
    cin >> s[i];
  }
  if(s[2] !=s[3] || s[4] != s[5]){
    cout << "No" << endl;
  }
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K,X; cin >> K >> X;
    FOR(i,X-K+1,X+K){
        cout << i << " ";
    }
    cout << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	long X = Long.parseLong(scan.next());
	long Y = Long.parseLong(scan.next());

	System.out.println(Math.abs(X-Y) <= 1 ? "Brown" : "Alice");
	scan.close();
    }
}


Measured memory_bytes: 23380
##### 解けた #####

N=int(input())
L=[2,1]+[0]*max(0,N-1)

# 1より大きい場合
if N>1:
    for n in range(2,N+1): # 1個ずつ求めてゆく
        L[n]=L[n-1]+L[n-2]

print(L[N])

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  
  int i,j,n,R[2000000],minv,maxv;
    
  scanf("%d",&n);
  for(i = 0;i< n;i++) scanf("%d",&R[i]);
  
  minv = R[0];
  maxv = (-1)*1000000000;
  for(j = 1;j < n;j++){
    if(maxv < R[j] - minv) maxv = R[j] - minv;
    if(minv > R[j]) minv = R[j];
  }
  
  printf("%d\n",maxv);
  
  return 0;
}



Measured memory_bytes: 2584
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll N;
vector<ll> dp(100007,-1);

ll comp(ll a,ll b){
  return a > b;
}

ll binaly(ll key){
  ll ok=0,ng=N;
  while(ok<ng){
    ll mid = (ok+ng)/2;
    if(dp[mid]>=key){
      ok = mid+1; 
    }
    else{
      ng = mid;
    }
  }
  return ok;
}

template<class T> int LIS(vector<T> a) {
  int n = (int)a.size();
  for (int i = 0; i < n; ++i) {
    dp[binaly(a[i])] = a[i];
  }
  return lower_bound(dp.begin(), dp.end(), -1,comp) - dp.begin();
}
 
int main(){
  ll ans=1;
  vector<ll> V;
  cin >> N;
  rep(i,N){
    ll X;
    cin >> X;
    V.pb(X);
  }
  cout << LIS(V) << endl;
}

Measured memory_bytes: 2676
int main() {
    int n, x, j, k, ans = 0, max;

    while (1) {
        scanf("%d %d", &n, &x);

        if (n == 0 && x == 0)
            break;

        max = x;
        if (max > n)
            max = n;

        for (int i = 1; i <= max; ++i) {
            for (j = i + 1; j <= max; ++j) {
                for (k = j + 1; k <= max; ++k) {
                    if (i != j && i != k && j != k && i + j + k == x) {
                        ans++;
                        break;
                    }

                }
            }
        }

        printf("%d\n", ans);
        ans = 0;
    }
    return 0;
}


Measured memory_bytes: 2076
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	w := []byte(nextLine())
	var w2 []int
	for i := 0; i < len(w); i++ {
		w2 = append(w2, int(w[i]))
	}
	if len(w)%2 != 0 {
		fmt.Println("No")
	} else {
		sort.Sort(sort.IntSlice(w2))
		for i := 0; i < len(w)/2; i++ {
			if w2[2*i] != w2[2*i+1] {
				fmt.Println("No")
				return
			}
		}
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(_, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        d.merge(a, b);
    }
    cout << (int)d.groups().size() - 1 << endl;
}


Measured memory_bytes: 9000
#!/usr/bin/env python
# coding: utf-8
#


def main(input_str):
    l = list(map(int, input_str.split(' ')))
    if len(l) != 2:
        print('x')
        return

    
    if l[0] + l[1] == 15:
        print('+')
        return
    elif l[0] * l[1] == 15:
        print('*')
        return
    else:
        print('x')
        return
    

if __name__ == '__main__':
    try:
        main(input().strip())
    except EOFError:
        pass


Measured memory_bytes: 3060
/*input
6 727202214173249351
6 5 2 5 3 2
*/

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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> to(n);
  rep(i, n) cin >> to[i], --to[i];
  vector<int> t;
  vector<int> lv(n, -1);
  int len = 0;
  int p = 0;
  while (lv[p] == -1) {
    t.push_back(p);
    lv[p] = len;
    len++;
    p = to[p];
  }
  int ans = 0;
  if (k < len) ans = t[k];
  else {
    k -= len;
    k %= (len-lv[p]);
    ans = t[lv[p]+k];
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 5788
#include<math.h>
#include<iostream>
using namespace std;

int main(void) {
	string s;
	cin >> s;
	for (int i = 0;i < s.size()-1;i++) {
		for (int j = i+1;j < s.size();j++) {
			if (s[i] == s[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
	return 0;
}

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

int main()
{
    double a,b,c,s,l,h;

    scanf("%lf %lf %lf",&a,&b,&c);

    c=c*3.14159265/180.0;
    s=a*b*sin(c)/2;
    l=a+b+(sqrt(a*a+b*b-2*a*b*cos(c)));
    h=b*sin(c);

    printf("%.8f\n%.8f\n%.8f\n",s,l,h);
return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
# define fills(x,y) memset(x,y,sizeof x)
# define ALL(v) (v).begin(), (v).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define INF (int)1e9
# define EPS 1e-9
# define rep(i,n) for(int i=0;i<n;++i)
# define REP(i,k,n) for(int i=k;i<=n;++i)
# define mod 1000000007

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef vector<ll> Vl;
typedef vector<Vl> VVl;
typedef vector<string> VS;
typedef vector<Pll> Vll;
typedef map<ll,ll> Mll;
typedef set<ll> SETl;


int		main()
{
	int N; cin >> N;
	while (N)
	{
		if (N % 10 == 7)
		{
			cout << "Yes" << endl;
			return 0;
		}
		N /= 10;
	}
	cout << "No" << endl;
}



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

long long g(long long a,long long b){
    if(b==0){
        return a;
    }else{
        return g(b,a%b);
    }
}

int main() {
long long n,m,a,b,c;
string s,t;
cin>>n>>m>>s>>t;
c=g(m,n);
a=n/c;
b=m/c;
for(int i=0;i<c;i++){
    if(s[i*a]!=t[i*b]){
        cout<<-1<<endl;
        return 0;
    }
}
cout<<a*b*c<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main () {
    int n, m, l, r;
    cin >> n >> m;
    int gate[n+1] = {};
    for(int i=0; i<m; i++) {
        cin >> l >> r;
        gate[l-1]++;
        gate[r]--;
    }
    for(int i=1; i<n+1; i++) gate[i] += gate[i-1];

    int cnt=0;
    for(int i=0; i<n+1; i++) if(gate[i]==m) cnt++;

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <set>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

int main(void){
    int a, x, t;
    cin >> a >> x >> t;
    int c = (a + x-1)/x;
    cout << c * t << endl;
    
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

// End of template code!
int main() 
{
    buff();
    auto check_pal = [&] (string s) {
        string s2 = s;
        reverse(all(s2));
        return (s2 == s);
    };

    string x;
    cin >> x;
    int len = sz(x);
    string pref, suff;
    for(int i = 0; i < len / 2; ++i) {
        pref += x[i];
        suff += x[len - 1 - i];
    }
    if(check_pal(x) && ( check_pal(pref) && check_pal(suff) ) ) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool prime_check(int n, int k)
{
    if(k * k > n) { return true; }

    if(n % k == 0) { return false; }

    return prime_check(n, k + 1);
}

int bool_to_int(bool a)
{
    if(a == true) { return -1; }

    return 0;
}

int main()
{
    const int DATASETS = 10000;

    int n, k = 0, data[DATASETS];

    cin >> n;

    for(int i = 0; i < n; i++) { cin >> data[i]; }

    for(int i = 0; i < n; i++) { k -= bool_to_int(prime_check(data[i], 2)); }

    cout << k << endl;

    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pob pop_back
#define pp push
#define pf push_front 
#define pof pop_front 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree< ll  , null_type,less<ll >, rb_tree_tag,tree_order_statistics_node_update>

#define ff first
#define ss second
int main(){
	ll n;
	cin>>n;
	ll a[n],b[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	ll x=0;
	for(ll i=0;i<n;i++){
		if(b[i]!=a[i]){
			x++;
		}
	}
	if(x<=2){
		cout<<"YES";
	}
	else cout<<"NO";
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    res = 0
    for i in range(k, n + 2):
        mi = (i - 1) * i // 2
        ma = n * (n + 1) // 2 - (n - i) * (n - i + 1) // 2
        res += ma - mi + 1
        res %= mod

    print(res)


if __name__ == '__main__':
    resolve()


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
  for (auto& x : v) o << x << ' ';
  return o;
}

const int MAXN = 1e5 + 5;
ll memo[MAXN];
int arr[MAXN];
int n, k;

ll dp(int i) {
  ll &res = memo[i];
  if (res != -1) return res;
  if (i == n-1) return res = 0;
  res = LLONG_MAX;
  for (int j = 1; j <= min(k, n-1-i); j++) {
    res = min(res, dp(i+j) + abs(arr[i] - arr[i+j]));
  }
  return res;
}

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

  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> arr[i];
  memset(memo, -1, sizeof memo);
  cout << dp(0) << endl;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
 using namespace std;
 int main(){
     int a,b;
     cin>>a>>b;
     if((a+b)<24){
        cout<<(a+b)<<endl;
     }
     else{
        cout<<((a+b)%24)<<endl;
     }
     return 0;
 }


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

N = int(input())
A = list(map(int, input().split()))
iA = [(i, A[i]) for i in range(N)]
iA.sort(key=lambda t: t[1], reverse=True)
dp = [[0]*(N+1) for _ in range(N+1)]

for i in range(N):
    for j in range(N):
        if i+j<N:
            idx, v = iA[i+j]
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]+v*abs(idx-i))
            dp[i][j+1] = max(dp[i][j+1], dp[i][j]+v*abs(N-1-j-idx))

ans = 0

for i in range(N+1):
    ans = max(ans, dp[i][N-i])

print(ans)

Measured memory_bytes: 100404
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<ll> x(n), y(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    set<P> st;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i == j) {
                continue;
            }
            st.insert(P(x[j] - x[i], y[j] - y[i]));
        }
    }
    int ans = INF;
    for(auto it = st.begin(); it != st.end(); it++) {
        ll p = it->first, q = it->second;
        int s = 0;
        vector<int> vis(n);
        for(int i = 0; i < n; i++) {
            bool f = true;
            for(int j = 0; j < n; j++) {
                if(vis[j] || i == j) {
                    continue;
                }
                if(x[i] - x[j] == p && y[i] - y[j] == q) {
                    vis[j] = 1;
                    f = false;
                    break;
                }
            }
            if(f) {
                s++;
            }
        }
        chmin(ans, s);
    }
    cout << ans << endl;
}


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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int q;
int dp[1010][1010];

int solve(string x, string y)
{
    int n = x.length();
    int m = y.length();
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (x[i] == y[j])
            {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            else
            {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }
    return dp[n][m];
}

int main()
{
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        string x, y;
        cin >> x >> y;
        cout << solve(x, y) << endl;
    }
}



Measured memory_bytes: 7160
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

inline int repunit(int n) { return (1<<n)-1; }

int N, M;
int A[15][15];
LL dp[1<<15][15];
LL C[1<<15];

void MAIN() {
    scanf("%d%d", &N, &M);
    REP (i, M) {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	a--; b--;
	A[a][b] = A[b][a] = c;
    }

    memset(dp, 0xc0, sizeof dp);

    REP (s, 1<<N) REP (i, N) if (s>>i&1) REP (j, i) if (s>>j&1) {
	C[s] += A[i][j];
    }
    REP (s, 1<<N) if (s&1) {
	dp[s][0] = C[s];
    }

    REP (s, 1<<N) REP (v, N) if (s>>v&1) {
	REP (w, N) if (~s>>w&1 && A[v][w]) {
	    int sub = repunit(N) ^ s ^ (1<<w);
	    for (int t=sub; ; t=(t-1)&sub) {
		LL cst = C[t|(1<<w)] + A[v][w];
		amax(dp[s|t|(1<<w)][w], dp[s][v] + cst);
		if (t == 0) break;
	    }
	}
    }

    LL ans = C[repunit(N)]- dp[repunit(N)][N-1];
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(W, H, N);
  int hMin, hMax, wMin, wMax;
  hMin = wMin = 0;
  hMax = H;
  wMax = W;

  REP(i, N) {
    CIN(x, y, a);
    switch(a) {
    case 1:
      wMin = max(wMin, x);
      break;
    case 2:
      wMax = min(wMax, x);
      break;
    case 3:
      hMin = max(hMin, y);
      break;
    case 4:
      hMax = min(hMax, y);
      break;
    }
  }

  int ans = (hMax - hMin) * (wMax - wMin);
  if (hMin > hMax or wMin > wMax) {
    ans = 0;
  }

  /*
    debug(hMax);
    debug(hMin);
    debug(wMax);
    debug(wMin);
  */
  cout << ans << endl;
  

  return 0;
}



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

using System.Collections;

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();

        string A = S.Substring(0, 2);
        string B = S.Substring(2, 2);

        int a = int.Parse(A);
        int b = int.Parse(B);

        if ((a == 0 || a > 12) && (b == 0 || b > 12))
        {
            Console.WriteLine("NA");
            return;
        }

        if ((a != 0 && a <= 12 && b != 0 && b <= 12))
        {
            Console.WriteLine("AMBIGUOUS");
        }
        else if (a != 0 && a <= 12)
        {
            Console.WriteLine("MMYY");            
        }
        else if (b != 0 && b <= 12)
        {
            Console.WriteLine("YYMM");
        }
    }

    static long calcGCD(long num1, long num2)
    {
        if(num1 < num2)
        {
            var tmp = num1;
            num1 = num2;
            num2 = tmp;
        }

        while(true)
        {
            long res;
            long div = Math.DivRem(num1, num2, out res);

            if (res == 0)
            {
                return num2;
            }
            else
            {
                num1 = num2;
                num2 = res;
            }
        }
    }
}


static class MathUtil
{
    public static T Max<T>(params T[] datas)
    {
        return datas.Max();
    }

    public static T Min<T>(params T[] datas)
    {
        return datas.Min();
    }

    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}




Measured memory_bytes: 11092
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
auto f(int bit){
    if(bit % 4 == 0) return bit;
    if(bit % 4 == 1) return 1LL;
    if(bit % 4 == 2) return bit+1;
    if(bit % 4 == 3) return 0LL;
    return LLONG_MAX;
}
signed main(){
    int a,b;
    cin >> a >> b;
    cout <<(long long)(f(a) xor a xor f(b)) << endl;
    
}



Measured memory_bytes: 256