akhauriyash/Code-Regression huggingface dataset:
def inp():
    return(int(input()))


def invr():
    return(map(int, input().split()))


n = inp()

ratings = invr()

flags = [0]*8
c = 0
a = 0
for r in ratings:
    if r >= 1 and r < 400 and flags[0] == 0:
        c += 1
        flags[0] = 1
    if r >= 400 and r < 800 and flags[1] == 0:
        c += 1
        flags[1] = 1
    if r >= 800 and r < 1200 and flags[2] == 0:
        c += 1
        flags[2] = 1
    if r >= 1200 and r < 1600 and flags[3] == 0:
        c += 1
        flags[3] = 1
    if r >= 1600 and r < 2000 and flags[4] == 0:
        c += 1
        flags[4] = 1
    if r >= 2000 and r < 2400 and flags[5] == 0:

        c += 1
        flags[5] = 1
    if r >= 2400 and r < 2800 and flags[6] == 0:
        c += 1
        flags[6] = 1
    if r >= 2800 and r < 3200 and flags[7] == 0:
        c += 1
        flags[7] = 1
    if r >= 3200:
        a += 1
if c == 0:
    print(1, a)
else:
    print(c, c+a)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    long long s;
    cin>>n>>a>>b;
    if(n>=1 && n<=20 && a>=1 && a<=100 && b>=1 && b<=2000){
    s=n*a;
    if(s<b) cout<<s<<endl;
    else cout<<b<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }

        Collections.sort(list);

        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }
        System.out.println(ans);
    }

}

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

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

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>//"M_PI"→円周率(小数点以下5桁)
#include<iomanip>//fixed<<setprecision(15)<<
#define LL long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define srep(i,s,n) for(int i=s;i<=(n);i++)
#define E "\n"
#define PI 3.141592653589793

//以下、解答の写し
int main(){
  int a,b;cin>>a>>b;
  int cnt=0;
  srep(i,a,b){
    int s=i%10,t=i/10000%10;//sは一の位、tは一万の位(多分%10は要らん)
    int u=i/10%10,v=i/1000%10;//uは十の位、vは千の位(上に同じ)
    if(s==t&&u==v)
      cnt++;
  }
  cout<<cnt<<E;
}

Measured memory_bytes: 3516
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
const ll MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

// 二項係数計算nCk
ll com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 二項係数計算nPk
ll per(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n-k] % MOD) % MOD;
}

// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	return b ? gcd(b,a%b) : a;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/


//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>t(n);
    rep(i,0,n){
        cin>>t[i];
    }
    ll sum=0;
    sort(all(t),greater<ll>());
    for(ll i=0;i<k;i++){
        sum+=t[i];
    }
    cout<<sum<<endl;
    
    
    
}


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

const int maxN = 1e5+100;

int n, a[maxN], ans;

int main() {
    cin >> n;
    for(int i=1; i<=n; i++) 
        cin >> a[i];
    for(int i=1; i<=n; i++) 
        if (a[i] == i) {
            ++ans;
            if (a[i+1] == i+1)
                i++;
        }
    cout << ans;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i ,a, b) for(int i = a; i < b; i++)
#define REP(i, n) rep(i, 0, n)
#define all(a) a.begin(), a.end()
using namespace std;

int main(){
    int d, e;
    while(1){
        cin >> d >> e;
        if(d + e == 0) break;
        double MIN = 1e9;
        rep(i, 0, 101){
            rep(j, 0, 101){
                if(i + j != d) continue;
                double l = abs(e - sqrt(i*i + j*j));
                MIN = min(MIN, l);
            }
        }
        printf("%.10lf\n", MIN);
    }
}

Measured memory_bytes: 1196
n,k = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
'''
ここは任意
'''

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(n+1):
    tmp = n -i -1
    if n-i < k:
        continue
    kei = cmb(tmp,k-1,mod)
    ans += A[tmp] * kei % mod
    ans -= A[i] * kei %mod
print(ans % mod)
    

Measured memory_bytes: 77096
package main

import "fmt"

func main() {
	var a, b, x int
	fmt.Scan(&a, &b, &x)
	if a == b {
		if a%x == 0 {
			fmt.Println(1)
		} else {
			fmt.Println(0)
		}
	} else { // a < b
		nb := b / x
		na := a / x
		if a%x == 0 {
			fmt.Println(nb - na + 1)
		} else {
			fmt.Println(nb - na)
		}
	}
}


Measured memory_bytes: 512
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
  n, k = na()

  def Base_10_to_n(X, n):
    if (int(X/n)):
      return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
  
  print(len(Base_10_to_n(n, k)))

if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x; }
ll lcm(ll x, ll y) { return x/gcd(x, y)*y; }

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

  int n; cin >> n;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];

  vector<ll> LCM(n);
  LCM[0] = t[0];
  for(int i = 1; i < n; ++i) {
    LCM[i] = lcm(t[i], LCM[i-1]);
  }
  cout << LCM[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = map(int, input().split())
def sub(x):
    if n>=x:
        return m>=2*x
    else:
        return max(0, (m-2*x)//2) + n >= x
l = 0
r = n+m+1
while l<r-1:
    mm = (l+r)//2
    if sub(mm):
        l = mm
    else:
        r = mm
print(l)

Measured memory_bytes: 38384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC_110_A solver = new ABC_110_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC_110_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] a = new int[3];
            a[0] = in.nextInt();
            a[1] = in.nextInt();
            a[2] = in.nextInt();
            Arrays.sort(a);
            out.print(a[2] * 10 + a[1] + a[0]);


        }

    }
}



Measured memory_bytes: 23508
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int main(){
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int>v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  sort(v.begin(),v.end());
  for(int i=1;i<n;i++){
    if(v[i]==v[i-1]){
      cout<<"NO";
      return 0;
    }
  }
  cout<<"YES";
  return 0;
}

Measured memory_bytes: 1024
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(ll A, ll B, ll C, ll D) {
  bool t = true;
  while (A > 0 && C > 0) {
    if (t) {
      C -= B;
    } else {
      A -= D;
    }
    t = !t;
  }

  yesOrNo(A > 0);
}

int main() {
  ll A;
  scanf("%lld", &A);
  ll B;
  scanf("%lld", &B);
  ll C;
  scanf("%lld", &C);
  ll D;
  scanf("%lld", &D);
  solve(A, B, C, D);
  return 0;
}


Measured memory_bytes: 3664
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll pw(ll x,ll k)
{
    ll ret = 1;
    for(ll i = 0, bs = x;(1LL<<i) <= k;i++,bs = bs * bs % MOD)if((1LL<<i) & k)ret = (ret * bs) % MOD;
    return ret;
}

ll d[MAXn], inv[MAXn];


int main()
{
    IOS();
    ll n;
    cin>>n;
    REP(i,n)cin>>d[i];
    REP1(i,n)inv[i] = pw(i, MOD-2);
    REP1(i,n)inv[i] = (inv[i-1] + inv[i]) % MOD;
    ll tt = 0;
    REP(i,n)tt = (tt + d[i] * (inv[i+1] + inv[n-i] - 1)) % MOD;
    REP1(i,n)tt = tt * i % MOD;
    cout<<tt<<endl;
}


Measured memory_bytes: 1792
(defmacro defsolver (name vars &body body)
  `(defun ,name ()
     (let (,@(mapcar #'list
            vars
            (mapcar (constantly '(read))
                vars)))
       ,@body)))

(defsolver solution-b (n l)
  (let ((sum (* (/ (+ (* 2 l) n -1) 2) n)))
    (format t "~a~%"
     (cond
	 ((<= (- 1 N) l 0) sum) 
	 ((< l 0) (- sum l n -1))
	 (t (- sum l))))))

(solution-b)

Measured memory_bytes: 15976
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord

main :: IO ()
main = breads >>= main'
    where
        main' [_, k] = breads >>= print . solve k 

-- |
-- >>> solve 3 [-30, -10, 10, 20, 50]
-- 40
-- >>> solve 2 [10, 20, 30]
-- 20
-- >>> solve 1 [0]
-- 0
-- >>> solve 5 [-9, -7, -4, -3, 1, 2, 3, 4]
-- 10
solve :: Int -> [Int] -> Int
solve k xs = search len (tail xs) bs
    where
        (b : bs) = drop (k - 1) xs
        len = calc (head xs) b

        search res (y : ys) (z : zs) = search (min res $ calc y z) ys zs
        search res _ _ = res

        calc minv maxv
            | minv >= 0 = maxv 
            | maxv <= 0 = abs minv
            | otherwise = abs minv + maxv + min (abs minv) maxv


breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

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

int main(){
    int n;
    cin>>n;
    int a[n];

    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    for(int i=n-1;i>0;i--){
        cout<<a[i]<<" ";
    }
    cout<<a[0]<<endl;

    return 0;
}


Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, M, A[1100], B[1100], C[1100], dist[101][101], INF = 1 << 27;

void solve() {
    rep(i, N) {
        rep(j, N)dist[i][j] = INF;
        dist[i][i] = 0;
    }

    rep(i, M)dist[A[i]][B[i]] = dist[B[i]][A[i]] = C[i];

    rep(k, N)rep(i, N)rep(j, N)smin(dist[i][j], dist[i][k] + dist[k][j]);

    int ans = M;
    rep(e, M) {
        int j = A[e], k = B[e], d = C[e], use = 0;
        rep(i, N)rep(l, N) {
            if(dist[i][j] + d + dist[k][l] == dist[i][l]) {
                use = 1;
                goto END;
            }
        }
        END:;
        ans -= use;
    }

    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> N >> M){
        rep(i, M)cin >> A[i] >> B[i] >> C[i], --A[i], --B[i];
        solve();
    }
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, reversed(input().split())))
cs1 = np.cumsum(a1)
cs2 = np.cumsum(a2)
income = [cs1[i]+cs2[n-1-i] for i in range(n)]
print(max(income))

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

int main(){
    int n;
    int ans=0;
    cin >> n;
    vector <int> vec(n);
    rep(i,n){
        cin >> vec.at(i);
    }
    for(int i=1;i<n-1;i++){
        int a=vec.at(i);
        vector <int> v{vec.at(i-1),vec.at(i),vec.at(i+1)};
        sort(v.begin(),v.end());
        if(a==v.at(1)) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> Interval;

template<typename T> T chmin(T &a,T &b){if(a <= b) return 1;else {a = b;return 0;}}
template<typename T> T chmax(T &a,T &b){if(a >= b) return 1;else {a = b;return 0;}}

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}


int N;
const double INF = 1e9;
const int maxn = 1e5+5;
LL dx[maxn];
LL dy[maxn];
LL x[maxn];
LL y[maxn];

double value(double t){

    double xmax = -INF,ymax = -INF;
    double xmin = INF,ymin = INF;

    _for(i,0,N){
        double xx = x[i] + dx[i]*t;
        double yy = y[i] + dy[i]*t;
        chmin(xmin,xx);chmin(ymin,yy);
        chmax(xmax,xx);chmax(ymax,yy);
    }

    return (ymax-ymin)*(xmax-xmin);
}

int main()
{
    cin >> N;

    string s;
    _for(i,0,N){
        cin >> x[i] >> y[i] >> s;
         if(s == "R"){
            dx[i] = 1;
            dy[i] = 0;
        }
         if(s == "L"){
            dx[i] = -1;
            dy[i] = 0;
        }
         if(s == "U"){
            dx[i] = 0;
            dy[i] = 1;
        }
         if(s == "D"){
            dx[i] = 0;
            dy[i] = -1;
        }
    }
    double l = 0;
    double r = INF;



    _for(i,0,200){
        double t1  = (r + 2*l)/3;
        double t2 =  (2*r + l)/3;
        double v1 = value(t1);
        double v2 = value(t2);
        if(v2 > v1) r = t2;
        else l = t1;
    }

    printf("%.9lf\n",value(l));
    
    return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n & 1){
        puts("No");
        return 0;
    }
    n /= 2;
    puts(s.substr(0, n) == s.substr(n, n) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <stdio.h>

int test(int a, int n){
  // printf("(%d, %d)\n", a, n);
  if(n<=0) return 1;
  int b=a;
  do{
    a=b;
    scanf("%d", &b);
    n--;
  }while(a==b && n>0);
  if(n==0) return 1;
  if(a>b){
    do{
      a=b;
      scanf("%d", &b);
      n--;
    }while(a>=b && n>0);
    if(a>=b && n==0) return 1;
    else return test(b, n) + 1;
  }else{
    do{
      a=b;
      scanf("%d", &b);
      n--;
    }while(a<=b && n>0);
    if(a<=b && n==0) return 1;
    else return test(b, n) + 1;
  }
}

int main()
{
  int a, b, c, n, i, f, ans=1;
  scanf("%d", &n);
  scanf("%d", &a);
  printf("%d\n", test(a, n-1));
  return 0;
}

Measured memory_bytes: 2048
#include<iostream>
using namespace std;
#define NUL -1
const int N_MAX = 45;
int root;
struct Node{
    int parent, left, right;
};
Node tree[N_MAX];
int pre[N_MAX], in[N_MAX];

void reConstruct(int parent, int * preP, int * inP, int n, bool isLeft){
    if(n==0) return;
    int nowRoot = preP[0];
    tree[nowRoot].parent = parent;
    //getchar();
    //cout<<"-- nowRoot: "<<nowRoot<<endl;
    if(parent==NUL){
        root=nowRoot;
    }else if(isLeft){
        tree[parent].left=nowRoot;
    }else{
        tree[parent].right=nowRoot;
    }
    if(n==1)return;
    int flag = 0;
    for(;flag<n;flag++){
        if(inP[flag]==nowRoot) break;
    }
    //cout<<"nowRoot: "<<nowRoot<<" flag: "<<flag<<endl;
    reConstruct(nowRoot, preP+1, inP, flag, true);
    reConstruct(nowRoot, preP+1+flag, inP+1+flag, n-flag-1, false);
}

void post(int id){
    if(id==NUL) return;
    if(tree[id].left==NUL&&tree[id].right==NUL&&id!=root){
        cout<<id<<" ";
        return;
    }
    post(tree[id].left);
    post(tree[id].right);
    if(id==root){
        cout<<id<<endl;
    }else{
        cout<<id<<" ";
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>pre[i];
        tree[i].parent=tree[i].left=tree[i].right=NUL;
    }
    tree[n].parent=tree[n].left=tree[n].right=NUL;
    for(int i=0;i<n;i++){
        cin>>in[i];
    }
    reConstruct(NUL, pre, in, n, true);
    /*//Debugging/
    for(int i=1;i<=n;i++){
        cout<<"node"<<i<<": p: "<<tree[i].parent<<"  l: "<<tree[i].left<<"  r: "<<tree[i].right<<endl;
    }
    ///Debugging*/
    post(root);
    //cout<<"root: "<<root<<endl;
    return 0;
}



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

using namespace std;

int main(void)
{
	string S;
	cin >> S;
	
	if(S.size() < 4) cout << "No" << endl;
	else if(S.substr(0, 4) == "YAKI") cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 400005

ll res = 1;
int n, a[maxn];

void solve(){
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    int run = 1;
    int m = 0;
    For(i, 1, n) {
    	cin >> a[i];
    	res = res * (i - m) % mod;
    	if(a[i] >= run) {
    		a[i] = run;
    		run += 2;
    	} else{
    		m++;
    	}
    }
    cout << res << endl;

}

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


Measured memory_bytes: 640
// finish date: 2018/01/19
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000

string changeBase(int N, int b, int digit = -1) {
    string s = "";
    while (N != 0) {
        s = to_string(N % b) + s;
        N /= b;
    }
    if (digit != -1) {
        while (s.length() < digit) {
            s = "0" + s;
        }
    }
    return s;
}

int main() {
    string S;
    cin >> S;
    ll sum = 0;
    string isPlus;
    string str;
    ll temp;
    rep(i, pow(2, S.length() - 1)) {
        str = S[0];
        isPlus = changeBase(i, 2, S.length() - 1);
        rep(j, isPlus.length()) {
            if (isPlus[j] == '1') str += "+";
            str += S[j + 1];
        }
        //cout<<str<<endl;
        temp = 0;
        rep(k, str.length()) {
            if (str[k] == '+') {
                sum += temp;
                temp = 0;
            } else {
                temp *= 10;
                temp += str[k] - '0';
            }
            if (k == str.length() - 1) sum += temp;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for _ in range(K):
        new_A = [0] * (N)
        for i, a in enumerate(A):
            s = i - a
            if s < 0:
                s = 0
            f = i + a + 1
            new_A[s] += 1
            if f < N:
                new_A[f] -= 1
        A = list(accumulate(new_A))
        if min(A) == N:
            break
    print(*A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 177828
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int n, m;

int imos[100010];
int main() {
    //cout << fixed << setprecision(15);
    cin >> n >> m;

    REP(i, m){
        int L, R; cin >> L >> R;
        L--; R--;
        imos[L]++;
        imos[R+1]--;
    }

    for(int i=0; i<n; ++i){
        imos[i+1] += imos[i];
    }

    int ans = 0;
    for(int i=0; i<n; ++i){
        if(imos[i]==m) ans++;
    }
    cout << ans << endl;


    return 0;
}

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

#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

#define len(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int a = h1 * 60 + m1;
    int b = h2 * 60 + m2;
    cout << b - a - k << '\n';
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  int student[n][2];
  for(int i = 0; i< n; i++){
    int a,b;
    cin >> a >> b;
    student[i][0] = a;
    student[i][1] = b;
  }

  int checkpoint[m][2];
  for(int i = 0; i< m; i++){
    int c,d;
    cin >> c >> d;
    checkpoint[i][0] = c;
    checkpoint[i][1] = d;
  }

  for(int i = 0; i<n; i++){
    long int min = 10000000000;
    int num = 0;
    for(int k=0; k < m; k++){
      int manhattan = abs(student[i][0]-checkpoint[k][0]) + abs(student[i][1]-checkpoint[k][1]);
      if(manhattan<min){
        min = manhattan;
        num = k+1;
      }
    }
    cout << num << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int c[][]=new int[8][8];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i=sc.nextInt();
		for(int j = 0; j<i;j++){
			for(int l=0;l<8;l++){
				String s=sc.next();
				for(int p=0;p<8;p++){
					c[p][l]=s.charAt(p)-48;
				}
			}
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			bom(x,y);
			
			System.out.println("Data "+(j+1)+":");
			for(int l=0;l<8;l++){
				for(int p=0;p<8;p++){
					System.out.print(c[p][l]);
				}
				System.out.println();
			}
		}
	}
	
	public static void bom(int x,int y){
		c[x][y]=0;
		for(int i=0;i<7;i++){
			if((x-3+i)<0 || (x-3+i)>7)continue;
			if(c[x-3+i][y]==1)bom(x-3+i,y);
		}
		for(int i=0;i<7;i++){
			if((y-3+i)<0 || (y-3+i)>7)continue;
			if(c[x][y-3+i]==1)bom(x,y-3+i);
		}
	}

}

Measured memory_bytes: 26160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[][] A = new long[n+1][2];
        A[0] = new long[]{1L,1L};
        for (int i = 1; i <= n; i++) {
            long t = sc.nextLong();
            long a = sc.nextLong();
            long m = Math.max((A[i-1][0] +t -1) /t, (A[i-1][1] +a -1) /a);
            A[i][0] = t * m;
            A[i][1] = a * m;
        }

        System.out.println(A[n][0] + A[n][1]);
        sc.close();
    }

}


Measured memory_bytes: 26064
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int calc(int x){
    if(x==0){
        return 0;
    }
    //cout << x << endl;
    int a=0;
    int tmp=x;
    while(tmp>0){
        a+=tmp&1;
        tmp>>=1;
    }

    return calc(x%a)+1;
}

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

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

    string X;
    cin >> X;
    int a=0;
    for(int i=0; i<N; i++){
        if(X[i]=='1'){
            a++;
        }
    }

    int a0=a+1;
    int a1=max(1,a-1);
    int r0=0;
    int r1=0;
    vector<int> fact0(N+1,1);
    vector<int> fact1(N+1,1);
    for(int i=0; i<N; i++){
        if(X[N-1-i]=='1'){
            r0=(r0+fact0[i])%a0;
            r1=(r1+fact1[i])%a1;
        }
        fact0[i+1]=2*fact0[i]%a0;
        fact1[i+1]=2*fact1[i]%a1;
    }

    //cout << r << endl;
    //cout_vec(fact);

    for(int i=0; i<N; i++){
        if(X[i]=='0'){
            cout << calc((r0+fact0[N-1-i])%a0)+1 << '\n';
        }else{
            if(a==1){
                cout << 0 << '\n';
            }else{
                cout << calc(((r1-fact1[N-1-i])%a1+a1)%a1)+1 << '\n';
            }
        }
    }
}

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

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


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

def main():
    s = input().strip()
    S = [int(i) for i in s]
    n1 = 0
    n2 = 0
    for i,v in enumerate(S):
        if i%2 == 0:
            if v == 0:
                n1 += 1
            else:
                n2 += 1
        else:
            if v == 1:
                n1 += 1
            else:
                n2 += 1
    print(min(n1,n2))
if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::string;

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

}

Measured memory_bytes: 3624
s= input()[::-1]
mods= [0] * 2019
mods[0] = 1
num=0
d = 1
for c in s:
    num += int(c) * d
    num %= 2019
    d *= 10
    d %= 2019
    mods[num] += 1

ans = 0
for cnt in mods:
    ans += cnt * (cnt - 1) // 2

print(ans) 

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

int main(){
    int N,K;
    vector<int> p;
    cin>>N>>K;
    for(int i=0;i<N;i++){
        int temp;
        cin>>temp;
        p.push_back(temp);
    }
    sort(p.begin(),p.end());
    long long sum=0;
    for(int i=0;i<K;i++){
        sum+=p[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, T, E, A[N];
long long dp[N];
int main()
{
    scanf("%d%d%d", &n, &E, &T);
    for (int i = 1; i <= n; i++)
        scanf("%d", &A[i]);
    int r = 1;
    long long Mn = 1e18;
    for (int i = 1; i <= n; i++)
    {
        while ((A[i] - A[r]) * 2 >= T)
            Mn = min(Mn, dp[r - 1] - A[r] * 2), r ++;
        dp[i] = min(dp[r - 1] + T, Mn + A[i] * 2);
    }
    return !printf("%lld\n", dp[n] + E);
}

Measured memory_bytes: 1408
K=int(input())
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[K-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using ld = long double;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
    #define rrep(i, n) for (int i = 1; i < (int)(n + 1); i++)
    // vector<vector<int>> A(3, vector<int>(4));
    int main() {
        int A,B;
        cin>>A>>B;
        string S;
        cin>>S;
        bool ans=true;
        rep(i,A+B+1){
            if(i!=A){
                if(48<=int(S[i])&&int(S[i])<=57){
                }
                else{
                    ans=false;
                    break;
                }
            }
            else{
                if(S[i]!='-'){
                    ans=false;
                    break;
                }
            }
        }
        if(ans==true){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }

Measured memory_bytes: 3576
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 100001;
const int mod = 1000000007;

int a[MAXN];
ll dp[101][MAXN];

int main(){
    int n,k;
    cin>>n>>k;
    fr(i,n)cin>>a[i];

    for(int i = 0; i <= k; i++){
        dp[0][i] = (i <= a[0]);
    }

    for(int i = 1; i < n; i++){
        dp[i][0]  = 1;

        for(int c = 1; c <= a[i]; c++){
            dp[i][c] = (dp[i-1][c] + dp[i][c-1])%mod;
        }
        for(int c = a[i]+1;  c <= k; c++){
            dp[i][c] = (dp[i-1][c] + dp[i][c-1] - dp[i-1][c-a[i]-1] + mod)%mod;
        }
    }
    cout<< dp[n-1][k] << endl;

}


Measured memory_bytes: 78336
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
using namespace std;

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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

uint gcd_of_vector(uint A[100000], int begin, int end){
  uint result = A[begin];
  for(int i=begin;i<end;i++){
    result = gcd(A[i],result);
  }
  return result;
}

uint gcd_of_vector_with_skip(uint A[100000], int skip, uint size){
  uint result = A[0];
  if(skip==0)result=A[1];
  for(uint i=1;i<size;i++){
    if(i==skip)continue;
    result = gcd(A[i],result);
  }
  return result;
}

int main() {
  uint N=getint();
  uint A[100000];
  for(int i=0;i<N;i++)A[i]=getint();

  if(N>=100){
    cout<<max(gcd_of_vector(A,0,N/2),gcd_of_vector(A,N/2,N))<<"\n";
  }else{
    uint ans=0;
    for(int i=0;i<N;i++){
      ans=max(ans,gcd_of_vector_with_skip(A,i,N));
    }
    cout<<ans<<"\n";
  }
  return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	vint X(5); cin >> X;
	for (int i = 0; i < 5; i++) {
		if (X[i] == 0) {
			cout << i+1 << endl;
			break;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3640
def dot3(O, A, B):
  ox, oy = O
  ax, ay = A
  bx, by = B
  return (ax - ox) * (bx - ox) + (ay - oy) * (by - oy)

def cross3(O, A, B):
  ox, oy = O
  ax, ay = A
  bx, by = B
  return (ax - ox) * (by- oy) - (bx - ox) * (ay - oy)

def dist2(A, B):
  ax, ay = A
  bx, by = B
  return (ax - bx)**2 + (ay - by)**2

def is_intersection(p0, p1, q0, q1):
  c0 = cross3(p0, p1, q0)
  c1 = cross3(p0, p1, q1)
  d0 = cross3(q0, q1, p0)
  d1 = cross3(q0, q1, p1)
  if c0 == c1 == 0:
    e0 = dot3(p0, p1, q0)
    e1 = dot3(p0, p1, q1)
    if not e0 < e1:
      e0, e1 = e1, e0
    return e0 <= dist2(p0, p1) and 0 <= e1
  return c0 * c1 <= 0 and d0 * d1 <= 0

for q in range(int(input())):
  x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
  print(+is_intersection((x0, y0), (x1, y1), (x2, y2), (x3, y3)))



Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back      
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define buli(x) __builtin_popcountll(x)
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define M 1000000007
#define N 211111

#define TASK "1"

using namespace std;

int n, a[N], q[N];

int main(){
	#ifdef home
		freopen(TASK".in","r",stdin);	
		freopen(TASK".out","w",stdout);
	#endif		
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	int h = 1;

	int ba = 0;
	for (int i = 0; i < n; i++) {
		q[h]++;

		int em = a[i] - (i + 1);
		int t = (i + 1) - em;

		while (t - ba > 1) {
			h++;
			ba += 2;
		}
	}	
//	for (int i = 1; i <= n; i++) cout << q[i] << endl;
	int ans = 1;
	int s = 0;
	for (int i = 1; i <= n; i++) {
		s += q[i];
		ans = (ans * 1ll * s) % M;
		s--;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const long long MOD=1000000007;

long long add_mod(long long x,long long y){
	return (x+y)%MOD;
}

long long sub_mod(long long x,long long y){
	return (x-y+MOD)%MOD;
}

long long mul_mod(long long x,long long y){
	return x*y%MOD;
}

int n;
long long dp[100001];

void solve(){
    long long i,j;
    string str;
    long long x;
    cin >> n >> x;
    vector<long long> s(n);
    for(i = 0;i < n;i++) cin >> s[i];
    sort(s.begin(),s.end());
    dp[x] = 1;
    for(i = s.size()-1;i >= 0;i--){
        for(j = 0;j <= 100000;j++){
            if(j >= s[i]){
                dp[j%s[i]] = add_mod(dp[j%s[i]],dp[j]);
                dp[j] = mul_mod(dp[j],i);
            }
            else{
                dp[j] = mul_mod(dp[j],i+1);
            }
        }
    }
    long long ans = 0;
    for(i = 0;i <= 100000;i++) ans = add_mod(ans,mul_mod(dp[i],i));
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  char A;
  cin >> A;
  cout << (A == tolower(A) ? 'a' : 'A') << endl;

  return 0;
}


Measured memory_bytes: 3612
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;
 
int N,M;

string ans;
 
void solve(){
	if(N==M){
		ans = "Yes";
		return;
	}
	ans = "No";
}
 
int main(){
	cin>>N>>M;

	solve();

	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))

int main(){
	int n,i,a=0,b=0,ans=20000000;
	char s[200001];
	scanf("%d%s",&n,s);
	int ff=0,f=0;
	for(i=0;i<n;i++){
		if(s[i]=='#')b++;
		else a++;
	}
	ans=min(a,b);
	int w=0,bb=0;
	for(i=0;i<n;i++){
		if(s[i]=='#')bb++;
		else w++;
		ans=min(ans,bb+(a-w));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (A, B) = read!(i64, i64);
    if (A + B) % 2 != 0 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", (A + B) / 2);
    }
}


Measured memory_bytes: 4352