akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int H = in();
  int W = in();
  const string U = "snuke";

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      char S[7];
      scanf("%s", S);
      if (string(S) == U) {
        printf("%c%d\n", 'A' + j, i + 1);
      }
    }
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll mod=1e9+7;
ll MAX=1e6;
vector<ll> fact(MAX),fact_inv(MAX);
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
ll comb(ll n, ll r){
    if(n<r || n<0 || r<0) return 0;
    return(fact[n]*fact_inv[r])%mod*fact_inv[n-r]%mod;
}

ll pow(ll x, ll n, ll mod) { //x^n 計算量O(logn)
	ll ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x;
            ans%=mod;
		}
		x = x * x; //一周する度にx, x^2, x^4, x^8となる
        x%=mod;
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans%mod;
}


int main(){
    ll n,k; cin>>n>>k;
    ll mod=1e9+7;
    fact[0]=1;
    rep(i,n)fact[i+1]=fact[i]*(i+1)%mod;
    fact_inv[n]=power(fact[n],mod-2);
    rep(i,n)fact_inv[n-1-i]=fact_inv[n-i]*(n-i)%mod;
    ll res=0;
    if(n<=k) k=n-1;
    for(ll i=0; i<=k; i++){
        res+=comb(n,i)*comb(n-1,i);
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 15872
k = [int(input()) for i in range(4)]
p = 0

#どの硬貨も高々50枚
for a in range(k[0]+1):
    for b in range(k[1]+1):
        for c in range(k[2]+1):
            if 500*a + 100*b + 50*c == k[3]:
                p += 1

print(p)


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

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

int main(){
  ll a,b;
  cin >> a >> b;
  ll g=gcd(a,b);
  int rg=sqrt(g);
  int i=2,ans=1;
  bool checker=false;
  while(i<=rg){
    while(g%i==0){
      if(!checker){
        checker=true;
        ans++;
      }
      g/=i;
    }
    checker=false;
    i++;
  }
  if(g!=1) ans++;
  cout << ans;
  return 0;
}

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

int main() {

  string S;
  cin >> S;

  if(S == "SUN"){
    cout << 7 << endl;
  }else if(S == "MON"){
    cout << 6 << endl;
  }else if(S == "TUE"){
    cout << 5 << endl;
  }else if(S == "WED"){
    cout << 4 << endl;
  }else if(S == "THU"){
    cout << 3 << endl;
  }else if(S == "FRI"){
    cout << 2 << endl;
  }else if(S == "SAT"){
    cout << 1 << endl;
  }

}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main(){
	int a,b,n,box[17][17],g[40],h[40];
	
	for(int i=1;i<17;i++){
		box[0][i]=0;
		box[i][0]=0;
	}
	box[1][0]=1;
	
	while(1){
		cin >> a >> b ;
		if((a==0)&&(b==0)){
			return 0;
		}
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> g[i] >> h[i];
		}
		for(int i=1;i<=a;i++){
			for(int j=1;j<=b;j++){
				box[i][j]=box[i][j-1]+box[i-1][j];
				for(int i=0;i<n;i++){
					box[g[i]][h[i]]=0;
				}
			}
		}
		cout << box[a][b] << "\n";
	}
return 0;
}

Measured memory_bytes: 1160
N, D = gets.split.map(&:to_i)
V = N.times.map{ gets.split.map(&:to_i) }
puts V.combination(2).count{|a,b| d2 = a.zip(b).inject(0){|s, (da,db)| s + (da - db) ** 2 } ; d2 == Math.sqrt(d2).floor ** 2 }


Measured memory_bytes: 1788
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  long long a, b, c;
  int k;

  cin >> a >> b >> c;
  cin >> k;
  long long ans = a + b + c;
  long long d = max(a, max(b, c));
  ans -= d;
  for (int i = 0; i < k; i++) {
    d *= 2;
  }
  ans += d;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100007];
int gcd(int x,int y){
  if(y==0)return x;
else return gcd(y,x%y);
}
int main(){
  ios::sync_with_stdio(false);
  cin>>n>>a[0];
  for(int i=1;i<=n;i++){
      cin>>a[i];
}
sort(a,a+n+1);int g=0;
for(int i=1;i<=n;i++){
  g=gcd(g,a[i]-a[i-1]);
}
cout<<g<<endl;return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define Max_num 100

void insertionsort(int array[],int number){
    int temp;
    int j;
    for(int i = 0;i < number;i++){
        if(i == number - 1){
            cout << array[i] << endl;
            break;
        }
        cout << array[i] << " ";
    }
    for(int i = 1;i < number;i++){
        temp = array[i];
        j = i - 1;
        while(j >= 0 && array[j] > temp){
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = temp;
        for(int t = 0;t < number;t++){
            if(t == number - 1){
                cout << array[t] << endl;
                break;
            }
            cout << array[t] << " ";
        }
    }
}

int main(){
    int num;
    int origin[Max_num];
    cin >> num;
    for(int i = 0;i < num;i++) cin >> origin[i];
    insertionsort(origin,num);
    return 0;
}


Measured memory_bytes: 3120
<?php
$n=trim(fgets(STDIN));
$i=0;
while($i<$n){
  $s[]=trim(fgets(STDIN));
  ++$i;
}
$c=array_count_values($s);
arsort($c);
$m=0;
foreach($c as $k => $v){
  if($m==0){
    $m=$v;
  }
  if($v==$m){
    $ans[]=$k;
  }else{
    break;
  }
}
sort($ans);
echo join("\n",$ans);

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

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

Node *root, *NIL;

void insert(int key)
{
    Node *newnode = (Node *)malloc(sizeof(Node));
    newnode -> key = key;
    newnode -> parent = NIL;
    newnode -> left = NIL;
    newnode -> right = NIL;

    Node *x = root;
    Node *y = NIL;

    while (x != NIL)
    {
        y = x;

        if (x -> key >= newnode -> key)
        {
            x = x -> left;
        }
        else
        {
            x = x -> right;
        }
    }

    newnode -> parent = y;

    if (y == NIL)
    {
        root = newnode;
    }
    else
    {
        if (y -> key >= newnode -> key)
        {
            y -> left = newnode;
        }
        else
        {
            y -> right = newnode;
        }
    }
}

void preParse(Node *u)
{
    if (u == NIL) return;
    cout << " " << u -> key;
    preParse(u -> left);
    preParse(u -> right); 
}

void inParse(Node *u)
{
    if (u == NIL) return;
    inParse(u -> left);
    cout << " " << u -> key;
    inParse(u -> right); 
}

int main()
{
    int m, key;
    string command;

    cin >> m;

    for (int i = 0; i != m; ++i)
    {
        cin >> command;

        if (command == "insert")
        {
            cin >> key;
            insert(key);
        }
        else if (command == "print")
        {
            inParse(root);
            cout << endl;
            preParse(root);
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 26588
#!/usr/bin/env python3

H, W = map(int, input().split())
S = [list('.'*(W+2))]

for i in range(H):
    S.append(list('.' + input() + '.'))

S.append(list('.'*(W+2)))

A = []


for i in range(1, H+1):
    AA = []
    for j in range(1, W+1):
        cnt = 0
        if S[i][j] == '#':
            AA.append('#')
            continue
        if S[i-1][j-1] == '#': cnt += 1
        if S[i-1][j] == '#': cnt += 1
        if S[i-1][j+1] == '#': cnt += 1
        if S[i][j-1] == '#': cnt += 1
        if S[i][j+1] == '#': cnt += 1
        if S[i+1][j-1] == '#': cnt += 1
        if S[i+1][j] == '#': cnt += 1
        if S[i+1][j+1] == '#': cnt += 1
        AA.append(cnt)
    A.append(AA)

for a in A:
    print(''.join(map(str, a)))


Measured memory_bytes: 3064
/*  -*- coding: utf-8 -*-
 *
 * d.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;

typedef long long ll;
const ll LINF = 1LL << 62;
const ll INIT = 1000000000000000LL;

/* typedef */

typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<pii> vpii;

/* global variables */

vpii anbrs[MAX_N], bnbrs[MAX_N];
ll ads[MAX_N], bds[MAX_N], sums[MAX_N];

/* subroutines */

void dijkstra(int n, vpii nbrs[], ll dists[], int st) {
  fill(dists, dists + n, LINF);
  dists[st] = 0;

  priority_queue<pli> q;
  q.push(pli(0, st));

  while (! q.empty()) {
    pli u = q.top(); q.pop();
    ll ud = -u.first;
    int &ui = u.second;

    vpii &nbru = nbrs[ui];
    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &vi = vit->first;
      ll vd = ud + vit->second;
      if (dists[vi] > vd) {
	dists[vi] = vd;
	q.push(pli(-vd, vi));
      }
    }
  }
}

/* main */

int main() {
  int n, m, s, t;
  scanf("%d%d%d%d", &n, &m, &s, &t);
  s--, t--;

  for (int i = 0; i < m; i++) {
    int u, v, a, b;
    scanf("%d%d%d%d", &u, &v, &a, &b);
    u--, v--;
    anbrs[u].push_back(pii(v, a));
    anbrs[v].push_back(pii(u, a));
    bnbrs[u].push_back(pii(v, b));
    bnbrs[v].push_back(pii(u, b));
  }

  dijkstra(n, anbrs, ads, s);
  dijkstra(n, bnbrs, bds, t);

  ll minsum = LINF;
  for (int i = n - 1; i >= 0; i--) {
    ll sum = ads[i] + bds[i];
    if (minsum > sum) minsum = sum;
    sums[i] = minsum;
  }

  for (int i = 0; i < n; i++)
    printf("%lld\n", INIT - sums[i]);
  return 0;
}


Measured memory_bytes: 16252
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int h, n;
	cin >> h >> n;

	vector<pair<int, int> > spells(n);
	int a, b;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		spells[i] = {a, b};
	}

	vector<int> dp(h + 1, 1e8);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < h; ++j) {
			dp[min(j + spells[i].first, h)] = min(dp[min(j + spells[i].first, h)], dp[j] + spells[i].second);
		}
	}
	cout << dp[h] << "\n";

	return 0;

}

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

using namespace std;

#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define all(c) (c).begin(), (c).end()
#define sz(a) int((a).size())
#define pb push_back
#define fo(i, n) for (int i = 0; i < n; i++)
#define FO(i, k, n) for(int i = k; i < n; i++)
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ii = pair<int, int>;
using ll = long long;

const int MAX = 1000001;

int factor[MAX] = {0};

void generatePrimeFactors()
{
    factor[1] = 1;

    // Initializes all the positions with their value.
    for (int i = 2; i < MAX; i++)
        factor[i] = i;

    // Initializes all multiples of 2 with 2
    for (int i = 4; i < MAX; i += 2)
        factor[i] = 2;

    // A modified version of Sieve of Eratosthenes to
    // store the smallest prime factor that divides
    // every number.
    for (int i = 3; i * i < MAX; i++)
    {
        // check if it has no prime factor.
        if (factor[i] == i)
        {
            // Initializes of j starting from i*i
            for (int j = i * i; j < MAX; j += i)
            {
                // if it has no prime factor before, then
                // stores the smallest prime divisor
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}

int calculateNoOFactors(int n)
{
    if (n == 1)
        return 1;

    int ans = 1;

    // stores the smallest prime number
    // that divides n
    int dup = factor[n];

    // stores the count of number of times
    // a prime number divides n.
    int c = 1;

    // reduces to the next number after prime
    // factorization of n
    int j = n / factor[n];

    // false when prime factorization is done
    while (j != 1)
    {
        // if the same prime number is dividing n,
        // then we increase the count
        if (factor[j] == dup)
            c += 1;

        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else
        {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }

        // prime factorizes a number
        j = j / factor[j];
    }

    // for the last prime factor
    ans = ans * (c + 1);

    return ans;
}

int main(){
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    generatePrimeFactors();
    int n ;
    cin >> n;

    int ans = 0;
    for (int i = 1; i < n; i++)
        ans += calculateNoOFactors(i);

    cout << ans;
    return 0;
}


Measured memory_bytes: 7492
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <queue>
#include <tuple>

using namespace std;

using TUP = tuple<int, int, int, int>;

using VD = vector<double>;
using VVD = vector<VD>;
using VVVD = vector<VVD>;

int n;

VVVD memo; //ijk -> 000 となる期待値

double dfs(int n1, int n2, int n3) {
	if (memo[n1][n2][n3] != 0 ||
		// 0,0,0の値は0で初期化済み
		(n1 == 0 && n2 == 0 && n3 == 0)
	) {
		return memo[n1][n2][n3];
	}

	double val = n;
	if (n1 > 0) { val += dfs(n1-1, n2,   n3)   * n1; }
	if (n2 > 0) { val += dfs(n1+1, n2-1, n3)   * n2; }
	if (n3 > 0) { val += dfs(n1,   n2+1, n3-1) * n3; }
	val /= (n1 + n2 + n3);
	memo[n1][n2][n3] = val;

	return val;
}

int main() {
	cin >> n;

	int a;
	int n1, n2, n3;
	n1 = n2 = n3 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		switch (a) {
			case 1: n1++; break;
			case 2: n2++; break;
			case 3: n3++; break;
			default: break;
		}
	}
	memo.assign(n+1, VVD(n+1, VD(n+1, 0)));
	double ans = dfs(n1, n2, n3);

	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 216960
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline long long read(){
    long long f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
int main(){
    int l = read(),r = read(),k = read();   
    cout << r / k - (l-1)/k << endl; 
    return 0;
}

Measured memory_bytes: 3632
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

bool isok(int n) {
    for (int i = 2; i < n; i++) {
        if (n%i == 0)return false;
    }
    return true;
}

int main() {
    int N;
    cin >> N;

    for (int i = 11; N != 0; i += 10) {
        if (isok(i)) {
            cout << i << " ";
            N--;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int A, B;
    cin >> A >> B;
    cout << max({2 * A - 1, 2 * B - 1, A + B}) << endl;
}


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

int main () {
    int N;
    cin >> N;
    int A[N];
    for (int i=0;i < N; ++i) cin >> A[i];
    int ans = 0;

    while(true) {
        bool exist_odd = false;
        for (int i = 0; i < N; i++) {
            if(A[i] % 2 != 0) exist_odd = true;
        }
        if (exist_odd) break;
        else {
            for (int i = 0; i < N; i++) {
                A[i] = A[i] / 2;
            }
            ans ++;
        }
        
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N;
    cin >> N;
    vector<int64_t>vec(N);
    for (int64_t i = 0; i< N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    int64_t size = vec.size();
    int64_t kazu = vec[size/2] - vec[size/2-1];
    cout << kazu << endl;
    return 0;
}

Measured memory_bytes: 1024
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0, M =0, C =0;
    cin(N);cin(M);cin(C);

    vll B(M);
    vvll A(N,vll(M));
    REP(i,M) cin(B.at(i));
    REP(i,N){
        REP(j,M){
            cin(A.at(i).at(j));
        }
    }

    //本文
    ll count = 0;
    REP(i,N){
        ll ans = 0;
        REP(j,M){
            ans += B.at(j) * A.at(i).at(j);
        }
        if(ans + C > 0) count++;
    }



    //出力
    cout << count << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3628
def slove():
    import sys
    import itertools
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    mt = 0
    for v in itertools.product(["+", ""], repeat=len(s)-1):
        l = []
        t = 0
        for i, vv in enumerate(v):
            l.append(s[i])
            if vv == "+":
                t += int("".join(l))
                l = []
        l.append(s[-1])
        t += int("".join(l))
        mt += t
    print(mt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40688
d,g = map(int,input().split())
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = map(int,input().split())
ans = 10**9
for bin in range(0, 1<<d):
    cnt = tot = 0
    rest_max_bit = -1
    for i in range(d):
        if bin & 1<<i:
            t = (i+1)*100
            tot += P[i]*t + C[i]
            cnt += P[i]
        else: rest_max_bit = i
    if tot >= g:
        ans = min(ans, cnt)
        continue
    if rest_max_bit < 0: continue
    t = (rest_max_bit+1)*100
    p = (g+t-tot-1)//t
    if p < P[rest_max_bit]: ans = min(ans, cnt + p)
print(ans)


Measured memory_bytes: 3064
// abc136_a
#include <iostream>
using namespace std;

int main(void) {
	int A, B, C;
	cin >> A >> B >> C;
	int res = C - (A - B);
	if (res < 0) {
		cout << 0 << endl;
	}
	else {
		cout << C - (A - B) << endl;
	}
	return 0;


}

Measured memory_bytes: 256
N, M = input().split()
height = input().split()
able = []
for n in range(int(N)):
  able.append([])
for m in range(int(M)):
  con = input().split()
  con[0] = int(con[0]) - 1
  con[1] = int(con[1]) - 1
  able[con[0]].append(int(height[con[1]]))
  able[con[1]].append(int(height[con[0]]))
good = []
for n in range(int(N)):
  if len(able[n]) == 0:
    good.append(n)
  else:
    if int(height[n]) > max(able[n]):
      good.append(n)
print(len(good))


Measured memory_bytes: 35584
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		public static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var line = cin.ReadIntArray(2);
			int N = line[0], K = line[1];
			var A = cin.ReadIntArray(N);
			bool brightFlag = false;
			for(int q = 0; q < K; q++) {
				LightUp(A, N, ref brightFlag);
				if(brightFlag) break;
			}
			Console.WriteLine(A.Join());
		}

		public void LightUp(int[] bulbs, int N, ref bool brightFlag) {
			var imos = new int[N];
			//count[i]=sum_{j in 0..i} imos[j]
			var minL = bulbs[0];
			for(int i = 0; i < N; i++) {
				var l = bulbs[i];
				if(l < minL) minL = l;
				imos[Max(0, i - l)]++;
				if(i + l + 1 < N) imos[i + l + 1]--;
			}
			if(!brightFlag && minL >= N) brightFlag = true;
			bulbs[0] = imos[0];
			for(int i = 1; i < N; i++) {
				bulbs[i] = imos[i] + bulbs[i - 1];
			}
		}
	}

	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ")
			=> string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

}

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

int main() {
  int n,count=0;
  cin>>n;
  vector<string> w(n);
  for(int i=0; i<n; i++) cin>>w[i];
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(w[i]==w[j]) count++;
      if(count==2) {
        cout<<"No";
        return 0;
      }
    }
    count=0;
  }
  for(int i=0; i<n-1; i++){
    if(w[i].back() != w[i+1].front()){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int n,m;
main()
{
	while(cin>>n>>m,n)
	{
		int cnt[11]={};
		for(int i=0;i<n;i++)
		{
			int d,p;cin>>d>>p;
			cnt[p]+=d;
		}
		for(int i=10;i>=0&&m;i--)
		{
			if(m>cnt[i])
			{
				m-=cnt[i];cnt[i]=0;
			}
			else
			{
				cnt[i]-=m;
				m=0;
			}
		}
		long long ans=0;
		for(int i=0;i<=10;i++)ans+=cnt[i]*i;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 2976
from collections import defaultdict
table=defaultdict(int)
n=int(input())
m=0
for i in range(n):
    word =input()
    table[word]+=1
    if table[word]<m:
        pass
    else:
        m=table[word]
rtable=[]
for i in table.keys():
    if table[i]==m:
        rtable.append(i)

rtable.sort()
for i in rtable:
    print(i)

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

#define int long long

signed main(){
    int n, m;
    priority_queue<pair<int, int> > pq;

    cin >> n >> m;
    int a;
    for(int i = 0;i < n;i++){
        cin >> a;
        pq.push(make_pair(a, 1));
    }

    for(int i = 0;i < m;i++){
        int b, c;
        cin >> b >> c;
        pq.push(make_pair(c, b));
    }

    int noko = n;
    int ans = 0;
    while(noko > 0){
        int num = pq.top().first;
        int size = min(pq.top().second, noko);
        ans += num * size;
        noko -= size;
        pq.pop();
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6512
N = int(input())
x = []
u = []
for i in range(N):
  x1,u1 = input().split()
  x.append(float(x1))
  u.append(str(u1))
otoshidama = 0.0
for i in range(N):
  if u[i] == "JPY":
    otoshidama += x[i]
  else:
    otoshidama += x[i]*380000.0
print(otoshidama)

Measured memory_bytes: 3060
// AOJ 2900 Bumpy Array
// 2018.3.14 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 整数の入力（負数に対応）
{
	int n = 0, c = gc();
	if (c == '-') {
		c = gc();
		do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int N;
int a[100005], b[100005];

int calc(int *a)
{
	int i, t, ans = 0;

	for (i = 2; i < N; i++) {
		if (a[i - 2] > a[i - 1]) {
			if (i == N - 1) {
				if (a[i - 1] > a[i]) ans++;
				break;
			}
		}
		else {
			if (a[i - 2] < a[i]) t = a[i - 2], a[i - 2] = a[i - 1], a[i - 1] = t;
			else t = a[i - 1], a[i - 1] = a[i], a[i] = t;
			ans++;
		}
		
		if (++i == N) break;
		if (a[i - 2] < a[i - 1]) {
			if (i == N - 1) {
				if (a[i - 1] < a[i]) ans++;
				break;
			}
		}
		else {
			if (a[i - 2] > a[i]) t = a[i - 2], a[i - 2] = a[i - 1], a[i - 1] = t;
			else t = a[i - 1], a[i - 1] = a[i], a[i] = t;
			ans++;
		}
	}
	return ans;
}

int main()
{
	int i, ans;

	N = in();
	if (N < 3) { puts("0"); return 0; }
	for (i = 0; i < N; i++) a[i] = in(), b[i] = -a[i];

	ans = calc(a);
	i = calc(b);
	if (i < ans) ans = i;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2632
#include<iostream>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;
int inf=-1;
int upper(vector<int> const& dp,int const& key){
  int right=dp.size()-1;
  int left=0;int res;
  if(dp[right]>=key){
    res=right;
    goto FINE;
  }
  while(right-left>1){
    int mid=(right+left)/2;
    if(dp[mid]<key)right=mid;
    else left=mid;
  }
  res=right;
  FINE:
  return res;
}
void lis(int const& n,vector<int> const& c,int& ans){
    //vector<int>::iterator it;
    int index;
    vector<int> dp(n+1,inf);
    dp[0]=1000000007;
    for(int i=0;i<n;i++){
        index=upper(dp,c[i]);
        dp[index]=max(dp[index],c[i]);
    }
    ans=0;
    for(int i=1;i<=n;i++){
        if(dp[i]!=inf)ans++;
        else break;
    }
}

signed main(){
    int n;
    cin>>n;
    vector<int> c(n);
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    //reverse(c.begin(),c.end());
    int ans;
    lis(n,c,ans);
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    ll d, g;
    cin >> d >> g;
    vector<ll> nums(d);
    vector<ll> bonus(d);
    for (ll i = 0; i < d; ++i) {
        cin >> nums[i] >> bonus[i];
    }
    ll ans = 1e9;
    for (ll mask = 0; mask < 1 << d; ++mask) {
        ll tmp = mask;
        ll cnt = 0;
        ll score = g;
        ll last = 0;
        for (ll i = 0; i < d; ++i) {
            if (tmp & 1) {
                score -= (nums[i] * (i + 1) * 100 + bonus[i]);
                cnt += nums[i];
            } else last = i;
            tmp >>= 1;
        }
        if (score <= 0) ans = min(ans, cnt);
        else {
            for (int j = 1; j < nums[last]; ++j) {
                if (j * (last + 1) * 100 >= score) {
                    cnt += j;
                    ans = min(ans, cnt);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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 (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N,K;
	ll result=INF;
	string S;
	cin>>N>>K;
	VI vec(N);
	REP(i, N) cin >> vec[i];
	SORT(vec);
	REP(i,N-K+1){
		ll tmp=vec[i+K-1]-vec[i];
		result =min(result,tmp);
	}
	cout << result << "\n";
	return;
}

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


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

int main(){
  int n,a;
  cin>>n>>a;
  int memo;
  int ans=0;
  lp(i,n){
    cin>>memo;
    if(memo>a) ans+=memo-a;
  }
  if(ans<=0) cout<<"kusoge"<<endl;
  else cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 52;
const int BIT = (1<<20);
int n, m, d[N];
vector<int> g[N];
ll bit[BIT];
vector<int> v;
void dfs_pre(int fa, int u, int src, int dest, int idx) {
    v.push_back(u);
    if(u == dest) {
        for(int i = 1; i < v.size(); i++) {
            int t = v[i];
            if(d[v[i]] < d[v[i-1]]) t = v[i-1];
            bit[1<<idx] |= (1LL<<t);
        }
    }
    for(int v : g[u]) {
        if(v == fa) continue;
        if(dest==-1) d[v] = d[u]+1;
        dfs_pre(u, v, src, dest, idx);
    }
    v.pop_back();
}
int get_count(ll x) {
    int t = 0;
    while(x) {
        if(x&1) t++;
        x /= 2;
    }
    return t;
}
int main() {
    cin >> n;
    for(int i = 1, u, v; i < n; i++) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    cin >> m;
    dfs_pre(-1, 1, 1, -1, 0);
    for(int i = 0, u, v; i < m; i++) {
        cin >> u >> v;
        dfs_pre(-1, u, u, v, i);
    }
    ll ans = (1LL<<(n-1));
    for(int i = 1; i < (1<<m); i++) {
        bit[i] = bit[i&-i] | bit[i-(i&-i)];
        int c = get_count(bit[i]);
        ll res = (1LL<<(n-1-c)) * ((get_count(i) & 1) ? 1 : -1);
        ans -= res;
    }
    cout << ans << '\n';
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> already(n,false);
  rep(i,n){
    int b;
    cin >> b;
    a[i]=b-1;
  }
  
  bool can=true;
  int count=0;
  already[0]=true;
  int i=0;
  
  rep(j,n){
    if(already[a[i]]){
      can=false;
      count=-1;
      break;
    }
    else{
      already[a[i]]=true;
      count++;
      if(a[i]==1){
        break;
      }
      i=a[i];
    }
  }
  cout << count << endl;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(0);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;

const int MOD = inf + 7;

signed main(){
	fast;
	
	int n;
	cin >> n;
   int ans = (n+1)/2;
   cout << ans;
}

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

int main()
{
    long H,W;
    std::cin >> H >> W;
    if(H==1 || W==1){
        std::cout << 1 << std::endl;
    }else{
        long result=H*W;
    long result1=result/2+result%2;
    std::cout << result1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N, long long L, std::vector<std::string> S){
    sort(S.begin(), S.end());
    REP(i, N)
        cout << S[i];
    cout << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    long long L;
    cin >> L;
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, L, std::move(S));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	long int a[10000];

	long int i, j,n,z,s;

	scanf("%ld",&n);

	for (i = 0; i < n; i++){
		scanf("%ld", &a[i]);
	}

	for (i = 0; i < n; i++){
		for (j = i+1; j <= n - 1; j++){

			if (a[i]>a[j]){
				z = a[i];
				a[i] = a[j];
				a[j] = z;
			}

		}
	}
	s = a[0];
	for (i = 1; i < n; i++){
		s = s + a[i];
	}
	printf("%ld %ld %ld\n",a[0],a[n-1],s);

	return 0;
}

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

int main() {
  int n;
  cin >> n;

  vector<int> data(10001);

  for (int i = 1; i < 101; i++) {
    for (int j = 1; j < 101; j++) {
      for (int k = 1; k < 101; k++) {
        int sum = i*i + j*j + k*k +i*j + j*k + k*i;
        if (sum < 10001) {
          data[sum]++;
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << data[i] << endl;
  }
  
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef struct dice{
	int num[6];
	int i;
	
}Dice;

int main(int argc, const char * argv[]) {
	
	int i,j,n,s;
	char way[101];
	Dice a;
	int Dice[5] = {6 ,3 ,4 ,5 ,2 }; // sita , E ,W ,N ,S

	
	scanf("%d",&a.num[0]);
	scanf("%d",&a.num[1]);
	scanf("%d",&a.num[2]);
	scanf("%d",&a.num[3]);
	scanf("%d",&a.num[4]);
	scanf("%d",&a.num[5]);
	
	scanf("%s",way);
	
	for(i = 0; way[i] != '\0' ; i++) {
		
		int tmp = 0;
		if(way[i] == 'N') { 
			tmp = Dice[3];
		    Dice[3] = 7 - Dice[0];
			Dice[4] = Dice[0];
			Dice[0] = tmp;
		} else if(way[i] == 'S') {
			tmp = Dice[4];
			Dice[4] = 7 - Dice[0];
			Dice[3] = Dice[0];
			Dice[0] = tmp;
		} else if(way[i] == 'W') {
			tmp = Dice[2];
			Dice[2] = 7 - Dice[0];
			Dice[1] = Dice[0];
			Dice[0] = tmp;
		} else if(way[i] == 'E') {
			tmp = Dice[1];
			Dice[1] = 7 - Dice[0];
			Dice[2] = Dice[0];
			Dice[0] = tmp;
		}
		
// 		for(j = 0 ; j < 5 ; j++) {
// 			printf("%d ",Dice[j]);
// 		}
// 		printf("\n");

	}
	
	printf("%d\n",a.num[7-Dice[0] - 1]);
	return 0;
	
	
}

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


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

    // solution comes here

    ll N, P;    cin >> N >> P;

    if(1 == N) {
        cout << P << "\n";
        return 0;
    }

    if(N >= 50) {
        cout << "1\n";
        return 0;
    }

    ll ans=1;
    for(ll i=2; i*i<=P; i++) {
        if(P%i == 0) {
            ll cnt=1;
            P /= i;
            while(P%i == 0){
                P /= i;
                cnt++;
                if(cnt%N == 0) ans *= i;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
use std::io::Write;
use std::io::{stdin, stdout, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        (&mut $iter).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

#[derive(Clone, Copy, Debug)]
enum Node {
    Null,
    Ng,
    D(usize),
}

fn main() {
    use Node::*;
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(iter, 2);
    let mut v: Vec<_> = iter
        .next()
        .unwrap()
        .chars()
        .map(|x| if x == '0' { Null } else { Ng })
        .collect();
    v[n] = D(0);
    let mut r = n - 1;
    for i in 0..n {
        if let D(cur) = v[n - i] {
            if i + r <= n {
                for j in (n - i - r)..(m + 1) {
                    if i + j <= n {
                        let k = n - i - j;
                        v[k] = match v[k] {
                            Null => D(cur + 1),
                            x => x,
                        };
                        if k > 0 {
                            r = k - 1;
                        }
                    }
                }
            }
        }
    }
    let mut curi = 0;
    let mut cur = match v[0] {
        D(d) => d,
        _ => {
            println!("{}", -1);
            return;
        }
    };
    let mut ret: Vec<usize> = vec![];
    while curi < n {
        for next in (curi + 1)..(n + 1) {
            match v[next] {
                D(d) if d < cur => {
                    ret.push(next - curi);
                    curi = next;
                    cur = d;
                    break;
                }
                _ => {}
            }
        }
    }
    println!(
        "{}",
        ret.iter()
            .map(|&x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    ); // debug
}


Measured memory_bytes: 12668
n,m,x,y=map(int ,input().split())
a=list(map(int ,input().split()))
b=list(map(int ,input().split()))
l=a[0]
r=b[0]
for i in a:
    if i > x:
        if i<l:
            pass
        else:
            l=i
            if l>r:
                print('War')
                exit()
    if i>=y:
        print('War')
        exit()
           
for i in b:
    if i <y:
        if i>r:
            pass
        else:
            r=i
            if l>r:
                print('War')
                exit()
    if i<=x:
        print('War')
        exit() 
if l==r:
    if r==y:
        print('No War')
    else:
        print('War')
else:
    print('No War')

Measured memory_bytes: 38512
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;

using lll = long long;
using ull = unsigned long long;
using namespace std;
const ull MOD = 1000000007;

int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int n;
  vector<lll> a;

  cin >> n;
  a.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }

  lll sumAdd = 0;

  for(ii=0;ii<a.size();ii++){
    sumAdd += a[ii];
    sumAdd %= MOD;
  }
  lll sum = 0;


  
  for(ii=0;ii<a.size();ii++){
    //if(ii % 1000 == 0){
    //  cout << ii << endl;
    //}
    //for(jj=ii+1;jj<a.size();jj++){
    //  sum = a[ii] * a[jj]   + sum;
    //  sum %= MOD;
    //}

    sumAdd -= a[ii];
    if(sumAdd < 0) sumAdd += MOD;
    
    sum += a[ii] * sumAdd;
    sum %= MOD;
    
  }
  //cout << MOD << endl;
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4848
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
const int ng=100000000;
int N,M,X;
int C[13];
int A[13][13];
int U[13];
int Mi=ng,ans=0;
int main(){
	cin >> N >> M >> X;
	for(int i=0;i<N;i++){
		cin >> C[i];
		for(int j=0;j<M;j++){
			cin >> A[i][j];
		}
	}
	
	for(int i=0;i< 1<<N ;i++){
		bool f = true;
		//printf("%d\n",i);
		for(int j=0;j<M;j++)U[j]=0;
		ans=0;
		int x=i;
		for(int j=0;j<N;j++){
			//printf("%d %d %d\n",i,j,Ma);
			if(x >> j & 1){
				ans+=C[j];
				for(int k=0;k<M;k++)U[k]+=A[j][k];
					
			}
		}
		for(int k=0;k<M;k++){if(U[k]<X) f=false;};
		if(f)Mi=min(Mi,ans);
	}
	if(Mi == ng) cout << "-1" << endl;
	else cout << Mi << endl;
	return 0;
}

Measured memory_bytes: 3632
import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n,a,b=map(int,input().split())
	if b<a:
		print(0)
	else:
		print(max(0,(b-a)*(n-2)+1))


if __name__ == "__main__":
	main()


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

using namespace std;

int n,k;

int main (){
    cin >> n >> k;
    int s = 1;
    for (int i = 1; i <= n; i++)
        if (2 * s < s + k ) s = 2 * s;
            else s = s + k;
    cout << s;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int K = sc.nextInt();
	long A = sc.nextLong();
	long B = sc.nextLong();
	long prepre = 1;
	long pre = 2;
	for(int i = 2; i<=K; i++) {
	    long bis = 0;
	    if(prepre>=A) {
		bis = (long)(Math.max(pre+1, prepre-A+B));
	    }else {
		bis = pre+1;
	    }
	    prepre = pre;
	    pre = bis;
	}
	System.out.println(pre);
    }
}

Measured memory_bytes: 23124