akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

const int N = int(2e5)+10;
const int K = int(1e6)+10;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 2e18;

// const ll MOD = 1e9 + 7;
// inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
// inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

int cnt[K],ans[N],f_cnt[K];
ii a[N];

void solve () {
    int n;cin>>n;
    for (int i=1;i<=n;i++) {
        int x;cin>>x;
        a[i] = {x,i};
        f_cnt[x]++;
    }
    int ret = 0;
    for (int i=1;i<=n;i++) {
        int x = a[i].first;
        if (x == 1) {
            if (f_cnt[1] == 1) ret++;
            continue;
        }
        bool ok = true;
        if (f_cnt[1] > 0 || f_cnt[x] > 1)  continue;
        for (int j=2;j*j<=x;j++) {
            if (x%j != 0) continue;
            int num = x/j;
            if (f_cnt[num] || f_cnt[j]) {
                ok = false;
                break;
            }
        }
        ret += ok;
    }
    cout<<ret<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

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

int main(){
  ll n; cin>>n;
  vector<ll> num(n*3);
  for(ll i=0;i<3*n;i++){
    cin>>num[i];
  }
  sort(num.begin(),num.end());
  ll ans=0,now=n*3-2;
  while(n!=0){
    n--;
    ans+=num[now];
    now-=2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import collections


# In[26]:


N = int(input())
clist = input()


# In[27]:


c = collections.Counter(clist)
cr = c["R"]
# mylist = [x for x in clist]
# mylist_r = list(reversed(mylist))
# ans = 0
# while mylist[:cr].count("R") != cr:
#     W_i = mylist.index("W")
#     R_i = mylist_r.index("R")
#     mylist[W_i] = "R"
#     mylist[N-R_i-1] = "W"
#     mylist_r[N-W_i-1] = "R"
#     mylist_r[R_i] = "W"
#     ans += 1
# print(ans)
ans = clist[:cr].count("W")
print(ans)


# In[ ]:






Measured memory_bytes: 9776
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	string S;
	cin >> S;
	int cnt[3] = {};
	rep(i,3){
		rep(j,S.size()){
			if(S[j] == 'a'+i){
				cnt[i] ++;
			}
		}
	}
	int m=cnt[0],M=cnt[0];
	rep(i,3){
		m = min ( m , cnt[i] );
		M = max ( M , cnt[i] );
	}
	if(M-m <= 1)puts("YES");
	else puts("NO");
}



Measured memory_bytes: 764
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

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

  int n;
  cin >> n;
  ll ans = 1e9;
  FOR(i,1,n){
    int a = i;
    int b = n-i;
    int a_val = 0, b_val = 0;
    while(a > 0){
      a_val += a%10;
      a /= 10;
    }
    while(b > 0){
      b_val += b%10;
      b /= 10;
    }
    ans = min(ans, (ll)a_val+b_val);
    //if(i == 50000) cout << "i:" << i << " " << a_val << " " << b_val<< endl;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N,L;
  cin>>N>>L;
  int R = L+N-1;

  int eat;
  if(L>0) eat=L;
  else if(R<0) eat=R;
  else eat=0;

  int answer = (R+L)*N/2 - eat;
  cout<<answer<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
ll n,k;
struct Mat{
    mint val[55][55];
    Mat(){
        rep(i,55){
            rep(j,55){
                val[i][j]=0;
            }
        }
    }
};
Mat operator*(Mat a,Mat b){
    Mat c;
    rep(i,n){
        rep(j,n){
            rep(k,n){
                c.val[i][j]+=a.val[i][k]*b.val[k][j];
            }
        }
    }
    return c;
}
Mat I;
Mat power_Mat(Mat a,ll k){
    if(k==0)return I;
    Mat res;
    res=power_Mat(a,k/2);
    res=res*res;
    if(k&1)res=res*a;
    return res;
}
int main(){
    cin>>n>>k;
    Mat a;
    rep(i,n){
        I.val[i][i]=1;
    }
    rep(i,n){
        rep(j,n){
            cin>>a.val[i][j].x;
        }
    }
    Mat res=power_Mat(a,k);
    mint ans=0;
    rep(i,n){
        rep(j,n){
            ans+=res.val[i][j];
        }
    }
    cout<<ans.x<<endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB") {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

int main(void)
{
    short int n;
    cin>>n;
    int one = n%10;

    if(one==3) cout<<"bon"<<endl;
    else if(one==2 || one==4 || one==5 || one==7 || one==9) cout<<"hon"<<endl;
    else cout<<"pon"<<endl;
}

Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val (T, A) = readLine()!!.split(" ").map(String::toInt)
    val H = readLine()!!.split(" ").map(String::toInt)

    var min: Double = 10e9
    var minIndex: Int? = null

    H.forEachIndexed { i, h ->
        val c = Math.abs(A - (T - h * 0.006))
//        println("$A-($T -$h * 0.006)")
//        println(c)
        if (min > c) {
            min = c
            minIndex = i
        }
    }
    println(minIndex!! + 1)
}

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

int main() {
    int a;
    int b;
 
   cin >> a >> b;
  
     int ans = 0;
  
      ans = b;
  
       
     for (int i = 1; i < a; ++i) {
       
       int c = b - 1;
       
     
       
       ans = ans*c;
       
     }
  
  
   cout << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100010],b[100010];

int main() {
	ll n,t;
	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll MAX=0;
	for(int i=n-1;i>=0;i--){
		MAX=max(MAX,a[i]);
		b[i]=MAX;
	}
	MAX=b[0]-a[0];
	ll ans=0;
	for(int i=0;i<n;i++){
		ll now=b[i]-a[i];
		if(MAX==now){
			ans++;
		}
		if(now>MAX){
			ans=1;
			MAX=now;
		}
	}
	cout<<ans;
	return 0;
}

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

#define llong long long 
#define inf 9999999999
int N, M;
llong int D[1001];
llong int C[1001];
llong int score[1001][1000][2];

llong int solve(int day, int now, llong int wry, int go){
	//cout << day << " " << now << " " << wry << " " << score[day][now][go] << endl;
	if(score[day][now][go] != inf) return score[day][now][go];
	// if(day > M)return inf;
	if(day + (N - now) > M) return inf;
	if(now == N){
		if(score[day][now][go] > wry) return score[day][now][go] = wry;
		else return inf;
	}

	llong int ret = inf;
	ret = min(ret, solve(day + 1, now, 0, 0) + wry);
	llong int walk = D[now + 1] * C[day + 1];
	ret = min(ret, solve(day + 1, now + 1, walk, 1) + wry);

	return score[day][now][go] = ret;
}

int main(){
	fill_n(D, 1000, -1);
	fill_n(C, 1001, -1);
	fill_n(**score, 1001 * 1000 * 2, inf);
	cin >> N >> M;
	for(int i = 1; i <= N; i++){
		cin >> D[i];
	}
	for(int i = 1; i <= M; i++){
		cin >> C[i];
	}

	cout << solve(0, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 18796
N = int(input())
S = sorted([int(input()) for i in range(N)])

tot = sum(S)
if tot % 10 != 0:
    print(tot)
else:
    p = 0
    for val in S:
        if val % 10 != 0:
            p = val
            break
    if p != 0:
        print(tot - p)
    else:
        print(0)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}
ll modexpo(ll a, ll b, ll m) {if (b == 0) {return 1;} else if (a == 1) {return 1;} if (b % 2 == 0) {ll t = modexpo(a, b / 2, m); t = (t * t) % m; return t;} else {ll t = modexpo(a, b / 2, m); t = (t * t) % m; t = (t * a) % m; return t;}}




int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll a, b, n;
	cin >> a >> b >> n;
	// for (int i = 1; i <= n; i++) {
	// 	int k1 = int((floor(((double)(a) * i) / b)));
	// 	int k2 = a * int((floor((double)(i) / b)));
	// 	cout << i << " " << (k1 - k2) << endl;
	// }

	ll i = min(b - 1, n);
	ll k1 = (ll)((floor(((double)(a) * i) / b)));
	ll k2 = a * (ll)((floor((double)(i) / b)));
	cout << (k1 - k2) << endl;

}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ;
const int inf = 1e9 + 7 ; 
int n, cnt, S, T, head[N], cur[N], dep[N], P[N], Q[N] ; 
struct E { int to, next, w ; } e[N << 1] ;
void add( int x, int y, int z ) {
	e[++ cnt] = (E){ y, head[x], z }, head[x] = cnt,
	e[++ cnt] = (E){ x, head[y], 0 }, head[y] = cnt ; 
}
queue<int> q ; 
bool bfs() {
	memset( dep, 0, sizeof(dep) ), q.push(S), dep[S] = 1 ; 
	while( !q.empty() ) {
		int u = q.front() ; q.pop() ; 
		Next( i, u ) {
			int v = e[i].to ; 
			if( e[i].w && !dep[v] )
			dep[v] = dep[u] + 1, q.push(v) ;
		}
	}
	return ( dep[T] != 0 ) ;
}
int dfs( int x, int dist ) {
	if( x == T || dist == 0 ) return dist ; int flow = 0 ; 
	for( re int &i = cur[x]; i; i = e[i].next ) {
		int v = e[i].to ; 
		if( e[i].w && ( dep[v] == dep[x] + 1 ) ) {
			int d = dfs( v, min( dist, e[i].w ) ) ;
			flow += d, dist -= d, e[i].w -= d, e[i ^ 1].w += d ;
			if( dist == 0 ) break ; 
		}
	} return flow ; 
}
int dinic() {
	int ans = 0 ;
	while( bfs() ) {
		memcpy( cur, head, sizeof(head) ) ; int di = 1 ; 
		while( di = dfs( S, inf ) ) ans += di ;
	} return ans ; 
}
int p[N], q1[N], idnex ; 
signed main()
{
    n = gi(), S = ++ idnex, cnt = 1, T = ++ idnex ;
    rep( i, 1, n ) P[i] = gi() + 1 ;
    rep( i, 1, n ) Q[i] = gi() + 1 ; 
    rep( i, 1, n ) {
        if( p[i] ) continue ; 
        int u = i ; ++ idnex ; 
        while( !p[u] ) p[u] = idnex, u = P[u] ; 
    }
    rep( i, 1, n ) {
        if( q1[i] ) continue ; 
        int u = i ; ++ idnex ;
        while( !q1[u] ) q1[u] = idnex, u = Q[u] ; 
    } 
    int Ans = n ; 
    rep( i, 1, n ) {
        if( P[i] != i && Q[i] != i ) {
            add( q1[i], p[i], 1 ) ;
            if( P[i] == Q[i] ) add( p[i], q1[i], 1 ) ;
        }
        else if( P[i] == i && Q[i] == i ) -- Ans ;
        else if( P[i] == i ) add( q1[i], T, 1 ) ;
        else if( Q[i] == i ) add( S, p[i], 1 ) ;
    }
    Ans -= dinic() ;
    printf("%lld\n", Ans ) ;
	return 0 ;
}

Measured memory_bytes: 18816
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
 
	public static void main(String[] args) {
		new Main();	
	}
 
	public Main() {
		new A().doIt();
	}
	class A{
		void doIt(){
			while(true){
				int n = sc.nextInt();
				if(n == 0)break;
				int num = 0;
				double ans = 1000000;
				for(int i = 0;i < n;i++){
					int num2 = sc.nextInt();
					double m = sc.nextDouble();
					double kg = sc.nextDouble();
					double bmi = (kg / (m * m))*10000;
					if(22 - bmi < 0)bmi = bmi - 22;
					else bmi = 22 - bmi;
					if(ans > bmi){
						ans = bmi;
						num = num2;
					}else if(ans == bmi){
						num = Math.min(num, num2);
					}
				}
				System.out.println(num);
			}
		}
	}
}

Measured memory_bytes: 46084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    int tmp = 0;
    int ans = 1;
    REP(i,n+1) {
        int x = i; int ct = 0;
        while (x % 2 == 0) {
            x /= 2;
            ct++;
        }
        if (chmax(tmp,ct)) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
const int N=100005;
int n,sum,a[N],b[N];
int main()
{
	int x;
	n=read();
	for(RI i=1;i<=n;++i) a[i]=b[n-i+1]=1+(i-1)*(n+1);
	sum=(n-1)*(n+1)+2;
	for(RI i=1;i<=n;++i) x=read(),a[x]+=sum+i-1-a[x]-b[x];
	for(RI i=1;i<=n;++i) printf("%d ",a[i]);
	puts("");
	for(RI i=1;i<=n;++i) printf("%d ",b[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007

using namespace std;

string s;

int main() {
	cin >> s;
	cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
	
	return 0;
}


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

long long cmb(long i){
    return i*(i-1)/2;
}

int main()
{
    char s[2000001];
    cin >> s ;
    long len;
    len = strlen(s);
    long long sum = 1+cmb(len);
    long long count[26]={0};
    for(long i=0;i<len;i++){
        count[(int)s[i]-97]+=1;
    }
    for(int k=0;k<26;k++){
        sum-=cmb(count[k]);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 384
// Medha's code  :


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double dd;
#define fastio ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 0x3f3f3f3f3f
#define MOD 1000000007

int main() {

    fastio;

    ll n , k;
    vector<ll> a(100005);
    vector<ll> dp(100005);
    ll flag = 0;
    vector<bool> visited(100005);

    cin >> n >> k;

    for( ll i = 1 ; i <= n ; i++)
    {
        cin >> a[i];
        dp[a[i]] = 1;
        visited[a[i]] = true;
    }

    for( ll i = 1 ; i < a[1] ; i++)
    {
        dp[i] = 2;
    }

    for( ll i = a[1]+1 ; i <= k ; i++)
    {
        if(visited[i]) continue;
        for( ll j = 1 ; j <= n ; j++)
        {
            if( (i-a[j]) >0 && dp[i-a[j]]==2)
            {
                dp[i] = 1;
                flag = 1;
                break;
            }
        }

        if(flag !=1)
        {
            dp[i]=2;
        }
        flag = 0;
    }

    if(dp[k] == 1) cout << "First";
    else cout << "Second";


    return 0;
}


Measured memory_bytes: 1792
X, K, D = map(int, input().split())


def f(x):
    return X + (2 * x - K) * D


if f(0) >= 0:
    print(f(0))
    exit()

if f(K) <= 0:
    print(-f(K))
    exit()

left = 0
right = K
while right - left > 1:
    mid = int((right + left) / 2)
    if f(mid) < 0:
        left = mid
    else:
        right = mid

print(min(-f(left), f(right)))


Measured memory_bytes: 9164
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

//
// func nextInt() int {
// 	l := nextLine()
// 	i, e := strconv.Atoi(l)
// 	if e != nil {
// 		panic(e)
// 	}
// 	return i
// }

func main() {
	//sc.Split(bufio.ScanWords)
	_, S := nextLine(), nextLine()

	fmt.Printf("%d\n", ABC098B(S))
}

// ABC098B ...
func ABC098B(S string) (res int) {
	for i := 1; i < len(S)-1; i++ {
		chars, checked, cnt := map[string]bool{}, map[string]bool{}, 0
		for j := 0; j < len(S); j++ {
			c := string(S[j])
			if j < i {
				chars[c] = true
			} else {
				_, exists := chars[c]
				_, isChecked := checked[c]
				if exists && !isChecked {
					cnt++
				}
				checked[c] = true
			}
		}

		if res < cnt {
			res = cnt
		}
	}

	return
}


Measured memory_bytes: 1956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int h, w, k, ans = 0;
  cin >> h >> w >> k;
  string c[h];
  rep(i, h) cin >> c[i];
  for (int bith = 0; bith < (1 << h); ++bith) {
    for (int bitw = 0; bitw < (1 << w); ++bitw) {
      int cnt = 0;
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
          if (bitw & (1 << j)) {    // 列挙に i が含まれるか
            if (bith & (1 << i)) {  // 列挙に i が含まれるか
              if (c[i][j] == '#') cnt++;
            }
          }
        }
      }
      if (cnt == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
object Main extends App {
  val src = io.Source.stdin.getLines.next.toInt

  def addInterest(w: Int, org: Int): Int = {
    if (w == 0) org
    else addInterest(w - 1, (org*1.05).ceil.toInt)
  }

  println(addInterest(src, 100)*1000)
}

Measured memory_bytes: 43688
from functools import *
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline


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


def II():
    return int(input())




N = int(input())
A = []
for i in range(N):
    A.append(II())


if A[0] >0:
    print(-1)
    sys.exit()

for i in range(1, N):
    if A[i]-A[i-1] > 1:
        print(-1)
        sys.exit()

count = 0
x = [0]*N

for i in range(0,N-1):
    if A[i]+1==A[i+1]:
        count+=1
    else:
        count+=A[i+1]

""" for i in reversed(range(N)):
    if A[i] != x[i]:
        for j in range(i-A[i], i):
            x[j+1] = x[j]+1
            count += 1

 """
print(count)


Measured memory_bytes: 52828
#include<bits/stdc++.h>
using namespace std;
int a[55];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			sum+=(a[i]*a[j]);
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

int main(void){
	int n;
	int a,b;
	int s;
	string str;
	cin >> n;
	getline(cin,str);
	for(a=0;a<n;a++){
		getline(cin,str);
        s=str.size();
		for(b=0;b<s;b++){
			if(str[b]=='H' && str[b+1]=='o' && str[b+2]=='s' && str[b+3]=='h' && str[b+4]=='i' && str[b+5]=='n' && str[b+6]=='o')str[b+6]='a';
		}
		cout << str << endl;

	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>
#include <set>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 500000000  //
#define INFLL 1000000000000000000  //
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int length = x - z;
    cout << length / (y + z) << endl;
    return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
long long a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    cin >> n;
    vl p(n + 1);
    p[0] = 2, p[1] = 1;
    FOR(i, 2, n)
    {
        p[i] = p[i - 2] + p[i - 1];
    }
    pr(p[n]);
    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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 pid_t pid = getpid();
// Problem Specific Parameter:

const ll inf = 100000;

void calc(ll d, ll x) {
	for(ll b = -inf + 1; b <= inf; ++b) {
		const ll a = b + d;
		ll val = 0LL;
		val += a * a * a * a;
		val += a * a * a * b;
		val += a * a * b * b;
		val += a * b * b * b;
		val += b * b * b * b;

		if (val  == x / d) {
			cout << a << " " << b << endl;
			exit(0);
		}
	}
}

int main(void){
	ll x;
	cin >> x;

	for(ll i = 1; 1LL * i * i <= x; ++i) {
		if(x % i) continue;
		calc(i, x);
		calc(-i, x);
		calc(x / i, x);
		calc(- x / i, x);
	}
	
 	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);	
	int a, b;
	cin >> a >> b;
	string s1, s2;
	for(int i=0; i<b; ++i) s1.push_back(char(a+'0'));
	for(int i=0; i<a; ++i) s2.push_back(char(b+'0'));
	cout << string(min(s1, s2)) << endl;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int[] p = cin.ArrayInt(n);
			int[] indexes = new int[n];
			for (int i = 0; i < n; i++) {
				indexes[p[i] - 1] = i;
			}

			long ans = 0;
			var temp = new SortedList<int, int>(n);
			for (int i = n - 1; i >= 0; --i) {
				int index = indexes[i];
				temp.Add(index, index);
				int l1 = -1;
				int l2 = -1;
				int r1 = n;
				int r2 = n;

				int current = index;
				int currentIndex = temp.IndexOfKey(index);
				if (currentIndex - 1 >= 0) {
					l1 = temp.Keys[currentIndex - 1];
				}

				if (currentIndex - 2 >= 0) {
					l2 = temp.Keys[currentIndex - 2];
				}

				if (currentIndex + 1 < temp.Count()) {
					r1 = temp.Keys[currentIndex + 1];
				}

				if (currentIndex + 2 < temp.Count()) {
					r2 = temp.Keys[currentIndex + 2];
				}

				int rangeL1 = current - l1;
				int rangeL2 = l1 - l2;
				int rangeR1 = r1 - current;
				int rangeR2 = r2 - r1;

				ans += (i + 1) * ((long)rangeL2 * rangeR1 + (long)rangeR2 * rangeL1);
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 20192
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int ans = 0;

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    Arrays.sort(a);

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

    System.out.println(ans);

  }
}

Measured memory_bytes: 35804
N,K,Q = list(map(lambda x: int(x),input().split()))

lst = [K-Q]*N

for i in range(Q):
    x = int(input())
    lst[x-1] += 1

for i in range(N):
    if lst[i]>0:
        print("Yes")
    else:
        print("No")


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

using namespace std;

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

int main(int argc, char const *argv[]){
	int foods, people, item_num, tmp, ans;
	while(cin >> people >> foods){
		ans = 0;
		bool foods_ch[foods + 5];
		bool foods_ch_tmp[foods + 5];
		for (int i = 1; i <= foods + 5; ++i){
			foods_ch[i] = true;
			foods_ch_tmp[i] = false;
		}

		for (int i = 0; i < people ; ++i){
			cin >> item_num;
			for (int j = 0; j < item_num; ++j){
				cin >> tmp;
				foods_ch_tmp[tmp] = true;
			}
			for (int j = 1; j <= foods; ++j){
				if (foods_ch_tmp[j] == false){
					foods_ch[j] = false;
					//cout << "j: " << j << endl;
				}
			}

			for (int j = 1; j <= foods + 5; ++j)
				foods_ch_tmp[j] = false;
		}

		for (int i = 1; i <= foods; ++i){
			if (foods_ch[i]){
				ans++;
				//cout << "---" << i << endl;
			}	
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
open System
open System.Collections.Generic

let n, m =
    let l = Console.ReadLine().Split(' ') |> Array.map int
    l.[0], l.[1]

let connectedCondition: Map<int, ResizeArray<int>> =
    let condition =
        seq { for i in 0 .. n - 1 do
                (i, new ResizeArray<int>())
        }
        |> Map

    for i in 1 .. m do
        let a, b =
            let l = Console.ReadLine().Split(' ') |> Array.map int
            l.[0] - 1, l.[1] - 1
        condition.[a].Add(b)
        condition.[b].Add(a)

    condition

let path = Array.init n (fun i -> if i = 0 then 0 else -1)

let q = Queue<int>()
q.Enqueue(0)
let mutable cnt = 0
while q.Count <> 0 do
    let i = q.Dequeue()
    for j in connectedCondition.[i] do
        if path.[j] = -1 then
            cnt <- cnt + 1
            q.Enqueue(j)
            path.[j] <- i

if cnt = n - 1 then
    Console.WriteLine "Yes"
    for i in 1 .. n - 1 do
        Console.WriteLine (path.[i] + 1)
else
    Console.WriteLine "No"

Measured memory_bytes: 54560
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		int
			n,		//入力件数
			b,		//棟
			f,		//階
			r,		//部屋
			v;		//入居者
			
		int[][][]
			house	= new int[4][3][10];	//記録用配列（4棟3階10部屋分の入居者数(v)を格納）
			
		String
			output;							//出力する文字列
			
		String[]
			input	= new String[4];		//入力(b,f,r,v)を格納する
		
		
		n = Integer.parseInt(sc.nextLine());		//入力件数の入力
		
		for(int i=0;i<n;i++){
			
			//各情報の入力
			input = sc.nextLine().split("[\\s]+");
			b = Integer.parseInt(input[0]);
			f = Integer.parseInt(input[1]);
			r = Integer.parseInt(input[2]);
			v = Integer.parseInt(input[3]);
			
			//入力データを記録用配列に合わせ、入居者を加算
			house[b - 1][f - 1][r - 1] += v;
		}
		
		//表示処理
		for(b = 0;b < 4;b++){
			
			for(f = 0;f < 3;f++){
				
				output = "";
				for(r = 0;r < 10;r++){
					
					//数字の前にスペースを入れる
					output += " " + house[b][f][r];
				}
				//出力
				System.out.println(output);
				
			}
			//棟が変わる場合#を20個入れる(最後の行には入れないように)
			if(b < 3){
				System.out.println("####################");
			}
		}
	}
}



Measured memory_bytes: 27468
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        if (line.equals("1")) {
            System.out.println("Hello World");
        } else {
            String line2 = sc.nextLine();
            String line3 = sc.nextLine();    
            int a = Integer.parseInt(line2);
            int b = Integer.parseInt(line3);
            System.out.println(a+b);
            
        }
        sc.close();
    }
}


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

bool prime(int x){
    if(x==1)return false;
    for(int i=2; i<=pow(x,0.5); i++){
        if(x%i==0)return false;
    }
    return true;
}

int like2017(int j){
  if(prime((j+1)/2) && prime(j)){return 1;}
  return 0;
}

int main() {
  int n; cin>>n;
  int l,r;
  vector<int> v(50000);
  rep(i,50000){
    if(i==0){v[0]=like2017(1);}
    else{v[i]=v[i-1]+like2017(2*i+1);}
  }
  rep(i,n){
    cin>>l>>r;
    if(l==1){cout<<v[(r-1)/2]<<endl;}
    else{cout<<v[(r-1)/2]-v[(l-3)/2]<<endl;}
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) *min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) *max_element(v.begin(), v.end())
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> a, b;

int main()
{
  int n, t, premin = MOD;
  cin>>n>>t;
  REP(i,n) {
    int tmp;
    cin>>tmp;
    a.push_back(tmp);
    if (i>0) {
      premin = min(premin, a[i-1]);
      b.push_back(tmp-premin);
    }
  }

  cout<<count(b.begin(), b.end(), MAX_ELEMENT(b))<<endl;

  return 0;
}


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

int main()
{
   int l,r,d,cnt=0;
   cin>>l>>r>>d;

   for(int i=l;i<=r;i++)
   {
       if(i%d == 0)
       {
           cnt++;
       }
   }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#define n 100000

int Partition(int *, int, int);

int main(){
  int A[n], A_len, q, i;

  scanf("%d",&A_len);
  for(i = 0; i < A_len; i++) scanf("%d",&A[i]);

  q = Partition( A, 0, A_len-1);
  for(i = 0; i < q; i++) printf("%d ",A[i]);
  printf("[%d] ",A[q]);
  for(i = q+1; i < A_len-1; i++) printf("%d ",A[i]);
  printf("%d\n",A[A_len-1]);

  return 0;
}

int Partition(int *A, int p, int r){
  int i, j, x;

  i = p-1;
  for(j = p; j < r; j++){
    if( A[j] <= A[r] ){
      i++;
      x = A[i];
      A[i] = A[j];
      A[j] = x;
    }
  }
  x = A[i+1];
  A[i+1] = A[r];
  A[r] = x;

  return i+1;
}



Measured memory_bytes: 2244
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint n, k;

const int FACT_MAX = 600005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

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

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint divide(llint n, llint r)
{
	return comb(n+r-1, n);
}


int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> n >> k;
	if(n <= k){
		cout << divide(n, n) << endl;
		return 0;
	}
	
	llint ans = 0;
	for(int i = 0; i <= k; i++){
		ans += comb(n, i) * divide(i, n-i) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 9600
S = input()
if S[0]=='R' and S[1]=='R' and S[2]=='R':
    print('3')
if S[0]=='R' and S[1]=='R' and S[2]=='S':
    print('2')
if S[0]=='S' and S[1]=='R' and S[2]=='R':
    print('2')
if S[0]=='R' and S[1]=='S' and S[2]=='R':
    print('1')
if S[0]=='R' and S[1]=='S' and S[2]=='S':
    print('1')
if S[0]=='S' and S[1]=='R' and S[2]=='S':
    print('1')
if S[0]=='S' and S[1]=='S' and S[2]=='R':
    print('1')
if S[0]=='S' and S[1]=='S' and S[2]=='S':
    print('0')


Measured memory_bytes: 9092
<?php
  
 	fscanf(STDIN, "%i", $a);
	$order = explode(" ",fgets(STDIN));
	$point = explode(" ",fgets(STDIN));
	$add_point = explode(" ",fgets(STDIN));
	$ans = 0;
	$before_order;
      
     for($i=0; $i<$a; $i++){
     	$ans += $point[$order[$i]-1];
        if($i > 0){       
           if((int) ($before_order + 1) === (int) $order[$i]){
            $ans += $add_point[$before_order-1];
           }
        }
        $before_order = $order[$i];
        
       
     }
	 echo $ans;
  ?>

Measured memory_bytes: 3576
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

const int MAXN = 200005;

ll a[MAXN], dp[MAXN][3];
ll sum, ans;

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

  ll n;
  cin >> n;
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 0;
  FOR(i, 1, n+1){
    cin >> a[i];
    dp[i][0] = min(dp[i-1][0], sum) + (a[i] & 1 ? 1 : (a[i] ? 0 : 2));
    dp[i][1] = min(dp[i-1][1], dp[i-1][2]) + (a[i] & 1 ? 1 : (a[i] ? 0 : 2));
    dp[i][2] = min(dp[i-1][0], min(sum, dp[i-1][2])) + (a[i] & 1 ? 0 : 1);
    sum+=a[i];
  }

  int i;
  for(sum = 0, ans = 1e18, i=n; i>=0; i--){
    ans = min(ans, min({dp[i][0], dp[i][1], dp[i][2]}) + (sum += a[i+1]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
n = int(input())
p = list(map(int, input().split()))
# print(n)
# print(p)
import numpy as np
a = list(range(n+1))
a.pop(0)
# print(a)
d = np.array(p) - np.array(a)
# print(d)
z = np.count_nonzero(d)
if z==2 or z==0:
    print("YES")
else:
    print("NO")

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

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

    int ans = 1;
    for (int i=1; i*i<=M; i++) {
        if (M%i==0) {
            if (i>=N) ans = max(ans, M/i);
            if (M/i>=N) ans = max(ans, i);
        }
    }

    cout << ans << endl;

    return 0;
}

 

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

int pri[1000000]={0};


int main(){
	
	pri[0]=pri[1]=1;
	for(int i=2;i*i<=999999;i++){
		for(int j=i*2;pri[i]==0&&j<=999999;j+=i){
			pri[j]=1;
		}
	}
	
	int n;
	while(cin>>n){
		int tmp=0;
		for(int i=0;i<=n;i++){
			if(pri[i]==0)tmp++;
		}
		cout<<tmp<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 5064
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)


#define N 100005

int32_t main()
{



    IOS


    int n,m,x;
    cin >> n >> m >> x;


    int arr[n][m];
    int cost[n];




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

      for(int j = 0; j < m; j++)
      {
        cin >> arr[i][j];
      }
    }


    // for(int i = 0; i < n; i++)
    // {
    //   for(int j = 0; j < m; j++)
    //   {
    //     cout << arr[i][j] << " " ;
    //   }
    //   cout << endl;
    // }


    // for(int i = 0; i < n; i++)
    // {
    //   cout << cost[i] << endl;
    // }


    
    int mincost = 1e9;

    for(int mask = 0; mask < (1 << (n)); mask++)
      {
        bool ok = true;
        int maskcost = 0;

        vector<int> v(m,0);

        for(int j = 0; j < n; j++)
        {
          if(mask&(1 << j))
          {
            maskcost += cost[j];

            for(int k = 0; k < m; k++)
            {
             // if(mask == 3)trace3(j,k,arr[j][k]);
              v[k] += arr[j][k];
            }
          }
        }

        for(int i = 0; i < m; i++)
        {
          //trace3(mask,i,v[i]);;

          if(v[i] < x)
          {
            ok = false;
          //  break;
          }
        }

        if(ok)
        {
          mincost = min(maskcost,mincost);
        }
      }


      if(mincost == 1e9)
      {
        mincost = -1;
      }


        cout << mincost << endl;
      

   
    return 0;
}

Measured memory_bytes: 3652
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main ()
{
	string s;
	while ((s = readln.strip) != "")
	{
		s = readln.strip;
		writeln (s.count ('R') > s.count ('B') ? "Yes" : "No");
	}
}


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

int main()
{

    //ll i,j,k,a,b,c,n,t,m,d,r,g,y,f;
   // string st,et,mt;
    long double aa,bb;
    cin>>aa;
    bb = acos(-1);
    cout<<setprecision(20)<<fixed<<bb*aa*2*1.0<<endl;
}


Measured memory_bytes: 3780