akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

const int mod = 1e9 + 7;

int main(){
  int N, K;
  scanf("%d%d", &N, &K);
  
  int a[N];
  for(int i = 0; i < N; i++) scanf("%d", a + i);
  
  long long dp[N + 1][K + 1];
  
  for(int j = 0; j <= K; j++) dp[0][j] = 1;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= K; j++){
      if(j > a[i]) dp[i + 1][j] = dp[i][j] - dp[i][j - a[i] - 1];
      else dp[i + 1][j] = dp[i][j];
      
      if(j) dp[i + 1][j] += dp[i + 1][j - 1];
      dp[i + 1][j] %= mod;
    }
  }
  
  if(K) printf("%lld\n", (mod + dp[N][K] - dp[N][K - 1]) % mod);
  else puts("1");
  
  return 0;
}

Measured memory_bytes: 79104
//grid
#include<bits/stdc++.h>
using namespace std;
int dp[1005][1005];
int mod=1e9+7;
int solve(vector<vector<char> >&grid,int i,int j,int n,int m){
	if(i>=n||j>=m){
		return 0;
	}
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	if(grid[i][j]=='#'){
		return 0;
	}
	if(i==n-1&&j==m-1){
		return 1;
	}
	return dp[i][j]=(solve(grid,i+1,j,n,m)+solve(grid,i,j+1,n,m))%mod;
}
int main(){
	int n,m;
	cin>>n>>m;
	memset(dp,-1,sizeof dp);
	vector<vector<char> >grid(n+1,vector<char>(m+1));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>grid[i][j];
		}
	}
	cout<<solve(grid,0,0,n,m);
}

Measured memory_bytes: 8736
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int n;
vector<ll> a, b;
ll ret = 0;

ll min(ll a, ll b) {
	if (a >= b)
		return b;
	else
		return a;
}

int main(void) {
	cin >> n;
	for (int i = 0; i <= n; i++) {
		int ai;
		cin >> ai;
		a.push_back(ai);
	}
	for (int i = 0; i < n; i++) {
		ll bi;
		cin >> bi;
		ll tmp = min(a[i], bi);
		ret += tmp;
		bi -= tmp;

		tmp = min(a[i + 1], bi);
		ret += tmp;
		a[i + 1] -= tmp;
	}
	cout << ret << endl;
	return 0;
}

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

int main() {
	int a, b, c;
	int d = 0;
	scanf("%d %d %d" , &a, &b, &c);//////////////////////
	if (a < b) {
		if (b < c) {
			printf("Yes\n");
			d = 1;
		}
	}
	if (d == 0) {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2600
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,q;
  int b[1000000],dp[1000000]={};
  cin>>a>>q;
  for(int i=0;i<a;i++) cin>>b[i];
  for(int i=1;i<q;i++) dp[i]=abs(b[i]-b[0]);
  for(int i=q;i<a;i++){
    for(int j=1;j<=q;j++){
      if(j==1) dp[i]=abs(b[i]-b[i-j])+dp[i-j];
      else dp[i]=min(abs(b[i]-b[i-j])+dp[i-j],dp[i]);
    }
  }
  cout<<dp[a-1]<<"\n";
  }

Measured memory_bytes: 8064
import java.util.Scanner;
class Main {
	static final int MAX = 200000;
	public static void main(String[] args) {
		int[] R = new int[MAX];
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int i = 0;i<n;i++) R[i] = in.nextInt();		
		int maxv = R[1]-R[0];
		int minv = R[0];
		for(int i = 1;i<n;i++){
			maxv = Math.max(maxv, R[i]-minv);	
			minv = Math.min(minv, R[i]);
		}
		System.out.println(maxv);
	}
}

Measured memory_bytes: 100484
#!/usr/bin/python3
n,m = map(int,input().split())
List_a = list(map(int,input().split()))
List_a.sort(reverse=True)
Condition = sum(List_a) / (4*m)
for i in range(m):
    if List_a[i] < Condition:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 main(){
    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    rep(i,n){
        if(a[i]==b[i]&&b[i]==c[i]) continue;
        if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i]) ans++;
        else ans+=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
       int r = s.nextInt();
       int D = s.nextInt();
       int x = s.nextInt();
       int tmp = x;

       for(int i = 0; i < 10; i++){
           System.out.println(r*tmp-D);
           tmp = r*x-D;
           x = tmp;

       }
    }
}

Measured memory_bytes: 20692
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;

constexpr inline int square(int x) {
	return x * x;
}

int main() {
	int edge[3];
	int triangle = 0;
	int right	 = 0;
	int acute	 = 0;
	int obtuse	 = 0;

	while(scanf("%d %d %d", edge, edge + 1, edge + 2) == 3) {
		sort(edge, edge + 3);

		if(edge[0] + edge[1] <= edge[2]) {
			printf("%d %d %d %d\n", triangle, right, acute, obtuse);
			break;;
		}

		++triangle;
		const int a = square(edge[0]) + square(edge[1]);
		const int b = square(edge[2]);

		if(a == b) ++right;
		else if(a > b) ++acute;
		else ++obtuse;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	ll H; cin >> H;
	vector<ll> pow2(60,1);
	for(int i = 1; i < 60; ++i) pow2[i] = pow2[i-1]*2;
	for(int i = 1; i < 60; ++i) pow2[i] += pow2[i-1];
	ll ans = 0;
	for(ll i = 0; i < 60; ++i) if((H>>i)&1) ans = pow2[i];
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		ArrayList array = new ArrayList();
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		boolean ans = true;
		String w=sc.next();
		array.add(w);
		for(int i=0; i<a-1; i++) {
			String w2=sc.next();		
			if(array.contains(w2)) {
				ans = false;
			}
			if(w.charAt(w.length()-1)!= w2.charAt(0)) {
				ans = false;
			}
			array.add(w2);
			w=w2;
		}
		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N;
    int A[214514];
    int B[214514]={};
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }
    REP(i,N){
        B[i+1]=B[i]+A[i];
    }
    int Ans=INF;
    REP(i,N+1){
        int c=(B[N]-B[i]);
        int d=(B[i]-B[0]);
        Ans=min(Ans,abs(c-d));
    }
    cout << Ans << endl;
    return 0;
}



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

int h,w,k;
int field[6][6];

int main(){

    cin>>h>>w>>k;
    rep(i,6){
        rep(j,6){
            field[i][j]=0;
        }
    }


    char tmp;
    rep(i,h){
        rep(j,w){
            cin>>tmp;
            if(tmp=='.')field[i][j]=0;
            else field[i][j]=1;
        }
    }

    int ans=0;
    int calc_f[6][6];

    // bit全探索
    for(int bit=0; bit < (1<<(w+h));++bit){
        //計算用field生成
        rep(i,6){
            rep(j,6){
                calc_f[i][j]=field[i][j];
            }
        }
        int sum=0;
        rep(i,(w+h)){
            if(bit&(1<<i)){
                //0で塗りつぶし
                if(i<h){
                    rep(j,6){
                        calc_f[i][j]=0;
                    }
                    // cout<<" h["<<i<<"]"<<endl;
                }else{
                    int tmp_i =i-h;
                    rep(i,6){
                        calc_f[i][tmp_i]=0;
                    }
                    // cout<<" w["<<tmp_i<<"]"<<endl;
                }

            }
        }

        //集計
        rep(i,6){
            rep(j,6){
                sum += calc_f[i][j];
            }
        }
        // cout<<bit<<":"<<sum<<endl;
        // cout<<"---"<<endl;

        if(sum==k){
            ans++;
        }
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3652
N = int(input())
lun = ["1","2","3","4","5","6","7","8","9"]
ruiseki = 0
oldlevel = 9
nowlevel = 0
while len(lun) < N:
  for _ in range(oldlevel):
    if lun[ruiseki][-1] != "0":
      lun.append(lun[ruiseki] + str(int(lun[ruiseki][-1]) - 1))
      nowlevel += 1
    lun.append(lun[ruiseki] + lun[ruiseki][-1])
    nowlevel += 1
    if lun[ruiseki][-1] != "9":
      lun.append(lun[ruiseki] + str(int(lun[ruiseki][-1]) + 1))
      nowlevel += 1
    ruiseki += 1
  oldlevel = nowlevel
  nowlevl = 0
print(lun[N - 1])

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	rep(i, N) cin >> C[i];

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	int ans = 0;
	rep(i, N) {
		int a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
		int c = C.end() - upper_bound(C.begin(), C.end(), B[i]);
		ans += a * c;
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
  int K,N;
  cin>>K;
  N=K%2;
  if(N==1){
    cout<<(K/2+1)*(K/2)<<endl;
    return 0;
  }
  cout<<(K/2)*(K/2)<<endl;
  return 0;
}

  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
  string s,t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.length(); ++i) {
    ans += s[i] != t[i];
  }
  cout << ans << endl;

}


Measured memory_bytes: 3796
//
//  main.cpp
//  競技20190629

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
#define ll long long int
const ll overflow=1000000007;

int br(){
    printf("\n");
    return 0;
}
ll combi(int n, int k) {
    if (n == k || k == 0 )
        return 1;
    else {
        return combi(n - 1, k - 1) + combi(n - 1, k);
    }
}

ll combi2(int n, int k) {
    if (n == k || k == 0 )
        return 1;
    else {
        return (combi(n - 1, k - 1) + combi(n - 1, k) )% overflow;
    }
}
ll modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll combi3(ll n,ll k,ll m){
    ll ans=1;
    for(ll i=0;i<k;i++){
        ans=(ans*(n-i))%m;
        ans=(ans*modinv(i+1,m))%m;
    }
    return ans;
}


int gcd(int a,int b){//最大公約数
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}


//sort(a,a+100,greater<int>());大きい順
//sort(a,a+100);小さい順
/*
 int N;
 cin >> N;
 vector<int> d(N);
 int i = 0;
 int n = N;
 while(n--){
 cin >> d[i];
 i++;
 }
 
 sort(d.begin(),d.end());
 d.erase( unique(d.begin(),d.end()), d.end());隣り合った重複を削除し、き消し多分要素数を詰める
 cout<<d.size()<<endl;
 return 0;
*/

int X(){
    string s;
    cin >> s;
    size_t size = s.length();
    
    string ans;
    
    for(int i=0;i<size;i++){
        if(i%2==0){
            ans = ans+s[i];
            
        }
    }
    cout << ans << endl;
    
    return 0;
}

int Ap(){
    string s;
    cin >> s;
    if(s[0]==s[1] && s[1]==s[2] && s[2]==s[3]){return printf("No\n");}
    if(s[0]==s[1] && s[2]==s[3]){return printf("Yes\n");}
     if(s[0]==s[2] && s[1]==s[3]){return printf("Yes\n");}
     if(s[0]==s[3] && s[1]==s[2]){return printf("Yes\n");}
  return printf("No\n");
}

int mymid(int a,int b,int c){
    if(a>=b && b>=c )return b;
    if(a<=b && b<=c )return b;
    return -1;
}

int Bp(){
    int N;
    cin >> N;
    int p[N];
    for(int i=0;i<N;i++){cin >> p[i];}
    int ans=0;
    for(int i=1;i<N-1;i++){
        if(mymid(p[i-1],p[i],p[i+1])==p[i])ans++;
    }
    printf("%d\n",ans);
    return 0;
}

int Cp(){
    int N;
    cin >> N;
    vector<int> d(N);
    int i = 0;
    int nn = N;
    while(nn--){
        cin >> d[i];
        i++;
    }
    sort(d.begin(),d.end());
    printf("%d\n",d[N/2]-d[N/2-1]);
    return 0;
}


int Dp(){
    ll n,k;
    cin >> n >> k;
    //for(int i=1;i<=k;i++){printf("%d\n",(int)(combi2(n-k+1,i)*combi(k-1,i-1)) );}
    for(int i=1;i<=k;i++){printf("%lld\n",(combi3(n-k+1,i,overflow)*combi3(k-1,i-1,overflow))%overflow );}
    return 0;
}
int main(){
    Dp();
    return 0;
}


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

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

    string S[H];
    for(int i=0;i<H;i++){
        cin >> S[i];
    }

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

    int new_i,new_j;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]=='#'){
                continue;
            }

            int count=0;
            for(int k=0;k<8;k++){
                new_i = 0;
                new_j = 0;

                new_i = i + dy[k];
                new_j = j + dx[k];

                if(new_i<0 || new_i>=H) continue;
                if(new_j<0 || new_j>=W) continue;
                if(S[new_i][new_j]=='#'){
                    count++;
                }
            }
            S[i][j] = char(count + '0');
        }
    }

    for(int i=0;i<H;i++){
        cout << S[i] << endl;
    }


}

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

int main(){
	string s;
	cin>>s;
	int n = s.size();
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(ans % 2 == 0){
			if(s[i] == 'A') ans++;
		}else{
			if(s[i] == 'Z') ans++;
		}
	}
	if(ans % 2 == 1) ans--;
	if(ans == 0) cout<<-1<<endl;
	else{
		for(int i = 0; i < ans/2; i++)cout<<"AZ";cout<<endl;
	}
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,P,a,p=0;cin>>N>>P;
  long ans=10;
  for(int i=0;i<N;i++){
    cin>>a;
    if(a%2==0)p++;
  }
  if(p==N){
    if(P==1)ans=0;
    else ans=pow(2,N);
  }
  else ans=pow(2,N-1);
  cout<<ans<<endl;
}

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

namespace shit
{
	typedef long long ll;
	const int N=1010000,MOD=998244353;

	ll inv(int x){return x==1?1:(-(MOD/x)*inv(MOD%x)%MOD);}

	int fact[N],ifact[N];
	int f(int n,int m){return (ll)fact[n+m]*ifact[n]%MOD*ifact[m]%MOD;}

	int n,k;

	int calc(int R,int B) //assure that R>B
	{
		int K=std::max(B-R+n,0),T=R-K+1;
		if(K>R || K>B)return 0;

		return f(R,B)-(R>=T?f(R-T,B+T):0);
	}

	void initialize()
	{
		scanf("%d%d",&n,&k);
		fact[0]=1;
		for(int i=1;i<N;i++)fact[i]=(ll)fact[i-1]*i%MOD;
		ifact[N-1]=inv(fact[N-1]);
		for(int i=N-1;i;i--)ifact[i-1]=(ll)ifact[i]*i%MOD;
	}

	void solve()
	{
		initialize();
		int ans=0;
		for(int R=k;R*2>k;R--)
			ans=(ans+calc(R,k-R))%MOD;
		if(k%2==0)ans=(ans+calc(k/2,k/2-1))%MOD;
		ans=(ans+MOD)%MOD;
		printf("%d\n",ans);
	}

}

int main()
{
	shit::solve();
	return 0;
}


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

int main() {
    long long N;
    cin >> N;
    vector <long long> h(N);
    for (long long i=0; i<N; i++) cin >> h.at(i);
    vector <long long> c(N);
    c.at(0)=0;
    c.at(1)=abs(h.at(1)-h.at(0));
    for (long long i=2; i<N; i++) {
        c.at(i)=min(c.at(i-2)+abs(h.at(i)-h.at(i-2)), c.at(i-1)+abs(h.at(i)-h.at(i-1)));
    }
    cout << c.at(N-1) << endl;
}

Measured memory_bytes: 4772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String r = sc.next();
		String g = sc.next();
		String b = sc.next();
		int rgb = Integer.valueOf(r + g + b);
		if (rgb % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		sc.close();
	}
}

Measured memory_bytes: 23764
#!/usr/bin/python3

#渡されたxとlistに対して、listに存在しない最も近い整数を返す関数
def foo(x, list):
    i = 1
    if list.count(str(x)) == 0:
        return (x)
    while True:
        if list.count(str(x-i)) == 0:
            return (x-i)
        if list.count(str(x+i)) == 0:
            return (x+i)
        i = i+1
        
#標準出力からの読み込み
x, n = input().split(" ")
if int(n) != 0:
    p = input().split(" ")
    print(foo(int(x), p))
else:
    print(x)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int N, M; 
bool C[60][60] = {}; 
bool V[60] = {}; 
bool bridge = false; 
int A[60] = {}, B[60] = {}; 
void search(int x){
	V[x] = true; 
	for(int i = 1; i <= N; i++){
		if(C[x][i] & !V[i]){search(i);}
	}
	return; 
}
int main() {
	cin >> N >> M; 
    int count = 0; 
	for(int i = 0; i < M; i++){
		cin >> A[i] >> B[i]; 
		C[A[i]][B[i]] = true, C[B[i]][A[i]] = true; 
	}
	for(int i = 0; i < M; i++){
		C[A[i]][B[i]] = false, C[B[i]][A[i]] = false; 
		search(1); 
		for(int j = 1; j <= N; j++){
			if(V[j] == false){bridge = true; break;}
		}
		if(bridge) {count ++;}
		C[A[i]][B[i]] = true, C[B[i]][A[i]] = true; 
		for(int j = 1; j <= N; j++){
			V[j] = false; 
		}
        bridge = false; 
	}
	cout << count << endl; 
}

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

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    if ((a - b) & 1) {
        puts("IMPOSSIBLE\n");
    } else {
        printf("%d\n", (a + b) / 2);
    }
}

Measured memory_bytes: 256
N = int(input())
li = [int(i) for i in input().split()]

dp = [0] * N
dp[1] = abs(li[1] - li[0])

for i in range(2,N):
    dp[i] = min(dp[i-2] + abs(li[i] - li[i-2]), dp[i-1] + abs(li[i] - li[i-1]))

print(dp[-1])


Measured memory_bytes: 13780
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll int n;
	cin>>n;
	cout<<n*n*n<<endl;


	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <set>

using namespace std;

int main() {
    int N, Q;
    cin >> N;

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

    cin >> Q;

    int ans = 0;
    for (int i = 0; i < Q; ++i) {
        int n;
        cin >> n;
        if (S.find(n) != S.end()) ++ans;
    }

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



Measured memory_bytes: 7768
n = int(input())

arr=list(map(int,input().split()))
inf =1e9+5
dp = [inf]*(n)

dp[0] = 0

for i in range(n):
    for j in range(i+1,i+3):
        if j < n:
            dp[j] = min(dp[j],dp[i]+abs(arr[i]-arr[j]))
            
            
print(dp[n-1])

Measured memory_bytes: 13928
import numpy as np
import time

def get_sieve(n):
  # エラトステネスの篩
  f = np.ones(n+1, dtype=bool)
  f[0] = f[1] = False
  rn = np.sqrt(n)
  for i in range(2, int(rn)+1):
    if f[i]:
      # 素数
      j = 2
      while 1:
        ij = i * j
        if ij > n:
          break
        f[ij] = False
        j += 1
  return f


N = int(input())

rn = np.sqrt(N)
S = get_sieve(int(rn)+1)

count = 0
primes = []
newN = N
for p, s in enumerate(S):
  if s:
    e = 1
    while 1:
      z = p**e
      if z > newN:
        break
      if newN % z == 0:
        # print(f"{newN}は{z}で割り切れます. N/z={newN//z}")
        newN = newN // z
        count += 1
      e += 1
if newN > rn:
  count += 1
print(count)



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

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using namespace std;

/* function */
//  - none - 


/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int A, B;    // input
  int C, D;    // input

  int ans_min;


  /* Input, Array_Proclamation */
  cin >> A >> B;
  cin >> C >> D;

  int A_begin, A_end;
  int B_begin, B_end;
  A_begin = A;
  A_end   = B;
  B_begin = C;
  B_end   = D;

  vector<int> times(4);
  times.at(0) = A;
  times.at(1) = B;
  times.at(2) = C;
  times.at(3) = D;


  /* Initialize */
  //  - none - 


  /* Calculation */

  sort( all(times) );

  if(times.at(1) == A_end && times.at(2) == B_begin)
  {
    ans_min = 0;
  }
  else if(times.at(1) == B_end && times.at(2) == A_begin)
  {
    ans_min = 0;
  }
  else
  {
    ans_min = times.at(2) -times.at(1);
  }


  /* Output */
  cout << ans_min << endl;


  return 0;

}


/* entity */
//  - none -




Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

const int maxn = 3e5 + 5;
int n, a[maxn], ans[maxn];
set <pair <int, int> > S[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < (1 << n); i ++) {
		scanf("%d", a + i);
		S[i] = {make_pair(a[i], i)};
	}
	for (int i = 0; i < n; i ++)
		for (int j = 0; j < (1 << n); j ++) {
			if (j & (1 << i)) continue;
			int k = j | (1 << i);
			for (pair <int, int> x:S[j])
				S[k].insert(x);
			while (S[k].size() > 2)
				S[k].erase(S[k].begin());
		}
	for (int i = 1; i < (1 << n); i ++) {
		ans[i] = 0;
		for (pair <int, int> x:S[i])
			ans[i] += x.first;
		ans[i] = max(ans[i], ans[i - 1]);
		printf("%d\n", ans[i]);
	}
	return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	
	int ind=0;
	for(int i=0;i<n;i++){
		if(a[i]==(ind+1)) ind++;
	}
	if(ind==0){
		cout << -1 << "\n";
	}else{
		cout << (n-ind) << "\n";
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
//#define DEBUG


int main(void)
{
  string S;
  cin >> S;
  if(S[2]==S[3] && S[4]==S[5])
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }
  
  return 0;
} 

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

int main(){
    int N;
    cin >> N;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    long long int sum = 0;
    for (int i = 0; i < M; i++)
    {
        int A;
        cin >> A;
        sum += A;
    }

    if (sum > N)
    {
        cout << -1 << endl;
        return 0;
    }

    cout << N - sum << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  int i;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  int mini=100000000000;
  for(i=1;i<100;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      int dis=vec.at(j)-i;
      sum+=dis*dis;
    }
    mini=min(mini,sum);
  }
  cout << mini;
}
      

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

x,y = readInts()

if abs(x)==abs(y):
  if x==y:
    print(0)
  else:
    print(1)
elif x==0:
  if y>0:
    print(y)
  else:
    print(abs(y)+1)
elif y==0:
  if x>0:
    print(1+x)
  else:
    print(abs(x))
elif abs(x)<abs(y):
  if x>0 and y>0:
    print(y-x)
  elif x>0 and y<0:
    print(abs(y)-x+1)
  elif x<0 and y>0:
    print(x+y+1)
  else:
    print(abs(y)-abs(x)+2)
else:
  if x>0 and y>0:
    print(2+x-y)
  elif x>0 and y<0:
    print(1+x+y)
  elif x<0 and y>0:
    print(1+abs(x)-y)
  else:
    print(y-x)

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
bool is_pal(string s){
    string k = s;
    reverse(k.begin(), k.end());
    return k==s;
}
int main(){
    string s; cin >> s;
    bool check1 = false, check2 = false;
    int n = (int)s.size();
    string a = s.substr(0,n/2);
    
    string b = s.substr(n/2 + 1, n/2);
   // cout << a << ':' << b << endl;
    check1 = is_pal(a);
    check2 = is_pal(b);
    if(check1 && check2 && is_pal(s)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
}



Measured memory_bytes: 256
import sys
input=sys.stdin.readline
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    zeros=[0]*n

    if min(a)==n:
        print(*a)
        exit()

    for i in range(k):
        x=zeros.copy()
        for j in range(n):

        
            l=max(0,j-a[j])
            r=min(j+a[j]+1,n)
            #print(l,r)
            x[l]+=1
            if r!=n:
                #print(r)
                x[r]+=-1
            #print(x)
        ruiseki=[0]*n
        ruiseki[0]=x[0]
        a[0]=ruiseki[0]
        for i in range(1,n):
            ruiseki[i]=ruiseki[i-1]+x[i]
            a[i]=ruiseki[i]
        if min(a)==n:
            print(*a)
            exit()
 
        #print(*ruiseki)
    print(*a)
if __name__=="__main__":
    main()

Measured memory_bytes: 127788
dx = [-1, -1, 0, 0, 1, 1]
dy = [-1, 0, -1, 1, 0, 1]

loop do
  t, n = gets.chomp.split.map(&:to_i)

  if t | n == 0
    break
  end

  visited = Array.new(200) { Array.new(200, 0) }

  field = Array.new(200) { Array.new(200, 0) }
  
  n.times do
    x, y = gets.chomp.split.map(&:to_i)
    field[y + 100][x + 100] = 1
  end

  sx, sy = gets.chomp.split.map(&:to_i)
  sx += 100
  sy += 100

  queue = [[sx, sy, 0]]
  visited[sy][sx] = 1

  while !queue.empty? do
    tmp = queue.shift

    if tmp[2] + 1 > t
      next
    end
    
    6.times do |i|
      nx = tmp[0] + dx[i]
      ny = tmp[1] + dy[i]
      if field[ny][nx] == 1 || visited[ny][nx] == 1
        next
      end
      visited[ny][nx] = 1
      queue.push([nx, ny, tmp[2] + 1])
    end
  end

  ans = 0;
  200.times do |i|
    200.times do |j|
      ans += visited[i][j]
    end
  end
                          
  puts ans
end

Measured memory_bytes: 13412
#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 reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> xs(n);
  vector<int> ys(n);
  vector<ll> hs(n);
  rep(i, n) cin >> xs[i] >> ys[i] >> hs[i];
  rep(i, 101)rep(j, 101) {
    ll ch = -1;
    bool ok = true;
    rep(k, n) {
      if (hs[k] != 0) {
        ll tmp = hs[k] + abs(xs[k] - i) + abs(ys[k] - j);
        if (ch == -1) {
          ch = tmp;
        } else {
          if (ch != tmp) {
            ok = false;
            break;
          }
        }        
      }
    }
    if (!ok) continue;
  
    rep(k, n) {
      if (hs[k] == 0) {
        ll tmp = abs(xs[k] - i) + abs(ys[k] - j);
        if (ch > tmp) {
          ok = false;
          break;
        }
      }
    }

    if (ok) {
      cout << i << " " << j << " " << ch << endl;
    }

  }
  
  return 0;
}

Measured memory_bytes: 3636
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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


int main(){
    int N, M, ans=0;
    string A[60], B[60];
    cin >> N >> M;
    for(int i = 0; i < N; ++i) cin >> A[i];
    for(int i = 0; i < M; ++i) cin >> B[i];
    for(int i = 0; i <= N - M; ++i){
        for(int j = 0; j <= N - M; ++j){
            bool ok = true;
            for(int m = i; m < i + M; m++){
                if(A[m].substr(j, M) != B[m - i].substr(0, M)) ok = false;
            }
            if(ok){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


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

void solve(){
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}
		
	


int main(){
	solve();
}


Measured memory_bytes: 3636
N=int(input())
T=[]
for i in range(N):
    T.append(int(input()))
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b>0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
if N==1:
    print(T[0])
elif N==2:
    print(lcm(T[0],T[1]))
else:
    l=[T[0]]
    for i in range(N-1):
      l.append(lcm(l[i],T[i+1]))
    print(l[-1])

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

int a[200005];
int ans,mx,n,k;

int main()
{
    //freopen("file.inp","r",stdin);
    cin >> k >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 2; i <= n; i++)
    {
        ans += a[i] - a[i - 1];
        mx = max(mx, a[i] - a[i - 1]);
    }
    int res = a[1] + (k - a[n]);
    mx = max(mx, res);
    ans += res;
    cout << ans - mx;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

#define WHITE 0
#define GLAY 1
#define BLACK 2
#define MAX 100
#define INFTY 10000000
#define NIL -1

int color[MAX];
int G[MAX][MAX];
int n;
int d[MAX];
int p[MAX];

void buildG(){
  int u,k,i,j,v,c;

  for(i = 0; i < n; i++){
    scanf("%d %d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d %d",&v,&c);
      G[u][v] = c;
    }
  }
  return;
}

void init(){
  int i;

  for(i = 0; i < n; i++){
    color[i] = WHITE;
    d[i] = INFTY;
  }

}

void dijkstra(int s){
  int mincost,i,v,u;
  
  init();
  d[s] = 0;
  p[s] = NIL;

  while(1){
    mincost = INFTY;
    for(i = 0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == INFTY)break;

    color[u] = BLACK;

    for(v = 0; v < n; v++){
      if(color[v] != BLACK && G[u][v] != 0){
        if(d[u] + G[u][v] < d[v]){
          d[v] = d[u] + G[u][v];
          p[v] = u;
          color[v] = GLAY;
        }
      }
    }
  }
}

int main(){
  int i,j;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++)G[i][j] = INFTY;
  }
  
  buildG();
  dijkstra(0);

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


Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int input() {
	int r;
	scanf("%lld", &r);
	return r;
}
int n, c[234567], dp[234567], c1[234567];
signed main() {
	n = input(); for1(i, n)c[i] = input();
	dp[0] = 1;
	for1(i, n) {
		dp[i] = dp[i - 1];
		if (c1[c[i]] > 0 && c[i] != c[i - 1])dp[i] += dp[c1[c[i]]];
		c1[c[i]] = i;
		dp[i] %= mod;
	}
	printf("%lld\n", dp[n]);
}

Measured memory_bytes: 5248
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N;
    cin >> N;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    sort(A, A+N, greater<ll>());
    priority_queue<ll, vector<ll> > pq;
    pq.push(A[0]);
    ll ans = 0;
    rep(i,1,N){
        ll v = pq.top();
        pq.pop();
        ans += v;
        pq.push(A[i]);
        pq.push(A[i]);
    }
    print(ans);




    

}

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

Measured memory_bytes: 6892
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>num(n);
    vector<int>box(n);
    int check(int a);
    int count(int b, int c);
    for(int i = 0; i < n; i++){
        cin >> num.at(i);
    }
    for(int i = 0; i < n; i++){
        box.at(i) = check(num.at(i));
    }
    int ans = box.at(0);
    for(int i = 0; i < n; i++){
        ans = count(ans,box.at(i));
    }
    cout << ans << endl;
}
int check(int a){
    int answer = 0;
        while(a != 0){
            if(a % 2 == 0){
                answer += 1;
                a /= 2;
            }
            else{
                a = 0;
            }
        }
    return answer;
}

int count(int b, int c){
    
    if(b <= c){
        return b;
    }
    else{
        return c;
    }
}


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

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll h, w; cin >> h >> w;

    char c[h][w];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> c[i][j];
        }
    }

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cout << c[i][j];
        }
        cout << "\n";
        for (int j=0; j<w; j++) {
            cout << c[i][j];
        }
        cout << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

// REQUIRES a >= b
static int FindGCD(int a, int b) {
  if (!b)
    return a;
  for (int d = b; d > 1; --d) {
    if (b % d == 0 && a % d == 0)
      return d;
  }
  return 1;
}

int main() {
  int x, y;
  cin >> x >> y;

  const int ret = x >= y ? FindGCD(y, x % y) : FindGCD(x, y % x);
  cout << ret << endl;
  return 0;
}

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


#define ll long long
#define scan(x) scanf("%lld",&x)

const ll mod=1e9+7;
using namespace std;
ll dp[101][5][5][5],n;

ll func(ll x, ll prev1, ll prev2 , ll prev3)
{
    if(x>=n)
        return 1;
    ll ret= dp[x][prev1][prev2][prev3];
    if(ret!=-1)
        return ret;
    ll ans=0;
    for(ll i=1;i<=4;i++)
    {
        if(i==2)
        {
            if((prev1==3)&&(prev2==1))
                continue;

        }
        if(i==3)
        {
            if((prev1==2)&&(prev2==1))
                continue;
             if((prev1==1)&&(prev2==2))
                continue;

            if((prev2==2)&&(prev3==1))
                continue;

            if((prev3==1)&&(prev1==2))
                continue;

        }

        ans+= func(x+1,i,prev1,prev2)%mod;
        ans%=mod;


    }
    dp[x][prev1][prev2][prev3]=ans;
    return ans;

}


int main()
{
    memset(dp,-1,sizeof dp);
    ll i,j,k,l,m;
    cin >> n;
    cout << func(0,0,0,0);
}


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

int main()
{
    int n[4];
    bool flag[4] = {false, false, false, false};
    cin >> n[0] >> n[1] >> n[2] >> n[3];

    if (n[0] == 1 || n[1] == 1 || n[2] == 1 || n[3] == 1)
    {
        flag[0] = true;
    }
    if (n[0] == 9 || n[1] == 9 || n[2] == 9 || n[3] == 9)
    {
        flag[1] = true;
    }
    if (n[0] == 7 || n[1] == 7 || n[2] == 7 || n[3] == 7)
    {
        flag[2] = true;
    }
    if (n[0] == 4 || n[1] == 4 || n[2] == 4 || n[3] == 4)
    {
        flag[3] = true;
    }

    if (flag[0] && flag[1] && flag[2] && flag[3])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A,B,X;
    cin >> A >> B >> X;
    if (A==X){
        cout << "YES";
    }
    else if (A>X){
        cout << "NO";
    }
    else if (A+B>=X){
        cout << "YES";
    }
    else if (A+B<X){
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

ll A, B, a[100010];
int n;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    if (n < 1200) cout << "ABC";
    else cout << "ARC";
    return 0;
}


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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll A, B;
    scanf("%lld %lld", &A, &B);
    if ( (A + B) % 2 == 0)
        printf("%lld\n", (A + B) / 2);
    else  printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 256
using System;

namespace B
{
    class Program
    {
        static int[] ToInt(string[] str)
        {
            int len = str.Length;
            int[] intAry = new int[len];
            for(int i = 0; i < len; i++)
            {
                intAry[i] = int.Parse(str[i]);
            }
            return intAry;
        }
        static void Main(string[] args)
        {
            int[] IntAry = ToInt(Console.ReadLine().Split(' '));
            int Count = 0, Player;
            int[] HP = new int[2];
            HP[0] = IntAry[0];
            HP[1] = IntAry[2];
            int[] ATK = new int[2];
            ATK[0] = IntAry[1];
            ATK[1] = IntAry[3];
            string[] Output = new string[2] {"Yes","No"};

            while (true)
            {
                Player = Count % 2;
                if( Player == 0 )
                {
                    HP[1] -= ATK[Player];

                }else{
                    HP[0] -= ATK[Player];
                }
                if( HP[0] <= 0 ||HP[1] <= 0 )
                {
                    Console.WriteLine(Output[Player]);
                    break;
                }
                Count++;
            }
        }
    }
}


Measured memory_bytes: 27480
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007

bool vis[200005];
vector<int> vec[2000005], v1;
int child[2000005];
int parent[2000005];
int div1[100005];
int min_indx[900005];
int count1 = 0;
int height = 0;
int max_indx[200005];
void dfs(int node)
{

    vis[node] = 1;
    // cout << node << "\n";
    min_indx[count1] = node;
    max_indx[node] = min(max_indx[node], count1);
    count1++;

    //  count1++;
    child[node] = height++;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            min_indx[count1] = node;
            max_indx[node] = min(max_indx[node], count1);
            count1++;
        }
    }
    height--;
}

int MAXN = 200005;
int LOGMAXN = (int)log2(200005) + 1;
int M[200005][60];
void process2(int A[], int N)
{
    int i, j;

    //initialize M for the intervals with length 1
    for (i = 0; i < N; i++)
        M[i][0] = i;
    //compute values from smaller to bigger intervals
    for (j = 1; 1 << j <= N; j++)
        for (i = 0; i + (1 << j) - 1 < N; i++)
            if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]])
                M[i][j] = M[i][j - 1];
            else
                M[i][j] = M[i + (1 << (j - 1))][j - 1];
}
//int parent[200005];
vector<int> vec1;
//bool vis[200005];
//int hei[200005];
int lev[200005];
int dis[200005];
bool cmp(pair<int, int> &a,
         pair<int, int> &b)
{
    return a.second < b.second;
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    //  int t;
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * (h / 2) << "\n";
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n; cin >> n;
    vector<ll>a(n),b(n),c(n);
    for(ll i = 0;i < n;i++)cin >> a[i];
    for(ll i = 0;i < n;i++)cin >> b[i];
    for(ll i = 0;i < n;i++)cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    ll ans = 0;
    for(ll i = 0;i < n;i++)
        ans += distance(a.begin(),lower_bound(a.begin(),a.end(),b[i]))*distance(upper_bound(c.begin(),c.end(),b[i]),c.end());

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	string s;cin >> s;
	vector<int> ans;
	int cur = n;
	while(1){
		bool ch = true;
		for(int i = max(0,cur - m); i < cur; i++){
			if(s.at(i) == '0'){
				ans.pb(cur - i);
				cur = i;
				ch = false;
				break;
			}
		}
		if(ch){
			cout << -1 << endl;
			return 0;
		}
		if(cur == 0) break;
	}
	for(int i = ans.size() - 1; i >= 0; i--){
		if(i == 0) cout << ans.at(i) << endl;
		else cout << ans.at(i) << " ";
	}
}


Measured memory_bytes: 1096