akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int a;
  cin >> a;
  cout << (a+(a*a)+(a*a*a)) << '\n';
  return;
} 

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3608
def main():
    a, b = map(int, input().split())
    if (a % 3 ==0) | (b % 3 ==0):
        ans = 0
    else:
        anss = []
        s1 = (b // 3 + 1) * a
        s2 = (b - (b // 3 + 1)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3 + 2) * a
        s2 = (b - (b // 3 + 2)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3 + 1) * a
        s2 = (b - (b // 3 + 1)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3 + 2) * a
        s2 = (b - (b // 3 + 2)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))
        
        # b a
        t = a
        a = b
        b = t
        s1 = (b // 3 + 1) * a
        s2 = (b - (b // 3 + 1)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3 + 2) * a
        s2 = (b - (b // 3 + 2)) * (a // 2)
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3) * a
        s2 = (b - (b // 3)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3 + 1) * a
        s2 = (b - (b // 3 + 1)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        s1 = (b // 3 + 2) * a
        s2 = (b - (b // 3 + 2)) // 2 * a
        s3 = a * b - s1 - s2
        anss.append(max(s1, s2, s3) - min(s1, s2, s3))

        ans = min(anss)

    print(ans)
main()

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

using ll = long long;

signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

 	ll m,n;
 	cin >> m >> n;

 	ll res = (m*(m-1)/2) + (n*(n-1)/2);

 	cout << res << "\n";   
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int c = 0;

  for ( ; ; )
  {
    char  s[ 128 ];
    char  * sp,
          * ep;

    if ( fgets ( s, sizeof ( s ), stdin ) == NULL ) break ;

    for ( ep = s; *ep != '\n'; ++ep ) ;
    --ep;

    for ( sp = s; sp < ep; ++sp, --ep )
    {
      if ( *sp != *ep )
      {
        goto CONTT;
      }
    }
    ++c;

CONTT: ;
  }

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

  return ( 0 );
}

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

int main() {
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	if (ceil(c / b) <= ceil(a / d))puts("Yes");
	else puts("No");
}






Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_S (1000*100)
char S[MAX_S+1];
char T[MAX_S+1];

bool match(const char *instr, int inlen)
{
	if(inlen==0) {
		return true;
	}
	int len1=0;
	int len2=0;
	if(strncmp(&instr[0], "dream", strlen("dream"))==0) {
		len1 = strlen("dream");
		if(strncmp(&instr[len1], "er", strlen("er"))==0) {
			len2 = len1+2;
			if(match(&instr[len2], inlen-len2)) {
				return true;
			}
		}
		if(match(&instr[len1], inlen-len1)) {
			return true;
		}
		return false;
	}
	if(strncmp(&instr[0], "erase", strlen("erase"))==0) {
		len1 = strlen("erase");
		if(strncmp(&instr[len1], "r", strlen("r"))==0) {
			len2 = len1+1;
			if(match(&instr[len2], inlen-len2)) {
				return true;
			}
		}
		if(match(&instr[len1], inlen-len1)) {
			return true;
		}
	}
	return false;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> S;

	int len = strnlen(S, MAX_S);

	// int i=0;
	bool result = match(S, len);
	if(result) {
		cout << "YES"<<endl;
	}
	else {
		cout << "NO"<<endl;
	}

	return 0;
}



Measured memory_bytes: 640
#! -*- coding:utf-8 -*-
s = str(input())
s = list(s)
#print(s)
a = 'x'
b = 'x'

for i in range(len(s)):
    s.pop()
    if len(s) % 2 == 0:
        a = s[:len(s)//2]
        b = s[len(s)//2:]
        if a == b:
            print(len(s))
            break


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N ;
    vector<int> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    int max=0;
    vector<int> B(N);
    for(int i=0; i<N; i++)
    {
        if(max<A.at(i))
        {
            max=A.at(i);
        }
        B.at(i)=A.at(i);
    }
    sort(B.begin(),B.end());
    reverse(B.begin(),B.end());
    int submax=max;
    for(int i=0; i<N; i++)
    {
        if(!(B.at(i)==max))
        {
            submax=B.at(i);
            break;
        }
    }
        for(int i=0; i<N; i++)
    {
        if(!(B.at(i)==max))
        {
            submax=B.at(i);
            break;
        }
    }
    if(B.at(0)==B.at(1))
    {
        for(int i=0; i<N; i++)
        cout << max << endl;
    }
    else
    {
        for(int i=0; i<N; i++)
    {
        if(!(A.at(i)==max))
        {
            cout << max << endl;
        }
        else
        {
            cout << submax << endl;
        }
    }
    }
}


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

int bubbleSort(vector<int>& A, int N) {
  bool flag = true;
  int swaps = 0;
  while (flag) {
    flag = false;
    for (int j = N - 1; j > 0; j--) {
      if (A[j] < A[j - 1]) {
        int tmp = A[j];
        A[j] = A[j - 1];
        A[j - 1] = tmp;
        swaps++;
        flag = true;
      }
    }
  }
  return swaps;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int swaps = bubbleSort(A, N);
  cout << A.at(0);
  for (int i = 1; i < N; i++) cout << ' ' << A.at(i);
  cout << endl << swaps << endl;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <cassert>
#include <time.h>
#include <numeric>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)


#define trarr(a,n) forn(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) forn(i,0,n)forn(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 2e5+10;

void solve(int _t){
	int p;
	cin >> p;
	cout<<p+p*p+p*p*p<<endl;
	return;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}  

Measured memory_bytes: 3632
from statistics import median

N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

mn = median(A)
mx = median(B)

if N % 2 == 1:
    print(int(mx - mn + 1))        # mn, mn + 1, mn + 2, ..., mx
else:
    print(int((mx - mn) * 2 + 1))    # mn, mn + 0.5, mn + 1, ..., mx

Measured memory_bytes: 28976
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    int p[n+1], m[n+1][n+1];
    for(int i = 1; i <= n; i++) cin >> p[i-1] >> p[i];
    for(int i = 1; i <= n; i++) m[i][i] = 0;
    for(int i = 2; i <= n; i++) for(int j = 1; j <= n - i + 1; j++){
        int k = j + i - 1;
        m[j][k] = (1 << 21);
        for(int l = j; l <= k - 1; l++) m[j][k] = min(m[j][k], m[j][l] + m[l + 1][k] + p[j - 1] * p[l] * p[k]);
    }
    cout << m[1][n] << endl;
}


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

void Main() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) cout << B << endl;
  else if (6 <= A && A <= 12) cout << B / 2 << endl;
  else cout << 0 << endl;
}

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

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

// 構造体
struct work {
  int A;
  int B;
};

// 比較関数
bool cmp (const work &a, const work &b) {
  if (a.B < b.B) {
    return true;
  }
  if (a.B > b.B) {
    return false;
  }
  if (a.A < b.A) {
    return true;
  }
  if (a.A > b.A) {
    return false;
  }
  return false;
}

int main() {

  int N;
  cin >> N;

  // A と B の情報を構造体を入れた配列で管理
  vector<work> W;
  for (int i = 0; i < N; i++) {
    int A_, B_;
    cin >> A_ >> B_;
    work w_ = work {A_, B_};
    W.push_back(w_);
  }

  // 比較関数で並び替え
  sort(W.begin(), W.end(), cmp);

  string answer = "Yes";

  // current:処理した仕事の量
  int current = 0;
  // 空き時間
  int free = 0;

  for (int i = 0; i < N; i++) {

    // 処理した時間に A を加える
    current += W[i].A;
    
    // B より処理した時間が大きいと作業は終わらない
    if (W[i].B < current) {
      answer = "No";
      break;
    }
    
  }

  cout << answer << endl;

  return 0;
}

Measured memory_bytes: 2420
#include<iostream>  
#include<cstring>  
#include<cstdio>  
#include<cmath>  
#include<algorithm>  
  
using namespace std;  
  
bool s[15][10005]= {0};  
  
int n, m;  

void reverse(int row){
    for(int i=1; i<=m; i++){
        if(s[row][i]==0) s[row][i]=1;
        else s[row][i]=0;
    }
}

int dfs(int x)  
{  
    if(x==n+1)  
    {  
        int sum=0;  
        int term=0,term2;  
        for(int j=1;j<=m;j++)  
        {  
            for(int i=1;i<=n;i++)  
                if(s[i][j]==1)term++;  
            //sum += term > n-term ? term : n-term;  
            term2=n-term;
            term>term2?(sum+=term):(sum+=term2);
            term=0;  
        }  
        return sum;  
    }  
    int a=dfs(x+1);  
    reverse(x);
    //for(int i=1;i<=m;i++)  
      //  s[x][i]=!s[x][i];  
    int b=dfs(x+1);  
    return a>b?a:b;
}  
  
int main()  
{  
    //freopen("in.in","r",stdin);  
    while(scanf("%d%d",&n,&m)!=EOF)  
    {  
        if(n==0&&m==0)break;   
        for(int i=1; i<=n; i++)  
            for(int j=1; j<=m; j++)  
                cin>>s[i][j];  
        cout<<dfs(1)<<endl;  
    }  
    return 0;  
}  


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k,x;
    cin>>k>>x;
    rep(i,2*k-1){
        cout<<x-k+1+i<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    ll a[n+1];
    a[0] = 0;
    rep(i, n){
        ll tmp; cin >> tmp;
        a[i+1] = a[i] + tmp;
    }
    map<ll, ll> m;

    rep(i, n+1){
        m[a[i]]++;
    }

    ll ans = 0;
    for (auto mm : m){
        ans += mm.second * (mm.second-1)/2;
    }

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


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if((m-1)%(n-1)==0)
	{
		cout<<(m-1)/(n-1);
	}
	else
	{
		cout<<(m-1)/(n-1)+1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int n;
    cin >> n;
    int a[n + 1];
    rep(i, 0, n) cin >> a[i];
    a[n] = 0;

    int cnt = 1;
    int ans = 0;
    rep(i, 0, n) {
        if (a[i] == a[i + 1]) {
            cnt ++;
        } else {
            if (cnt >= 2) {
                ans += cnt / 2;
                cnt = 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int keisann(int a,int b) {
	while (true) {
		a=a%b;
		if (a != 0) {
			b = b%a;
			if (b == 0) { cout << a<<endl; return 0; }
		}
		else if (a == 0) {
			cout << b<<endl;
			return 0;
		}
	}
}

int main()
{
	int a, b;
	cin >> a >> b;
	if (b > a) {
		keisann(b, a);
	}
	else if (b == a) {
		cout << a << endl;
	}
	else {
		keisann(a, b);
	}
}

Measured memory_bytes: 3048
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

func main() {
	n := readInt()
	a := make([]int, n)
	a_c := make(map[int]int)
	for i := 0; i < n; i++ {
		in := readInt()
		a[i] = in
		a_c[in] = a_c[in] + 1
	}

	total_comb := 0
	for k := range a_c {
		total_comb = total_comb + comb(a_c[k], 2)
	}

	for i := 0; i < len(a); i++ {
		ans := total_comb - comb(a_c[a[i]], 2) + comb(a_c[a[i]]-1, 2)
		fmt.Println(ans)
	}
}

/*-------------------inputs-------------------*/

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func subL(list []int) []int {
	sl := make([]int, len(list)-1)
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		sl[i] = sub
	}
	return sl
}

func comb(n int, k int) int {
	return permutation(n, k) / factorial(k)
}

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n-1)
}


Measured memory_bytes: 14720
n = readline.chomp.to_i
n.times{
  v = readline.chomp.split.map{|c| c.to_i}

# (1..10).to_a.permutation{|v|
  # p v
  stack1 = [0]
  stack2 = [0]

  v.each{|c|
    if stack1[-1] < c
      stack1.push(c)
    elsif stack2[-1] < c
      stack2.push(c)
    else
      puts "NO"
      break
    end
    # if stack1[-1] > stack2[-1]
    #   if stack1[-1] < c
    #     stack1.push(c)
    #   elsif stack2[-1] < c
    #     stack2.push(c)
    #   else
    #     puts "NO"
    #     break
    #   end
    # else
    #   if stack2[-1] < c
    #     stack2.push(c)
    #   elsif stack1[-1] < c
    #     stack1.push(c)
    #   else
    #     puts "NO"
    #     break
    #   end
    # end
  }
  if stack1.size + stack2.size == 12
    puts "YES"
  end
  # p stack1
  # p stack2
}

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define INF 1e9
// const ll INF = 1LL << 60;

void warshallFloyd(vector<vector<int>>& g){
  int n = g.size();
  REP(k, n){
    REP(i, n){
      REP(j, n){
        if(g[i][k] == INF || g[k][j]==INF) continue;
        if(g[i][k] + g[k][j] < g[i][j]){
          g[i][j] = g[i][k] + g[k][j];
        }
      }
    }
  }
}

int main(){
   int H, W;
   cin >> H >> W;
   vector<vector<int>> A(H, vector<int>(W)), c(10, vector<int>(10));
   REP(i, 10){
     REP(j, 10){
       cin >> c[i][j];
     }
   }
   REP(i, H){
     REP(j, W){
       cin >> A[i][j];
     }
   }
   warshallFloyd(c);
   ll ans = 0;
   REP(i, H){
     REP(j, W){
       if(A[i][j] == -1) continue;
       ans += c[A[i][j]][1];
     }
   }
   cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val uf = UnionFind(n)

    repeat(m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt()-1 }
        uf.merge(a, b)
    }

    println(uf.maxSize())
}

private data class UnionFind(val initSize: Int) {
    private val parents = IntArray(this.initSize) { it }
    private val sizes = LongArray(this.initSize) { 1L }

    private var maxSize = 1L

    fun root(idx: Int): Int {
        if (idx == parents[idx]) return idx

        val rootP = root(parents[idx])
        parents[idx] = rootP
        return rootP
    }

    // NOTE: merge to the larger group
    fun merge(p1: Int, p2: Int) {
        if (this.isSame(p1, p2)) return

        val rootP1 = root(p1)
        val rootP2 = root(p2)

        if (this.sizes[rootP1] >= this.sizes[rootP2]) {
            this.sizes[rootP1] += this.sizes[rootP2]
            this.parents[rootP2] = this.parents[rootP1]
            this.maxSize = Math.max(this.maxSize, this.sizes[rootP1])

        } else {
            this.sizes[rootP2] += this.sizes[rootP1]
            this.parents[rootP1] = this.parents[rootP2]
            this.maxSize = Math.max(this.maxSize, this.sizes[rootP2])
        }
    }

    fun isSame(p1: Int, p2: Int): Boolean {
        return this.root(p1) == this.root(p2)
    }

    fun size(idx: Int): Long {
        return this.sizes[this.root(idx)]
    }

    fun maxSize(): Long {
        return this.maxSize
    }
}

Measured memory_bytes: 67928
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
H = LI()

a = INF
for i in reversed(range(n)):
    if H[i] > a + 1:
        print("No")
        exit()
    elif H[i] == a+1:
        H[i] -= 1
    a = min(a, H[i])

print("Yes")

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

#define ll long long int
#define LD long double

const int N = 200010;

int inf = 1e9;
int mod = 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += mod;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % mod);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= mod;
  if (a < 0) a += mod;
  int b = mod, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += mod;
  return u;
}


signed main()
{
    //freopen("IN", "r", stdin);
    //freopen("OUT", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n; cin >> n;
    int len = 0;
    string s; cin >> s;
    for(int i = 0; i < n; i++) {
        if(s[i] == '1')
            len++;
    }

    int dp[N];
    memset(dp, 0, sizeof(dp));

    for(int i = 1; i < N; i++) {
        int x = __builtin_popcount(i);
        dp[i] = dp[i % x] + 1;
    }

    int val[3];
    memset(val, 0, sizeof(val));

    for(int i = 0; i < 3; i++) {
        int x = len + i - 1;
        mod = x;
        if(x == 0) continue;
        for(int j = 0; j < n; j++) {
            val[i] = mul(val[i], 2);
            add(val[i], (s[j] - '0'));
        }
    }

    for(int i = 0; i < n; i++) {
        int x = len;
        int ans = 0;
        int p = n - i - 1;
        if(s[i] == '0') {
            x++;
            ans = val[2];
            mod = x;
            add(ans, power(2, p));
            cout << dp[ans] + 1 << "\n";
        }
        else {
            x--;
            if(x == 0) cout << "0\n";
            else {
                mod = x;
                ans = val[0];
                sub(ans, power(2, p));
                cout << 1 + dp[ans] << "\n";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4540
#include<stdio.h>
int main(void) {
	int N, D, X,ans=0;
	int a;

	scanf("%d", &N);
	int A[100];
	scanf("%d %d", &D, &X);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j*A[i] + 1 <= D; j++) {
			ans++;
		}
	}
	printf("%d", ans + X);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define INF 1<<29
#define MAX 11
using namespace std;

int a[MAX],se[MAX];

void solve(){
 int n,k;
 for(;;){
  cin>>n;
  cin>>k;
  if(!n&&!k) break;
  set<int> S;
  FOR(i,n) cin>>a[i];
  FOR(i,1<<n){
   int p=0;
   FOR(j,n) if((1<<j)&i) se[p++]=j;
   if(p!=k) continue;
   vector<int> ord;
   FOR(j,k) ord.pb(j);
   do{
    int t=0;
    FOR(j,k){
     int x=a[se[ord[j]]];
     t*=(x>=10)?100:10;
     t+=x;
    }
    S.insert(t);
   }while(next_permutation(ord.begin(),ord.end()));
  }
  cout<<S.size()<<endl;
 }
}

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

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int T;

ll extgcd(ll a,ll b,ll& x,ll& y){
  ll d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}

ll llceil(ll a,ll b){ // a/b
  assert(b!=0);
  if(a<0){
    a=-a;
    return -(a/b);
  }else{
    return (a+b-1)/b;
  }
}

int main(){
  cin>>T;
  while(T--){
    ll a,b;
    cin>>a>>b;
    ll g=__gcd(a,b);
    if(a+b<g*g){ // 4
      printf("4\n");
      printf("%lld %lld\n", 0, 0);
      vector<P> ps;
      ps.push_back(P(a-1,b)); ps.push_back(P(a,b-1)); ps.push_back(P(a/g,b/g));
      sort(all(ps),[](const P& aa,const P& bb){ return aa.se*bb.fi > bb.se*aa.fi; });
      rep(i,ps.size())printf("%lld %lld\n", ps[i].fi,ps[i].se);
    }else{ // 3
      ll c,d;
      ll a2=a/g,b2=b/g;
      extgcd(a2,-b2,c,d);
      if(a2*c-b2*d==-1){
        c=-c; d=-d;
      }
      //assert(a2*c-b2*d==1);
      ll k=max(llceil(-d,a2),llceil(-c,b2));
      printf("3\n");
      printf("%lld %lld\n", 0,0);
      printf("%lld %lld\n", a,b);
      printf("%lld %lld\n", a2*k+d,b2*k+c);
      //assert(llabs(a*(b2*k+c)-b*(a2*k+d))<=25000);
      //assert(!(a2*k+d==0&&b2*k+c==0));
      //assert(a2*k+d>=0); assert(b2*k+c>=0);
      //assert(g*(a2*k+d)<=a); assert(g*(b2*k+c)<=b);
    }
  }
  return 0;
}



Measured memory_bytes: 3236
#include <stdio.h>
#include <math.h>
#define d hypot(xa-xb,ya-yb)

/*
SÔ£ðdÆµÄA

 ra-rb > d ¨ BÍAÉàï³êé
 rb-ra > d ¨ AÍBÉàï³êé
|ra-rb|< d ¨ AÆBÍðíé
 ra+rb < d ¨ OÉ é
*/

int main(void){
	double xa, ya, ra, xb, yb, rb; int n;
	scanf("%d",&n);
	
	for(; n>0; n--){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		if(ra-rb>d) printf("2\n");
		else if(rb-ra>d) printf("-2\n");
		else if(d>ra+rb) printf("0\n");
		else printf("1\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

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

    vector<int> S(N+1, 0);
    for(int i=1; i<=K; i++){
        int a;
        cin >> a;

        for(int j=1; j<=a; j++){
           //cin >> A[i][j];
           int b=0;
           cin >> b;
           S[b] = S[b] + 1;
        }
    }

    int cnt=0;
    for(int i=1; i<=N; i++){
        if(S[i] == 0){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3196
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def Z_algorithm(s):
        n = len(s)
        z = [0]*n
        z[0] = n
        c = 1
        for i in range(1,n):
            if i+z[i-c] < c+z[c]:
                z[i] = z[i-c]
            else:
                j = max(0,c+z[c]-i)
                while i+j < n and s[j] == s[i+j]:
                    j += 1
                z[i] = j
                c = i
        return z
    n = I()
    a = LI()
    b = LI()
    c = [a[i]^a[(i+1)%n] for i in range(n)]
    d = [b[i]^b[(i+1)%n] for i in range(n)]
    z = Z_algorithm(d+c*2)[n:]
    for k in range(n):
        if z[k] >= n:
            print(k,a[k]^b[0])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 119636
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) (v).begin(), (v).end()

int main() {
	int A,B,m; cin >> A >> B >> m;
	vint a(A); vint b(B);
	int amin=100001;
	int bmin=amin;
	rep(i,A) {
		cin >> a[i];
		amin=min(amin,a[i]);
	}
	rep(i,B) {
		cin >> b[i];
		bmin=min(bmin,b[i]);
	}
	vint price(m);
	rep(i,m) {
		int x,y,c; cin >> x >> y >> c;
		price[i]=a[x-1]+b[y-1]-c;
	}
	sort(be(price));
	cout << min(price[0],amin+bmin) << endl;
}

Measured memory_bytes: 4576
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int t;
  bool field[5][5];
  int area[5][5];
  cin >> t;
  while(t--){
    for(int i = 0 ; i < 5 ; i++){
      for(int j = 0 ; j < 5 ; j++){
	cin >> field[i][j];
      }
    }

    for(int i = 0 ; i < 5 ; i++){
      int x = 1;
      for(int j = 4 ; j >= 0 ; j--){
	if(field[i][j] == 1){
	  area[i][j] = x;
	  x++;
	}
	else{
	  area[i][j] = 0;
	  x = 1;
	}
      }
    }

    int ans = 0;

    for(int i = 0 ; i < 5 ; i++){
      for(int j = 0 ; j < 5 ; j++){
	int h = 1;
	int tmp = area[i][j];
	ans = max(ans, h*tmp);

	while(i+h < 5 && area[i+h][j] != 0){
	  tmp = min(tmp, area[i+h][j]);
	  h++;
	  ans = max(ans, h*tmp);
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n = gets.to_i
a = gets.to_i.to_f
b = gets.to_i.to_f
c = gets.to_i.to_f
d = gets.to_i.to_f
e = gets.to_i.to_f
max_num = [(n / a).ceil, (n / b).ceil, (n / c).ceil, (n / d).ceil, (n / e).ceil].max
ans = 4 + max_num

puts ans.to_s

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

int main(){
	int n, a[101];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int ans = 0;
	for(int i = 1; i < n; i++){
		if(a[i] == a[i-1]){
			a[i] = a[i+1]+1;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

nice_box = [0]*n

for i in range(n-1,-1,-1):
  baisu = 2
  ball_memo = 0
  index = i+1
  while baisu * index - 1 < n:
    ball_memo += nice_box[baisu * index - 1]
    baisu += 1

  if ball_memo % 2 != a[i]:
    nice_box[i] += 1

ans = []

for i in range(n):
  if nice_box[i] == 1:
    ans.append(i+1)

print(len(ans))
if len(ans)>0:
  print(*ans)
  

Measured memory_bytes: 70108
# p^2*q^2*r^2 ->(p,q,r)=(3,5,7),(3,5,11),(3,5,13)
# p^3*q^2->(3,5),(3,7)
# 105,135,165,189,195
N=int(input())
if N<105:
    ans=0
elif N<135:
    ans=1
elif N<165:
    ans=2
elif N<189:
    ans=3
elif N<195:
    ans=4
else:
    ans=5
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
#define mod 1000000007
#define inf (1ll<<60)
using namespace std;
vector<ll> v1[100005];
vector<ll> v2[100005];
bool visited[100005]={false};
ll dp[100005];
ll dfs(ll x)
{
   visited[x]=true;
   for(ll i=0;i<v1[x].size();i++)
   {
       if(!visited[v1[x][i]])
       {
           dp[x]=max(dp[x],1+dfs(v1[x][i]));
       }
       else
        dp[x]=max(dp[x],1+dp[v1[x][i]]);
   }
   return dp[x];
}
int main()
{
    iof;
    ll n,m,mx=-1; cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll x,y; cin>>x>>y;
        v1[x].push_back(y);
        v2[y].push_back(x);
    }
    for(ll i=1;i<=n;i++)
    {
        if(v2[i].size()==0)
        {
            //dp[i]=0;
            mx=max(dfs(i),mx);
        }
    }
    cout<<mx<<endl;
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h + 2, vector<char>(w + 2,'.'));
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> a.at(i).at(j);
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <=w; j++) {
			if (a.at(i).at(j) == '#') continue;
			int cnt = 0;
			if (a.at(i - 1).at(j - 1) == '#') cnt++;
			if (a.at(i).at(j - 1) == '#') cnt++;
			if (a.at(i + 1).at(j - 1) == '#') cnt++;
			if (a.at(i - 1).at(j) == '#') cnt++;
			if (a.at(i + 1).at(j) == '#') cnt++;
			if (a.at(i - 1).at(j+1) == '#') cnt++;
			if (a.at(i).at(j + 1) == '#') cnt++;
			if (a.at(i + 1).at(j + 1) == '#') cnt++;
			a.at(i).at(j) = (char)('0' + cnt);
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cout << a.at(i).at(j) ;
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    int h;
    for(int i = 0; i < n; i++) {
        cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#coding:utf-8
import numpy as np
N = int(input())
ls_sp = []
for n in range(N):
    s,p = input().split()
    sp = s + str(100-int(p)).zfill(3)
    ls_sp.append(sp)
ans = np.argsort(ls_sp)
for a in ans:
    print (a+1)



Measured memory_bytes: 21516
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug prllf
#else
	#define debug(...)
#endif
const ll maxn = 1005;
ll b[maxn];
vector<ll> v;
int main()
{
	ll n,k;
	cin>>n>>k;
	for(ll i = 0;i < n; ++i)
	{
		cin>>b[i];
	}
	for(ll i = 0;i < n; ++i)
	{
		ll now = 0;
		for(ll k = i;k < n; ++k)
		{
			now += b[k];
			v.push_back(now);
		}
	}
	ll ans = 0;
	for(ll i = 40;i >= 0; --i)
	{
		ll now = ans | (1ll << i);
		ll ret = 0;
		for(ll j : v)
		{
			if((j & now) == now)
			{
				ret++;
			}
		}
		if(ret >= k)
		{
			ans |= (1ll << i);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll A,B,K;
  cin >> A >> B >> K;

  rep(i,0,K){
    if(i % 2 == 0){
      if(A % 2 != 0) A--;
      A /= 2;
      B += A;
    }
    else{
      if(B % 2 != 0) B--;
      B /= 2;
      A += B;
    }
  }

  cout << A _ B << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
 
 
void change(char *str){
  int len=strlen(str);
  int i;
  for(i=0;i<len;i++){
    if('a'<=str[i]&&str[i]<='z'){
      str[i]-=32;
    }
  }
}
 
int main(){
  char t[10000];
  char key[10000];
  char eofstr[]={"END_OF_TEXT"};
  int ans=0;
 
  scanf("%s",key);
  change(key);
 
  while(1){
    scanf("%s",t);
    if(strcmp(t,eofstr)==0){
      break;
    }
    change(t);
    if(strcmp(t,key)==0){
      ans++;
    }
  }
 
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2076
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 1;
	vector<int> A, con;
	
	cin>>N;
	
	A.resize(N);
	con.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		con[A[i]]++;
	}
	
	for(int i = (N+1)%2; i < N; i += 2){
		
		if(i){
			if(con[i] != 2){
				cout<<0<<endl;
				return 0;
			}
			ans *= 2;
			ans %= MOD;
		} else {
			if(con[i] != 1){
				cout<<0<<endl;
				return 0;
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    for(int i=b-a+1;i<=b+a-1;i++)cout<<i<<" ";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n, k, h[100000];
  int count = 0;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> h[i];
    if(h[i] >= k){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b!=c) cout<<"Yes"<<endl;
  else if(b==c && c!=a) cout<<"Yes"<<endl;
  else if(c==a && a!=b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
const int N = 200;
int A[N];
int main(){
    int n;scanf("%d", &n);
    for(int i=0 ;i<n;i++){
        scanf("%d", &A[i]);
    }
    int sum = 0;
    for(int i =0;i<n;i++ ){
        sum += A[i];
    }
    int ans = 0;
    int lost = abs(A[0]*n - sum);
    for(int i =0;i<n;i++){
        int tmp = abs(A[i]*n - sum);
        if( tmp < lost ){
            lost = tmp;
            ans = i;
        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 2e5+5;

void solve(){
	string s;
	cin>>s;
	int ok=0;
	for(int i=0;i<3;++i){
		if(s[i]=='R')ok=1;
	}
	if(!ok){
		cout<<0;
	}
	else{
		int cnt=1;
		for(int i=1;i<3;i++){
			if(s[i]==s[i-1] && s[i]=='R')cnt++;
		}
		cout<<cnt;
	}
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while (T--)solve();
}

Measured memory_bytes: 3636
K = int(input())
D = int(input())
mod = 10**9 + 7

dp = [[[0] * D for _ in range(2)] for _ in range(len(str(K))+1)]
dp[0][0][0] = 1

for i in range(len(str(K))):
    N = int(str(K)[i])
    for j in range(2):
        for k in range(D):
            for n in range((9 if j == 1 else N) + 1):
                dp[i+1][j or n < N][(k+n%D)%D] += dp[i][j][k]%mod

print((dp[-1][0][0]+dp[-1][1][0]-1)%mod)

Measured memory_bytes: 62816
var GET = (function(){
  function f(s){return new g(s);}
  function g(s){this._s=s.trim().split("\n");this._y=0;}
  g.prototype.a = function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y]=s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  }
  g.prototype.l = function(f){
    var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);
  }
  g.prototype.m = function(n,f){
    var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));
    return f?r:r.map(a=>a.map(a=>+a));
  }
  g.prototype.r = function(n,f){
    var r = this._s.slice(this._y,this._y+=n);
    return f?r:r.map(a=>+a);
  }
  return f;
})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var x = Array(n+1).fill(1);
  for(var i = 2; i <= n; i++){
    var t = i, j = 2;
    while(t > 1){
      if(t % j === 0){x[j]++; t /= j;}
      else j++;
    }
  }
  var a = Array(26).fill(0).map(a=>{return {}}), ans = 0;
  for(i = 2; i <= n; i++){
    if(x[i] >= 75)ans++;
    if(x[i] >= 25)a[25][i] = 1;
    if(x[i] >= 15)a[15][i] = 1;
    if(x[i] >= 5)a[5][i] = 1;
    if(x[i] >= 3)a[3][i] = 1;
  }
  for(i in a[3]){
    var t = Object.keys(a[5]).length;
    if(a[5][i])t--;
    ans += t * (t-1) / 2;
    var t = Object.keys(a[25]).length;
    if(a[25][i])t--;
    ans += t ;
  }
  for(i in a[5]){
    var t = Object.keys(a[15]).length;
    if(a[15][i])t--;
    ans += t;
  }
  return ans;
}

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

using namespace std;

vector<double> v;
double dp[3002][3002];
bool visitado[3002][3002];


double coin(int posicao, int n_head)
{

	double soma = 0.00;


	if(n_head > v.size() - n_head)
	{
		return 1.00;
	}

	if(posicao >= v.size())
	{

		return 0.00;
	}

	if(visitado[posicao][n_head])
		return dp[posicao][n_head];

	visitado[posicao][n_head] = true;


	soma += v[posicao] * coin(posicao + 1, n_head + 1);
	soma += (1.00 - v[posicao]) * coin(posicao + 1, n_head);


	return dp[posicao][n_head] = soma;



}





int main()
{

	int n;
	double real;

	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		cin >> real;
		v.push_back(real);
	}

	real = coin(0, 0);


	cout << fixed << setprecision(10) << real << endl;




	return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<=n;i++)
typedef long long ll;
using namespace std;
int main()
{
   int R, G ,B, N;
   cin >> R >> G >> B >> N;
   ll ans=0;
   rep2(r,0,N/R)
   {
      rep2(g,0,N/G)
      {
         int res=N-(r*R)-(g*G);
         if(res>=0&&res%B==0)
         {
            ++ans;
         }
      }
   }

   cout << ans << endl;
}

Measured memory_bytes: 256
sub f{my($i,$t)=$_;
	$m[$i]||=$t*!!map{$t+=$-=&f+1-$t;$-?$z[$i]=$_:0}@$_
}
map{/ /,push@{$'+0},$`for<>;f,print$z[$_]+0,$/}1..<>


Measured memory_bytes: 155264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  int prv = 0;
  ll ans = 0;
  while (n--) {
    int cur; cin >> cur;
    if (cur < prv) ans += prv - cur;
    else prv = cur;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v;
	for(int i=1;i<=n;++i){
		int t;
		cin>>t;
		v.push_back(t);
	}
	sort(v.begin(),v.end());
	int sum[2]{0};
	for(int i=0;!v.empty();i=!i){
		sum[i]+=v.back();
		v.pop_back();
	}
	cout<<sum[0]-sum[1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 301;
int cnt[4];
bool memo[maxn][maxn][maxn];
double f[maxn][maxn][maxn];
int n;
double calc(int a, int b, int c)
{
    if (min({a,b,c}) < 0) return 0;
    if (a+b+c==0) return 0;
    if (memo[a][b][c]) return f[a][b][c];
    memo[a][b][c] = 1;
    f[a][b][c] = 1.0 * a / n * calc(a - 1, b, c) + 1.0 * b / n * calc(a+1, b - 1, c) + 1.0 * c / n * calc(a, b+1, c - 1) + 1;
    f[a][b][c]/=1.0*(a+b+c)/n;
    return f[a][b][c];
}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".txt","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i<=n; ++i) {
        int x;
        cin >> x;
        ++cnt[x];
    }
    cout.precision(9);
    cout << fixed << calc(cnt[1], cnt[2], cnt[3]);
    return 0;
}

Measured memory_bytes: 239872