akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define clr(a) memset(a, 0, sizeof(a))
#define set(a) memset(a, -1, sizeof(a))
#define pb push_back
#define sz(a) ((ll)a.size())
#define all(a) a.begin(), a.end()
#define mp make_pair
#define rep(i, a, y) for (ll i = a; i <= y; i++)
#define rep2(i, b) for (int i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(x) scanf("%d", &x)
#define pcl(x) printf("%d", x)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
/*
 
     ██╗██╗   ██╗██╗  ██╗ █████╗ ███╗   ██╗
     ██║██║   ██║██║  ██║██╔══██╗████╗  ██║
     ██║██║   ██║███████║███████║██╔██╗ ██║
██   ██║██║   ██║██╔══██║██╔══██║██║╚██╗██║
╚█████╔╝╚██████╔╝██║  ██║██║  ██║██║ ╚████║
 ╚════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝
 
*/
map<char, ll> p;
map<char, ll>::iterator it;
bool solve(string str)
{
    p.clear();
    for(auto xx:str) p[xx]++;
    for(auto xx:p) 
    {
        if(xx.ss%2!=0) return false;
    }
    return true;
}
// bool solve(string str)
// {
//     ll arr[26];
//     memset(arr,0,sizeof(arr));
//     for(ll i=0; i<sz(str); ++i)
//     {
//         ll id=(int)str[i]-97;
//         arr[id]=arr[id]+1;
//     }
//     for(ll i=0; i<26; ++i)
//     {
//         if(arr[i]%2!=0)
//         {
//             return false;
//         }
//     }
//     return true;
// }
int main()
{
    //bool cnt=0;
    FastRead;
    string s;
    cin >> s;
    for (ll i =sz(s)-1;i>=0; i--)
    {
        string x="";
        for(ll j=0;j<i;j++) x+=s[j];
        if(solve(x))
        {
            string z="",y="";
            for(ll j=0;j<sz(x)/2;j++) z+=x[j];
            for(ll j=sz(x)/2;j<sz(x);j++) y+=x[j];
            if(z==y)
            {
                cout<<sz(x)<<endl;
                return 0;
            }
        }
    }
    cout<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

vector<ll> fact(100005), fact_inv(100005);
vector<int> appear(100005, 0);
int l, r;
ll mod = 1e9 + 7;

ll func(ll n, ll p) {
	if (p == 1) return n;
	ll res = func(n, p / 2);
	res *= res;
	res %= mod;
	if (p % 2 == 1) return (res*n)%mod;
	return res;
}

int main() {
	int n; cin >> n;
	ll f = 1;
	fact[0] = fact_inv[0] = 1;
	for (int i = 1; i <= n + 1; ++i) {
		f *= i;
		f %= mod;
		fact.at(i) = f;
		fact_inv.at(i) = func(f, mod - 2);
	}


	for (int i = 1; i <= n; ++i) {
		int a; cin >> a;
		if (appear.at(a) != 0) {
			l = appear.at(a) - 1;
			r = n + 1 - i;
		}
		appear.at(a) = i;
	}

	cout << n << endl;
	for (int k = 2; k <= n; ++k) {
		ll ans = ((fact.at(n + 1) * fact_inv.at(k))%mod * fact_inv.at(n + 1 - k)) % mod;
		if (l + r >= k - 1) ans = (ans + mod - ((fact[l + r] * fact_inv[k - 1]) % mod * fact_inv[l + r - k + 1]) % mod) % mod;
		cout << ans << endl;
	}
	cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;

int main()
{
	char c;
	cin >> c;

	if (c=='a'|| c == 'i' || c == 'u' || c == 'o' || c == 'e') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant " << endl;
	}

}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    lint ans = LINF;
    lint tmp = 0;
    for (int i=0; i<n; ++i){
        if(i % 2 == 0 && s[i] == '0'){
            tmp++;
        }
        else if(i % 2 == 1 && s[i] == '1'){
            tmp++;
        }
    }
    ans = tmp;
    tmp = 0;
    for (int i=0; i<n; ++i){
        if(i % 2 == 0 && s[i] == '1'){
            tmp++;
        }
        else if(i % 2 == 1 && s[i] == '0'){
            tmp++;
        }
    }
    ans = min(tmp, ans);
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int a,b;
    while(cin >> a >> b){
        int c[101] = {};
        a--; b--;
        c[a]++; c[b]++;
        while(cin >> a >> b, a || b){
            a--; b--;
            c[a]++; c[b]++;
        }
        
        if(!(c[0] % 2 && c[1] % 2)) {
            cout << "NG" << endl;
            continue;
        }
        
        bool f = true;
        for(int i = 2; i < 100; ++i){
            if(c[i] % 2) {
                f = false;
                break;
            }
        }
        cout << (f ? "OK" : "NG") << endl;
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define fastio std::ios_base::sync_with_stdio(false), std::cout.tie(0), std::cin.tie(0);
#define N 100007
#define mxx INT_MAX

typedef long long ll;


int main(){
	std::string name;
	std::cin>>name;
	if(name[1]=='R')std::cout<<"ABC";
	else std::cout<<"ARC";





}

Measured memory_bytes: 3596
ls = []
while 1:
    ls1 = list(map(int,input().split()))
    if ls1[0] == 0 and ls1[1] == 0:
        break
    ls.append(list(ls1))
    ls1.clear()
#print(ls)
for i in range(len(ls)):
    ans = 0
    for j in range(1,ls[i][0]+1):
        for k in range(j+1,ls[i][0]+1):
            for l in range(k+1,ls[i][0]+1):
                #print(i,j,k,l,ls[i][1])
                if j + k + l == ls[i][1]:
                    #print(j,k,l)
                    ans += 1
    print(ans)



Measured memory_bytes: 5596
#include<stdio.h>
int main(){
int i,j,yama[10];

for(i=0;i<10;i++)
scanf("%d",&yama[i]);

for(i=0;i<10;i++)
	for(j=0;j<9;j++)
	if(yama[j]<yama[j+1]){
	int a=yama[j];
	yama[j]=yama[j+1];
	yama[j+1]=a;
	}

for(i=0;i<3;i++)
	printf("%d\n",yama[i]);

return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main(){
    int n;
    cin>>n;
    bool a=false;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n){
                a=true;
            }
        }
    }
    if(a){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int L[101];

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, x;
    cin >> n >> x;
    int sum = 0;
    int elem;
    int cnt = 1;
    F0R(i,n)
    {
        cin >> elem;
        sum+=elem;
        if(sum<=x)
            cnt++;
    }
    cout << cnt;

    return 0;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }
template<typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template<typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];


ll solve(int N, vi& a, vi& b) {
    vll fact(N+1);
    fact[0] = 0; fact[1] = 1;
    for(int i=2; i<=N; ++i) fact[i] = MUL(i, fact[i-1]);

    sort(ALL(a)); sort(ALL(b));
    vector<ii> c(N);
    rep(i,N){
        c[i] = ii( min(a[i],b[i]), max(a[i],b[i]) );
    }
    sort(ALL(c));

    vi till(N);
    deque<int> dq;
    dq.push_back(0);

    rep1(i,N-1) {
        while (!dq.empty() && c[dq.front()].second < c[i].first) {
            till[dq.front()] = i-1;
            dq.pop_front();
        }
        dq.push_back(i);
    }
    while (!dq.empty()) {
        till[dq.front()] = N-1;
        dq.pop_front();
    }
    rep(i,N) till[i] -= i-1;
    ll ans = till[0];
    rep1(i,N-1) ans = MUL(ans, till[i]);

    return ans;
}


int main() {
    int N; scanf("%d", &N);
    vi a(N), b(N);
    rep(i,N){
        scanf("%d", &a[i]);
    }
    rep(i,N){
        scanf("%d", &b[i]);
    }
    cout << solve(N,a,b) << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int K = N /2;
    if (N%2 == 0 && S.substr(0, K) == S.substr(K, K)) {
        cout << "Yes" << endl;
    } else {
        cout << "No"  << endl;
    }

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();


int main(){

  ll h,w,res;
  cin >> h >>w;
  
  if(h!=1&&w!=1)
 res=w*(h/2)+(w%2+w/2)*(h%2);
  else
    res=1;
  

  cout << res << endl;
}


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

ll luca(int n){
  ll L[86];
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= n; i++){
    L[i] = L[i-1] + L[i-2];
  }
  return L[n];
}

int main(){
  int n;
  cin >> n;
  cout << luca(n) << endl;
  return 0;
}


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

using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    int ss=s.size();
    int ts=t.size();

    int crt=-1;
    for(int i=0;i<ss;++i){
        bool f=false;
        for(int j=i;j<i+ts;++j){
            if(j>ss-1){
                f=false;
                break;
            }
            if(s[j]==t[j-i]||s[j]=='?') f=true;
            else{
                f=false;
                break;
            }
        }
        if(f) crt=i;
    }
    
    string ans;
    if(crt==-1) ans="UNRESTORABLE";
    else{
        for(int i=crt;i<crt+ts;++i) s[i]=t[i-crt];
        for(int i=0;i<ss;++i) s[i]=s[i]=='?'?'a':s[i];
        ans=s;
    }

    cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
}

Measured memory_bytes: 256
import math
 
n,d=map(int,input().split())
x=[]
for j in range(n):
	tmp=list(map(int,input().split()))
	x.append(tmp)
 
count=0
for i in range(n-1):
	for j in range(i+1,n):
		ans=0
		for (a,b) in zip(x[i],x[j]):
			ans+=(a-b)**2
		if math.sqrt(ans).is_integer():
			count+=1
 
print(count)

Measured memory_bytes: 38416
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;
vector<pii> a[N];
int ans[N];
void dfs(int u,int p,int color)
{
      ans[u]=color;
      for(auto x:a[u])
      {
            if(x.fi==p) continue;
            if(x.se%2==0)
            {
                  dfs(x.fi,u,color);
            }
            else dfs(x.fi,u,1-color);
      }
} 
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n;
      cin>>n;
      for(int i=0;i<n-1;i++)
      {
            int x,y,z;
            cin>>x>>y>>z;
            a[x].pb({y,z});
            a[y].pb({x,z});
      }
      dfs(1,1,0);
      for(int i=1;i<=n;i++) cout<<ans[i]<<"\n";
}     



Measured memory_bytes: 11008
import bisect

while True:

  d = int(raw_input())

  if d == 0:
    break

  n = int(raw_input())
  m = int(raw_input())

  store = []
  store.append(0)
  store.append(d)

  for x in xrange(n - 1):
    s = int(raw_input())
    store.append(s)

  store.sort()

  ans = 0

  # print repr(store)

  for x in xrange(m):
    p = int(raw_input())

    l = bisect.bisect_right(store, p) - 1
    r = bisect.bisect_right(store, p)

    l_ = store[l]
    r_ = store[r]

    # print 'log L:%d R:%d p:%d' % (l_, r_, p)

    t = min(abs(p - l_), abs(p - r_))
    ans += t

  print ans

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

void fnInput(vector<string>& rvsBoard)
{
  int nHigh, nWide;
  cin >> nHigh >> nWide;

  rvsBoard.resize(nHigh);
  for (int ny = 0; ny < nHigh; ny++)
    cin >> rvsBoard[ny];
}

int fnCountBomb(int ny, int nx, const vector<string>& cnrvsBoard)
{
  if (   ny >= 0  && ny < cnrvsBoard.size()
      && nx >= 0  && nx < cnrvsBoard[ny].size())
    if (cnrvsBoard[ny][nx] == '#')  return 1;
    else;

  return 0;
}

void fnMinesweeper(vector<string>& rvsBoard)
{
  const vector<int> cnvnDy = {-1, -1, -1,  0,  0,  1,  1,  1};
  const vector<int> cnvnDx = {-1,  0,  1, -1,  1, -1,  0,  1};
  for (int ny = 0; ny < rvsBoard.size(); ny++)
    for (int nx = 0; nx < rvsBoard[ny].size(); nx++)
      if (rvsBoard[ny][nx] == '.')
      {
        int nCount = 0;
        for (int i = 0; i < cnvnDy.size(); i++)
          nCount += fnCountBomb(ny + cnvnDy[i], nx + cnvnDx[i], rvsBoard);

        rvsBoard[ny][nx] = '0' + nCount;       // int → char 変換
      }
}

void fnResult(const vector<string>& cnrvsBoard)
{
  for (string sBoard : cnrvsBoard)
    cout << sBoard << endl;
}

int main()
{
  vector<string> vsBoard;

  fnInput(vsBoard);
  fnMinesweeper(vsBoard);
  fnResult(vsBoard);

  return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long h = sc.NextLong();
        long w = sc.NextLong();
        long n = sc.NextLong();

        long answer = (n + Math.Max(h, w) - 1) / Math.Max(h, w);

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x1,Y1,x2,y2,x3,y3;
int main()
{
	ll s;
	cin>>s;
	x1=0,Y1=0;
	x2=1;y2=1e9;
	x3=s/y2;
	if(x3*y2!=s)x3++;
	y3=x3*y2-s;
	cout<<x1<<" "<<Y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
const int maxn=12;
int n;
int a[maxn];

int dd;

long long LCM(int a[],int n)
{
    long long m=1;
    for(int i=0; i<n; i++) m*=a[i];
    long long _min=m,cnt=0;
    for(int i=0; i<n; i++)
    {
        a[i]=m/a[i];
    }
    int pos;
    for(;;)
    {
        sort(a,a+n);
//         for(int i=0; i<n; i++) printf("%d ",a[i]);
//         printf("\n");
        pos=lower_bound(a,a+n,1)-a;
        if(a[pos]==1||pos==n-1) return m/a[pos];
        for(int i=0; i<n; i++)
        {
            if(i!=pos) a[i]%=a[pos];
        }
    }
    return 0;



}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    printf("%ld\n",LCM(a,n));
    return 0;

}

Measured memory_bytes: 3244
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[] wt = new int[n];
        int[] p  = new int[n];
        for (int i = 0; i < n; i++) {
            wt[i] = scanner.nextInt();
            p[i]  = scanner.nextInt();
        }
        long[][] dp = new long[n+1][w+1];
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= w; j++) {
                if(i==0 || j==0)
                    dp[i][j]=0;
                else if(wt[i-1] <= j)
                    dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j-wt[i-1]] + p[i-1]);
                else
                    dp[i][j] = dp[i-1][j];
            }
        }
        System.out.println(dp[n][w]);
    }
}


Measured memory_bytes: 140480
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

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

    ll R, C, K;
    cin >> R >> C >> K;
    vector<vector<ll>> a(R, vector<ll>(C, 0));
    ll r, c, v;
    REP(_, 0, K)
    {
        cin >> r >> c >> v;
        a[--r][--c] = v;
    }

    vector<vector<vector<ll>>> dp(R + 1, vector<vector<ll>>(C + 1, vector<ll>(4, 0)));
    REP(i, 0, R)
    REP(j, 0, C) REP(k, 0, 4)
    {
        if (k < 3)
        {
            dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k] + a[i][j]);
            dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + a[i][j]);
        }
        dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
        dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
    }

    ll ans = 0;
    REP(i, 0, R + 1)
    REP(j, 0, C + 1) REP(k, 0, 4) ans = max(ans, dp[i][j][k]);
    cout << ans << endl;
}


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

int main()
{
	ll n, k;
	cin >> n >> k;
	vector<pair<ll, ll>> ab(n);
	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		ab[i] = make_pair(a, b);
	}
	sort(ab.begin(), ab.end());
	ll sumb = 0;
	for (const auto& item : ab) {
		sumb += item.second;
		if (k <= sumb) {
			cout << item.first;
			return 0;
		}
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    int n;
    cin>>n;
long tt=0;
for(int i=1;i<=n;i++)
{
cin>>a[i];
tt+=abs(a[i]-a[i-1]);
}
tt+=abs(a[n]);
for(int i=1;i<=n;i++)
{
    long ans=tt+abs(a[i-1]-a[i+1])-abs(a[i-1]-a[i])-abs(a[i+1]-a[i]);
    cout<<ans<<endl;
}
return 0;
}
 


Measured memory_bytes: 1664
fun main(args : Array<String>) {
    val ss = readLine()!!

    val stack = mutableListOf<Char>()
    var count = 0

    for(i in ss.indices) {
        if (stack.size == 0) {
            stack.add(ss[i])
        } else if (stack.last() != ss[i]) {
            stack.removeAt(stack.size-1)
            count += 2
        } else {
            stack.add(ss[i])
        }
    }

    println(count)
}

Measured memory_bytes: 34688
N,M=map(int,input().split())
temp=0
TEMP=N-1
for i in range(M):
    a,b=map(int,input().split())
    if b-1<temp or TEMP<a-1:
        print(0)
        exit()
    if a-1>temp:
        temp=a-1
    if TEMP>b-1:
        TEMP=b-1
    
print(TEMP-temp+1)


Measured memory_bytes: 9044
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n, m, k = 2e9, a[N], b[N], ans, f[N];
char s[N];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); m = read(); scanf("%s", s + 1);
	int tag = 1;
	for(int i = 1, len = 0; i <= m; i ++)
	{
		if(s[i] != s[1])
		{
			if(tag || len & 1) k = min(k, len / 2 + 1);
			tag = len = 0;
		}
		else len ++;
	}
	if(tag)
	{
		f[0] = 0; f[1] = 1;
		for(int i = 2; i <= n; i ++) f[i] = (f[i - 1] + f[i - 2]) % mod;
		printf("%lld\n", (2 * f[n - 1] + f[n]) % mod);
		return 0;
	}
	if(n & 1) {puts("0"); return 0;}
	n /= 2; a[0] = b[0] = 1;
	for(int i = 1; i <= n; i ++)
	{
		a[i] = b[i - 1];
		if(i > k) a[i] = (b[i - 1] - b[i - k - 1] + mod) % mod;
		b[i] = (b[i - 1] + a[i]) % mod;
	}
	for(int i = 1; i <= k; i ++) ans = (ans + 2 * i * a[n - i]) % mod;
	printf("%lld\n", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const int N_MAX = pow(10, 5);
int main (void) {
    int n;
    int h;
    int amax = 1;
    int b[N_MAX];
    int ans = 0;
    int bi = 0;

    cin >> n >> h;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a >> b[i];
        amax = max(amax, a);
    }

    sort(b, b + n, greater<int>());

    while (h > 0) {
        if (bi >= n) h -= amax;
        else {
            if (amax >= b[bi]) h -= amax;
            else h -= b[bi++];
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main(void){
    char t[5];
    int i,j;
    scanf("%s",t);
    for(i=0;i<8;i++){
        char siki[20]={'\0'};
        int tmp=t[0]-'0';
        siki[0] = t[0];
        for(j=0;j<3;j++){
            if(i&(1<<j)){
                sprintf(siki,"%s%c%c",siki,'+',t[j+1]);
                tmp = tmp + (t[j+1]-'0');
            }
            else{
                sprintf(siki,"%s%c%c",siki,'-',t[j+1]);
                tmp = tmp - (t[j+1]-'0');
            }
        }
        if(tmp==7){
            for(j=0;siki[j]!='\0';j++) printf("%c",siki[j]);
            printf("=7\n");
            return 0;
        }
    }

}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
using namespace std;
typedef long long LL;

int main(void) {
	int h, w, i, j;
	cin >> h >> w;
	vector<string> s(h);
	for (i = 0; i < h; i++) {
		cin >> s[i];
	}
	for (i = 0; i < h; i++) {
		cout << s[i] << endl;
		cout << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
type Table = ([Int],[Int],[Int])
fst3 (x,_,_) = x

primes :: [Int]
primes = concatMap fst3 $ iterate sieve ([],[2],[2..])
sieve :: Table -> Table
sieve (ps,q:qs,ss)
    = let (xs,ys) = span (q*q >) ss
    in (xs,qs++xs,filter ((/= 0) . (`mod` q)) ys)

main = getContents >>= mapM_ print . map (\n -> (length $ takeWhile (<=n) primes)) . map read . words

Measured memory_bytes: 18652
b,a = map(int,input().split())
lis = []
for i in range(50):
	g = []
	for m in range(100):
		g.append(".")
	lis.append(g)
for i in range(50):
	g = []
	for m in range(100):
		g.append("#")
	lis.append(g)
cou = 0
co = 0
for k in range(a-1):
	lis[cou][co] = "#"
	co += 2
	if co >= 100:
		co = 0
		cou += 2
cou = 51
co = 0
for h in range(b-1):
	lis[cou][co] = "."
	co += 2
	if co >= 100:
		co = 0
		cou += 2
print("100 100")
for m in range(100):
	print("".join(lis[m]))

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


int main()
{
	
	int n,k;
	cin>>n>>k;
	vector<int>a;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		a.push_back(x);
	}
	// sort(a.begin(),a.end());
	
	vector<bool> dp(k+1);
  for(int i = 1;i<=k;i++)
    for(int j = 0;j<n;j++)
      if(a[j] <= i && dp[i - a[j]] == false)
        dp[i] = true;
      
    
  
	if(dp[k])
		cout<<"First";
	else
		cout<<"Second";
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    cin >> n;

    set<int> st;
    for (int i = 0 ;i < n ;i++) {
        int x;
        cin >> x;
        st.insert(x);
    }

    cout << (st.size() == n ? "YES" : "NO");
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
   int n,m; cin >> n >> m;
   vector<vector<int>> E(n);
   int ans[n];
   rep(i,1,n) ans[i] = MOD;

   rep(i,0,m){
      int a,b; cin >> a >> b;
      a--; b--;
      E[a].push_back(b);
      E[b].push_back(a);
   }

   queue<int> q;
   q.push(0);
   while(q.size()){
      int tp = q.front();
      q.pop();
      rep(i,0,E[tp].size()){
         if(ans[E[tp][i]] == MOD){
            ans[E[tp][i]] = tp+1;
            q.push(E[tp][i]);
         }
      }
   }

   cout << "Yes\n";
   rep(i,1,n){
      cout << ans[i] << "\n";
   }
}

Measured memory_bytes: 10204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			 System.out.println(Math.max(a,b)>8?":(":"Yay!");
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll w[n];
    for(ll i=0; i<n; i++) {
        cin>>w[i];
    }
    ll right=0;
    ll left=0;
    ll max=n;
    for(ll i=0; i<n; i++) {
        right=0;
        left=0;
        for(ll j=0; j<i; j++) {
            left += w[j];
        }
        for(ll j=i; j<n; j++) {
            right += w[j];
        }

        if(llabs(right-left)<max){
            max = llabs(right-left);
        }
    }

    cout<<max<<endl;
    return  0;
}

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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint fact[1000005];

modint nCk(int n, int k) {
  return fact[n] / fact[k] / fact[n - k];
}

int main() {
  int N, K;
  cin >> N >> K;
  fact[0] = fact[1] = 1;
  for (int i = 2; i < 1000005; i++) {
    fact[i] = fact[i - 1] * i;
  }
  modint ans = 0;
  for (int i = 0; i < N; i++) {
    if (i > K) {
      break;
    }
    ans += nCk(N, i) * nCk(N - 1, N - i - 1);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 8064
n = int(input())
info = [list(map(int,input().split())) for i in range(n)]

cnt_l = info[0][0]
cnt_r = info[0][1]
#print(cnt_l,cnt_r)
for i in range(1,n):
  tmpcnt_l = info[i][0]
  tmpcnt_r = info[i][1]
  
  if cnt_l > tmpcnt_l and cnt_l/tmpcnt_l >= cnt_r/tmpcnt_r:
    cnt_l = (cnt_l//tmpcnt_l+int(bool(cnt_l%tmpcnt_l))) * tmpcnt_l
    cnt_r = (cnt_l//tmpcnt_l+int(bool(cnt_l%tmpcnt_l))) * tmpcnt_r
  elif cnt_r > tmpcnt_r and cnt_l/tmpcnt_l <= cnt_r/tmpcnt_r:
    cnt_l = (cnt_r//tmpcnt_r+int(bool(cnt_r%tmpcnt_r))) * tmpcnt_l
    cnt_r = (cnt_r//tmpcnt_r+int(bool(cnt_r%tmpcnt_r))) * tmpcnt_r
  else:
    cnt_l = tmpcnt_l
    cnt_r = tmpcnt_r
#  print(cnt_l,cnt_r)
print(cnt_l+cnt_r)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,INF=0x3f3f3f3f;
typedef pair<int,int> pii;
int fa[N],vis[N],mi[N],V[N];
vector<pii >Q(N);
int find(int x)
{
    return x==fa[x]?x:(fa[x]=find(fa[x]));
}
inline char tc(){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(){
	int a=0;char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int main()
{
    ios::sync_with_stdio(false);
    int n=read(),m=read(),tn=0;
    for(int i=0; i<n; i++)
        Q[i].first=read(),fa[i]=i,mi[i]=INF;
    for(int i=0,u,v; i<m; i++)
    {
        u=read(),v=read(),u=find(u),v=find(v);
        if(u!=v)fa[u]=v;
    }
    for(int i=0; i<n; i++)
    {
        find(i);
        if(!vis[fa[i]])V[tn++]=fa[i];
        vis[fa[i]]=1,Q[i].second=fa[i],mi[fa[i]]=min(Q[i].first,mi[fa[i]]);
    }
    if(tn==1)cout<<0;
    else if((tn-1)*2>n)cout<<"Impossible";
    else
    {
        long long s=0;
        for(int i=0; i<tn; i++)s+=mi[V[i]];
        if(tn!=2)sort(Q.begin(),Q.begin()+n);
        for(int i=0; i<n&&tn!=2; i++)
        {
            if(vis[Q[i].second])
            {
                vis[Q[i].second]=0;
                continue;
            }
            s+=Q[i].first,tn--;
        }
        cout<<s;
    }
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const ll MOD = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> last{1};
    rep(i,1,n) {
        vector<ll> next(i+1);
        if(s[i-1]=='>') reverse(all(last));
        rep(j,1,i+1) {
            next[j] = (next[j-1]+last[j-1])%MOD;
        }
        if(s[i-1]=='>') reverse(all(next));
        swap(last,next);
    }
    ll ans = 0;
    rep(i,0,n) ans = (ans+last[i])%MOD;
    cout << ans << "\n";
} 


Measured memory_bytes: 384
import sys
import collections

# Set max recursion limit
sys.setrecursionlimit(1000000)


def li_input():
    return [int(_) for _ in input().split()]


def main():
    N = int(input())
    C = [input().split() for _ in range(N)]

    D = collections.defaultdict(lambda: 0)

    for c in C:
        command, value = c

        if command == "insert":
            D[value] = 1
        else:
            if D[value] == 1:
                print("yes")
            else:
                print("no")


main()



Measured memory_bytes: 319540
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}

int f(int n){
  if(n==0) return 0;

  return n%10+f(n/10);
}

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

  int n;
  cin>>n;

  Yes(n%f(n)==0);


}

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



#define pp pair<int,int>
#define oo 100000000
#define RRR ios_base::sync_with_stdio(false);cin.tie(0);
#define ll long long
// #define int ll

int32_t main()
{RRR
    int n;
    cin >> n;
    string b;
    for (int i=0;i<n;i++)
    {
        cin >> b;
        if (b[0] == 'Y')
        return cout << "Four",0;
    }
  cout << "Three";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define umii unordered_map<ll,ll> 
#define umib unordered_map<ll,bool>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define pb push_back
#define eb emplace_back


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string S,T;
    cin>>S;
    cin>>T;
    int minC = T.size();
    for(int i = 0;i<=S.size()-T.size();i++)
    {
        int nsame = 0;
        for(int j = i;j<i+T.size();j++)
        {
            if(T[j-i]==S[j])
                nsame++;
        }
        minC = min(minC,int(T.size()-nsame));
    }
    cout<<minC;
	return 0;
}


Measured memory_bytes: 3616
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// 基本テンプレート
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;


// Effective std
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }

template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }

template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }

template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }

template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }

template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }


// グラフテンプレート
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int f = 0, s = 0;
  if (a==5) f++;
  if (a==7) s++;
  if (b==5) f++;
  if (b==7) s++;
  if (c==5) f++;
  if (c==7) s++;
  if(f==2&&s==1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}



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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ld tmp=0;
  rep(i,0,n)tmp+=ld(1)/a[i];
  lfs<<1/tmp<<endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val d = readLine()!!.toInt()
    var ans = 0
    for(i in 0..a){
        for(j in 0..b){
            for(k in 0..c) {
                if(500*i + 100*j + 50*k == d) ans++
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 29932
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)


// ------------debug用------------
#define FALSE cout<<"false"<<endl;
#define TRUE cout<<"true"<<endl;
// ------------debug用------------


// ------------計算用------------
#define ALL(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)
// ------------計算用------------


// ------------出力用------------
#define PRINT(x) cout<<x<<endl;
// ------------出力用------------


using namespace std;
typedef long long ll;

int main(){
  int N;
  cin>>N;
  vector<int> a(N);FOR(N)cin>>a[i];
  sort(ALL(a));
  
  int ans = abs(a[N / 2] - a[N / 2 - 1]);

  cout<<ans;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

typedef long long ll;

using namespace std;

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

int H, W;
bool memo[1010][1010];
queue<pair<int, int>> q;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {0, 0, 1, -1};

int main() {
    cin >> H >> W;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char x; cin >> x;
            if (x == '.') memo[i][j] = false;
            else {
                q.push(make_pair(i, j));
                memo[i][j] = true;
            }
        }
    }

    int res = 0;

    // memoするタイミングと実行の時差に注意
    while(!q.empty()) {
        ++res;

        int round = q.size();
        for (int i = 0; i < round; ++i) {
            pair<int, int> p = q.front(); q.pop();
            int px = p.first;
            int py = p.second;

            for (int j = 0; j < 4; j++) {
                int dxj = dx[j];
                if (px + dxj < 0 || H <= px + dxj) continue;

                for (int k = 0; k < 4; k++) {
                    int dyk = dy[k];
                    if (py + dyk < 0 || W <= py + dyk) continue;

                    // 斜めに移動はできない
                    if (abs(dxj * dyk) == 1) continue;

                    if (!memo[px + dxj][py + dyk]) {
                        q.push(make_pair(px + dxj, py + dyk));
                        memo[px + dxj][py + dyk] = true;

                    }
                }
            }
        }
    }

    cout << (res - 1) << endl;
}


Measured memory_bytes: 9488