akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Sep 13 21:03:29 JST 2020
 **/

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

signed main() {
    Int n;
    std::cin >> n;
    std::vector<Int> x(n), y(n);
    REP(i, n) std::cin >> x[i] >> y[i];
    Int ans = -1;
    REP(t, 2) {
        Int mi = 1e18, ma = -1e18;
        REP(i, n) {
            chmin(mi, t ? x[i] + y[i] : x[i] - y[i]);
            chmax(ma, t ? x[i] + y[i] : x[i] - y[i]);
        }
        chmax(ans, ma - mi);
    }
    std::cout << ans << std::endl;
}


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

int main(){
    int n;
    cin >> n;
    set<string> a;
    rep(i,n){
        string s;
        cin >> s;
        a.insert(s);
    }
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 19232
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> a;
  vector<int> b;
  vector<string> op;
  int cnt;
  for(int i = 0; i < 1e6; i++){
    int atmp, btmp;
    string optmp;
    cin >> atmp >> optmp >> btmp;
    if(optmp == "?"){
      cnt = i;
      break;
    }
    a.push_back(atmp);
    b.push_back(btmp);
    op.push_back(optmp);
  }
  REP(i, cnt){
    if(op.at(i) == "+"){
      cout << a.at(i) + b.at(i) << endl;
    }else if(op.at(i) == "-"){
      cout << a.at(i) - b.at(i) << endl;   
    }else if(op.at(i) == "*"){
      cout << a.at(i) * b.at(i) << endl;
    }else if(op.at(i) == "/"){
      cout << a.at(i) / b.at(i) << endl;
    }
  }
}


Measured memory_bytes: 3200
/* {{{ Definitions */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ios>
#include <utility>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
/* }}}------------------------------------------- */
int N, K;
string S;
int ans;
void solve(){
	rep(i, N){
		if(S[i] == 'L' && i != 0){
			ans += (S[i - 1] == 'L');
		}
		else if(S[i] == 'R' && i != N - 1){
			ans += (S[i + 1] == 'R');
		}
	}
	ans += K * 2;
	cout << min(N - 1, ans) << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> K;
	cin >> S;
		solve();
	return 0;
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int A, B, C;
signed main(){
    cin >> A >> B >> C;
    if(A+B+C >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200;
typedef long long ll;

int n,ans_dp,mdp,ch[N];ll ans_lf;
vector<int>g[N];
void dfs(int x,int dp,int fa=-1){
	int sz=0;mdp=max(mdp,dp);
	for(int j:g[x])if(j!=fa){
		++sz;dfs(j,dp+1,x);
	}
	ch[dp]=max(ch[dp],sz);
}

int main(){
	cin>>n;
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].push_back(y);g[y].push_back(x);
	}
	ans_dp=n;ans_lf=n;
	for(int i=1;i<=n;++i){
		memset(ch,0,sizeof ch);mdp=0;
		dfs(i,1);
		ll tmp=1;
		for(int i=1;i<mdp;++i)tmp*=ch[i];
		if(mdp<ans_dp||(mdp==ans_dp&&tmp<ans_lf)){
			ans_dp=mdp;ans_lf=tmp;
		}
		for(int j:g[i])if(j>i){
			memset(ch,0,sizeof ch);mdp=0;
			dfs(i,1,j);dfs(j,1,i);
			ll tmp=2;
			for(int i=1;i<mdp;++i)tmp*=ch[i];
			if(mdp<ans_dp||(mdp==ans_dp&&tmp<ans_lf)){
				ans_dp=mdp;ans_lf=tmp;
			}
		}
	}
	cout<<ans_dp<<' '<<ans_lf<<endl;
	return 0;
}



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

int main()
{
	int m, f, b;

	cin >> m >> f >> b;

	if (m >= b)
		cout << 0 << endl;
	else if (m + f < b)
		cout << "NA" << endl;
	else
		cout << b - m << endl;

	return 0;
}


Measured memory_bytes: 3084
N, A, B = map(int, input().split())

if abs(A-B) % 2 == 0:
    print(abs(A-B)//2)
else:
    M = max(A, B)
    m = min(A, B)
    print(min(N-m, M-1, (N-M+1)+(M-m)//2, m+(M-m)//2))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define _LIBCPP_DEBUG 0
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(){
///////////////////////////////////////////////////////////
ll n;
ll b=0;
cin >> n;
ll ans=9223372036854775807;
for(ll i=1;i*i<=n;i++){
    if(n%i==0){
        b = n/i;
        ans =min(ans,i+b-2); 
    }
}
cout << ans << endl;
//////////////////////////////////////////////////////////
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int main (void) {

    int N, L;
    cin >> N >> L;

    int minx = 1000; 

    for (int i = 0; i < N; i++) {
        if (abs(L + i) < abs(minx)) {
            minx = L + i;
        }
    }

    int sum = 0;

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

    sum -= minx;

    cout << sum << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

W, H, x, y, r = list(map(int, input().split()))

if y + r > H: # Up
    print("No")
elif y - r < 0: # Down
    print("No")
elif x - r < 0: # Left
    print("No")
elif x + r > H: # Right
    print("No")
else:
    print("Yes")



Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int

bool is_AC( string s, int index ) {
  if( s[index] == 'C' && s[index - 1] == 'A' ) return true;
  else return false;
}
int main () {
  int n,q;
  string s;
  cin >> n >> q >> s;
  vector< int > l(q),r(q),r_sum(n);
  for ( int i = 0; i < q; ++i ) {
    cin >> l[i] >> r[i];  
  }
  
  for ( int i = 0; i < s.size(); ++i ) {
    if ( i == 0 ) continue;
    if ( is_AC( s, i ) ) {
      ++r_sum[i];
    }
    r_sum[i] += r_sum[i - 1];
  }

  for ( int i = 0; i < q; ++i ) {
    cout << r_sum[r[i] - 1] - r_sum[l[i] - 1] << endl;  
  }
  return 0;
}


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

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

int main(void) {
    string s;
    ll k;
    cin >> s >> k;

    int i = 0;
    while(s[i] == '1') {
        i++;
    }

    if(i >= k) {
        cout << '1' << endl;
    }else{
        cout << s[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

const int maxn = 65;
const int mod = 1e9 + 7;

int a[maxn];

LL qpow(LL a,LL b) {
    LL res = 1;
    while(b) {
        if(b&1) {
            res = (res * a)%mod;
        }
        a = (a * a) % mod;
        b >>= 1;
    }
    return res%mod;
}

int main() {
    LL n;
    while(cin >> n) {
        memset(a,0,sizeof(a));
        for(int i = 1 ; i <= n ; i++) {
            LL x;
            cin >> x;
            for(int j = 0 ; j < 62 ; j++) {
                if(x & (1LL << j)) a[j]++;
            }
        }
        LL ans = 0;
        for(int j = 0 ; j < 62 ; j++) {
            ans = ((ans%mod) + ((((n-a[j])%mod)*(a[j]%mod))%mod*qpow(2LL,j))%mod)%mod;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,a=0,b=0,c=0;
    char S[3];
    scanf("%s",&S);
    for(int i=0;i<3;i++){
        if(S[i]=='a'){
            a++;
        }else if(S[i]=='b'){
            b++;
        }else if(S[i]=='c'){
            c++;
        }
    }

    if((a==1)&&(b==1)&&(c==1)){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll a,b;
  cin>>a>>b;
  if(a)a--;
  ll t=2;
  if(a%t){
    if((a/t)%t==0)a=1;
    else a=0;
  }else if((a/t)%t)a++;
 
  if(b%t){
    if((b/t)%t==0)b=1;
    else b=0;
  }else if((b/t)%t)b++;

  //  cout<<a<<" "<<b<<endl;
  cout<<(a^b)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  set<int> S;
  int A;
  for (int i = 0; i < N; i++){
    cin >> A;
    S.insert(A);
  }
  cout << (S.size() == N ? "YES" : "NO");
}

Measured memory_bytes: 9600
# import numpy as np
import math
N = int(input())
a = list(map(int, input().split()))

two_count = 0
four_count = 0
for i in a:
    if i >= 4 and i % 4 == 0:
        four_count += 1
    elif i >= 2 and i % 2 == 0:
        two_count += 1

if two_count <= 1:
    if len(a) == 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= len(a)//2 else "No")
else:
    check = len(a) - two_count
    if check == 0:
        print("Yes")
    elif check <= 2:
        print("Yes" if four_count >= 1 else "No")
    else:
        print("Yes" if four_count >= math.ceil(check/2) else "No")

Measured memory_bytes: 15020
#include <stdio.h>

int main(void) {
  int n, q, i, key, flag = 0, count = 0;
  int left, mid, right;
  scanf("%d", &n);
  int S[n];
  for(i = 0; i < n; i++) scanf("%d", &S[i]);
  scanf("%d", &q);
  int T[q];
  for(i = 0; i < q; i ++) scanf("%d", &T[i]);

  for(i = 0; i < q; i ++) {
    key = T[i];
    left = 0;
    right = n;
    while(left < right) {
      mid = (left + right) / 2;
      if(S[mid] == key) {
        count ++;
        break;
      }
      else if(key < S[mid]) {right = mid;}
      else {left = mid + 1;}
    }
  }

  printf("%d\n", count);
  return 0;

}

Measured memory_bytes: 2268
a = [0]*26
s = input()
for i in range(len(s)) :
	a[ord(s[i])-ord('a')] += 1
cek = True
for i in range(len(a)) :
	if a[i] % 2 == 1:
		cek = False
		break
if (cek) :
	print("Yes")
else :
	print("No") 

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
int vis[1000005];
int a[200005];

int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	std::sort(a+1,a+1+n);
	int cnt = 0;
	int upper = 1000000;
	//same segment...
	int p = 1;
	while(p<=n){
		int u = a[p];
		int np = p;
		while(np+1<=n && a[np+1]==a[p]) np++;
		if(!vis[u]){ 
			if(np==p) cnt++;
			for(int i = u; i <= upper; i+=u) vis[i] = 1;
		}
		p = np+1;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 6412
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#include <complex>
typedef complex<double> P;
double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}
int ccw(P a, P b,P c) {
	P e = b - a;
	P f = c - a;
	if (cross(e, f) > eps) {
		return 1;
	}
	if (cross(e, f) < -eps) {
		return -1;
	}
	if (dot(e, f) < -eps) return 2;
	if (abs(e) < abs(f)) return -2;
	return 0;
}
bool intersect(P a, P b, P c, P d) {
	if (ccw(a, b, c) * ccw(a, b, d) <= 0) {
		if (ccw(c, d, a) * ccw(c, d, b) <= 0){
			return 1;
		}
	}
	return 0;
}
double getDistanceLP(P a, P b, P c) {
	return abs(cross(b - a, c - a) / abs(b - a));
}
double getDistanceSP(P a, P b, P c) {
	if (dot(b - a, c - a) < 0.0) return abs(c - a);
	if (dot(a - b, c - b) < 0.0) return abs(c - b);
	return getDistanceLP(a, b, c);
}
double getDistance(P a, P b, P c, P d) {
	if (intersect(a, b, c, d)) return 0.0;
	return min({ getDistanceSP(a, b, c), getDistanceSP(a, b, d), getDistanceSP(c, d, a), getDistanceSP(c, d, b) });
}
int moved[27] = {};
int used[27] = {};
int main() {
	string s, t;
	cin >> s >> t;
	REP(i, 26) {
		moved[i] = -1;
		used[i] = -1;
	}
	for (int i = 0; i < s.length(); ++i) {
		if (moved[s[i] - 'a'] == -1) {
			moved[s[i] - 'a'] = t[i] - 'a';
			if (used[t[i] - 'a'] != -1) {
				cout << "No" << endl;
				return 0;
			}
			used[t[i] - 'a'] = 1;
		}
		else {
			if (moved[s[i] - 'a'] != t[i] - 'a') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

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

  int D, G; cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; i++) cin >> p[i] >> c[i];

  int n = 1;
  for (int i = 0; i < D; i++) n *= 2;

  int ans = 1000;
  for (int x = 0; x < n; x++) {
    int y = x, m = 0, sum = 0, count = 0;
    for (int i = 0; i < D; i++) {
      if (y % 2) {
        sum += (i + 1) * 100 * p[i] + c[i];
        count += p[i];
      }
      else m = max(m, i);
      y /= 2;
    }
    if (sum < G) {
      int point = (m + 1) * 100;
      int problem = (G - sum + point - 1) / point;
      if (problem >= p[m]) continue;
      count += problem;
    }
    ans = min(ans, count);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int k,n;cin>>k>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  vector<int> dist(n);
  rep(i,n-1){
    dist[i]=abs(a[i+1]-a[i]);
  }
  dist[n-1]=k-a[n-1]+a[0];
  int mx=0;
  rep(i,n){
    mx=max(mx,dist[i]);
  }
  int ans=k-mx;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int n, cnt[13];
bool H[25];

int count() {
    int i = 0, j = -1, ans = 24;
    while (i < 25) {
        if (H[i]) {
            if (j >= 0) ans = min(ans, i-j);
            j = i;
        }
        i++;
    }
    return ans;
}

int solve(int h) {
    if (h == 12) {
        if (cnt[h] > 0) H[h] = true;
        int a = count();
        H[h] = false;
        return a;
    } else {
        if (cnt[h] == 0) return solve(h+1);
        else if (cnt[h] == 1) {
            H[h] = true;
            int a1 = solve(h+1);
            H[h] = false;
            H[24-h] = true;
            int a2 = solve(h+1);
            H[24-h]= false;
            return max(a1, a2);
        } else if (cnt[h] == 2) {
            H[h] = H[24-h] = true;
            int a = solve(h+1);
            H[h] = H[24-h] = false;
            return a;
        } else return 0;
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int h; cin >> h;
        cnt[h]++;
    }
    H[0] = H[24] = true;
    if (cnt[0] > 0 || cnt[12] > 1) { cout << "0\n"; }
    else cout << solve(1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

struct edge{ll from,to,cost;};
struct graph{
    ll V; //1番でかい頂点番号+1
    vector<edge> es; //辺
    vector<ll> d; //最短距離
 
    graph(ll n){
        init(n);
    }
 
    void init(ll n){ //n:頂点数
        V=n+1; //1-origin
        d.resize(V);
        rep1(i,V-1) d[i]=INF; //1~n
    }
 
    void add_edge(ll from,ll to,ll cost){
        edge e;
        e.from=from;
        e.to=to;
        e.cost=cost;
 
        es.pb(e);
    }
 
    bool bellman_ford(ll s){//O(|V||E|)
        bool loop=false;
        rep1(i,V-1) d[i]=INF;
        d[s]=0;
        
        rep1(i,(V-1)*2){
            bool update=false;
            rep(j,sz(es)){
                edge e=es[j];
                if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                    d[e.to]=d[e.from]+e.cost;
                    if(i>=V-1){
                        d[e.to]=-INF;
                        loop=true;
                    }
 
                    update=true;
                }
            }
            if(!update) break;
        }
 
        if(loop) return true;
        else return false;
    }
};
/*
 bool(BellmanFord)がtrue:負閉路あり
                    false:負閉路なし
 graph.d[目的地]が-INF:目的地に関与する負の閉路あり
 */

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,M; cin>>N>>M;
    graph G(N);
    rep(i,M){
        ll A,B,C; cin>>A>>B>>C;
        G.add_edge(A-1,B-1,-C);
    }
    G.bellman_ford(0);
    
    if(G.d[N-1]==-INF) cout<<"inf";
    else cout<<-G.d[N-1];
}



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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

struct Comp 
{
  bool operator()(const std::tuple<string,int, int> &a, const std::tuple<string,int, int> &b) 
  {
    if (get<0>(a) != get<0>(b)) {
        return get<0>(a) < get<0>(b);
    }
    return get<1>(a) > get<1>(b);
  }

};

vector< tuple<string,int,int> > v;
int n,temp;
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>n;
    rep(i,1,n)
    {
        cin>>s>>temp;
        v.emplace_back(make_tuple(s,temp,i));
    }
    Comp comp_functor;
    sort(v.begin(), v.end(), comp_functor);
    for (int i = 0; i < v.size(); i++)  
        cout<< get<2>(v[i])<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int N ,marurin = 1;
    cin>>N;
    while(1){
        marurin = marurin * 2;
        if(marurin > N){
            break;
        }
    }
    cout << marurin / 2 << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD 1000000007

ll fact[200000], ifact[200000], dp[100000];
int h, w, a, b;

//二分累乗法
ll binpow(ll x, ll e)
{
  ll a = 1;
  ll p = x;

  while(e > 0)
  {
    if(e%2 == 0) {p = (p*p) % MOD; e /= 2;}
    else {a = (a*p) % MOD; e--;}
  }

  return a;
}

int main(void)
{
  fact[0] = 1;
  ifact[0] = 1;
  scanf("%d %d %d %d", &h, &w, &a, &b);
  for(int i = 1; i < h+w; i++)
  {
    fact[i] = fact[i-1] * i % MOD;
    ifact[i] = binpow(fact[i], MOD-2);
    //printf("i:%d fact:%d ifact:%d\n", i, fact[i], ifact[i]);
  }

  for(int i = 0; i < h-a; i++)
      dp[i] = ((fact[b-1+i]*ifact[b-1]%MOD)*ifact[i]%MOD);

  ll ans = 0LL;
  for(int i = 0; i < h-a; i++)
      ans = (ans + ((dp[i]*fact[h+w-b-i-2]%MOD)*ifact[h-i-1]%MOD)*ifact[w-b-1]%MOD) % MOD;

  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

lli ba[100100],cb[100100];
lli sumBA[100100];

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n),b(n),c(n);
	REP(i,0,n)cin>>a[i];
	REP(i,0,n)cin>>b[i];
	REP(i,0,n)cin>>c[i];

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());

	//a on b

	REP(i,0,n){
		lli cnt = (lli)(lower_bound(a.begin(),a.end(),b[i])-a.begin());
		ba[i]=cnt;
	}

	REP(i,0,n){
		sumBA[i+1] = sumBA[i]+ba[i];
	}

	lli ans = 0;
	//c on a
	REP(i,0,n){
		lli cnt = (lli)(lower_bound(b.begin(),b.end(),c[i])-b.begin());
		if(DEBUG)cout<<"caCnt="<<cnt<<endl;
		ans += sumBA[cnt];
	}

	cout<<ans<<endl;

	return 0;
}

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

const int MAXN = 305;
const int INF = 0x3f3f3f3f;

int N, M;
char mat[MAXN][MAXN];
string col[MAXN];
int trans[2 * MAXN][MAXN];
int dp[MAXN][MAXN];

void load() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++)
		scanf("%s", mat[i]);
}

void mn(int &ref, int val) {
	ref = min(ref, val);
}

int calc(string a, string b) {
	memset(trans, 0, sizeof trans);
	for (int i = 0; i <= 2 * N; i++) 
		for (int j = 0; j < N; j++) {
			int pos = j + i - N;
			if (pos >= 0 && pos < N)
				trans[i][j] = a[j] == b[pos];
			if (j)
				trans[i][j] += trans[i][j - 1];
		}
	
	memset(dp, INF, sizeof dp);
	dp[0][0] = 0;
	for (int i = 0; i <= N; i++)
		for (int j = 0; j <= N; j++) {
			if (!i && !j) continue;
			if (i) mn(dp[i][j], dp[i - 1][j]);
			if (j) mn(dp[i][j], dp[i][j - 1]);
			if (!i || !j) continue;
			int diff = i - j;
			int lo = max(0, diff);
			dp[i][j] += trans[N - diff][i - 1] - (lo ? trans[N - diff][lo - 1] : 0);
		}
	
	return dp[N][N];
}

int solve() {
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			col[j] += mat[i][j];
	
	int sol = 0;
	for (int i = 1; i < M; i++)
		sol += calc(col[i], col[i - 1]);
	
	return sol;		
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};




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

    string s,t;
    cin >> s >> t;
    char c = s[0];
    map<char,int> smemo;
    map<char,int> tmemo;
    rep(i,s.length()){
        smemo[s[i]]++;
        tmemo[t[i]]++;
    }
    bool ok = true;
    rep(i,s.length()){
        if(smemo[s[i]] != tmemo[t[i]]){
            ok = false;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 916
N, M, X, Y = gets.split.map(&:to_i)
x_list = gets.split.take(N).map(&:to_i)
y_list = gets.split.take(M).map(&:to_i)
range = (X + 1)..Y
is_no_war = range.any? do |n|
  x_list.all? { |x| x < n } && y_list.all? { |y| y >= n }
end
ans = is_no_war ? 'No War' : 'War'
puts ans


Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-11;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

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

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}


ll N;
vector<ll> E[200000];
bool used[200000];
ll x, y;

void dfs(ll now){
  if(used[now]) return;
  used[now] = 1;
  if(now < 100000) x++;
  else y++;
  for(ll to: E[now]){
    if(used[to]) continue;
    dfs(to);
  }
}

void solve(){
  cin >> N;
  rep(i, N){
    ll x, y;
    cin >> x >> y;
    x--, y--;
    y += 100000;
    E[x].pb(y);
    E[y].pb(x);
  }
  ll ans = 0;
  rep(i, 200000){
    x = 0, y = 0;
    dfs(i);
    ans += x * y;
  }
  cout << ans - N << endl;
}



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


Measured memory_bytes: 11520
import math
N = int(input())
A = list(map(int,input().split()))

judge = 0
counter = 0

while judge == 0:
	for i in range(0,N):
		if A[i] % 2 == 1:
			judge = 1
		
		A[i] = A[i] //2
		
	counter = counter + 1

counter = counter -1
print(counter)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
vector<int> E[100005];
int B[100005], H[100005];
bool used[100005];
int cnt[2];
ll sumDiff;
int cycleTop, cycleBottom;
vector<int> cyc;
bool findCycle(int x, int h = 0) {
	H[x] = h;
	for (int y : E[x]) {
		if (H[y] == -1) {
			if (findCycle(y, h + 1)) {
				if (H[x] >= H[cycleTop]) cyc.push_back(x);
				return true;
			}
		} else if (H[y] < H[x] - 1) {
			// Backedge.
			cycleTop = y;
			cycleBottom = x;
			cyc.push_back(x);
			return true;
		}
	}
	return false;
}
void getCnt(int x, int h = 0) {
	cnt[h & 1]++;
	B[x] = (h & 1) ? 1 : -1;
	used[x] = true;
	for (int y : E[x]) {
		if (used[y]) continue;
		getCnt(y, h + 1);
	}
}
void dfs(int x) {
	used[x] = true;
	for (int y : E[x]) {
		if (used[y]) continue;
		dfs(y);
		sumDiff += abs(B[y]);
		B[x] += B[y];
	}
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	if (m == n) {
		memset(H, -1, sizeof(H));
		assert(findCycle(1));
		getCnt(cycleTop);
		if (cyc.size() & 1) {
			if ((cnt[0] - cnt[1]) & 1) {
				printf("-1\n");
				return 0;
			}
			int v = (cnt[0] - cnt[1]) / 2;
			B[cycleTop] += v;
			B[cycleBottom] += v;
			sumDiff += abs(v);
		} else if (cnt[0] != cnt[1]) {
			printf("-1\n");
			return 0;
		}
//		dbv(cyc);
//		db2(cycleTop, cycleBottom);
		memset(used, 0, sizeof(used));
		dfs(cycleTop);
		if (cyc.size() % 2 == 0) {
			vector<int> bs;
			for (int x : cyc) {
				bs.push_back(B[x]);
			}
			nth_element(bs.begin(), bs.begin() + bs.size() / 2, bs.end());
			int mid = bs[bs.size() / 2];
			for (int x : cyc) {
				sumDiff -= abs(B[x]);
				sumDiff += abs(B[x] - mid);
			}
		}
		printf("%lld\n", sumDiff);
	} else {
		getCnt(1);
		memset(used, 0, sizeof(used));
		dfs(1);
		printf("%lld\n", cnt[0] != cnt[1] ? -1 : sumDiff);
	}
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w;
string s[52];

int di[4] = { 1, 0, -1,  0 };
int dj[4] = { 0, 1,  0, -1 };

int main() {
	cin >> h >> w;
	s[    0] = string(w + 2, '.');
	inc1(i, h) { cin >> s[i]; s[i] = '.' + s[i] + '.'; }
	s[h + 1] = string(w + 2, '.');
	
	bool ans = true;
	inc1(i, h) {
	inc1(j, w) {
		int t = 0;
		inc(k, 4) {
			int ii = i + di[k];
			int jj = j + dj[k];
			t += (s[ii][jj] == '#' ? 1 : 0);
		}
		if(s[i][j] == '#' && t == 0) { ans = false; }
	}
	}
	
	cout << (ans ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split('')

ans = 0

(2**(s.size-1)).times{|i|
  str = ''
  bit = i
  for j in 0...s.size
    str += s[j]
    f = bit&1
    str += '+' if f==1
    bit = bit/2
  end
  ans += eval(str)
}

p ans


Measured memory_bytes: 1916
import java.util.*;
import java.util.TreeMap;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collections;
 
class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        String[] S = new String[N];
        ArrayList<String> list = new ArrayList<String>();

        for(int i=0; i<N; i++){
            S[i] = sc.next();
            list.add(S[i]);
        }

        Collections.sort(list);
        int ans = 0;
        String a = "";
        for(int i=0; i<N; i++){
            if(!list.get(i).equals(a)){
                ans += 1;
                a = list.get(i);
            }
        }
        System.out.println(ans);
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int R, G, B, N; cin >> R >> G >> B >> N;

    int ans = 0;
    FOR(i,0,N/R) {
        int a = N-i*R;
        FOR(j,0,a/G){
            int c = a-j*G;
            if (c%B == 0) ++ans;
        }
    }
    cout << ans << '\n';
}



Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans = 0

if a + b >= c * 2:
    if x < y:
        temp = a
        a = b
        b = temp
        temp = x
        x = y
        y = temp
    
    if a > 2 * c:
        ans = x * 2 * c
    else:
        ans = y * 2 * c + a * (x - y)
else:
    ans = a * x + b * y
print(ans)

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

const long double PI = (acos(-1));
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

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

  double a,b,x;
  cin >> a >> b >> x;

  double h = x/a/a;

  double h_2 = x/a/a*2;

  double ans_h, ans_deg;

  if(h_2>b){
      ans_h = 2*b - 2*x/a/a;

      ans_deg=90.0-atan(a/ans_h)*180/PI;
  }
  else {
      ans_h = x*2/a/b;

      ans_deg=90.0-atan(ans_h/b)*180/PI;
  }
  
  cout << fixed << setprecision(6) << ans_deg;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1<<29;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int a, b, c; cin >> a >> b >> c;
    int cnt = 0;
    rep(i, c){
        if( b - a >= 0){
            b -= a;
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	int N;
	cin >> N;
	int L[200];
	for(int i=0; i<2*N; i++){
		cin >> L[i];
	}
	sort(L,L+2*N);
	int ans = 0;
	for(int i=0; i<N; i++) ans += L[i*2];
	cout << ans << endl;

	return 0;
}


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

string str;

long long solve(long long sum, long long add, int now);

int main()
{

    cin >> str;

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

    return 0;
}
    
long long solve(long long sum, long long add, int now)
{
    if (now == str.size()) {
        return sum + add;
    }

    long long rec = 0;

    rec += solve(sum + add, 0, now + 1) +
            solve(sum, add * 10 + (str[now] - '0'), now + 1);

    return rec;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    string s;
    cin >> s;
    int ans = s.size() / 2;
    for(int i = 0; i < s.size(); i++) {
        ans -= s[i] == 'p';
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,ans = 0;
  string s,sta;
  cin >> sta >> n;
  for(int i=0;i<n;i++){
    cin >> s; s += s;
    if(s.find(sta) != string::npos) ans++;
  }
  cout << ans << endl;
} 

Measured memory_bytes: 1212
//
// Created by tac on 2016/10/14.
//

#include <cstdlib>
#include <iostream>

namespace  {
const int R_SIZE = 100 + 1;
const int C_SIZE = 100 + 1;

int arr[R_SIZE][C_SIZE] {};

}

int main() {
    int r, c;

    std::cin >> r >> c;
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            std::cin >> arr[i][j];
            arr[i][c] += arr[i][j];
            arr[r][j] += arr[i][j];
            arr[r][c] += arr[i][j];
        }
    }

    for (int i = 0; i < r + 1; ++i) {
        std::string sep {""};
        for (int j = 0; j < c + 1; ++j) {
            std::cout << sep << arr[i][j];
            sep = " ";
        }
        std::cout << std::endl;
    }

    return EXIT_SUCCESS;
}

Measured memory_bytes: 3168
fn main() {
    let s: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    let t: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    let mut ans = std::usize::MAX;
    for i in 0..=(s.len() - t.len()) {
        let mut res = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                res += 1;
            }
        }
        ans = std::cmp::min(ans, res);
    }
    println!("{}", ans);
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 998244353;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int l, r;
	cin >>l >>r;
	rep(i, 2020){
		if(l+i > r) break;
		if((l+i)%2019 ==0){puts("0"); return 0;}
	}
	int ans = 22222222;
	rep2(i, l, r+1) rep2(j, i+1, r+1){
		ans =min<ll>(ans, ((ll)i * j )%2019);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

const int N = 1e4 + 11;
bool isprime[N];
vector<int> primes;

void sieve(){
  fill(isprime + 2, isprime + N, true);
  
  for (int i = 2; i < N; i++){
	  if (isprime[i]){
		primes.push_back(i);
		for (int j = 2; i * j < N; j++){
		   isprime[i * j] = false;	
	    }  
	  }  
	}	
}

void solve(){
  sieve();
  int n;
  while (cin >> n){
	  vector<int> v1, v2;
	  int ret = 0;
	  for (int i = 1; i <= n; i++) v1.push_back(i);
	  for (int i = n; i >= 1; i--) v2.push_back(i);
      
	  for (int i = 1; i <= n; i++){
		 ret += isprime[i] && isprime[n - i + 1]; 
	  }
	 cout << ret << endl;  
	}	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3280
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <cmath>

constexpr long long MOD = 1000000007;

template<typename T>
constexpr T pow_mod(T a, T b, T m)
{
	T r = 1;
	while (b > 0)
	{
		if ((b & 1) != 0) r = (r * a) % m;
		a = (a * a) % m;
		b >>= 1;
	}
	return r;
}

long long pattern[100001];

int main()
{
	long long n, k;
	scanf("%lld%lld", &n, &k);

	for (long long g = k; g > 0; --g)
	{
		pattern[g] = pow_mod(k / g, n, MOD);
		for (long long gg = 2 * g; gg <= k; gg += g)
		{
			pattern[g] = (pattern[g] + (MOD - pattern[gg])) % MOD;
		}
	}
	long long ans = 0;
	for (long long g = 1; g <= k; ++g)
	{
		ans = (ans + pattern[g] * g) % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CManyRequirements {
public:
    int n, m, q;
    vector<int> a, b, c, d;

    ll dfs(vector<int>& v, int depth) {
      ll ret = 0;
      if (depth==0) {
        for(int i=1; i<=m; i++) {
          v.push_back(i);
          chmax(ret, dfs(v, depth+1));
          v.pop_back();
        }
      } else if (depth < n) {
        for(int i=v.back(); i<=m; i++) {
          v.push_back(i);
          chmax(ret, dfs(v, depth+1));
          v.pop_back();
        }
      } else {
        ll now = 0;
        rep(i, q) {
          if (v[b[i]]-v[a[i]] == c[i]) {
            now += d[i];
          }
        }
        return now;
      }
      return ret;
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      cin >> n >> m >> q;
      a.resize(q);
      b.resize(q);
      c.resize(q);
      d.resize(q);
      rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
      }
      vector<int> now;
      ll ret = dfs(now, 0);
      cout << ret << endl;

    }
};

signed main() {
  CManyRequirements solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3596
// A. 

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	int N;
	cin >> N;
	LL a[100000], b[100000];
	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i];
	}
	LL ans = 0;
	for (int i = N - 1; i >= 0; --i) {
		LL r = (ans + a[i]) % b[i];
		ans += (b[i] - r) % b[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;


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

    rep(t,k){
        vi b(n+1,0);
        rep(i,n){
            int l = max(0,i- a[i]);
            int r = min(n ,i + a[i]+1);
            ++b[l];
            --b[r];
        }
        rep(i,n) b[i+1] += b[i];
        b.pop_back();
        if(a==b) break;
        a = b;
    }
    rep(i,n) cout << a[i] << " ";
    cout<<endl;

    return 0;
}

Measured memory_bytes: 4824