akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
 
int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	int h, n;
	cin >> h >> n;
	int cur = 0;
	int what = 0;
	for(int i = 1; i <= n; i++) cin >> what, cur += what;
	if(cur >= h) cout << "Yes";
	else cout << "No";
}                                

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void clearCharArray(char* c,int length){
    for(int i = 0; i<length;i++){
        c[i]=0;
    }
}
int main(){
    string s;
    cin >> s;
    int length = s.length();
    int result = 0;
    const char* p_c = s.c_str();
    int mod = 2019;
    vector <int> givenNumbers(length);
    vector <int> totalNumberModRemain(length);
    //cout << length;
    //cout << "A"<<endl;
    for(int i = 0; i<length;i++){
        int tmp =  (int)(p_c[length-i-1]-'0');
        //cout << "i:" <<i<<" ";
        //cout << tmp<<endl;
        givenNumbers[i]=tmp;
    }
    //cout << "B"<<endl;
    #if 0
    for(int i = (givenNumbers.size()-1);i>=0;i--){
        cout << givenNumbers[i];
    }
    cout << endl;
    #endif
    long order = 1;
    for(int i = 0; i < length; i++){
        int tmp = 0;
        tmp += (givenNumbers[i]%mod);
        if(i!=0){
            order*=10;
            order%=mod;
            tmp*=order;
            tmp%=mod;
            tmp+=totalNumberModRemain[i-1];
            tmp%=mod;
        }
        totalNumberModRemain[i]=(tmp);
    }
    //cout << "C"<<endl;
    vector <int> sum(2019);
    for(int i = 0; i < totalNumberModRemain.size(); i++){
        sum[totalNumberModRemain[i]]++;
    }
    //余が0の場合は、1プラス(1桁目から数えるため。)
    sum[0]++;
    #if 0
    for(int i = 0; i < sum.size(); i++){
        if(sum[i]!=0){
            cout <<"i:"<<i<<" "<<sum[i]<<endl;
        }
    }
    #endif
    //nCrで二つの選び方を数え上げる。
    for(int i = 0; i < sum.size(); i++){
        if(sum[i]==2){
            result++;
        }else if(sum[i]>2){
            result+=(sum[i]*(sum[i]-1))/2;
        }else{
            //do nothing
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  if(s[0] == '1')
    cnt++;
  if(s[1] == '1')
    cnt++;
  if(s[2] == '1')
    cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 256
n, P = map(int, input().split())
S = input()
ans = 0
#----------------------------------------------
# 1.
# int(S[a:b]) * 10 ** (n - b) == (int(S[a: n]) - int(S[b: n])) で表される
# 例
# S = 1234
# a = 1, b = 3 のとき
# 23 = (234 - 4) // 10 ** (4 - 3)
#    =  230 // 10
#    =  23
#
# 2.
# Pは素数のため　P = 2, 5　のとき以外は　１０の約数でない
# A * (10 ** x) が Pで割れるとき　A は P の倍数　(x は任意定数)
#
# 3.
# 1. の式を mod P で考える
# int(S[a: b]) * 10 ** (n - b) == (int(S[a: n]) - int(S[b: n]))
# ⇒　(S[a: b] * 10 ** (n - b)) % P == (S[a: n] - S[b: n]) % P  (mod P)
# ⇒　(S[a: b] % P) * (10 ** (n - b) % P) == (S[a: n] % P) - (S[b: n] % P)  (mod P)
# 2.より P = 2, 5以外のときは 10 ** (n - b) % P != 0となるため
# (S[a: n] % P) - (S[b: n] % P)　= 0　すなわち　(S[a: n] % P) == (S[b: n] % P)のとき
# S[a:b] % P　= 0である
#
# これより
# S[i: n] % P (0 <= i < n) を求めれば
# 以下のコードのようにS[i: j] % P を求めることができる (0 <= i < n, i <= j < n)
#----------------------------------------------
#まずS[i: n] % P (0 <= i < n) を求める (remain に格納する)
remain = [0] * P
remain[0] += 1
d = 1
left = 0
for i in range(n):
    # print(left)
    left = (left + int(S[n - i - 1]) * d) % P
    remain[left] += 1
    d = d * 10 % P
# print(remain)
for r in remain:
    ans += r * (r - 1) // 2
#----------------------------------------------
# 4.P = 2, 5　のときについて考える
#     1. P = 2 のとき
#         ある数の下１桁が2の倍数のとき、その数は2の倍数であるため
#         S[i] % 2 == 0 のとき
#         S[h:i] % 2 == 0 (0 <= h <= i)
#         よって以下のようなコードで答えを求めることができる
#----------------------------------------------
if P == 2:
    ans = 0
    for i in range(n):
        if int(S[i]) % 2 == 0:
            ans += i + 1
    print(ans)
#----------------------------------------------
    # 2. P = 5 のときもP = 2 のときと同様に考えれば良いため
#----------------------------------------------
if P == 5:
    ans = 0
    for i in range(n):
      if int(S[i]) % 5 == 0:
          ans += i + 1
    print(ans)
if P != 2 and P != 5:
    print(ans)


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

 

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var vs = Int32.Parse(Console.ReadLine());
            var result = max(vs);
            Console.WriteLine(result);
            Console.ReadKey();
        }

        public static double max(double vs){
            double vs2 = vs/3;
            double vs3 = vs2*vs2*vs2;
            return vs3;
        }
    }
}

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

#define INF 1000000000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {

    int N,maxtmp=0,cnt=0;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; i++) { 
      cin >> A[i];
      if(maxtmp<=A[i])cnt++;
      if(maxtmp<A[i])maxtmp=A[i]; }
    
  
    cout<<cnt<<endl;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

    ll n;
    cin >> n;
    ll ans = 1e18;
    for(ll i=1;i*i<= n; i++){
        if(n%i != 0) continue;
        ll j = n/i;
        ans = min(ans,i+j-2);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
ct = [0 for i in range(N+1)]

for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        ct[a] += 1

ans = 0
for i in range(1, N+1):
    if ct[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9204
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    char a,b;
    cin >> a >> b;
    if(a==b) cout << 'H' << endl;
    else cout << 'D' << endl;
    return 0;
}

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


int main(){
  int A,B,C,D;

  cin >> A >> B >> C >> D;

  while(1){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node {
	struct node *parent;
	struct node *child[2];
	int key;
};

void Insert(struct node **root, struct node *p){
	struct node *y = NULL;
	struct node *x = *root;
	while(x!=NULL){
		y = x;
		if(p->key<x->key){
			x = x->child[0];
		}else{
			x = x->child[1];
		}
	}
	p->parent = y;
	if(y==NULL){
		*root = p;
	}else if(p->key<y->key){
		y->child[0] = p;
	}else{
		y->child[1] = p;
	}

}
/*
void calcDepth(int num){
	int i;
	for(i=0;i<2;i++){
		if(tree[num].child[i] == -1){
			continue;
		}
		tree[tree[num].child[i]].depth = tree[num].depth + 1;
		calcDepth(tree[num].child[i]);
	}
	return;
}
*/

/*
int calcHeight(int num){
	int i;
	int temp;
	int h = -1;
	if(num==-1){
		return -1;
	}
	for(i=0;i<2;i++){
		temp = calcHeight(tree[num].child[i]);
		h = (h>temp?h:temp);
	}
	tree[num].height = h + 1;
	return tree[num].height;
}
*/

void Preorder(struct node *p){
	if( p == NULL ){ return; }
	printf(" %d",p->key);
	Preorder(p->child[0]);
	Preorder(p->child[1]);
	return;
}

void Inorder(struct node *p){
	if( p == NULL ){ return; }
	if(p->child[0]==NULL&&p->child[1]==NULL){
		printf(" %d",p->key);
		return;
	}else if(p->child[0]==NULL&&p->child[1]!=NULL){
		printf(" %d",p->key);
		Inorder(p->child[1]);
	}else if(p->child[0]!=NULL&&p->child[1]==NULL){
		Inorder(p->child[0]);
		printf(" %d", p->key);
	}else{
		Inorder(p->child[0]);
		printf(" %d",p->key);
		Inorder(p->child[1]);
	}
	return;
}

void Postorder(struct node *p){
	if(p->child[0]==NULL&&p->child[1]==NULL){
		printf(" %d",p->key);
		return;
	}else if(p->child[0]==NULL&&p->child[1]!=NULL){
		Postorder(p->child[1]);
	}else if(p->child[0]!=NULL&&p->child[1]==NULL){
		Postorder(p->child[0]);
	}else{
		Postorder(p->child[0]);
		Postorder(p->child[1]);
		printf(" %d",p->key);
	}
}

int main(){
	int n;
	struct node *root = NULL;
	struct node *temp;
	int i,j;
	char order[32];
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%s",order);
		if(strcmp(order,"insert")==0){
			temp = (struct node *)malloc(sizeof(struct node));
			scanf("%d",&temp->key);
			temp->parent = NULL;
			temp->child[0] = NULL;
			temp->child[1] = NULL;
			Insert(&root,temp);
		}else if(strcmp(order,"print")==0){
			Inorder(root);
			printf("\n");
			Preorder(root);	
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 24040
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,x;
  cin >> n >> x;
  int a[n];
  for(int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  int cnt = 0;
  while(x > 0 && cnt < n) {
    int tmp = x - a[cnt];
    x -= a[cnt];
    if(cnt + 1 == n && x == 0) ++cnt;
    else if(cnt + 1 < n && x >= 0) ++cnt;
  }

  cout << cnt << endl;
  return 0;
}

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

using namespace std;

#define ll long long

ll n;

int main(){
	cin >> n;
	ll ans = 0;
	ans += (n/500)*1000;
	n %= 500;
	ans += (n/5)*5;
	cout << ans;
}

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

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

const int N = 1e5 + 5;
int dp[N];
int n, m;
string s;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, 255, sizeof dp);

  cin >> n >> m;
  cin >> s;

  int r = n - 1;
  int cur = n;
  dp[n] = 0;
  while (cur > 0) {
    if (dp[cur] == -1) {
      --cur;
      continue;
    }
    for (int i = max(0, cur - m); i <= min(cur - 1, r); ++i) {
      if (s[i] == '0') {
        dp[i] = dp[cur] + 1;
      }
    }
    r = min(r, cur - m - 1);
    --cur;
  }
  int s = dp[0];
  if (s == -1)
    cout << -1 << endl;
  else {
    s--;
    int start = 0;
    for (int i = 1; i <= n; ++i) {
      if (dp[i] == s) {
        s--;
        cout << i - start << endl;
        start = i;
      }
    }
  }
  
  return 0;
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n, m, k;  cin >> n >> m >> k;
  vector<ll> a(n), b(m);  cin >> a >> b;
  vector<ll> pa(n), pb(m);
  pa[0] = a[0];
  for (int i = 1; i < n; ++i){
    pa[i] = pa[i-1] + a[i];
  }
  pb[0]=b[0];
  for (int i = 1; i < m; ++i){
    pb[i] = pb[i-1] + b[i];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i){
    if(pa[i]>k) break;
    int now = upper_bound(pb.begin(), pb.end(), k-pa[i]) - pb.begin();
    ans = max(ans, i+1+now);
  }
  for (int i = 0; i < m; ++i){
    if(pb[i]>k) break;
    int now = upper_bound(pa.begin(), pa.end(), k-pb[i]) - pa.begin();
    ans = max(ans, i+1+now);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 9540
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    if r==1:return n
    elif r==0:return 1
    else:
        num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
        den=reduce(lambda x,y:x*y%mod,range(1,r+1))
        return num*pow(den,mod-2,mod)%mod
def main():
    x,y=map(int,input().split())
    mod=10**9+7
    n=2*x-y
    m=2*y-x
    if n%3==0 and m%3==0 and n>=0 and m>=0:
        print(mod_comb4(n//3+m//3,n//3,mod))
    else:
        print(0)


if __name__=='__main__':
    main()

Measured memory_bytes: 3572
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
for i in range(n - 1):
    pair1 = a[i] // 2
    a[i] -= pair1 * 2
    pair2 = min(a[i], a[i+1])
    ans += pair1 + pair2
    a[i+1] -= pair2

ans += a[-1] // 2
print(ans)


Measured memory_bytes: 7072
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    string a, b, c;
    cin >> a >> b >> c;

    cout << ((a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
cnt = s.count("R") * s.count("G") * s.count("B")
for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        k = j - i + j
        if k > n-1:
            break
        if s[i] == s[k] or s[j] == s[k]:
                continue
        cnt -= 1
print(cnt)


Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

vi conv(string s) {
  int c = 0;
  vi res(1);
  rep(i,sz(s)) {
    int x = s[i]-'0';
    if (x == c) {
      res.back()++;
    } else {
      res.pb(1);
      c ^= 1;
    }
  }
  return res;
}

int n;
ll f(vi& a, vi& b, int o) {
  o *= 2;
  ll res = 0;
  int d = 0;
  srep(ai,-n-10,n*2+20) {
    int bi = ai+o;
    if (0 <= ai && ai < sz(a)) d -= a[ai];
    if (0 <= bi && bi < sz(b)) d += b[bi];
    res += abs(d);
  }
  return res;
}

int main() {
  scanf("%d",&n);
  string s, t;
  cin>>s>>t;
  vi a = conv(s);
  vi b = conv(t);
  
  n = max(sz(a),sz(b));
  // while (sz(a) < n) a.pb(0);
  // while (sz(b) < n) b.pb(0);

  int m = (n+5)/2;
  int l = -m, r = m;

  while (l+3<r) {
    int c1 = (l*2+r)/3;
    int c2 = (l+r*2)/3;
    ll d1 = f(a,b,c1);
    ll d2 = f(a,b,c2);
    if (d1 > d2) l = c1; else r = c2;
  }

  ll ans = LINF;
  srep(i,l-2,r+2) mins(ans, f(a,b,i));
  cout<<ans<<endl;
  return 0;
}






















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

int main(){
    int N=0,M=0,ni=1;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        ni *= 2;
    }
    cout << ni*(M*1900+(N-M)*100) << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 998244353
#define INF 1000000000000000LL

using namespace std;

ll facs[200001];

// x^n in mod
ll modpow(ll x, ll n, ll mod){
  if(n==0) return 1;

  if(n%2==0){
    return modpow(x*x%mod, n/2, mod) % mod;
  }else{
    return x * modpow(x, (n-1), mod) % mod;
  }
}

// n! in mod
ll fac(ll n){
  return facs[n];
}

// nCr in mod
ll comb(ll n, ll r){
  if(n<0 || n<r || r<0)return 0;
  ll fn = fac(n);
  ll fr = fac(r);
  ll fn_r = fac(n-r);
  
  ll d = (modpow(fr, MOD-2, MOD) * modpow(fn_r, MOD-2, MOD)) % MOD;
  ll u = fn%MOD;
  
  ll result = u * d % MOD;
 
  return result;
}

int main(){
  ll n, m, k; cin>>n>>m>>k;
  facs[0]=1;
  rep(i, 200001)facs[i+1] = (facs[i]*(i+1))%MOD;

  ll result = 0;
  rep(i, k+1){
    ll t = m*modpow(m-1, (ll)(n-1-i), MOD)%MOD;
    t = t*comb(n-1, (ll)i)%MOD;
    t %= MOD;
    result += t;
    result %= MOD;
//cout<<comb(n-1, (ll)i)<<' '<<modpow(m-1, (ll)(n-1-i), MOD)<<endl;cout<<i<<' '<<t<<' '<<result<<endl;cout<<"---"<<endl;

  }

  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

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

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

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    int w,s;
    cin>>s>>w;
    if(s<=w) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n, x;
    cin >> n >> x;
    vec a(n);
    loop(i, n) cin >> a[i];
    ll ans = 0;
    if (a[0] > x)
    {
        ans += a[0] - x;
        a[0] = x;
    }
    loop(i, n - 1)
    {
        if (a[i] + a[i + 1] > x)
        {
            ans += (a[i] + a[i + 1]) - x;
            a[i + 1] = x - a[i];
        }
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n == 1) {
        string s, t = "! BR";
        cout << "? 1" << endl;
        cin >> s;
        if (s[0] == 'R') swap(t[2], t[3]);
        cout << t << endl;
        return 0;
    }
    vector<char> c(2 * n + 1);
    int l = 1, r = n + 1;
    cout << "? ";
    rep(i, l, r) cout << i << " ";
    cout << endl;
    string s;
    cin >> s;
    char t = s[0];
    while (r - l > 1) {
        int m = (r + l) / 2;
        cout << "? ";
        rep(j, 0, n) cout << m + j << " ";
        cout << endl;
        cin >> s;
        if (s[0] == t)
            l = m;
        else
            r = m;
    }
    r += n - 2;
    l++;
    rep(i, 1, 2 * n + 1) {
        if (l <= i && i <= r) continue;
        cout << "? ";
        rep(j, l, r + 1) cout << j << " ";
        cout << i << endl;
        cin >> s;
        c[i] = s[0];
    }
    set<int> red, blue;
    rep(i, 1, 2 * n + 1) {
        if (c[i] == 'R' && red.size() != n / 2) {
            red.insert(i);
        } else if (c[i] == 'B' && blue.size() != n / 2) {
            blue.insert(i);
        }
    }
    rep(i, l, r + 1) {
        cout << "? ";
        for (int r : red) cout << r << " ";
        for (int b : blue) cout << b << " ";
        cout << i << endl;
        cin >> s;
        c[i] = s[0];
    }
    cout << "! ";
    rep(i, 1, 2 * n + 1) cout << c[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for (auto &it : r)
  {
    cin >> it;
    it--;
  }
  vector<vector<ll>> d(N, vector<ll>(N, INF / 2));
  for (int i = 0; i < M; i++)
  {
    int A, B, C;
    cin >> A >> B >> C;
    A--, B--;
    if (d[A][B] > C)
      d[A][B] = C, d[B][A] = C;
  }
  for (int i = 0; i < N; i++)
    d[i][i] = 0;
  for (int k = 0; k < N; k++)
  {
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < N; j++)
      {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  vector<int> v(R);
  iota(v.begin(), v.end(), 0);
  ll ans = INF;
  do
  {
    ll tmp = 0;
    for (int i = 1; i < R; i++)
    {
      tmp += d[r[v[i]]][r[v[i - 1]]];
    }
    ans = min(tmp, ans);
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
  return 0;
}

// next_permutationとワーシャルフロイド


Measured memory_bytes: 640
h, n = map(int, input().split())
state_lst = [0] * h
for _ in range(n):
    x, y = map(int, input().split())
    state_lst[y] += 2 ** x

left_mask = 3
middle_mask = 6
right_mask = 12
all_mask = 15

INF = 10 ** 20
dp = [[-INF] * 2 ** 4 for _ in range(h + 1)]
dp[0][all_mask] = 0
for i in range(h):
    state = state_lst[i]
    for mask in (left_mask, middle_mask, right_mask):
        if (state & mask): continue
        for pre_state in range(16):
            if (pre_state & mask): continue
            dp[i + 1][state | mask] = max(dp[i + 1][state | mask], dp[i][pre_state] + 1)
    dp[i + 1][all_mask] = max(dp[i + 1][all_mask], -INF if state else (dp[i][0] + 2))
    dp[i + 1][state] = max(dp[i + 1][state], max(dp[i]))

print(max(dp[h]))



Measured memory_bytes: 9088
//package 测试;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
	public static void main(String[] argv) throws IOException {
		BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
		String s1=f.readLine();
		String[] s=new String[2];
		s=s1.split(" ");
		System.out.println(s[1]+s[0]);
	}
}


Measured memory_bytes: 22740
#include <iostream>
using namespace std;
#define INF 2000000000
#define MAX 500000

void mergeSort(int left, int right);
void merge(int left, int mid, int right);
int A[MAX];
int L[MAX/2+2], R[MAX/2+2];
long long cnt = 0, N;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    mergeSort(0, N);

    for (int i = 0; i < N; i++) {
        if (i) 
            cout << ' ';
        cout << A[i];
    }
    cout << '\n';
    cout << cnt << '\n';
}


void merge(int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) 
        L[i] = A[left + i];
    for (int i = 0; i < n2; i++) 
        R[i] = A[mid + i];
    L[n1] = INF; R[n2] = INF;
    int i = 0, j = 0;
    for(int k = left ; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        }
        else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, mid, right);
    }
}



Measured memory_bytes: 6936
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int SHEEP = 1;
const int WOLF = -1;

int N;
string S;

vector<int> solve(int sn, int s0){
    vector<int> ret(N);
    ret[0] = s0; ret[N-1] = sn;
    for(int i=0;i<N;i++){
        if(ret[i] == SHEEP){
            if(S[i] == 'o'){
                ret[(i+1+N)%N] = ret[(i-1+N)%N];
            }else if(S[i] == 'x'){
                ret[(i+1+N)%N] = -1 * ret[(i-1+N)%N];
            }
        }else if(ret[i] == WOLF){
            if(S[i] == 'o'){
                ret[(i+1+N)%N] = -1 * ret[(i-1+N)%N];
            }else if(S[i] == 'x'){
                ret[(i+1+N)%N] = ret[(i-1+N)%N];
            }
        }
    }
    return ret;
}

void print_vec(vector<int> &A){
    for(auto a : A){
        if(a == SHEEP){
            cout << 'S';
        }else if(a == WOLF){
            cout << 'W';
        }else {
            cout << 'X';
        }
    }
    cout << endl;
}

int main(){
    cin >> N >> S;
    vector<int> ans;

    ans = solve(SHEEP, SHEEP);
    if(ans[N-1] == SHEEP && ans[0] == SHEEP){
        print_vec(ans);
        return 0;
    }
    ans = solve(SHEEP, WOLF);
    if(ans[N-1] == SHEEP && ans[0] == WOLF){
        print_vec(ans);
        return 0;
    }
    ans = solve(WOLF, SHEEP);
    if(ans[N-1] == WOLF && ans[0] == SHEEP){
        print_vec(ans);
        return 0;
    }
    ans = solve(WOLF,WOLF);
    if(ans[N-1] == WOLF && ans[0] == WOLF){
        print_vec(ans);
        return 0;
    }

    cout << -1 << endl;
}

Measured memory_bytes: 1392
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

long long lcm(long long a, long long b)
{
    long long tmp = max(a, b);

    do{
        if(tmp % a == 0 and tmp % b == 0)
            return tmp;
        else 
            tmp += max(a, b);
    }while(1);
}
int main()
{
    int n;
    long long t[100];

    cin >> n;
    for(int i=0; i<n; i++) cin >> t[i];

    long long ans;
    long long tmp = t[0];
    for(int i=1; i<n; i++){
        tmp = lcm(tmp, t[i]);
    }

    cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
ll arr[200005];
ll dp[200005];
int main()
{
	boost
	ll n,k;
	cin>>n>>k;
	ll i;
	for(i=0; i<n; i++)
		cin>>arr[i];
	dp[0]=0;
	for(i=1; i<n; i++)
	{
		dp[i]=inf;
		for(ll j=1; j<=k; j++)
		{
			if(i-j>=0)
			{
				dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
object Main {
  def main(args:Array[String]):Unit={
    var N = readLine.toInt
    var TA = readLine.split(" ")
    var H = readLine.split(" ")
    var res = -1
    var min = scala.Int.MaxValue.toDouble
    for(i <- 0 until N){
      var temp = TA(0).toInt-H(i).toInt*0.006
      var diff = scala.math.abs(TA(1).toInt-temp.toDouble)
      if(diff<min){
        res=i
        min=diff
      }
    }
    println(res+1)
  }
  
}

Measured memory_bytes: 27204
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */


#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define el '\n'
#define F first
#define S second
#define M_PI 3.14159265358979323846  /* pi */
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
#define degreesToRadians(angleDegrees) (angleDegrees * M_PI / 180.0) // Converts degrees to radians.
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / M_PI) // Converts radians to degrees.
#define ordered_set1 tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<int>		vll;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


void manipulateString(string &str)
{

    // looping through each character of string
    for (int i = 0; i < str.length(); i++) {

        // storing integer ASCII value of
        // the character in 'asc'
        int asc = str[i];

        // 'rem' contains coded value which
        // needs to be rounded to 26
        int rem = asc - (26 - (str[i] - 'a'));

        // coverting 'rem' character in range
        // 0-25 and storing in 'm'
        int m = rem % 26;

        // printing character by adding ascii value of 'a'
        // so that it becomes in the desired range i.e. a-z
        str[i] = (char)(m + 'a');
    }
}

class BROTN {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n; in >> n;
        string s;
        in >> s;
        string al;
        for (char i='A';i<='Z';++i) {
            al += i;
        }
        for (int i = 0; i < s.length(); ++i) {
            char cur = s[i]+n;
            if (cur>'Z') {
                int rem = n - (26 - (s[i] - 'A'));
                int m = rem % 26;
                s[i] = (char) (m + 'A');
            } else {
                s[i] = cur;
            }
        }
        out << s << el;

	}
};


int main() {
	BROTN solver;
	std::cout << std::fixed;
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const* argv[])
{
	string input;
	char answer[64];
	int n;

	cin >> n;

	for( int i = 0;i < n;i++ ){
		cin >> input;
		for( int j = 0;j < 64;j++ ) answer[j] = '\0';
		int pos = 32;

		answer[pos] = input[0];
		for( int j = 3;j < input.size();j += 3 ){
			if( input[j - 2] == '<' ){
				pos--;
				answer[pos] = input[j];
			} else if( input[j - 2] == '-' ){
				pos++;
				answer[pos] = input[j];
			}
		}

		int j;
		for( j = 0;j < 64;j++ ){
			if( answer[j] != '\0' ) break;
		}

		cout << ( answer + j ) << endl;
	}
				

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long
const ll mod = 1e9+7;

int n ;
ll f[1000];

int main()
{
    cin >> n;
    f[0] = 2;
    f[1] = 1;
    for(int i = 2; i <= n; i++)
    {
        f[i] = f[i-1] + f[i-2];
    }
    cout<<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

int main(){
    int n;
    cin>>n;
    int total=0;
    // vector<int> a(n);
    string s;
    
    s=to_string(n);
    for(int i=0;i<s.size();i++){
        
        total=total+stoi(s.substr(i,1));
    }
    
    if(n%total==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N+1);
  vector<int> B(N+1);
  for (int i=1; i<N+1; i++){
    cin >> A.at(i);
  }
  for (int i=1; i<N+1; i++){
    B.at(A.at(i))=i;
  }
  for (int i=1; i<N+1; i++){
    cout << B.at(i) << " ";
  }
}

Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    n, m = map(int, input().split())
    key = []  # 集合S，コスト
    for i in range(m):
        a, b = map(int, input().split())
        s = 0
        C = list(map(int, input().split()))
        for j in range(b):
            C[j] -= 1
            s |= 1 << C[j]  # C[j]桁目のbitを1にする
        key.append((s, a))
    INF = 10**9+7
    dp = [INF]*(2**n)
    dp[0] = 0

    for s in range(2**n):
        for i in range(m):
            t = s | key[i][0]
            cost = dp[s]+key[i][1]
            dp[t] = min(dp[t], cost)

    print(dp[-1] if dp[-1] != INF else -1)


resolve()

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

int main(){
    ll n, m, v, p;
    cin >> n >> m >> v >> p;

    vector<ll> a(n);

    rep(i,n){
        cin >> a[i];
    }

    ll ans = p;

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

    ll jud = 0;
    ll vote = m * (n-v);
    ll jud2 = 0;

    for(ll i=p; i<n; i++){
        jud += a[i-1];
        jud2++;

        if(jud - (jud2 * a[i]) <= vote){
            if(a[p-1]-a[i] <= m){
                ans++;
            }
        }

    }

    cout << ans << endl;
}

Measured memory_bytes: 1152
/*

Eulerian path

 */
#include <stdio.h>
#include <string.h>


int main(void) {
    int s, t, result, last_vertex, i, v[101];
    int odd;

    while (1) {
        memset(v, 0, sizeof(v));
        last_vertex = 2;
        odd = 0;
        while ((result = scanf("%d%d", &s, &t)) != EOF) {
            if (!s && !t) break;
            v[s]++;
            v[t]++;
            if (last_vertex < s) last_vertex = s;
            if (last_vertex < t) last_vertex = t;
        }
        if (result == EOF) return 0;

        for (i = 3; i <= last_vertex; i++) {
            if (v[i]&1) {
                odd++;
            }
        }

        if (odd == 0 && (v[1]&1) && (v[2]&1)) {
            puts("OK");
        }
        else {
            puts("NG");
        }
    }
    return 0;
}

Measured memory_bytes: 580
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort(reverse=True)

    ans = 0
    flag = True

    while flag:
        flag = False
        cur = 0
        for i in range(n):
            if a[i] > (n - 1):
                cnt = (a[i] - (n - 1) + (n - 1)) // n
                ans += cnt
                cur += cnt
                a[i] -= (n + 1) * cnt
        for i in range(n):
            a[i] += cur
            if a[i] > n - 1:
                flag = True

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68972
a=list(input())
b=list(input())
c=list(input())
d='a'
while True:
    if d=='a':
        if len(a)==0:
            print('A')
            break
        d=a[0]
        del a[0]
    elif d=='b':
        if len(b)==0:
            print('B')
            break
        d=b[0]
        del b[0]
    elif d=='c':
        if len(c)==0:
            print('C')
            break
        d=c[0]
        del c[0]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, vector<long long> A){
	map<ll, ll> m;
	rep(i, N) {
		m[A[i]]++;
	}
	ll sum = 0;
	for (auto x : m) {
		sum += x.second*(x.second-1)/2;
	}
	rep(i, N) {
		ll a = m[A[i]];
		cout << sum-a*(a-1)/2+(a-1)*(a-2)/2 << endl;
	}
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 12672
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def paint_col(adj, cols, i, col):
    nxt = [i]

    while nxt:
        u = nxt[-1]
        try:
            v = next(adj[u])
            if cols[v] == 0:
                cols[v] = col
                nxt.append(v)
        except StopIteration:
            nxt.pop()
            cols[u] = col

def solve():
    n, m = map(int, sys.stdin.readline().split())
    adj = [[] for i in range(n)]

    for i in range(m):
        s, t = map(int, sys.stdin.readline().split())
        adj[s].append(t)
        adj[t].append(s)

    cols = [0] * n
    col = 1
    adj = list(map(iter, adj))

    for i in range(n):
        if cols[i] == 0:
            paint_col(adj, cols, i, col)
            col += 1

    # debug(cols, locals())

    q = int(sys.stdin.readline())

    for i in range(q):
        s, t = map(int, sys.stdin.readline().split())

        if cols[s] == cols[t]:
            ans = 'yes'
        else:
            ans = 'no'

        print(ans)

if __name__ == '__main__':
    solve()

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int R, L;
  R = A + B;
  L = C + D;
  if(R > L) {
    cout << "Left" << endl;
  }
  
  if (R == L) {
    cout << "Balanced" << endl;
  }
  
  if (R < L) 
    cout << "Right" << endl;

}


Measured memory_bytes: 256
<?php
  $s = str_split(trim(fgets(STDIN)));

  $count=0;
  $max_count=0;
  for($h=0;$h<3;$h++){
    if($s[$h] == "R"){
      $count += 1;
    }else $count = 0;
    if($count != 0) $max_count = $count;
  }

  echo $max_count."\n";

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

using namespace std;

int main()
{
	string a;
	int b;
	cin>>b>>a;
	if (a.length()<b||a.length()==b)
		cout<<a;
	else
	{
		for (int i=0;i<b;i++)
			cout<<a[i];
		cout<<"...";
	}
    return 0;
}


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

int main(){
int N,A,B,C=0,K,d;
cin >> K >> A >> B;
//vector<int> A(N);

for(int i = A;i <= B; i++){
	if(i%K==0){
		C++;
		break;
	}
}
if(C == 1) cout << "OK" << endl;
else cout << "NG" << endl;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1000000009;
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first	
#define sc  second


int main() {
	int a, b, c, d, e, f, g, h;
	int i, j, k, l, m, n, o, p, q, r;
	string s, t, u;
	int v, w, x, y, z;

	cin >> d >> n;
	if (n == 100) ++n;
	cout << n;
	rep(i, d) cout << "00";
	cout << endl;


	return 0;
}

Measured memory_bytes: 256