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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
// inline void CIN() {}
// template <class Head, class... Tail>
// inline void CIN(Head &&head, Tail &&... tail) {
//     cin >> head;
//     CIN(move(tail)...);
// }
// CIN(__VA_ARGS__)
// CIN(__VA_ARGS__)
// CIN(__VA_ARGS__)
// #define Yes(a) cout << (a ? "Yes" : "No") << "\n"
// #define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
// typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N;
VL p;

int main() {
    cin >> N;
    p.resize(N);
    VECCIN(p);
    int ans = 1e9;
    for(int k = 0; k <= 3; ++k) {
        int nans = k;
        int from = k;
        for(int i = 0; i < N; ++i) {
            int plus = max(0, (int)p[i] - from);
            nans += (i == N - 1 ? 1 : 2) * max(0, plus);
            from = plus;
        }
        ans = min(ans, nans);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3124
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a+b==3)
    printf("3\n");
    if(a+b==4)
      printf("2\n");
      if(a+b==5)
        printf("1\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,K,board;
  cin >> N;
  board=1;
  for(int i=0;i<N;i++){
	cin >> K;
    if(board*2 < board + K){
       board *= 2;
    }else{
      board += K;
    }
  }
  cout << board <<endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> P;
const int MAX = 105;
const int INF = (1<<25);
vector<string> V;
map<string,int> M;
int n,T[MAX];

string isGOTO(string s){

  string check = "goto";

  for(int i = 0; i < check.length(); i++)
    if(s[i] != check[i]) return "";

  return s.substr(5,s.length()-6);
}

void make(){

  for(int i = 0; i < V.size(); i++){
    string s = isGOTO(V[i]);
    if(s == "") M[V[i].substr(0,V[i].length()-1)] = i;
  }
  
}
void solve(){
  
  T[0] = 0;

  priority_queue<P,vector<P>,greater<P> > Q;

  Q.push(P(0,0));

  
  while(!Q.empty()){
    P p = Q.top();
    Q.pop();

    if(T[p.second] < p.first) continue;
    
    string s = isGOTO(V[p.second]);

    if(s == "" && T[p.second+1] > p.first && p.second+1 <= n){
      if(p.second+1 < n) Q.push(P(p.first,p.second+1));
      T[p.second+1] = p.first;
    }

    if(s != ""){
      int nex = M[s];
      if(T[nex] > p.first){
	Q.push(P(p.first,nex));
	T[nex] = p.first;
      }

      if(T[p.second+1] > p.first+1 && p.second+1 <= n){
	if(p.second+1 < n) Q.push(P(p.first+1,p.second+1));
	T[p.second+1] = p.first+1;
      }
    }
  }

  cout << T[n] << endl;
}

int main(){

  fill(T,T+MAX,INF);

  cin >> n;
  cin.ignore();
  for(int i = 0; i < n; i++){
    string s;
    getline(cin,s);
    V.push_back(s);
  }

  make();
  solve();

  
  return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#define inf 1000000000
using namespace std;
int main()
{
    int n,a[40],b[40],c[40],ans;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for(int i=1;i<=n-1;i++)
        scanf("%d",&c[i]);
    ans=b[a[1]];
    for(int i=2;i<=n;i++)
    {
        ans+=b[a[i]];
        if(a[i]-a[i-1]==1)
            ans+=c[a[i-1]];
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,k;
bool memo[100005];
int arr[105],small=100005;
int main(){
    scanf("%d%d",&n,&k);
    for (int x=0;x<n;x++){
        scanf("%d",&arr[x]);
        small=min(small,arr[x]);
    }
    for (int x=small;x<=k;x++){
        for (int y=0;y<n;y++){
            if (x>=arr[y] && !memo[x-arr[y]]){
                memo[x]=true;
                break;
            }
        }
    }
    printf(memo[k]?"First":"Second");
}


Measured memory_bytes: 256
def resolve():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    T = int(input())
    if v <= w:
        print("NO")
        return
    if abs(a - b) <= T * abs(v - w):
        print("YES")
    else:
        print("NO")

resolve()

Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <set>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    vvec<int> L(N,vec<int>(10,0)),R(N,vec<int>(10,0));
    for(int i=0;i<N;i++){
        L[i][S[i]-'0'] = 1;
        if(i!=0){
            for(int j=0;j<10;j++) L[i][j] |= L[i-1][j];
        }
    }
    for(int i=N-1;i>=0;i--){
        R[i][S[i]-'0'] = 1;
        if(i!=N-1){
            for(int j=0;j<10;j++) R[i][j] |= R[i+1][j];
        }
    }
    set<int> s;
    for(int i=1;i<N-1;i++){
        for(int j=0;j<10;j++) for(int k=0;k<10;k++){
            if(L[i-1][j] && R[i+1][k]){
                s.insert(100*j+10*(S[i]-'0')+k);
            }
        }
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 4608
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

#define NIL NULL

void insert(int);
void inorder(Node);
void preorder(Node);
Node treeSearch(Node, int);

Node root;

int main(){

  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
  
    if( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }

    else if( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

void insert(int k){

  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

 
  while(x != NIL){

    y = x;

    if(z->key < x->key){
      x = x->left;
    }

    else{
      x = x->right;
    }
  }

  z->parent = y;

  if(y == NIL){
    root = z;
  }

  else if(z->key < y->key){
    y->left = z;
  }

  else y->right = z;

}

void inorder(Node u){

  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }

}

void preorder(Node u){

  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }

}

Node treeSearch(Node u, int k){

  if((u == NIL) || (k == u->key)) return u;

  if(k < u->key) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);

}

Measured memory_bytes: 19364
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(H, W, Ss):
    Ss = ['#' + S + '#' for S in Ss]
    Ss = ['#' * (W + 2)] + Ss + ['#' * (W + 2)]
    # for S in Ss:
    #     print(S)
    ans = 0
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if Ss[i][j] == '#':
                continue
            visited = [[-1] * (W + 2) for _ in range(H + 2)]
            now = 0
            visited[i][j] = now
            q = deque([(i, j, now)])
            while q:
                x, y, n = q.popleft()
                # for v in visited:
                #     print(v)
                # input()
                if Ss[x + 1][y] == '.' \
                        and visited[x + 1][y] < 0:
                    q.append((x + 1, y, n + 1))
                    visited[x + 1][y] = n + 1
                if Ss[x - 1][y] == '.' \
                        and visited[x - 1][y] < 0:
                    q.append((x - 1, y, n + 1))
                    visited[x - 1][y] = n + 1
                if Ss[x][y + 1] == '.' \
                        and visited[x][y + 1] < 0:
                    q.append((x, y + 1, n + 1))
                    visited[x][y + 1] = n + 1
                if Ss[x][y - 1] == '.' \
                        and visited[x][y - 1] < 0:
                    q.append((x, y - 1, n + 1))
                    visited[x][y - 1] = n + 1
            ans = max(ans, max([max(v) for v in visited]))
    print(ans)


if __name__ == '__main__':
    H, W = map(int, input().split())
    Ss = [input() for _ in range(H)]
    solve(H, W, Ss)


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
#define rev(s) (string((s).rbegin(), (s).rend()))

vector<char> comb(3);
vector<char> vec(3);

void func(int n,int ans,vector<char>& vec,int sum,vector<int> inp) {
    if (n==3) {
        if (sum==ans) {
            comb[0]=vec[0];
            comb[1]=vec[1];
            comb[2]=vec[2];
        }
        return;
    }
    vec[n]='+';
    func(n+1,ans,vec,sum+inp[n+1],inp);
    vec[n]='-';
    func(n+1,ans,vec,sum-inp[n+1],inp);
}

int main() {

    string s;cin>>s;
    vector<int> inp(4);
    rep(i,4) {
        inp[i]=int(s[i]-'0');
    }
    int ans=7-inp[0];

    func(0,ans,vec,0,inp);

    cout<<inp[0]<<comb[0]<<inp[1]<<comb[1]<<inp[2]<<comb[2]<<inp[3]<<"=7"<<endl;

}

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

int main() {
	const int MAX_N = 100000 + 2;
	std::vector<int> field(MAX_N, 0);

	int N;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		int x; 
		std::cin >> x;
		field[x]++;
		field[x + 3]--;
	}

	std::pair<int, int> ans = std::make_pair(0, field[0]);
	for (int i = 1; i < MAX_N; i++) {
		field[i] = field[i - 1] + field[i];

		if (ans.second < field[i])
			ans = std::make_pair(i, field[i]);
	}

	std::cout << ans.second << std::endl;
	

	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    printf("%d %d %d\n", c , a,b);
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        s: usize,
        a: [usize;n],
    }
    let mut dp = vec![0;s+1];
    dp[0]=f(2,n);
    let t=f(2,MOD-2);
    for a in a { if a<=s {
        for i in (0..=s-a).rev() {
            dp[i+a]=(dp[i+a]+dp[i]*t)%MOD;
        }
    }}
    println!("{}",dp[s]);
}
const MOD: usize=998244353;
fn f(mut a: usize, mut k: usize) -> usize {
    let mut b=1;
    while k>0 {
        if k&1==1 {
            b=b*a%MOD;
        }
        a=a*a%MOD;
        k>>=1;
    }
    b
}

Measured memory_bytes: 2220
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

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

int main() {
    string S, T; cin >> S >> T;
    int count = 0;
    repp(i,0,3) count += S[i] == T[i];
    cout << count << endl;
}


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

int mem[60][60], H, W, dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
int d[30][30];
int main()
{
loop:
  for(int i = 0; i < 30; i++)
    for(int j = 0; j < 30; j++)
      d[i][j] = 0;
  
  cin >> W >> H;
  if(!W)
    return 0;
  for(int i = 0; i < H * 2 - 1; i++)
  {
    for(int j = 0; j < W  - (i + 1) % 2; j++)
    {
      cin >> mem[i][j];
    }
  }
  d[0][0] = 1;
  queue<int> q;
  q.push(0); q.push(0);
  while(!q.empty())
  {
    int x = q.front(); q.pop();
    int y = q.front(); q.pop();
    if(x == W - 1 && y == H - 1)
    {
      cout << d[y][x] << endl;
      goto loop;
    }
    for(int i = 0; i < 4; i++)
    {
      int tx = x + dx[i];
      int ty = y + dy[i];
      if(tx >= 0 && tx < W && ty >= 0 && ty < H && !d[ty][tx])
      {
        if(dx[i] == 1 && !mem[y * 2][x] ||
           dx[i] == -1 && !mem[y * 2][tx] ||
           dy[i] == 1 && !mem[y * 2 + 1][x] ||
           dy[i] == -1 && !mem[ty * 2 + 1][x])
        {
          q.push(tx); q.push(ty);
          d[ty][tx] = d[y][x] + 1;
        }
      }
    }
  }
  cout << 0 << endl;
  goto loop;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int A, B;
    cin >> A >> B;
    cout << A*B << endl;
}


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

int main() {
  int N;
  cin >> N;
  int A = 0;
  int i = N;
  
  while(i){
    A += i % 10;
    i = i / 10;
  }
    
  if(N % A == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
while 1:
    d,e=map(int,input().split())
    mi=((d//2)**2+(d-d//2)**2)**0.5
    if d==e==0:break
    if d<=e:
        print(e-d)
    elif mi>=e:
        print(f'{mi-e:.5f}')
    else:
        ans=float("inf")
        for i in range(d//2):
            mi=abs(((i)**2+(d-i)**2)**0.5-e)
            ans=min(ans,mi)
        print(f'{ans:.5f}')


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

int main()
{
    int n, m;
    cin >> n >> m;
    int even = 0;
    int odd = 0;

    if (n == 1 && m == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    else if (n == 0)
    {
        for (int i = 0; i < m - 1; i++)
        {
            for (int j = i + 1; j < m; j++)
            {
                odd++;
            }
        }
        cout << odd << endl;
        return 0;
    }
    else if (m == 0)
    {
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                even++;
            }
        }
        cout << even << endl;
        return 0;
    }
    else
    {
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                even++;
            }
        }
        for (int i = 0; i < m - 1; i++)
        {
            for (int j = i + 1; j < m; j++)
            {
                odd++;
            }
        }
    }
    cout << even + odd << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x*res)%hell;
    x=(x*x)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);


/*class CompareDist
{
public:
    bool operator()(pair<ll,int> a,pair<ll,int> b) {
        if(a.F!=b.F)
        return a.F<b.F;
        else
        return a.S>b.S;
    }
};*/

bool comp(pair<ll,ll> a,pair<ll,ll> b){
  if(a.S!=b.S)
  return (a.S<b.S);
  else
  return a.F<b.F;
}

ll p[3];
char mat[16][16];
int si,sj,ei,ej;
vector<ll> res;
bool vis[16][16];

bool issafe(int i,int j,int n,int m){
  return (i>=0 && j>=0 && i<n && j<m && mat[i][j]=='.');
}
int dx[]={0,1,-1};
int dy[]={1,1,1};

void dfs(int i,int j,int n,int m,ll cp){
  if(i==ei && j==ej){
    //cout<<cp<<'\n';
    res.pb(cp);
    return;
  }

  vis[i][j]=true;

  for(int k=0;k<3;k++){
    int nx=i+dx[k];
    int ny=j+dy[k];
    if(issafe(nx,ny,n,m) && vis[nx][ny]==false){
        dfs(nx,ny,n,m,(cp*p[k])%hell);
    }
  }
  vis[i][j]=false;
}


void solve(){

  int test;
  //cin>>test;
  test=1;
  while(test--){
      int a,b,c;
      cin>>a>>b>>c;
      if(a+b+c>=22)
      cout<<"bust";
      else
      cout<<"win";
  }
}




/*bool issafe(int x,int y){
  return (x>=0 && y>=0 && x<n && y<m);
}*/

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  string s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n;i++){
    if(s[i]!=s[n-i-1]){
      cout<<"No";
      return 0;
    }
  }
  n=n/2;
  for(int i=0;i<n;i++){
    if(s[i]!=s[n-1-i]){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

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

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

bool isPrime(::std::int64_t x){
  for (::std::int64_t i = 2; i*i <= x; ++i) {
    if (x % i == 0) return false;
  }
  return true;
}
int main(void) {
  int64 X;
  cin >> X;
  FOR(i, X, X+1000) {
    if (isPrime(i)) {
      cout << i << endl;
      return 0;
    }
  }

}



Measured memory_bytes: 256
using System;
using System.Linq;

namespace C___Exception_Handling
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = new int[n];
            for (var i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }
            var b = a.OrderByDescending(x => x).ToArray();
            for (var i = 0; i < n; i++)
            {
                if (a[i] == b[0])
                {
                    Console.WriteLine(b[1]);
                }
                else
                {
                    Console.WriteLine(b[0]);
                }
            }
        }
    }
}

Measured memory_bytes: 23512
#include "iostream"
using namespace std;
 
int power_int(int a, int b) {
  int x = 1;
  while (b > 0) {
    x *= a;
    b--;
  }
  return x;
}
 
int main() {
  int n;
  cin >> n;
  long x[1010], y[1010], u[1010], v[1010];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
 
  int parity = (x[0] + y[0]) % 2;
 
  bool check = true;
  for (int i = 0; i < n; i++) {
    if ((x[i] + y[i] - parity) % 2 != 0) check = false;
  }
 
  if (check) {
    if (parity == 0) {
      cout << 32 << endl;
      for (int i = 30; i > -1; i--) {
        cout << power_int(2, i) << " ";
      }
      cout << 1 << endl;
      for (int i = 0; i < n; i++) {
        x[i]++;
      }
    }
    else {
      cout << 31 << endl;
      for (int i = 30; i > -1; i--) {
        cout << power_int(2, i) << " ";
      }
      cout << endl;
    }
 
    for (int i = 0; i < n; i++) {
      u[i] = x[i] + y[i];
      v[i] = x[i] - y[i];
    }
 
    for (int i = 0; i < n; i++) {
      for (int j = 30; j > -1; j--) {
        if (u[i] > 0 && v[i] > 0) {
          cout << 'R';
          u[i] -= power_int(2, j);
          v[i] -= power_int(2, j);
        }
        else if (u[i] > 0 && v[i] < 0) {
          cout << 'U';
          u[i] -= power_int(2, j);
          v[i] += power_int(2, j);
        }
        else if (u[i] < 0 && v[i] > 0) {
          cout << 'D';
          u[i] += power_int(2, j);
          v[i] -= power_int(2, j);
        }
        else {
          cout << 'L';
          u[i] += power_int(2, j);
          v[i] += power_int(2, j);
        }
      }
      if (parity == 0) cout << 'L';
      cout << endl;
    }
  }
 
  else {
    cout << "-1" << endl;
  }
}

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

int main() 
{
	int n; cin>>n;
	string s; cin>>s;
	int cnt=1;
	for(int i=0;i<n-1;i++)
	{
		if(s[i]!=s[i+1])
		{
		//	cout<<"in";
			cnt++;
		}
	}
	cout<<cnt;
		
	
	
}

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

int main() {
  int K;
  cin >> K;
  int X = 0;
  for (int i = 1; i <= K + 1; i++) {
    X = (X * 10 + 7) % K;
    if (X == 0) {
      cout << i << endl;
      break;
    }
    else if (i == K + 1) {
      cout << -1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 3656
def resolve():
    a=int(input())
    b=int(input())
    c=int(input())
    d=int(input())
    e=int(input())
    k=int(input())
    if b-a>k or c-a>k or d-a>k or e-a>k or c-b>k or d-b>k or e-b>k or d-c>k or e-c>k or e-d>k:
        print(':(')
    else:
        print('Yay!')
resolve()

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

string calc(string s, string t, char ch)
{
    int a = stoi(s), b = stoi(t);
    if(ch == '+') return to_string(a | b);
    if(ch == '*') return to_string(a & b);
    return to_string(a ^ b);
}

int solve(string s, string v)
{
    vector<string> t;
    for(int i = 0; i < (int)s.size(); i++)
    {
        if('a' <= s[i] and s[i] <= 'd')
        {
            string tmp = "";
            tmp += v[s[i] - 'a'];
            while(tmp.size() != 4) tmp.insert(tmp.begin(), '0');
            t.push_back(tmp);
        }
        else
        {
            string tmp = "";
            tmp += s[i];
            t.push_back(tmp);
        }
    }

    stack<string> st;
    for(int i = 0; i < (int)t.size(); i++)
    {
        if(t[i] == "]")
        {
            string res = "";
            while(true)
            {
                string ch = st.top(); st.pop();
                if(ch == "[") break;
                res += ch;
            }
            res = calc(res.substr(0, 4), res.substr(4, 4), res.back());
            while(res.size() != 4) res.insert(res.begin(), '0');
            st.push(res);
        }
        else
        {
            st.push(t[i]);
        }
    }
    return stoi(st.top());
}

int main(void)
{
    string s, v;
    while(cin >> s, s != ".")
    {
        cin >> v;
        int ans = solve(s, v);
        int cnt = 0;
        for(int i = 0; i <= 9999; i++)
        {
            string t = to_string(i);
            while(t.size() != 4) t.insert(t.begin(), '0');
            int v = solve(s, t);
            if(v == ans) cnt++;
        }
        cout << ans << " " << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 3224
# include <iostream>
# include <set>
using namespace std;
set <int> a;
int n,s;
void work (void)
{
	int i,j;
	for (i=1;i<=n;i++)
	{
		cin>>j;
		if (a.find (j)==a.end ())
		a.insert (j);
   else a.erase (j);
	}
	s=a.size ();
	cout<<s;
}
int main (void)
{
	cin>>n;
	work ();
	return 0;
}


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

double solve() {
    ll N;
    cin >> N;
    vector<ll> V(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> V[i];
    }
    sort(V.begin(), V.end());
    double a = V[0];
    for ( int i = 1; i < N; i++ ) {
        a = (a + V[i]) / 2;
    }
    return a;
}

int main() {
    cout.precision(15);
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int n,m,x,l=0,r=0;
int a[101];

int main(){
  int i,j;
  cin >> n >> m >> x;
  for(i=0;i<m;i++){
    cin >> a[i];
    if(a[i]>x)r++;
    else l++;
  }
  cout << min(r,l) << endl;

  return 0;
}


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

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

    if (a == 5 && b == 5 && c== 7) {
      cout << "YES" << endl;
    } else if (a == 5 && b == 7 && c== 5) {
      cout << "YES" << endl;
    } else if (a == 7 && b == 5 && c== 5) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }

}


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

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    REP(i, n) cin >> v[i];
    REP(i, n) cin >> c[i];

    int ans = 0;
    REP(i, n)
    {
        if(v[i] - c[i] > 0) ans += v[i] - c[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#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> P;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int n,m,x;
int c[12];
int a[12][12];
int minn = 1e9;

void dfs(int i,int box[],int money){
  int check = 0;
  rep(s,m){
    cout << box[s] << endl;
    if(box[s] >= x){
      check++;
    }
  }
  if(check == m){
    minn = min(minn,money);
    return;
  }
  if(i == n)return;

  dfs(i+1,box,money);
  
  for(int s = 0;s < m;s++)box[s] += a[i][s];
  dfs(i+1,box,money+c[i]);
  return;
}

int main(){
  int s,w;
  cin >> s >> w;
  if(s <= w)cout << "unsafe" << endl;
  else cout << "safe" << endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N= 1e5+5;
int t, k,n;;

int32_t main()
{
	IOS;
 	int sum=0;
 	cin>>k;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int l=1;l<=k;l++){
				sum+= __gcd(i,__gcd(j,l));
			}
		}
	}

	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3640
# coding: utf-8
num = int(input())


# def make_sum(ind):
#     return sum(range(1, ind + 1))

ans = 0
sum_num = 0

if num == 1:
    print(1)
else:
    while True:
        ans += 1
        sum_num += ans
        if sum_num < num <= (sum_num + ans + 1):
            break

    print(ans + 1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

int main() {

    int A, B, K;

    cin >> A >> B >> K;

    int k =0;
    while(true)
    {
        if(A%2==1)
            A=A-1;

        B += A/2;
        A = A/2;
        k++;
        if(k>=K)
            break;

        if(B%2==1)
            B=B-1;

        A += B/2;
        B = B/2;
        k++;
        if(k>=K)
            break;

    }

    cout<<A<<" "<<B<<endl;


    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b, n = map(int, input().split())
max_score = 0
if n < b:
    max_score = int(a * n / b) - a * (n // b)
elif n == b:
    max_score = int(a * (n-1) / b) - a * ((n-1) // b)
elif a <= b:
    max_score = a - 1
elif a >= b:
    max_score = int(a * (b-1) / b) - a * ((b-1) // b)
print(max_score)


Measured memory_bytes: 9212
#include <stdio.h>
int main(void)
{
int S,h,m,s;
scanf("%d",&S);
h=S/3600;
S=S%3600;
m=S/60;
S=S%60;
s=S;
printf("%d:%d:%d\n",h,m,s);
return(0);
}

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

#define N 110

int vis[N];

int dfs(int n) {
    if (n == 7 || n == 4) return vis[n] = 1;
    if (vis[n] != -1) return vis[n];
    vis[n] = 0;
    if (dfs(n - 7)) {vis[n] = 1; return 1;}
    if (dfs(n - 4)) {vis[n] = 1; return 1;}
    return vis[n];
}

int main() {
    int n;
    memset(vis, -1, sizeof(vis));
    scanf("%d", &n);
    printf("%s\n", dfs(n) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}


// youtube editorial
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  sort(all(a));
  /*
  s = t のとき cost = 0
  s = t も考えていい
  全パターンの bit 列を考えるから入力 sort しておいていい
  */

  /*
  まず, 各 bit で, 違うかだけが大事
  xor を考える
  s ^ t = x
  x = 0 にするのが s = t にすること
  x 探索
  ある bit の ai を何回足すか

  その bit を含めて右側の 1 の数
  その bit は 1
  右側の bit 数を r とすると, 2^r

  右側で何個 1 になるか
  縦に集計すると, どの bit も 2^(r-1)
  割合は 0, 1 が半分ずつ
  */

  ll ans = 0; // debuged, int to ll, かけるから
  rep(i, n) {
    int r = n - i - 1;
    // i を含めて右の 1 の数
    ll cnt_right_one = 0;
    add(cnt_right_one, modpow(2LL, r, mod) + r * modpow(2LL, r - 1, mod) % mod);

    add(ans, cnt_right_one * modpow(2LL, i, mod) % mod * a[i] % mod);
  }
  // ある x に対し, t を 2^n 通り決めると s は一意に決まる
  (ans *= modpow(2LL, n, mod)) %= mod;
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N;
	cin >> N;
	char s[301][301];
	for(int i=0;i<N;i++){
		cin >> s[i];
	}
	int ret=0;
	for(int i=0;i<N;i++){
		bool ok=true;
		for(int j=0;j<N;j++){
			for(int k=0;k<N;k++){
				//cerr << s[(i+j)%N][k];
				if(s[(i+j)%N][k]!=s[(i+k)%N][j]){
					ok=false;
				}
			}
			//cerr << endl;
		}
		//cerr << endl;
		if(ok){
			ret+=N;
		}
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.text.Segment;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			final int C = sc.nextInt();
			final int D = sc.nextInt();
			
			final int a = Math.max(A, C);
			final int b = Math.min(B, D);
			
			
			System.out.println(Math.max(0, b - a));
			
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22996
#include <stdio.h>

#define MAX 100000

typedef struct{
  char name[10];
  int time;
} queue;
  
void enqueue(queue);
queue dequeue(void);

int head=0,tail=0;
queue Q[MAX],t;

int main()
{
  int n,q,i,sum=0;

  scanf("%d%d",&n,&q);

  for(i=0;i<n;i++){
    scanf("%s%d",t.name,&t.time);
    enqueue(t);
  }
  while(head!=tail){
    t=dequeue(); 
    if(t.time>q){
      t.time-=q;
      enqueue(t);
      sum+=q;
    }
    else {
      printf("%s %d\n",t.name,t.time+sum);
      sum+=t.time;
    }
    
  }
  
  return 0;
  
}

void enqueue(queue x){
  Q[tail] = x;
  if(tail+1==MAX) tail=0;
  else tail++;
}

queue dequeue(){
  queue x;
  x=Q[head];
  if(head+1==MAX) head=0;
  else head++;
  return x;
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 5e5 + 10;
int N, M;
LL fact[maxn], fact_inv[maxn];
LL qpow(LL a, LL b)
{
    LL res = 1;
    a %= MOD;
    while(b)
    {
        if(b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
void preprocess()
{
    fact[0] = 1;
    for(int i = 1; i <= M; i++)
        fact[i] = fact[i-1] * i % MOD;
    fact_inv[M] = qpow(fact[M], MOD - 2);
    for(int i = M; i >= 1; i--)
        fact_inv[i-1] = fact_inv[i] * i % MOD;
}
LL comb(int a, int b)
{
    if(a < 0 || b < 0 || a < b)
        return 0;
    else
        return fact[a] * fact_inv[b] % MOD * fact_inv[a-b] % MOD;
}
LL perm(int a, int b)
{
    if(a < 0 || b < 0 || a < b)
        return 0;
    else
        return fact[a] * fact_inv[a-b] % MOD;
}
int main()
{
    scanf("%d %d", &N, &M);
    preprocess();
    LL ans = 0;
    for(int K = 0; K <= N; K++)
        ans = (ans +  qpow(-1, N - K) * comb(N, K) % MOD * perm(M, N - K) % MOD * qpow(perm(M - N + K, K), 2) % MOD) % MOD;
    printf("%lld\n", (ans % MOD + MOD) % MOD);
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf  = LLONG_MAX;
const ll minf = LLONG_MIN;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cerr << #x << " " << x << endl

vector<ll> adj[maxn];

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

    ll n,m;
    cin >> n >> m;
    vector<ll> v(n+1);

    for(ll i=0 ; i<n ; ++i) cin >> v[i+1];

    for(ll i=0,a,b ; i<m ; ++i)
    {
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    ll cnt=0;

    for(ll i=1 ; i<=n ; ++i)
    {
        bool flag = true;
        for(auto x : adj[i])
        {
            if(v[x] >= v[i])
            {
                flag = false;
                break;
            }
        }

        if(flag) cnt++;
    }    

    cout << cnt;

    return 0;
} 

Measured memory_bytes: 9788
import java.util.Scanner;

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

        char[] S = scanner.next().toCharArray();

        int count = 0;

        if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R') {
            count = 3;
        } else if ((S[0] == 'R' && S[1] == 'R')|| (S[1] == 'R' && S[2] == 'R')) {
            count = 2;
        } else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R') {
            count = 1;
        }
        System.out.println(count);

    }
}


Measured memory_bytes: 35500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
    int n, h, now = -1, buf = 0, ans = 0;
    cin >> n;
    rep(i, n) {
        cin >> h;
        if(now >= h) {
            buf++;
        }
        else {
            ans = max(ans, buf);
            buf = 0;
        }
        now = h;
    }
    ans = max(ans, buf);
    cout << ans << endl;
}

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

using namespace std;

main(){
	int a,b,c,d,e;
	int k=0;
	int l=0;
	cin >>a >>b >>c >>d >>e;
	if (a < b && a < c){
		k=k+a;
	}
	else if (b < a && b < c){
		k=k+b;
	}
	else{
		k=k+c;
	}
	if (e > d){
		l=l+d;
	}
	else {
		l=l+e;
	}
	int g=k+l-50;
	printf("%d\n",g);
	}




Measured memory_bytes: 3224
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    a.sort(reverse=True)
    print(sum(a[1:2*n:2]))
    return

#Solve
if __name__ == "__main__":
    solve()


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

using namespace std;

void max_self(long long& a , long long b){
  a = max(a , b);
}

int main() {
  int n ; cin>>n;
  vector<pair<long long, int> > v;
  for(int i = 0 ; i < n; ++i){
    long long x ; cin>>x;
    v.emplace_back(x , i);
  }
  sort(v.rbegin() , v.rend());
  vector<long long>dp(n + 1, -1000000009);
  dp[0] = 0;
  for(int i = 0 ; i < n; ++i){
    long long cst = v[i].first;
    int p = v[i].second;
    vector<long long> new_dp(n + 1 , -1000000009);
    for(int j = 0 ; j <= i; ++j){
      max_self(new_dp[j + 1] , dp[j] + abs(p - j)  * cst);
      max_self(new_dp[j] , dp[j] + abs(n - 1 - (i - j) - p) * cst);
    }
    swap(new_dp , dp);
  }
  cout<<*max_element(dp.begin() , dp.end())<<"\n";
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

template <class T>
T fexp(T x, long long e) {
	T ans(1);
	for(; e > 0; e /= 2) {
		if(e & 1) ans = ans * x;
		x = x * x;
	}
	return ans;
}

const int MOD = 1e9 + 7;

template <int mod = MOD>
struct modBase {
	modBase(int v = 0) : val(v) {}
	int val;
 
	void operator += (modBase<mod> o) { *this = *this + o; }
	void operator -= (modBase<mod> o) { *this = *this - o; }
	void operator *= (modBase<mod> o) { *this = *this * o; }
	modBase<mod> operator * (modBase<mod> o) { return (int)((long long) val * o.val % mod); }
	modBase<mod> operator / (modBase<mod> o) { return *this * fexp(o, mod - 2); }
	modBase<mod> operator + (modBase<mod> o) { return val + o.val >= mod ? val + o.val - mod : val + o.val; }
	modBase<mod> operator - (modBase<mod> o) { return val - o.val < 0 ? val - o.val + mod : val - o.val; }
};

const int ms = 100100;
modBase<> fat[ms];

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	fat[0] = 1;
	for(int i = 1; i < ms; i++) {
		fat[i] = fat[i-1] * i;
	}
	int n;
	std::cin >> n;
	std::vector<modBase<>> sum(n + 1, 0);
	for(int i = 1; i <= n; i++) {
		sum[i] = sum[i - 1] + fexp(modBase<>(i), MOD - 2);
	}
	auto f = [&](int x) {
		return sum[x];
	};
	modBase<> ans(0);
	for(int i = 1; i <= n; i++) {
		modBase<> wtf = f(i) + f(n-i+1) - 1;
		int v;
		std::cin >> v;
		ans = ans + wtf * v;
	}
	std::cout << (ans * fat[n]).val << '\n';
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int W = Integer.parseInt(st.nextToken());
		int[] v = new int[n];
		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(reader.readLine());
			v[i] = Integer.parseInt(st.nextToken());
			w[i] = Integer.parseInt(st.nextToken());
		}
		reader.close();
		System.out.println(getMaxValue(n, W, v, w));
	}

	private int getMaxValue(int n, int W, int[] values, int[] weigths) {
		int[][] dp = new int[n+1][W+1];
		for (int i = 0; i < n; i++) {
			int w = weigths[i];
			for (int j = 0; j <= W; j++) {
				if (w <= j) {
					dp[i+1][j] = Math.max(dp[i][j], dp[i][j-w] + values[i]);					
				} else {
					dp[i+1][j] = dp[i][j];					
				}
			}
		}
		return dp[n][W];
	}
}



Measured memory_bytes: 29072
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;


int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i] >> B[i];
	}

	//mapを使う方法
	//TreeMap -> 順番がソートされる
	//HashMap -> 順番がソートされない
	map<int, long long> m;

	for (int i = 0; i < N; i++)
	{
		//A円のお店にはB個追加されたよ
		if (m.count(A[i])) m[A[i]] += B[i];
		else m[A[i]] = B[i];
	}

	long long ans = 0;
	for (auto shop : m) {
		long long buy = min((long long)M, shop.second);
		ans += buy * shop.first;
		M -= (int)buy;
	}

	cout << ans << endl;
}



Measured memory_bytes: 7296
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var (n, k) = (nk[0], nk[1]);
        var snukes = Enumerable.Range(1, n);
        for (int i = 0; i < k; i++)
        {
            int.Parse(Console.ReadLine());
            snukes = snukes.Except(Console.ReadLine().Split().Select(int.Parse).ToArray());
        }
        Console.WriteLine(snukes.Count());
    }
}

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

int main() {
	ll n,ans=0;
	cin>>n;
	for(ll i=1;i<=n;i++){
		ll now=i;
		ll cnt=0;
		while(now!=0){
			now/=10;
			cnt++;
		}
		if(cnt%2!=0){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(10**9)
n = int(input())

def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)

num = factorial(n)

ans = 1
for i in range(2, n+1):
    count = 0
    while num % i == 0:
        count += 1
        num = num // i
    ans *= (count + 1)

print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3700
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

if v-w <= 0:
  print('NO')
else:  
  if b<a:
    if (a-b)/(v-w)<=t:
      print('YES')
    else:
      print('NO')
  else:
    if (b-a)/(v-w)<=t:
      print('YES')
    else:
      print('NO')

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

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i < 1001; ++i) {
        auto j = (double)i;
        if (floor(j * 0.08) == a && floor(j * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

int A, B;
string S;
bool k = false;
bool ans = true;

void solve() {
  for (int i = 0; i < A + B + 1; ++i) {
    if (i == A){
      if (S[i] != '-'){
        ans = false;
      }
    }else{
      if (S[i] == '0' || S[i] == '1' || S[i] == '2' || S[i] == '3' || S[i] == '4' || S[i] == '5' || S[i] == '6' || S[i] == '7' || S[i] == '8' || S[i] == '9'){
          k = true;
      }
      if (!k){ans = false;}
      k = false;
    }
  }
  if (ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

int main() {
  cin >> A >> B;
  cin >> S;
  solve();
  return 0;
}


Measured memory_bytes: 256