akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

#define ll long long
#define ld long double

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) begin(x), end(x)
#define rall(x) end(x), begin(x)
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(int N, const vector<ll> & H) {
  int cost = 0;
  pair<ll, ll> res = cons(0, 0);
  rep3(i, 1, N)
    if (H[i-1]<H[i]) cost = 0;
    else {
      cost++;
      if(res.car < cost) res = cons(cost, i);
    }
  return res.car;
}

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

  int N;
  cin >> N;
  vector<ll> H(N);
  rep (i, N) {
    cin >> H[i];
  }

  auto ans = solve(N, H);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3568
n = int(input())
a = list(map(int, input().split()))
 
ops = []
while len(a):
  if not any(a[i] == i + 1 for i in range(len(a))):
    print(-1)
    exit()
  for i in reversed(range(len(a))):
    if a[i] == i + 1:
      ops.append(a[i])
      a.pop(i)
      break
 
for op in reversed(ops):
  print(op)


Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
double d[mm];
ll mod=1e9+7;
int main()
{
	int n,i,k,j;
	double s=0,ss=0;
	cin>>n>>k;
	for(i=0;i<n;i++)
	cin>>d[i];
	for(i=0;i<n;i++)
	{
		d[i]=d[i]+d[i-1];
	}
	for(i=k-1;i<n;i++)
	{
	   ss=(d[i]-d[i-k]+k)/2;
	   s=max(s,ss);	
	} 
	printf("%.12f\n",s);
   
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
int main(int argc, char *argv[]) {
	unsigned int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	const unsigned int l = a + b;
	const unsigned int r = c + d;
	const std::string s =
		(l > r) ? "Left"  :
		(l < r) ? "Right" :
		          "Balanced";
	std::cout << s << std::endl;
	return 0;
}

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

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

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S; cin >> S;
    cout << S.substr(0,3) << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  if(N==1){
    cout<<M<<endl;
    return 0;
  }
  for(int i=M/2;i>0;i--){
    if(M%i==0 and M/i>=N){
      cout<<i<<endl;
      return 0;
    }
  }
}


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

int main () {
  int A, B;
  cin >> A >> B;
  bool ans = false;
  if (A%3==0||B%3==0||(A+B)%3==0) {
    ans = true;
  }
  if (ans) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}

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

int main() {
  int a,b,c,d;
  string r,l,f;
  r = "Right";
  l = "Left";
  f = "Balanced";
  cin >> a >> b >> c >> d;
  if (a+b > c+d){
    cout << l << endl;
  }
  else if (a+b == c+d){
    cout << f << endl;
  }
  else {
    cout << r << endl;
  }
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int n; cin >> n;

	vector<int> a(n);
	REP(i,n) cin >> a[i];

	deque<int> deq;
	deq.push_back(a.front());


	FOR(i,1,n){
		if(n%2 == 1){
			if(i%2 == 0) deq.push_front(a[i]);
			else deq.push_back(a[i]);

		}else{
			if(i%2 == 0) deq.push_back(a[i]);
			else deq.push_front(a[i]);
		}
	}

	REP(i,n) cout << deq[i] << " ";
	cout << endl;



	return 0;

}


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

int main() {

    string S;
    int max = 0;
    int tmp_max = 0;

    cin >> S;

    bool flg = false;

    for (int i = 0; i < S.size(); i++) {
        char c = S[i];
        //cout << c << endl;
        if (c == 'A' || c == 'G' || c == 'C' || c == 'T'){
            flg = true;
        }else{
            flg = false;
        }

        if (flg){
            tmp_max++;
        }else{
            if(max < tmp_max){
                max = tmp_max;
            }
            tmp_max = 0;
        }
    }
    if (flg){
        if(max < tmp_max){
            max = tmp_max;
        }
    }

    cout << max << endl;

    
    return 0;

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,n;
  cin>>a>>b>>n;
  while(n--){
    int q,w;
    cin>>q>>w;
    if(!(q>=b||w<=a)){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
}


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int diffX = x2 - x1;
  int diffY = y2 - y1;
  COUTS(x2 - diffY); COUTS(y2 + diffX); COUTS(x1 - diffY); COUTB(y1 + diffX);
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
    ll n;
    cin>>n;
    string ans;
    while (n > 0){
        --n;
        char now = 'a' + (n % 26);
        ans.push_back(now);
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

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

int main(){
    int n, m; cin >> n >> m;
    vector<long long>  a(n), b(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

    auto ans = convolution(a, b);
    for (auto p : ans) cout << p << " ";
    cout << "\n";
    return 0;
}

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

using namespace std;

int main()
{
    int n,sum=0,i;
    cin >> n;
    int arr1[n];
    int arr2[n];
    for(i=0; i<n; i++)
        cin >> arr1[i];
    for(i=0; i<n; i++)
        cin >> arr2[i];
    for(i=0; i<n; i++)
    {
        if(arr1[i]>arr2[i])
        {
            sum+=arr1[i]-arr2[i];
        }
    }
    cout << sum;

}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<PII> X(N);
    int NN = N*N;
    vector<int> ans(NN);
    rep(i, N) {
        int tmp; cin >> tmp;
        X[i] = PII(tmp-1, i+1);
    }
    sort(ALL(X));

    bool ok = true;

    for (auto x : X) {
        ans[x.first] = x.second;
        if (x.second == 1) continue;

        int cnt = 0;
        for (int i=0; i<x.first; i++) {
            if (ans[i] == 0) {
                ans[i] = x.second;
                cnt++;
            }

            if (cnt == x.second - 1) break;
        }

        if (cnt < x.second-1) {
            ok = false;
            break;
        }
    }

    for (int j=N-1; j>=0; j--) {
        PII x = X[j];
        if (x.second == N) continue;

        int cnt = 0;
        for (int i=NN-1; i>x.first; i--) {
            if (ans[i] == 0) {
                ans[i] = x.second;
                cnt++;
            }

            if (cnt == N - x.second) break;
        }

        if (cnt < N - x.second) {
            ok = false;
            break;
        }
    }

    if (ok) {
        cout << "Yes" << endl;
        rep(i, NN) {
            // if (i > 0) cout << " ";
            cout << ans[i] << " ";
        }
        cout << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  int n;
  cin >> n;
  int x = 1;
  int ct = 0;
  for (int i = 0; i < n; i++){
    int f;
    cin >> f;
    if (f == x){
      x++;
      ct++;
    }
  }
  int ans;
  if (!ct) ans = -1;
  else ans = n - ct;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=1,z=0,w=0,n=0,m=0;
std::cin >> x;
repone(i,x+1){
  y=(y*i)%MOD;
}
std::cout << y << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n, a[max];
    
    scanf("%d", &n);
    rep(i, n){
        scanf("%d", &a[i]);
    }
    
    qsort(a, n, sizeof(int), up_comp);
    
    printf("%d", a[n-1]-a[0]);
    
    return 0;
}


Measured memory_bytes: 1692
def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage

def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    left = 0
    right = 10000 * baggage_num
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid;
        else:
            left = mid
    return right


import sys

n, k = map(int, sys.stdin.readline().split())

T = list(map(int, sys.stdin))

P = min_capacity(T, n, k)

print(P)

Measured memory_bytes: 11536
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(K, A):
    L = H = 2
    for a in A[::-1]:
        if math.ceil(L/a)*a > H:
            return -1
        L = math.ceil(L/a)*a
        H = math.floor(H/a)*a + a-1

    return ' '.join(map(str, [L, H]))


def main():
    K = read_int()
    A = read_int_n()
    print(slv(K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 85356
#include <iostream>
#include <math.h>
using namespace std;
#define ll long long

int N;
ll X;


ll sub_solve(ll n){
	if(n == 0) return 0;

	ll ans = N;

	for(int i=0;i<N;i++){
		ans += 2 * (n / (4 * (ll)pow(2,i)));
		if(n % (4 * (ll)pow(2,i)) == 0) ans--;
	}
	return ans+n;
}


void solve(){
	ll head = 0;
	ll tail = X;
	ll cur = X/2;

	while(!(sub_solve(cur) <= X && X < sub_solve(cur+1))){
		if(sub_solve(cur) < X){
			head = cur;
			cur = (cur + tail)/2;
		}else{
			tail = cur;
			cur = (head + cur)/2;
		}
	}
	cout << cur << endl;
}


int main(){
	cin >> N >> X;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int MOD = 1000 * 1000 * 1000 + 7; // odd modulus
const int N = 100;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
ll n , d ;
bool cal ( const vector<int> &a, const vector<int> &b   ){
int  s =  0 ;
for ( int i = 0 ; i < d ; ++i )
{
    int d = a[i] - b[i]  ;
    int dd = d * d ;
    s += dd ;
}
s = abs(s);
int  x  = llround(sqrt(s)) ;
return (x * x == s) ;
}
int main()
{
    Fast_IO();
    cin >> n >> d ;
    vector<vector<int>> v(n) ;
    for ( int i = 0 ; i < n ; ++ i )
    {

        for ( int j = 0 ; j < d ; ++j )
        {   int x ;
            cin >> x ;
            v[i].pb(x);
        }
    }
    int cnt = 0 ;
    for ( int i = 0 ; i < n ; ++ i )
    {
        for ( int j = i+1 ; j < n ; ++j )
    {
            cnt += cal( v[i] , v[j] ) ;
    }
    }
    cout << cnt ;
    return 0 ;
}


Measured memory_bytes: 256
def update(BIT,index,letter,value):
    while index < len(BIT):
        BIT[index][letter] += value
        index += index&-index

def sumQuery(BIT,index):
    letters = [0]*26
    while index > 0:
        for i in range(26):
            letters[i] += BIT[index][i]

        index -= index&-index

    return letters

def rangeQuery(BIT,l,r,ans):
    right = sumQuery(BIT,r)
    left = sumQuery(BIT,l-1)
    count = 0
    for i in range(26):
        right[i] -= left[i]
        if right[i] > 0:
            count += 1

    ans.append(count)

def main():
    n = int(input())
    s = list(input())
    q = int(input())
    BIT = [[0 for i in range(26)] for j in range(n+1)]
    ans = []

    for i in range(n):
        update(BIT,i+1,ord(s[i])-ord('a'),1)

    for i in range(q):
        query,index,c = map(str,input().split())
        query = int(query)
        if query == 1:
            index = int(index)
            update(BIT,index,ord(s[index-1])-ord('a'),-1)
            s[index-1] = c
            update(BIT,index,ord(s[index-1])-ord('a'),1)
        else:
            l,r = int(index),int(c)
            rangeQuery(BIT,l,r,ans)

    for i in ans:
        print(i)


main()


Measured memory_bytes: 243740
#include <stdio.h>
#include <string.h>

int main(void) {
	int c1, c2, c3;
	int table[10];
	int count;
	int i;

	memset(table, 0, sizeof(table));
	while(scanf("%d %d %d", &c1, &c2, &c3) != EOF) {
		table[c1 - 1] = 1;
		table[c2 - 1] = 1;
		table[c3 - 1] = 1;

		count = 0;
		
		for(i = 0; i + c1 + c2 < 20 && i < 10; i++) {
			if(!table[i])
				count++;
		}
		
		if(count > 3)
			printf("YES\n");
		else
			printf("NO\n");
		fflush(stdout);

		memset(table, 0, sizeof(table));
	}

	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <chrono>
#include <vector>

using namespace std;

int main () {
    int N;
    cin >> N;
    vector<long long int> x(N), y(N);
    for (int i=0; i<N; i++) {
        cin >> x[i] >> y[i];
    }
    vector<string> s(N, "");
    vector<long long int> d;

    if ( ((x[0] + y[0]) & 1) != 1 ) {
        d.push_back(1);
        for (int i=0; i<N; i++) {
            y[i]--;
            s[i].push_back('U');
        }
    }

    long long int step = 1;
    while( step < (1LL << 33) ) {
        d.push_back(step);
        for(int i=0; i<N; i++) {
            if ( ((x[i] + y[i]) & 1) != 1 ) {
                cout << -1 << endl;
                return 0;
            }
            if ( x[i] & 1 ) {
                if (((x[i] - 1) & 2 ) == (y[i] & 2)) {
                    x[i]++;
                    s[i].push_back('L');
                } else {
                    x[i]--;
                    s[i].push_back('R');
                }
            } else {
                if (((y[i] - 1) & 2 ) == (x[i] & 2)) {
                    y[i]++;
                    s[i].push_back('D');
                } else {
                    y[i]--;
                    s[i].push_back('U');
                }
            }
            x[i] /= 2;
            y[i] /= 2;
        }
        step <<= 1;
    } 
    d.push_back(step);
    for (int i=0; i<N; i++) {
        if (x[i] == 1) {
            s[i].push_back('R');
        } else if (x[i] == -1) {
            s[i].push_back('L');
        } else if (y[i] == 1) {
            s[i].push_back('U');
        } else {
            s[i].push_back('D');
        }
    }
    int m = (int) d.size();
    cout << m << endl;
    for (int i=0; i<m; i++) {
        if (i>0) {
            cout << " ";
        }
        cout << d[i];
    }
    cout << endl;
    for (int i=0; i< N; i++) {
        cout << s[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, t, ans = 0, cntr = 2, temp;
    cin >> a >> b >> t;
    temp = a;
    for(int i = 1; i <= 100; i++){
        if(i * a > t)
            break;
        ans += b;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3572
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    string s, rs, s1="", rs1, s2="", rs2, s3;
    cin>>s; l = s.size();

    for(i=1; i<=(l-1)/2; i++) s1+=s[i-1];
    for(i=(l+3)/2; i<=l; i++) s2+=s[i-1];

    rs = s, rs1 = s1, rs2 = s2;
    reverse(rs.begin(), rs.end());
    reverse(rs1.begin(), rs1.end());
    reverse(rs2.begin(), rs2.end());

    if(s==rs && s1==rs1 && s2==rs2) cout<<"Yes\n";
    else cout<<"No\n";

   // main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string A,B,C;
  cin>>A>>B>>C;
  if(A.at(A.size()-1)==B.at(0)&&B.at(B.size()-1)==C.at(0)){
    ce("YES")
  }else{
    ce("NO")
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  
  set<ll> values;
  rep(i,n) values.insert(a[i]);
  
  if (values.size() == a.size()) cout << "YES" << endl;
  else cout << "NO" << endl;    
  return 0;
}


Measured memory_bytes: 11136
using System;
using System.Linq;
using System.Text;

namespace ALDS1_6_B {
    public static class MyExtension {
        public static int Pertition(this int[] arr,int p,int r) {
            int x = arr[r];
            int i = p - 1;
            for(int j = p; j < r; j++) {
                if (arr[j] <= x) {
                    i++;
                    arr.Replace(i, j);
                }
            }
            arr.Replace(i + 1, r);
            return i + 1;
        }

        public static void Replace(this int[] arr,int indexA,int indexB) {
            int temp = arr[indexA];
            arr[indexA] = arr[indexB];
            arr[indexB] = temp;
        }
    }

    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int q = A.Pertition(0, n - 1);
            
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < q; i++)
                sb.Append(A[i] + " ");
            sb.Append("[" + A[q] + "]");
            for (int i = q + 1; i < n; i++)
                sb.Append(" " + A[i]);
            Console.WriteLine(sb);
        }
    }
}

Measured memory_bytes: 20864
#include<bits/stdc++.h>
using namespace std;
#define      fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define      debug       printf("\n<<CameHere>>\n")
#define      mem(x,y)    memset(x, y, sizeof(x))
#define      all(qz)     qz.begin(),qz.end()
#define      rall(qz)    qz.rbegin(),qz.rend()
#define      inf         1000000000000000000
#define      mod         1000000007
#define      Sqr(x)      ((x)*(x))
#define      ll          long long
#define      mk          make_pair
#define      pb          push_back
#define      pi          acos(-1.0)
#define      cos(a)      cos(a*pi/180)
#define      sin(a)      sin(a*pi/180)
#define      tan(a)      tan(a*pi/180)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    fastt

    ll h,w,m;
    cin>>h>>w>>m;
    ll row[h+10],col[w+10];
    mem(row,0);mem(col,0);
    ll mxr=0,mxc=0;
    map<pair<ll,ll>,ll > mp;
    while(m--){
        ll a,b;
        cin>>a>>b;
        mp[{a,b}]++;
        mxr=max(mxr,++row[a]);
        mxc=max(mxc,++col[b]);
    }
    vector<ll> r,c;
    for(ll i=1;i<=h;i++) if(row[i]==mxr) r.push_back(i);
    for(ll i=1;i<=w;i++) if(col[i]==mxc) c.push_back(i);


    bool ok=false;
    for(ll i=0;i<r.size();i++){
        for(ll j=0;j<c.size();j++){
            ll x=r[i];
            ll y=c[j];
            //cout<<x<<" "<<y<<endl;
            if(!mp.count({x,y})){
                ok=true;
                break;
            }
        }
        if(ok) break;
    }
    if(ok) cout<<mxr+mxc<<endl;
    else cout<<max(0LL,mxr+mxc-1)<<endl;
    return 0;
}
























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

#define ll long long int
#define mp make_pair 
#define pb push_back
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define ff first
#define ss second
#define ll_MAX 922337203685477999
#define endl "\n"
inline ll absdiff(ll a,ll b) {return (a>b)?a-b:b-a;}
const ll MOD = 1000000007;
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt", "w", stdout);

    ll t_c;t_c = 1;
    // cin >> t_c;
    for (ll ti = 0; ti < t_c; ++ti)
    {  
        ll n; cin >> n;
        ll arr[n];
        for(auto &i:arr)
            cin >> i;
        
        ll ans = INT_MAX;
        for(ll i=0; i<=100; ++i){
            ll temp = 0;
            for(ll j=0; j<n; ++j){
                temp += (i-arr[j])*(i-arr[j]);
            }
            ans = min(ans,temp);
        }
        cout << ans;    
    }
    return 0;       
}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll n;
string ans;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	while(n > 0){
		char c = (n % 26ll) + 'a' - 1ll;
		if(n % 26ll == 0){
			c = 'z';
		}
		ans += c;
		if(n % 26ll == 0){
			n--;
		}
		n /= 26ll;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
		
}
	


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    int F[N+1][6][3];

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= 5; j++){
            for(int k = 1; k <= 2; k++){
                scanf("%d", &F[i][j][k]);
            }
        }
    }

    int P[N+1][11];

    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= 10; j++){
            scanf("%d", &P[i][j]);
        }
    }

    int max = -1000000000;

    for(int l = 1; l < 1024; l++){
        int m = l;
        F[0][1][1] = m % 2;
        m /= 2;
        F[0][1][2] = m % 2;
        m /= 2;
        F[0][2][1] = m % 2;
        m /= 2;
        F[0][2][2] = m % 2;
        m /= 2;
        F[0][3][1] = m % 2;
        m /= 2;
        F[0][3][2] = m % 2;
        m /= 2;
        F[0][4][1] = m % 2;
        m /= 2;
        F[0][4][2] = m % 2;
        m /= 2;
        F[0][5][1] = m % 2;
        m /= 2;
        F[0][5][2] = m % 2;
        m /= 2;

        int c[N+1];
        for(int i = 1; i <= N; i++){
            c[i] = 0;
        }
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= 5; j++){
                for(int k = 1; k <= 2; k++){
                    if(F[0][j][k] == 1 && F[i][j][k] == 1){
                        c[i]++;
                    }
                }
            }
        }
        int sum = 0;
        for(int i = 1; i <= N; i++){
            sum += P[i][c[i]];
        }
        if(max < sum){
            max = sum;
        }
    }

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

    return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[200005],f[200005],ans;
void solve(){
    cin>>n;
    rep(i,1,n+1){
        cin>>a[i];
        f[a[i]]++;
    }
    rep(i,1,n+1) ans+=f[i]*(f[i]-1)/2;
    rep(i,1,n+1) cout<<ans-f[a[i]]*(f[a[i]]-1)/2+(f[a[i]]-1)*(f[a[i]]-2)/2<<endl;
}

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

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main(){
	int p, n;
	cin >> p >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++)
		cin >> v[i];
	int maxdist = p - v[n-1] + v[0];	
	for(int i=0; i<n-1; i++)
		maxdist = max(maxdist, v[i+1]-v[i]);
	cout << p - maxdist;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    if (A[i] % 2 == 0) and (A[i] % 3 != 0) and (A[i] % 5 != 0):
        print("DENIED")
        break
else:
    print("APPROVED")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const int MAX = 210000;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N, M;
    COMinit();
    cin >> N >> M;
    auto vec = prime_factorize(M);
    ll ans = 1;
    for(auto pa : vec){
      int num = pa.second;
      ll tmp = COM(num+N-1, N-1);
      ans = (ans * tmp) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    flag = 0

    while flag == 0:
        for i in range(N):
            if A[i] % 2 != 1:
                A[i] = A[i] // 2
            else:
                flag = 1
                print(cnt)
                return
        cnt += 1

main()

Measured memory_bytes: 9100
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

K = int(input())

# indexは桁数
luns = [[]]
luns.append(list("123456789"))
for keta in range(2, 11):
    keta_lun = []
    for s in luns[-1]:
        lst = int(s[-1])
        if lst - 1 >= 0:
            keta_lun.append(s + str(lst - 1))
        keta_lun.append(s + str(lst))
        if lst + 1 < 10:
            keta_lun.append(s + str(lst + 1))
    luns.append(keta_lun)

index = 0
for keta_luns in luns:
    for lun in keta_luns:
        index += 1
        if index == K:
            print(lun)
            quit()

Measured memory_bytes: 23280
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
typedef long long LL;
constexpr int kNum = 40;

int main() {
  LL N, K; std::cin >> N >> K;
  std::vector<LL> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }

  LL count[kNum] = {};
  for (LL a : A) {
    for (int i = 0; i < kNum; ++i) {
      LL mask = (1L << i);
      if (a & mask) ++count[i];
    }
  }

  LL X = 0;
  LL sum = 0;
  for (int i = kNum-1; i >= 0; --i) {
    LL mask = (1L<<i);
    LL Z = X + mask;
    if (Z <= K && (N - count[i] > count[i])) {
      X = Z;
      sum += mask * (N - count[i]);
    } else {
      sum += mask * count[i];
    }
  }
  std::cout << sum << std::endl;
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = x[0] * x[1];
            int b = x[2] + x[3];
            Console.WriteLine(a % 2 == 1 && b % 2 == 1 ? "No" : "Yes");
        }
    }
}



Measured memory_bytes: 18348
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
using ll=long long;
using Graph=vector<vector<ll>>;

ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}

int main(){
  ll N,S;
  cin>>N>>S;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
  }

  ll waru=modinv(2,MOD);

  ll a=modpow(2,N-1,MOD);

  vector<ll> dp(S+1,0);
  for(ll i=0;i<N;i++){
    for(ll j=S-A.at(i);j>0;j--){
      dp.at(j+A.at(i))+=dp.at(j)*waru%MOD;
      dp.at(j+A.at(i))%=MOD;
    }
    if(A.at(i)<=S){
      dp.at(A.at(i))+=a;
      dp.at(A.at(i))%=MOD;
    }
  }

  cout<<dp.at(S)%MOD<<endl;

}


Measured memory_bytes: 3676
while (True):
    s1=input()
    if (s1=="."):
        break
    s2=input()
    l1=s1.split("\"")
    l2=s2.split("\"")
   #print(l1,l2)
    if (len(l1)!=len(l2)):
        print("DIFFERENT")
        continue
    error=0
    for i in range(len(l1)):
        #print(l1,l2,i)
        if (l1[i]!=l2[i] and i%2==0):
            print("DIFFERENT")
            error=-1
            break
        if (len(l1[i])!=len(l2[i])):
            error+=1
        else:
            for j in range(min(len(l1[i]),len(l2[i]))):
            #   print(l1[i][j],l2[i][j])
                if (l1[i][j]!=l2[i][j]):
                    error+=1
                    break

    if (error==0):
        print("IDENTICAL")
    elif (error==1):
        print("CLOSE")
    elif(error>=2):
        print("DIFFERENT")


Measured memory_bytes: 5588
while True:
    try:
        q={}
        a=input()
        if a==0:break
        for i in range(10): q[i]=0
        for i in range(a): q[input()]+=1
        for i in range(10):  print "*"*q[i] if q[i] != 0 else "-"
    except SyntaxError: pass

Measured memory_bytes: 4536
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		sc.nextLine();
		String s = sc.nextLine();
		boolean haveFour = s.contains("Y");
		System.out.println(haveFour ? "Four" : "Three");
		sc.close();
	}

}


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

int main(void){
    int N,K; cin >> N >> K;
    pair<ll,int> A[N];
    for(int i=0; i<N; i++){
        ll t,d; cin >> t >> d;
        A[i]={d,t};
    }
    sort(A, A+N);
    reverse(A, A+N);
    ll ans=0, sum=0;
    map<int ,ll> mp; //map<寿司の種類番号、その数>
    for(int i=0; i<K; i++){
        sum+=A[i].first;
        mp[A[i].second]++;
    }
    ll s=mp.size();
    ans=sum+s*s;

    int r=K-1; //集合から追い出す要素を指すインデックス
    for(int i=K; i<N; i++){
        if(mp[A[i].second]==0){

            while(mp[A[r].second]==1 && r>=0) r--;
            if(r==-1) break;
            mp[A[i].second]++;
            sum+=A[i].first-A[r].first;
            mp[A[r].second]--; r--;
            s=mp.size();
            ans=max(ans,sum+s*s);
        }
    }

    cout << ans << endl;
    
}

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

int main(){
    using namespace std;
    constexpr size_t MOD = 1000000007;
    auto modinv = [&MOD](auto a, auto b){
        a %= MOD;
        auto n = MOD - 2;
        while(n){
            if(n & 1)(a *= b) %= MOD;
            (b *= b) %= MOD;
            n >>= 1;
        }
        return a;
    };
    size_t B, W;
    cin >> B >> W;
    vector<size_t> binom(B + W - 1);
    {
        vector<size_t> binomB(W), binomW(B);
        binomB[0] = MOD - 1;
        binomW[0] = 1;
        for(size_t i = 1, j = B; i != W; ++i, ++j)binomB[i] = modinv(binomB[i - 1] * j, i);
        for(size_t i = 1, j = W; i != B; ++i, ++j)binomW[i] = modinv(binomW[i - 1] * j, i);
        copy(binomB.rbegin(), binomB.rend(), binom.rbegin());
        transform(binomW.rbegin(), binomW.rend(), binom.rbegin(), binom.rbegin(), [&MOD](auto a, auto b){return min(a + b, a + b - MOD);});
    }
    size_t a{1}, b{500000004};
    for(size_t i = 0; i != W + B; ++i){
        cout << a * b % MOD << endl;
        ((a *= 2) += binom[i]) %= MOD;
        (b += (b & 1) * MOD) >>= 1;
    }
}

Measured memory_bytes: 3808
s = input()
b = s[0]
cou = 0


lis = []
for i in s:
    if b ==i:
        if i=='<':
            cou-=1
        else:
            cou+=1
    else:
        lis.append(cou)
        b = i
        if b=='<':
            cou =-1
        else:
            cou = 1
lis.append(cou)
l = len(lis)
sum = 0
if s[0]=='<':
    for i in range(0,l,2):
        if i+1 == l and (i+1)%2==1:
            a = abs(lis[i])
            sum += a*(a+1)//2
            break
        a = abs(lis[i])
        b = abs(lis[i+1])

        if a < b:
            sum += b*(b+1)//2
            sum += (a-1)*a//2
        else:
            sum += a*(a+1)//2
            sum += (b-1)*b//2
else:
    a = abs(lis[0])
    sum += a*(a+1)//2
    for i in range(1,l,2):
        if i+1 == l and (i+1)%2==0:
            a = abs(lis[i])
            sum += a*(a+1)//2
            break
        a = abs(lis[i])
        b = abs(lis[i+1])

        if a < b:
            sum += b*(b+1)//2
            sum += (a-1)*a//2
        else:
            sum += a*(a+1)//2
            sum += (b-1)*b//2

print(sum)


Measured memory_bytes: 6304
n=int(input())
a=n//100
b=n//10-10*a
c=n%10
if a==1:
    a=9
else:
    a=1
if b==1:
    b=9
else:
    b=1
if c==1:
    c=9
else:
    c=1
print(100*a+10*b+c)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
#define show(x) cout<<(#x)<<" is "<<(x)<<endl

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e6+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int a[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    ll ans=INF;
    for(int i=k;i<=n;i++){
        ll l=a[i-k+1];
        ll r=a[i];
        if(l<0 && r>0){
            ans=min(ans,min(l*-2+r,r*2-l));
        }
        else{
            if(l<0)ans=min(ans,-l);
            else ans=min(ans,r);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  for(int i=0; i<vec.size()-1; i++) cout << vec.at(i) << " ";
  cout << vec.at(vec.size()-1) << endl;
}

int main(){
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> A(Q);
  for(int i=0; i<Q; i++){
    cin >> A.at(i);
    A.at(i)--;
  }
  vector<int> P(N);
  for(int i=0; i<N; i++) P.at(i) = K-Q;
  int a;
  for(int i=0; i<Q; i++){
    a = A.at(i);
    P.at(a)++;
  }
  int p;
  for(int i=0; i<N; i++){
    p = P.at(i);
    if(p>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
import std.stdio, std.ascii, std.conv, std.string;
import std.regex, std.math, std.bigint;

bool x_exists;

bool zero_filter(char[] str) {
  if (str.length == 1) return true;
  return str[0] != 'X';
}

BigInt conv(char[] str, int i) {
  BigInt x;
  int digit = 0;
  foreach(s; str) {
    BigInt n;
    if (s == 'X') {
      n = i;
      x_exists = true;
    }
    else if (isDigit(s)) n = s - '0';
    x = 10 * x + n;
    digit++;
  }
  return x;
}

void main() {
  string line;
  while ((line = readln) != null) {
    char[] expr = line.chomp.dup.to!(char[]);
    auto m = match(expr, r"^(.*?)\+(.*?)=(.*?)$").captures;
    int ans = -1;
    bool is_zero = true;
    for(int i = 1; i <= 3; i++) {
      is_zero &= zero_filter(m[i]);
    }
    for(int i = (is_zero ? 0 : 1); i <= 9; i++) {
      x_exists = false;
      if ((m[1].conv(i) + m[2].conv(i)) == m[3].conv(i)) {
        if (!x_exists) continue;
        ans = i;
        break;
      }
    }
    writeln((ans >= 0) ? ans.to!(string) : "NA");
  }
}

Measured memory_bytes: 1600
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(10);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int N;
int A[1000005];



void solve() {
	vector<int> table(1000005, -1);
	for (int i = 2; i < 1000005; i++) {
		for (int j = i; j < 1000005; j += i) {
			if (table[j] == -1) {
				table[j] = i;
			}
		}
	}
	vector<int> cnt(1000005, 0);
	rep (i, N) {
		int a = A[i];
		while (a != 1) {
			cnt[table[a]]++;
			int use = table[a];
			while (a % use == 0) {
				a = a / use;
			}
		}
	}
	
	if (*max_element(rng(cnt)) < 2) {
		cout << "pairwise coprime" << endl;
		return;
	}

	int _gcd = A[0];
	rep2 (i, 1, N) _gcd = gcd(_gcd, A[i]);
	if (_gcd == 1) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
}

int main() {
	cin >> N;
	rep (i, N) cin >> A[i];

	solve();
	
	return 0;
}


Measured memory_bytes: 14756