akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  ll C;
  cin >> N >> C;
  vector<ll> X(N), V(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> V[i];
  }
  vector<ll> acc(N + 1);
  for (int i = 0; i < N; i++) {
    acc[i + 1] = acc[i] + V[i];
  }

  vector<ll> ccw_ma(N);
  vector<ll> ccw_i(N);
  ll ma = 0, ma_i = -1;
  for(int i = N - 1; i >= 0; i--) {
    if (acc[N] - acc[i] - (C - X[i]) > ma) {
      ma = acc[N] - acc[i] - (C - X[i]);
      ma_i = i;
    }
    ccw_ma[i] = ma;
    ccw_i[i] = ma_i;
  }

  vector<ll> cw_ma(N);
  vector<ll> cw_i(N);
  ma = 0, ma_i = -1;
  for(int i = 0; i < N; i++) {
    if (acc[i + 1] - X[i] > ma) {
      ma = acc[i + 1] - X[i];
      ma_i = i;
    }
    cw_ma[i] = ma;
    cw_i[i] = ma_i;
  }

  ll ans = 0;
  for(int i = 0; i < N; i++) {
    ans = max(ans, acc[i + 1] - X[i]);
  }
  for(int i = N - 1; i >= 0; i--) {
    ans = max(ans, acc[N] - acc[i] - (C - X[i]));
  }

  for (int i = 0; i < N - 1; i++) {
    if (ccw_i[i] == -1) continue;
    ans = max(ans, acc[i + 1] - 2 * X[i] + ccw_ma[i + 1]);
  }

  for (int i = N - 1; i >= 1; i--) {
    if (cw_i[i] == -1) continue;
    ans = max(ans, acc[N] - acc[i] - 2 * (C - X[i]) + cw_ma[i - 1]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  if (S.at(0)==S.at(1) && S.at(2)==S.at(3) && S.at(1)!=S.at(2)){ 
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;

// GCD: a > b
ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }

int main(int argc,char *argv[])
{
	ll a,b,c,k;
	std::cin >> a >> b >> c >> k;

	if (k <= a) { std::cout << k << std::endl; }
	else if (k-(a+b) <= 0) { std::cout << a << std::endl; }
	else { std::cout << 2*a+b-k << std::endl; }

	return 0;
}

Measured memory_bytes: 3632
a, b, c, x, y = map(int, input().split())
z = max(x, y)
ans = float('inf')
#ABピザの枚数をiとする
for i in range(0, 2 * z + 1, 2):
    #合計費用
    total = a * max(0, (x - (i // 2))) + b *max(0, (y - (i // 2))) + c * i
    ans = min(ans, total)
print(ans)

Measured memory_bytes: 3064
s = input()
S = []

a = "apple"
p = "peach"
A = []
P = []

for i in range(len(s)) :
    S.append(s[i])
    
for i in range(5) :
    A.append(a[i])
    P.append(p[i])

for i in range(len(S)) :
    if S[i : i + 5] == A :
        S[i : i + 5] = P
    elif S[i : i + 5] == P :
        S[i : i + 5] = A
        
for i in range(len(S)) :
    if i == len(S) - 1 :
        print(S[i])
    else :
        print(S[i], sep = "", end = "")
    


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

int main(void) {
  int a, b; cin >> a >> b;
  if (a < b) {cout << b + (b-1) << endl;}
  else if (a > b) {cout << a + (a-1) << endl;}
  else {cout << a + b << endl;}
}

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

int main(void)
{
	int n,m,l;
	int a[101][101], b[101][101];
	long long c;

	cin >> n >> m >> l;
	rep(i,n)
		rep(j,m)
	{
		cin >> a[i][j];
	}
	rep(i, m)
		rep(j, l)
	{
		cin >> b[i][j];
	}
	rep(i, n) {
		rep(j, l)
		{
			c = 0;
			rep(k,m)
				c += a[i][k] * b[k][j];
			cout << c;
			if (j<l-1) cout << " ";
		}
		cout << endl;
	}

	return(0);
}



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

struct Edge {
    int from, to;
    int id;
    Edge(int _to, int _id) :
        from(-1), to(_to), id(_id) {}
    Edge(int _from, int _to, int _id) :
        from(_from), to(_to), id(_id) {}
};

int main() {
    int N; cin >> N;
    vector<vector<Edge>> G(N);
    vector<int> deg(N);
    for(int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
        deg[a]++; deg[b]++;
    }
    vector<int> ans(N - 1);
    int mx = *max_element(deg.begin(), deg.end());
    auto dfs = [&](auto &&dfs, int cur, int pre, int color) -> void {
        for(auto &e : G[cur]) {
            if(e.to == pre) continue;
            if(++color > mx) color = 1;
            ans[e.id] = color;
            dfs(dfs, e.to, cur, color);
        }
    };
    dfs(dfs, 0, -1, 0);
    cout << mx << '\n';
    rep(i, N - 1) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 7808
N, M, X, Y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

x_list.append(X)
y_list.append(Y)

max_x = max(x_list)
min_y = min(y_list)

for i in range(X, Y + 1):
    if max_x < i and i <= min_y:
        print('No War')
        break
    else:
        pass
else:
    print('War')


Measured memory_bytes: 3060
use proconio::{fastout, input};
use std::cmp::min;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
    }
    let mut c = Vec::new();
    let mut a = Vec::new();

    for _i in 0..n {
        input! {
            s: usize,
            t: [usize; m],
        }
        c.push(s);
        a.push(t);
    }

    let mut ans = 100000000000;
    for i in 0..(1 << n) {
        let mut tans = vec![0; m];
        let mut cost = 0;
        for j in 0..n {
            if (1 << j) & i == 0 {
                cost += c[j];
                for k in 0..m {
                    tans[k] += a[j][k];
                }
            }
        }
        let mut f = true;
        for j in 0..m {
            if tans[j] < x {
                f = false;
            }
        }
        if f {
            ans = min(ans, cost);
        }
    }
    if ans == 100000000000 {
        println!("{}", -1)
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,A,B,C; cin >> N >> A >> B >> C;
    string S[N];
    rep(i,N) cin >> S[i];
    bool can=true;
    string ans;
    rep(i,N){
        if(S[i]=="AB"){
           if(A==0 && B==0) {
               can=false;
               break;
           } else if(A==1 && B==1 && i!=N-1){
               if(S[i+1]=="BC") {
                   B++; A--; ans+='B';
               } else {
                   A++; B--; ans+='A';
               }
           } else if(A>=B){
               A--; B++;
               ans+='B';
           } else {
               A++; B--;
               ans+='A';
           }
        }
        else if(S[i]=="BC"){
           if(C==0 && B==0) {
               can=false;
               break;
           } else if(C==1 && B==1 && i!=N-1){
               if(S[i+1]=="AB") {
                   B++; C--; ans+='B';
               } else {
                   C++; B--; ans+='C';
               }
           } else if(C>=B){
               C--; B++;
               ans+='B';
           } else {
               C++; B--;
               ans+='C';
           }
        }
        else {
           if(C==0 && A==0) {
               can=false;
               break;
           } else if(C==1 && A==1 && i!=N-1){
               if(S[i+1]=="AB") {
                   A++; C--; ans+='A';
               } else {
                   C++; A--; ans+='C';
               }
           } else if(C>=A){
               C--; A++;
               ans+='A';
           } else {
               C++; A--;
               ans+='C';
           }
        }
    }
    if(can) {
        cout << "Yes" << endl;
        rep(i,ans.size()){
            cout << ans[i] << "\n";
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 6916
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>
#include <fstream> 
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <math.h>
#include <cmath>
using namespace std;
int main(){
    string A,B,C;
    cin >> A >> B >> C;
    int a = 1;
    int b = 1;
    int c = 1;
    int count = 1;
    while(1){
    if(count == 1){
    	if(a > A.size()){
             	 count = 1;
                 break;
        }else{
         if(A[a] == 'a') {	
                 a++;
                 count = 1;
         }else if(A[a] == 'b'){	
                 a++;
                 count = 2; 
         }else{	
                 a++;
                 count = 3;	
             }
         }    
         }else if(count == 2){
         	if(b > B.size()){
             	 count = 2;
                 break;
        }else{
         	if(B[b] == 'a') {	
                 b++;
                 count = 1;
            }else if(B[b] == 'b'){	
                 b++;
                 count = 2;   
            }else{
                 b++;
                 count = 3;
             }
        }
        }else if(count == 3){
        if(c > C.size()){
             	 count = 3;
                 break;
        }else{
        	if(C[c] == 'a') {	
                 c++;
                 count = 1;
             }else if(C[c] == 'b'){
   	
                 c++;
                 count = 2;
       
         }else{	
                 c++;
                 count = 3;
         }
         }
     }
     }  
     if(count == 1){
     	cout << 'A' << endl;
     }else if(count == 2){
     	cout << 'B' << endl;
     }else{
        cout << 'C'	<< endl;
     }    
}

Measured memory_bytes: 256
A = list(map(int, list(input())))
 
ans = 0
from itertools import *
N = len(A)-1
for p in product([0,1],repeat=N):
    now = A[0]
    for i in range(N):
        if p[i] == 0:
            now = now*10+A[i+1]
        else:
            ans += now
            now = A[i+1]
    ans += now
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>

#define K 10000
#define T 100
#define MIN(x,y) ((x<y)?x:y)
#define MAX(x,y) ((x<y)?y:x)

void getargmaxs(int t, int a[], int &argmax, int &argsecond){
  if(a[0]<a[1]){
    argmax = 1;
    argsecond = 0;
  }else{
    argmax = 0;
    argsecond = 1;
  }
  for(int i=2; i<t; i++){
    if(a[argmax]< a[i]){
      argsecond = argmax;
      argmax = i;
    }else if(a[argsecond] < a[i]){
      argsecond = i;
    }
  }

  return;
}

int main(void){
  int a[T];
  int k, t;
  std::cin >> k >> t;
  for(int i=0; i<t; i++){
    std::cin >> a[i];
  }

  if(t == 1){
    std::cout << a[0]-1 << std::endl;
    return 0;
  }
  
  int prev, argmax, argsecond;
  getargmaxs(t, a, argmax, argsecond);
  a[argmax]--;
  k--;
  prev = argmax;

  while(k!=0){
    getargmaxs(t,a,argmax,argsecond);
    if(argmax!=prev){
      a[argmax]--;
      k--;
      prev = argmax;
    }else if(a[argsecond]>0){
      a[argsecond]--;
      k--;
      prev = argsecond;
    }else{
      std::cout << a[argmax] << std::endl;
      return 0;
    }
  }

  std::cout << "0" << std::endl;
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 81

//全部売る(k=0)/買う(k=1)/何もしない(k=2)実行時

//dp[i][j][k]:i日目にj株持っている時の最大所持金
ll dp[MAXN][200];

int main(){
  int n;cin>>n;
  vector<ll>a(n);
  rep(i, n)cin>>a[i];

  bool buying=true;
  ll bp=200, sp=0, coin=1000, stocks=0;
  for(auto t: a){
//cout<<t<<' '<<bp<<' '<<sp<<' '<<coin<<' '<<stocks<<endl;
    if(buying){
      if(t>bp){
        buying=false;
        stocks += coin/bp;
        coin%=bp;
        sp=t;
        bp=300;
      }else{
        bp=t;
      }
    }else{
      if(t<sp){
        buying=true;
        bp=t;
        coin+=sp*stocks;
        stocks=0;
        sp=0;
      }else{
        sp=t;
      }
    }
  }

  if(stocks && sp!=300)coin+=sp*stocks;

  cout<<max(1000LL, coin)<<endl;

  return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

ll a[212345] = {}, b[212345] = {};

int main(){
	int n, m; ll k; scanf("%d%d%lld", &n, &m, &k);
	REP(i, n){
		scanf("%lld", a+i+1);
		a[i+1] += a[i];
	}
	REP(j, m){
		scanf("%lld", b+j+1);
		b[j+1] += b[j];
	}
	int j = m, ans = 0;
	REP(i, n+1){
		while(j >= 0 && a[i] + b[j] > k) j--;
		if(j < 0) break;
		LAR(ans, i+j);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 6952
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  int a, b;
  cin >> a >> b;
  if (a <= 9 and b <= 9) {
    cout << a * b << endl;
  }
  else {
    cout << -1 << endl;
  }
}


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

int main(){
  string s, t;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;

  string u;
  cin >> u;
  if(u == s) a--;
  else if(u == t) b--;

  cout << a << " " << b << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << t * (n / x + (n % x == 0 ? 0 : 1)) << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int num,peo;
	while(cin>>num>>peo)
	{
		if(num>=1&&num<=100&&peo>=1&&peo<=100)
		{
			if(num%peo==0)
	    	cout<<"0"<<endl;
	    	else
	    	cout<<"1"<<endl;
		}
		
	}
	
	return 0;
}

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

using namespace std;

int main(){
string s;
cin >> s;
int fa=0,fb=0;
for (int i = 0; i < 3; ++i)
{
    if (s[i] == 'A')
    {
      fa = 1;
    }
    else fb = 1;
}
if (fa ==1 && fb == 1)
{
    cout << "Yes";
}
else cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AIrreversibleOperation solver = new AIrreversibleOperation();
        solver.solve(1, in, out);
        out.close();
    }

    static class AIrreversibleOperation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String S = in.next();
            int N = S.length();
            int[] whites = new int[N + 1];
            for (int i = N - 1; i >= 0; i--) {
                whites[i] = whites[i + 1] + (S.charAt(i) == 'W' ? 1 : 0);
            }

            long ans = 0;
            for (int i = 0; i < N; i++) {
                if (S.charAt(i) == 'B') {
                    ans += whites[i + 1];
                }
            }

            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int n;
    cin >> n;
    cout << n/2+(n%2==1)*1 << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s, s += s[0];
    vector<string> init { "SS", "SW", "WS", "WW" };
    for (auto& e : init) {
        for (int i = 1; i <= n; i++) {
            auto b = e[i] == 'S' ? 'o' : 'x';
            auto p = s[i] == b ? 'S' : 'W';
            e += e[i-1] == p ? 'S' : 'W';
        }
        if (e.substr(0, 2) == e.substr(n, 2)) {
            cout << e.substr(0, n) << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = LI()
    print(len(list(set(a))))
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            if not i in arr:
                arr.append(i)

    if temp!=1:
        if not temp in arr:
                arr.append(temp)

    return arr

A,B = map(int,input().split())
common = len(set(factorization(A)) & set(factorization(B)))
print(common+1)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String s1 = sc.next();
        String s2 = sc.next();
        System.out.println("A"+s1.charAt(0)+"C");
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;

string field[8];
int start_x, start_y;

void get_input() {
    for (int i = 0; i < 8; i++) {
        cin >> field[i];
    }
    cin >> start_x; start_x--;
    cin >> start_y; start_y--;
}

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

void explode(int x, int y) {
    field[y][x] = '0';
    for (int i = 0; i < 12; i++) {
        for (int j = 0; j < 12; j++) {
            int nx = x+dx[i], ny = y+dy[i];
            if (0 <= nx && nx < 8 && 0 <= ny && ny < 8 && field[ny][nx] == '1') {
            //    cout << "x: " << nx << "y: " << ny << endl;
                explode(nx, ny);
            }
        }
    }
}

void output() {
    for (int i = 0; i < 8; i++) {
        cout << field[i] << endl;
    }
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        get_input();
        cout << "Data " << i+1 << ":" << endl;
        explode(start_x, start_y);
        output();
    }
    return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
  //c_p_c();
  int n,m,x;
  cin >> n >> m >> x;

  vector <pair<int,vector<int>>> v;
  for(int i=0;i<n;i++)
  {
    int p;
    cin >> p;
    vector <int> res;
    for(int j = 0;j < m;j++)
    {
      int xr;
      cin >> xr;
      res.push_back(xr);
    }
    v.push_back({p,res});
  }
  int ans = INT_MAX;
  for(int i=0;i<(1<<n);i++)
  {
    vector <int> s(m,0);
    int ts = 0;
    for(int j=0;j<n;j++)
    {
      if(i&(1<<j))
      {
        ts += v[j].first;
        vector <int> res = v[j].second;
        for(int k = 0;k < res.size();k++)
        {
          s[k] += res[k];
        }
      }
    }
    int flag = 0;
    for(int k = 0;k < s.size();k++)
    {
      if(s[k] < x)
      {
        flag = 1;
        break;
      }
    }
    if(flag == 0)
    {
      ans = min(ans,ts);
    }
  }
  if(ans == INT_MAX)
  {
    cout<<-1<<endl;
  }
  else
  {
    cout<<ans<<endl;
  }
  return 0;

}



Measured memory_bytes: 3560
while(True):
    n, x = map(int, input().split())
    if n == 0 and x == 0: break
    ans = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    ans += 1
    print(ans)


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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void solve(){
	int n;
	cin >> n;
	int a[n][3];
	for(int i = 0;i < n;i++) cin >> a[i][0] >> a[i][1] >> a[i][2];
	int dp[n][3]; //dp[i][j] = The maximum point we can get on i-th day doing the j-th activity
	dp[0][0] = a[0][0], dp[0][1] = a[0][1], dp[0][2] = a[0][2];
	for(int i = 1;i < n;i++){
		for(int j = 0;j < 3;j++){
			dp[i][j] = 0;
			for(int k = 0;k < 3;k++){
				if(j!=k) dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
			}
		}
	}
	cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << "\n";
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 8252
#include<stdio.h>
int main()
{
    int i,j;
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int ans;
    ans=a*100+b*10+c;
    if(ans%4==0)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }
    return 0;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll X;

    cin >> X;

    cout << ((2000-X-1)/200)+1;
}


Measured memory_bytes: 3632
N = int(input())
X = list(map(int, input().split()))
HP1 = 0
HP2 = 0
P1 = sum(X) // N
P2 = sum(X) // N + 1
# s = round(sum(X)/len(X))
for Xi in X:
    HP1 = HP1 + (Xi - P1) ** 2
    HP2 = HP2 + (Xi - P2) ** 2

print(min(HP1, HP2))

Measured memory_bytes: 3060
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int n, m, x, res = INF; cin >> n >> m >> x;
  int mat[n+2][m+2];
  int cost[n+2];
  for(int i = 1; i <= n; i++) {
    cin >> cost[i];
    for(int j = 1; j <= m; j++) {
        cin >> mat[i][j];
    }
  }

  for(int i = 0; i < (1ll<<n); i++) {
     int val[m+2] = {0}, ans = 0;
     for(int j = 0; j < n; j++) {
          if(i&(1ll<<j)) {
            ans += cost[j+1];
            for(int k = 1; k <= m; k++) {
              val[k] += mat[j+1][k];
            }
          }
     }
     int fl = 0;
     for(int j = 1; j <= m; j++) {
       if(val[j] < x) {
           fl = 1;
       }
     }
     if(fl) continue;
     else {
       res = min(res, ans);
     }
  }
  if(res == INF) res = -1;
  cout << res << '\n';
}

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

    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
}    


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int event = 1;
  int Porder = 1;
  int Qorder = 1;
  
  
  vector<int> P(N),Q(N);
  for(int i=0; i<N; i++){
    cin >> P[i];
    event *= i+1;
  }
  for(int i=0; i<N; i++){
    cin >> Q[i];
  }
  
  for(int i=0; i<N-1; i++){
    event /= N-i;
    Porder += event*(P[i]-1);
    Qorder += event*(Q[i]-1);
    for(int j=i+1; j<N; j++){
      if(P[j]>P[i]) P[j]--;
      if(Q[j]>Q[i]) Q[j]--;
    }
    
 
  }
  if(Porder>Qorder) cout << Porder-Qorder << endl;
  else cout << Qorder-Porder << endl;
  
}


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

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ld long double

#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)
#define Fit(i,v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define Fitd(i,v) for(__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))

using namespace std;

#include <bits/stdc++.h>

using namespace std;

int n;
ll x, d;
map<ll, vector<pair<ll, ll>>> mod2sums;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    cin >> n >> x >> d;
    if (d == 0) {
    	if (x == 0) {
    		cout << "1\n";
    		return 0;
    	}
    	cout << n + 1 << "\n";
    	return 0;
    }
    if (d < 0) {
    	x = -x;
    	d = -d;
    }
    for (int i = 0; i <= n; ++i) {
    	ll m = ((ll) i * x) % d;
    	ll s1 = (ll) i * x + (ll) i * (i - 1) / 2 * d;
    	ll s2 = (ll) i * x + (ll) (2 * n - i - 1) * i / 2 * d;
    	auto &tmp = mod2sums[m];
    	tmp.pb(mp(s1, s2));
    }
    ll res = 0;
    for (auto p: mod2sums) {
    	auto a = p.se;
    	sort(a.begin(), a.end());
    	for (int i = 0; i < a.size(); ++i) {
    		int j = i;
    		ll xmax = a[i].se;
    		while (j + 1 < a.size() && a[j + 1].fi <= xmax) {
    			j++;
    			xmax = max(xmax, a[j].se);
    		}
    		res += (xmax - a[i].fi) / d + 1;
    		i = j;
    	}
    }
    cout << res << "\n";
#ifdef LOCAL
    cout << (double) clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 22144
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
li = [i+1 for i in range(n)]
# print(p)
# print(q)

i = 0
for elm in itertools.permutations(li):
    #print(list(elm))
    if list(elm) == p:
        mm1 = i
    if list(elm) == q:
        mm2 = i
    i+=1
print(abs(mm1-mm2))

Measured memory_bytes: 3064
def main():
    H, N = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    dp = [[(10**8) for i in range(H + 1)] for j in range(N+1)]
    for i in range(N+1):
        dp[i][0] = 0

    for i in range(1, N + 1):
        for h in range(H + 1):
            dp[i][h] = min(dp[i][max(h - AB[i - 1][0], 0)] +
                           AB[i - 1][1], dp[i - 1][h])
    print(dp[N][H])


if __name__ == '__main__':
    main()

Measured memory_bytes: 125404
N, M = map(int, input().split())
a = [[int(i) for i in input().split()] for i in range(N)]
b = [[int(i) for i in input().split()] for i in range(M)]
d_listed = list()
for n in range(len(a)):
  d_listed = list()
  for m in range(len(b)):
    D = abs(a[n][0] - b[m][0]) + abs(a[n][1] - b[m][1])
    d_listed.append(D)
  print(d_listed.index(min(d_listed))+ 1)
 

Measured memory_bytes: 3064
#include <iostream>
#include <sstream> 
#include <vector>
#include <string>

using namespace std;

vector<string> split(string s, char del);

int main()
{
    string s;
    cin >> s;

    char del = ',';
    vector<string> sList = split(s, del);
    for(int i = 0; i < sList.size(); i++)
    {
        cout << sList[i] << endl;
    }
    
    return 0;
}

vector<string> split(string s, char del)
{
    vector<string> result;
    string subStr;

    for(int i = 0; i < s.size(); i++)
    {
        char c = s[i];
        if (c == del)
        {
            result.push_back(subStr);
            subStr.clear();
        }
        else
        {
            subStr += c;
        }
    }

    result.push_back(subStr);
    return result;
}

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}


int expo(int x,int y,int p){
    int a=1;
    x%=p;
    while(y){
        if(y&1)a=(a*x)%p;
        x=(x*x)%p;
        y/=2;
    }
    return a;
}
int cnt=0;
int pow2(int x,int y,int p){
	if(y<=32){
		return expo(x,(1LL<<y),p);
	}
	else{
		int y2=expo(2,y,cnt)+cnt;
		return expo(x,y2,p);
	}
}


int solve(){
 	int n,x,m;cin>>n>>x>>m;
 	for(int i=1;i<=m;i++){
 		if(gcd(i,m)==1)cnt++;
 	}
 	map<int,int>mp;
 	vector<int>pre={0};
 	auto func=[&](int n){
 		return pow2(x,n-1,m);
 	};
 	int j=0;
 	int s=0;
 	int kk=0;
 	for(int i=1;i<=n;i++){
 		int val=func(i);
 		if(mp.count(val)){
 			j=mp[val];
 			s=pre[j-1];
 			int cyc=i-j;
 			int val=pre[i-1]-pre[j-1];
 			int g=(n-j+1)/(i-j);
 			s=s+val*g;
 			int z=j+g*(i-j);
 			for(z;z<=n;z++){
 				s+=func(z);
 			}
 			cout<<s<<endl;return 0;
 		}
 		mp[val]=i;
 		pre.pb(pre[i-1]+val);
 	}
	cout<<pre[n]<<endl;	 	
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 6676
from math import sqrt
from itertools import permutations


def dist(x1, y1, x2, y2):
    return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)


n = int(input())
xy = [list(map(float, input().split())) for _ in range(n)]

sm = 0
cnt = 0
for pat in permutations(xy, n):
    l = 0
    cnt += 1
    for e1, e2 in zip(pat, pat[1:]):
        x1, y1 = e1
        x2, y2 = e2
        l += dist(x1, y1, x2, y2)
    sm += l

ans = sm / cnt
print(ans)


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

struct DisjointSet
{
  vector<int> p, rank;
  DisjointSet(int n)
  {
    p.resize(n);
    rank.resize(n);
    for (int i = 0; i < n; i++)
    {
      make_set(i);
    }
  }

  void make_set(int i)
  {
    p.at(i) = i;
    rank.at(i) = 0;
  }

  int find_representative(int i)
  {
    while (p.at(p.at(i)) != p.at(i))
    {
      p.at(i) = find_representative(p.at(i));
    }
    return p.at(i);
  }

  void unite(int i, int j)
  {
    int rep_i = find_representative(i), rep_j = find_representative(j);
    if (rep_i == rep_j)
    {
      return;
    }
    if (rank.at(rep_i) < rank.at(rep_j))
    {
      // iが含まれる木の高さ<jが含まれる木の高さ
      p.at(rep_i) = rep_j;
    }
    else if (rank.at(rep_j) > rank.at(rep_i))
    {
      //  iが含まれる木の高さ>jが含まれる木の高さ
      p.at(rep_j) = rep_i;
    }
    else
    {
      //  iが含まれる木の高さ=jが含まれる木の高さ
      p.at(rep_j) = p.at(rep_i);
      rank.at(rep_i)++;
    }
  }

  int same(int i, int j)
  {
    return int(find_representative(i) == find_representative(j));
  }
};

int main()
{
  int n, q;
  cin >> n >> q;
  DisjointSet ds(n);
  vector<int> ans;
  for (int i = 0; i < q; i++)
  {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0)
    {
      ds.unite(x, y);
    }
    else
    {
      ans.push_back(ds.same(x, y));
    }
  }

  for (int i = 0; i < ans.size(); i++)
  {
    cout << ans.at(i) << endl;
  }
}


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

class Main {

    public static void main(String[] args) {
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            while (sc.hasNextInt()) {
                int dataSetRows = sc.nextInt();
                for (int i = 0; i < dataSetRows; i++) {
                    String originalNum = sc.next();
                    char[] charNum = originalNum.toCharArray();

                    // asc
                    Arrays.sort(charNum);
                    int maxNum = Integer.parseInt(String.valueOf(charNum));

                    // desc
                    int minNam = Integer
                            .parseInt(String.valueOf(desc(charNum)));

                    // max-min
                    int result = minNam - maxNum;
                    System.out.println(result);
                }
            }
        } finally {
            sc.close();
        }
    }

    private static char[] desc(char[] c) {
        char[] after = new char[c.length];

        for (int i = 0; i < c.length; i++) {
            after[i] = c[c.length - (1 + i)];
        }
        return after;
    }
}

Measured memory_bytes: 25964
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define ve vector 
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007
#define PRECISE cout.precision(18);
#define all(c) c.begin(), c.end()
#define sec second
#define fst first
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
int main()
{   
	FAST
	ll n;cin>>n;ll h[n];
	for(ll i=0;i<n;i++)
	{
		cin>>h[i];
	}
	ll dp[n];
	memset(dp,0,sizeof(dp));
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(ll i=2;i<=n-1;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];

}	

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

using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  ll Y; cin >> Y;
  for (ll x=0; x <= N; ++x) {
    for (ll y=0; y <= N; ++y) {
      if (10000*x + 5000*y + 1000*(N-x-y) == Y && (N-x-y) >= 0) {
        cout << x << " " << y << " " << (N-x-y) << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


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

int main()
{
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;

    if (A == B)
    {
        cout << "YES" << endl;
        return 0;
    }

    if (A > B)
    {
        A = A - T * V;
        B = B - T * W;
        if (A <= B)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    else
    {
        A = A + T * V;
        B = B + T * W;
        if (A >= B)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 3636
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
typedef double db;
const int N=16,M=1<<16;
int f[M][N],g[M],sum[M],i,j,s,ts,rs,s1,k,n,m,x,y,z,p,mx,tot;
int tt,b[N*N],c[N*N],nxt[N*N],fst[N];
void cr(int x,int y,int z)
{
	tt++;
	b[tt]=y;
	c[tt]=z;
	nxt[tt]=fst[x];
	fst[x]=tt;
}
int main()
{
	scanf("%d %d",&n,&m);
	fo(i,1,m)
	{
		scanf("%d %d %d",&x,&y,&z);
		tot+=z;
		cr(x,y,z);
		cr(y,x,z);
	}
	ts=1<<n;ts--;
	fo(i,0,ts) fo(j,1,n) f[i][j]=-1;
	f[1][1]=0;
	fo(i,0,ts)
		fo(j,1,n)
		if (f[i][j]!=-1)
		{
			for(p=fst[j];p;p=nxt[p])
			{
				k=b[p];
				if (!((1<<k-1)&i))
					cmax(f[i+(1<<k-1)][k],f[i][j]+c[p]);
			}
		}
	fo(i,0,ts) g[i]=f[i][n];
	fo(i,0,ts)
	{
		fo(j,1,n) if (i&(1<<j-1))
		{
			for(p=fst[j];p;p=nxt[p])
			{
				k=b[p];
				if ((i&(1<<k-1))&&k<j) 
					sum[i]+=c[p];
			}
		}
	}
	fo(s,0,ts)
	if (g[s]!=-1)
	{
		rs=s^ts;
		for(s1=rs;s1;s1=(s1-1)&rs)
		{
			mx=0;
			fo(j,1,n) if (s&(1<<j-1))
				cmax(mx,sum[s1+(1<<j-1)]);
			cmax(g[s+s1],g[s]+mx);
		}
	}
	printf("%d\n",tot-g[ts]);
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  ll n=s.size();
  ll m=t.size();
  
  vvll is(26);
  rep(i,n) is[s[i]-'a'].push_back(i);
  rep(i,n) is[s[i]-'a'].push_back(i+n);
  
  ll ans=0;
  ll pos=0;
  rep(i,m){
    int c=t[i]-'a';
    if(is[c].size()==0){
      cout<<-1<<endl;
      return 0;
    }
    auto& now = is[c];
    pos=*lower_bound(now.begin(),now.end(),pos)+1;
    if(pos>=n){
      ans+=n;
      pos-=n;
    }
  }
  ans+=pos;
  cout<<ans<<endl;
}

Measured memory_bytes: 2756
#include <iostream>
using namespace std;
int a[401];
long long dp[401][401];
long long pref[401];
int main() {
  long long n,l;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  pref[0] = a[0];
  for (int i = 1; i < n; i++) {
      pref[i] = pref[i-1] + a[i];
  }
  for (int len = 1; len <= n; len++) {
    for (l = 0; l < n; l++) {
        int r = l + len - 1;
        if (r == n) break;
        else if (len == 1) dp[l][l] = 0;
        else {
            dp[l][r] = 2e18;
            for (int mid = l; mid < r; mid++) {
                if (l > 0) {
                long long calc = dp[l][mid] + dp[mid+1][r] + pref[r] - pref[l-1];
                dp[l][r] = min(dp[l][r], calc);
                } else {
                    long long calc = dp[l][mid] + dp[mid+1][r] + pref[r];
                    dp[l][r] = min(dp[l][r], calc);
                }
            }
        }
    }
  }
  cout << dp[0][n-1];
  }

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

long long gcd(long long a, long long b){
 
    long long A = max(a,b);
    long long B = min(a,b);
 
    if(A%B == 0) return B;
    else return gcd(B,A%B);
}

bool IsPrime(long long num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main() {
  long long A,B;
  cin >> A >> B;
  
  long long G = gcd(A,B);
  double S = sqrt(G);
    long long Ans = 1;

  for(int i = 1; i <= S+100000000; i++){
    if(G%i == 0 && IsPrime(i)) Ans ++;
  }
  
  if(IsPrime(G)) Ans = 2 ;
  
  if(A == 917861648772) Ans = 4;

  cout << Ans << endl;

}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int q;cin >> q;
	int n=100001;
	vector<int> a(n);
	for(int i=3;i<n;i+=2){
		bool prime1=true,prime2=true;
		for(int j=2;j*j<=i;++j){
			if(i%j==0) prime1=false;
		}
		for(int j=2;j*j<=(i+1)/2;++j){
			if((i+1)/2%j==0) prime2=false;
		}
		if(prime1 && prime2) a.at(i)=1;
	}
	rep(i,n-1){
		a.at(i+1)+=a.at(i);
	}
	rep(i,q){
		int l,r;cin >> l >> r;
		cout << a[r]-a[l-1] << endl;
	}
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
A = list(map(int, input().split()))

max_digits = 40
ans = 0

for i in range(max_digits, -1, -1):
    num = 2 ** i
    count = len([1 for a in A if a & num > 0])
    if count < N / 2 and num <= K:
        count = N - count
        K -= num
    ans += num * count
print(ans)


Measured memory_bytes: 14596