akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

#define NUM 5

int main(void)
{
  int a[NUM], k;

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

  cin >> k;

  for (int i = 0; i < NUM; i++) {
    for (int j = 0; j < NUM; j++) {
      if (i == j) {
        continue;
      }
      if (abs(a[i] - a[j]) > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,D,X;
  cin>>N>>D>>X;
  int A[N],ans=0;
  REP(i,N){
    cin>>A[i];
    ans+=(D-1)/A[i];
  }
  cout<<ans+N+X<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll 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 * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int a[100010], n, m,ans;
signed main() {
	cin >> m >> n;
	rep(i, n)cin >> a[i];
	if (m == 2) {
		rep(i, n) {
			if (a[i] == 1 && i % 2 == 0)ans++;
			if (a[i] == 2 && i % 2 == 1)ans++;
		}
		int ans2 = 0;
		rep(i, n) {
			if (a[i] == 2 && i % 2 == 0)ans2++;
			if (a[i] == 1 && i % 2 == 1)ans2++;
		}
		cout << min(ans, ans2) << endl;
	}
	else {
		int cnt = 1;
		loop(i, 1, n) {
			if (a[i] != a[i - 1]) {
				ans += cnt / 2;
				cnt = 1;
			}
			else { cnt++; }
		}
		ans += cnt / 2;
		cout << ans << endl;
	}
}



Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int x; cin >> x;
    int r = x % 11;
    if(r == 0) r = 0;
    else if(r <= 6) r = 1;
    else r = 2;
    cout << 2 * (x / 11) + r << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    sx, sy, tx, ty = MII()
    x1 = tx-sx
    y1 = ty-sy
    go1 = 'U'*y1 + 'R'*x1
    bk1 = 'D'*y1 + 'L'*x1
    go2 = 'L'+'U'+go1+'R'+'D'
    bk2 = 'R'+'D'+bk1+'L'+'U'
    print(go1+bk1+go2+bk2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double l;
    cin >> l;
    l /= 3.0;
    printf("%0.10f\n",l*l*l);
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int count = 0;
  int ans = 0;
  for (int i=0; i<n; i++){
    cin >> a.at(i);
    count += a.at(i); 
  }
  for (int i=0; i<n; i++){
    if(a.at(i) >= 1.0 * count / 4 / m){
      ans++;
    }
  }
  if(m <= ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {


	int n,x;
	int a1[100001];
	int a2[100001]={};
	int t=0,e=1;

	cin>>n>>x;

	rep(i,n){
		cin>>a1[i];

	}

	a1[n]=x;
	sort(a1,a1 + n+1);
	rep(i,n){
		a2[i]=a1[i+1]-a1[i];
	}
	sort(a2,a2+n);

	for(int j=a2[0]; j>1; --j){
		t=0;
		for(int i=0; i<n; ++i){
			if(a2[i]%j==0){
				t+=1;
			}
		}

		if(t==n){
			e=j;

			break;
		}
	}

	cout<<e<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int n,x,y,keta[4],keta2[4],cnt,box,i,j,flg;
	while(1){
		scanf("%d",&n);
		flg=0;
		cnt=0;
		if(n==0000){
			break;
		}
		else{
		while(!(n==6174)){
		box=n;
		keta[0]=box%10;
		box=box/10;
		keta[1]=box%10;
		box=box/10;
		keta[2]=box%10;
		box=box/10;
		keta[3]=box;
		if(keta[0]==keta[1]&&keta[1]==keta[2]&&keta[2]==keta[3]){
			printf("NA\n");
			flg=1;
			break;
		}
		else{
			keta2[0]=keta[0];
			keta2[1]=keta[1];
			keta2[2]=keta[2];
			keta2[3]=keta[3];
			for(i=0;i<3;i++){
				for(j=i+1;j<4;j++){
					if(keta[i]<keta[j]){
						box=keta[i];
						keta[i]=keta[j];
						keta[j]=box;
					}
					if(keta2[i]>keta2[j]){
						box=keta2[i];
						keta2[i]=keta2[j];
						keta2[j]=box;
					}
				}
			}
			x=keta[0]*1000+keta[1]*100+keta[2]*10+keta[3];
			y=keta2[0]*1000+keta2[1]*100+keta2[2]*10+keta2[3];
			n=x-y;
			cnt++;
		}
	}
	if(flg==0){
	printf("%d\n",cnt);
	}
		}
	}
	return 0;
}


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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long A, P;
    scan(A, P);
    long x = A * 3 + P;
    writeln(x / 2);
}


Measured memory_bytes: 380
#include <stdio.h>

int main(){

  int n;
  int i;
  int a;
  int b;
  int ta;
  int tb;


  while(1){

    ta=0;
    tb=0;

    scanf("%d",&n);

    if(n==0){break;}

    for(i=0;i<n;i++){
      scanf("%d %d",&a,&b);
      if(a>b){
	ta+=(a+b);
      }
      else if(a<b){
	tb+=(a+b);
      }
      else if(a==b){
	ta+=a;
	tb+=b;
      }
    }

    printf("%d %d\n",ta,tb);

  }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
char k[100001];
int a, b, c, d;
int main(){
	cin >> k;
	int l = strlen(k);
	for(int i = 0 ; i < l ; i++){
		if(k[i] == 'N') a++;
		if(k[i] == 'S') b++;
		if(k[i] == 'E') c++;
		if(k[i] == 'W') d++;
	}
	int pd = 1;
	if(a != 0){
		if(b == 0){
			pd = 0;
		}
	}
	else if(a == 0){
		if(b != 0){
			pd = 0;
		}
	}
	if(c != 0){
		if(d == 0){
			pd = 0;
		}
	}
	else if(c == 0){
		if(d != 0){
			pd = 0;
		}
	}
	if(pd == 0){
		puts("No");
	}
	else{
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
num = [input().split() for _ in range(N)]
 
X = []
Y = []
count = 0
 
for n in num:
    X.append(int(n[0]))
    Y.append(int(n[1]))
 
for x, y in  zip(X, Y):
    dist = x**2 + y**2
    if dist <= D**2:
        count += 1
 
print(count)

Measured memory_bytes: 83588
import collections
import queue
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M = map(int, input().split())
        edges = [tuple(map(int, input().split())) for _ in range(M)]
        S, T = map(int, input().split())

        edge_map = collections.defaultdict(list)
        for u, v in edges:
            edge_map[u - 1].append(v - 1)

        q = queue.Queue()
        q.put((S - 1, 0))

        INF = 10 ** 5
        dist = [[INF] * 3 for _ in range(N)]
        dist[S - 1][0] = 0
        while not q.empty():
            node, kkp = q.get()

            for next_node in edge_map[node]:
                next_kkp = (kkp + 1) % 3
                if dist[next_node][next_kkp] == INF:
                    dist[next_node][next_kkp] = dist[node][kkp] + 1
                    q.put((next_node, next_kkp))

        if dist[T - 1][0] == INF:
            print(-1)
        else:
            print(dist[T - 1][0] // 3)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 92884
#include<bits/stdc++.h>
using namespace std;
#define maxn 510
int r[maxn];
int n;
double dis[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&r[i]);
	double ans=0.0;
	for(int i=0;i<n;i++){
		dis[i]=r[i]*1.0;
		for(int j=0;j<i;j++){
			int x=max(r[i],r[j]),y=min(r[i],r[j]);
			double tmp=sqrt((x+y)*(x+y)*1.0-(x-y)*(x-y)*1.0);
			dis[i]=max(dis[i],dis[j]+tmp);
		}
	}
	for(int i=0;i<n;i++){
		ans=max(ans,dis[i]+r[i]);
	}
	printf("%.8f\n",ans);
}


Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <cmath>

using namespace std;

const int MOD = 998244353;

typedef tuple<int, int, int> line;

int gcd(int a, int b){
    if(a == 0) return b;
    if(b == 0) return a;
    if(a < 0) a *= -1;
    if(b < 0) b *= -1;
    if(a < b) swap(a, b);
    while(b != 0){
        int tmp = b;
        b = a%b;
        a = tmp;
    }
    return a;
}

line norm(line l){
    int a = get<0>(l);
    int b = get<1>(l);
    int c = get<2>(l);
    if(a < 0){
        a *= -1;
        b *= -1;
        c *= -1;
    }
    if(a == 0 && b < 0){
        b *= -1;
        c *= -1;
    }
    int m = gcd(a, b);
    m = gcd(m, c);
    return make_tuple(a/m, b/m, c/m);
}

line calc_line(int x1, int y1, int x2, int y2){
    line ans = make_tuple(y2-y1, -(x2-x1), y1*x2-x1*y2);
    ans = norm(ans);
    return ans;
}

long pow2[201];

void init(){
    pow2[0] = 1;
    for(int i = 1; i <= 200; i++){
        pow2[i] = 2*pow2[i-1];
        pow2[i] %= MOD;
    }
}

void print_line(line l){
    cout << get<0>(l) << ' ' << get<1>(l) << ' ' << get<2>(l) << endl;
}

int main(){
    init();
    map<line, int> mp;
    int N;
    cin >> N;
    int x[200], y[200];
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++){
            line l = calc_line(x[i], y[i], x[j], y[j]);
            if(mp.count(l) == 0){
                mp[l] = 1;
            }else{
                mp[l]++;
            }
        }
    }
    long ans = pow2[N];
    ans -= (1+N);
    for(auto iter = mp.begin(); iter != mp.end(); iter++){
        int m = iter-> second;
        m = ((int)sqrt(2*m))+1;
        //cout << m << endl;
        ans -= (pow2[m]-m-1);
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main(){
	int N, A, B;
	while(cin >> N >> A >> B){
		int res = 0;
		for(int i=0;i<N;i++){
			int t; cin >> t;
			if(A <= t && t < B) continue;
			++res;
		}
		cout << res << endl;
	}
}


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

using namespace std;

int main(){
    int N,nfcnt=0,fcnt=0,a;
    bool res;
    scanf("%d",&N);
    
    for(int i=0;i<N;i++){
        scanf("%d",&a);
        if(a%2!=0)
            nfcnt++;
        else if(a%4==0)
            fcnt++;                
    }
    
    if(nfcnt+fcnt==N)
        res = nfcnt <= (fcnt+1);
    else
        res = nfcnt <= fcnt;    
    
    if(res)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i <= 3; i++) {
        if (s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e15)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)

const int mxn = 1*(1e5) + 5;
ll n;

int solve(){
	int t;
	int c=1;
	while(cin>>t) {
		if(t == 0) {
			cout<<c;
			return 0;
		}
		c++;
	}		
}
 
int main(){
	fast;
	// tt
		solve();
}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
  int k;
  cin >> k;
  
  int a,b;
  cin >> a >> b;
  
 for(int i=a; i<b+1; i++){
  if(i%k==0){
    cout << "OK" << endl;
    exit(0);
  }
 }
cout << "NG" << endl;
}

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

int main()
{
    int N;
    std::cin >> N;
    std::vector<long long> a(N);
    for(int i=0; i<N; i++) scanf(" %lld", &a[i]);

    // if(N % 3 != 0){
    //     std::cout << "No" << std::endl;
    //     return 0;
    // }

    std::sort(a.begin(), a.end());
    int j=0;
    int count[3];
    long long list[3];
    for(int i=0; i<3; i++){
        count[i] = 0; 
        list[i] = 0;
    }
    count[0]++;
    list[0] = a[0];
    for(int i=1; i<N; i++){
        if(a[i] == a[i-1]) count[j]++;
        else{
            j++;
            if(j == 3) break;
            count[j]++;
            list[j] = a[i];
        }
    }
    if(j == 3) std::cout << "No" << std::endl;
    else if(j == 2 && count[0] == count[1] && count[1] == count[2] && (list[0]^list[1]) == list[2])
        std::cout << "Yes" << std::endl;
    else if(j == 1 && N%3 == 0 && (count[0] == N/3 || count[1] == N/3) && a[0] == 0)
        std::cout << "Yes" << std::endl;
    else if(j == 0 && a[0] == 0) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 1024
#-*- coding:utf-8 -*-

n, k, q = map(int, input().split())
a_li = [int(input()) for i in range(q)]

b_li = [0]*n

for i in range(q):
    b_li[a_li[i]-1] += 1

for t in range(n):
    pt = k -q + b_li[t]
    if pt > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int n, e[110];

int num(int m) {
    int ret = 0;
    for (auto &x: e) {
        if (x >= m-1) ret++;
    }
    return ret;
}

int main() {
    cin >> n;

    for (int i = 2; i <= n; i++) {
        int cur = i;
        for (int j = 2; j <= i; j++) {
            while (cur % j == 0) {
                e[j] += 1;
                cur /= j;
            }
        }
    }

    int ans = num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#l=list(map(int, input().split()))
h,w,a,b=map(int, input().split())

point = w - a
hanten = h -b
for i in range(h):
        for j in range (w):
            if (i < hanten):
                if (j < point):
                    print("0", end="")
                else:
                    print("1", end="")
            else:
                if (j < point):
                    print("1", end="")
                else:
                    print("0", end="")

        print("")




Measured memory_bytes: 5360
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int arr[] = new int[101];
        for(int i = 1; i <= 100; i++) {
            if((a % i == 0) && (b % i == 0)) {
                arr[i] = i;
            }
        }
        int count = 0;
        for(int i = 100; i >= 0; i--) {
            if(arr[i] > 0) {
                count++;
            }
            if(count == k) {
                System.out.println(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
inline ll add(ll a, ll b){ return ((a%MOD)+(b%MOD))%MOD;}
inline ll mul(ll a, ll b){ return ((a%MOD)*(b%MOD))%MOD;}
inline ll sub(ll a, ll b){ return ((a%MOD)-(b%MOD)+MOD)%MOD;}
// const int N = 1e5+7;
 
#define deb(x) {x}
#ifndef local
    #define deb(x) ;
#endif
///---------------------------------------------------------------

inline int gcd(int a, int b) {
    while (a != 0 && b != 0) {
        if (a > b) {
            a %= b;
        } else {
            b %= a;
        }
    }
    return max(a, b);
}

void solve()
{
    int k;cin>>k;
    int ans=0;
    rep(i,1,k+1){
        rep(j,1,k+1){
            rep(l,1,k+1){
                ans+=gcd(i,gcd(j,l));
            }
        }
    }
    cout<<ans<<endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    #ifdef local
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
    int t=1;
    // cin>>t;
    rep(a,0,t)
    {
        // cout<<"Case #"<<a+1<<": ";
        solve();
    }

    // solve();
    
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;
    double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;
    cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "
    <<time_taken<<" seconds\n";}
    #endif
}

Measured memory_bytes: 3648
function lcm(a,b) {
  var g = (n, m) => m ? g(m, n % m) : n
  return a * b / g(a, b)
}

function Main(input) {
  const array = input.trim().split(' ').map(s => parseInt(s))
  const ans = lcm(array[0], array[1])

  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	snacks := io.ScanStrings(n)
	snackExistMap := map[string]bool{}
	for _, s := range snacks {
		snackExistMap[s] = true
	}
	
	if len(snackExistMap) == 3 {
		fmt.Println("Three")
	} else {
		fmt.Println("Four")
	}
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2176
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main () {
    int x = 0, n = 0;
    cin >> x >> n;
    if (x < n) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}


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

int main() {
    vector<char> bus(3);
    for (int i = 0; i < 3; i++) {
        cin >> bus.at(i);
    }
    if (bus.at(0) != bus.at(1) || bus.at(1) != bus.at(2))
        cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll total = 0;
  rep(i, n) total += a[i];
  set<ll> candidate;
  for (int i = 1; i*i <= total; i++) {
    if (total % i == 0) {
      candidate.insert(i);
      candidate.insert(total/i);
    }
  }
  ll ans = 1;
  for (ll d : candidate) {
    vector<ll> r(n);
    rep(i, n) r[i] = a[i] % d;
    sort(r.begin(), r.end());
    ll B = 0;
    rep(i, n) B += d - r[i];
    ll A = 0;
    ll need = 1e18;
    rep(i, n) {
      A += r[i];
      B -= d - r[i];
      need = min(need, max(A, B));
    }
    if (need <= k) {
      ans = max(ans, d);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

vi R[111111];
vi B[111111];
int ans[111111];
vi adj[111111];

void add_pair(int x, int y)
{
	adj[x].pb(y); adj[y].pb(x);
}

void calcred(int u, int p)
{
	ans[u]=1;
	for(int i=0;i<R[u].size();i++)
	{
		int v=R[u][i];
		if(v==p) continue;
		calcred(v,u);
		ans[u]^=1;
	}
}

void calcblue(int u, int p)
{
	int cur=1;
	for(int i=0;i<B[u].size();i++)
	{
		int v=B[u][i];
		if(v==p) continue;
		calcblue(v,u);
		cur^=1;
	}
	if(cur!=ans[u])
	{
		cout<<"IMPOSSIBLE\n"; exit(0);
	}
}

int matchred(int u, int p)
{
	int cur=-1; if(ans[u]) cur=u;
	for(int i=0;i<R[u].size();i++)
	{
		int v=R[u][i];
		if(v==p) continue;
		int tmp=matchred(v,u);
		if(tmp!=-1)
		{
			if(cur==-1) cur=tmp;
			else
			{
				add_pair(cur,tmp); cur=-1;
			}
		}
	}
	return cur;
}

int matchblue(int u, int p)
{
	int cur=-1; if(ans[u]) cur=u;
	for(int i=0;i<B[u].size();i++)
	{
		int v=B[u][i];
		if(v==p) continue;
		int tmp=matchblue(v,u);
		if(tmp!=-1)
		{
			if(cur==-1) cur=tmp;
			else
			{
				add_pair(cur,tmp); cur=-1;
			}
		}
	}
	return cur;
}

bool vis[111111];
void coloring(int u, int col)
{
	vis[u]=1; ans[u]=col;
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i];
		if(!vis[v])
		{
			coloring(v,col*-1);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	int rt1=0; int rt2=0;
	for(int i=0;i<n;i++)
	{
		int p; cin>>p;
		if(p==-1) rt1=i;
		else
		{
			p--; R[p].pb(i);
		}
	}
	for(int i=0;i<n;i++)
	{
		int p; cin>>p;
		if(p==-1) rt2=i;
		else
		{
			p--; B[p].pb(i);
		}
	}
	calcred(rt1,-1); calcblue(rt2,-1);
	matchred(rt1,-1); matchblue(rt2,-1);
	for(int i=0;i<n;i++) {if(!vis[i]&&ans[i]!=0) coloring(i,1);}
	cout<<"POSSIBLE\n";
	for(int i=0;i<n;i++) cout<<ans[i]<<(i<n-1?' ':'\n');
}


Measured memory_bytes: 21248
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    AB1 = zip(A,B)
    AB2 = sorted(AB1, key=lambda t:t[0])

    m = M
    s = 0
    for ab in AB2:
        if m > ab[1]:
            m -= ab[1]
            s += ab[0] * ab[1]
        else:
            s += ab[0] * m
            break

    print(s)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]" 
    B = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19736
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(void){
    string s;
    cin>>s;
    if(s[1]=='B'){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int coconut(int e){
    int min=inf;
    for(int z=0;z*z*z<=e;z++){
        for(int y=0;y*y<=e-z*z*z;y++){
            int x=e-z*z*z-y*y;
            if(x+y+z<min)min=x+y+z;
        }
    }
    return min;
}

int main(){
    vin ans(10000);
    int i=0;
    while(1){
        int e;cin>>e;
        if(e==0)break;
        ans[i]=coconut(e);
        i++;
    }
    int j=0;
    while(ans[j]){
        cout<<ans[j]<<endl;
        j++;
    }
}


Measured memory_bytes: 3048
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] abc = s.split("");
        Arrays.sort(abc);
        s = String.join("",abc);
        System.out.println(s.equals("abc")?"Yes":"No");
        
    }
}

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

using namespace std;


int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n;
	cin >> n;

	map < string, vector < pair<int, int> > > restaurant; // city S, point P, idx i

	int point;
	string name;

	for (int i = 0; i < n; ++i) {
		cin >> name >> point;
		restaurant[name].push_back({point, i+1});
	}
	
	for (auto x : restaurant) {
		sort(x.second.rbegin(), x.second.rend());
		for (auto y : x.second) {
			cout << y.second << '\n';
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>

using namespace std;
const long long iinf=100000000000000007;
const int maxn = 1000005;
long long a[maxn];
long long sum[maxn];
int main()
{
	int n;
	cin>>n;
	memset(sum,0,sizeof(sum));
	long long sumn=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum[i]=(i==0?a[i]:sum[i-1]+a[i]);
		sumn+=a[i];
	}
	long long ans=iinf;
	for(int i=0;i<n-1;i++)
	{
		ans=min(ans,abs(sumn-2*sum[i]));
	}
	cout<<ans<<endl;
	return 0;
} 

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


using namespace std;

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


const int D = 1000 * 1000 * 1000 + 7, MAXN = 100 * 1000 + 123;




int n, ans = 1, cnt[MAXN];

int main() {
	{
		int a;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> a;
			cnt[a]++;
		}
	}
	for (int i = (n + 1) & 1; i < n; i += 2)
		if (cnt[i] != 2 && !(i == 0 && cnt[i] == 1))
			return cout << 0, 0;
	while (n > 1) {
		n -= 2;
		ans <<= 1;
		ans %= D;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ret := dfs(n, 0)

	fmt.Println(ret)
}

func dfs(max, ac int) int {
	if ac > max {
		return 0
	}
	ret := 0
	if has(ac, 7) && has(ac, 5) && has(ac, 3) {
		ret += 1
	}
	return dfs(max, ac*10+7) + dfs(max, ac*10+5) +
		dfs(max, ac*10+3) + ret
}

func has(n, c int) bool {
	for n != 0 {
		if n%10 == c {
			return true
		}
		n /= 10
	}
	return false
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
  		int a = sc.nextInt();
      	int b = sc.nextInt();
      	
      	if(a <= b) {
        	System.out.println(a);	  
        } else {
          	System.out.println(a - 1);	
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max(max(a, b), c) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string a;
	cin>>a;
	int sum=0;
	for(int i=0;i<a.size();){
		int j=i;
		while(j<a.size()&&a[i]==a[j]){
			j++;
		}
		sum++;
		i=j;
	}
	cout<<sum-1<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

std::vector<int> preorder;
std::vector<int> inorder;
std::vector<int> postorder;

struct Sibling
{
    int left, right;
    Sibling(){left = -1; right = -1;}
};
Sibling sibling[41];

void dfs(const int index, const int parent_index)
{
    //cout << "dfs " << index << ", " << parent_index << endl;
    //preorder.push_back(index);
    if(sibling[index].left == -1 && sibling[index].right == -1){
        //inorder.push_back(index);
        postorder.push_back(index);
        return;
    }
    if(sibling[index].left != -1){
        dfs(sibling[index].left, index);
    }
    //inorder.push_back(index);
    if(sibling[index].right != -1){
        dfs(sibling[index].right, index);
    }
    postorder.push_back(index);
}

int pos = 0;
void Reconstruct(int left, int right)
{
    int root = preorder[pos];
    //cout << "Reconstruct " << root << ": " << left << ", " << right << endl;
    
    std::vector<int>::iterator itr, start, end;
    start = inorder.begin()+left;
    end   = (right==inorder.size())? inorder.end():(inorder.begin()+right+1);
    itr = std::find(start, end, root);
    if(itr == inorder.end()) return; // error
    
    int distl = std::distance(start, itr);
    int distr = std::distance(itr+1, end);
    if(distl != 0){  // 左の部分木がなければそのまま右へ
        pos++;  // 左の部分木のルートを設定
        sibling[root].left = preorder[pos];
        if(distl > 1){  // 左の部分木が2つ以上なら再帰（1つなら葉で確定）
            Reconstruct(left, left+(distl-1)); // rootは含まない
        }
    }
    if(distr != 0){
        pos++;  // 右の部分木のルートを設定
        sibling[root].right = preorder[pos];
        if(distr != 1){
             Reconstruct(left+(distl+1), right); // rootは含まない
        }
    }
}
int main()
{
    int n, id;
    cin >> n;
    std::vector<int> childlist;
    for(int i=0; i<n; i++){
        cin >> id;
        preorder.push_back(id);
    }
    for(int i=0; i<n; i++){
        cin >> id;
        inorder.push_back(id);
    }
    Reconstruct(0, n-1);
    dfs(preorder[0], -1);

    std::vector<int>::iterator itr = postorder.begin();
    while(itr != postorder.end()){
        cout << *itr; ++itr;
        if(itr != postorder.end()) cout << " ";
    }
    cout << endl;
}



Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 1<<30;

int n, m, data[16], dp[2][256], in;

main(){
  while(cin >> n >> m && (n|m)){
    for(int i=0;i<m;i++) cin >> data[i];
    fill(dp[0], dp[2], INF);
    dp[0][128] = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<256;j++) dp[(i+1)%2][j] = INF;
      cin >> in;
      for(int j=0;j<256;j++){
        if(dp[i%2][j] == INF) continue;
        for(int k=0;k<m;k++){
          int next = j + data[k];
          if(next < 0) next = 0;
          if(next > 255) next = 255;
          dp[(i+1)%2][next] = min(dp[(i+1)%2][next], abs(in-(next)) * abs(in-(next)) + dp[i%2][j]);
        }
      }
    }
    int ans = INF;
    for(int i=0;i<256;i++) ans = min(ans, dp[n%2][i]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int dp[100];
int main() {
	int N;
	scanf("%d", &N);
	vpii v;
	rep(i, N) {
		int w, h;
		scanf("%d%d", &w, &h);
		if(w > h) swap(w, h);
		v.pb(mp(w, -h));
	}
	sort(all(v));
//	each(i, v) cerr << i->first << ", " << i->second << endl;
	//Dilworth's
	//w_i < w_j かつ h_i < h_j
	//これを満たさないのは、
	//w_i = w_j \/ h_i = h_j \/ (w_i < w_j /\ h_i > h_j)
	//推移的にできないからめんどい。どうにかして最後の条件だけにしたい
	mset(dp, 0);
	rep(i, N) dp[i] = 1;
	int ans = 0;
	rep(i, N) {
		int x = dp[i];
//		cerr << i << ": " << x << endl;
		amax(ans, x);
		reu(j, i+1, N) {
			if((v[i].first == v[j].first) ||
				(v[i].first < v[j].first && -v[i].second >= -v[j].second))
				amax(dp[j], x + 1);
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> h(N);
    rep(i,N) cin>>h.at(i);
    sort(all(h));
    ll answer=9999999999;
    rep(i,N-K+1) {
        answer=min(answer,h.at(i+K-1)-h.at(i));
    }
    cout<<answer<<endl;
}

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

using namespace std;

int main()
{/* int a,sum=0;
for(int i=0;i<3;i++){
    scanf("%d",&a);
    sum+=a;
}
if(sum<22)printf("win");
else printf("bust");*/

char a[100];
scanf("%s",a);
if(a[0]=='S')printf("Cloudy");
else if(a[0]=='C')printf("Rainy");
else printf("Sunny");





    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.collect(&:to_i)
 
puts a.join(" ")
 
for j in 1...n
  key = a[j]
  i = j - 1
  while i >= 0 and a[i] > key
    a[i+1] = a[i]
    i -= 1
  end
  a[i+1] = key
  puts a.join(" ")
end


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


int main() {
	
	long long a,b,k;
	cin >> a >> b >> k;
	cout << max( a-k,0LL ) << ' ' << max( b - max( k-a, 0LL ), 0LL ) << endl;
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,0,n) cin >> l[i];
  sort(l.begin(), l.end());
  int ans = 0;
  rep(i,0,n-1) rep(j,i+1,n) {
    int k = lower_bound(l.begin(), l.end(), l[i]+l[j]) - l.begin();
    ans += k - j - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
ans = 'No'
for i in range(3):
    cnt = 0
    for j in range(3):
        if a[i][j] in b:
            cnt += 1
    if cnt == 3:
        ans = 'Yes'
for i in range(3):
    cnt = 0
    for j in range(3):
        if a[j][i] in b:
            cnt += 1
    if cnt == 3:
        ans = 'Yes'
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    ans = 'Yes'
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 38472
#include <stdio.h>
int main(void){
    int a, b, c, f=2, s=1;
    scanf("%d%d%d", &a, &b, &c);
    
    a == 5 ? f-- : a == 7 ? s--:0;
    b == 5 ? f-- : b == 7 ? s--:0;
    c == 5 ? f-- : c == 7 ? s--:0;
    
    printf(f == 0 && s == 0 ? "YES\n": "NO\n");
    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if (A1 + A2 + A3 >= 22) {
        puts("bust");
    } else {
        puts("win");
    }
}


Measured memory_bytes: 256
/* ファイル名：ITP1_6_D.c	*/
/* 内容：n×m  の行列 A と、m×1 の列ベクトルb を読み込み、A と b の積を出力する	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:n×m  の行列 A と、m×1 の列ベクトルb を読み込み、A と b の積を出力する	*/
int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	int n;				/* ベクトルの行	*/
	int m;				/* ベクトルの列	*/
	int A[100][100];	/* 行列			*/
	int b[100];			/* 列ベクトル	*/
	
	/* 処理	*/
	int i;	/* ループ用変数1	*/
	int j;	/* ループ用変数2	*/
	int c;	/* A と b の積		*/
	
	scanf("%d %d",&n,&m);	/* 行と列を取得	*/
	
	/* 行列の取得	*/
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			scanf("%d",&A[i][j]);
		}
	}
	
	/* 列ベクトルの取得	*/
	for(i = 0; i < m; i++){
		scanf("%d",&b[i]);
	}
	
	/* A と b の積を算出して出力	*/
	for(i = 0; i < n; i++){
		int c = 0;	/* cの初期化	*/
		for(j = 0; j < m; j++){
			c += A[i][j] * b[j];
		}
		printf("%d\n",c);	/* 行ごとに結果を出力	*/
	}
	
	return 0;
}



Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int n;
	cin>>n;
	set<string>s;
	while(n--)
	{
		string a;
		cin>>a;
		s.insert(a);
	}
	cout<<s.size();
}



Measured memory_bytes: 19288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    long long int a,b,c;
    cin >> a>>b>>c;
    if((a*100+b*10+c)%4==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "?ABC" ].solve == 4 );		// 追加ケース
	assert( [ "ABC?" ].solve == 4 );		// 追加ケース
	
	assert( [ "A??C" ].solve == 8 );
	assert( [ "ABCBC" ].solve == 3 );
	assert( [ "????C?????B??????A???????" ].solve == 979596887 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	
	const M = 10L ^^ 9 + 7;
	const ABC = "ABC$"d;
	auto dp = new ModWorld!M[][]( 1 + s.length, 1 + ABC.length );
	dp[ 0 ][ 0 ] = 1L;
	foreach( i, c; s )
	{
		foreach( j, x; ABC )
		{
			if( c == '?' )
			{
				dp[ i + 1 ][ j + 1 ] += dp[ i ][ j ];
				dp[ i + 1 ][ j ] += dp[ i ][ j ] * 3;
			}
			else
			{
				if( c == x ) dp[ i + 1 ][ j + 1 ] += dp[ i ][ j ];
				dp[ i + 1 ][ j ] += dp[ i ][ j ];
			}
		}
	}
	return dp[ $ - 1 ][ 3 ];
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}


Measured memory_bytes: 10216