akhauriyash/Code-Regression huggingface dataset:
p,q,r=map(int,input().split())

    
def comb_mod(N,K,modp):

    K_fact=1
    NK_fact=1
    N_fact=1

    for i in range(1,K+1):
        K_fact*=i
        K_fact=K_fact%modp
    for i in range(1,N-K+1):
        NK_fact*=i
        NK_fact=NK_fact%modp
    for i in range(1,N+1):
        N_fact*=i
        N_fact=N_fact%modp

    K_inv=pow(K_fact, -1, modp)
    NK_inv=pow(NK_fact, -1, modp)
    pat=(N_fact*K_inv)%modp*NK_inv%modp
    return pat

pat=comb_mod(p*q-2,r-2,10**9+7)

ans=0
for i in range(0,q+1):
    ans+=i*(q-i)*p*p
    ans=ans%(10**9+7)
    
for k in range(0,p+1):
    ans+=k*(p-k)*q*q%(10**9+7)
    ans=ans%(10**9+7)

print(ans*pat%(10**9+7))

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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == 'o') counter++;
    if (s[1] == 'o') counter++;
    if (s[2] == 'o') counter++;
    cout << counter * 100 + 700 << endl;
    return 0;

}

Measured memory_bytes: 256
while gets
	n,k = $_.split.map(&:to_i)
	break if n == 0 
	l = gets.split.to_a.map(&:to_i)
	n.times do
		m = gets.split.to_a.map(&:to_i)
		k.times do |i|
			l[i] -= m[i]
		end
	end
	puts l.min < 0 ? "No" : "Yes"
end

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

int t[55][55] = {0};



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	int n , m;
	cin >> n >> m;
	vector<string> a(n) , b(m);
	rep(i , n){
		cin >> a[i];
	}
	rep(i , m){
		cin >> b[i];
	}
	if(m > n)dier("No");
	int total = 0;
	for(int i = 0 ; i < n ; ++i){
		if(i + m > n)break;
		for(int j = 0 ; j < n ; ++j){
			if(j + m > n)break;
			total = 0;
			for(int x = i ; x < i + m ; ++x){
				for(int y = j ; y < j + m ; ++y){
					total += a[x][y] == b[x - i][y - j];
				}
			}
			if(total == m * m){
				dier("Yes");
			}
		}
		
	}
	dier("No");


	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

struct UnionFind {
  // 子は親のID,親は-サイズ
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};

ll n, m;
int main() {
  cin >> n >> m;
  vector<ll> a(m), b(m), ans;
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }

  ans.push_back(n * (n - 1) / 2);

  UnionFind uf(n);
  for (int i = m - 1; i > 0; --i) {
    ll cnt = 0;
    if (uf.same(a[i], b[i])) {
      ans.push_back(ans.back());
      continue;
    } else {
      ans.push_back(ans.back() - (ll)uf.size(a[i]) * (ll)uf.size(b[i]));
    }
    uf.unite(a[i], b[i]);
  }

  reverse(ans.begin(), ans.end());

  rep(i, m) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 6212
// She is Pretty pretty!
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 1e6 + 100;
const int mod = 1e9 + 7;
const int MAXN = 55;  //几维就写几   不要多1的
// ll m[MAXN][MAXN]={};
struct Matrix {
    ll mat[MAXN][MAXN];
    Matrix() {}
    Matrix operator*(Matrix const &b) const {
        Matrix res;
        memset(res.mat, 0, sizeof(res.mat));
        for (int i = 0; i < MAXN; i++)
            for (int j = 0; j < MAXN; j++)
                for (int k = 0; k < MAXN; k++)
                    res.mat[i][j] =
                        (res.mat[i][j] + this->mat[i][k] * b.mat[k][j]) % mod;
        return res;
    }
};
Matrix pow_mod(Matrix base, ll n) {
    Matrix res;
    memset(res.mat, 0, sizeof(res.mat));
    for (int i = 0; i < MAXN; i++) res.mat[i][i] = 1;
    while (n > 0) {
        if (n & 1) res = res * base;
        base = base * base;
        n >>= 1;
    }
    return res;
}
int n;
ll k;
int main() {
    Matrix base;
    memset(base.mat, 0, sizeof base.mat);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> base.mat[i][j];
        }
    }
    Matrix ans = pow_mod(base, k);
    ll ANS = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ANS = (ANS + ans.mat[i][j]) % mod;
        }
    }
    cout << ANS << endl;
    return 0;
}

Measured memory_bytes: 384
s,S,m,M,i;main(n){for(;scanf("%d",&n)*n;printf("%d\n",(S-m-M)/(n-2)))for(m=1e3,S=M=i=0;i++<n;S+=s)scanf("%d",&s),s>M?M=s:0,s<m?m=s:0;}

Measured memory_bytes: 0
#include <cstdio>
#include <string.h>
using namespace std;

#define n 100

char temp[100], data[200];
int key=0;

void henkan(char ei[])
{
	int i, d;

	d = 'a' - 'A';

		for (i=0; i<strlen(ei); i++){
			if (ei[i] >= 'A' && ei[i] <= 'Z')
				ei[i] += d;
		}
}

int main (void)
{
	char ei[1001];
	int count=0;


	scanf("%s", data);

	henkan(data);

	while (scanf("%s", ei) != EOF && strcmp(ei, "END_OF_TEXT")!=0){

		if(strlen(ei) == strlen(data))
			henkan(ei);

		if (strcmp(ei, data) == 0)
			count++;
	}

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

	return 0;
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = (int)1e5 + 10;

int n, a[N];
int pref[N], suff[N];

int32_t main(){_

   cin>>n;

   for (int i = 1; i <= n; ++i)
   {
      cin>>a[i];
      pref[i] = __gcd(pref[i-1], a[i]);
   }

   for (int i = n; i >= 1; --i)
   {
      suff[i] = __gcd(suff[i+1], a[i]);
   }
   
   int ans = 1;
   for (int i = 1; i <= n; ++i)
   {
      smax(ans, __gcd(pref[i-1], suff[i+1]));
   }

   cout<<ans;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;

ll x[100],y[100],h[100];

int main(){
	cin >> n;
	rep(i,n)cin >> x[i] >> y[i] >> h[i];
	rep(cy,101){
		rep(cx,101){
			rep(i,n){
				bool ok = true;
				ll d = abs(cx-x[i]) + abs(cy-y[i]);
				ll H = h[i] + d;
				rep(j,n){
					ll dd = abs(cx-x[j]) + abs(cy-y[j]);
					if(max((ll)0,H - dd) != h[j])ok = false;
				}
				if(ok){
					cout << cx << " " << cy << " " << H << endl;
					return 0;
				}
			}
		}
	}
}


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


void solve() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> x(n);
  for (auto& x_i: x) {
      cin >> x_i;
  }
  int min_tairyoku = 1e9;
  for (int p = 1; p <= 100; p++) {
      int sum_tairyoku = 0;
      for (int i = 0; i < n; i++) {
          sum_tairyoku += (x[i] - p) * (x[i] - p);
      }
      min_tairyoku = min(min_tairyoku, sum_tairyoku);
  }
  cout << min_tairyoku << endl;
}

int main() {
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S >> T;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

const int maxn = 1e5 + 5;
int a[maxn];

int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n, k, q;
    sf(n, k, q);
    int ans = 0;
    ll sum = 0;
    rep(i, 1, q) {
        int t = read();
        sum += 1;
        a[t]++;
    }
    rep(i, 1, n) {
        ll temp = sum - a[i];
        ll pre = a[i];
        a[i] = k - temp;
        prln(a[i]);
        if (a[i] <= 0) puts("No");
        else puts("Yes");
    }
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 1024
// Problem : C - Go Home
// Contest : AtCoder - AtCoder Beginner Contest 056
// URL : https://atcoder.jp/contests/abc056/tasks/arc070_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int x;cin>>x;
int pos=0,t=1;
while(pos<x)
pos+=t,t++;
cout<<t-1;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool check_three(int);

int main()
{
  int n, val;
  cin >> n;
  char key;

  bool card[4][13] = {false};
  // for (int i=0; i<4; i++){
  //   for (int j=0; j<13; j++){
  //     card[i][j] = j+1;
  //   }
  // }

  for (int i=0; i<n; i++) {
    cin >> key >> val;
    if (key == 'S') {
      card[0][val-1] = true;
    } else if (key == 'H') {
      card[1][val-1] = true;
    } else if (key == 'C') {
      card[2][val-1] = true;
    } else {
      card[3][val-1] = true;
    }
  }

  // for (int i=0; i<13; i++) {
  //   cout << card[1][i] << endl;
  // }

  for (int i=0; i<4; i++) {
    for (int j=0; j<13; j++) {
      if (card[i][j] != true) {
        if (i == 0) {
          cout << 'S' << " " << j+1 << endl;
        } else if (i == 1) {
          cout << 'H' << " " << j+1 << endl;
        } else if (i == 2) {
          cout << 'C' << " " << j+1 << endl;
        } else {
          cout << 'D' << " " << j+1 << endl;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3084
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define MAX 100005

int main()
{
    jaldi;
    
    ll k, a, b;
    cin >> k >> a >> b;

    if ((a-1)/k != b/k) cout << "OK\n";
    else cout << "NG\n";
    
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    string s;
    cin >> s;
    int n = s.length();

    if(s[0] != '1' || s[n - 1] != '0'){
        cout << -1 << endl;
        return 0;
    }

    for(int i = 1; i < n / 2; ++i){
        if(s[i] != s[n - i - 2]){
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> cnt;
    for(int i = 0; i < n; ++i){
        if(s[i] == '1') cnt.push_back(i + 1);
    }

    int sz = cnt.size();
    vector<P> ans;
    int cur = 1;
    for(int i = 0; i < sz; ++i){
        ans.push_back(P(cur, cur + 1));
        ++cur;
    }

    ++cur;
    int sum = 0;
    for(int i = 0; i < sz; ++i){
        ++sum;
        if(sum < cnt[i]){
            int need = cnt[i] - sum;
            for(int j = 0; j < need; ++j){
                ans.push_back(P(i + 1, cur++));
                ++sum;
            }
        }
    }
    
    for(auto p : ans)   cout << p.first << ' ' << p.second << '\n';
}

Measured memory_bytes: 2756
import sys

def shuffle( cards ):
	h = int( sys.stdin.readline() )
	n = len( cards )
	s = ""
	t = ""
	for i in range( h ):
		s += cards[i]
	for i in range( h, n ):
		t += cards[i]
	t += s
	return t

while True:
	cards = sys.stdin.readline().rstrip()
	if '-' == cards:
		break
	m = int( sys.stdin.readline() )
	for i in range( 0, m ):
		cards = shuffle( cards )
	print( cards )

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

static class CodeJam
{
    static bool CanDo(int N, int K, int[] A, int d)
    {
        int[] M = A.Select(a => a % d).OrderBy(m => m).ToArray();
        int[] X = new int[N];
        int[] Y = new int[N];
        for (int i = N - 1; i >= 0; --i)
        {
            if (i + 1 < N) { Y[i] = Y[i + 1]; }
            Y[i] += d - M[i];
        }
        for (int i = 0; i < N; ++i)
        {
            if (i - 1 >= 0) { X[i] = X[i - 1]; }
            X[i] += M[i];
            if (i + 1 < N && X[i] == Y[i + 1]) { return X[i] <= K; }
        }
        return false;
    }

    static int Solve(int N, int K, int[] A)
    {
        int S = A.Sum();
        var D = new List<int>();
        for (int i = 1; i * i <= S; ++i)
        {
            if (S % i == 0)
            {
                D.Add(i);
                if (i * i < S) { D.Add(S / i); }
            }
        }
        foreach (int d in D.OrderByDescending(d => d))
        {
            if (CanDo(N, K, A, d)) { return d; }
        }
        return 1;
    }

    static void Main(string[] args)
    {
        int[] V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(V[0], V[1], A));
    }
}


Measured memory_bytes: 17564
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main()
{
	int a,b,ans;
	bool up=false;
	while(1)
	{
		cin >> a >> b;
		if(a==0&&b==0)break;
		if(up)cout << endl;
		up=true;
		bool check=false;
		for(int i=a;i<=b;i++)
		{
			if(i%400==0)
			{
				cout << i << endl;
				check=true;
			}
			else if(i%100==0)
			{
			}
			else if(i%4==0)
			{
				cout << i << endl;
				check=true;
			}
		}
		if(!(check))cout << "NA" << endl;
	}
	return 0;
}

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

int dp[5003] , N , M;

int main(){
	cin >> N >> M; if(N == 2){puts("3"); return 0;}
	bool flg = 0; dp[0] = 1; if(!(N & 1)){flg = 1; --N;}
	for(int i = 1 ; i < N ; ++i){
		int val = i <= N / 2 ? i : N - i + 1;
		if(flg && i == N / 2 + 1)
			for(int j = N ; j >= val ; --j)
				for(int k = 1 ; k * val <= j ; ++k)
					dp[j] = (dp[j] + 1ll * dp[j - k * val] * (k + 1)) % M;
		else
			for(int j = val ; j <= N ; ++j) dp[j] = (dp[j] + dp[j - val]) % M;
	}
	N += flg; int sum = N;
	for(int i = 1 ; i < N ; ++i) sum = (sum + 1ll * (N - i) * dp[i]) % M;
	cout << sum; return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);

int main() {
	int a, b; cin >> a >> b;
	if (a * b * (a + b) % 3 == 0)cout << "Possible";
	else cout << "Impossible";
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

int solve() {
	ll n, k;
	cin >> n >> k;

	vector<ll> ps(n);
	vector<ll> cs(n);
	ll p;
	REPD(i, 0, n) { cin >> p; --p; ps[i] = p; }
	REPD(i, 0, n) cin >> cs[i];

	vector<bool> is_examined(n, false);
	vector<ll> cycle_lengths;
	vector<vector<ll>> group_cum_scores;
	REPD(i, 0, n) {
		if (is_examined[i]) continue;
		
		ll pos = i;
		ll cycle_length = 0;
		ll cum_score = 0;
		vector<ll> cum_scores;
		do {
			cum_score += cs[pos];
			cum_scores.emplace_back(cum_score);
			++cycle_length;
			is_examined[pos] = true;
			pos = ps[pos];
		} while (pos != i);
		cycle_lengths.emplace_back(cycle_length);
		group_cum_scores.emplace_back(cum_scores);
	}

	ll res = -MAX_VALUE;
	REPD(i, 0, cycle_lengths.size()) {
		REPD(j1, 0, group_cum_scores[i].size()) {
			REPD(j2, j1, group_cum_scores[i].size() * 2LL) {
				if (j2 - j1 >= k) break;
				ll curr_res = 0;
				if (j2 < group_cum_scores[i].size()) {
					curr_res += group_cum_scores[i][j2];
				}
				else {
					curr_res += group_cum_scores[i][j2 - group_cum_scores[i].size()] + group_cum_scores[i][group_cum_scores[i].size() - 1LL];
				}
				if (j1 > 0) curr_res -= group_cum_scores[i][j1 - 1LL];
				if (group_cum_scores[i][group_cum_scores[i].size() - 1LL] > 0LL) {
					curr_res += group_cum_scores[i][group_cum_scores[i].size() - 1LL] * ((k - j2 + j1 - 1LL) / cycle_lengths[i]);
				}

				res = max(res, curr_res);
			}
		}
	}

	RET(res);

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


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

int main(){
//srandom((unsigned long)time(NULL));

string n;
cin>>n;
bool seven=false;
for(int i=0;i<3;i++){
    if(n[i]-'0'==7)seven=true;
}
if(seven)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt(),B = scan.nextInt();
        if(A+B < A*B && A-B < A*B){
            System.out.println(A*B);

        }else if(A-B < A+B && A*B < A+B){
            System.out.println(A+B);
        }else{
            System.out.println(A-B);
        }
    }
}

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

using namespace std;

int main() {
    char s[500005]={},c;
    int Q,T,F,ok=0,st=200000,dr=200001;
    cin>>s+200000;
    while(s[dr]!=NULL){
        dr++;
    }
    dr--;
    cin>>Q;
    for(int i=1;i<=Q;i++){
        cin>>T;
        if(T==1){
            ok=1-ok;
        }
        else{
            cin>>F>>c;
            if(ok==0 && F==1){
                st--;
                s[st]=c;
            }
            if(ok==1 && F==2){
                st--;
                s[st]=c;
            }
            if(ok==0 && F==2){
                dr++;
                s[dr]=c;
            }
            if(ok==1 && F==1){
                dr++;
                s[dr]=c;
            }
        }
    }
    if(ok==0)   for(int i=st;i<=dr;i++) cout<<s[i];
    else        for(int i=dr;i>=st;i--) cout<<s[i];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
const int N = 1e5 + 55;
int nxtL[N], prvR[N];
int ans[N] = {0};
void solve() {
	string s;
	cin >> s;
	int n = (int) s.size();
	s = '$' + s;
	prvR[1] = 1;
	for (int i = 2; i <= n; ++i) {
		if (s[i] == 'R')
			prvR[i] = i;
		else 
			prvR[i] = prvR[i - 1];
	}
	nxtL[n] = n;
	for (int i = n - 1; i >= 1; --i) {
		if (s[i] == 'L') 
			nxtL[i] = i;
		else 
			nxtL[i] = nxtL[i + 1];
	}
	for (int i = 1; i <= n; i += 1) {
		int par = 0;
		if (s[i] == 'L') {
			int j = prvR[i];
			par ^= (i - j + 1) % 2;
			if (par == 0) ans[j + 1] += 1;
			else ans[j] += 1;
		}
		else if (s[i] == 'R') {
			int j = nxtL[i];
			par ^= (j - i + 1) % 2;
			if (par == 0) ans[j - 1] += 1;
			else ans[j] += 1;
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << ans[i] << ' ';	
	}
}	


Measured memory_bytes: 2924
N=int(input())
S=input()
r=b=g=0
for s in S:
    if s=='R':
        r+=1
    elif s=='B':
        b+=1
    else:
        g+=1
out=0
for i in range(1,N):
    for j in range(min(i+1,N-i)):
        if S[i]!=S[i+j] and S[i]!=S[i-j] and S[i+j]!=S[i-j]:
            out+=1
print(r*b*g-out)

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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, k; cin >> n >> k;
    vector<set<int>> st(n);

    int ans = 0;
    while(n--) {
        int i, x;
        cin >> x;
        for(i = ans; i > 0; i--) {
            auto it = st[i-1].lower_bound(x);
            if(it != st[i-1].end() && *it - x <= k) break;
            if(it != st[i-1].begin() && x - *(--it) <= k) break;
        }

        st[i].insert(x);
        ans = max(ans, i + 1);
    }

    cout << ans;
}

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

int main() {
     int N;
    cin >> N;
    
    long long A[200050];
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    long long S[N + 1];
    S[0] = 0;
    for (int i = 1; i <= N; ++i){
        S[i] = S[i-1] + A[i-1];
    }
    
sort(S, S + N + 1);
   
    long long res = 0;
    long long m = 1;
    
    for (int i=0; i < N; ++i) {
        if ( S[i] == S[i+1]) {
            ++m;
          
            if (i == N - 1) {
                if (S[i] != 0 ) res += m * (m-1) /2;
                else {
                    res += m - 1 + (m-1) * (m-2) /2;
                }
            }
        }
        else {
            if (S[i] != 0 ) res += m * (m-1) /2;
            else {
                res += m - 1 + (m-1) * (m-2) /2;
            }
            m = 1;
        }   
    }
    cout << res << endl;

}

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>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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 T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

long long a[3], m[3];

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

long long inv(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);
    }
    return mod(u, m);
}

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

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

int main() {
    while (cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2]) {
        if (a[0] == 0) break;
        long long b[3];
        
        for (int i = 0; i < 3; ++i) {
            b[i] = 1;
            long long ta = a[i];
            while (ta != 1) {
                ++b[i];
                ta *= a[i];
                ta %= m[i];
                
                //cout <<a[i] << ", " <<  ta << endl;
            }
        }

        long long res = lcm(b[0], b[1]);
        res = lcm(res, b[2]);
        
        //cout << b[0] << ", " << b[1] << ", " << b[2] << endl;
        
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int MAXN = 200005;
const int MAXT = 530000;

int n, a[MAXN];
vector<int> v;

struct seg{
	pi  tree[MAXT];
	int lazy[MAXT];
	void init(int s, int e, int p, vector<int> &v){
		if(s == e){
			tree[p] = pi(v[s], s);
			return;
		}
		int m = (s + e) / 2;
		init(s, m, 2*p, v);
		init(m+1, e, 2*p+1, v);
		tree[p] = min(tree[2*p], tree[2*p+1]);
	}
	void lazydown(int p){
		tree[2*p].first += lazy[p];
		tree[2*p+1].first += lazy[p];
		lazy[2*p] += lazy[p];
		lazy[2*p+1] += lazy[p];
		lazy[p] = 0;
	}
	void add(int s, int e, int ps, int pe, int p, int v){
		if(e < ps || pe < s) return;
		if(s <= ps && pe <= e){
			tree[p].first += v;
			lazy[p] += v;
			return;
		}
		int pm = (ps + pe) / 2;
		lazydown(p);
		add(s, e, ps, pm, 2*p, v);
		add(s, e, pm+1, pe, 2*p+1, v);
		tree[p] = min(tree[2*p], tree[2*p+1]);
	}
	pi query(int s, int e, int ps, int pe, int p){
		if(e < ps || pe < s) return pi(2e9, -1);
		if(s <= ps && pe <= e) return tree[p];
		int pm = (ps + pe) / 2;
		lazydown(p);
		return min(query(s, e, ps, pm, 2*p), query(s, e, pm+1, pe, 2*p+1));
	}
}seg;

int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d",&a[i]);
		v.push_back(a[i]);
	}
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());
	seg.init(0, v.size() - 1, 1, v);
	lint ans = 0;
	for(int i=0; i<n; i++){
		a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
		auto ret = seg.query(a[i], v.size() - 1, 0, v.size() - 1, 1);
		ans += ret.first - v[a[i]];
		seg.add(0, ret.second - 1, 0, v.size() - 1, 1, 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 8180
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")
ll dp[1<<22];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin>>n;
	vvi in(n,vi(n));
	rep(i,n)rep(j,n)cin>>in[i][j];
	int N=1<<n,MOD=1000000007;
	//vi dp(N);
	dp[0]=1;
	rep(i,n)for(int j=N-1;j>=0;j--)if(dp[j])rep(k,n)if(!(1<<k&j)&&in[i][k])
		(dp[j|1<<k]+=dp[j])%=MOD;

	cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 18688
S = input()
N = len(S)


def convert(s):
    lst = []
    for i in range(N):
        if (s >> i) & 1 == 1:
            lst.append(i)
    return lst


def calc(lst):
    if len(lst) == 0:
        return int(S)
    elif len(lst) == 1:
        return int(S[:lst[0] + 1]) + int(S[lst[0] + 1:])
    else:
        tmp = [S[:lst[0] + 1]]
        for i in range(len(lst) - 1):
            tmp.append(S[lst[i] + 1:lst[i+1] + 1])
        tmp.append(S[lst[-1] + 1:])
        ans = 0
        for t in tmp:
            ans += int(t)
        return ans

ans = 0
for i in range(1 << (N - 1)):
    lst = convert(i)
    ans += calc(lst)
print(ans)


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

int main() {
  int N, A, B;
  cin>>N>>A>>B;
  if (N*A == B) {
    cout << B << endl;
  }
  else if (N*A < B) {
    cout << N*A << endl;
  }
  else if (N*A > B) {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        x: i32,
        y: i32,
        xdata: [i32;n],
        ydata: [i32;m],
    }

    'outer: for z in -100..101 {
        if z <= x {
            continue;
        }
        if z > y {
            continue;
        }
        'inner: for i in 0..n {
            if z <= xdata[i] {
                continue 'outer;
            }
        }
        for i in 0..m {
            if z > ydata[i] {
                continue 'outer;
            }
        }
        println!("No War");
        return;
    }
    println!("War");
    return;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,i=0,ans;
  cin >>N >>K;
  
  ans = 1;
  
  while(N--){
    i++;
  	if(std::pow(2,i-1)<K){
      ans *= 2; 
    }else{
      ans += K;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int,input().split()))

count = 0
for i in range(N):
    while True:
        if a[i]%2 == 0:
            a[i] =a[i]//2
            count += 1
        else:
            break
print(count)


Measured memory_bytes: 10044
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n,l;
cin>>n>>l;
ll tmp=infll;
ll a;
ll sum=0;
for(int i=l;i<l+n;i++){
    sum+=i;
    if(chmin(tmp,(ll)abs(0-i))){
        a=i;
    }
}
cout<<sum-a<<endl;
}











Measured memory_bytes: 256
#include <cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    char s[a + b + 1 + 1];
    scanf("\n%s",s);
    if(s[a] == '-'){
        for(int i = 0; s[i] != 0; i++){
            if(i != a){
                if('0' <= s[i] && s[i] <= '9'){
                    continue;
                }else{
                    printf("No\n");
                    
                    return 0;
                }
            }else{
                continue;
            }
        }
    }else{
        printf("No\n");

        return 0;
    }
    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
char a[10001],b[10001];
int main()
{
  scanf("%s\n",a);
  scanf("%s",b);
  sort(a,a+strlen(a));
  sort(b,b+strlen(b));
  if(a[0]<b[strlen(b)-1])
  {
    printf("Yes");
    return 0;
  }
  if(strcmp(a,b)<0)
   printf("Yes");
  else 
  printf("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

int gcd(int x, int y) {
    if(x < y) swap(x, y);
    if(y == 0) return x;

    while(y > 0) {
        if(x < y) swap(x, y);
        int temp = x % y;
        x = y;
        y = temp;
    }
    return x;
}

const int maxn = 100100;
int n, arr[maxn], x;

int main() {
    cin>>n>>x;
    int result = 0;
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        arr[i] = abs(arr[i] - x);
        result = gcd(result, arr[i]);
    }
    cout<<result;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

bool reach[50];
vector<int> edge[50];

void dfs(int now){
    if(reach[now]) return;
    reach[now]=true;
    rep(i,edge[now].size()) dfs(edge[now][i]);
}

int main(void){
    int N,M;
    cin >> N >> M;
    int A[M],B[M];
    rep(i,M) cin >> A[i] >> B[i];
    rep(i,M) A[i]--,B[i]--;
    int ans=0;
    rep(i,M){
        rep(j,N) edge[j].clear();
        rep(j,N) reach[j]=false;
        rep(j,M) if(i!=j) edge[A[j]].push_back(B[j]),edge[B[j]].push_back(A[j]);
        dfs(0);
        bool check=false;
        rep(j,N) if(!reach[j]) check=true;
        if(check) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for (int i = 0; i < N; i++)
    cin >> x[i] >> u[i];
  //x.push_back(5);

  double sum = 0;
  for (int i = 0; i < N; i++)
  {
    if (u[i] == "JPY")
      sum += x[i];

    if (u[i] == "BTC")
      sum += (x[i]) * 380000.0;
  }
  printf("%lf\n", sum);
}

Measured memory_bytes: 256