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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n,q;
    cin>>n>>q;
    UnionFind uf(n+1);
    rep(i,q){
        int a,x,y;
        cin>>a>>x>>y;
        if (a==1){
            if (uf.issame(x,y)){
                cout<<1<<endl;
            }
            else{
                cout<<0<<endl;
            }
        }
        else{
            uf.merge(x,y);
        }
    }
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

constexpr lnt MOD = 1e9+7;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


int main() {
	lnt n,m;
	std::cin >> n >> m;
	mint ans=0;
	auto f = mint::construct_fact(m);
	auto nC = mint::construct_comb(n);
	rep(k,n+1) {
		ans+=mint(k%2?-1:1)*nC[k]*f[m]/f[m-k]*(f[m-k]/f[m-n]).pow(2);
	}
	print(ans);
}


Measured memory_bytes: 11104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int K, X;
    try(Scanner sc = new Scanner(System.in)) {
      K = sc.nextInt();
      X = sc.nextInt();
    }
    int m = X - (K-1);
    int M = X + (K-1);
    int count = 0;
    for( int i = m; i <= M; i++ ) {
      if ( count > 0 ) {
        System.out.print(" ");
      }
      System.out.print(i);
      count++;
    }
    System.out.println();
  }
}

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

int main() {
    int n, d;
    cin >> n >> d;
    vector<int> t(n+2), f(n+2);
    for (int i = 0; i < n; i++) {
	cin >> t[i+1] >> f[i+1];
    }
    f[0] = 1;

    long long int sum = 0, count = 0;
    for (int i = 1; i <= n; i++) {
	if ( abs(f[i] - f[i-1]) > t[i] - t[i-1]) {
	    cout << -1 << endl;
	    return 0;
	}

	if ( f[i] + f[i-1] - 2 <= t[i] - t[i-1]) {
	    sum += count * (f[i-1] - 1);
	    count = 0;
	} else {
	    sum += count * (t[i] - t[i-1]);
	}

	count++;

	if (count > d) {
	    cout << -1 << endl;
	    return 0;
	}
    }

    cout << sum + count * (f[n] - 1) << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 200005, MOD = 1000000007;
typedef long long i64;

int A[MAX_N], B[MAX_N], N;

int f[4005][4005];
i64 fac[8005], ifac[8005], inv[8005];

i64 binom(int n, int m) {
  if (n < m) return 0;
  return 1LL * fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d%d", &A[i], &B[i]);
  
  i64 res = 0;
  
  fac[0] = ifac[0] = inv[1] = 1;
  for (int i = 1; i <= 8000; ++i) fac[i] = 1LL * fac[i - 1] * i % MOD;
  for (int i = 2; i <= 8000; ++i) inv[i] = -1LL * (MOD / i) * inv[MOD % i] % MOD;
  for (int i = 1; i <= 8000; ++i) ifac[i] = 1LL * ifac[i - 1] * inv[i] % MOD;

  int base = 2001;
  for (int i = 1; i <= N; ++i) f[base - A[i]][base - B[i]]++;
  for (int i = 1; i <= 4001; ++i)
    for (int j = 1; j <= 4001; ++j)
      f[i][j] = (f[i][j] + f[i - 1][j] + f[i][j - 1]) % MOD;
  
  // i64 temp = 0;
  // for (int i = 1; i <= N; ++i)
  //   temp = (temp + binom(A[i] + B[i], A[i]) % MOD) % MOD;
  // printf("%lld %d\n", temp, f[base][base]);
  for (int i = 1; i <= N; ++i)
    res = (res + f[A[i] + base][B[i] + base] - binom(A[i] + B[i] + A[i] + B[i], A[i] + A[i])) % MOD;
  res = res * inv[2] % MOD;
  
  printf("%lld\n", (res + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 64512
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def solve():

    S = input()
    T = input()

    LS = len(S)
    LT = len(T)

    dp = [[0] * (LT + 1) for _ in range(LS + 1)]
    pre = [[None] * (LT + 1) for _ in range(LS + 1)]
    for i in range(LS):
        for j in range(LT):
            now = 0
            if S[i] == T[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
                pre[i+1][j+1] = 1
            else:
                if dp[i + 1][j] < dp[i][j + 1]:
                    dp[i + 1][j + 1] = dp[i][j + 1]
                    pre[i+1][j+1] = 2
                else:
                    dp[i + 1][j + 1] = dp[i + 1][j]
                    pre[i+1][j+1] = 3

    # print(dp)

    # for p in pre:
        # print(p)

    si = LS
    ti = LT
    ans = []

    while not ((si == 0) and (ti == 0)):
        frm = pre[si][ti]
        if frm == 1:
            si -= 1
            ti -= 1
            ans.append(S[si])
        elif frm == 2:
            si -= 1
        elif frm == 3:
            ti -= 1
        elif frm == None:
            break

    return ans[::-1]


ans = solve()
print("".join(ans))


Measured memory_bytes: 175112
S = input()
a,b,c,d = S[0],S[1],S[2],S[3]
op_list = ['+','-']
for op1 in op_list:
    for op2 in op_list:
        for op3 in op_list:
            f = a+op1+b+op2+c+op3+d
            if eval(f)==7:
                print(f+'=7')
                exit()

Measured memory_bytes: 3060
/**
    The problem simply asks you to do the following
    Given array a of n integer
    Divide it into two groups such that
    sum of (xor sum of two groups) is maximized
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10;
int n;
using ll = long long;
ll basis[65];
ll a[maxn];
void ins(ll x){
    for(int i = 61;i>= 0 ;i--){
        if(!((x>>i) & 1)) continue;
        if(basis[i] == -1)
            return (void)(basis[i] = x);
        x ^= basis[i];
    }
}
bool odd[65];

int main(){
    memset(basis,-1LL,sizeof(basis));
    scanf("%d",&n);
    ll xorsum = 0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        xorsum ^= a[i];
    }
    ll oddsum = 0;
    for(int i=60;i>=0;i--){
        if((xorsum >> i) & 1){
            odd[i] = true;
            oddsum ^= (1LL << i);
        }
    }
    for(int i=60;i>=0;i--){
        if(!odd[i]) continue;
        for(int j=1;j<=n;j++){
            if((a[j] >> i) &1)
                a[j] ^= (1LL << i);
        }
    }
    for(int i=1;i<=n;i++){
        ins(a[i]);
    }
    ll ans = 0;
    for(int i=60;i>=0;i--){
        if( (ans >>i) & 1)continue;
        if(basis[i] != -1) ans ^= basis[i];
    }
    ans <<= 1;
    printf("%lld\n",ans+oddsum);
}


Measured memory_bytes: 1024
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int cut=0,i=0,N=IN(),K=IN(),A[N]={0},l=1,r=2e9;
  while(i<N){A[i++]=IN();}
  while(l<=r)
  {
    int m=(l+r)/2,temp=0;
    for(i=0;i<N;i++){temp+=(A[i]-1)/m;}
    if(temp<=K){cut=m;r=m-1;}else l=m+1;
  }
  return printf("%d\n",cut),0;
}

Measured memory_bytes: 2328
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX/2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }




void update(vector<int> & Segtree, int k, int a,int N)
{
  k += N -1;
  Segtree[k] = a;
  while(k > 0)
  {
    k = (k-1)/2;
    Segtree[k] = min(Segtree[2*k+1],Segtree[2*k + 2]);
  }
}

int query(vector<int> & Segtree,int a, int b, int k, int l,int r)
{
  // DEBUG(k);
  if(r <= a || b <= l) return 2147483647;
  if(a <= l && r <= b) return Segtree[k];
  else
  {
    int vl = query(Segtree,a,b,k*2+1,l,(r+l)/2);
    int vr = query(Segtree,a,b,k*2+2,(l+r)/2,r);
    return min (vr,vl);
  }

  

}

void solve(void)
{
  int X;
  cin>>X;
  if(X < 1200)
  {
    cout<<"ABC"<<endl;
  }
  else
  {
    cout<<"ARC"<<endl;
  }


  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))

a = sorted(a, key = lambda x:x[0])

x = 0
for i in a:
	x += i[1]
	if x >= k:
		break
print(i[0])

Measured memory_bytes: 29412
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    if (!(cin >> N)) { return; }
    vector<ll> P;
    for (int i = 0; i < N; ++i) {
        ll tmp;
        cin >> tmp;
        tmp--;
        P.push_back(tmp);
    }
    ll ans = 0;
    for (int i = 0; i < N-1; ++i) {
        if(P[i] == i){ swap(P[i], P[i+1]); ans++; }
    }
    if(P[N-1] == N-1) ans++;
    cout << ans << endl;

}

int main(int argc, char *argv[]) {
    string FileName("ABC072"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        while (cin) { solve(cin); }
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}


Measured memory_bytes: 1400
p, g, ig = 998244353, 3, 332748118
W = [pow(g, (p - 1) >> i, p) for i in range(24)]
iW = [pow(ig, (p - 1) >> i, p) for i in range(24)]

def convolve(a, b):
    def fft(f):
        for l in range(k, 0, -1):
            d = 1 << l - 1
            U = [1]
            for i in range(d):
                U.append(U[-1] * W[l] % p)

            for i in range(1 << k - l):
                for j in range(d):
                    s = i * 2 * d + j
                    t = s + d
                    f[s], f[t] = (f[s] + f[t]) % p, U[j] * (f[s] - f[t]) % p

    def ifft(f):
        for l in range(1, k + 1):
            d = 1 << l - 1
            U = [1]
            for i in range(d):
                U.append(U[-1] * iW[l] % p)

            for i in range(1 << k - l):
                for j in range(d):
                    s = i * 2 * d + j
                    t = s + d
                    f[s], f[t] = (f[s] + f[t] * U[j]) % p, (f[s] - f[t] * U[j]) % p

    n0 = len(a) + len(b) - 1
    k = (n0).bit_length()
    n = 1 << k
    a = a + [0] * (n - len(a))
    b = b + [0] * (n - len(b))
    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    for i in range(n0):
        a[i] = a[i] * invn % p
    del a[n0:]
    return a

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(*convolve(A, B))


Measured memory_bytes: 204312
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,A,B;
    cin>>N>>A>>B;
    int i=0;
    while(true){
        if(i%2){
            if(B-1 == A){
                break;
            }
            --B;
        } else {
            if(A+1 == B){
                break;
            }
            ++A;
        }
        ++i;
    }
    cout << (i%2 ? "Alice" : "Borys")  << '\n';
    return 0;
}

Measured memory_bytes: 256
(n, m) = [int(s) for s in input().split()]

p = []

for i in range(0, m):
    p.append([int(s) for s in input().split()])

ans = -1
for i in range(0, 1000):
    r = True

    si = str(i)

    if len(si) == n:

        for (s, c) in p:
            if len(si) <= s - 1 or si[s-1] != str(c):
                r = False
                break
    else:
        r = False

    if r:
        ans = i
        break

print(ans)


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

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

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
// long long mod=180143987779;
// vector<long long > t(4*100001);
// bool comp(tuple<int,int,int> a,tuple<int,int,int> b)
// {
//   if(get<0>(a)<get<0>(b))
//   {
//     return false;
//   }
//   else if(get<0>(a)==get<0>(b) && get<1>(b)<get<1>(a))
//   {
//     return true;
//   }
//   else
//   {
//     return true;
//   }
// }
// void buildseg(long long  x,long long  l,long long  r,vector<long long > &a,long long  modi)
// {
//   if(l==r)
//   {
//     t[x]=a[l]%modi;
//   }
//   else
//   {
//     long long  mid=(l+r)/2;
//     buildseg(2*x+1,l,mid,a,modi);
//     buildseg(2*x+2,mid+1,r,a,modi);
//     t[x]=(t[2*x+1]+t[2*x+2])%modi;
//   }
// }
// long long  sum(long long  x,long long  l1,long long  r1,long long  l,long long  r,long long  modi)
// {
//   if(l>r)
//   {
//     return 0;
//   }
//   else if(l1==l && r1==r)
//   {
//     return t[x];
//   }
//   else
//   {
//     long long  mid=(l1+r1)/2;
//     return (sum(2*x+1,l1,mid,l,min(r,mid),modi)+sum(2*x+2,mid+1,r1,max(l,mid+1),r,modi))%modi;
//   }
// }
// void update(long long  x,long long  l,long long  r,long long  value,long long  pos,long long  modi)
// {
//   if(l==r)
//   {
//     t[x]=value%modi;
//   }
//   else
//   {
//     long long  mid=(l+r)/2;
//     if(mid>=pos)
//     {
//       update(2*x+1,l,mid,value,pos,modi);
//     }
//     else
//     {
//         update(2*x+2,mid+1,r,value,pos,modi);
//     }
//     t[x]=(t[2*x+1]+t[2*x+2])%modi;
//   }
// }
// void prdoubleseg(long long  n)
// {
//   for(long long  i=0;i<4*n;i++)
//   {
//     cout<<t[i]<<" ";
//   }
//   cout<<endl;
// }
// void dfs(double x,  vector<vector<double> > &adj,vector<set<double> > &v,double &count,vector<double> &vis)
// {
//   v[x].insert(count);
//   vis[x]=1;
//   for(auto i : adj[x])
//   {
//     if(vis[i]==0)
//     {
//       vis[i]=1;
//       dfs(i,adj,v,count,vis);
//     }
//   }
// }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
   T=1;
  while(T--)
  {
    int n;
    cin>>n;
    long long k;
    cin>>k;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
    }
  //  cout<<"f"<<endl;
    vector<int> vis(n+1,0);
    int cycle=0;
      //cout<<cycle<<endl;
    for(int i=1;;)
    {
      if(vis[i]==0)
      {
        vis[i]=1;
        //cout<<i<<endl;
        i=a[i];
        k--;
        if(k==0)
        {
          cout<<i<<endl;
          return 0;
        }
      }
      else
      {
        cycle=i;
        break;
      }
    }
  //  cout<<cycle<<endl;
    int len=1;
    int z=a[cycle];
    while(z!=cycle)
    {
      z=a[z];
      len++;
    }
    k=k%len;
    while(k--)
    {
      cycle=a[cycle];
    }
    cout<<cycle<<endl;
  }


   return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

bool cmp(pair<string,pii> &a, pair<string,pii> &b){
	if(a.first==b.first)return (a.second.first > b.second.first); 
	else return a.first<b.first;
}

int main(){
	int t; cin>>t;
	vector<pair<string, pii>> v;
	for (int i = 0; i<t; i++){
		string s; cin>>s;
		int x; cin>>x;
		v.push_back({s,{x,i+1}});
	}
	sort(v.begin(), v.end(), cmp);
	for(auto&x: v){
		cout<<x.second.second<<endl;
	}
}


Measured memory_bytes: 3576
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b;
	return 0;
}


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

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

int n;
vector<string> s;
int r;

int rec(int c) {
    const char o = s[r++][c];
    if('0' <= o && o <= '9') return o-'0';
    int ret = (o == '+' ? 0 : 1);
    while(true) {
        if (r >= n || c+1 >= (int)s[r].size()) break;
        int res = rec(c+1);
        if (o == '+') ret += res;
        else ret *= res;
    }
    return ret;
}

signed main (void) {
    while(true) {
        cin >> n;
        if (n == 0) break;
        s.clear();
        rep(i,n) {
            string tmp;
            cin >> tmp;
            s.push_back(tmp);
        }
        r = 0;
        cout << rec(0) << endl;
    }
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	
	int n ; 
	cin >> n ; 
	int ans = 0 ;
	for(int i = 1  ; i <= n ; ++i) {
		for(int j = 1 ; j <= n ; ++j) {
			if(i*j >= n) 
				break ; 
			ans ++ ; 
		}
	}
	cout << ans ;

	
		
	return 0 ; 
}

Measured memory_bytes: 3640
#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; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; 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()

// output
#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 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 << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c;
int x, y;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >>a >> b;
  if(a==b)Yes();
  else No();
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
int n,a[500005];
ll b[500005];
int main(){
	scanf("%d",&n);
	For(i,0,n) scanf("%d",&a[i]);
	if (a[0]){
		if (n>0) puts("-1");
		else if (a[0]!=1) puts("-1");
		else puts("1");
		return 0;
	}
	ll v=1;
	For(i,1,n){
		v=v*2;
		if (v<a[i]) return puts("-1"),0;
		v=min(v-a[i],1ll<<40);
	}
	v=1; ll sum=1;
	Rep(i,n,1)
		b[i]=b[i+1]+a[i];
	For(i,1,n){
		v=min(v*2,b[i]);
		sum+=v; v-=a[i];
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 4996
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll N, T;
	cin >> N >> T;

	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	vector<ll> r(N + 1);
	r[N] = A[N];

	for (ll i = N - 1; i > 0; i--) {
		r[i] = max(r[i + 1], A[i]);
	}

	ll ben = 0;

	repn(i, N - 1) {
		ben = max(ben, r[i + 1] - A[i]);
	}

	ll ans = 0;

	repn(i, N - 1) { if (r[i + 1] - A[i] == ben) { ans++; } }
	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 2040
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    string s;
    cin>>s;
    bool moji[30]={false};
    for(int i=0;i<s.length();i++){
        moji[s[i]-'a']=true;
    }
    for(int i=0;i<26;i++){
        if(moji[i]==false){
            cout<<(char)(i+'a')<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}

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

using namespace std;

typedef long long LL;

int MOD=1000000007;

int a[55][55];
int ret[55][55];

void matmul(int a[55][55], int b[55][55]) {
    int c[55][55];
    for (int i=0;i<55;i++)
        for (int j=0;j<55;j++) {
            c[i][j]=0;
            for (int k=0;k<55;k++) c[i][j]=(c[i][j]+1LL*a[i][k]*b[k][j])%MOD;
        }
    for (int i=0;i<55;i++) for (int j=0;j<55;j++) a[i][j]=c[i][j];
}

void print(int a[55][55]) {
    for (int i=0;i<4;i++) {
        for (int j=0;j<4;j++) cout<<a[i][j];cout<<endl;
    }
    cout<<endl;
}

int main() {
    LL n, k;
    cin>>n>>k;
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++) scanf("%d", &a[i][j]);
    memset(ret,0,sizeof(ret));
    for (int i=0;i<n;i++) ret[i][i]=1;
    int last=0;
    for (;(1LL<<last)<=k;last++);
    last--;
    for (;last>=0;last--) {
        if ((1LL<<last)&k) {
            matmul(ret, a);
        }
        if (last>0) {
            matmul(ret, ret);
        }
    }
    LL r=0;
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++) r=(r+ret[i][j])%MOD;
    cout<<r<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    intl a = 1;
    repi(i,2,n + 1){
        a *= i;
        a %= MOD;
    }
    intl b = 1;
    repi(i,2,m + 1){
        b *= i;
        b %= MOD;
    }
    intl ans = (a * b) % MOD;
    if(n == m)ans *= 2;
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    for(int i=0;i<N;i++){
      cin >> A.at(i);
      sum += A.at(i);
    } 
    double th = (double)sum/(4*M);
    int cnt = 0;
    for(int i=0;i<N;i++){
      if (A.at(i)>=th){
          cnt++;
      }
    } 
    if (cnt>=M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//queue ???????????????

#include <iostream>
#include <queue>
#define inf 1e9
#define mp make_pair
#define f first
#define s second 
using namespace std;
int h1[4] = {0,1,0,-1},w1[4] = {1,0,-1,0};
int h2[4] = {0,2,0,-2},w2[4] = {2,0,-2,0};
int res,H,W;
int grid[103][103];
int ans[103][103];
bool check1(int y, int x){
	if(grid[y][x] == 1)return false;
	return true;
}

bool check2(int y, int x){
	if(y <= 0 || x <= 0 || y > H*2 || x > W*2)return false;
	return true;
}

void solve(){
	queue<pair<int,int> > q;
	int x,y;
	x = y = 1;
	pair<int,int> p;
	q.push(mp(y,x));
	ans[y][x] = 1;
	while(q.size()){
		p = q.front();
		x = p.s;
		y = p.f;
		q.pop();
		if(p == mp((H*2)-1,(W*2)-1))break;
		for(int i = 0;i < 4;i++){
			if(check1(y+h1[i],x+w1[i])){
				if(check2(y+h2[i],x+w2[i])){
					if(ans[y+h2[i]][x+w2[i]] == inf){
						q.push(mp(y+h2[i],x+w2[i]));
						ans[y+h2[i]][x+w2[i]] = ans[y][x] + 1;

					}
				}
			}
		}
	}
}


int main(){
	int n;
	while(1){
		cin >> W >> H;
		if(W == 0)break;
		for(int i = 0;i < 103;i++){
			for(int j = 0;j < 103;j++){
				ans[i][j] = inf;
			}
		}
		for(int i = 0;i < H*2 + 1;i++){
			for(int j = 0;j < W*2 + 1;j++){
				if(j == 0 || i == 0 || j == W*2 || i == H*2)grid[i][j] = 1;
				else if(i%2 == 1 && j%2 == 0){
					cin >> n;
					grid[i][j] = n;
				}
				else if(i%2 == 1 && j%2 == 1){
					grid[i][j] = 0;
				}
				else if(i%2 == 0 && j%2 == 0){
					grid[i][j] = 1;
				}
				else if(i%2 == 0 && j%2 == 1){
					cin >> n;
					grid[i][j] = n;
				}
			}
		}
		solve();
		res = ans[(H*2)-1][(W*2)-1];
		if(res == inf)cout << 0 << endl;
		else cout << res <<endl;
		
		
	}
	return 0;
}

Measured memory_bytes: 1288
#優先度付きキュー
import heapq

N, M = map(int, input().split())

#heapqは最小値しか取り出せないので全ての要素に-1をかける
A = list(map(lambda x: int(x)*(-1), input().split()))
# print(A)

#リストを優先度付きキューに入れる
heapq.heapify(A)

for _ in range(M):
    num = heapq.heappop(A)
    # print(num >> 1)
    heapq.heappush(A, (-num)//2*(-1))
print(sum(A)*(-1))

Measured memory_bytes: 14180
///Happy copying <3

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n],cnt=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i+=2)
    {
        if(a[i]%2)
            cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll X, Y; cin >> X >> Y;
    if (abs(X-Y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}

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

int n, k, l;
struct City {
	std::list<int> edge[2];
	int id, parent[2]{-1, -1}, connected{};
};

std::vector<City> cities;
void dfs(int, int, int);

int main()
{
	scanf("%d%d%d", &n, &k, &l);
	cities.resize(n);
	for (int i = 0; i < n; i++)
		cities[i].id = i;

	for (int i = 0; i < k; i++)
	{
		int p, q;
		scanf("%d%d", &p, &q);
		p--; q--;
		cities[p].edge[0].push_back(q);
		cities[q].edge[0].push_back(p);
	}
	for (int i = 0; i < l; i++)
	{
		int r, s;
		scanf("%d%d", &r, &s);
		r--; s--;
		cities[r].edge[1].push_back(s);
		cities[s].edge[1].push_back(r);
	}
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < n; j++)
			if (cities[j].parent[i] == -1)
				dfs(j, j, i);

	std::sort(cities.begin(), cities.end(),
		[](const City& a, const City& b)
		{
			if (a.parent[0] != b.parent[0]) return a.parent[0] < b.parent[0];
			else return a.parent[1] < b.parent[1];
		}
	);
	for (auto i{cities.begin()}; i != cities.end(); i++)
	{
		if (i != cities.begin() && i->parent[0] == (i - 1)->parent[0]
			&& i->parent[1] == (i - 1)->parent[1] )
		{
			i->connected = (i - 1)->connected;
			continue;
		}
		i->connected =
			std::upper_bound(cities.begin(), cities.end(), *i,
				[](const City& value, const City& e)
				{
					if (e.parent[0] != value.parent[0]) return e.parent[0] > value.parent[0];
					else return e.parent[1] > value.parent[1];
				}
			) - i;
	}
	std::sort(cities.begin(), cities.end(),
		[](const City& a, const City& b){ return a.id < b.id; }
	);
	for (int i = 0; i < n; i++)
		printf("%d%c", cities[i].connected, i == n - 1?'\n':' ');

	return 0;
}

void dfs(int city, int parent, int edge_i)
{
	if (cities[city].parent[edge_i] == parent) return;
	cities[city].parent[edge_i] = parent;
	for (auto &e: cities[city].edge[edge_i])
		dfs(e, parent, edge_i);
	return;
}

Measured memory_bytes: 22144
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

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

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    string A, B;
    cin >> A;
    cin >> B;

    if (A.size() < B.size()) {
        cout << "LESS" << endl;
        return 0;
    } else if (B.size() < A.size()) {
        cout << "GREATER" << endl;
        return 0;
    } else {
        for (int i = 0; i < A.size(); ++i) {
            if (A[i] < B[i]) {
                cout << "LESS" << endl;
                return 0;
            } else if (B[i] < A[i]) {
                cout << "GREATER" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  LL m = 1;
  while (m <= n) {
    m *= 2;
  }
  cout << m/2 << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input());
A = list(map(int, input().split()));

for i in A:
  if i % 2 != 0: #奇数
    continue;
  else: #偶数
    if i % 5 == 0 or i % 3 == 0:
      continue;
    else:
      print("DENIED");
      break;
else:
  print("APPROVED");



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 N;
    cin >> N;
    Vec<i32> d(N);
    for (i32 i = 0; i < N; i++) cin >> d[i];
    i64 sum = 0;
    for (i32 i = 0; i < N - 1; i++) {
        for (i32 j = i + 1; j < N; j++) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3632
def slove():
    import sys
    input = sys.stdin.readline
    ss = str(input().rstrip('\n'))
    n = 1 if ss.count("N") != 0 else 0
    w = 1 if ss.count("W") != 0 else 0
    s = 1 if ss.count("S") != 0 else 0
    e = 1 if ss.count("E") != 0 else 0
    if n == s and w == e:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll n, ans = 0;
    cin >> n;
    vector<ll> a(n + 1);
    vector<ll> b(n);
    for (int i = 0; i < n + 1; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }

    for (int i = n; i > 0; i--)
    {
        ll tmp = min(a[i], b[i - 1]);
        ans += tmp;
        a[i] -= tmp;
        b[i - 1] -= tmp;
        tmp = min(a[i - 1], b[i - 1]);
        ans += tmp;
        a[i - 1] -= tmp;
        b[i - 1] -= tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
N, x = map(int, raw_input().split())
M = 2*N-1
if x == 1 or x == M:
    print 'No'
    exit()

if N == 2:
    if x == 2:
        print 'Yes'
        print 1
        print 2
        print 3
    else: 'No'
    exit()

if x == 2:
    core = [3, 2, 1, 4]
else:
    core = [x-1, x, x+1, x-2]

ans = [i for i in xrange(1, M+1) if i not in core]
ans = ans[:(M-4)/2] + core + ans[(M-4)/2:]
print 'Yes'
for a in ans:
    print a


Measured memory_bytes: 30832
#!usr/bim/python
#! -*- coding: utf-8 -*-

import numpy as np

n = raw_input()
n = int(n)
a = raw_input()
a = a.split()

m = n/2
b = []

if n % 2 == 0:
    i = 0
    while i < m:
        b.append(a[2*(m-i)-1])
        i += 1
    i = 0
    while i < m:
        b.append(a[2*i])
        i += 1

else:
    i = 0
    while i <= m:
        b.append(a[2*(m-i)])
        i += 1
    i = 0
    while i < m:
        b.append(a[2*i+1])
        i += 1

for s in b:
    print s+" ",
print ""


Measured memory_bytes: 24956
#include <stdio.h>

int main(void){


	int n, m, i, x, y, b;
	scanf("%d %d", &n, &m);
	int A[n][m], sum[n];
	
	for(y = 0; n > y; y++){
		for(x = 0; m > x; x++){
			A[y][x] = 0; 
		}
		sum[y] = 0;
	}
	
	for(y = 0; n > y; y++){
		for(x = 0; m > x; x++){
			scanf("%d", &b);
			A[y][x] = b; 

		}
	}
	
	for(x = 0; m > x; x++){
		scanf("%d", &b);
		for(y = 0; n > y; y++){
			A[y][x] = A[y][x] * b;
			sum[y] = sum[y] + A[y][x];
			
		}
	}

	for(y = 0; n > y; y++){
		printf("%d\n", sum[y]);
	}


	return 0;
	
}

Measured memory_bytes: 636
n, m  = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
a = sorted(a, key=lambda x :x[1])
bridge = a[0][1] - 1
ans = 1

for i in range(1, m):
    if a[i][0] > bridge:
        bridge = a[i][1] - 1
        ans += 1
        
print(ans)

Measured memory_bytes: 29264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main() {
  int n;
  int ans = 0;
  cin >> n;
  for(int i=1;i<=n;i+=2){
    int cnt = 0;
    for(int j=1;j<=sqrt(i);j++){
      if(i%j == 0) cnt += 2;
      else if(j*j == i) cnt ++;
    }
    if(cnt == 8) ans ++;
    
  }
  cout << ans << endl;
   
  return 0;
}




Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

data = int(input())

array = [[] for i in range(data)]

for i in range(data-1):
    a, b = map(int, input().split())
    array[a-1].append([b-1, i])

result = [None]*(data-1)

def func(prt, col):
    cnt = 1
    for cld, org in array[prt]:
        if cnt==col:
            cnt += 1
        result[org] = cnt
        func(cld, cnt)
        cnt += 1

func(0, 0)

print(max(result))
for i in range(data-1):
    print(result[i])

Measured memory_bytes: 70984
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	int n;
	cin >> n;
	vector<int> ans;
	ans.push_back(2);
	cout << 2 << endl;
	vector<int> five;
	five.push_back(2);
	for (int i = 3; i < 55556; i++) {
		int flag = 1;
		for (int j = 0; j < ans.size(); j++) {
			if (i%ans[j] == 0) {
				flag = 0;
				break;
			}
		}
		if (flag == 1) {
			ans.push_back(i);
			if (i % 5 == 2) {
				five.push_back(i);
				cout << i << endl;
				if (five.size() == n)break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        //モンスターの体力
        //int H = Integer.valueOf(s.next());
        //社員番号
        int N = Integer.valueOf(s.next());
        //部下持ち数
        int[] Ai = new int[N+1];
        Arrays.fill(Ai, 0);
		for(int i = 0; i < N-1; i++) {
            int hoge = Integer.valueOf(s.next());
			Ai[hoge] += 1;
        }
        for(int i = 1; i < Ai.length; i++) {
            System.out.println(Ai[i]);
        }
    }
}

Measured memory_bytes: 61792