akhauriyash/Code-Regression huggingface dataset:
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int a,b;cin>>a>>b;
    if(1<=a&&a<=9&&1<=b&&b<=9)cout<<a*b<<endl;
    else cout<<"-1"<<endl;
}

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

using namespace std;

int gcd(int a, int b){
  if(a%b == 0){
    return b;
  }

  return gcd(b, a%b);
}

// int lcm(int a, int b){
//   return a / gcd(a, b) * b;
// }

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

  long long ans = 0;
  int res = 0;
  for(int i = 1; i <= k; i++){
    for(int j = 1; j <= k; j++){
      for(int t = 1; t <= k; t++){
        res = gcd(i,j);
        res = gcd(res, t);
        ans += res;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
const ll MOD = 1e9 + 7;

ll fact[10001], fact_i[10001];

ll power(int x, int y) {
    if (y == 0) return 0;
    if (y == 1) return x;
    ll p = power(x, y >> 1);
    if (y & 1) return p * p % MOD * x % MOD;
    else return p * p % MOD;
}

ll inv(ll n) {
    return power(n, MOD - 2);
}

void init(int n) {
    fact[0] = 1;
    REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_i[n] = inv(fact[n]);
    REP(i, n) fact_i[n - i - 1] = fact_i[n - i] * (n - i) % MOD;
}

ll nCr(ll n, ll r) {
    return fact[n] * fact_i[r] % MOD * fact_i[n - r] % MOD;
}

ll nPr(int n, int r) {
    return fact[n] * fact_i[n - r] % MOD;
}

int main() {
    init(10000);
    ll S;
    cin >> S;

    ll i = 1;
    ll ans = 0;
    while (S >= 3 * i) {
        // if (S > 9 * i) {
        //     i++;
        //     continue;
        // }
        ll rest = S - 3 * i;
        ans += nCr(rest + i - 1, i - 1);
        ans %= MOD;
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

vector<int> SNS[100000];
int Group[100000] = { 0 };

int main()
{
	int n, m, q, s, t;
	int man1, man2;
	int grNo = 1;
	int current, next;
	queue<int> Q;
	vector<int>::iterator it;
	
	cin >> n >> m;
	rep(i, m) {
		cin >> man1 >> man2;
		SNS[man1].push_back(man2);
		SNS[man2].push_back(man1);
	}

	rep(i, n) {
		if (Group[i] == 0) {
			Q.push(i);
			Group[i] = grNo;

			while (!Q.empty()) {
				current = Q.front();

				for (it = SNS[current].begin(); it != SNS[current].end(); it++) {
					next = *it;
					if (Group[next] == 0) {
						Q.push(next);
						Group[next] = grNo;
					}
				}

				Q.pop();
			}

			grNo++;
		}
	}

	cin >> q;
	rep(i, q) {
		cin >> s >> t;
		if (Group[s] == Group[t]) cout << "yes" << endl;
		else cout << "no" << endl;
	}

	return 0;
}


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

int main() {
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; i++) {
        int j = x - i;
        if (2 * i + 4 * j == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main (){
       int a;
       while(cin>>a){
            if(a==0)break;
            int N;
            cin>>N;
            int ans=0;
            for(int i=0;i<N;i++){
                      int c,d;
                      cin>>c>>d;
                       ans=ans+(d-c);
               }
                       if(ans>=a){
                              cout<<"OK"<<endl;
                        }
                        else{   cout<<a-ans<<endl;
                      }   
                }
         return 0;
  }

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


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

    ll n,m;
    cin>>n>>m;
    string s[m];
    ll p[m];
    ll a[n]={};
    ll ac=0,pe=0;
    bool ok[n]={};
    for(int i=0;i<m;i++){
        cin>>p[i] >> s[i];
        p[i]--;
        if(s[i]=="AC"){
            if(!ok[p[i]]){
                ac++;
                ok[p[i]]=1;
                pe+=a[p[i]];
            }
        }
        else a[p[i]]++;
    }
    cout <<ac<<" "<<pe<<endl;



}

Measured memory_bytes: 7424
import java.io.*;
import java.math.*;
import java.util.*;


public class Main{
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	String a = sc.next();
    		char[] chars = a.toCharArray();
        	for(int i=0;i<chars.length;i++) {
        		if(chars[i]=='?') {
        			chars[i]='D';
        		}
        	}
        	System.out.println(String.valueOf(chars));
    }
}


Measured memory_bytes: 41268
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 20000005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
const int MOD = 1000000007;
int H,W,K,N;
int C[2][4],inv[4];
int inc(int a,int b) {
	return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
	return 1LL * a * b % MOD;
}
void update(int &x,int y) {
	x = inc(x,y);
}
int fpow(int x,int c) {
	int res = 1,t = x;
	while(c) {
		if(c & 1) res = mul(res,t);
		t = mul(t,t);
		c >>= 1;
	}
	return res;
}
void Solve() {
	read(H);read(W);read(K);
	N = H + W;
	inv[1] = 1;inv[2] = (MOD + 1) / 2;inv[3] = (MOD + 1) / 3;
	C[0][0] = C[1][0] = 1;
	for(int i = 1 ; i <= 3 ; ++i) {
		C[0][i] = mul(mul(C[0][i - 1],inv[i]),K - i + 1);
		C[1][i] = mul(mul(C[1][i - 1],inv[i]),N - i + 1);
	}

	int ans = K;
	int t1 = mul(K,fpow(N,MOD - 2)),t2 = mul(C[0][2],fpow(C[1][2],MOD - 2)),t3 = mul(C[0][3],fpow(C[1][3],MOD - 2));
	int s = inc(t1,mul(mul(t2,inv[2]),N - 1));
	update(ans,mul(s,H + W));
	s = inc(t2,mul(mul(t3,inv[3]),N - 2));
	update(ans,mul(s,1LL * H * W % MOD));
	for(int i = N ; i >= N - K + 1; --i) {
		ans = mul(ans,i);
	}
	out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

int main()
{
  int64_t a;
  double b;
  cin >> a >> b;
  cout << a * (int)b + a * (int)round((b - (int)b) * 100) / 100 << endl;
}

Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int p,q,r;
	cin>>p>>q>>r;
	int m=p+q;
	int n=p+r;
	int k=q+r;
	int d=m<n?m:n;
	int dd=n<k?n:k;
	int ddd=d<dd?d:dd;
	cout<<ddd;
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <algorithm>
#define max_n 100000
#define max_m 200000 
using namespace std;
typedef const int& ci;
struct node{
	int v,nxt;
	node(){}
	node(int _v,int _nxt):v(_v),nxt(_nxt){}
};
struct graph{
	int head[max_n+1];
	int cnt;
	node edge[max_m];
	void build(){
		memset(head,-1,sizeof(head));
		cnt=-1;
	}
	void insert(ci u,ci v){
		push(u,v);
		push(v,u);
	}
	void push(ci u,ci v){
		edge[++cnt]=node(v,head[u]);
		head[u]=cnt;
	}
};
graph g;
int n,sz[max_n+1];
long long dis[max_n+1],d[max_n+1];
map<long long, int> mp;
void dfs(int u,int p=0){
	for(int i=g.head[u],v; ~i; i=g.edge[i].nxt){
		if((v=g.edge[i].v)==p)
			continue;
		dis[v]=dis[u]+1;
		dfs(v,u);
	}
}
int main(){
    scanf("%d",&n),g.build();
    for(int i=0; ++i<=n; mp[d[i]]=i,sz[i]=1)
    	scanf("%lld",d+i);
    int cnt=0,u,v;
	for(map<long long,int>::reverse_iterator it=mp.rbegin(); ++cnt<n&&it!=mp.rend(); ++it,g.insert(u,v),sz[u]+=sz[v])
		if(!(u=mp[it->first+2*sz[v=it->second]-n])||u==v){
			puts("-1");
			return 0;
		}
    int rt=mp.begin()->second;
    dfs(rt);
    if(accumulate(dis+1,dis+n+1,0LL)!=d[rt]){
    	puts("-1");
    	return 0;
	}
	for(int i=0; ++i<=n; )
		for(int j=g.head[i]; ~j; j=g.edge[j].nxt)
			i<g.edge[j].v&&printf("%d %d\n",i,g.edge[j].v);
    return 0;
}

Measured memory_bytes: 16440
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int ans = 0;
	for(int i=1,x;i<=n;++i)
	{
		cin>>x;
		if(x%2==1&&i%2==1)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    bool finish = false;
    while( k > 0){
        if( b > a) break;
        b *= 2;
        k--;
    }
    while( k > 0){
        if( c > b) break;
        c *= 2;
        k--;
    }
    if( b > a && c > b){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3648
n = input()
a = tuple(map(int, input().split()))
p = sorted(a)
ans = 0
for x, y in zip(a, p):
    if x != y:
        ans += 1
if ans == 0 or ans == 2:
    print("YES")
else:
    print("NO")
from sys import argv
debug = 'a' in argv
if debug:
    print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

void swap(int* a , int* b)
{
	int* tmp = a;
	a = b;
	b = tmp;
}
int main()
{
	string str;
	string item;
	vector<int> list;
	getline(cin, str);
	stringstream ss(str);
	while (getline(ss, item, ' ') && !item.empty()) {
		list.push_back(stoi(item));
	}

	int a = list[0];
	int b = list[1];
	int c = list[2];
	for (int i = 0; i < 9;i++)
	{
		if (a > b)
		{
			swap(a, b);
			if (b > c)
			{
				swap(b, c);
			}
		}
		else {
			if (b > c)
			{
				swap(b, c);
			}
		}
	}
	cout << a << " " << b << " " << c <<endl;
	return 0;
}

Measured memory_bytes: 3196
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N, M;
	std::cin >> N >> M;
	std::vector<int64_t> A(N);
	for (int64_t i = 0; i < N; i++)
	{
		std::cin >> A[i];
	}

	std::priority_queue<int64_t> q;
	for (int i = 0; i < N; i++)
	{
		q.push(A[i]);
	}

	for (int i = 0; i < M; i++) {
		int64_t tmp = q.top();
		q.pop();
		tmp /= 2;
		q.push(tmp);
	}

	int64_t sum = 0;
	for(int i = 0; i < N; i++)
	{
		sum += q.top();
		q.pop();
	}

	std::cout << sum << std::endl;

}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
void solution(int a[])
{
	int t=1;
	if(a[0]!=a[1] && a[0]!=a[2])
	{
		t++;
	}
	if(a[1]!=a[2])
	{
		t++;
	}
	cout<<t<<endl;
}
main()
{
	int a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
	}
	solution(a);
}

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

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

    string ACGT_ref = "ACGT";
    int max = 0;
    int len = 0;
    bool is_acgt = false;

    for (auto itr = S.begin(); itr != S.end(); itr++){
        for(auto itr_ref = ACGT_ref.begin(); itr_ref != ACGT_ref.end(); itr_ref++){
            if(*itr == *itr_ref){
                is_acgt = true;
                break;
            }
        }
        if(is_acgt){
            len++;
        }else{
            if(max < len){
                max = len;
            }
            len = 0;
        }
        is_acgt = false;
    }
    if(max < len){
        max = len;
    }
    cout << max << endl;
    return 0;

} 


Measured memory_bytes: 3608
//package atcoder.ABC;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner input = new java.util.Scanner(System.in);
		
		String a = input.next();
		String b = input.next();
		String c = input.next();
		
		System.out.println(c+" "+a+" "+b);
		
	}

}


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

int main()
{
    int x, e;
    int sum_min;

    while (std::cin >> e && e > 0) {
        sum_min = 100000000;
        for (int i = 0; i * i <= e; i++) {
            for (int j = 0; j * j * j <= e - i * i; j++) {
                x = e - i * i - j * j * j;
                if (x >= 0 && x + i + j < sum_min) {
                    sum_min = x + i + j;
                }
            }
        }
        std::cout << sum_min << '\n';
    }
    return 0;
}



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

/*                                                                              
  let's try computer shogi!!!                                                   
 */

int main(){

  int N;
  std::vector<int> points;
  cin >> N;
  points.resize(N);
  for(int i=0;i<N;++i){
    cin >> points[i];
  }

  sort(points.begin(),points.end());
  cout<<(points[N-1]-points[0]);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n,m; cin >> n >> m;
  map<int,int> C;
  for(ll i = 2; i*i <= m; i++) {
    while(m%i == 0){
      C[i]++;
      m /= i;
    }
  }
  if(m != 1) C[m]++;

  ll ans = 1LL;
  COMinit();
  for(auto c : C) {
    ll num = c.second;
    //cout << c.first << endl;
    ans *= COM(n+num-1, num);
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 119808
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,k;
string a[105],s;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    {
        s+=a[i];
    }
    cout<<s;
    return 0;
}

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

using i64 = long long int;

int main(){
    i64 n, m;
    cin >> n >> m;
    vector<i64> v[8];
    for(int i=0;i<n;++i){
        i64 x, y, z;
        cin >> x >> y >> z;
        for(int j=0;j<8;++j){
            i64 tmp = x * (((j>>2)&1) ? -1 : 1);
            tmp += y * (((j>>1)&1) ? -1 : 1);
            tmp += z * ((j&1) ? -1 : 1);
            v[j].push_back(tmp);
        }
    }

    i64 ans = 0;
    for(int i=0;i<8;++i){
        sort(v[i].rbegin(), v[i].rend());
        i64 tmp = 0;
        for(int j=0;j<m;++j)tmp += v[i][j];
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}

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

    int N; cin >> N;
    vl t(N); REP(i, N) cin >> t[i];

    ll ans = t[0];
    FOR(i,1,N) {
        ans = lcm(ans, t[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <map>

int main() {
  size_t N;
  intmax_t M;
  scanf("%zu %jd", &N, &M);

  std::vector<intmax_t> A(N);
  for (size_t i=0; i<N; ++i)
    scanf("%jd", &A[i]);

  std::vector<intmax_t> B(N+1);
  for (size_t i=0; i<N; ++i)
    B[i+1] = (B[i] + A[i]) % M;

  std::map<intmax_t, uintmax_t> c;
  for (size_t i=0; i<=N; ++i)
    ++c[B[i]];

  uintmax_t res=0;
  for (const auto &p: c)
    res += p.second*(p.second-1)/2;

  printf("%ju\n", res);
}


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

int main(){

	string str;
	cin >> str;
	int m1,m2,d1,d2;
	m1 = str[5];
	m2 = str[6];
	d1 = str[8];
	d2 = str[9];

	if (m1=='0' && m2<='4'){
		cout << "Heisei";

	}else{
		cout << "TBD";
	}
	
	return 0;
}



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

#define HOME_ADDRESS 1000

int main(){
  int N;
  cin >> N;
  int a[HOME_ADDRESS] = {0};
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  
  sort (a , a + N , greater<int>());
  
  cout << a[0]-a[N-1] << endl;
}

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

int main(){
  int n; cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    while(k % 2 == 0) {
      k /= 2; cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define qq queue
#define dq deque
#define vc vector
#define INF ((int)(2e9))
#define LINF ((int)(1e18))
#define fir for( int i = 1 ; i <= n ; i++ )
#define fjr for( int j = 1 ; j <= n ; j++ )
#define fkr for( int k = 1 ; k <= n ; k++ )
#define firx( _x ) for( int i = 1 ; i <= _x ; i++ )
#define fjrx( _x ) for( int j = 1 ; j <= _x ; j++ )
#define fkrx( _x ) for( int k = 1 ; k <= _x ; k++ )
#define fir0x( _x ) for( int i = 0 ; i < _x ; i++ )
#define fjr0x( _x ) for( int j = 0 ; j < _x ; j++ )
#define fkr0x( _x ) for( int k = 0 ; k < _x ; k++ )
#define out cout <<
#define ln  << endl
#define pb push_back
#define mp make_pair
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define mp make_pair
#define sint short int
#define ull unsigned long long
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define ll long long
#define B out "BreakPoint\n";
#define read(_nowans) scanf("%d",&_nowans)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_nowans1,_nowans2) scanf("%d %d",&_nowans1,&_nowans2)
#define msn(_data,_nowans) memset(_data,_nowans,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define read3(_nowans1,_nowans2,_nowans3) scanf("%d %d %d",&_nowans1,&_nowans2,&_nowans3)
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print( ll _x ){ cout << _x << endl; }
_tp<_tyn T>void print( T _data[] , int _size ){
	firx( _size )
		cout << _data[i] << " ";
	cout << endl;
}
#define MAXN 200010

int n;
string s;

int nextapp[MAXN][27];
int mem[MAXN] , tran[MAXN];
int dfs( int pos ){
	if( mem[pos] != -1 ) return mem[pos];

	int ans = INF;
	for( int i = 0 ; i < 26 ; i++ ){
		if( nextapp[pos][i] >= n + 1 ){
			ans = 1;
			tran[pos] = i;
			return mem[pos] = 1;
		}
		int ret = dfs( nextapp[pos][i] ) + 1;
		if( ans > ret ){
			ans = ret;
			tran[pos] = i;
		}
	}

	return mem[pos] = ans;
}

void getpath( int pos ){
	cout << (char)(tran[pos]+'a');
	if( nextapp[pos][tran[pos]] >= n + 1 ) return;
	getpath( nextapp[pos][tran[pos]] );
}

int main(){
	//fin( "E.txt" );
	msn( mem , -1 );

	cin >> s;
	n = s.length();
	s = " " + s;

	int nownext[27];
	for( int i = 0 ; i < 26 ; i++ )
		nownext[i] = n + 1;

	for( int i = n ; i >= 0 ; i-- ){
		for( int j = 0 ; j < 26 ; j++ )
			nextapp[i][j] = nownext[j];
		if(i) nownext[ s[i]-'a' ] = i;
	}

	for( int i = 0 ; i < n ; i++ ){
		if( mem[i] == -1 )
			dfs(i);
	}

	getpath(0);
	cout << endl;

	return 0;
}


Measured memory_bytes: 23744
#include <stdio.h>
int main(){
    for (;;){
        int hight,width,i,j;
        scanf("%d %d",&hight,&width);
        if (hight == 0 && width == 0) {
            return 0;
        }
        for (i = 0; i < hight; i++){
            for (j = 0;j < width; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N;
  cin >> N;
  N+=1000; // nannde?
  vector<int> v;
  v.push_back(1);
  for (int i = 6; i < N; i*=6) v.push_back(i);
  for (int i = 9; i < N; i*=9) v.push_back(i);
  vector<int> dp(N, INF);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < v.size() && i+v[j]<N; j++) {
      dp[i+v[j]] = min(dp[i+v[j]], dp[i]+1);
    }
  }
  cout << dp[N-1000] << endl;  // nannde?
}



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

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> p(n), a(n, 0);
    rep(i, n) cin >> p[i];
    double ans = 0.0;
    int idx = 0;

    rep(i, k) a[0] += p[i];

    for(int i=1; i<=n-k; i++) { 
        a[i] = a[i-1] - p[i-1] + p[i+k-1];
        if (a[idx] < a[i]) idx = i;
    }

    rep(i, k) {
        ans += 1.0 + double(p[idx+i]-1)*0.5;
    }
    cout << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int m, k;
    cin >> m >> k;
     if(pow(2,m)<=k){
       cout << -1 << endl;
   }
   else{
   if(m==0){
       cout << 0 <<" "<<0<<endl;
   return 0;}
   if (m==1){
       if(k==0)
           cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
        else
            cout << -1 << endl;
        return 0;
   }
  
   for (int i = pow(2,m)-1; i >=0; i--){
       if(i==k)
           continue;
   
   cout << i << " ";
   }
   cout << k << " ";
   for (int i = 0; i < pow(2, m); i++)
   {    
       if(i==k)
           continue;
       cout << i << " ";
   }
   cout << k << endl;
   }
   
   

   return 0;
}

Measured memory_bytes: 1792
"""
// Author : snape_here - Susanta Mukherjee
     
 """
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

mod=1000000007

import math

import bisect

abc="abcdefghijklmnopqrstuvwxyz"

def main():

    l=[]
    for _ in range(ii()):
        s=si()
        l.append(s)
    print(len(set(l)))

# region fastio

 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main()

Measured memory_bytes: 103672
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,M;
  cin>>N>>M;
  int s[10],c[10];
  for (int i(0);i<M;i++){
    cin>>s[i]>>c[i];
  }
  int tmp(0),tmp2;
  if (N==1){
    tmp = 10;
    tmp2 = 0;
  }
  if (N==2) {
    tmp = 100;
    tmp2 = 10;
  }
  if (N==3){
    tmp = 1000;
    tmp2 = 100;
  }
  for (int i(tmp2);i<tmp;i++){
    bool flag = true;
    for (int j(0);j<M;j++){
      string si = to_string(i);
      if (si[s[j]-1]-'0' != c[j]) flag = false;
    }
    if (flag) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}



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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n, d, x;
    cin >> n >> d >> x;
    int a[n];
    rep(i, n) { cin >> a[i]; }

    // 処理
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= d; j += a[i]) {
            cnt++;
        }
    }

    // 出力
    cout << cnt + x << endl;

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a,b = gets.chomp.split(" ").map(&:to_i);

min = 0

if n == 1 then
	puts "OK"
	exit
end


if n < a then
	if a%n == 0 then
		min = (a/n) * n
	else
		min = (a/n+1) * n
	end
else
	min = n
end


if min <= b then
	puts "OK"
else
	puts"NG"
end


Measured memory_bytes: 14356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var output = "Yes";

            if (!IsBatch(S)) output = "No";
            if (!IsBatch(S.Substring(0, S.Length / 2))) output = "No";
            if (!IsBatch(S.Substring((S.Length + 2) / 2))) output = "No";

            Console.WriteLine(output);
        }

        private static bool IsBatch(string s)
        {
            for (int i = 0; i < s.Length / 2; i++)
            {
                if (s[i] != s[s.Length - i - 1])
                {
                    return false;
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 17300
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;


int main(int argc, char *argv[]) {
    vector<pair<int, int>> vp;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        vp.push_back(make_pair(l, r));
    }
    sort(vp.begin(), vp.end());

    vector<int> minr;
    int minr_v = 1000000001;
    for (int i = vp.size() - 1; i > 0; i--) {
        minr_v = min(minr_v, vp[i].second);
        minr.push_back(minr_v);
    }
    reverse(minr.begin(), minr.end());
    int maxrv = 0, minrv = 1000000001;
    int res = 0;
    for (int i = 0; i < vp.size() - 1; i++) {
        // set1: [vp[i].first, vp[i].second]
        // set2: [vp[vp.size() - 1].first, minr[i]]
        if (i > 1) {
            res = max(res, max(0, min(vp[i].second, maxrv) - vp[i].first + 1) + max(0, min(minr[i], minrv) - vp[vp.size() - 1].first + 1));
            res = max(res, max(0, min(vp[i].second, minrv) - vp[i].first + 1) + max(0, min(minr[i], maxrv) - vp[vp.size() - 1].first + 1));
            
            res = max(res, max(0, vp[i].second - vp[i].first + 1) + max(0, min(minr[i], minrv) - vp[vp.size() - 1].first + 1));
            res = max(res, max(0, min(vp[i].second, minrv) - vp[i].first + 1) + max(0, minr[i] - vp[vp.size() - 1].first + 1));
        }
        else if (i == 1) {
            res = max(res, max(0, min(vp[i].second, maxrv) - vp[i].first + 1) + max(0, minr[i] - vp[vp.size() - 1].first + 1));
            res = max(res, max(0, vp[i].second - vp[i].first + 1) + max(0, min(minr[i], maxrv) - vp[vp.size() - 1].first + 1));
        }
        else {
            res = max(res, max(0, vp[i].second - vp[i].first + 1) + max(0, minr[i] - vp[vp.size() - 1].first + 1));
        }
        maxrv = max(vp[i].second, maxrv);
        minrv = min(vp[i].second, minrv);
    }
    cout << res << endl;
}



Measured memory_bytes: 1908
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while( true ){
			int w = Integer.parseInt(scan.next());	//??????
			int h = Integer.parseInt(scan.next());	//?????????
			int count = 0;	//??¶?????°???
			if( w == 0 && h == 0 ){
				break;
			}
			int [][] c = new int[h+2][w+2];	//???????????¨?????????????????§?????¨?????????0????????????1????????????2???????????§???????????????
			//?????????
			for( int i = 0; i < h+2; i++ ){
				for( int j = 0; j < w+2; j++ ){
					c[i][j] = 0;
				}
			}
			//??\???
			for( int i = 1; i <= h; i++ ){
				for( int j = 1; j <= w; j++ ){
					c[i][j] = Integer.parseInt(scan.next());
				}
			}
			for( int i = 1; i <= h; i++ ){
				for( int j = 1; j <= w; j++ ){
					count += Move(c, i, j);
				}
			}
			System.out.println(count);
		}
		return;
	}
	
	public static int Move(int[][] c, int h, int w){
		if( c[h][w] == 0 ){
			return 0;
		}
		c[h][w] = 0;
		Move(c, h-1, w-1);	//??????
		Move(c, h, w-1);	//???
		Move(c, h+1, w-1);	//??????
		Move(c, h+1, w);	//???
		Move(c, h+1, w+1);	//??????
		Move(c, h, w+1);	//???
		Move(c, h-1, w+1);	//??????
		Move(c, h-1, w);	//???
				
		return 1;
	}
}

Measured memory_bytes: 44076
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

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

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

int main() {
  kyun;
  string s;
  cin >> s;
  if(s[0] == s[1]) cout << "Bad";
  else if(s[1] == s[2]) cout << "Bad";
  else if(s[2] == s[3]) cout << "Bad";
  else cout << "Good";
  hinata;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, k, a[101010];
void solve(){
	cin >> n >> k;
	int pos = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] == 1) pos = i;
	}
	
	k--;
	i64 ans = 0;
	ans += (pos+k-1)/k;
	pos = pos + (k-(pos-k)%k)%k;
	ans += (n-pos-1+k-1)/k;
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main() {
  int H, W, K, S = 0, s = 0;
  cin >> H >> W >> K;
  vector<vector<char>> v(6, vector<char>(6));
  REP(i, H) {
    REP(j, W) {
      char s;
      cin >> s;
      v[i][j] = s;
    }
  }
  REP(i, (1 << H)) {
    bitset<6> a(i);
    REP(j, (1 << W)) {
      bitset<6> b(j);
      s = 0;
      REP(k, H) {
        REP(l, W) {
          if(!(a.test(k)) && !(b.test(l))) {
            if(v[k][l] == '#') {
              s++;
            }
          }
        }
      }
      if(s == K) S++;
    }
  }
  cout << S << endl;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;

    vi seq(N);
    for (int i = 0; i < N; i++)
        cin >> seq[i];

    if (seq[0] != 0) {
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (seq[i] == 0) continue;

        if (seq[i] <= seq[i-1]) {
            ans += seq[i];
            continue;
        }

        if (seq[i] == seq[i-1]+1) {
            ans++;
            continue;
        }

        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;
    return 0;
}



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

using ll = long long int;

int n;
ll yy;

int main(void){
  // Here your code !
  scanf("%d %lld", &n, &yy);

  for (int x = 0; x <= n; ++x) {
    for (int z = 0; z <= n - x; ++z) {
      ll temp = yy - (ll)((ll)10000 * (ll)x) - (ll)((ll)1000 * (ll)z);
      int y = (int)(temp / 5000);
      if ((temp % 5000 == 0) && (y + x + z == n) && y >= 0 && (x != 0 || y != 0 || z != 0)) {
        printf("%d %d %d\n", x, y, z);
        return 0;
      }
    }
  }
  printf("%d %d %d\n", -1, -1, -1);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
p = [int(i) for i in input().split()]
count = 0 
res = "YES"
p_sorted = sorted(p)
for i in range(N):
  if p_sorted[i] != p[i]:
    count += 1
    if count > 2:
      res = "NO"
      break
print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1061109567;
const ll LINF = 4557430888798830399ll;

/* --- */

void TestCase() {
    ll x;
    scanf("%lld", &x);
    ll ans = (x / 2) * ((x + 1) / 2);
    printf("%lld\n", ans);
    return;
}

int main() {
#ifdef KisekiPurin
    freopen("KisekiPurin.in", "r", stdin);
    //freopen("KisekiPurin.out", "w", stdout);
#endif // KisekiPurin
    //InitCase();
    int t = 1;
    //scanf("%d", &t);
    for(int i = 1; i <= t; ++i) {
        //printf("Case #%d: ", i);
        TestCase();
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  long L0 = 2;
  long L1 = 1;
  long dat = 0;

  for(int i = 2;i <= N;i++)
  {
    dat = L0+L1;
    L0 = L1;
    L1 = dat;
  }
    if(N == L1)
  {
    cout << L1 <<endl;
    
  }
  else
  {
  cout << dat << endl;
  }
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<char> vc;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;
typedef vector<vector<char>> vcc;

class UnionFind{
private:
    int n;
    vector<int> parent, r;

    int _find(int x){
        if(parent[x] == x) return x;
        else return parent[x] = _find(parent[x]);
    }

    void _unite(int x, int y){
        x = _find(x); y = _find(y);
        if(x == y) return;
        if(r[x]<r[y]) parent[x] = y;
        else{
            parent[y] = x;
            if(r[x] == r[y]) r[x]++;
        }
    }

public:
    int find(int x){
        return _find(x);
    }

    void unite(int x, int y){
        return _unite(x, y);
    }

    int operator[](int i){
        return find(i);
    }

    UnionFind(){}

    UnionFind(size_t _n) : n(_n){
        parent = vector<int>(n);
        r = vector<int>(n);
        for(int i=0;i<n;i++){
            parent[i] = i;
            r[i] = 0;
        }
    }
};


class CAlternatingPath {
public:
    int H, W;
    vcc grid;

    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>H>>W;
        grid = vcc(H, vc(W));
        REP(i, H) REP(j, W) in>>grid[i][j];
    }

    void solve(std::istream& in, std::ostream& out){
        input(in, out);
        vi di = {1, 0, -1, 0}, dj = {0, 1, 0, -1};
        UnionFind uf(H*W);
        REP(i, H) REP(j, W){
            for(int k=0;k<4;k++){
                int ni = i + di[k], nj = j + dj[k];
                if(0<=ni and ni<H and 0<=nj and nj<W and grid[i][j]!=grid[ni][nj]){
                    uf.unite(i*W+j, ni*W+nj);
                }
            }
        }

        lint ans = 0;
        vl b(H*W, 0), w(H*W, 0);
        REP(i, H) REP(j, W){
            if(grid[i][j]=='.') w[uf.find(i*W+j)]++;
            else b[uf.find(i*W+j)]++;
        }

        REP(i, H*W) ans += w[i] * b[i];
        out<<ans<<'\n';
    }
};


int main() {
	CAlternatingPath solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
int main(void){
    int n, target, i, j, k, count=0;
    while(1){
        scanf("%d %d", &n, &target);
        if(n == 0 && target == 0) break;
        for(i = 1; i <= n; i++){
            for(j = i+1; j<=n  ; j++){
                for(k = j+1;k<=n ;k++){
                    if(i+j+k == target) count++;
                }
            }
        }
        printf("%d\n", count);
        count = 0;
    }
    return 0;
}

Measured memory_bytes: 600