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



int main() {
  ll x;
  cin >> x;
  if(x == 2){cout << 2 << endl; return 0;}
  if(x%2==0){ x++; }
  int i, j, k, ans;
  for(i=x; i < 10000000; i+=2){
    bool is_prime = true;
    for(j=3; j<= sqrt(i); j+=2){
      if(i%j==0){
        is_prime = false;
      }
    }
    if(is_prime){
      ans = i;
      break;
    }
  }
   
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	cin >> s;
	int n = s.size();
	if (n % 2)n -= 3;
	else n -= 2;

	while (true) {
		bool ok = true;
		rep(i, n / 2)if(s[i] != s[n / 2 + i])ok = false;
		if(ok)break;
		else n -= 2;
	}

	cout << n << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(), .end());
int main(){
  str s, K = "keyence";
  cin >> s;
  ll n = s.size(), keyence1 = 0, keyence2 = 0;
  for (ll i = 0; i < 7; i++) {
    if (s[i] == K[i]) keyence1 = i+1;
    else break;
  }
  for (ll i = 0; i < 7; i++) {
    if (s[n-i-1] == K[6-i]) keyence2 = i+1;
    else break;
  }
  str ans ="NO";
  if (keyence1 + keyence2 >= 7) ans = "YES";
  cout << ans << endl;
}

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

int main(){
	int h[10000], w[10000], i, j, k;

	for(i = 0; i <= 9999; i++){
		cin >> h[i] >> w[i];
		if((h[i] == 0) and (w[i] == 0)){
			break;
		}
	}

	for(j = 0; j <= i-1; j++){
		cout.width(w[j]);
		cout.fill('#');
		cout << '#' << endl;
		for(k = 1; k <= h[j]-2; k++){
			cout.width(w[j]-1);
			cout.fill('.');
			cout << left << '#';
			cout << '#' << endl;
		}
		cout.width(w[j]);
		cout.fill('#');
		cout << '#' << endl << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(void) {
	int n,k;
	int a[200010];
	int i = 0;
	int count = 0;
	
	scanf("%d%d",&n,&k);
	for(i=1;i<n+1;i++){
		scanf("%d",&a[i]);
	}
	//printf("%d,%d,%d,%d\n",a,b,c,k);
	
	for(i=k+1;i<n+1;i++){
		if(a[i-k]<a[i]){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	

	return 0;
}


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

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  for(int i=1;i<=n;i++){
      int sum=0;
      int x=i; 
      while(x>9){
          sum+=x%10;
          x/=10;
      }
      sum+=x;
      if(a<=sum&&sum<=b) ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3556
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

int dp[3005][3005];

signed main() {
	int n, t;
	cin >> n >> t;
	P p[3005];
	rep(i, n) cin >> p[i].first >> p[i].second;
	sort(p, p + n);
	for (int i = 1; i <= n; i++) {
		rep(j, t) {
			if (j < p[i - 1].first) dp[i][j] = dp[i - 1][j];
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - p[i - 1].first] + p[i - 1].second);
			}
		}
	}
	int ans = 0;
	rep(i, n) {
		ans = max(ans, dp[i][t - 1] + p[i].second);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 70784
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
char a[26];
bool c[26];
int main(){
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		if (a[s[i] - 'a'] == 0) {
			a[s[i] - 'a'] = t[i];
			c[s[i] - 'a'] = true;
		}
		else if (a[s[i] - 'a'] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	bool b[26] = {};
	for (int i = 0; i < 26; i++) {
		if (!b[a[i] - 'a']) {
			b[a[i] - 'a'] = true;
		}
		else if(c[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int sum=0;
  for(int i=0;i<N;i++){
    if(i%2==0)
      sum+=A.at(i);
    else
      sum-=A.at(i);
  }
    cout<<sum<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

// typedef pair<pint, int> P;
// bool hoge(const P &a, const P &b) {
// 	return a.first.first < b.first.first;
// }
// bool fuga(const P &a, const P &b) {
// 	return a.second < b.second;
// }

int main() {
	int N; cin >> N;
	vint joubu(N), chubu(N), kabu(N);
	// vector<P> data(N);
	rep(i,N) joubu[i] = in();
	rep(i,N) chubu[i] = in();
	rep(i,N) kabu[i] = in();
	
	// sort(data.begin(), data.end(), hoge);
	// rep(i, N) joubu[i] = data[i].first.first;
	// sort(data.begin(), data.end(), fuga);
	// rep(i, N) kabu[i] = data[i].second;
	sort(joubu.begin(), joubu.end());
	sort(kabu.begin(), kabu.end());
	ll ans = 0;
	rep(i, N) {
		int c = chubu[i];
		int j = lower_bound(joubu.begin(), joubu.end(), c) - joubu.begin();
		int k = kabu.end() - upper_bound(kabu.begin(), kabu.end(), c);
		ans += (ll)j * k;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
while True:
    h, w = map(int, input().split())

    if h == 0 and w == 0:
        break

    for y in range(1, h + 1):
        for x in range(1, w + 1):
            if y == 1 or y == h:
                print('#', end='')
            else:
                if x == 1 or x == w:
                    print('#', end='')
                else:
                    print('.', end='')
        print('')
    print('')

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

int main() {
  string s;
  cin >> s;
  if (s[2]==s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
  return 0;
}

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

int main(){
  long long x;
  cin >> x;
  long long a = 100;
  
  long long count = 0;
  while(1){
    long long b = a/100;
    a += b;
    count++;
    if(a >= x) break;
  }
  cout << count << endl;
}

    

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

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

using namespace std;

vector<string> encode(string s) {
  rep(i,(int)s.size()) if( s[i] == '/' ) s[i] = ' ';
  stringstream ss;
  ss << s;
  vector<string> field;
  while( ss >> s ) {
    string tmp = "";
    rep(i,(int)s.size()) {
      if( s[i] == 'b' ) {
	tmp += "b";
      } else {
	tmp += string(s[i]-'0',' ');
      }
    }
    field.push_back(tmp);
  }
  return field;
}

string decode(vector<string> vec,int a,int b,int c,int d) {
  --a, --b, --c, --d;
  swap(vec[a][b],vec[c][d]);
  string ret = "";
  rep(i,(int)vec.size()) {
    if( i ) ret += "/";
    int cnt = 0;
    rep(j,(int)vec[i].size()) {
      if( vec[i][j] == 'b' ) {
	if( cnt ) {
	  ret += string(1,(char)('0'+cnt));
	  cnt = 0;
	}
	ret += "b";
      } else {
	++cnt;
      }
    }
    if( cnt ) {
      ret += string(1,(char)('0'+cnt));
      cnt = 0;
    }
  }
  return ret;
}

int main() {
  string s;
  int a,b,c,d;
  while( cin >> s, s[0] != '#' ) {
    cin >> a >> b >> c >> d;
    vector<string> field = encode(s);
    cout << decode(field,a,b,c,d) << endl;
  }
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	rep(i,N) cin >> L[i];

  sort(all(L));
	int ans = 0;
	rep(a,N)rep(b,a){
		int index = lower_bound(all(L),L[a]-L[b]+1) - L.begin();
		ans += max(b - index,0);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
int main(void){
 char s[101];
  scanf("%s",s);
  for(int i = 1;i<=100;i++){
      if(i  % 2 == 0 && s[i - 1] == 'R'){
          printf("No");
          goto end;
      }
      if(i  % 2 != 0 && s[i - 1] == 'L'){
          printf("No");
          goto end;
      }
      
  }
  printf("Yes");
    end:
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}
ll len(ll n) {
  return pow(2, n+2)-3;
}

ll f(ll n, ll x) {
  if(x==1) {
    if(n==0)
      return 1;
    else
      return 0;
  } else if(x <= 1 + len(n-1)) {
    return f(n-1, x-1);
  } else if(x == 2 + len(n-1)) {
    return f(n-1, x-2)+1;
  } else if(x < len(n)) {
    return 1 + f(n-1, len(n-1)) + f(n-1, x-(2+len(n-1)));
  } else {
    return f(n-1, (x-3)/2)*2 +1;
  }
}

void solve(long long N, long long X){
  std::cout << f(N, X) << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long X;
  scanf("%lld",&X);
  solve(N, X);
  return 0;
}



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

#define debug(x) cout << (#x) << " is " << x << endl;
#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;

#define N 300005
int H[N], W[N];

int main()
{
    int h, w, m, hmx=0, wmx=0;
    cin >> h >> w >> m;
    vector<pi> p;
    for(int i=0; i<m; i++){
		int x, y;
		cin >> x >> y;
		H[x]++;
		W[y]++;
		p.push_back({x, y});
		hmx = max(hmx, H[x]);
		wmx = max(wmx, W[y]);
	}
	lli hc=0, wc=0;
	for(int i=1; i<=h; i++) hc += (H[i] == hmx);
	for(int i=1; i<=w; i++) wc += (W[i] == wmx);
	
	lli cc = 0;
	for(auto el: p){
		if(H[el.first]==hmx && W[el.second]==wmx) cc++;
	}
	if(cc == hc*wc){
		cout << hmx+wmx-1 << endl;
	}
	else
		cout << hmx+wmx << endl;
		
 
    return 0;
}


Measured memory_bytes: 9808
t = "abcdefghijklmnopqrstuvwxyz"
s = input()
ans = 1000
for i in t:
    S = s
    c = 0
    while len(set(S))!=1:
        c+=1
        ts = ""
        for  j,k in zip(S,S[1:]):
            if j == i or k == i:
                ts+=i
            else:
                ts+=k
        S = ts
    ans = min(ans,c)
    # print(c)

print(ans)




Measured memory_bytes: 3060
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int t = 0, h = 0, lim = scn.nextInt();
        for(int i = 0; i < lim; i++) {
            int val = scn.next().compareTo(scn.next());
            if(val > 0) {
                t += 3;
            } else if(val < 0) {
                h += 3;
            } else {
                t++;
                h++;
            }
        }
        System.out.println(t + " " + h);
    }
}

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

using namespace std;
#define rep(i,n) for(int i=1;i<n+1;i++)
#define ll long long int

int keta(int n){
  int count=1;
  while(n/10>0){
    n/=10;
    count++;
  }  
  return count;
}

int main(){
  int N;
  cin>>N;
  int count=0;
  rep(i,N){
    if(keta(i)%2!=0)
       count++;
    
  }
  // cout<<keta(N)<<endl;
    cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>

using namespace std;

int main() {
    int N, W;
    scanf("%d%d", &N, &W);
    long long w[N];
    int v[N];
    int V = 0;
    for(int i=0; i<N; i++) {
    	scanf("%lld%d", &w[i], &v[i]);
    	V += v[i];
    }
    long long dp[V+1];
    dp[0] = 0;
    for(int i=1; i<=V; i++) {
    	dp[i] = W+1;
    }
    for(int i=0; i<N; i++) {
    	for(int value=V; value>=v[i]; value--) {
    		if(dp[value-v[i]]<=W) {
    			dp[value] = min(dp[value], dp[value-v[i]]+w[i]);
    		}
    	}
    }
    for(int value=V; value>0; value--) {
    	if(dp[value]<=W) {
    		printf("%d\n", value);
    		return 0;
    	}
    }
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

void test_case(){
	int t;
	cin >> t;
	if(t>=30 ) cout <<"Yes" << endl;
	else cout << "No" << endl;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}



Measured memory_bytes: 3636
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };


string s, t;
int rui[26][222222];

int q(int c, int l, int r) {
    if (l == 0)
        return rui[c][r];
    return rui[c][r] - rui[c][l - 1];
}

int main() {
    cin >> s >> t;
    s = s + s;

    int ss = s.size();

    rep(i, ss) {
        rui[s[i] - 'a'][i]++;
    }
    rep(i, 26) {
        rep(j, ss) {
            rui[i][j + 1] += rui[i][j];
        }
    }


    rep(i,t.size()) {
        if (q(t[i] - 'a', 0, ss) == 0) {
            cout << -1 << endl;
            return 0;
        }
    }
 
        
    ll ans = 0;
    ll now = 0;
    rep(i, t.size()) {
        int ng = now-1, ok = ss;
        while (abs(ok - ng) > 1) {
            int mid = (ng + ok) / 2;
            int res = q(t[i]-'a', now, mid);
            if (res >= 1)
                ok = mid;
            else
                ng = mid;
        }
       // cout << t[i] << " " << ok << endl;
        if (ok == ss) {
            ans += ss;
            now = 0;
            i--;
        }
        else {
            now = ok + 1;
        }
    }

    cout << ans+now << endl;


    return 0;
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll A, B, K;
	cin >>A >>B >>K;
	ll a=max(A-K, (ll)0);
	ll b=max((ll)0, B-max(K-A, (ll)0));
	cout <<a <<' ' <<b <<endl;
	return 0;
}



Measured memory_bytes: 256
/*
Original problem: https://atcoder.jp/contests/abc137/tasks/abc137_b
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
    void main() {
        int k, x;
		cin >> k >> x;
		int L = max(-1000000, x - k + 1);
		int R = min(1000000, x + k - 1);
		REP(i,L,R+1) {
			cout << i << ' ';
		}
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		StringBuilder sb = new StringBuilder();

		if(a >= b) {
			for(int i = 0; i < a; i++) sb.append(b);
		} else {
			for(int i = 0; i < b; i++) sb.append(a);
		}

		System.out.println(sb);
	}
}

Measured memory_bytes: 35436
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define llint long long

using namespace std;

llint n;
multiset<llint> S;
vector<llint> vec[20];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint x;
	for(int i = 0; i < (1<<n); i++){
		cin >> x;
		S.insert(x);
	}
	
	auto it = S.end(); it--;
	vec[0].push_back(*it);
	S.erase(*it);
	for(int i = 1; i <= n; i++){
		//for(int j = 0; j < vec[i-1].size();j++) cout << vec[i-1][j] << " "; cout << endl;
		for(int j = 0; j < vec[i-1].size(); j++){
			llint v = vec[i-1][j];
			vec[i].push_back(v);
			auto it = S.lower_bound(v);
			//cout << v << " " << *it << " " << S.size() << endl;
			if(it == S.begin()){
				cout << "No" << endl;
				return 0;
			}
			it--;
			vec[i].push_back(*it);
			S.erase(it);
		}
		sort(vec[i].rbegin(), vec[i].rend());
	}
	
	if(S.size() == 0)  cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 17652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)	for(int i=0;i<n;i++)
#define itr(i,a)	for(auto i=a.begin(),i!=a.end();i++)
#define mp	make_pair
#define pb	push_back
int w,h;
bool grd[2020][2020];
int main(){
	while(true){
		cin>>w>>h;
		if(w==0)	return 0;
		int n;	cin>>n;
		int x1[n],y1[n],x2[n],y2[n];
		set<int> xdata,ydata;
		xdata.insert(0);	xdata.insert(w);
		ydata.insert(0);	ydata.insert(h);
		rep(i,n){
			cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
			xdata.insert(x1[i]);	xdata.insert(x2[i]);
			ydata.insert(y1[i]);	ydata.insert(y2[i]);
		}
		vector<int> lx(1000010),ly(1000010);
		int cw=xdata.size(),ch=ydata.size();
		int t;	set<int>::iterator it;
		for(it=xdata.begin(),t=0;it!=xdata.end();it++,t++)	lx[*it]=t;
		for(it=ydata.begin(),t=0;it!=ydata.end();t++,it++)	ly[*it]=t;
		rep(i,ch)	rep(j,cw)	grd[i][j]=false;
		rep(i,n){
			int l=lx[x1[i]],r=lx[x2[i]],o=ly[y1[i]],u=ly[y2[i]];
			for(int y=o;y<u;y++)	for(int x=l;x<r;x++)	grd[y][x]=true;
		}
		int cnt=0;
		ch--,cw--;
		int mx[]={1,0,0,-1},my[]={0,1,-1,0};
		rep(y,ch)	rep(x,cw){
			if(grd[y][x])	continue;
			queue<pair<int,int>> q;	q.push(mp(y,x));
			while(!q.empty()){
				pair<int,int> now=q.front();	q.pop();
				int nx=now.second,ny=now.first;
				if(grd[ny][nx])	continue;
				grd[ny][nx]=true;
				rep(i,4){
					int xx=nx+mx[i],yy=ny+my[i];
					if((0<=xx&&xx<cw)&&(0<=yy&&yy<ch)&&(!grd[yy][xx])){
						q.push(mp(yy,xx));
					}
				}
			}
			cnt++;
		}
		cout<<cnt<<endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  int t=0,m=0,a;
  for(int i=0;i<N;i++){
    cin >> a;
    while(a%2==0){
      t++;
      a=a/2;
      if(i==0){
        m=t;
      }
      if(t>m){
        continue; 
      }
    }
    if(m>t){
      m=t;
    }
    t=0;
  }
  cout << m << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 2e6+100;
const int mod = 1e9+7;
pii arr[upperlimit];
bool cmp(pii a,pii b){
	if(a.F+b.F==0) return (a.S>b.S);
	if((a.S>=0)&&(b.S>=0)) return(a.F>b.F);
	if((a.S>=0)&&(b.S<=0)) return true;
	if((a.S<=0)&&(b.S>=0)) return false;
	return ((a.S-a.F)>(b.S-b.F));
}
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	int n;
	ll totsum=0;
	string s;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> s;
		int sum=0,mps=0;
		for(int j = 0; j < s.size(); j++){
			if(s[j]=='(') sum++;
			else sum--;
			mps=min(mps,sum);
		}
		arr[i]=mp(mps,sum);
		totsum+=sum;
	}
	if(totsum){
		cout << "No\n";
		return 0;
	}
	sort(arr+1,arr+n+1,cmp);
	for(int i = 1; i <= n; i++){
		if(totsum+arr[i].F < 0){
//			pllds(totsum);pds(i);pdn(arr[i].S);
			cout << "No\n";
			return 0;
		}
		totsum+=arr[i].S;
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 11308
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a,b,c;
    cin>>a>>b>>c;
    char dif='A'-'a';
    char a1,b1,c1;
    a1=a[0]+dif;
    b1=b[0]+dif;
    c1=c[0]+dif;
    cout<<a1<<b1<<c1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MAXN 1000
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int y,e,t,s;
	e=c+d-a;
	y=c+b-d;
	t=a+b-d;
	s=b+c-a;
	printf("%d %d %d %d\n",y,e,t,s);
}


Measured memory_bytes: 256
#include <stdio.h>
int a[1000001];
int main(){
    int K;
    scanf("%d",&K);
    a[1]=7%K;
    for(int i=2;i<=K;i++)a[i]=(a[i-1]*10+7)%K;

    for(int i=1;i<=K;i++)if(a[i]==0){
        printf("%d\n",i);
        return 0;
    }
    printf("-1\n");
}

Measured memory_bytes: 5628
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    int tmp = 0;
    for(int j = 0; j < m; j++) {
      int a;
      cin >> a;
      tmp += a * b[j];
    }
    tmp += c;
    if(tmp > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll a[303][303];
int ck[303][303];
int main() {
	scanf("%d", &n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
			//ans += a[i][j];
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][k] + a[k][j] < a[i][j]) {
					puts("-1"); return 0;
				}
				if (i == k || j == k)continue;
				if (a[i][k] + a[k][j] == a[i][j]) {
					//ans -= a[i][j];
					ck[i][j] = 1;
				}
			}
		}
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (!ck[i][j])ans += a[i][j];
	cout << ans / 2;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}


int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    set<int> st;
    int a;
    rep(i,n) {
        cin >> a;
        A[i] = a;
        st.insert(a);
    }
    if (A.size() == st.size()) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  rep(i,m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if(ac[p]) continue;
    if(s=="AC") ac[p]=1;
    else pena[p]++;
  }
  int AC=0, WA=0;
  rep(i,n) {
     AC += ac[i];
     if(ac[i]) WA += pena[i]; 
  }
  cout <<AC <<" " << WA << endl;  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;
ll nodes, edges;
vector<vector<ll>> v;
vector<bool> visited;
stack<ll> st;
void dfs_recursive(ll s)
{
    visited[s] = true;
    for (auto i : v[s])
    {
        if (!visited[i])
        {
            dfs_recursive(i);
        }
    }
    st.push(s);
}

vector<ll> T;

void topological_sort()
{
    T.clear();
    for (ll i = 1; i <= nodes; ++i)
    {
        if (!visited[i])
        {
            dfs_recursive(i);
        }
    }
    while (!st.empty())
    {
        T.push_back(st.top());
        st.pop();
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> nodes >> edges;
    ll from, to;
    v.resize(nodes + 1);
    visited.resize(nodes + 1);
    vector<ll> dist(nodes + 1);
    for (ll i = 0; i < edges; i++)
    {
        cin >> from >> to;
        v[from].push_back(to);
    }
    topological_sort();
    for (ll &el : T)
    {
        for (ll &e : v[el])
        {
            dist[e] = max(dist[e], dist[el] + 1);
        }
    }
    cout << *max_element(dist.begin(), dist.end());
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    cout << s.at(i);
    if (i == 3) {
      cout << ' ';
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n;cin>>n;
    int increase = 0;
    ll before = 0,ans=1;
    rep(i,n){
        ll a;cin>>a;
        if(i){
            if(increase == 0){
                if(before < a){
                    increase = 1;
                }else if(before > a){
                    increase = -1;
                }
            }else if(increase == 1){
                if(before > a){
                    increase = 0;
                    ans++;
                }
            }else{
                if(before < a){
                    increase = 0;
                    ans++;
                }
            }
        }
        before = a;
    }
    cout << ans << endl;
}



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

using namespace std;

long long a[200001];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i > 0)
            a[i] += a[i - 1];
    }


    map<long long, int> mp;
    for (int i = 0; i <= n; ++i) {
        mp[a[i]]++;
    }

    long long ans = 0;
    for (auto v : mp) {
        long long k = v.second - 1;
        ans += k * (k + 1) / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 14336
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String c = br.readLine();
		if (c.equals("a") || c.equals("i") || c.equals("u") || c.equals("e") || c.equals("o")) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");

		}
	}
}


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

int main() {
	string s;
  	cin >> s;
  	int count_0 = 0;
  	int count_1 = 0;
  	for(int i = 0; i < s.length(); i++) {
    	if(s[i] == '0') {
        	count_0++;
        }else{
        	count_1++;
        }
    }
  
  	cout << min(count_0, count_1) * 2 << endl;
  	return 0;
}

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


int main(){
  map<string, int> week;
  week["SUN"] = 7;
  week["MON"] = 6;
  week["TUE"] = 5;
  week["WED"] = 4;
  week["THU"] = 3;
  week["FRI"] = 2;
  week["SAT"] = 1;

  string day;
  cin >> day;
  cout << week[day] << endl;
}


Measured memory_bytes: 256
from __future__ import print_function
from copy import deepcopy

try:
    xrange
except NameError:
    pass
else:
    range = xrange

def rotate(array):
    array2 = deepcopy(array)
    for i in range(8):
        for j in range(8):
            array2[j][7 - i] = array[i][j]
    return array2

def to_str(array):
    return '\n'.join(map(''.join, array))

def solve(lines):
    lines90 = rotate(lines)
    print(90)
    print(to_str(lines90))
    
    lines180 = rotate(lines90)
    print(180)
    print(to_str(lines180))
    
    lines270 = rotate(lines180)
    print(270)
    print(to_str(lines270))

if __name__ == '__main__':
    lines = []
    for _ in range(8):
        lines.append(list(raw_input().strip()))
    solve(lines)

Measured memory_bytes: 4284
n=int(input())
dic={}
for i in range(n):
  a=input()
  if a not in dic.keys():dic[a]=1
  else:dic[a]+=1
max_value=max(dic.values())
dic_max=[k for k, v in dic.items() if v==max_value]
dic_s=sorted(dic_max)
[print(i) for i in dic_s]

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

void solve() 
{
    ll A,B,M;cin>>A>>B>>M;
    ll a[A],b[B],x[M],y[M],c[M];
    REP(i,A)cin>>a[i];
    REP(i,B)cin>>b[i];
    REP(i,M)cin>>x[i]>>y[i]>>c[i];
    ll mna=2147483646,mnb=2147483646;
    REP(i,A)mna=min(mna,a[i]);
    REP(i,B)mnb=min(mnb,b[i]);
    ll ans=mna+mnb;
    REP(i,M){
        ll tmp=a[x[i]-1]+b[y[i]-1]-c[i];
        ans=min(ans,tmp);
    }cout<<ans<<endl;
}

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

Measured memory_bytes: 4224
#include <iostream>

using namespace std;

int main()
{
    int n,x;
    cin >> n;
    for(int i=1;i<=n;i++){
        x=i;
        if(i%3==0){
            cout << " " << i;
            continue;
        }
        while(x!=0){
            if(x%10==3){
                cout << " " << i;
                break;
            }
            x /=10;
        }
    }
    cout << endl;
}



Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	static int N = 123456;

	public static void main(String[] args) {

		boolean[] primeNumber = new boolean[2 * N + 1];
		primeNumber[1] = true;
		for (int i = 4; i <= 2 * N; i += 2)
			primeNumber[i] = true;

		for (int i = 3; i <= 2*N; i += 2)
			for (int j = 2; j <= 2*N/i; j++)
				primeNumber[i * j] = true;

		Scanner sr = new Scanner(System.in);

		while (true) {
			int count = 0;
			int n = sr.nextInt();
			if(n == 0) break;
			for(int i = n+1; i <= 2*n; i++)
				if(primeNumber[i] == false) count++;


			System.out.println(count);


		}

	}
}



Measured memory_bytes: 27664
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n - 1];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
            c[i] = sc.nextInt();
        }
        int cur = a[0] - 1;
        int s = b[cur];
        for (int i = 1; i < n; i++) {
            int next = a[i] - 1;
            s += b[next] + (next == cur + 1 ? c[cur] : 0);
            cur = next;
        }
        System.out.println(s);
    }
}


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

using namespace std;
using ll =long long;
//nCm 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nCmここまで

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n;	
	cin >> n;	
	vector<ll> a(n);
	rep(i,n) cin >>a[i];

	map<int,int> M ;
	rep(i,n){
		M[a[i]] ++ ;
		if(M[a[i]] >= 2){
			cout << "NO"<<endl;
			return 0;
		}
	}
	cout <<"YES"<<endl;
	
}


Measured memory_bytes: 11136
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long n, m;
    readlnTo(n, m);
    if(n > m/2) {
        writeln(m/2);
        return;
    }
    writeln(n + (m - 2*n)/4);
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		String s[][] = new String[h][w];

		for (int i = 0; i < h; i++) {
			s[i] = scanner.next().split("");
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j].equals("#")) {
					if (check(s, i, j, h, w)) {
						continue;
					} else {
						System.out.println("No");
						return;
					}
				}
			}
		}

		System.out.println("Yes");

	}

	private static boolean check(String[][] s, int y, int x, int h, int w) {
		for (int i = -1; i <= 1; i++) {
			for (int j = -1; j <= 1; j++) {
				if ((i == 0 && j != 0) || (i != 0 && j == 0)) {
					int tarX = j + x;
					int tarY = i + y;
					if (0 <= tarX && tarX <= w - 1 && 0 <= tarY && tarY <= h - 1) {
						if (s[tarY][tarX].equals("#")) {
							return true;
						}
					}
				}
			}
		}
		return false;
	}

}


Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin>>a[i];

  sort(a.begin(), a.end());

  int Alice=0, Bob=0;
  int i=N-1;
  while(i>0) {
    Alice+=a[i--];
    Bob+=a[i--];
  }
  if(i==0) Alice+=a[0];
  cout << Alice-Bob << endl;
}


Measured memory_bytes: 256
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int a;
  long double b;
  cin >> a >> b;
  long double ans = (long double)a * b;
  int ans2 = floor(ans);
  cout << ans2 << endl;
  return 0;
}


Measured memory_bytes: 3744
n,m = map(int,input().split())
l = list(list(map(int,input().split())) for _ in range (m))
a = l[0][0]
b = l[0][1]
for s,t in l:
  a = max(a,s)
  b = min(b,t)
print(max(b-a+1,0))
  

Measured memory_bytes: 27332
#include<stdio.h>
int main(void)
{
    int A,B,C,D,x,y;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    if(A<=C) x=C;
    else x=A;
    if(B<=D) y=B;
    else y=D;
    if(B<=C||D<=A) printf("0");
    else printf("%d",y-x);
    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	string t, p;
	cin >> t >> p;

	for (int i = 0; i <= (int)(t.length() - p.length()); i++)
	{
		if (p == t.substr(i, p.length()))
		{
			cout << i << endl;
		}
	}
}


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

using namespace std;

const int N = 23, mod = 1e9 + 7;

int n;

int ok[N][N], dp[N][(1 << N)];

int main () {
    ios_base::sync_with_stdio (0), cin.tie (0), cout.tie (0);
    cin >> n;
    for (int i = 1;i <= n;i ++) {
        for (int j = 1;j <= n;j ++) {
            cin >> ok[i][j];
        }
    }dp[0][0] = 1;
    for (int i = 0;i < n;i ++) {
        for (int mask = 0;mask < (1 << n);mask ++) {
            if (__builtin_popcount (mask) != i)continue;
            int check;
            for (int bit = 0;bit < n;bit ++) {
                if (!(mask & (1 << bit)) && ok[i + 1][bit + 1]) {
                    dp[i + 1][mask ^ (1 << bit)] = (dp[i + 1][mask ^ (1 << bit)] + dp[i][mask]) % mod;
                }
            }
        }
    }
    cout << dp[n][(1 << n) - 1];
}


Measured memory_bytes: 178432
import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())
dp = [[0] * (M + 1) for _ in range(N + 1)]
for i in range(N + 1):
  for j in range(M + 1):
    dp[i][j] = i * M + j * N - 2 * i * j
    if dp[i][j] == K:
      print("Yes")
      exit(0)
print("No")

Measured memory_bytes: 46704
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        t: chars
    }
    let s: String = t.iter().map(|&c| if c == '?' {'D'} else {c}).collect();
    println!("{}", s);
}


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

using namespace std;
typedef long long ll;
ll n,m,ans;
bool check(ll x)
{
	ll tm=m,tn=n;
	if(tn>x)
	{
		tn-=x; tm-=x*2;
		if(tm<0) return 0;
		else return 1;
	}
	else
	{
		x-=tn; tm-=tn*2;
		if(tm<0) return 0;
		tn=0;
		x-=tm/4;
		if(x<=0) return 1;
	}
	return 0;
}
int main()
{
	scanf("%lld%lld",&n,&m);
	ll l=0,r=n+m/2;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(check(mid)) l=mid+1,ans=mid;
		else r=mid-1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  cin >> n;

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

  map<ll, ll> dp;
  for (int i = 0; i < n; i++) {
    for (int num = -100; num <= 100; num++) {
      int v = (num - a[i]) * (num - a[i]);

      dp[num] += v;
    }
  }

  ll ans = 1e9;
  for (auto p : dp) {
    ans = min(ans, p.second);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() 
{
  int N;
  cin >> N;
  
  if(N%2!=0){
  cout << "No" << endl;
    return 0;
  }
  char S[N];
  rep(i, N)
  cin >>S[i];
  rep(i, N/2){
  if(S[i]!=S[i+N/2]){
  cout << "No" << endl;
    return 0;  
  }
  }
  cout << "Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector< vector<int> > Graph;
vector< int > value;









int main(int argc, const char * argv[]) {
    
   
    
    ll n; cin >> n;
    ll ans = (n)*(n-1)/2;
    
    cout << ans << endl;
    
    


    
    

    
}


Measured memory_bytes: 256