akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	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;
	}

	// for prime mod
	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;
	}
};

// nCr
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

void solve_abc151() {
	ll N, K;
	cin >> N >> K;

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

	mint ans = 0;
	combination c(N + 5);

	sort(ALL(A));
	rep(i, N) {
		if (i > K - 2) {
			mint v = c(i, K - 1);
			ans += v * A[i];
		}
	}

	sort(ALL(A),greater<ll>());
	rep(i, N) {
		if (i > K - 2) {
			mint v = c(i, K - 1);
			ans -= v * A[i];
		}
	}

	cout << ans.x << "\n";
}

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

	solve_abc151();

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<ll,ll>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;cin >> n;
    vl a(3*n);
    rep(i,3*n) cin >> a[i];

    sort(a.begin(), a.end());
    int cnt = 0;
    int r = 3*n -2;
    ll ans = 0;
    while(cnt < n){
        ans += a[r];
        r -= 2;
        ++cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
using System;

class P
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        
        int w = int.Parse(str[0]);
        int h = int.Parse(str[1]);
        int x = int.Parse(str[2]);
        int y = int.Parse(str[3]);
        int r = int.Parse(str[4]);
        
        if( ((x - r) >= 0 && (x + r) <= w) && (y - r) >= 0 && (y + r) <= h) 
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
        
    }
}


Measured memory_bytes: 17932
#n,k
n,k=(int(x) for x in input().split())

#h(n)
h=list(map(int, input().split()))
#美しくないが降順ソートして代入
hi=sorted(h,reverse=True)

cnt=0

#美しくないがkの数分、配列の位置をずらす
#敵より必殺技の数の方が多いケースがあるのでif文を入れる
if k >= len(hi):
    i = len(hi)
else:
    i = k

#ん～。ださい
while (i<len(hi)):
    cnt += hi[i]
    i += 1

print(cnt)

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

int main () {
    string a, b;
    int n;
    cin >> n;
    cin >> a >> b;
    for (int i = 0; i < n; i++) {
        cout << a[i] << b[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, q, a, p[100009];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k >> q;
    for (int i = 0; i < q; i++) {
        cin >> a;
        p[a]++;
    }
    for (int i = 1; i <= n; i++) {
        if (k - q + p[i] > 0)
            cout << "Yes" << E;
        else cout << "No" << E;
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 1024
def main():
    N =  int(input())
    cnt = 0
    for i in range(3, N + 1, 2):
        div = 0
        for j in range(1,i+1):
            if i % j == 0:
                div += 1
        if div == 8:
            cnt += 1

    print(cnt)


main()

Measured memory_bytes: 38512
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<vector<int>> friends;
vector<vector<int>> blocks;

int dfs(const int cur, const int group_no, vector<int> &group) {
    if (group[cur] >= 0) {
        return 0;
    }
    int acc = 0;
    acc++;
    group[cur] = group_no;
    for(auto &nv : friends[cur]) {
        acc += dfs(nv, group_no, group);
    }
    return acc;
}

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

    friends.resize(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        friends[a].push_back(b);
        friends[b].push_back(a);
    }

    blocks.resize(N);
    for (int i = 0; i < K; i++) {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        blocks[c].push_back(d);
        blocks[d].push_back(c);
    }

    vector<int> group(N, -1);
    map<int, int> group_num;
    int group_no = 0;
    for (int i = 0; i < N; i++) {
        if (group[i] < 0) {
            group_num[group_no] = dfs(i, group_no, group);
            group_no++;
        }
    }

    // printf("group: \n");
    // for (int i = 0; i < N; i++) {
    //     cout << group[i] << " ";
    // }
    // cout << endl;

    // for (auto &p : group_num) {
    //     printf("group %d has %d users\n", p.first, p.second);
    // }

    for (int i = 0; i < N; i++) {
        // printf("user %d\n", i);
        int n = group_num[group[i]];
        n--; // remove myself
        n -= (int) friends[i].size(); // remove users who are already friends
        for (auto &nv : blocks[i]) {
            if (group[i] == group[nv]) {
                n--; // remove block user
            }
        }
        if (i == 0) {
            cout << n;
        } else {
            cout << " " << n;
        }
    }
    cout << endl;

    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int i=0;i < (int)n;++i)

int main() {
    int n;cin>>n;
    int a[n];
    rep(i,n){
        int tmp;cin>>tmp;
        a[i]=tmp/400;
    }
    sort(a,a+n);
    int ans = 1;
    int cc = 0;
    rep(i,n-1)if(a[i+1]!=a[i] && a[i+1] < 8)++ans;
    rep(i,n  )if(a[i ] >= 8)++cc;
    if(cc==n)--cc;
    
    cout<<ans<<" "<<ans+cc<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int ASC(const int *a,const int *b){
	return (*a - *b);
}

int DESC(const int *a,const int *b){
	return (*b - *a);
}

int main(int argc, char const *argv[])
{	
	int n,s[100];
	int max = 0,min = 0x7F,pat,sum = 0;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf(" %d",&s[i]);
		sum += s[i];
	}
	if(sum % 10 != 0){
		printf("%d\n",sum);
		return 0;
	}
	else{
		qsort(s,n,sizeof(int),ASC);
		for (int i = 0; i < n; ++i)
		{
			if(s[i] % 10 != 0){
				sum -= s[i];
				break;
			}
		}
		sum = (sum % 10 == 0) ? 0 : sum;
		printf("%d\n", sum);
	}
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)


int8_t f(const char c, const string& s, int i) {
    int n = s.size();
    if (count(s.begin(), s.end(), c) == n)
        return i;
    
    string t = "";
    rep(i, n - 1) {
        if (s[i] == c || s[i + 1] == c) t += c;
        else t += s[i];
    }
    return f(c, t, i + 1);
}

char buf[120];
int main() {
    scanf("%s", buf);
    string s = buf;
    int8_t ans = 110;
    for (char c = 'a'; c <= 'z'; c++) if (count(s.begin(), s.end(), c) != 0) {
        ans = min(ans, f(c, s, 0));
    }
    printf("%d\n", ans);
    return 0;
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


class RmqTree {
private:
 ll _find(ll a, ll b, ll k, ll l, ll r) {
  if (r <= a || b <= l)return INF;
  if (a <= l && r <= b)return dat[k];
  else {
   ll s1 = _find(a, b, 2 * k + 1, l, (l + r) / 2);
   ll s2 = _find(a, b, 2 * k + 2, (l + r) / 2, r);
   return min(s1, s2);
  }
 }
public:
 ll n, height;
 vector<ll> dat;

 RmqTree(ll _n) {
  n = 1;
  height = 1;
  while (n < _n) {
   n *= 2;
   height++;
  }
  dat = vector<ll>(2 * n - 1, INF);
 }

 //場所iにxを代入する
 void update(ll i, ll x) {
  i += n - 1;
  dat[i] = x;
  while (i > 0) {
   i = (i - 1) / 2;
   dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
  }
 }

 //区間[a,b)の最小値
 ll find(ll a, ll b) {
  return _find(a, b, 0, 0, n);
 }
};

void solve(){
    ll n;
    cin>>n;
    map<ll,ll> mp;
    vec<P> xd(n);
    mp[INF]++;
    REP(i,n){
        ll x,d;
        cin>>x>>d;
        mp[x]++;
        xd[i]={x,d};
    }
    ll con=0;
    for(auto& i:mp){
        i.second=con;
        con++;
    }
    sort(all(xd));
    RmqTree seg(con);

    vec<ll> dp(con,0);
    dp[con-1]=1;
    REP2(i,n){
        ll x=xd[i].first;
        ll d=xd[i].second;
        ll r = mp.lower_bound(x+d)->second;
        ll ma = -seg.find(i+1,r);
        if(ma==-INF) ma=i+1;
        dp[i]=(dp[i+1]+dp[ma])%MOD;
        seg.update(i,-ma);
    }
    cout<<dp[0]<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 21504
n, k = map(int, input().split())
L = [''] * n
for i in range(1, n + 1):
    j = 0
    while i * (2 ** j) < k:
        j += 1
    L[i - 1] = j
S = 0
for k in L:
    S += 1 / (2 ** k)
print(S / n)

Measured memory_bytes: 3828
#include <stdio.h>
int main(void){
    int n=0,x=0,i,j,k,y,z;
    while(scanf("%d %d",&n,&x)!=EOF){
        if(n==0 && x==0)break;
        z=0;
        for(i=1;i<=n-2;i++){
            for(j=i+1;j<=n-1;j++){
                for(k=j+1;k<=n;k++){
                    y=i+j+k;
                    if(y==x){
                        z=z+1;
                    }
                }
            }
        }
    printf("%d\n",z);
    }
    return 0;
}



Measured memory_bytes: 2104
# -*- coding: utf-8 -*-
# 整数の入力
a = list(map(int, input()))
#print(a)

def rev01(x):
  if x == 0:
    return 1
  else:
    return 0

cnt = 0
for i, v in enumerate(a):
  if i == 0:
    prev = v
  else:
    if v != rev01(prev):
#      print(i,v)
      cnt += 1
      prev = rev01(v)
    else:
      prev = v
      
print(cnt)

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

int main()
{
    int a, b, c, ans = 0;
    cin >> a >> b >> c;

    for (int i = a; i <= b; ++i) {
        if (c % i == 0) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    string S;
    cin >> S;
    for (int i = 1; i < S.size(); ++i) {
        if(S[i] == S[i-1]){
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from sys import stdin
def main():
    N = int(stdin.readline())
    edge = defaultdict(list)
    for _ in range(N-1):
        u,v,w = map(int,stdin.readline().split())
        u -= 1;v -= 1
        edge[u].append([v,w])
        edge[v].append([u,w])
    stack = [0]
    color = [-1 for _ in range(N)]
    color[0] = 0
    while stack:
        u = stack.pop()
        for e in edge[u]:
            v,dist = e
            if dist%2==0 and color[v] == -1:
                color[v] = color[u]
                stack.append(v)
            elif dist%2==1 and color[v] == -1:
                if color[u] == 1:
                    color[v] = 0
                else:
                    color[v] = 1
                stack.append(v)
            else:continue
    for c in color:
        print(c)

if __name__ == "__main__":
    main()

Measured memory_bytes: 50772
#include <stdio.h>
#include <math.h>

int main(void)
{
	int x;
	int max=-1;
	int result=0;
	
	scanf("%d",&x);
	
	if(x==1){
		max=1;
	}else{
		int i=2;
		while(i<=x){
			int j=2;
			while(j<=x){
				result=pow(i,j);
				if(result<=x&&result>max){
					max=result;
				}
				j++;
			}
			i++;
		}
	}
	
	printf("%d\n",max);
	
	return 0;
}

Measured memory_bytes: 384
import numpy as np
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
mv=pow(10,3)*n+1
mw=pow(10,9)*n+1
dp=np.full(mv,mw,np.int64)
# dp[i]:価値をちょうどiすることができる重さの最小値。ちょうどにできない場合dp[i]=inf。求めるのはdp[i]<=wとなるiのうち最大のもの。
dp[0]=0
for i in range(n):
      w_=wv[i][0]
      v_=wv[i][1]
      dp[v_:]=np.minimum(dp[v_:],dp[:-v_]+w_)
print(np.where(dp<=w)[-1][-1])

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
//#define i_7 (ll)(1E9+7)
//#define i_7 998244353
ll i_7;
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////


ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}


int main(){fastio
    ll n;cin>>n;
    string s;cin>>s;
    ll cr=0;
    rep(i,0,n-1){
        if(s[i]=='R')cr++;
    }
    ll ans=0;
    rep(i,0,cr-1){
        if(s[i]=='W')ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3768
fn shortage(s: &String) -> (usize, usize) {
    let mut sum = 0;
    let mut ans = 0;
    for c in s.chars() {
        if c == '(' {
            sum += 1;
        } else {
            if sum == 0 {
                ans += 1;
            } else {
                sum -= 1;
            }
        }
    }
    (ans, sum)
}
fn main() {
    let n: i32 = readln();
    let s: String = readln();
    let (a, b) = shortage(&s);
    let ans = String::from_utf8(vec![b'('; a]).unwrap() + &s +
     &String::from_utf8(vec![b')'; b]).unwrap();
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n { vs.push(readln()); }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T> where T: FromLn {
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);

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

int main(){
    string s;
    cin >> s;
    int a=0;
    for(int i=0;i<4;i++){
        if(s.at(i)=='+'){
            a++;
        }else{
            a--;
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int out[(1<<17)+10];
int n;
void rec(int a,int b,int s,int g,int m){
	if(s+2==g){
		out[s]=a;out[g-1]=b;
		return;
	}
	int t,u;
	rep(i,n){
		if((a&(1<<i))!=(b&(1<<i))) t=i;
	}
	rep(i,n){
		if(i!=t && !(m&(1<<i))) u=i;
	}
	int x=(a^(1<<u));
	int y=(x^(1<<t));
	rec(a,x,s,(s+g)/2,m+(1<<t));
	rec(y,b,(s+g)/2,g,m+(1<<t));
}
int main()
{
	int a,b,c,d;
	cin>>n>>a>>b;c=(a^b);d=__builtin_popcount(c);
	if(d%2==0){
		//assert(false);
		cout<<"NO"<<endl;return 0;
	}
	rec(a,b,0,(1<<n),0);
	cout<<"YES"<<endl;
	rep(i,(1<<n)){
		cout<<out[i];
		if(i<(1<<n)-1) cout<<' ';else cout<<endl;
	}
}


Measured memory_bytes: 1536
import sys
import numpy as np

size_data = sys.stdin.readline().strip().split(" ")

N = int(size_data[0])
M = int(size_data[1])
C = int(size_data[2])

column_vector = np.append(np.array(sys.stdin.readline().strip().split(" "), dtype=np.int64), [C])
a_matrix = []

for i in range(N):
    a_row = np.append(np.array(sys.stdin.readline().strip().split(" "), dtype=np.int64), [1])
    a_matrix.append(a_row)


a_matrix = np.array(a_matrix)
values = np.dot(a_matrix, column_vector)
results = np.where(values > 0)
result = len(results[0])

print(result)

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int x, a;
    cin >> x >> a;
    if (x < a)
        OP(0);
    else
        OP(10);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int power = 1;
  int ten = 1;
  int digits = 1;
  int fn = 0;
  while (true){
      ten *= 10;
      if (N < ten){
          break;
      }
      digits += 1;
  }
  for (int i = 0; i < digits; i++){
      power *= 10;
      fn += ((N - fn) % power) / (power / 10);
  }
  if (N % fn == 0){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
  }


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

//LIFE IS NOT A PROBLEM TO BE SOLVED

#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) cout << mat[i][j] << " "; cout << endl; }

using namespace std;

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

string s;
ll pd[100010][14];

const int mod = 1e9+7;

ll solve(int i, int r){
	if(i==s.size()){
		return r==5;
	}
	
	if(pd[i][r]!=-1) return pd[i][r];
	ll ret = 0;
	if(s[i]!='?'){
		ret = solve(i+1, (r*10+s[i]-'0')%13);
	}else{
		rep(j, 0, 10){
			ret = (ret + solve(i+1, (r*10+j)%13))%mod;
		}
	}
	return pd[i][r] = ret;
}

int main(){
	
	cin >> s;
	memset(pd, -1, sizeof pd);
	cout << solve(0, 0) << '\n';
	
	
	return 0;
}

Measured memory_bytes: 19200
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;
const int MX = 1e5+8;
int n,a[MX],b[MX];
int main(){
    cin >> n;
    for(int i=0 ; i<n+1 ; ++i)
        cin >> a[i];
    for(int i=0 ; i<n ; ++i)
        cin >> b[i];
    ll ans = 0;
    for(int i=0 ; i<n ; ++i){
        ll num = min(b[i],a[i]);
        b[i] -= num;
        a[i] -= num;
        ans += num;
        num = min(b[i],a[i+1]);
        ans += num;
        b[i] -= num;
        a[i+1] -=num;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

int gcd(int p, int q){
  while(q != 0){
  int r = p % q;
  p = q;
  q = r;
  }
  return p;
}


int main(void){
  long long s=0;
  int k;
  std::cin >> k;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
        s += gcd(gcd(a,b),c);
      }
    }
  }
  std::cout << s;
  return 0;
}

Measured memory_bytes: 3604
# coding: utf-8
# Your code here!

S = input()

ACGT = ("A", "G", "C", "T")

max_len = 0
tmp_len = 0
for c in S:
    if c in ACGT:
        tmp_len += 1
    else:
        tmp_len = 0
    
    if tmp_len > max_len:
        max_len = tmp_len

print(max_len)

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    lld n;
    scanf("%lld", &n);
    lld t[10][10];
    rep(i, 0, 10){
        rep(j, 0, 10){
            t[i][j] = 0;
        }
    }
    rep(i, 1, n+1){
        lld buf = i;
        lld a, b;
        b = buf % 10;
        while(buf >= 10){
            buf /= 10;
        }
        a = buf;
        t[a][b]++;
    }
    lld ans = 0;
    rep(i, 1, 10){
        rep(j, 1, 10){
            ans += t[i][j] * t[j][i];
            //printf("%lld ", t[i][j]);
        }
        //printf("\n");
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const int max_n = 10000+5;
long long cnt[111];
long long m,n,a=0,b,W;
const int INF = 1e8;
const int mod = 1e9 + 7;
long dist[max_n],s[max_n],w[max_n],v[max_n];
long long dp[max_n][max_n];
vector<vector<int> > G;
bool isprime(long long xx){
    if(xx == 2) return true;
    if(xx % 2==0 || xx<2)    return false;
    long long ii = 3;
    while(ii*ii <= xx){
        if(xx %ii == 0) return false;
        ii += 2;
    }
    return true;
}
long long gcd(long long xx, long long yy){
    if(yy == 0) return xx;
    long long k = xx/yy;
    long long c = xx - k*yy;
    return gcd(yy, c);
}
void solve(){
    for(int i=0 ; i<=W ; i++){
        dp[i][0] = 0;
    }
    for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<=W ; j++){
            if(j>=w[i]){
                dp[i+1][j] = max(dp[i+1][j-w[i]]+v[i], dp[i][j]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[n][W] << endl;
}
int main(){
    cin >> n >> W;
    for(int i=0 ; i<n ; i++){
        cin >> v[i] >> w[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 50528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll MOD=1e9+7;
const ll INF=1ll<<60;

//
//　定数, 変数 *********************************************
int N;
ll K;

// *********************************************************
int main(){

    cin >> N >> K;
    int A[N+1];
    int B[N+1];
    // **************************************
    for(int i=1; i<=N; i++){
        cin >> A[i];
        B[i] = 0;
    }
    B[1] = 1;

    int ct = 1;     // current town = 1
    int loop=0;
    ll loopzan=0;
    int loop1st=0;
    for(int i=1; i<=K; i++){
        if(B[A[ct]] == 0){ // not visited before
            B[A[ct]] = i+1;  // (i+1)th town
            ct = A[ct];
            if(i==K){
                loop1st = ct;
            }
        }else{
            loop = B[ct] - B[A[ct]] + 1;
            loop1st = A[ct];
            loopzan = K - i;
            break;
        }
    }

   
    if(loop != 0){
        loopzan = loopzan % loop;
        for(ll i=1; i<=loopzan; i++){
            loop1st = A[loop1st];
        }
    }

    cout << loop1st << endl;


    return 0;
}

Measured memory_bytes: 5192
def f(line):
    if line == ['b','b','b']:
        print 'b'
        return True
    elif line == ['w', 'w', 'w']:
        print 'w'
        return True

while True:
    L = []
    line = raw_input()
    if line == '0': break
    L.append(list(line))
    for i in range(2):
        L.append(list(raw_input()))
    flag = False
    for line in L:
        if f(line):
            flag = True
            break
    if flag: continue
    for w in range(3):
        if f([L[h][w] for h in range(3)]):
            flag = True
            break
    if flag: continue
    if f([L[i][i] for i in range(3)]): continue
    if not f([L[i][2-i] for i in range(3)]):
        print 'NA'

Measured memory_bytes: 4256
#include<stdio.h>
struct card{
  char mark;
  char kazu;
};
void bubblesort(struct card a[],int n){
  int i,j;
  struct card x;
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(a[j].kazu<a[j-1].kazu){
	x=a[j];
	a[j]=a[j-1];
	a[j-1]=x;
      }
    }
  }
}
void selectionsort(struct card a[],int n){
  int i,j,mimj;
  struct card x;
  for(i=0;i<n;i++){
    mimj=i;
    for(j=i;j<=n-1;j++){
      if(a[j].kazu<a[mimj].kazu)
	mimj=j;
    }
    x=a[i];
    a[i]=a[mimj];
    a[mimj]=x;
  }
}
int stable(struct card a1[],struct card a2[],int n){
  int i;
  for(i=0;i<n;i++){
    if(a1[i].mark!=a2[i].mark) return 0;
  }
  return 1;
}
int main(){
  char p;
  int n,i;
  struct card a1[36],a2[36];
  char s[100];
  scanf("%d",&n);
  scanf("%c",&p);
  for(i=0;i<n;i++){
    scanf("%s", s);
    a1[i].mark = s[0];
    a1[i].kazu = s[1];
  }
  for(i=0;i<n;i++)
    a2[i]=a1[i];
    bubblesort(a1,n);
    selectionsort(a2,n);
    for(i=0;i<n;i++){
      if(i!=0)printf(" ");
      printf("%c%c",a1[i].mark,a1[i].kazu);
    }
    printf("\n");
    printf("Stable\n");
    for(i=0;i<n;i++){
      if(i!=0)printf(" ");
  printf("%c%c",a2[i].mark,a2[i].kazu);
    }
    printf("\n");
    if(stable(a1,a2,n)==1){
      printf("Stable\n");
    }
    else{
      printf("Not stable\n");
    }
    return 0;
}


Measured memory_bytes: 2144
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
#define ND 2000000
void push(int);
int R,x[MN+5],y[MN+5],cx[MN+5],cxn,cy[MN+5],cyn,u[MN+5];
long long ans;
struct segtree
{
	struct node{int l,r,s,u;}t[ND+5];
	int rt[MN+5],tn;
	void ins(int&k,int l,int r,int x,int z)
	{
		if(!k)k=++tn;
		++t[k].s;t[k].u|=z;
		if(l==r)return;
		int mid=l+r>>1;
		if(x<=mid)ins(t[k].l,l,mid,x,z);
		else ins(t[k].r,mid+1,r,x,z);
	}
	void solve(int k,int l,int r)
	{
		if(!t[k].u)return;
		if(l==r&&!u[t[k].u])push(t[k].u);
		t[k].u=0;
		int mid=l+r>>1;
		if(l<r)solve(t[k].l,l,mid),solve(t[k].r,mid+1,r);
	}
	int query(int k,int l,int r,int ql,int qr)
	{
		if(l==ql&&r==qr){solve(k,l,r);return t[k].s;}
		int mid=l+r>>1,res;
		if(qr<=mid)res=query(t[k].l,l,mid,ql,qr);
		else if(ql>mid)res=query(t[k].r,mid+1,r,ql,qr);
		else res=query(t[k].l,l,mid,ql,mid)+query(t[k].r,mid+1,r,mid+1,qr);
		t[k].u=t[t[k].l].u|t[t[k].r].u;
		return res;
	}
}A,B;
inline int getx(int x){return lower_bound(cx+1,cx+cxn+1,x)-cx;}
inline int gety(int y){return lower_bound(cy+1,cy+cyn+1,y)-cy;}
void push(int v)
{
	int xl,xr,yl,yr;u[v]=1;
	xl=getx(x[v]-R);xr=getx(x[v]+R);
	yl=gety(y[v]-R);yr=gety(y[v]+R+1)-1;
	if(xl<=cxn&&cx[xl]==x[v]-R&&yl<=yr)ans+=A.query(A.rt[xl],1,cyn,yl,yr);
	if(xr<=cxn&&cx[xr]==x[v]+R&&yl<=yr)ans+=A.query(A.rt[xr],1,cyn,yl,yr);
	if(xl<=cxn&&cx[xl]==x[v]-R)++xl;--xr;
	if(yl<=cyn&&cy[yl]==y[v]-R&&xl<=xr)ans+=B.query(B.rt[yl],1,cxn,xl,xr);
	if(yr<=cyn&&cy[yr]==y[v]+R&&xl<=xr)ans+=B.query(B.rt[yr],1,cxn,xl,xr);
}
int main()
{
	int n,a,b,i,X,Y;
	n=read();a=read();b=read();
	for(i=1;i<=n;++i)
	{
		x[i]=read();y[i]=read();
		cx[i]=x[i]+=y[i];cy[i]=y[i]=x[i]-y[i]-y[i];
	}
	R=max(abs(x[a]-x[b]),abs(y[a]-y[b]));
	sort(cx+1,cx+n+1);cxn=unique(cx+1,cx+n+1)-cx-1;
	sort(cy+1,cy+n+1);cyn=unique(cy+1,cy+n+1)-cy-1;
	for(i=1;i<=n;++i)
	{
		X=getx(x[i]);Y=gety(y[i]);
		A.ins(A.rt[X],1,cyn,Y,i);
		B.ins(B.rt[Y],1,cxn,X,i);
	}
	push(a);
	cout<<ans/2;
}

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

int main(){
    int n; cin>>n;
    int a[110];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,greater<int>());
    int ans=0;
    for(int i=0,j=1;i<n;i++,j*=-1){
        ans+=j*a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto d=new int[](n);
  foreach(i; 0..n) rd(d[i]);

  bool ok=true;
  void f(){
    int r=0;
    foreach(int i, int e; d){
      ok&=i*10<=r;
      r=max(r, i*10+e);
    }
  }

  f();
  reverse(d);
  f();

  if(ok) writeln("yes");
  else writeln("no");

}

void chmax(T)(ref T x, T y){
  if(x<y) x=y;
}
void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 4512
n=int(input())
*p,=map(int,input().split())
order=1
cnt=0
for i in range(n-1):
    if p[i]==i+1:
        p[i],p[i+1]=p[i+1],p[i]
        cnt+=1
if p[n-1]==n:
    p[n-2],p[n-1]=p[n-1],p[n-2]
    cnt+=1
print(cnt)

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

typedef long long ll;

bool cmp(pair<int, int>& a, pair<int, int> &b){
    return (a.first>=b.first);
}

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

    int n; cin>>n;
    vector<pair<int, int> > v(2);
    v[0].first = 0; v[0].second = 0;
    v[1].first = 0; v[1].second = 0;

    int A[n];
    int max1 = 0, max2 = 0;
    for (int i=0;i<n;++i){
        cin>>A[i];

        if (A[i]>=max1){
            max2 = max1;
            max1 = A[i];
            v[1] = make_pair(max2, v[0].second);
            v[0] = make_pair(max1, i);
        }
        else if (A[i]>=max2){
            max2 = A[i];
            v[1] = make_pair(max2, i);
        }
    }

    for (int i=0;i<n;++i){
        if (v[0].second == i) cout<<v[1].first<<endl;
        else cout<<v[0].first<<endl;
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t a, b, c;
    std::cin >> a >> b >> c;

    std::cout << ((a==b && a==c) ? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int N = 2005;
int a[N],d[N];
ll f[N][N];
bool cmp(int x,int y)
{
	if(a[x] != a[y])
		return a[x] > a[y];
	return x < y;
}
int main()
{
	int n;scanf("%d",&n);
	for(int i = 1;i <= n;++i)	scanf("%d",&a[i]),d[i] = i;
	sort(d+1,d+1+n,cmp);
	
	for(int i = 1;i <= n;++i)
	{
		for(int j = 0;j <= n;++j)
		{
			if(j >= 1)	f[i][j] = max(f[i][j],f[i - 1][j - 1] + a[d[i]] * abs(d[i] - j));
			if(j != i)	f[i][j] = max(f[i][j],f[i - 1][j] + a[d[i]] * abs(n - i + j + 1 - d[i]));
		}
	}
	ll res = 0;
	for(int i = 0;i <= n;++i)	res = max(res,f[n][i]);
	printf("%lld",res);
    return 0;
}


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

using namespace std;

typedef long long ll;

const int N = (int) 1e5 + 7;
int n;
int a[N];

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

  cin >> n;
  ll sum  = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sum /= 2;

  for (int i = 2; i <= n; i += 2) {
    sum -= a[i];
  }

  for (int i = 1; i <= n; i++) {
    cout << 2 * sum << " ";
    sum = a[i] - sum;
  }
  cout << "\n";

  return 0;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin>>n;

    rep(i,n){
        if((i+1)%3==0 || (i+1)%5==0)continue;
        else ans += i+1;
    }
    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3628
//A
#include<iostream>
#include<algorithm>
using namespace std;
pair<int,int> a[100010];
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n + 1);
	for (int i = 1; i <= n; i++)
		cout << a[i].second << " ";
	
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int c[30];string a="None";
int main(){
	string s;cin>>s;
	for(int i=0;s[i];++i)c[s[i]]++;
	for(int i='z';i>='a';--i)if(!c[i])a=i;
	cout<<a<<endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<set>
#include<algorithm>
#include<vector>
 
using namespace std;
 
typedef pair<int, int> PP;
 
 
int N;
char S[10010];
 
int main(){
    while(1){
        scanf("%d", &N);
        if(N == 0) break;
        scanf("%s", S);
        set<PP> pat1, pat2;
         
        int prev = 0;;
        for(int i = 0; i < N; i++){
            if(S[i] == 'u'){
                prev = 0;
            }else{
                int mask = 1 << (S[i] - '0');
                pat1.insert(make_pair(prev, mask));
                prev |= mask;
            }
        }
        vector<PP> tmp;
        bool flg = true;
        int bsize;
        do{
            bsize = pat1.size();
            tmp.clear();
            for(auto v1 : pat1){
                for(auto v2 : pat1){
                    if((v1.first & v2.first) == 0 && (v1.first & v2.second) != 0){
						PP np = make_pair(v1.first | v2.first, v1.second);
						if((np.first & np.second) != 0){
							flg = false;
							goto LOOP;					
						}
                        tmp.push_back(np);
                    }
                }
            }
            for(auto v : tmp){
                pat1.insert(v);
            }
        }while(bsize != pat1.size());
 
		LOOP:

        if(flg){
            printf("SAFE\n");
        }else{
            printf("UNSAFE\n");
        }
    }
}

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

int main(){
  int N;
  vector<string> s(100010);

  cin >> N;
  for (int i=0; i<N; i++){
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }

  sort(s.begin(), s.begin()+N);

  s.push_back("donotexist");

  int64_t cnt = 1;
  int64_t ans = 0;

  for(int i=0; i<N; i++){
    if (s[i] == s[i+1]){
      cnt++;
    } else {
      ans += cnt*(cnt-1)/2;
      cnt = 1;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 8064
#include<stdio.h>

int main(){

    int N, L;

    scanf("%d%d", &N, &L);

    int sum = 0;

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

    if(L > 0){
        printf("%d", sum - L);
    }else if(L+N-1 < 0){
        printf("%d", sum - (L + N - 1));
    }else{
        printf("%d", sum);
    }

    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

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

    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int front,back;
    front=0;
    back=n-1;
    int sw=0;
    int tot=0;
    FOR(i,1,n)
    {
        if(s[i-1]==s[i])
            tot++;
        else
            sw++;
    }
    // cout << tot << endl;
    if(tot+2*k<sz(s)-1)
        cout << tot+2*k;
    else
        cout << sz(s)-1;

    return 0;
}


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

using namespace std;

long long N;
deque <int> ans;
vector <int> dd;

void solve(long long N)
{
    if (N == 1) return;
    if (N%2 == 0)
    {
        solve(N/2);
        dd.push_back(1);
    }
    else
    {
        solve(N-1);
        dd.push_back(2);
    }
}

int main()
{
    cin >> N;
    solve(N+1);
    for (int i=0,j=1; i < dd.size(); i++, j++)
        if (dd[i] == 2) ans.push_front(j);
        else ans.push_back(j);
    int sz = ans.size();
    cout << sz*2 << endl;
    while (!ans.empty())
    {
        int x = ans.front();
        cout << x << " ";
        ans.pop_front();
    }
    for (int i=1; i <= sz; i++) cout << i << " ";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  int l[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  int max = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (l[i] > max) {
      max = l[i];
    }
    sum += l[i];
  }
  sum -= max;
  if (sum > max) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
n = int(input())
L = []
last_letter = 0
for i in range(n):
    w = str(input())
    L.append(w)
    if (i != 0 and w[0] != last_letter) or L.count(w) != 1:
        print('No')
        exit()
    last_letter = w[-1]
print('Yes')


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
vector<int> a;

void init()
{
	cin >> N;
	CINV(a, N);
	sort(all(a));
}

void solve()
{
	int cnt = 0;
	reps(i, 1, N) {
		cnt += a[i] == a[i-1];
	}
	cout << N - (cnt + 1) / 2 * 2 << endl;
}




Measured memory_bytes: 640
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
function main(){
  var read = 0;
  var resultCase = 1;
  while(true){
    var maxWeight = +input[read++];
    if(!maxWeight){
      break;
    }
     
    var treasures = +input[read++];
    var pdp = new Int32Array(maxWeight + 1);
    for(var i = treasures; i--;){
      var c = input[read++].split(",");
      var tv = +c[0];
      var tw = +c[1];
 
      var dp = new Int32Array(maxWeight + 1);
      for(var w = 1; w <= maxWeight; w++){
          dp[w] = pdp[w];
        if(w - tw >= 0){
          dp[w] = max(pdp[w-tw] + tv, pdp[w]);
        }
      }
      pdp = dp;
    }
 
    var resultWeight = 1001;
    var resultCost = 0;
    for(var i = 0; i <= maxWeight; i++){
      var pdpi = pdp[i];
      if(pdpi > resultCost){
        resultCost = pdpi;
        resultWeight = i;
      }
    }
     
    console.log("Case " + resultCase++ + ":\n" + resultCost + "\n" + resultWeight);
  }
}
 
function max(a, b) {
  var t = a - b;
  return a - (t & (t >> 31));
}

Measured memory_bytes: 14392
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++) cin >> L[i];

    sort(L.begin(), L.end());

    long long ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            auto itr = lower_bound(L.begin(), L.end(), L[i] + L[j]);
            int dis = distance(L.begin(), itr);
            if(dis - (j + 1) >= 0)
                ans += dis - (j + 1);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.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 DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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 namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w; cin >> h >> w;
    vector<vector<string>> tbl(h, vector<string>(w)); rep(y, h) rep(x, w) cin >> tbl[y][x];

    rep(y, h){
        rep(x, w){
            if(tbl[y][x] == "snuke"){
                cout << (char)('A' + x) << y + 1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256