akhauriyash/Code-Regression huggingface dataset:
/*
	problem: 
	
	
*/

#include<bits/stdc++.h>
/*
#pragma GCC optamize("O2")
#pragma G++ optamize("O2")
*/
using namespace std;
const long long maxn = 0x3f3f3f3f;
typedef long long LL;

LL mi[31];
LL N;
LL a[200100];
map <LL, LL> mp;

int main() {
	
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	
	LL i, j, k;
    mi[0] = 1;
    for (i = 1; i <= 30; ++ i) mi[i] = (mi[i - 1] << 1);
    scanf("%lld", &N);
    for (i = 1; i <= N; ++ i) {
        scanf("%lld", &a[i]);
        ++ mp[a[i]];
    }
    sort(a + 1, a + N + 1);
    j = 30;
    LL ans = 0;
    for (i = N; i >= 1; -- i) {
        if (!mp[a[i]]) continue;
        while (mi[j] > (a[i] << 1) && j >= 0) -- j;
        LL x;
        if (a[i] != mi[j] - a[i]) {
            x = min(mp[a[i]], mp[mi[j] - a[i]]);
        }
        else {
            x = mp[a[i]] / 2;
        }
        mp[a[i]] -= x;
        mp[mi[j] - a[i]] -= x;
        ans += x;
    }
    printf("%lld\n", ans);
	
	return 0;
}
/*
3
1 2 3
5
3 11 14 5 13
*/ 


Measured memory_bytes: 30276
#include<stdio.h>
#include<stdlib.h>
#define N 100
int top=0;
int push(int);
int pop(void);

int main(){
  int x,y,e;
  char data[N],d,c;
  
  while(scanf("%s",data)!=EOF){
    
     if(data[0]== '+'){
      x =pop();
      y =pop();
     push(y+x);
    }
     else if(data[0]== '-'){
      x = pop();
      y =pop();
      push(y-x);
    }
    
    else if(data[0]== '*'){
      x =pop();
      y =pop();
      push(y*x);
    }

    else{ 
      e = atoi(data);
      push(e);
    }
   
  }
  printf("%d\n",pop());
  return 0;
}

int data[N];

  int push(int e){
    data[top++] = e ;
    return e;
  }
  
  int pop(void){
    return data[--top];
  }

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll K[101][100001];
int main()
{
	ll n,w,i,m;
	scanf("%lld%lld",&n,&m);
	ll wt[n],v[n];
    for(i=0;i<n;i++)
       scanf("%lld%lld",&wt[i],&v[i]);
    for(i=0;i<=n;i++)
    for(w=0;w<=m;w++)
    	{
    		if(i==0||w==0)
    			K[i][w]=0;
    		else if(wt[i-1]<=w)
    			K[i][w]=max((v[i-1]+K[i-1][w-wt[i-1]]),(K[i-1][w]));
            else
            	K[i][w]=K[i-1][w];
    	}
    printf("%lld\n",K[n][m]);

}

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

int main()
{
        int N, M;
        cin >> N >> M;
        vector<vector<int>> V(N);
        for (int i = 0; i < M; ++i) {
                int a, b;
                cin >> a >> b;
                V[a-1].push_back(b-1);
                V[b-1].push_back(a-1);
        }
#if 0
        for (int i = 0; i < N; ++i) {
                int len = V[i].size();
                for (int j = 0; j < len; ++j) {
                        cout << V[i][j] << " ";
                }
                cout << endl;
        }
#endif
        vector<int> check(N, -1);
        check[0] = 1;
        queue<int> que;
        que.push(0);
        int num = 1;
        vector<int> ans(N, 0);
        while (1) {

                if (que.empty()) break;

                int v = que.front();
                que.pop();

                for (int i = 0; i < V[v].size(); ++i) {

                        int vt = V[v][i];
                        if (check[vt] != -1) continue;

                        check[vt] = 1;
                        que.push(vt);
                        ans[vt] = v;
                        num++;

                }
        }

        if (num != N) {
                cout << "No" << endl;
        }
        else {
                cout << "Yes" << endl;
                for (int i = 1; i < N; ++i) {
                        cout << ans[i]+1 << endl;
                }
        }



}


Measured memory_bytes: 10704
#include <iostream>
#include <vector>


using namespace std;

int main() {
  int x[5];
  int  k;
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4] >> k;
  if (x[4] - x[0] <= k)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 3628
// abc145_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, T;
    cin >> N >> T;

    vector<P> BA(N);
    REP(i, N) cin >> BA[i].second >> BA[i].first;

    sort(ALL(BA), greater<P>());

    int ans = 0;
    REP(mx, min(100, N)){

        vector<int> dp(T+1);
        dp[0] = 0;
        REP(i, N){
            if (i == mx) continue;
            int a = BA[i].second;
            int b = BA[i].first;

            auto prev = dp;
            REPN(j, a, T){
                dp[j] = max(prev[j - a] + b, prev[j]);
            }
        }

        ans = max(ans, dp[T-1] + BA[mx].first);
    }

    print(ans);

    return 0;
}


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

#define int long long

const int N = 2e5 + 7;

int a[N], b[N];

int32_t main() {
	int n, m, k; cin >> n >> m >> k;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}

	for(int i = 1; i <= m; i++) {
		cin >> b[i];
		b[i] += b[i - 1];
	}

	int ans = 0;

	for(int i = 0; i <= n; i++) {
		if(a[i] <= k) {
			int j = upper_bound(b + 1, b + m + 1, k - a[i]) - b - 1;
			ans = max(ans, i + j);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 6712
//When Can We Meet?
#include <stdio.h>
int main(void){
    int N, Q;
    int M, m[100] = {};
    int count[100] = {};
    int max = 0 ,l;
    
    for ( int i = 0;; i++){
        scanf ("%d%d", &N, &Q);
        if (N == 0) break;
        max = 0;
        for (int h = 0; h < 100; h++) count[h] = 0;
        for ( int j = 0; j < N; j++){
            scanf ("%d", &M);
            for ( int k = 0; k < M; k++){
                scanf ("%d", &m[k]);
                count[m[k]]++;
                if (max < count[m[k]]) max = count[m[k]];
            }
        }
        for ( l = 0; l < 100; l++){
            if (count[l] >= Q && count[l] == max ){
                printf ("%d\n", l);
                break;
            }
        }
        if (l == 100) printf ("0\n");
    }
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,k;
int main(void){
    cin>>n>>k;
    if(2*k>n+1)cout<<-1<<endl;
    else{
		if(n%2){
			ll a=k,b=k+n+n/2LL,c=k+n*2LL;
			for(int i=0;i<n/2+1;i++){
				cout<<a<<' '<<b<<' '<<c<<endl;
				a+=2LL,b--,c++;
			}
			a=k+1,b=k+2LL*n-1LL;
			for(int i=0;i<n/2;i++){
				cout<<a<<' '<<b<<' '<<c<<endl;
				a+=2LL,b--,c++;
			}
		}else{
			ll a=k,b=k+n+n/2LL,c=k+n*2LL;
			for(int i=0;i<n/2;i++){
				cout<<a<<' '<<b<<' '<<c<<endl;
				a+=2LL,b--,c++;
			}
			cout<<k+n-1LL<<' '<<k+n<<' '<<c<<endl;
			c++;
			a=k+1,b=k+2LL*n-1LL;
			for(int i=0;i<n/2-1;i++){
				cout<<a<<' '<<b<<' '<<c<<endl;
				a+=2LL,b--,c++;
			}
		}
	}
    
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ll)(1e9+7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	ll cnt=n-1;
	for(ll i=2 ; i<n ; ++i){
		for(ll j=1 ; ; ++j){
			if(i *j >=n)break;
			++cnt;
		}
	}
	
	cout << cnt;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }

 if(a>c){
    tmp=a;
    a=c;
    c=tmp;
  }

  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }

  printf("%d %d %d\n",a,b,c);
  
  return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

vector<vector<int>> dp;
vector<pair<int, int>> vec;

int rec(int idx, int h){

	if(h <= 0) return 0;
	if(idx == (int)vec.size()) return (int)2e9;

	int &res = dp[idx][h];
	if(res != -1) return res;

	// res = (int)2e9;

	res = rec(idx + 1, h);
	res = min(res, vec[idx].Y + rec(idx, h - vec[idx].X));

	return res;
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);
	
	int h, n;
	cin >> h >> n;

	vec.resize(n);
	for(auto &p : vec){
		 cin >> p.X >> p.Y;
	}

	dp.resize(n, vector<int>(h + 1, -1));

	cout << rec(0, h);

	return 0;
}

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

int main()
{
	int k, x; cin >> k >> x;
	
	const int leftLimit = -1000000;
	const int rihgtLimit = 1000000;

	int left = max(leftLimit, x - k + 1);
	int right = min(rihgtLimit, x + k - 1);
	
	for (int i = left; i <= right; i++) {
		cout << i << " ";
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N =  int(sys.stdin.readline())
L =  list(map(int, sys.stdin.readline().split()))

# 順方向と逆方向から計算したリストを保持しておく？
# 戻るときはリストの最も右の要素と原点とのdiffをとればいい

# 増加しなければスキップしてもかかる金額は変わらない

L = [0] + L
A = [abs(x - y) for x , y in zip(L, L[1::])]
SA = sum(A)
ans = 0

for i in range(N):
    if i < N - 1:
        idx = i + 1
        x = L[idx]
        # 単調減少か、または単調増加か
        right = L[idx + 1] - x
        left = x - L[idx - 1]
        if (left >= 0 and right >= 0) or (left <= 0 and right <= 0):
            ans = SA
        else:
            ans = SA - (abs(x - L[idx - 1]) + abs(x - L[idx + 1])) + abs(L[idx + 1] - L[idx - 1])
        print(ans + abs(L[N]))
    else:
        print(SA - abs(L[N] - L[N - 1]) + abs(L[N - 1]))



Measured memory_bytes: 93556
#include<iostream>
#include<cmath>

using namespace std;

int func(int a,int b)
{
	int r = a%b;
	while(r != 0)
	{
		a = b;
		b = r;
		r = a%b;
	}
	return b;
}

void sort(int a[],int n)
{
	int i = 0,j = n - 1;
	int pivot = a[(i+j)/2];

	while(true)
	{
		while(a[i] < pivot)i++;
		while(a[j] > pivot)j--;

		if( i >= j )break;

		int hold = a[i];
		a[i] = a[j];
		a[j] = hold;

		i++;
		j--;
	}

	if( i > 1 )sort(a,i);
	if( n-j-1 > 1)sort(a+j+1,n-j-1);
}

int main()
{
	int N;
	int *a;
	int ans;

	cin >> N;
	a = new int[N];

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

	sort(a,N);

	bool flag = true;
	ans = a[0];

	for(int i=1;i<N;i++)
	{
		ans = min(ans,func(a[i],a[0]));
	}

	cout << ans << endl;

	delete(a);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n,i,j,k;
string a[100010];
long long nr,lg;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        for(j=0;j<9;j++)
            for(k=j+1;k<=9;k++)
                if(a[i][j]>a[i][k])
                    swap(a[i][j],a[i][k]);
    }
    sort(a+1,a+n+1);
    for(i=1;i<=n;i++)
    {
        j=i;
        lg=0;
        while(a[j]==a[j+1])
        {
            lg++;
            j++;
        }
        nr=nr+lg*(lg+1)/2;
        i=max(i,j-1);
    }
    cout<<nr;
    return 0;
}



Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define SIZE 30

int main(){
    int N,K; cin>>N>>K;
    int A[100000],B[100000];
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
    }
    ll ans=0;
    for(int i=0;i<SIZE;i++){
        if((K>>i)&1){
            //Kのi桁目を0にして，それ以下の桁は全部1にする．
            int d[SIZE];
            for(int j=0;j<SIZE;j++){
                if(j<i){
                    d[j]=1;
                }else if(j==i){
                    d[j]=0;
                }else{
                    d[j]=(K>>j)&1;
                }
            }
            ll tmp=0;
            for(int n=0;n<N;n++){
                //A[n]について考える．
                bool flag=true;
                for(int j=0;j<SIZE;j++){
                    if(d[j]==0 && ((A[n]>>j)&1)==1){
                        flag=false;
                        break;
                    }
                }
                if(flag){
                    tmp+=B[n];
                }
            }
            ans=max(ans,tmp);
        }
    }
    //補正しないKについて．
    int d[SIZE];
    for(int j=0;j<SIZE;j++){
        d[j]=(K>>j)&1;
    }
    ll tmp=0;
    for(int n=0;n<N;n++){
        //A[n]について考える．
        bool flag=true;
        for(int j=0;j<SIZE;j++){
            if(d[j]==0 && ((A[n]>>j)&1)==1){
                flag=false;
                break;
            }
        }
        if(flag){
            tmp+=B[n];
        }
    }
    ans=max(ans,tmp);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
fun main() {
    val N= readLine()!!.toInt()
    val K = readLine()!!.toInt()

    print(dfs(N, 1, K))
}

fun dfs(remain: Int, now:Int, K:Int): Int {
    if (remain == 0) {
        return now
    }

    return Math.min(dfs(remain - 1, now *2, K), dfs(remain - 1, now + K, K))
}


Measured memory_bytes: 34540
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=305;
const int mod=998244353;
int n,ans=1,s;
int a[maxn],dp[maxn][maxn*maxn];

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	dp[0][0]=1;
	rep(i,n){
		scanf("%d",&a[i]);
		rep(j,300*i+1){
			int cur=dp[i][j];
			if(!cur)continue;
			dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+cur)%mod;
			dp[i+1][j]=(dp[i+1][j]+2LL*cur)%mod;
		}
		ans=3LL*ans%mod;
		s+=a[i];
	}
	for(int i=(s+1)/2;i<=s;i++)ans=(ans-3LL*dp[n][i]%mod+mod)%mod;
	if(s%2==0){
		rep(i,n+1)rep(j,300*n+1)dp[i][j]=0;
		dp[0][0]=1;
		rep(i,n)rep(j,300*i+1){
			int cur=dp[i][j];
			if(!cur)continue;
			dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+cur)%mod;
			dp[i+1][j]=(dp[i+1][j]+cur)%mod;
		}
		ans=(ans+3LL*dp[n][s/2])%mod;
	}
	printf("%d\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 110848
round_n = int(input())

Taro = 0
Hanako = 0

for n in range(0, round_n):
    _in = input().split()
    if (_in[0] > _in[1]):
        Taro += 3
    elif (_in[0] < _in[1]):
        Hanako += 3
    else :
        Taro += 1
        Hanako += 1

print(str(Taro) + ' ' + str(Hanako))


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    if(s=="Cloudy") cout<<"Rainy"<<endl;
    if(s=="Rainy") cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

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

Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <random>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
#include <time.h>

using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
V Colors;
bool Bipartite_graph_DFS(VV &gragh,V & Colors,ll start,ll nowcolor){
    for(auto i:gragh[start]){
        if(Colors[i]!=-1){
            if(Colors[i]==nowcolor){
                return false;
            }
        }else{
            Colors[i]=1^nowcolor;
            if(!Bipartite_graph_DFS(gragh,Colors,i,1^nowcolor))return false;
        }
    }
    return true;
}
bool Bipartite_graph(ll N,VV &gragh){
    Colors.resize(N,-1);
    return Bipartite_graph_DFS(gragh,Colors,0,0);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    VV gragh(n);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        gragh[a].push_back(b);
        gragh[b].push_back(a);
    }
    if(Bipartite_graph(n,gragh)){
        ll wcount=0;
        ll bcount=0;
        rep(i,n){
            if(Colors[i]){
                wcount++;
            }else{
                bcount++;
            }
        }
        cout<<wcount*bcount-m<<endl;
    }else{
        cout<<n*(n-1)/2-m<<endl;
    }
}


Measured memory_bytes: 7552
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}


int main()
{
    int a, b;
    scanf("%d%d",&a,&b);
    printf("%d",MAX3(a+b, 2*a-1, 2*b-1));
    return 0;
}


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


int main() {
  int a, b;
  cin >> a >> b;
  if(a<6) cout << 0 << endl;
  else if(a<13) cout << b/2 << endl;
  else cout << b << endl;
  return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

string str;

int main() {
    cin >> str;
    int k = 15 - str.size();
    rep(i,str.size()) {
        if (str[i] == 'o') k++;
    }
    if (k >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main(){
    string s;
    ll count = 0;
    cin >> s;
    if(s[0] == '0'){
        rep(i,s.size()){
            if(i%2 == 0 && s[i] != '0') count++;
            if(i%2 != 0 && s[i] != '1') count++;
        }
    }
    if(s[0] == '1'){
        rep(i,s.size()){
            if(i%2 == 0 && s[i] != '1') count++;
            if(i%2 != 0 && s[i] != '0') count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,k,Act[100005][3],dp[100005][3];
int solve(int ind, int act){
	if(ind < 0){
		return INT_MIN;
	}
	if(ind == 0){
		return Act[0][act];
	}
	if(dp[ind][act] != -1){
		return dp[ind][act];
	}
	if(act == 0){
		dp[ind][0]=max(solve(ind-1,1),solve(ind-1,2))+Act[ind][0];
	}
	else if(act == 1){
		dp[ind][1]=max(solve(ind-1,0),solve(ind-1,2))+Act[ind][1];
	}
	else{
		dp[ind][2]=max(solve(ind-1,0),solve(ind-1,1))+Act[ind][2];
	}
	return dp[ind][act];
}
int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>Act[i][0];
		cin>>Act[i][1];
		cin>>Act[i][2];
	}
	for(int i=0;i<n;i++){
		dp[i][0]=-1;
		dp[i][1]=-1;
		dp[i][2]=-1;
	}
	int ans=solve(n-1,0);

	for(int i=0;i<n;i++){
		dp[i][0]=-1;
		dp[i][1]=-1;
		dp[i][2]=-1;
	}
	ans=max(ans,solve(n-1,1));

	for(int i=0;i<n;i++){
		dp[i][0]=-1;
		dp[i][1]=-1;
		dp[i][2]=-1;
	}
	ans=max(ans,solve(n-1,2));

	cout<<ans;
	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	int a=s.length();
	if(s[0]==s[a-1]) {
		if(a%2==0)
			cout<<"First"<<endl;
		else
			cout<<"Second"<<endl;
	} else {
		if(a%2==0)
			cout<<"Second"<<endl;
		else
			cout<<"First"<<endl;
	}
}

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

#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 INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;

typedef long long ll;

bool linearSearch(int A[], int n, int key) {
    A[n] = key;
    int i = 0;
    while (A[i] != key) ++i;
    return i != n;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    
    int A[n];
    REP(i, n) cin >> A[i];

    int q; cin >> q;
    int ans = 0;
    REP(i, q) {
        int key;
        cin >> key;
        if (linearSearch(A, n, key)) ++ans;
    }

    cout << ans << "\n";
} 


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e3 + 5;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll r;
        cin >> r;
        cout << fixed << setprecision(2) << r * 2 * 3.14;
}



Measured memory_bytes: 3792
function main(input) {
  var n = input[0]-0;
  var s = input[1];
  var ans = true;
  if(n%2==1) ans = false;
  else{
    for(var i=0;i<n/2;i++){
      if(s[i] != s[i+n/2]){
         ans = false;
         break;
      }
    }
  }
  console.log(ans?"Yes":"No");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


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

int main(){
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK";
			return 0;
		} 
	}
	cout<<"NG";
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stack>
using namespace std;

int main(void){
  string s1, s2;
  stack<int> sum;
  int tmp, carry, n, len1, len2;

  cin >> n;
  for(int i = 0; i < n; i++){
    tmp = carry = 0;
    while(!sum.empty()) sum.pop();
    cin >> s1 >> s2;
    len1 = s1.length();
    len2 = s2.length();
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());

    for(int i = 0; i < max(len1, len2); i++){
      tmp = carry;
      if(i < len1) tmp += s1[i] - '0';
      if(i < len2) tmp += s2[i] - '0';
      sum.push(tmp % 10);
      carry = tmp / 10;
    }
     
    if(carry != 0){
      sum.push(carry);
      carry = 0;
    }

    if(sum.size() > 80){
      cout << "overflow" << endl;
    }else{
      while(!sum.empty()){
        cout << sum.top();
        sum.pop();
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long  h, ans = 0, cnt = 0, k;
  cin >> h;
  k = h;
  while(k != 0){
    k /= 2;
    cnt++;
  }
  ans = pow(2, cnt)-1;
  cout << ans <<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
long long Q,H,S,D,N,ans;
int main(){
    cin>>Q>>H>>S>>D>>N;
    ans=(N%2==0)?(min(min(min(Q*8,H*4),S*2),D)*N/2):(min(min(Q*4,H*2),S)+min(min(min(Q*8,H*4),S*2),D)*(N-1)/2);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int euclid(int x, int y){
  if(x%y == 0){
    return y;
  }else{
    return euclid(y, x%y);
  }
}
int gcd(int a, int b, int c){
  return euclid(a, euclid(b, c));
}
int main(void){
  int a, b, c;
  int K;
  int sum = 0;
  
  scanf("%d", &K);
  for(a=1; a<=K; a++){
    for(b=1; b<=K; b++){
      for(c=1; c<=K; c++){
        sum += gcd(a, b, c);
      }
    }
  }
  printf("%d", sum);
  
  return 0;
}


Measured memory_bytes: 1708
# -*- coding: utf-8 -*-
h,w,d = map(int, input().split())
dd = {}
for hi in range(h):
    line = list(map(int, input().split()))
    for wi in range(w):
        dd[line[wi]] = (hi, wi)
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

acc = [0]*(h*w+1)
for i in range(h*w+1):
    if i<=d:
        acc[i] = 0
        continue

    h1,w1 = dd[i]
    h2,w2 = dd[i-d]
    acc[i] = acc[i-d] + abs(h1-h2) + abs(w1-w2)

for (l,r) in lr:
    print(acc[r] - acc[l])


Measured memory_bytes: 46908
#include <cstdio>
#include <vector>
using namespace std;
int main()
{
	long long n;
	while(scanf("%Ld\n", &n), n){
		vector<pair<long long, long long> > v;
		for(long long i = 0; i < n; i++){
			long long p, q, r, f = 1;
			scanf("%Ld %Ld %Ld\n", &p, &q, &r);
			for(long long j = 0; j < v.size(); j++){
				if(v[j].first == p){
					f = 0;
					v[j].second += q * r;
				}
			}
			if(f){
				pair<long long, long long> pa(p, q * r);
				v.push_back(pa);
			}
			
		}
		long long g = 1;
		for(long long i = 0; i < v.size(); i++){
			if(1000000 <= v[i].second){
				g = 0;
				printf("%Ld\n", v[i].first);
			}
		}
		if(g) puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1080
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

int main() {
#ifdef LOCAL
    //freopen("outp", "w", stdout);
#else
    // freopen(TASKNAME ".in", "r", stdin);
    // freopen(TASKNAME ".out", "w", stdout);
#endif
    string s;
    cin >> s;
    s[3] = '8';
    cout << s;
}



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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector a(n, 0L);
    for (auto&& aa : a) {
        cin >> aa;
    }

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

    --n;
    int64_t ans = 0;
    ans += a.back();
    a.pop_back();
    --n;
    while (n > 0) {
        ans += a.back();
        --n;
        if (n > 0) {
            ans += a.back();
            --n;
        }
        a.pop_back();
    }

    cout << ans << endl;
}

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

int main(void)
{
  string s ,t;
  cin >> s >> t;
  int ans=0;
  
  for(int i=0;i<3;i++){
    if(s.at(i)==t.at(i)){
      ans++;
    }
  }

  cout << ans << endl;
}
  
  


Measured memory_bytes: 256
K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S!=p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}

Measured memory_bytes: 384
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std;
const int INF = 1e9; 
const int MAX_N = 105; 
int N, M, f[MAX_N][MAX_N]; 
char a[MAX_N][MAX_N]; 
int main () { 
    scanf("%d %d", &N, &M); 
    for (int i = 1; i <= N; i++) scanf("%s", a[i] + 1);
    for (int i = 0; i <= N; i++) 
	for (int j = 0; j <= M; j++) f[i][j] = INF; 
    if (a[1][1] == '#') f[1][1] = 1;
    else f[1][1] = 0; 
    for (int i = 1; i <= N; i++) 
	for (int j = 1; j <= M; j++) { 
	    if (i == 1 && j == 1) continue; 
	    if (a[i][j] == '#') { 
		if (a[i - 1][j] == '.') f[i][j] = min(f[i - 1][j] + 1, f[i][j]);
		if (a[i - 1][j] == '#') f[i][j] = min(f[i - 1][j], f[i][j]);
		if (a[i][j - 1] == '.') f[i][j] = min(f[i][j - 1] + 1, f[i][j]);
		if (a[i][j - 1] == '#') f[i][j] = min(f[i][j - 1], f[i][j]); 
	    } else f[i][j] = min(f[i - 1][j], f[i][j - 1]); 
	} 
    cout << f[N][M] << endl; 
    return 0; 
} 

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

using namespace std;

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

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

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

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

#if 1


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

  int N;
  cin >> N;
  vector<int> ls(N);
  int sum = 0;
  F0R(i, N) {
    cin >> ls[i];
    sum += ls[i];
  }

  bool po = true;
  F0R(i, N) {
    po &= ls[i] < sum - ls[i];
  }
  cout << (po ? "Yes" : "No");
}
#endif


Measured memory_bytes: 3608
S = input()
S1 = int(S[:2])
S2 = int(S[2:])

if 1 <= S1 <= 12 and 1 <= S2 <= 12:
  print("AMBIGUOUS")
elif 0 <= S1 <= 99 and 1 <= S2 <= 12:
  print("YYMM")
elif 1 <= S1 <= 12 and 0 <= S2 <= 99:
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if i >= 1 and a[i] - j == 1:
        ans += c[j-1]
    j = a[i]
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//最大公約数を返す関数.
long long int gcd(long long int x, long long int y){
    if (x < y) swap(x,y);
    while (y > 0){
        long long int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
	int k,x;
	cin >> k >> x;
	if(x <= 500*k)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
//71　B - Not Found
#include <bits/stdc++.h>
using namespace std;

int main(){
    string s; cin >> s;
    int len=s.size();
    bool flag=false;//trueでfound
    for(char i='a';i<='z';++i){
        for(int j=0;j<len;++j){
            if(s[j]==i) {flag=true;break;}
        }
        if (!flag) {cout << i << endl; return 0;}
        flag = false;
    }
    cout << "None" << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>

long long int is753(long long int number) {
  long long int digit = 1;
  int f3 , f5, f7;
  f3 = f5 = f7 = 0;
  long long int tmp = number;
  while(tmp > 0) {
    int n = tmp % 10;
    if(n == 3) {
      f3 = 1;
    } else if(n==5) {
      f5 = 1;
    } else if(n==7) {
      f7 = 1;
    } else {
      return digit;
    }
    digit *= 10;
    tmp /= 10;
  }
  return (f3 && f5 && f7) ? 0 : 1;
}

int main(void) {
  long long int N;
  scanf("%lld", &N);

  long long int count = 0;
  long long int i = 0;
  while( i <= N ) {
    long long int r = is753(i);
    if(r == 0) {
      count ++;
      i++;
    } else {
      i += r;
    }
  }

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

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
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; }
const long long INF = 1LL << 60;
const int mod = 1000000007;

ll dp[100100];
int jij(int x,int y){
    int ans = 0;
    while(y<x){
        y*=2;
        ans++;
    }
    return ans;
}
int main() {
    int n,k;
    cin >> n >> k;
    double p=0.0;
    for(int i = 1;i<=n;++i){
          double d =1.0;
          rep(j,jij(k,i)) d/=2;
          p+=d;
    }
    cout << fixed <<setprecision(10) << p/n  <<endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func pow(args ...int) int {
  x, y := args[0], args[1]
  res := 1
  if len(args) == 3 {
    mod := args[2]
    for y != 0 {
      if y & 1 == 1 {res = res * x % mod}
      y >>= 1
      x = x * x % mod
    }
  }  else {
    for y != 0 {
      if y & 1 == 1 {res *= x}
      y >>= 1
      x *= x
    }
  }
  return res
}

const mod = 1e9 + 7
func makeTables(n, r, p int) ([]int, []int, []int) {
  fac, ifac, nChoose := make([]int, r + 1), make([]int, r + 1), make([]int, r + 1)
  fac[0] = 1; for i := 0; i < r; i++ {fac[i+1] = fac[i] * (i + 1) % p}
  ifac[r] = pow(fac[r], p - 2, p); for i := r; i > 0; i-- {ifac[i-1] = ifac[i] * i % p}
  nChoose[0] = 1; for i := 0; i < r; i++ {nChoose[i+1] = nChoose[i] * (n - i) % p}
  for i := 0; i < r + 1; i++ {nChoose[i] = nChoose[i] * ifac[i] % p}
  return fac, ifac, nChoose
}
var fac, ifac, nChoose = makeTables(1e9, 1e7, mod)
func choose(n, r int) int {
  if r > n || r < 0 {return 0}
  var p int = mod
  return fac[n] * ifac[n-r] % p * ifac[r] % p
}

func main() {
  var n int 
  fmt.Scan(&n)
  fmt.Println(fac[n])
}

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

// Inserted snippets: euclid, io, modint, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
ll euclid(ll a, ll b, ll &x, ll &y) {
	if (b) { ll d = euclid(b, a % b, y, x);
		return y -= a/b * x, d; }
	return x = 1, y = 0, a;
}
template<ll MOD = 1'000'000'007>
struct Mod {
	ll val;
	Mod() : val(0) {}
	Mod(ll xx) {
		if (0 <= xx && xx < MOD) val = xx;
		else val = (xx % MOD + MOD) % MOD;
	}
	Mod operator+=(Mod b) { if ((val += b.val) >= MOD) val -= MOD; return *this; }
	Mod operator-=(Mod b) { if ((val += MOD - b.val) >= MOD) val -= MOD; return *this; }
	Mod operator*=(Mod b) { (val *= b.val) %= MOD; return *this; }
	Mod operator/=(Mod b) { (val *= b.inv().val) %= MOD; return *this; }
	Mod operator+(Mod b) const { Mod<MOD> tmp(*this); return tmp += b; }
	Mod operator-(Mod b) const { Mod<MOD> tmp(*this); return tmp -= b; }
	Mod operator*(Mod b) const { Mod<MOD> tmp(*this); return tmp *= b; }
	Mod operator/(Mod b) const { Mod<MOD> tmp(*this); return tmp /= b; }
	Mod& operator++() { *this += 1; return *this; }
	Mod& operator--() { *this -= 1; return *this; }
	Mod operator++(int) { Mod<MOD> tmp(*this); operator++(); return tmp; }
	Mod operator--(int) { Mod<MOD> tmp(*this); operator--(); return tmp; }
	Mod inv() const {
		ll v, y, g = euclid(val, MOD, v, y);
		assert(g == 1); return Mod((v + MOD) % MOD);
	}
	Mod operator^(ll p) const {
		ll r = 1, b = val;
		for (; p; p >>= 1, b = b * b % MOD) if (p & 1) r = r * b % MOD;
		return Mod(r);
	}
	friend istream& operator>>(istream &is, Mod& mod) {
		ll tmp; is >> tmp;
		mod = Mod<MOD>(tmp);
		return is;
	}
	friend ostream& operator<<(ostream &os, const Mod& mod) {
		return os << mod.val;
	}
};
// End snippets

typedef Mod<> modint;

modint fact[1000005], invfact[1000005];

modint npr(int n, int r) {
	return fact[n] * invfact[n - r];
}
modint ncr(int n, int r) {
	return fact[n] * invfact[r] * invfact[n - r];
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, m; read(n, m);
	
	fact[0] = invfact[0] = 1;
	rep(i, 1, 1000005)
		fact[i] = fact[i - 1] * i, invfact[i] = invfact[i - 1] / i;

	modint ans = npr(m, n);

	modint cnt = npr(m, n);
	rep(i, 1, n + 1)
		cnt += modint(i % 2 == 1 ? -1 : 1) * ncr(n, i) * npr(m - i, n - i);

	write(ans * cnt);
}


Measured memory_bytes: 19236
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define fastio                      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define   endl                      "\n"

int main()
{
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	if((b < 0 && a<0) && (c > 0&& d > 0) ){
		cout << max(b,a) * min(d,c);
		return 0;
	}
	if((d < 0&&c<0) && (a > 0&&b>0)){
		cout << max(d,c) * min(a,b) << endl;
		return 0;
	}
	cout << max(b * d, a * c) << endl;
}

Measured memory_bytes: 3676
#include <iostream>

using namespace std;

int main(){
  long long n, d;
  
  cin >> n >> d;
  
  int answer = 0;
  
  for(int i = 0; i < n; i++){
    long long x, y;
    cin >> x >> y;
    
    if(x*x + y*y <= d*d){
      answer++;
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 3620
import sys

H,W,A,B=map(int,input().split())
mat=[]
for _ in range(H):
  array=[0]*W
  mat.append(array)
  
for i in range(B):
  for j in range(A):
    mat[i][j]=1
for i in range(B,H):
  for j in range(A,W):
    mat[i][j]=1
  
#print(mat)
for i in range(H):  
  print("".join(map(str,mat[i])))


Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}

template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vi a(m);
	cin>>a;
	sort(all(a));
	vi b(m-1);
	rep(i,m-1)b[i]=a[i+1]-a[i];
	sort(rall(b));
	int ans=0;
	range(i,n-1,m-1)ans+=b[i];
	puta(ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    int n, m, a;
    while (cin >> n >> m >> a && n && m && a) {
        vector<pair<int, pii> > v(m);
        rep(i, m) {
            int h, p, q; cin >> h >> p >> q;
            v[i].first = h;
            v[i].second.first = p;
            v[i].second.second = q;
        }
        sort(v.begin(), v.end());
        int now = a;
        for (int i = m - 1; i >= 0; --i) {
            if (v[i].second.first == now) {
                now = v[i].second.second;
            } else if (v[i].second.second == now) {
                now = v[i].second.first;
            }
        }
        cout << now << endl;
    }
}



Measured memory_bytes: 3108