akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int q;
    vector<int> v;
    scanf ("%d", &n);
    int S[n];
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    sort (S, S + n);
    
    
    scanf ("%d", &q);
    int T[q];
    
    for (int i = 0; i < q; i++) {
        scanf("%d", &T[i]);
    }
    
    sort (T, T + q);
    
    set_intersection(S, S + n, T, T + q, back_inserter(v));
    printf("%d\n",(int)v.size());
       
    
    return 0;
    
}


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

void put_nchar(char c, int n)
{
	while (n-- > 0)
		cout << c;
}

int main()
{
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		put_nchar('#', W);
		cout << endl;
		for (int i = 0; i < H - 2; i++)
		{
			put_nchar('#', 1);
			put_nchar('.', W - 2);
			put_nchar('#', 1);
			cout << endl;
		}
		put_nchar('#', W);
		cout << endl;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>

int main()
{
	int n;
	int r;
	int k;
	scanf("%d %d",&k,&r);
	
	if(k>=10){
		printf("%d",r);
	}
	else{
		n= 100*(10-k);
		printf("%d",n+r);
	}
	
	return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n;
    cin>>n;
    if(n%2 ==1)cout << 0 << endl;
    else {
        ll num = 10;
        ll ret = 0;
        while(num <= n){
            ret += n/num;
            num *=5;
        }
        cout << ret << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto S = readln.chomp.map!(a => a == 'A').array;
    foreach (i; 0..N) S ~= [0, 1];

    int p = 0;
    bool flip = false;

    while (p < N && K > 0) {
        int c = S[p] ^ flip;
        if (c) { // 先頭がA
            K -= 1;
            S[p] ^= 1;
        } else {
            p += 1;
            flip ^= 1;
            K -= 1;
        }
    }


    auto ans = new int[](N);

    if (K == 0) {
        foreach (i; 0..N) ans[i] = S[p+i] ^ flip;
    } else if (N % 2 == 0) {
        foreach (i; 0..N) ans[i] = i % 2;
    } else {
        ans[0] = S[p] ^ flip ^ (K % 2);
        foreach (i; 1..N) ans[i] = 1 - i % 2;
    }

    ans.map!(a => a ? 'A' : 'B').writeln;
}


Measured memory_bytes: 5500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define db double

db solve(pair<db,db> a, pair<db,db> b){
    return sqrt((b.f - a.f)*(b.f - a.f) + (b.s - a.s)*(b.s - a.s));
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    pair<db,db> p[n];
    
    for(int i=0; i<=n; i++){
        cin>>p[i].first>>p[i].second;
    }
    
    vector<int> v(n);
    for(int i=0; i<n; i++) v[i]=i;
    
    int count=0;
    db sum=0;
    do{
        count++;
        for(int i=1; i<n; i++) sum+=solve(p[v[i-1]], p[v[i]]);
    }
    while(next_permutation(v.begin(), v.end()));
    sum/=count;
    cout<<setprecision(10)<<sum<<"\n";
    return 0;
}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

string S;
int N;

LL C(int& i, VS& order);
LL D(int& i, VS& order);
LL E(int& i, VS& order);
LL F(int& i, VS& order);

LL C(int& i, VS& order){
  LL res = D(i, order);
  while(i < N && order[0].find(S[i]) != string::npos){
	char op = S[i];
	++i;
	LL res2 = D(i, order);
	switch(op){
	case '+':
	  res += res2;
	  break;
	case '-':
	  res -= res2;
	  break;
	case '*':
	  res *= res2;
	  break;
	}
  }
  return res;
}
LL D(int& i, VS& order){
  LL res = E(i, order);
  while(i < N && order[1].find(S[i]) != string::npos){
	char op = S[i];
	++i;
	LL res2 = E(i, order);
	switch(op){
	case '+':
	  res += res2;
	  break;
	case '-':
	  res -= res2;
	  break;
	case '*':
	  res *= res2;
	  break;
	}
  }
  return res;
}
LL E(int& i, VS& order){
  LL res = F(i, order);
  while(i < N && order[2].find(S[i]) != string::npos){
	char op = S[i];
	++i;
	LL res2 = F(i, order);
	switch(op){
	case '+':
	  res += res2;
	  break;
	case '-':
	  res -= res2;
	  break;
	case '*':
	  res *= res2;
	  break;
	}
  }
  return res;
}

LL F(int& i, VS& order){
  LL res = 0;
  if(S[i] == '('){
	++i;
	res = C(i, order);
	++i;
  }
  else{
	while(i < N && isdigit(S[i])){
	  res = res * 10 + (S[i]-'0');
	  ++i;
	}
  }

  return res;
}

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

  cin >> S;
  N = SZ(S);
  LL ans = 1ll<<63;

  REP(i1,3){
	REP(i2,3){
	  REP(i3,3){
		int i = 0;
		VS ops(3);
		ops[i1] += "+";
		ops[i2] += "-";
		ops[i3] += "*";
		maxi(ans, C(i,ops));
	  }
	}
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
char S[maxn],T[maxn];
int ps[maxn],pt[maxn];
int main(){
    int q;
    scanf("%s%s%d",S+1,T+1,&q);
    int ls=strlen(S+1),lt=strlen(T+1);
    for(int i=1;i<=ls;i++){
        if(S[i]=='A') ps[i]=ps[i-1]+1;
        else ps[i]=ps[i-1]+2;
    }
    for(int i=1;i<=lt;i++){
        if(T[i]=='A') pt[i]=pt[i-1]+1;
        else pt[i]=pt[i-1]+2;
    }
    int a,b,c,d;
    while(q--){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        int s1=ps[b]-ps[a-1],s2=pt[d]-pt[c-1];
        if(s1%3!=s2%3) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;
using P = pair<int, int>;
using VP = vector<P>;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//map<int,int>mp;
int ar[20000005];
int main()
{
    int n,i,j,c=1;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+n);
    for(i=1; i<n; i++)
    {

        if(ar[i]==ar[i-1])
        {
            c=0;
            break;
        }
    }
    if(c==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}
struct BMatch {
    const vector<vector<int>>& g;
    const int n;
    vector<int> match;
    vector<bool> used;

    BMatch(const vector<vector<int>>& g_) : g(g_), n(g_.size()) { }

    bool dfs(int v) {
        used[v] = true;
        for (int i = 0; i < g[v].size(); i++) {
            int u = g[v][i], w = match[u];
            if (w < 0 || !used[w] && dfs(w)) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

    int solve() {
        match.assign(n, -1);
        used.assign(n, false);
        int res = 0;
        for (int v = 0; v < n; v++) {
            if (match[v] < 0) {
                used.assign(n, false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }
};

int main() {
    int n;
    cin >> n;
    vector<P> red(n), blue(n);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        red[i] = { x,y };
    }
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        blue[i] = { x,y };
    }
    vector<vector<int>> graph(2*n);
    rep(i, n) {
        rep(j, n) {
            auto r = red[i];
            auto b = blue[j];
            if (r.first < b.first && r.second < b.second) {
                graph[i].push_back(n + j);
                graph[n+j].push_back(i);
            }
        }
    }
    BMatch match(graph);
    auto ans = match.solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int main()
{
	LL n,x;
	LL siz[52],eat[52];
	siz[0]=eat[0]=1;
	scanf("%lld%lld",&n,&x);
	LL ans=0;
	for(int i=1;i<=n;i++)
	{
		siz[i]=siz[i-1]*2+3;
		eat[i]=eat[i-1]*2+1;
	}
	for(int i=n;i>=0;i--)
	{
		 if(x==0)
			break;
		if(x==siz[i])
		{
			ans+=eat[i];
			break;
		}
		if(x==1)
            break;
		if(x<=(siz[i-1]+1))
		{
			x--;
		}
		else
		{
          ans+=(eat[i-1]+1);
			x-=(siz[i-1]+2);
		}
	}
	printf("%lld\n",ans);
    return 0;
}

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

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    string n;
    int m = 0;
    cin >> n;
    for (auto &&x : n) {
        m += x - '0';
    }
    if(m == (n.length()-1)*9+n[0]-'0'){
        cout << (n.length()-1)*9+n[0]-'0' << "\n";
    }else {
        cout << (n.length()-1)*9+n[0]-'0'-1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    int a,b,d,r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = (double)a/b;
    cout << fixed << setprecision(15) << d << " " << r << " " << f << "\n";
    
    return 0;
}


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

int main(){
    int h, w;
    while(1){
        cin >> h >> w;
        if(h==0 && w==0){
            break;
        }
        for(int i=1;i<=w;i++){
            cout<<"#";
        }
        cout<<endl;
        for(int i=1;i<=h-2;i++){
            cout<<"#";
            for(int j=1;j<=w-2;j++){
                cout<<".";
            }
            cout<<"#"<<endl;
        }
        for(int i=1;i<=w;i++){
            cout<<"#";
        }
        cout<<endl;
        cout<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 2992
using System;

class Program
{
  static void Main()
  {
	string line = Console.ReadLine().Trim();
    char[] array = line.ToCharArray();
    
    int count = 0;
    for (int i = 0; i < array.Length / 2; i++)
    {
      if (line[i] == array[array.Length - 1 - i]) continue;
      array[array.Length - 1 - i] = line[i];
      count++;
    }
    
    Console.WriteLine(count);
  }
}



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

int main(){
     ll i, j, k;
     ll n;
     cin >> n;
     string ans="";
     while(n){
          k=n%26LL;
          n/=26LL;
          if(k) ans+=char('a'+(k-1));
          else ans+='z', n--;
     }
     reverse(ans.begin(), ans.end());
     cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 500 + 50;
const int INF = 10 * MAXN;
char a[MAXN][MAXN];

int main() {
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
		scanf("%s", a[i] + 1);
	int full_col = 0;
	for(int j = 1; j <= N; j++) {
		bool full = true;
		for(int i = 1; i <= N; i++)
			if(a[i][j] != '#')
				full = false;
		if(full)
			full_col++;
	}
	bool full_row = false;
	for(int i = 1; i <= N; i++) {
		bool full = true;
		for(int j = 1; j <= N; j++)
			if(a[i][j] != '#')
				full = false;
		if(full)
			full_row = true;
	}
	int ans = INF;
	if(!full_row) {
		debug("!\n");
		for(int t = 1; t <= N; t++) { // make row t filled
			bool pos = false;
			for(int i = 1; i <= N; i++)
				if(a[i][t] == '#')
					pos = true;
			int cnt = 0;
			if(!pos) cnt += 1;
			for(int j = 1; j <= N; j++)
				if(a[t][j] != '#')
					cnt++;
			if(cnt > N) continue;
			ans = min(ans, cnt);
		}
	}
	else
		ans = 0;
	ans += N - full_col;
	if(ans >= INF) ans = -1;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int D;
	scanf("%d", &D);
	int c[26], s[D][26], last[26], ans[D];
	for (int i = 0; i < 26; ++i) scanf("%d", &c[i]);
	for (int i = 0; i < D; ++i) {
		for (int j = 0; j < 26; ++j) scanf("%d", &s[i][j]);
	}
	fill_n(last, 26, -1);
	for (int i = 0; i < D; ++i) {
		int x = -1000000000, opt = 0;
		for (int j = 0; j < 26; ++j) {
			if (c[j] * (i - last[j] + 13) + s[i][j] > x) x = c[j] * (i - last[j] + 13) + s[i][j], opt = j;
		}
		last[opt] = i;
		ans[i] = opt;
	}
	for (int i = 0; i < D; ++i) printf("%d\n", ans[i] + 1);
	return 0;
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 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 kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n;
vector<int>a(222222), b(222222);
int x(int y) {
	return (y + n) % n;
}
int f(vector<int>&v) {
	queue<int>que;
	rep(i, n) {
		if (v[x(i - 1)] + v[x(i + 1)] < v[i]) {
			que.push(i);
		}
	}
	int res = 0;
	while (!que.empty()) {
		int i = que.front(); que.pop();
		if (v[i] % (v[x(i - 1)] + v[x(i + 1)]) == 0) {
			int memo= v[i] / (v[x(i - 1)] + v[x(i + 1)]) - 1;
			res += memo;
			v[i] -= (v[x(i - 1)] + v[x(i + 1)]) * memo;
		}
		else {
			res += v[i] / (v[x(i - 1)] + v[x(i + 1)]);
			v[i] %= v[x(i - 1)] + v[x(i + 1)];
		}
		if (v[x(i - 1)] > v[i] + v[x(i - 2)])que.push(x(i - 1));
		if (v[x(i + 1)] > v[i] + v[x(i + 2)])que.push(x(i + 1));
	}
	return res;
}
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	int an1 = f(a), an2 = f(b);
	rep(i, n) {
		if (a[i] != b[i]) {
			cout << -1 << endl; return 0;
		}
	}
	cout << an2 - an1 << endl;
}


Measured memory_bytes: 4584
MOD = int(1e9 + 7)
N, K = map(int, input().split())
ans = 0
for k in range(K, N+2):
    maximum = (N+1)*(N+2)//2 - (N+1-k)*(N+2-k)//2
    minimum = k*(k+1)//2
    ans += (maximum - minimum +1)%MOD
print(ans%MOD)

Measured memory_bytes: 9224
#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 x;
  cin >> x;
  string ans = x >= 30 ? "Yes" : "No";
  cout << ans << endl;
}


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

num = 0
for i in range(1, N):
  while A[i] < A[i-1] and i-1 >= 0:
    temp = A[i-1]
    A[i-1] = A[i] 
    A[i] = temp
    i -= 1
    num += 1
 
print(*A)
print(num)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,K;
    cin >> N >> K;
    long long t,d,cmax,c,x;
    set<long long> used;
    vector<pair<long long, long long>> v(N);
    for (int i=0;i<N;i++) {
        cin >> t >> d;
        v[i] = make_pair(d,t);
    }

    priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,  greater<pair<long long, long long>>> dup;
    priority_queue<pair<long long, long long>> unused;
    sort(v.begin(), v.end(), greater<pair<long long, long long>>());
    c = 0;
    for (int i=0;i<N;i++) {
        if (i<K) {
            c += v[i].first;
            if (used.find(v[i].second) == used.end()) {
                used.insert(v[i].second);
            } else {
                dup.push(v[i]);
            }
        } else {
            unused.push(v[i]);
        }
    }
    x = used.size();
    c += x * x;
    
    cmax = c;
    while (unused.empty() == false && dup.empty() == false ) {
        auto p_add = unused.top();
        unused.pop();
        if (used.find(p_add.second) == used.end()) {
            used.insert(p_add.second);
            auto p_del = dup.top();
            dup.pop();
            x++;
            c += p_add.first - p_del.first + 2*x-1;
            if (cmax < c) {
                cmax = c;
            }
        }
    }
    cout << cmax << '\n';
}

Measured memory_bytes: 5752
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 

 
int main()
{
    char S[11];
  
 // 整数の入力
    scanf("%s", &S);
 // printf("%d\n",N);

    printf("2018%s\n", &S[4]);
    return 0;
}


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

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    k: usize,
    x: usize
    }
    let ans = if k * 500 >= x {"Yes"} else {"No"};
    println!("{}", ans);
}



Measured memory_bytes: 2084
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = 1;
        for(int i = 1; i <= x; i++){
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        }
        System.out.println(z);
    }  
}


Measured memory_bytes: 26308
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int now = 0;
  while(1) {
    if (now == 0) {
      if (a.size() == 0) break;
      now = a[0] - 'a';
      a = a.substr(1);
    } else if (now == 1) {
      if (b.size() == 0) break;
      now = b[0] - 'a';
      b = b.substr(1);
    } else {
      if (c.size() == 0) break;
      now = c[0] - 'a';
      c = c.substr(1);
    }
  }
  cout << (char)('A' + now) << endl; 
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        char[] cs = input.nextLine().toCharArray();
        int d = 'A' - 'a';
        for (int i = 0; i < cs.length; i++) {
            if ('A' <= cs[i] && cs[i] <= 'Z') {
                cs[i] -= d;
            } else if ('a' <= cs[i] && cs[i] <= 'z') {
                cs[i] += d;
            }
        }
        System.out.println(cs);
    }
}

Measured memory_bytes: 17140
#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>

#include <string.h>

using namespace std;

typedef long long ll;

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

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

const int MAX_S = 10;

ll solve(const int orig_bits, const int slen, const char *s) {
    ll acc = 0LL;
    ll current = 0LL;
    int bits = orig_bits;
    const char *p = s;
    while (bits > 0) {
        current = current * 10 + ((*p) - '0');
        if (bits & 1) {
            acc += current;
            current = 0LL;
        }
        p++;
        bits >>= 1;
    }
    if (((intptr_t) p) - ((intptr_t) s) < slen) {
        while (*p != 0) {
            current = current * 10 + ((*p) - '0');
            p++;
        }
        acc += current;
    }

    // cout << bitset<8>(orig_bits) << "," << acc << endl;
    return acc;
}

int main(void) {
    char S[MAX_S + 1];
    cin >> S;
    int len = strlen(S);

    ll acc = 0;
    for (int bits = 0; bits < 1 << (len - 1); bits++) {
        acc += solve(bits, len, S);
    }

    cout << acc << endl;
    
    return 0;
}


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

#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define ms memset
#define mp make_pair
#define f first
#define s second
#define int long long

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef pair<int, pair<int, int>> piii;

#define MAXN 100010


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

	int x;

	cin >> x;

	cout << (x == 1 ? 0 : 1) << "\n";
	
	return 0;	
}

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

using namespace std;
int main()
{
  string S, T;

  cin >> S >> T;

  if (T.find(S) == 0 && S.length() + 1 == T.length())
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    string s;
    cin >> s;
    int n=s.length();
    bool ans=true;
    if(s[0]!='A')ans=false;
    bool c=false;
    rep(i,n){
        if(i==0)continue;
        if(s[i]-'a'<0){
            if(s[i]!='C')ans=false;
            else{
                if(2<=i && i!=n-1 && !c)c=true;
                else ans=false;
            }
        }
    }
    if(ans && c)cout << "AC";
    else cout << "WA";


    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
 
vvi edge;
vi prenum;
vi lowest;
vi parent;
int timer;
 
void dfs(int u, int prev) {
  prenum[u] = timer;
  lowest[u] = timer;
  timer += 1;
 
  for (auto v : edge[u]) {
    if (prenum[v] < 0) {
      parent[v] = u;
      dfs(v, u);
      lowest[u] = min(lowest[u], lowest[v]);
    } else {
      lowest[u] = min(lowest[u], prenum[v]);
    }
  }
}
 
int main() {
  int v, e;
  cin >> v >> e;
  edge.resize(v);
  prenum.resize(v, -1);
  lowest.resize(v);
  parent.resize(v);
  rep (i, e) {
    int s, t;
    cin >> s >> t;
    edge[s].pb(t);
    edge[t].pb(s);
  }
  timer = 0;
  dfs(0, -1);
 
  int zero_parent = 0;
  set<int> ans;
  FOR(i, 1, v) {
    if (parent[i] == 0) {
      zero_parent += 1;
    } else {
      if (prenum[parent[i]] <= lowest[i]) {
        ans.insert(parent[i]);
      }
    }
  }
  if (zero_parent >= 2) {
    ans.insert(0);
  }
  for (auto i : ans) {
    printf("%d\n", i);
  }
 
  return 0;
}

Measured memory_bytes: 4520
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, bool> pib;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<double> vf;

typedef long double ld;

#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

#define printItr(A) for(auto itr = A.begin(); itr != A.end(); ++itr){cout << * itr << ", ";}cout << endl;

const double PI = 3.141592653589793;

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

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

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	ll N;
	cin >> N;
	ll count = 0;

	vector<vector<pii>> S(N, vector<pii>());
	rep(i, N) {
		ll A; cin >> A;
		rep(a, A) {
			ll x, y;
			cin >> x >> y;
			x--;
			S[i].pb(mp(x, y));
		}
	}

	ll n = 1;
	rep(i, N) {
		n *= 2;
	}
	
	rep(nn, n) {
		// judge
		bool flag = true;
		rep(i, N) {
			// 1は正直
			if ((nn & (1 << i)) != 0) {
				for (auto a : S[i]) {
					bool real = ((nn & (1 << a.first)) != 0);
					if (real != a.second) {
						flag = false;
					}
				}
			}
		}

		if (flag == false) {
			continue;
		}

		// count
		ll c = 0;
		rep(i, N) {
			// 1は正直
			if ((nn & (1 << i)) != 0) {
				c++;
			}
		}
		if (count < c) {
			count = c;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.IntMap.Strict as M
import Data.Foldable
 
favo 1 = M.singleton 1 0
favo n
  | odd n = M.insert n 0 f
  | even n = M.insert n v f
    where
    f = favo $ n - 1
    v = f M.! (n `div` 2) + 1
 
findKeyAtMax = fst . foldr1 f . M.toList
  where
  f (k, v) (j, u)
    | v > u = (k, v)
    | otherwise = (j, u)
 
main = do
  n <- readLn
  print . findKeyAtMax $ favo n

Measured memory_bytes: 508
#include <iostream>
using namespace std;
int main(){
    int n, y;
    cin >> n >> y;
    for(int m=0; m<=n; m++){
        for(int g=0; g<=n-m; g++){
            if(10000*m+5000*g+1000*(n-m-g)==y){
                cout << m << " " << g << " " << n-m-g << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

/*template*/
int main() {
	ll N; cin >> N;
	ll a[100001] = {};
	ll sum = 0;
	repe(i, 1, N) {
		ll A; cin >> A;
		a[i] = A;

		sum += ((i == 1) ? abs(a[i]) : abs(a[i] - a[i - 1]));
	}
	sum += abs(a[N]);
	repe(i, 1, N) {
		ll t = 0;
		t = sum - (abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]));
		t += abs(a[i + 1] - a[i - 1]);
		cout << t << endl;
	}

	return 0;
}

Measured memory_bytes: 2048
#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>;

const int mx = 100005;

int main(){
	int n;
	cin >> n;
	vector<ll> cnt(mx);
	rep(i,n){
		int a;
		cin >> a;
		cnt[a]++;
	}
	ll tot = 0;
	rep(i,mx) tot += i*cnt[i];

	int q;
	cin >> q;
	rep(i,q){
		int b,c;
		cin >> b >> c;
		tot -= b*cnt[b];
		tot -= c*cnt[c];
		cnt[c] += cnt[b]; cnt[b] = 0;
		tot += b*cnt[b];
		tot += c*cnt[c];
		cout << tot << endl;
	}
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int K,A,B;  cin>>K>>A>>B;
  for(int i=A ; i<=B ; i++){
    if(i%K==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
  return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
vector<vector<int> > u;
vector<vector<int> > sums;
vector<vector<vector<vector<i_i> > > > memo;
int h, w, s;
int sum;

i_i rec(i_i lu, i_i rd) {
	if(memo[lu.first][lu.second][rd.first][rd.second].first != INF) return memo[lu.first][lu.second][rd.first][rd.second];
	else {
		int sub = s - (sum - (sums[rd.first + 1][rd.second + 1] - sums[(lu.first + 1) - 1][rd.second + 1]
						 - sums[rd.first + 1][(lu.second + 1) - 1] + sums[(lu.first + 1) - 1][(lu.second + 1) - 1]));
		if(sub < 0) {
			return memo[lu.first][lu.second][rd.first][rd.second] = i_i(-1, -1);
		}
		i_i res = i_i(-1, -1);
		REP(i, rd.first - lu.first) {
			i_i lset = rec(lu, i_i(lu.first + i, rd.second));
			i_i rset = rec(i_i(lu.first + 1 + i, lu.second), rd);
			if(lset.first != -1 && rset.first != -1) {
				res = max(res, i_i(lset.first + rset.first, min(lset.second, rset.second)));
			}
		}
		REP(i, rd.second - lu.second) {
			i_i lset = rec(lu, i_i(rd.first, lu.second + i));
			i_i rset = rec(i_i(lu.first, lu.second + 1 + i), rd);
			if(lset.first != -1 && rset.first != -1) {
				res = max(res, i_i(lset.first + rset.first, min(lset.second, rset.second)));
			}
		}
		if(res.first != -1) return memo[lu.first][lu.second][rd.first][rd.second] = res;
		else {
			return memo[lu.first][lu.second][rd.first][rd.second] = i_i(1, sub);
		}
	}
}

int main(void) {
	while(true) {
		cin>>h>>w>>s;
		if(h == 0 && w == 0 && s == 0) break;
		sum = 0;
		u.resize(h);
		REP(i, h) u[i].resize(w);
		REP(i, h) {
			REP(j, w) {
				cin>>u[i][j];
				sum += u[i][j];
			}
		}
		sums.resize(h + 1);
		REP(i, h + 1) sums[i].resize(w + 1);
		REP(i, h + 1) {
			REP(j, w + 1) {
				if(i == 0 || j == 0) sums[i][j] = 0;
				else {
					sums[i][j] = u[i - 1][j - 1];
				}
			}
		}
		REP(i, h + 1) {
			REP(j, w + 1) {
				if(j == 0) continue;
				sums[i][j] += sums[i][j - 1];
			}
		}
		REP(j, w + 1) {
			REP(i, h + 1) {
				if(i == 0) continue;
				sums[i][j] += sums[i - 1][j];
			}
		}
		memo.resize(h);
		REP(i, h) {
			memo[i].resize(w);
			REP(j, w) {
				memo[i][j].resize(h);
				REP(k, h) {
					memo[i][j][k].resize(w);
					REP(l, w) {
						memo[i][j][k][l] = i_i(INF, INF);
					}
				}
			}
		}
		i_i ans = rec(i_i(0, 0), i_i(h - 1, w - 1));
		cout<<ans.first<<" "<<ans.second<<endl;
	}
}

Measured memory_bytes: 18096
S = input()

if S[0] == 'A':
    if S[2:-1].count('C') == 1:
        t = S.find('C')
        if S[1:t].islower() and S[t+1:].islower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#define DBL_MIN 0.000000000000001
#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;



int main(void){
  unsigned int x;
  cin >> x;
  cout <<( x ^ 1) << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

v<pi> A;


void solve()
{
    cin>>n;
    forn(i,1,n)
    {
    	int a,b;
    	cin>>a>>b;
    	A.pb({a+b,a-b});
    }
    sort(all(A));

    multiset<int>dc;
    int ans = 0;
    int x = -MOD*MOD;
    for(auto i : A)
    {
    	if(i.Y<x)
    	{
    		continue;
    	}
    	else
    	{
    		ans++;
    		x = i.X;
    	}
    }
    cout<<ans;
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, k, x[50], y[50], xx[50], yy[50];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> x[i] >> y[i]; xx[i] = x[i]; yy[i] = y[i]; }
	
	sort(xx, xx + n);
	sort(yy, yy + n);
	
	LL ans = 4e18;
	inc(xh,  n) {
	inc(xl, xh) {
	inc(yh,  n) {
	inc(yl, yh) {
		int c = 0;
		inc(i, n) {
			if(inII(x[i], xx[xl], xx[xh]) && inII(y[i], yy[yl], yy[yh])) { c++; }
		}
		if(c >= k) { setmin(ans, (xx[xh] - xx[xl]) * (yy[yh] - yy[yl])); }
	}
	}
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int N, W;
ll w[110], v[110], INF = 1000000000000, dp[100100], V_SUM, ans = 0;

int main(){
	cin >> N >> W;
	for (int i = 0; i < N; i++)cin >> w[i] >> v[i], V_SUM += v[i];
	for (int i = 0; i <= V_SUM; i++)dp[i] = INF;
	dp[0] = 0;
	for (int i = 0; i < N; i++){
		for (int j = V_SUM; j >= 0 && j >= v[i]; j--){
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	for (int i = 0; i <= V_SUM; i++)ans = (dp[i] <= W ? i : ans);
	cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0; i<N; i++) cin >> d.at(i);
  sort(d.begin(), d.end());
  int ans=1;
  for(int i=0; i<N-1; i++){
    if(d.at(i)<d.at(i+1)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
if n < m:
    print('NO')
    exit(0)
dcnt = {}
for x in d:dcnt[x] = 0
ok = True
for x in d:dcnt[x]+=1
for i in range(m):
    if t[i] not in dcnt:
        ok = False
        break
    if dcnt[t[i]] == 0:
        ok = False
        break
    dcnt[t[i]] -= 1
if ok:print('YES')
else:print('NO')


Measured memory_bytes: 127572
class Scanner {
    private var stack = [String]()
    private var index = 0
    
    func peek() -> String {
        if stack.count == index {
            stack += readLine()!.split(separator: " ").map{ String($0) }
        }
        return stack[index]
    }
    
    func next() -> String {
        let value = peek()
        index += 1
        return value
    }
    
    func nextInt() -> Int {
        return Int(next())!
    }
    
    func nextDouble() -> Double {
        return Double(next())!
    }
}

var scanner = Scanner()

let X = scanner.nextInt()
let Y = scanner.nextInt()

if (0 ... X).contains(where: { i in let j = X - i; return 2 * i + 4 * j == Y }) {
    print("Yes")
} else {
    print("No")
}


Measured memory_bytes: 7824
#include <iostream>
#include <algorithm>
#include <stack>
#include <utility>
#include <queue>
using namespace std;

const int H = 8, W = 8, C = 6;

struct State{
	int board[H + 2][W + 2];
};

typedef pair<int, int> P;

State duplicate(State& s){
	State d;
	for(int i = 0;i <= H + 1;++i){
		for(int j = 0;j <= W + 1;++j){
			d.board[i][j] = s.board[i][j];
		}
	}
	return d;
}

void paint(State& s, int c){
	int cc = s.board[1][1];
	int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, 1, -1};
	int visited[H + 2][W + 2] = { { 0 } };
	stack<P> st;
	st.push(make_pair(1, 1));
	while(!st.empty()){
		P p = st.top();
		st.pop();
		s.board[p.first][p.second] = c;
		visited[p.first][p.second]++;
		for(int i = 0;i < 4;++i){
			int y = p.first + dy[i], x = p.second + dx[i];
			if(!visited[y][x] && s.board[y][x] == cc) st.push(make_pair(y, x));
		}
	}
	return;
}

int count(State& s){
	int c = s.board[1][1];
	int count = 0;
	int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, 1, -1};
	int visited[H + 2][W + 2] = { { 0 } };
	stack<P> st;
	st.push(make_pair(1, 1));
	while(!st.empty()){
		P p = st.top();
		st.pop();
		visited[p.first][p.second]++;
		for(int i = 0;i < 4;++i){
			int y = p.first + dy[i], x = p.second + dx[i];
			if(!visited[y][x] && s.board[y][x] == c) st.push(make_pair(y, x));
		}
	}
	for(int i = 1;i <= H;++i){
		for(int j = 1;j <= W;++j){
			count += visited[i][j] > 0;
		}
	}
	return count;
}

int search(State init, int t){
	// P(area nuber, process count)
	int c = 0;
	queue<pair<State, int> > q;
	q.push(make_pair(init, 0));
	while(!q.empty()){
		pair<State, int> p = q.front();
		q.pop();
		State s = p.first;
		int now = p.second;
		if(now < 5){
			for(int i = 0;i < C;++i){
				State n = duplicate(s);
				paint(n, i + 1);
				q.push(make_pair(n, now + 1));
			}
		}
		else{
			if(s.board[1][1] == t){
				int cnt = count(s);
				c = max(c, cnt);
			}
		}
	}
	return c;
}


int main(){
	int h, w, c;
	State s;
	while(cin >> h >> w >> c, h){
		fill(s.board[0], s.board[W + 2], -1);
		for(int i = 1;i <= h;++i){
			for(int j = 1;j <= w;++j){
				cin >> s.board[i][j];
			}
		}
		cout << search(s, c) << endl;
	}
}

Measured memory_bytes: 4368
# -*- coding: utf-8 -*-
import numpy as np
import itertools

# input
l = list(map(int, input().split()))
N = l[0]

l = list(map(int, input().split()))
V = l

l = list(map(int, input().split()))
C = l

best_result = 0

# 総選択数 n

for n in range(N+1):
    v_list = list(itertools.combinations(V,n));
    c_list = list(itertools.combinations(C,n));
    for v, c in zip(v_list, c_list):
        X = sum(v)
        Y = sum(c)

        result = X - Y

        # Renew
        if best_result <= result:
            best_result = result

print(best_result)


Measured memory_bytes: 88156
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

i64 gcd(i64 a, i64 b) { return b ? gcd(b, a % b) : a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  cout << ::lcm(a, b);
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(){
  string s;
  string k;
  int i;
  int kk;
  int min = 100000;
  cin >> s;
  for(i=0;i<s.size()-2;i++){
    kk = (s[i] - '0')* 100 + (s[i+1] - '0')* 10 + (s[i+2] - '0');
    kk = abs(kk - 753);
    if(min > kk) min = kk;
  }
  cout << min << "\n";
  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;

int main() {
	int n, l;
	cin >> n >> l;
	vector<pair<int, int>> vec(n);
	for (int i = 0; i < n; i++) {
		vec.at(i).first = abs(l + i);
		vec.at(i).second = i;
	}
	sort(vec.begin(), vec.end());
	int pic = vec.at(0).second;
	int sum = n * (l + 1 - 1 + l + n - 1) / 2;
	int ans = sum - (l + pic);
	cout << ans;
}

Measured memory_bytes: 256
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	k = readline() |> parseInt
	a = Int[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
	println(a[k])
end

main()

Measured memory_bytes: 111840