akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include<iomanip>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  string A, B, C;
  cin >> A >> B >> C;
  
  int turn = 0;
  while (1) {
    if (turn == 0) {
      if (A.size() == 0) {
        cout << "A" << endl;
        break;
      }
      if (A[0] == 'b') {
        turn = 1;
      } else if (A[0] == 'c') {
        turn = 2;
      }
      A.erase(0, 1);
    } else if (turn == 1) {
      if (B.size() == 0) {
        cout << "B" << endl;
        break;
      }
      if (B[0] == 'a') {
        turn = 0;
      } else if (B[0] == 'c') {
        turn = 2;
      }
      B.erase(0, 1);
    } else {
      if (C.size() == 0) {
        cout << "C" << endl;
        break;
      }
      if (C[0] == 'a') {
        turn = 0;
      } else if (C[0] == 'b') {
        turn = 1;
      }
      C.erase(0, 1);
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int,int> P;
 
int main(){
    int n;     
    while(cin >> n,n){
        vector<P> v;
        int t,b;
        for(int i = 0 ; i < n ; i++){
            cin >> t >> b;
            v.push_back(P(b,t));
        }
        sort(v.begin(),v.end());
         
        bool flg = false;
        int sum = 0;
        for(int i = 0 ; i < n ; i++){
            sum += v[i].second;
            if(sum > v[i].first){
                flg = true;
                break;
            }
        }
        if(flg) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3044
// Author: Shusuke Ueda
// AtCoder Beginner Contest 115 - Problem D

#include <iostream>
#include <vector>
using lint = int_fast64_t;

int main() {
    int n;
    lint x;
    std::cin >> n >> x;
    x--;

    std::vector<lint> patty(n + 1), length(n + 1);
    patty[0] = 1;
    length[0] = 1;
    for (int i = 1; i <= n; i++) {
        patty[i] = patty[i - 1] * 2 + 1;
        length[i] = length[i - 1] * 2 + 3;
    }

    lint ans = 0;
    auto count = [&](auto count_, int lev, lint pos) -> void {
        if (pos == 0) {
            if (lev == 0) {
                ans++;
            }
            return;
        } else if (pos < length[lev] / 2) {
            count_(count_, lev - 1, pos - 1);
        } else if (pos == length[lev] / 2) {
            ans += patty[lev - 1] + 1;
            return;
        } else if (pos < length[lev] - 1) {
            ans += patty[lev - 1] + 1;
            count_(count_, lev - 1, pos - length[lev] / 2 - 1);
        } else {
            ans += patty[lev];
            return;
        }
    };
    count(count, n, x);

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int h,w;
    cin>>h>>w;
    int a[h][w];
    rep(i,h)rep(j,w)cin>>a[i][j];
    vector<pair<pint,pint>>ans;
    rep(i,h-1)rep(j,w){
        if(a[i][j]%2){
            ans.push_back({{i+1,j+1},{i+2,j+1}});
            ++a[i+1][j];
        }
    }
    rep(j,w-1)if(a[h-1][j]%2){
        ans.push_back({{h,j+1},{h,j+2}});
        ++a[h-1][j+1];
    }
    cout<<ans.size()<<endl;
    for(auto e:ans){
        cout<<e.first.first<<" "<<e.first.second<<" "<<e.second.first<<" "<<e.second.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int a, b,c,tem;
    cin >> a >> b >> c;
    if (a > b) {
        tem = a;
        a = b;
        b = tem;
    }
    if (b > c) {
        tem = b;
        b = c;
        c = tem;
    }
    if (a > b) {
        tem = a;
        a = b;
        b = tem;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
    
}


Measured memory_bytes: 3152
<?php 
  	fscanf(STDIN,"%s",$s);
	$l_li = explode(" ",trim(fgets(STDIN)));
	sort($l_li);
	$c = 0;
	for($i=0;$i<count($l_li);$i++){
      for($j=$i+1;$j<count($l_li);$j++){
        for($k=$j+1;$k<count($l_li);$k++){
          if($l_li[$i]!=$l_li[$j] && 
             $l_li[$i]!=$l_li[$k] &&
             $l_li[$j]!=$l_li[$k]){
            if($l_li[$i]+$l_li[$j]>$l_li[$k]){
              $c++;
            }
          }
        }
      }
    }
	

	echo $c;

Measured memory_bytes: 16240
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

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

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }
ll power(ll n , ll k) { if(k == 0) return 1 ; if(k&1) return n*sqr(power(n,k/2)) ; else return sqr(power(n,k/2)); }

const   int  N   =   2e6+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

ll a[100];

int main() {//ikarus_101

    ll n,m,i,j,k,x;

    cin>>n;
    rep1(i,n) cin>>a[i];

    ll tot = 1000;
    for(i=1;i<n;i++)
    {
        if(a[i] < a[i+1])
        {
            j=i+1;
            for(;j<n;j++)
            {
                if(a[j] > a[j+1])
                {
                    break;
                }
            }

            tot += (tot/a[i]) * (a[j]-a[i]);
            i=j;

        }
    }

    cout << tot << endl;





    return 0;
}


Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] ws = ReadIntArray();

	int total = ws.Sum();
	int ans = total;
	int diff = total;

	for (int i = 0; i < n; i++)
	{
	    diff -= ws[i] * 2;
	    ans = Math.Min(ans, Math.Abs(diff));
	}

	WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int H,W;
  cin >> H >> W;
  vector<vector<ll> >C(10, vector<ll>(10));
  for(int i=0; i < 10; i++){
    for(int j=0; j < 10; j++){
      cin >> C[i][j];
    }
  }
  vector<ll>A(10);
  for(int i=0; i < H; i++){
    for(int j=0; j < W; j++){
      ll a;
      cin >> a;
      if(a != -1)
        A[a]++;
    }
  }

  //const ll inf = 10000000000;
  //vector<vector<ll> >D(10, vector<ll>(10, inf));
  for(int k=0; k < 10; k++){
    for(int i=0; i < 10; i++){
      for(int j=0; j < 10; j++){
	C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      }
    }
  }
  ll ans = 0;
  for(int i=0; i < 10; i++)
    ans += A[i] * C[i][1];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//Input some commands (insertion or print)
//Output the in- & pre-order traversal
//Note that the input value must be distinct
#include <iostream>
using namespace std;

const int ArSize = 35;
const int MAX = 500000;

struct Node
{
	int key;
	Node * pa;
	Node * left, *right;
};

char ins[ArSize];
Node * rec_tree[MAX];
int cnt = 0;

Node * root = nullptr;

void insert(Node *);
void print();
void in_print(Node *);
void pre_print(Node *);

int main()
{
	ios::sync_with_stdio(false);

	int m;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> ins;
		if (ins[0] == 'i')
		{
			int v;
			cin >> v;

			//The following step mustn't use a list initializer directly
			//to build a LOCAL Node and pass it to insert().
			//Otherwise problems will occur when the execution
			//leaves this block and the LOCAL Node gets freed.
			Node * self = new Node({v, nullptr, nullptr, nullptr});

			rec_tree[cnt++] = self;
			insert(self);
		}
		else
		{
			print();
		}
	}

	for (int i = 0; i < cnt; i++)
		delete rec_tree[i];

	return 0;
}

void insert(Node * self)
{
// 	Node * self = new Node;
// 	self->key = v;
// 	self->pa = self->left = self->right = nullptr;

	Node * pa_can = nullptr;
	Node * self_can = root;

	while (self_can != nullptr)
	{
		pa_can = self_can;
		if (self->key < pa_can->key)
			self_can = pa_can->left;
		else
			self_can = pa_can->right;
	}

	self->pa = pa_can;
	if (self->pa == nullptr)
		root = self;
	else if (self->key < self->pa->key)
		self->pa->left = self;
	else
		self->pa->right = self;
	return;
}

void print()
{
	in_print(root);
	cout << endl;
	pre_print(root);
	cout << endl;
}

void in_print(Node * cur)
{
	if (cur == nullptr)
		return;

	in_print(cur->left);
	cout << " " << cur->key;
	in_print(cur->right);
	return;
}

void pre_print(Node * cur)
{
	if (cur == nullptr)
		return;

	cout << " " << cur->key;
	pre_print(cur->left);
	pre_print(cur->right);
	return;
}

Measured memory_bytes: 30348
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;
int par[100005], ran[100005];
struct edge {
	int u, v, cost;
};

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
};

void init(int n) {
	FOR(i, n) {
		par[i] = i;
		ran[i] = 0;
	}
}

int find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (ran[x] < ran[y]) par[x] = y;
	else {
		par[y] = x;
		if (ran[x] == ran[y]) ran[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	
	cin >> n;
	vector<pair<int, int> > px(n), py(n);
	FOR(i, n) {
		int x, y;
		cin >> x >> y;
		px[i] = make_pair(x, i);
		py[i] = make_pair(y, i);
	}
	
	sort(px.begin(), px.end());
	sort(py.begin(), py.end());

	vector<edge> es;
	FOR(i, n-1) {
		es.push_back((edge){px[i].second, px[i+1].second, px[i+1].first - px[i].first});
		es.push_back((edge){py[i].second, py[i+1].second, py[i+1].first - py[i].first});
	}

	sort(es.begin(), es.end(), comp);

	init(n);
	int ans = 0;
	FOR(i, es.size()) {
		edge e = es[i];
		if (!same(e.u, e.v)) {
			unite(e.u, e.v);
			ans += e.cost;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6516
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N, M;
    cin >> N >> M;
    vint A(M);
    vint Num(10);
    Num[1] = 2; Num[2] = 5; Num[3] = 5; Num[4] = 4; Num[5] = 5; Num[6] = 6; Num[7] = 3; Num[8] = 7; Num[9] = 6;
    rep(i, M) cin >> A[i];
    v2int dp(M + 1, vint(N + 1, -1));
    dp[0][0] = 0;
    sort(A.begin(), A.end(), greater<int>());
    REP(i, 1, M + 1) {
        REP(j, 0, N + 1) {
            if (j - Num[A[i - 1]] < 0) {
                if (dp[i - 1][j] < 0) continue;
                dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            }
            else {
                if (dp[i][j - Num[A[i - 1]]] < 0 && dp[i - 1][j] < 0) continue;

                dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - Num[A[i - 1]]] + 1));
            }
        }
    }
   
    auto maxDig = dp[M][N];
    string ans = "";
    int n = N;
    rep(i, maxDig) {
        
        for (auto& a : A) {
            if (n - Num[a] < 0) continue;
            if (i < maxDig - 1) {
                if (dp[M][n] == dp[M][n - Num[a]] + 1) {
                    ans += to_string(a);
                    n -= Num[a];
                    break;
                }
            }
            else {
                if (n - Num[a] == 0 && dp[M][n] == dp[M][n - Num[a]] + 1) {
                    ans += to_string(a);
                    n -= Num[a];
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
'''
https://atcoder.jp/contests/abc084/tasks/abc084_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    def primecheck(n):
        p = [True] * (n + 1)
        p[0] = False
        p[1] = False
        for i in range(2, int(n ** 0.5) + 1):
            if p[i]:
                for j in range(i * i, n + 1, i):
                    p[j] = False
        return p
    
    p = primecheck(10**5)
    cnt = 0
    res = [0]*(10**5)
    for i in range(10**5):
        if p[i]==p[(i+1)//2]==1:
            cnt += 1
        res[i] = cnt


    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        print(res[r]-res[l-1])

if __name__ == '__main__':
    main()

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

typedef long long ll;
#define mx 100009
const ll inf = 1e18;
ll dp_array[mx][4];
ll a[mx],b[mx],c[mx],n;
ll dp(ll i,ll object)
{
    if(i>=n) return 0L;
    if(dp_array[i][object]!=-1) return dp_array[i][object];

    ll value,value2;
    if(object==1)
    {
        value = a[i]+dp(i+1,2);
        value2 = a[i]+dp(i+1,3);
    }

    if(object==2)
    {
        value = b[i]+dp(i+1,1);
        value2 = b[i]+dp(i+1,3);
    }

    if(object==3)
    {
        value = c[i]+dp(i+1,2);
        value2 = c[i]+dp(i+1,1);
    }
   // printf("dp_array[%lld][%lld] : %lld\n",i,object,max(value,value2));
    return dp_array[i][object]=(long long ) max(value,value2);
}
int main()
{
    memset(dp_array,-1,sizeof dp_array);
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
        scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
    ll value = dp(0,1);
    ll value2 = dp(0,2);
    ll value3 = dp(0,3);
    ll ans = (long long ) max(value ,value2);
    ans = (long long ) max(ans,value3);
    printf("%lld\n",ans);

    return 0;

}




Measured memory_bytes: 10368
#include <iostream>
using namespace std;
 
int main() {
  int H,A,i,num;
 cin>>H>>A;
 for(i=1;i<=10000;i++){
   H=H-A;
   num=i;
   if (H<=0)
   break;
 }
 cout<<num;
    return 0;
}

Measured memory_bytes: 256
K,N=map(int,input().split())
A=list(map(int,input().split()))
A.append(A[0]+K)
m=0
n=0
for i in range(N):
  if A[i+1]-A[i]>=m:
    m=A[i+1]-A[i]
    n=i+1
if n==N:
  print(A[N-1]-A[0])
else:
  print(K-m)

Measured memory_bytes: 25840
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
P_list = []


for i in range(1, 2 ** 10):
    a = list(bin(i))[2::]
    while len(a) < 10:
        a = ["0"] + a
    P_list.append(a)
finalans = -1000000000000000
for i in P_list:
    ans = 0
    cnt = [0 for i in range(N)]
    for j in range(10):
        if i[j] == "1":
            for k in range(N):
                if F[k][j] == 1:
                    cnt[k] += 1
    for j in range(N):
        ans += P[j][cnt[j]]
    #print(ans)
    finalans = max(finalans, ans)

print(finalans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if (a == 1 && b == 2) cout << 3;
    else if (a == 1 && b == 3) cout << 2;
    else cout << 1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(){

    ll n;
    cin >> n;

    ll nums[n];
    ll sum = 0;

    for (int i = 0; i < n; i++){ 
        cin >> nums[i];
        sum += nums[i];
    }

    // if (n == 2){
    //     cout << nums[0] - nums[1] << endl;
    //     return 0;
    // }

    ll mn = 1e18;
    ll otherSum = 0;

    for (int i = n - 1; i > 0; i--){
        // going to have to do absolute
        
        otherSum += nums[i];
        sum -= nums[i];

        mn = min(mn, abs(sum - otherSum));
        
        // cout << " mn : " << mn << " sum : " << sum << " nums[i] : " << nums[i] << " otherSum : " << otherSum << endl;

    }

    cout << mn << endl;

    return 0; 
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a%b==0) {
		System.out.println(a%b);
	}
		else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 23636
#include <stdio.h>

int main () {
	char arr[4];
	scanf("%s", &arr);
	
	if (arr[0] == '7' || arr[1] == '7' || arr[2] == '7') {
		printf("Yes");
	}
	else {
		printf("No");
	}
	
	
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>

int max(int a, int b) {
    if(a>b) return a;
    else return b;
}
int min(int a, int b) {
    if(a<b) return a;
    else return b;
}
int abs(int a, int b) {
    if(a>b) return a-b;
    else return b-a;
}


using namespace std;
int main(int argc, const char * argv[]) {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    int each = A*X + B*Y;
    
    int mix1, mix2;
    
    mix1 = C*min(X,Y)*2 + (X>Y ? A : B)*abs(X,Y);
    mix2 = C*max(X,Y)*2;
    
    cout << min(min(each, mix1), mix2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;


int main(){
    int N, M; cin >> N >> M;
    Graph G(N);
    rep(i,M){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<int> que;
    que.push(0);
    vector<int> dist(N,-1);
    dist[0] = 0;

    while(!que.empty()){
        int v = que.front(); que.pop();
        for (auto nv : G[v]){
            if (dist[nv] == -1){
                dist[nv] = v+1;
                que.push(nv);
            }
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++){
        cout << dist[i] << endl;
    }

}

Measured memory_bytes: 10152
/* 

*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

const int MAXN = 2e3+5;
vector<int> graph[MAXN];
int color[MAXN], par[MAXN];
bool isCycle[MAXN];
int n, x, y, len = 1;

void Backtrack(int start, int finish)
{
    while(start != finish)
    {
        isCycle[start] = true;
        start = par[start];
        ++len;
    }
    isCycle[finish] = true;
}

void DFS(int curr)
{
    color[curr] = 1;
    for(auto& neighbor : graph[curr])
    {
        if(neighbor == par[curr]) continue;
        if(color[neighbor] == 0)
        {
            par[neighbor] = curr;
            DFS(neighbor);
        }
        else if(color[neighbor] == 1)
        {
            Backtrack(curr, neighbor);
        }
        
    }
    color[curr] = 2;
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    cin >> n >> x >> y;
    for(int i = 1; i < n; ++i)
    {
        graph[i].push_back(i+1);
        graph[i+1].push_back(i);
    }
    graph[x].push_back(y);
    graph[y].push_back(x);
    DFS(1);
    vector<ll> ans(n+5);

    for(int i = 1; i <= n; ++i)
    {
        for(int j = i+1; j <= n; ++j)
        {
            // Normal path
            int shortest = (j-i);

            // With cycle
            int temp = abs(x-i) + 1 + abs(y-j);
            shortest = min(shortest, temp);
            ++ans[shortest];
        }
    }
    for(int k = 1; k < n; ++k)
    {
        cout << ans[k] << "\n";
    }
    return 0; 
}


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

char a[100];
int flag;

void shift(){
  int i=0;
  
  while(a[i]!='\0'){
    if(a[i]>='a' && a[i]<='y')
      a[i]++;
    else if(a[i]=='z')
      a[i]='a';
    i++;
  }
}

void match(int x){
  char b1[5];
  char b2[4];
  char m1[2][5]={"that","this"};
  char m2[4]={"the"};
  int i;

  for(i=0;i<4;i++){
    b1[i]=a[x+i];
    if(i!=3)
      b2[i]=a[x+i];
  }
  b1[4]='\0';
  b2[3]='\0';
  if(strcmp(b1,m1[0])==0||
     strcmp(b1,m1[1])==0||
     strcmp(b2,m2)==0)
    flag=0;
}

int main(){
  int i,len;
  
  while(fgets(a,100,stdin)!=NULL){
    flag=1;
    len=strlen(a);
    while(flag){
      shift();
      for(i=0;i<len-4;i++){
	match(i);
	if(!flag)
	  break;
      }
      match(len-4);
    }
    fputs(a,stdout);
  }
  return 0;
}

Measured memory_bytes: 0
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N):
    for j in range(S + 1):
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod
        if j + A[i] <= S:
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])


Measured memory_bytes: 147580
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>
#define MAX_V 100
#define INF LONG_MAX / 4
using namespace std;

typedef struct {
  int to, cost;
} edge;

vector<edge> G[MAX_V];
long long d[MAX_V][MAX_V];

bool find_negative_cycle(int v) {
  for (int i = 0; i < v; i++) {
    if (d[i][i] < 0) return true;
  }
  return false;
}

void warshall_floyd(int v) {
  for (int k = 0; k < v; k++) {
    for (int i = 0; i < v; i++) {
      if (d[i][k] == INF) continue;
      for (int j = 0; j < v; j++) {
	if (d[k][j] == INF) continue;
	d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

void init(int v) {
  for (int i = 0; i < v; i++) {
    for (int j = 0; j < v; j++) {
      if (i == j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }
  
  for (int i = 0; i < v; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      d[i][G[i][j].to] = G[i][j].cost;
    }
  }
}

int main() {
  int v, e;
  cin >> v >> e;
  for (int i = 0; i < e; i++) {
    edge temp;
    int s, t, d;
    cin >> s >> t >> d;
    temp.to = t;
    temp.cost = d;
    G[s].push_back(temp);
  }

  init(v);
  warshall_floyd(v);

  if (find_negative_cycle(v) == true) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  
  for (int i = 0; i < v; i++) {
    for (int j = 0; j < v; j++) {
      if (INF - 20000000 <= d[i][j] && d[i][j] <= INF) {
	cout << "INF";
      } else {
	cout << d[i][j];
      }
      if (j < v - 1) {
	cout << ' ';
      } else {
	cout << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3336
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
typedef unsigned long long ull;
typedef long long ll;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
int n;
pair<int,int>p[N];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        sc("%d%d",&p[i].second,&p[i].first);
    }
    sort(p+1,p+1+n,[](pair<int,int>x,pair<int,int>y){
        if(x.first==y.first)return x.second<y.second;
        return x.first<y.first;
    });
    if(p[1].first<p[1].second)return o("No");
    if(n==1)return o("Yes");
    ll finsh=p[1].second;
    int cnt=1;
    for(int i=2;i<=n;i++){
        if(finsh+p[i].second<=p[i].first){
            finsh+=p[i].second;
            cnt++;
        }
        else break;
    }
    if(cnt^n||finsh>p[n].first)o("No");
    else o("Yes");
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A=in(),B=in(),C=in();

	cout << min(A*B,C) << endl;
	return 0;
}


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

int main() {
    stack<int> S;
    int a, b, x;
    string s;
    
    while(cin>>s) {
        if(s[0]=='+') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        }
        else if(s[0]=='-') {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a-b);
        } else if(s[0]=='*') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        } else {
            S.push(atoi(s.c_str()));
        }
    }
    
    cout << S.top() << endl;
    
    return 0;
}


Measured memory_bytes: 3216
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll a, b, c, d; cin >> a >> b >> c >> d;
  cout << max({a * c, a * d, b * c, b * d}) << '\n';
  return 0;
}


Measured memory_bytes: 3648
#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 ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll n, m, p;
vector<pl> e[2500];
vector<int> re[2500];
ll dist[2500];
ll ok[2500];

void dfs (int v) {
    ok[v] = true;
    rep(i,re[v].size()) {
        if (ok[re[v][i]]) continue;
        dfs(re[v][i]);
    }
}

int main() {
    cin >> n >> m >> p;
    rep(i,n) dist[i] = linf;
    dist[0] = 0;
    rep(i,m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        e[a].push_back(pl(b,c));
        re[b].push_back(a);
    }
    dfs(n-1);
    rep(i,n) {
        rep(j,n) {
            for (pl q : e[j]) {
                if (dist[j] == linf) continue;
                dist[q.first] = min(dist[q.first], dist[j]-q.second+p);
            }
        }
    }
    rep(i,n) {
        for (pl q: e[i]) {
            if (!ok[q.first]) continue;
            if (dist[i] == linf) continue;
            if (dist[q.first] > dist[i] - q.second + p) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << max(0LL, -1*dist[n-1]) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
        
int main(){
    char match; int lose=0;
    while(cin >> match){
        if( match == 'x' ){
            lose++;
        }
    }

    if( lose <= 7 ) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from collections import * #deque, Counter,OrderedDict,defaultdict
#set([]) 
import math
import copy
import itertools
import string
import sys
myread = lambda : map(int,raw_input().split())
def solver():
    H,W = myread()
    for i in xrange(H):
        S = raw_input()
        print S
        print S



if __name__ == "__main__":
    solver()
    


Measured memory_bytes: 3292
s = gets.chomp

s1 = s[0]
s2 = s.slice(2..s.length-2)

if s1 == "A" and s2.length == s2.delete("C").length + 1 and s.length == s.delete("AC").length + 2 and s.delete("AC") == s.delete("AC").downcase then
    puts "AC"
else
    puts "WA"
end


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

int n;
ll a[125252];
bool used[125252];

int main(){
	scanf("%d",&n);
	REP(i,n)scanf("%lld",a+i);
	ll s = 0;
	REP(i,n)s ^= a[i];
	// base
	vl base;
	FORR(b,0,61){
		if(s>>b&1)continue;
		int p = -1;
		REP(i,n){
			if(used[i])continue;
			if(a[i]>>b&1){
				p = i;
				break;
			}
		}
		if(p==-1)continue;
		base.push_back(a[p]);
		used[p] = true;
		ll v = a[p];
		REP(i,n)if(a[i]>>b&1)a[i] ^= v;
	}
	ll y = 0;
	for(ll v : base){
		ll cur = (s^y) + y;
		ll nxt = (s^y^v) + (y^v);
		if(nxt > cur){
			y ^= v;
		}
	}
	printf("%lld\n", (s^y) + y);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		int sl = s.length();
		int tl = t.length();
		boolean b = false;
		if(sl < tl){
			System.out.println("UNRESTORABLE");
		}else if(sl == tl){
			if(contains(s,t,tl)){
				System.out.println(t);
			}else{
				System.out.println("UNRESTORABLE");
			}
		}else{
			String front = s.substring(0, sl-tl);
			String subS = s.substring(sl-tl);
			b= contains(subS, t, tl);
			if(b){
				s = front.replaceAll("\\?", "a") + t;
			}
			for(int i = sl; i >= tl && !b;i--){
				front = s.substring(0, i-tl);
				subS = s.substring(i - tl, i);
				String back = s.substring(i);
				b = contains(subS, t, tl);
				if(b){
					s = front.replaceAll("\\?", "a") + t + back.replaceAll("\\?", "a");
					break;
				}
			}
			if(b){
				System.out.println(s);
			}else{
				System.out.println("UNRESTORABLE");
			}
		}
		sc.close();
	}

	private static boolean contains(String subS, String t, int tl){
		boolean b = true;
		for(int l = 0; l < tl && b; l++){
			b &= subS.charAt(l) =='?' || subS.charAt(l) == t.charAt(l);
		}

		return b;
	}
}

Measured memory_bytes: 21844
//
// Created by kashi on 27-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}

int32_t main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int count=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                    if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]){
                        vector<int>three;
                        three.pb(a[i]);three.pb(a[j]); three.pb(a[k]);
                        sort(three.begin(),three.end());
                        if(three[0]+three[1]>three[2])
                            count++;
                        }
                    }

                }
            }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <ctime>

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define TT int test_cases; cin >> test_cases; while(test_cases--)
#define TT1 int test_cases=1; while(test_cases--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
using namespace std;
typedef long long int ll;

 
int main() {
    
    FAST;
    TT1{
        
        vector<int> x(5);
        int pos=0;
        for(int i=0;i<5;i++)
        {
            cin>>x[i];
            if(x[i]==0) pos=i+1;
        }
        cout<<pos<<"\n";
        
        
    }
}

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

int main () {
	char str[4];
	bool flag = false;
	cin >> str;
	for (int i=0; i<3; i++)
		flag = flag || str[i]=='7';
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int n, int K) {
        const long long MOD = 1000000007;

        vector<int> X;
        for (int i = 1; i * i <= n; ++i) {
            X.push_back(i);
            if (i * i < n) {
                X.push_back(n / i);
            }
        }
        X.push_back(0);
        sort(X.begin(), X.end());
        // X.erase(unique(X.begin(), X.end()), X.end());

        int N = X.size();
        vector<long long> dp(N, 1);
        dp[0] = 0;
        vector<long long> ndp(dp);

        for (int _ = 0; _ < K; ++_) {
            fill(ndp.begin(), ndp.end(), 0);

            for (int i = 1, j = N - 1; i < N; ++i) {
                while (j >= 1 && X[i] * 1LL * X[j] > n) {
                    --j;
                }
                long long cnt = X[i] - X[i - 1];
                ndp[i] = dp[j] * cnt % MOD;
                (ndp[i] += ndp[i - 1]) %= MOD;
            }
            swap(ndp, dp);
        }

        return dp[N - 1];
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;

    Solution sol;
    cout << sol.solve(n, k) << "\n";

    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,n) for(int i = a; i < n; i++)
typedef long long ll;
int n,m,c,s,g;

struct edge{
  int to,c;
  ll d;
};

struct edge2{
  int to;
  ll d;
};

edge makeEdge(int to,int d, int c){
  edge e;
  e.to = to;
  e.d = d;
  e.c = c;
  return e;
}

edge2 makeEdge2(int to,int d){
  edge2 e;
  e.to = to;
  e.d = d;
  return e;
}

typedef pair<ll,ll> PLL;

vector<edge> edges[10010];
vector<vector<PLL>> costList;
ll costList2[21][20001];
const ll INF = 1e15;
typedef PLL State;

void solve(vector<vector<edge2>>& el){

  vector<ll> dist(n,INF);
  dist[s] = 0;
  priority_queue< State, vector<State>, greater<State>> que;
  que.push({0,s});

  while(que.empty() == false){
    State p = que.top(); que.pop();
    ll cdist = p.first ;
    ll current = p.second;
    if(dist[current] < cdist ) continue;
    // cout << el.size() << " " << current << ",";
    // cout << el[current].size() << endl;
    for(edge2 e: el[current]){
      if(dist[e.to] > cdist + e.d){
        dist[e.to] = cdist + e.d;
        que.push({dist[e.to],e.to});
      }
    }
  }
  // rep(i,n){
  //     cout << dist[i] << " ";
  // }
  // cout << endl;
  if(dist[g] == INF) cout << -1 << endl;
  else cout << dist[g] << endl;
}

void wa(int C, vector<vector<edge2>>& el){
  ll d[n][n];
  rep(i,n)rep(j,n) d[i][j] = INF;
  rep(i,n){
    for(edge e : edges[i]){
      if(e.c != C) continue;
      d[i][e.to] = min( e.d , d[i][e.to]);
      d[e.to][i] = min( e.d , d[e.to][i]);
    }
  }

  rep(k,n){
    rep(i,n){
      rep(j,n){
        d[i][j] = min(d[i][j], d[i][k] + d[j][k]);
      }
    }
  }

  rep(i,n){
    rep(j,n){
      if(d[i][j] != INF){
        ll cost = costList2[C][d[i][j]];
        el[i].push_back(makeEdge2(j,cost));
        el[j].push_back(makeEdge2(i,cost));
      }
    }
  }
  return;
}

int main() {
  while(true){
    cin >> n >> m >> c >> s >> g;
    if(n == 0 && m == 0 && c == 0 && s == 0 && g == 0) break;
    g--, s--;
    rep(i,m){
      int x,y,d,cate;
      cin >> x >> y >> d >> cate;
      cate--, x--, y--;
      edges[x].push_back(makeEdge(y,d,cate));
      edges[y].push_back(makeEdge(x,d,cate));
    }
    costList.resize(c);
    int p[c];

    rep(i,c)rep(j,20001) costList2[i][j] = INF;

    rep(i,c) cin >> p[i];
    rep(i,c){
      vector<PLL> pa(p[i]+1,{INF,0});
      pa[0].first = 0;
      FOR(j,1,p[i]) cin >> pa[j].first ;
      rep(j,p[i]) cin >> pa[j].second;
      costList2[i][0] = 0;
      int idx = 1;
      FOR(j,1,20001){
        costList2[i][j] = costList2[i][j-1] + pa[idx-1].second;
        if(pa[idx].first == j) idx++;
      }
      //rep(j,10) cout <<  costList2[1][j] << " ";
      //cout << endl;
   }
   vector<vector<edge2>> el(n);
   // それぞれの路線だけで最短経路問題をとく
   rep(i,c){
     wa(i,el);
     // rep(i,c) rep(j,el[i].size()) cout << i << "->"<< el[i][j].to << ":" << el[i][j].d << endl;
     // cout << " -------------- " << endl;
   }

   solve(el);
   rep(i,10010) edges[i].clear();
   rep(i,c) costList[i].clear();
  }
}



Measured memory_bytes: 13824
k=int(input())
lis=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lis[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  string s;
  cin >> s;

  if (s=="RRR") {
    cout << 3 << endl;
  } else if (s=="RRS") {
    cout << 2 << endl;
  } else if (s=="SRR") {
    cout << 2 << endl;
  } else if (s=="SRS") {
    cout << 1 << endl;
  } else if (s=="RSR") {
    cout << 1 << endl;
  } else if (s=="RSS") {
    cout << 1 << endl;
  } else if (s=="SSR") {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int a[101][101];

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int u, k, v;
		cin >> u >> k;
		while (k--) {
			cin >> v;
			a[i][v] = 1;

		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j != 1)cout << " " << a[i][j];
			else if(j==1){
				cout << a[i][j];
			}
		}
		cout << endl;
	}
	


	return 0;
}


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

#define rep(i,a,b) for(int i=a;i<(b);i++)
#define trav(a,x) for(auto & a :x)
#define all(x) begin(x),end(x)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vpii vector<pii>
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;


const int M=1e9+7;

/*
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;    
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
*/


void solve()
{ 
int n,c;
cin>>n>>c;
int arr[n+1];
for(int i=0;i<n;i++)
{
cin>>arr[i];	
}

sort(arr,arr+n);

ll sum=0;

for(int i=0;i<c;i++)
sum+=arr[i];

cout<<sum;
}

int main() 
{   
    ios::sync_with_stdio(0);
	cin.tie(0);
  
   int test=1;
 //  cin>>test;
   while(test--)
    {
	  solve();
	  cout<<"\n";
    }
  return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
int main()
{
    int n,r;

    scanf("%d",&n);

    if(n<=9)
    {
            if((n==2)||(n==4)||(n==5)||(n==7)||(n==9))
        {
            printf("hon\n");
        }

        if((n==0)||(n==1)||(n==6)||(n==8))
        {
            printf("pon\n");
        }

        if(n==3)
        {
            printf("bon\n");
        }
    }

    if(n>9)

    {
        r=n%10;

        if((r==2)||(r==4)||(r==5)||(r==7)||(r==9))
        {
            printf("hon\n");
        }

        if((r==0)||(r==1)||(r==6)||(r==8))
        {
            printf("pon\n");
        }

        if(r==3)
        {
            printf("bon\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;
// 最大公約数を求める
template <class T> T gcd(T a, T b){
    if(b>a) T tmp = a, a=b, b=tmp;
    if(b==0) return a;
    else return gcd(b,a%b);
}
// n要素の最大公約数を求める
template <class T> T gcd_n(const vector<T> &V){
    T tmp=V[0];
    for( auto v : V) tmp = gcd(tmp, v);
    return tmp;
}

//最小公約数を求めるO(1)
template <class T> T lcm(T a, T b){
    if(a==0 || b==0) return 0;
    else 
    {
        T g=gcd(a,b);
        return g*(a/g)*(b/g);
    }
}
// n要素の最小公約数を求める
template <class T> T lcm_n(const vector<T> &V){
    T gcd_ = gcd_n(V);
    T tmp = V[0];
    for(auto v : V) tmp = lcm(tmp, v);
    return tmp;
}
// 約数を列挙するO(n^-2/1)
template <class T> vector<T> enum_diviser(T n){
    vector<T> ret(0);
    for(T i=1; i*i<=n; i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        } 
    }
    sort(ret.begin(), ret.end());
    return ret;
}
// 素因数分解
template <class T> vector<T> enum_factor_vec(T n){
    vector<T> ret(0);
    for(int i=2; i*i<=n; i++){
    while(n%i==0){
            ret.push_back(i);
            n/=i;
        }
    }
    ret.push_back(n);
    return ret;
}
template <class T> map<T,int> enum_factor_map(T n){
    map<T, int> ret;
    for(int i=2; i*i<=n; i++){
    while(n%i==0){
            ret[i]++;
            n/=i;
        }
    }
    ret[n]++;
    return ret;
}

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

    ll div_c=0,div_d=0,div_cd=0;
    div_c = (b / c) - ((a-1) / c);
    div_d = (b / d) - ((a-1) / d); 
    ll _lcm = lcm(c,d);
    div_cd = (b/ _lcm ) - ((a-1) / _lcm );
    // cout << div_c << endl;
    // cout << div_d << endl;
    // cout << div_cd << endl;
    cout << (b-a+1) - div_c - div_d + div_cd << endl;

    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ses   "\n"
#define whp   " "
#define mxi 99999

#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define PI acos(-1)
#define sz(a) long long(a.size())
#define ff first
#define ss second
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)

#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)

#define MS(a,b) memset(a,b,sizeof(a));

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll fx[4]= {1,-1,0,0};
ll fy[4]= {0,0,1,-1};

typedef vector<ll> vll;
typedef vector<string> vss;
typedef vector<pair<ll,ll > > vpr;
typedef vector<pair<string,ll > > vspr;
typedef list<ll> li;
typedef list<string> ls;
typedef list<pair<ll,ll> > lpr;
typedef list<pair<string,ll> > lspr;

bool rs(ll a, ll b){return(a>b);}
ll spd(ll n){ if(n%2==0)return 2; for(ll i=3; i*i<=n; i++){if(n%i==0)return i;}return n;}

int main(){

ll n; cin>>n;
ll c=0;
for(ll i=1; i<=n; i++){
    ll x; cin>>x;
    if(i%2!=0 && x%2!=0)c++;
}
cout<<c<<endl;
return 0;
}


Measured memory_bytes: 3588