akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int h, w, a, b;
    R h >> w >> a >> b;
    co((h - a) * (w - b));
}


Measured memory_bytes: 256
#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 h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  
  vector<P> cell(h*w);
  rep(i, h) rep(j, w) {
    int ci = i*w + j;
    if (i % 2 == 0) cell[ci] = make_pair(i, j);
    else cell[ci] = make_pair(i, w-j-1);
  }

  vector<pair<P, P>> ans;
  rep(ci, h*w-1) {
    int y = cell[ci].first;
    int x = cell[ci].second;
    if (a[y][x] % 2 == 0) continue;
    a[y][x]--;
    int yp = cell[ci+1].first;
    int xp = cell[ci+1].second;
    a[yp][xp]++;
    ans.push_back(make_pair(make_pair(y, x), make_pair(yp, xp)));
  }

  int n = ans.size();
  printf("%d\n", n);
  rep(i, n) {
    int y = ans[i].first.first + 1;
    int x = ans[i].first.second + 1;
    int yp = ans[i].second.first + 1;
    int xp = ans[i].second.second + 1;
    printf("%d %d %d %d\n", y, x, yp, xp);
  }
  return 0;
}

Measured memory_bytes: 8300
import sys
import numpy as np

# 価値 x 以上の握手を全て行うとする
# 握手回数が決まる。左手ごとに集計できる。

N, M = map(int, sys.stdin.readline().rstrip().split())
A = np.array(sys.stdin.readline().rstrip().split(), np.int64)

A.sort()  # A を昇順に並び替える

# x より価値が高くなる握手の総数
#  -> a に対して、相手は x - a が必要
#   -> A = [a0, a1, a2, ...] に対して、[x-a0の開始位置, x-a1の開始位置, x-a2の開始位置,...] を探す
def shake_cnt(x):
    # x 以上の握手を全て行うとして、握手の回数を数える行わない握手を数える
    X = np.searchsorted(A, x - A)  # ソートされたリストA に対して、x - A が挿入される位置を返す
    return N * N - X.sum()  # index の和は「小さい方」を指しているので、引く


# 二分探索  握手の回数が
left = 0  # 握手の回数がM以上
right = 10 ** 6  # 握手の回数がM未満 <- まだ足りない側
while 1 < right - left:  # left と right が隣り合ったら終了
    x = (left + right) // 2
    if shake_cnt(x) >= M:
        left = x
    else:
        right = x

# M回には届かないけれど、M回に限りなく近くなる価値 x = right
X = np.searchsorted(A, right - A)  # 各a in A が握手を行わない人数のArray
shake = N * N - X.sum()  # ここまでの握手回数

Acum = np.zeros(N + 1, np.int64)  # 人数 -> 累積和
# Acum = [a0, a0+a1, a0+a1+a2, ....] を計算して、ai さんが k番目以降と握手をすれば
Acum[1:] = np.cumsum(A)  # cumsum [1,2,3,4,5,6,...] -> [1,3,6,10,15,21,...]

# 右手の幸福度は ai * ((a0+a1+...a(n-1)) - (a(k-1)+...+a(n-1))) を得られる
# 左手の幸福度は 回数だけで決まる（何人と握手とするか）
happy = (Acum[-1] - Acum[X]).sum() + (A * (N - X)).sum()

happy += (M - shake) * left  # 不足分。1回の価値は M とわかっている

print(happy)


Measured memory_bytes: 38860
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
#define Maxn 100005
using namespace std;

inline ll read()
{
	ll x = 0,w = 1;char c = getchar();
	while (c < '0' || c > '9'){if (c == '-') w = -1;c = getchar();}
	while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0',c = getchar();
	return x * w;
}

ll n,s,p;

struct L
{
	ll a,b;
}l[Maxn];

bool compare(L a,L b){return (a.a - a.b) < (b.a - b.b);}

int main()
{
	n = read();
	for (int i = 1; i <= n; ++i) l[i].a = read();
	for (int i = 1; i <= n; ++i) l[i].b = read();
	sort(l + 1,l + n + 1,compare);
	for (int i = 1; i <= n; ++i)
	{
		if (l[i].a > l[i].b)
		{
			s += l[i].a - l[i].b;
			if (p >= l[i].a - l[i].b) p -= l[i].a - l[i].b;
			else
			{
				printf("No");
				return 0;
			}
		}
		else p += (l[i].b - l[i].a) / 2;
		s += l[i].a - l[i].b;
	} 
	if (s <= 0) printf("Yes");
	else printf("No");
	
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  deque<int> deq;
  int N;
  cin >> N;
  REP(i, N) {
    string command;
    cin >> command;
    if (command == "insert") {
      int k;
      cin >> k;
      deq.push_front(k);
    } else if (command == "delete") {
      int k;
      cin >> k;
      REP(i, deq.size()) {
	if (deq[i] == k) {
	  deq.erase(deq.begin() + i);
	  break;
	}
      }
    } else if (command == "deleteFirst") {
      deq.pop_front();
    } else {
      deq.pop_back();
    }
  }
  int i = 0;
  for (auto l : deq) {
    cout << l << (i == (int)deq.size() - 1 ? '\n' : ' ');
    i++;
  }
  return 0;
}

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

int main() {
  int n,k,sum;
  sum = 0;
  cin >> n >> k;
  for(int i=0; i<n; i++){
    int h;
    cin >> h;
    if(h >= k)
      sum ++;
  }
  cout << sum;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        if(n > m){
            long tmp = n;
            n = m;
            m = tmp;
        }

        if(n == 1){
            if(m == 1){
                System.out.println("1");
            }else{
                System.out.println(m-2);
            }
        }else if(n == 2){
            System.out.println("0");
        }else{
            System.out.println((n-2)*(m-2));
        }
    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;

#define mx 1000010
int dp[mx];
ll gcd(ll a,ll b)
{
	//Write your code here
    if(b==0)
        return a;
    return gcd(b,a%b);
}


void solve()
{
 int n;
 cin>>n;
 int arr[n];

 for(int i=0;i<n;i++)
    cin>>arr[i];

    for(int i=2;i<mx;i++)
    {  if(!dp[i])
    {
        for(int j=i;j<mx;j+=i)
           dp[j]=i;
    }
    }
    dp[1]=1;
    int ok=1;
    map<int,int> mp;
    for(int i=0;i<n;i++)
    {
        int x=arr[i];

        while(x!=dp[x])
        {
            if(mp[dp[x]])
        {
            if(mp[dp[x]]!=i+1)
                ok=0;
        }


            mp[dp[x]]=i+1;
            x/=dp[x];
        }
       if(x!=1)
         {if(mp[x]&&mp[x]!=i+1)
            ok=0;
             mp[x]=i+1;
         }
    }
    if(ok)
    {
        cout<<"pairwise coprime"<<endl;
        return;
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ans=gcd(ans,arr[i]);
    }
    if(ans==1)
    {
        cout<<"setwise coprime"<<endl;
    }
    else
    {
        cout<<"not coprime"<<endl;
    }







}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

map<long long,long long> prime_factor(long long n) {
    map<long long,long long> ret;
    for(long long i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main()
{
	ll n,m;
	bool b=true;
	string s,t;
	cin >> n >> m >> s >> t;
	ll l=lcm(n,m);
	rep(i,n){
		if(i*m%n==0 && s[i]!=t[i*m/n]) b=false;
	}
	if(b) cout << l << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
 
char color[20][20];
int dp[2][1 << 20];
 
int main() {
    int i, j, k;
    int m, n;
    int n_bit;
    int *src = dp[0];
    int *dst = dp[1];
    int all_case = 1;
    int sum;
 
    scanf("%d %d", &m, &n);
    n_bit = 1 << n;
 
    for (i=0; i<m; i++) {
        for (j=0; j<n; j++) {
            scanf(" %c", &color[i][j]);
            if (color[i][j] == '?') {
                all_case *= 3;
                all_case %= 100000;
            }
        }
    }
 
    src[0] = 1;
    for (i=0; i<m; i++) {
        int *tmp;
 
        for (j=0; j<n; j++) {
            int bits;
 
            if (i == 0) {
                bits = 1 << j;
            } else {
                bits = 1 << n;
            }
 
            for (k=0; k < bits; k++) {
                int JO_state;
                int is_J;
                int JO_exists;
                int r_shifted;
                char c = color[i][j];
 
                if (!src[k]) continue;
                if (j > 0 && (k & (1 << j))) continue;
 
                JO_state = k & (~1);
                is_J = k & 1;
                JO_exists = k & (n_bit >> 1);
                r_shifted = (JO_state << 1) & (n_bit-1);
 
                if (c == 'J' || c == '?') {
                    dst[r_shifted | (0 << 1) | 1] += src[k]; // J
                }
 
                if (c == 'O' || c == '?') {
                    if (is_J && j > 0) {
                        dst[r_shifted | (1 << 1) | 0] += src[k]; // O
                    } else {
                        dst[r_shifted | (0 << 1) | 0] += src[k]; // O
                    }
                }
 
                if (!JO_exists && (c == 'I' || c == '?')) {
                    dst[r_shifted | (0 << 1) | 0] += src[k]; // I
                }
 
                dst[r_shifted | (1 << 1) | 0] %= 100000;
                dst[r_shifted | (0 << 1) | 1] %= 100000;
                dst[r_shifted | (0 << 1) | 0] %= 100000;
            }
 
            tmp = src;
            src = dst;
            dst = tmp;
            memset(dst, 0, sizeof(int) * (1 << 20));
        }
    }
 
    sum = 0;
    for (i=0; i<n_bit; i++) {
        sum += src[i];
        sum %= 100000;
    }
 
    if (all_case < sum) {
        all_case += 100000;
    }
 
    printf("%d\n", (all_case - sum)%100000);
}

Measured memory_bytes: 9224
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   long long N;
   cin >> N;
   vector<int> edge[N+1];
   set<int, greater<int>> S;
   bool used[N+1];
   memset(used,false,sizeof(used));
   for(int i = 0 ; i < N; i++){
      S.insert(i+1);
   }
   int val[N+1];
   vector<int> deg(N+1, 0);
   for(int i =0;i<N+1;i++){
      val[i]=i;
   }
   long long ans = 0;
   for(int i = 1 ; i <= N; i++){
      ans += i*(N+1-i);
   }
   for (int i = 0; i < N-1; i++)
   {
      int u,v;
      cin >> u >> v;
      edge[u].emplace_back(v);
      edge[v].emplace_back(u);
      deg[u]++;
      deg[v]++;

      long long l = min(u,v);
      long long r = max(u,v);
      ans -= l*(N-r+1);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 26224
A, B, C = map(int, input().split())

ans = min(
    abs(A - B) + abs(B - C),
    abs(A - C) + abs(B - C),
    abs(B - A) + abs(A - C),
    abs(B - C) + abs(A - C),
    abs(C - A) + abs(A - B),
    abs(C - B) + abs(A - B),
)

print(ans)

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

typedef long long ll;

int h, w, q;
int row[50002], row_order[50002];
int col[50002], col_order[50002];

int main(){
  while(cin >> h >> w >> q, h || w || q){
    for(int i = 0; i < 50002; i++){
      row[i] = col[i] = -1;
      row_order[i] = col_order[i] = 0;
    }

    for(int i = 0; i < q; i++){
      int A, B, order;
      cin >> A >> B >> order;

      if(A == 0){
        row[B] = i;
        row_order[B] = order;
      }
      else{
        col[B] = i;
        col_order[B] = order;
      }
    }

    vector<int> v0, v1;

    for(int j = 0; j < w; j++){
      if(col_order[j] == 0){
        v0.push_back(col[j]);
      }
      else{
        v1.push_back(col[j]);
      }
    }
    sort(v0.begin(), v0.end());
    sort(v1.begin(), v1.end());

    ll ans = 0;

    for(int i = 0; i < h; i++){
      if(row_order[i] == 0){
        ans += v1.end() - upper_bound(v1.begin(), v1.end(), row[i]);
      }
      else{
        ans += lower_bound(v0.begin(), v0.end(), row[i]) - v0.begin();
        ans += v1.size();
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 2408
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N;
  cin >> N;
  N %= 1000;
  if (N == 0) {
    cout << 0 << endl;
  } else {
    cout << 1000 - N << endl;
  }
  return 0;

}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
  scanf("%d",&head);
  RI(tail...);
}
using namespace std;
typedef long long LL;
int main()
{  
	string ar[11];
	ar[2] = "hon";
	ar[4] = "hon";
	ar[5] = "hon";
	ar[7] = "hon";
	ar[9] = "hon";
	ar[0] = "pon";
	ar[1] = "pon";
	ar[6] = "pon";
	ar[8] = "pon";
	ar[3] = "bon";
	string str;
	cin >> str;
	cout << ar[str[str.length()-1] - '0'] << endl;
  return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>
#include <algorithm>
using namespace std;
int dp[100001][3];
char txt[100001];
int arr[3];
inline int score(int idx, int v){
  return (v==0)*(txt[idx]=='s')+(v==1)*(txt[idx]=='p')+(v==2)*(txt[idx]=='r');
}
int main(){
  int N,K;scanf("%d %d",&N,&K);
  for(int i=0;i<3;i++) scanf("%d",arr+i);
  scanf("%s",txt);
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      if(i<K) dp[i][j] = score(i,j)*arr[j];
      else{
        for(int k=0;k<3;k++){
          if(k==j) continue;
          dp[i][j]=max(dp[i-K][k]+score(i,j)*arr[j],dp[i][j]);
        }
      }
    }
  }
  int sum=0;
  for(int i=0;i<K;i++) sum+=*max_element(dp[N-1-i],dp[N-1-i]+3);
  printf("%d",sum);
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    string s; cin>>s;
    int h = stoi(s.substr(0, 2));
    int t = stoi(s.substr(2, 2));

    if(1 <= h && h <= 12 && 1 <= t && t <= 12){
        cout << "AMBIGUOUS" << endl;
    }
    else if(0 <= h && h <= 99 && 1 <= t && t <= 12){
        cout << "YYMM" << endl;
    }
    else if(1 <= h && h <= 12 && 0 <= t && t <= 99){
        cout << "MMYY" << endl;
    }
    else{
        cout << "NA" << endl;
    }
}

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


P get_a(int x1, int y1, int x2, int y2){
    if(y2 < y1){
        swap(x1, x2);
        swap(y1, y2);
    }
    int x = x2 - x1, y = y2 - y1;
    if(y == 0) return P(1, 0);
    else if(x == 0) return P(0, 1);

    int gcd = __gcd(abs(x), y);
    return P(x / gcd, y / gcd);
}

int x[17], y[17];
P a[17][17];
int dp[1 << 17];

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

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

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            a[i][j] = get_a(x[i], y[i], x[j], y[j]);
            a[j][i] = a[i][j];
        }
    }

    map<P, vector<P>> para_pairs;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(para_pairs.count(a[i][j]) > 0) continue;
            vector<P> pairs;
            for(int k=0;k<n;k++){
                for(int l=k+1;l<n;l++){
                    if(a[i][j] == a[k][l]){
                        pairs.emplace_back(k, l);
                    }
                }
            }
            para_pairs[a[i][j]] = pairs;
        }
    }

    memset(dp, 0, sizeof(dp));
    for(int i=0;i<(1 << n);i++){
        for(auto& e : para_pairs){
            int cnt = 0;
            int bit = 0;
            for(P& p : e.second){
                int pair_bit = (1 << p.first) | (1 << p.second);
                if(i&pair_bit) continue;
                bit |= pair_bit;
                cnt++;
            }
            if(cnt > 0){
                dp[i | bit] = max(dp[i | bit], dp[i] + cnt * (cnt - 1) / 2);                
            }
        }
    }
    cout << dp[(1 << n) - 1] << endl;

    return 0;
}

Measured memory_bytes: 3616
while(True):
    n = int(input())
    if n == 0:
        break
    a_sum = 0
    b_sum = 0
    for i in range(n):
        a, b = map(int, input().split())
        if a == b:
            a_sum += a
            b_sum += b
        elif a > b:
            a_sum += (a+b)
        else:
            b_sum += (a+b)
    print(a_sum, b_sum)


Measured memory_bytes: 5608
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------
int main(){
  ll N;cin>>N;
  vi L(N);REP(i,N)cin>>L[i];
  sort(ALLv(L));
  ll cnt=0;
  REP(i,N-2){
    FOR(j,i+1,N-1){
      FOR(k,j+1,N){
        ll a=L[i],b=L[j],c=L[k];
        if(!(a<b+c&&b<c+a&&c<a+b))break;
        cnt++;
      }
    }
  }cout<<cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

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; }

long long gd(long long n){
    return log10(n)+1;
}

int main(){
    long long n;
    cin>>n;
    long long ans=INF;
    for(int i=1; i<=sqrt(n)+1; i++){
        if(n%i==0)chmin(ans, max(gd(i), gd(n/i)));
    }
    cout<<ans<<endl;
}


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

int main() {
  int N,W,sum=0;
  cin >> N >> W;
  vector<vector<int>> sina(N,vector<int>(2,0));
  for (int i=0;i<N;i++){
    cin >> sina.at(i).at(0) >> sina.at(i).at(1);
    sum+=sina.at(i).at(1);
  }
  vector<vector<int64_t>> dp(N,vector<int64_t>(sum+1,pow(10,11)));
  for (int v=0;v<=sina.at(0).at(1);v++){
    dp.at(0).at(v)=sina.at(0).at(0);
  }
  for (int n=1;n<N;n++){
    for (int v=1;v<=sum;v++){
      if (v<=sina.at(n).at(1)){
        dp.at(n).at(v)=min((int64_t)sina.at(n).at(0),dp.at(n-1).at(v));
      }else{
        dp.at(n).at(v)=(int64_t)min(dp.at(n-1).at(v-sina.at(n).at(1))+sina.at(n).at(0),dp.at(n-1).at(v));
      }
    }
  }
  for (int v=sum;v>=0;v--){
    if(dp.at(N-1).at(v)<=W){
      cout << v << endl;
      break;
    }
  }
}

Measured memory_bytes: 79488
#include <cstdio>
#include <cassert>
#include <stack>
#include <algorithm>
using namespace std;

typedef long long int64;
const int64 mod = 1000000007LL;
typedef pair<int64, int64> llp;

stack<int64> s;
void push(int64 v) { s.push(v); }
int64 pop() { int64 v = s.top(); s.pop(); return v; }

int64 temp;
int64 total, yes, no;
int64 r_yes, r_no;
int64 ans;
char str[1200000];
int it = 0;


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

	push(0);
	goto t_exp;

c_top:

	ans = r_yes;

	printf("%lld\n", ans);

	return 0;

t_exp:

	total = 1;
	no = 1;

	while(true) {

		push(total);
		push(no);
		push(1);
		goto t_term;
c_exp:
		no = pop();
		total = pop();

		total = (total * (r_yes + r_no)) % mod;
		no = (no * r_no) % mod;

		if(str[it] != '|')
			break;
		it += 1;
	}

	r_yes = (total + mod - no) % mod;
	r_no = no;
	goto ret;

t_term:

	total = 1;
	yes = 1;

	while(true) {

		push(total);
		push(yes);
		push(2);
		goto t_fac;
c_term:
		yes = pop();
		total = pop();

		total = (total * (r_yes + r_no)) % mod;
		yes = (yes * r_yes) % mod;

		if(str[it] != '&')
			break;
		it += 1;
	}

	r_yes = yes;
	r_no = (total + mod - yes) % mod;
	goto ret;

t_fac:

	if(str[it] == 'x') {
		it += 1;
		while(str[it] >= '0' && str[it] <= '9')
			it += 1;
		r_yes = 1;
		r_no = 1;
		goto ret;
	}

	if(str[it] == '~') {
		it += 1;
		push(3);
		goto t_fac;
c_fac1:
		temp = r_yes;
		r_yes = r_no;
		r_no = temp;
		goto ret;
	}

	if(str[it] == '(') {
		it += 1;
		push(4);
		goto t_exp;
c_fac2:
		it += 1;
		goto ret;
	}

ret:

	temp = pop();
	if(temp == 0) goto c_top;
	if(temp == 1) goto c_exp;
	if(temp == 2) goto c_term;
	if(temp == 3) goto c_fac1;
	if(temp == 4) goto c_fac2;
}

Measured memory_bytes: 30784
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

using namespace std;

#define PI			3.14159265
#define OO			1e9
#define SS       	second
#define FF       	first
#define Trace(n)  	cout<< #n <<" = "<< n << endl; 
#define ll			long long
#define endl		"\n"
#define EPS		    1e-9
//#define MOD         1e9 + 7	    
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { -1, 1, 0, 0, 1, -1, 1, -1 };

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

}


int main()
{
	fast();
	ll a, b;
	cin >> a >> b;
	ll sm = a + b;
	if (sm & 1)
		cout << "IMPOSSIBLE";
	else
		cout << sm / 2;


}

Measured memory_bytes: 256
//C - Poll

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

    vector<string> s;
    string ss;

    for (int i=0; i<n; i++){
        cin >> ss;

        s.push_back(ss);
    }

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

    vector<string> tmp;
    vector<int> cnt;

    string bs = "";
    int idx = -1;

    for (int i=0; i<n; i++){
        if (bs == s[i]){
            cnt[idx] = cnt[idx] + 1;
        }else{
            tmp.push_back(s[i]);
            cnt.push_back(1);
            idx++;
        }

        bs = s[i];
    }

    int max = *std::max_element(cnt.begin(), cnt.end());
    vector<string> result;
    for (int i=0; i<cnt.size(); i++){
        if (cnt[i] == max) {
            result.push_back(tmp[i]);
        }
    }

    for (int i=0; i<result.size(); i++){
        cout << result[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 22128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;




int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll left = (ll)2 * a *b;
    ll right = (ll)a*a;
    ll one = (ll)2*a*c;
    ll two = (ll)b*b;
    ll three = (ll)2*c*b;
    ll four = (ll)c*c;
    if(c-a-b<0){
        cout << "No" << endl;
    }
    else if(0 < four + right + two - one - three - left){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
# define pb push_back
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<tuple<int,int>> d;
    rep(i,n){
        int a;
        cin >> a;
        d.pb(make_tuple(a,i+1));
    }
    sort(d.begin(),d.end());
    rep(i,n){
        cout << get<1>(d[i]) << " ";
    }
}

Measured memory_bytes: 1780
N = int(input())
A = [int(i) for i in input().split()]
c4=0
c2=0
for i in range(N):
  if A[i]%4==0:
    c4+=1
  elif A[i]%2==0:
    c2+=1
if c4:
  a = c4*2+1
else:
  a = 0
if c2>1:
  b = c2
  if a:
    a -= 1
else:
  b = 0
if a+b>=N:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14228
import java.util.*;

// Tenakaichi 
// https://yukicoder.me/problems/no/325	

public class Main {
	
	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		double E = 1e-9;
		
		double N = in.nextDouble();
		boolean answerFound = false;
		double d = 4 / N;
		
		for (double i = 3500; i > 0 && 1 / i < d && !answerFound; i--) {
			double dd = d - 1 / i;
			
			for (double j = 3500; j > 0 && 1 / j < dd && !answerFound; j--) {
				double ddd = dd - 1 / j;
				
				double x = 1 / ddd;
				int k = 0;
				
				if (Math.abs(Math.ceil(x) - x) <= E) {
					k = (int) Math.ceil(x);
					answerFound = true;
				} else if (Math.abs(Math.floor(x) - x) <= E) {
					k = (int) Math.floor(x);
					answerFound = true;
				}
				
				if (answerFound) {
					System.out.printf("%d %d %d\n", (int) i, (int) j, k);
				}
			}
		}
	}
	
	
}


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

using namespace std;

int main () {
    
    int count = 0;
    string s;
    cin >> s;
    
    if (s[0] == '1') count++;
    if (s[1] == '1') count++;
    if (s[2] == '1') count++;
    
    cout << count << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int x;
void input(){
    fast_io();
    cin >> x;
}

int kyu(int x){
    if(x<600) return 8;
    else if(x<800) return 7;
    else if(x<1000) return 6;
    else if(x<1200) return 5;
    else if(x<1400) return 4;
    else if(x<1600) return 3;
    else if(x<1800) return 2;
    return 1;
}

int solve(){
    cout << kyu(x) << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3636
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.List.Split (splitOn)

main :: IO ()
main = do
  xs <- getc $ map toDbl . splitOn ","
  print $ solve xs

solve :: [[Double]] -> Double
solve (p:ps) = sum $ zipWith (\p1 p2 -> area p p1 p2) ps (tail ps)

area [x1,y1] [x2,y2] [x3,y3] = sqrt $ z * (z - a) * (z - b) * (z - c)
  where
    a = sqrt $ (x1 - x2) ^ 2 + (y1 - y2) ^ 2
    b = sqrt $ (x2 - x3) ^ 2 + (y2 - y3) ^ 2
    c = sqrt $ (x3 - x1) ^ 2 + (y3 - y1) ^ 2
    z = (a + b + c) / 2.0

toDbl :: String -> Double
toDbl s = read s

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

Measured memory_bytes: 4024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int n, m;
    cin >> n >> m;

    vvi s;
    REP(_, m) {
        int k;
        cin >> k;
        vi v(k);
        REP(i, k) cin >> v[i];
        s.emplace_back(v);
    }

    vi p(m);
    REP(i, m) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1<<n); bit++) {
        vector<bool> pat(n, false);
        REP(i, n) {
            if (bit & (1<<i)) pat[i] = true;
        }

        bool check = true;
        REP(i, m) {
            int sum = 0;
            for (int id : s[i]) if (pat[id-1]) sum += 1;
            if (sum % 2 != p[i]) check = false;
        }

        if (check) ans ++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int len[200010];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi v(n);
	rep(i, n){
		cin >> v[i];
		len[v[i]] = len[v[i] - 1] + 1;
	}
	cout << n - *max_element(len, len + n + 1) << endl;
	return 0;
}

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

int main() {
    int N, K, Q, A;
    cin >> N >> K >> Q;
    vector<int> pt(N, K - Q);
    rep(i, Q) {
        cin >> A;
        pt[A-1]++;
    }

    rep(i, N) {
        cout << (pt[i] > 0 ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 1152
n,m = map(int,input().split())

# 0-indexed
visited = [False]*n
aa = []
bb = []
edge = []
for i in range(51):
    edge.append([False]*51)
"""
edge = [[False]*7]*7
"""

for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    aa.append(a)
    bb.append(b)
    edge[a][b] = True
    edge[b][a] = True
    """
    for l in edge:
        print(l)
    print('')
    """

def dfs(vertex):
    visited[vertex] = True
    for i in range(n):
        if edge[vertex][i] and not visited[i]:
            #print(i, end=' ')
            dfs(i)

res = 0
for i in range(m):
    visited = [False]*n
    edge[aa[i]][bb[i]] = False
    edge[bb[i]][aa[i]] = False
    dfs(0)
    if not visited==[True]*n:
        res += 1
    #print(visited)
    edge[aa[i]][bb[i]] = True
    edge[bb[i]][aa[i]] = True

print(res)


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

int find_root(int x, vector<int> &parent) {
    if (parent[x] != x) {
        parent[x] = find_root(parent[x], parent);
    }
    return parent[x];
}

void union_by_size(int x, int y, vector<int> &parent, vector<int> &size) {
    int root_x = find_root(x, parent), root_y = find_root(y, parent);
    if (root_x == root_y) {
        return;
    }
    if (size[root_x] >= size[root_y]) {
        parent[root_y] = root_x;
        size[root_x] += size[root_y];
    }
    else {
        parent[root_x] = root_y;
        size[root_y] += size[root_x];
    }
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    vector<int> parent(N), size(N);
    for (int i = 0; i < N; ++i) {
        parent[i] = i;
        size[i] = 1;
    }
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        union_by_size(A - 1, B - 1, parent, size);
    }
    cout << *max_element(size.begin(), size.end()) << '\n';
    return 0;
}

Measured memory_bytes: 4776
N = int(input())
T = ("3","5","7")

def dfs(x):
  if x != "" and int(x) > N:
    return 0
  res = 0
  if len(set(x)) == 3:
    res = 1
  for t in T:
    res += dfs(x + t)
  return res
  
print(dfs(""))

Measured memory_bytes: 9092
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N, W;
int v[100], w[100];

//2_index
/*
int dp[101][10001];
//dp[i][j] i番目の品物まででできる重さj以下の価値の最大値

int main()
{
    ios::sync_with_stdio(false);
    cin >> N >> W;
    REP(i,0,N) cin >> v[i] >> w[i];
    REP(j,0,W+1) dp[0][j] = 0;
    REP(i,0,N){
        REP(j,0,W+1){
            if (j >= w[i]) dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]]+v[i]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    // REP(i,0,N+1){
    //     REP(j,0,W+1){
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    CO(dp[N][W]);
    return 0;
}
*/

//1index
int dp[10001];
// 重さj以下でできる価値の最大値

int main()
{
    ios::sync_with_stdio(false);
    cin >> N >> W;
    REP(i,0,N) cin >> v[i] >> w[i];
    REP(j,0,W+1) dp[j] = 0;
    REP(i,0,N){
        REP(j,0,W+1){
            if (j >= w[i]) dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
        }
    }
    // REP(i,0,N+1){
    //     REP(j,0,W+1){
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    CO(dp[W]);
    return 0;
}


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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PER(j,n,a) for (int j=n-1;j>=a;j--)
#define REP(i,a,n) for (ul i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define show(x) cout<<(x)<<endl
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long long int ul;
typedef long long ll;
typedef string str;
/*FIN*/
ul n,a;
int main() {
	FAST;
	cin>>n;
	a = 0UL;
	if(n%2 == 0 or n%5 == 0) {
		show(-1);
		return 0;
	}
	REP(i,0,999983) {
		a = (10UL*a) + 7UL;
		a %= n;
		//show(a);
		if(a%n == 0) {
			i+=1UL;
			show(i);
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

i64 lcm(i64 i, i64 j)
{
  return i * j / __gcd(i, j);
}

int main()
{
  i64 a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;
  cout << b - a - ((b / c + b / d - b / lcm(c, d)) - (a / c + a / d - a / lcm(c, d))) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    ll n,m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    ll ans=n;
    rep(i,m) ans -= a[i];
    if(ans<0){
        cout << "-1" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));

    bool flag = true;
    REP(i, n) if(a[i] != 0) flag = false;
    if(flag) {
        cout << "Yes" << endl;
        return 0;
    }

    sort(ALL(a));
    flag = true;
    REP(i, n/3) if(a[i] != a[0]) flag = false;
    FOR(i, n/3, n*2/3) if(a[i] != a[n/3]) flag = false;
    FOR(i, n*2/3, n) if(a[i] != a[n*2/3]) flag = false;
    if((a[0]^a[n/3]) != a[n-1]) flag = false;

    if(flag) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 1024
A,B,M=map(int,input().split())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))
XC=[]
for i in range(M):
  XC.append(list(map(int,input().split())))
ans=min(aa)+min(bb)
for i in range(M):
  ans=min(ans,aa[XC[i][0]-1]+bb[XC[i][1]-1]-XC[i][2])
print(ans)

Measured memory_bytes: 38560
#include<stdio.h>
#define INFTY 1000000000
#define N 500000

void mergeSort(int[],int,int,int);
int merge(int[],int,int,int,int);

int count=0;

int main(){
  int S[N];
  int i,n;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,n,0,n);

  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    printf("%d",S[i]);
  }
  printf("\n");
  printf("%d\n",count);
}

void mergeSort(int A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
    }
}

int merge(int A[],int n,int left,int mid,int right){
 
  int n1,n2,j,k,i;
  

  n1=mid-left;
  n2=right-mid;
  int L[n1];
  int R[n2];
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }

  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;

  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
  }
    count++;
}
}



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

int main() {
    int64_t N;
    cin >> N;
    vector<vector<pair<int64_t, int64_t>>> testimony(N);
    for (int64_t i = 0; i < N; i++) {
        int64_t A;
        cin >> A;
        for (int64_t j = 0; j < A; j++) {
            int64_t x, y;
            cin >> x >> y;
            x--;
            testimony[i].push_back({ x, y });
        }
    }

    int64_t ans = 0;
    const int64_t MAX = (1LL << N);
    for (int64_t honest = 0; honest < MAX; honest++) {
        bool ok = true;
        int64_t num = 0;
        for (int64_t i = 0; i < N; i++) {
            if (honest & (1 << i)) {
                //検証
                for (const pair<int64_t, int64_t>& t : testimony[i]) {
                    if (t.second != (bool)(honest & (1 << t.first))) {
                        ok = false;
                        break;
                    }
                }
                num++;
            }
        }

        if (ok) {
            ans = max(ans, num);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(input[0], 10);
		
	var i = 0;
   var d = [];
   for (var i = 0; i < n ; i++){
   var r= parseInt(tmp[i], 10);
   d[i] = r;}
//  console.log(d);
  
   var total = d.reduce(function(p, c) {
            return p + c;
             })
    //         console.log(total);
   var i = 0;
   var e = [];
   for (var i=0;i<n;i++){
   var r = d[i]*d[i];
   e[i] = r;}
 //  console.log(e);          
   
   var total2 = e.reduce(function(p, c) {
            return p + c;
             })
     //        console.log(total2);  
   ans = (total*total-total2 )/2;
   console.log(ans);                 
             
	//出力
	//console.log();
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372