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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

bool check(int j, int W) {
    bool ok = true;
    for (int k = 0; k + 1 < (W - 1); k++) {
        if ((j >> k & 1) && ((j >> (k + 1)) & 1)) ok = false;
    }
    return ok;
}

void solve() {
    int H, W, K;
    const int mod = 1e9 + 7;
    cin >> H >> W >> K;
    K--;

    vector<vector<vector<int>>> dp(H + 1, vector<vector<int>>(1 << (W - 1), vector<int>(W)));
    

    dp[0][0][0] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < 1 << (W - 1); j++) {
            if (!check(j, W)) continue;
            for (int k = 0; k < W; k++) {
                for (int l = 0; l < 1 << (W - 1); l++) {
                    if (!check(l, W)) continue;
                    int pos = k;
                    if (k % 2 == 0) {
                        if (l >> k & 1) pos++;
                        else if (k >= 1 && l >> (k - 1) & 1) pos--;
                    } else {
                        if (l >> (k - 1) & 1) pos--;
                        else if (l >> k & 1) pos++;
                    }
                    dp[i + 1][l][pos] += dp[i][j][k];
                    dp[i + 1][l][pos] %= mod;
                }
            }
        }
    }
    
    int ans = 0;
    for (int j = 0; j < 1 << (W - 1); j++) {
        ans += dp[H][j][K];
        ans %= mod;
    }

    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

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

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

void bfs(string s) {
    if (s == "") {

    }
}

class DLunlunNumber {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int K; in >> K;
	    int _count = 0;
	    string ans = "";
	    bool flag = true;
	    queue<string> q;
	    for (char c = '1'; c <= '9'; ++c) {
	        if (ctoi(c) == K) {
	            ans = c;
	            flag = false;
	            break;
	        }
	        string p{c};
	        q.push(p);
	        _count++;
	    }
	    if (flag) {
	        while(flag) {
	            string S = q.front();
	            q.pop();
	            char t = S[S.size()-1];
	            t--;
	            for (char c = t; c <= t+2; c++) {
	                if (c - '0' < 0) continue;
	                if (c - '9' > 0) continue;
	                _count++;
	                q.push(S+c);
	                if (_count == K) {
	                    ans = S+c;
	                    flag = false;
	                }
	            }
	        }
	    }
	    out << ans << '\n';
	}
};


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

	DLunlunNumber solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>
int main(void){
    char buf[1000];
    scanf("%s",buf);
    int flg=0;
    for(int i=0;i<3;i++){
        if(buf[i]==55)flg=1;
    }
    if(flg==1){printf("Yes\n");}else{printf("No\n");}
    //printf("%d\n",buf[2]);
    return 0;
}

Measured memory_bytes: 1664
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, d, tmp, m, h, w, x, y, sum, k, q;
ld a, b, c;

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

  cin >> a >> b >> c;
  if (a / c <= b)
    Cout("Yes");
  else
    Cout("No");
  return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <ctype.h>
using namespace std;

int main()
{	
	bool f = false;
	while (true)
	{
		char s[1000];
		cin >> s;
		if (!std::cin.good()) {
			break;
		}
		else
		{
			if (f) cout << " ";
			else f = true;
		}

		int i = 0;
		while (s[i] != '\0')
		{
			if ((s[i] >= 'A') && (s[i] <= 'Z')) {
				printf("%c", tolower(s[i]));
			}
			else if ((s[i] >= 'a') && (s[i] <= 'z')) {
				printf("%c", toupper(s[i]));
			}
			else {
				printf("%c", s[i]);
			}
			i++;
		}
		
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int main()
{
	int n,m,q,k;
	cin>>n;
	int f=0;
	while(n>0){
		int now=n%10;
		if(now==7) f=1;
		n/=10;
	}
	if(f) cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 3644
#include <cstdio>
 
int main()
{
  char c;
  scanf("%c", &c);
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    printf("vowel\n");
  else
    printf("consonant\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
 
#define all(v) v.begin(),v.end()
#define test() int t;cin>>t;while(t--) 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9+7;
const int N = 2e5+1;
vector<set<int>> graph(N);
vi visited(N, 0);
int cnt=0;

void dfs(int vtx)
{
    cnt++;
    visited[vtx]=1;
    for(auto x : graph[vtx])
        if(!visited[x])dfs(x);
}
int main()
{   
    fastio
    int n, m;
    cin>>n>>m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin>>a>>b;
        graph[a].insert(b);
        graph[b].insert(a);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if(!visited[i])
        {
            cnt=0;
            dfs(i);
            ans=max(ans, cnt);
        }
    }
    cout<<ans<<endl;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int hittokill_1 = 0, hittokill_2 = 0;
    if(a % d == 0){
        hittokill_1 = a/d;
    }else{
        hittokill_1 = a/d + 1;
    }
    
    if(c % b == 0){
        hittokill_2 = c/b;
    }else{
        hittokill_2 = c/b + 1;
    }

    if(hittokill_2 <= hittokill_1){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main() {
    int n; cin >> n;
    vector<string> dom(2);
    rep(i, 2) cin >> dom[i];

    ll res = 1, pos = 0, bef;
    if(dom[0][0] == dom[1][0]) res *= 3, pos++, bef = 1;
    else res *= 6, pos += 2, bef = 2;

    for(int i=pos; i<n; i++){
        int num;
        if(dom[0][i] == dom[1][i]) num = 1; else num = 2;
        if(bef == 2 && num == 2) res = res * 3 % MOD;
        else if(bef == 2 && num == 1) ;
        else res = res * 2 % MOD;
        bef = num;
        if(num == 2) i++;
    }
    cout << res << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, k;
    cin >> n >> k;
    if(k > (n-1)*(n-2)/2){
        puts("-1");
        return 0;
    }
    using P = pair<int, int>;
    vector<P> v;
    for (int i = 1; i < n; ++i) {
        v.emplace_back(0, i);
    }
    int cnt = (n-1)*(n-2)/2-k;
    for (int len = 1; len < n; ++len) {
        for (int i = 1; i+len < n; ++i) {
            if(!cnt) continue;
            v.emplace_back(i, i+len);
            cnt--;
        }
    }
    cout << v.size() << "\n";
    for (auto &&i : v) {
        cout << i.first+1 << " " << i.second+1 << "\n";
    }
    return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;


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

    int n,l;
    cin >> n >> l;
    int ar[n],tot=0;
    for (int i=0;i<n;i++){
        ar[i]=i+l;
        tot+=ar[i];
    }

    int mn=MOD,id=0;
    for (int i=0;i<n;i++){
        if (abs(ar[i])<mn){
            mn=abs(ar[i]);
            id=i;
        }
    }

    cout << tot-ar[id] << el;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>  //binary search trees
#include<stdlib.h>
#define NIL NULL 
 
struct node {
 
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};
 
typedef struct node* Node;
Node root;
  
void insert(int k) {
     
 Node y = NIL;
 Node x = root;
 Node z;  
 
 z = malloc(sizeof(struct node));
 z->key = k;
 z->left = NIL;
 z->right = NIL;
    
 while(x != NIL) {
    y = x;
  if(z->key < x->key)
    x = x->left;
   
  else x = x->right;
 }
  z->parent = y;
   
  if(y == NIL)
    root = z;
   
  else if(z->key < y->key)
    y->left = z;
   
  else
    y->right = z;
   
}
 
void inorder(Node u) {
   
  if(u->left != NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL)  
    inorder(u->right); 
}
 
void preorder(Node u) {
  printf(" %d",u->key);
  if(u->left != NIL)
    preorder(u->left);
  if(u->right != NIL)
    preorder(u->right); 
}
 
int main(void) {
   
  int i,n,x;
  char c[5];
   
  scanf("%d",&n);
   
  for(i=0;i<n;i++) {
    scanf("%s",c);
    if(c[0] == 'i') {
      scanf("%d",&x);
      insert(x);
    }
    else if(c[0] == 'p') {
      if(root != NIL)   
    inorder(root);
      printf("\n");
      if(root != NIL)
    preorder(root);
      printf("\n");
       
    }
  }
  return 0;
}

Measured memory_bytes: 24040
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    total = sum(a)
    must = total / (4 * m)
    cnt = 0
    for i in a:
        if i >= must:
            cnt += 1
            if cnt == m:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    main()

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

int main() {
  int a;
  vector<pair<int, int>> v(5);
  int count = 0;
  int sum = 0;
  for(int i=0; i<5; i++) {
    cin >> a;
    sum += a;
    if(a%10 == 0) count++;
    v[i] = make_pair(a%10, a);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  
  int x;
  for(int i=0; i<4-count; i++) {
    tie(x, ignore) = v[i];
    sum += 10-x;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <vector>
#include <map>
#include <fstream>
using namespace std;

int main()
{
	int a, b, h;

	cin >> a >> b >> h;

	int S = (a + b) * h / 2;

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
using namespace std;
int a[100004];
int main(){
  int n,ans=0;
  cin>>n;
  for (int i=1;i<=n;i++)
    cin>>a[i];
  a[0]=0,a[n+1]=0;
  for (int j=0;j<=n;j++) ans += abs(a[j+1] - a[j]);
  for (int q=1;q<=n;q++)
    cout<<ans - abs(a[q] - a[q-1]) - abs(a[q+1] - a[q]) + abs(a[q+1] - a[q-1])<<endl;
  system ("pause");
  return 0;
}

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

A,B,K = map(int, input().split())

l,r = A+K-1,B-K+1

if l >= r:
  first = list(range(A, r))
else:
  first = list(range(A, l+1))
last  = list(filter(lambda n: n>=A, range(r, B+1)))

for n in (first + last):
  print(n)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  #define int long
  int n,k,pos;
  string s;
  cin>>n>>k>>s;
  vector<int> v(1,0);
  if(s[0]=='1'){v[0]++;pos=0;}
  else {v.emplace_back(1);pos=1;}
  for(int i=1;i<n;++i){
    if(s[i]==s[i-1])v[pos]++;
    else {
      v.emplace_back(1);
      pos++;
    }
  }
  if(s[n-1]=='0')v.emplace_back(0);
  n=v.size();
  for(int i=1;i<n;++i)v[i]+=v[i-1];
  k=min(k,(int)v.size()/2);
  int res=v[2*k];
  for(int i=2*k+2;i<(int)v.size();i+=2){
    res=max(res,v[i]-v[i-2*k-1]);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1528
read X N
read str

[ $N -eq 0 ] && { echo $X; exit; }

echo $str | tr " " "\n" > omitfile

#seq -100000 100 1 | grep -vx -f omitfile | awk -v X=$X 'function abs(v){return v < 0 ? -v : v} {print $0,abs($0-X) }' | sort -k2,2n -k1,1n 


seq -200 101 | grep -vx -f omitfile | awk -v X=$X 'function abs(v){return v < 0 ? -v : v} {print $0,abs($0-X) }' | sort -k2,2n -k1,1n | head -1 | cut -d\  -f1


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

using namespace std;

int32_t gcdwrap(int32_t a, int32_t b, int32_t c)
{
    auto temp = gcd<int32_t, int32_t>(a, b);
    return gcd<int32_t, int32_t>(temp, c);
}

int main(void)
{
    int32_t sum = 0;
    int32_t N;
    cin >> N;

    for (size_t i = 1; i <= N; i++)
    {
        for (size_t j = 1; j <= N; j++)
        {
            for (size_t k = 1; k <= N; k++)
            {
                sum += gcdwrap(i, j, k);
            }
        }
    }

    cout << sum <<endl;
}


Measured memory_bytes: 3676
#include<stdio.h>
#include<math.h>

int status[1000000];

int main()
{
	int t, sq, i, j, count=0;

	while(scanf("%d",&t)!=EOF)
	{
	count=0;
	    
	sq=sqrt(t);

	for(i=0;i<=t;i+=2)
	{
	    status[i]=1;
	}
    status[1]=1;
    status[2]=0;
	for(i=3;i<=sq;i+=2)
	{
	    if(status[i]==0)
	    {
	        for(j=i*i;j<=t;j+=i)
    	    {
    	        status[j]=1;
    	    }
	    }
	}

	for(i=0;i<=t;i++)
	{
	    if(status[i]==0)
	    {
            count++;
	    }
	}

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

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

int main() {
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}


Measured memory_bytes: 3636
#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd

using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
	for (T x : s)
		cout << x << " ";
	cout << endl;
}

const int maxn = 1e5 + 7;

set<int> g[maxn];
int answer[maxn];
int s[maxn];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		g[a - 1].insert(b - 1);
		g[b - 1].insert(a - 1);
	}
	for (int i = 0; i < n; i++)
		cin >> s[i];
	sort(s, s + n);
	vector<int> q;
	for (int i = 0; i < n; i++)
		if (g[i].size() == 1)
			q.push_back(i);
	ll summa = 0;
	for (int i = 0; i < n; i++){
		int v = q[i];
		for (auto x : g[v]){
			g[x].erase(v);
			if (g[x].size() == 1)
				q.push_back(x);
		}
		answer[v] = s[i];
		if (i < n - 1)
			summa += s[i];
	}
	cout << summa << endl;
	for (int i = 0; i < n; i++)
		cout << answer[i] << " ";
	return 0;
}

Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();
		int a[] = new int[N];
		for(int i=0; i<N; i++) {
			a[i]=sc.nextInt();
		}
		int buf[] = new int[W];
		boolean forward = true;
		int c=0;
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				if(a[c]<=0)c++;
				if(forward) {
					buf[j]=c+1;
				}else {
					buf[W-1-j]=c+1;
				}
				a[c]--;
			}
			for(int j=0; j<W; j++) {
				System.out.print(buf[j] + (j==W-1 ? "\n" : " "));
			}
			forward=!forward;
		}
		sc.close();
	}

}


Measured memory_bytes: 32416
def resolve():
    n = int(input())

    ans = ''
    while n > 0:
        t = n % 26
        t = 26 if t == 0 else t
        ans = chr(t + 96) + ans
        n = (n - 1) // 26
    print(ans)


if 'unittest' not in globals():
    resolve()

Measured memory_bytes: 61696
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include <cassert>
#include<unordered_set>
using namespace std;

 
int main(){
    int n;
    cin >> n;
    vector<string> a(n+10);
     map<string, int> m;
    rep(i,n){
        cin >> a[i];
        auto itr = m.find(a[i]);     
            if( itr != m.end() ) {
                m[a[i]] -= 1;

    } else {
m.insert(make_pair(a[i], n));
    }
        
    }
    set<pair<int,string>> s;
        for(auto itr = m.begin(); itr != m.end(); ++itr) {
            s.insert(make_pair(itr->second, itr->first));
    }
    auto itr = s.begin();
    pair<int, string> buf;
    // buf = *itr;
    int bufnum = -1;
    // cout << endl;
    for(auto itr = s.begin(); itr != s.end(); ++itr) {
                buf = *itr;
                if(bufnum!=-1 && buf.first != bufnum) break;
                bufnum = buf.first;
                cout << buf.second << endl;
                // itr++;
                // buf = *itr;
    }
    // do{
    //     bufnum = buf.first;
    //     cout << buf.second << endl;
    //     itr++;
    //     buf = *itr;
    // }while(buf.first == bufnum);

}

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

B = list()
for i in range(len(A)):
    if A[i] % 2 == 0:
        B.append(A[i])

C = 0
for i in range(len(B)):
        if (B[i] % 3 == 0) or (B[i] % 5 == 0):
            C += 1 
    
if len(B) == C:
    print("APPROVED")
else :
    print("DENIED")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define MOD 1000000007
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> 
void __print(const pair<T, V> &x)
{
	cerr << '{'; __print(x.first);
	cerr << ','; __print(x.second);
	cerr << '}';
}

template<typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}

void _print()
{
	cerr << "]\n";
}

template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", "; _print(v...);
}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    

	int n;
	cin >> n;
	vector<int> old(3,0);

	for (int i=0;i<=n-1;i++)
	{
		vector<int> dp(3,0);
		for (int j=0;j<=2;j++)
		{
			cin >> dp[j];
			int a=0;
			for (int k=0;k<=2;k++)
			{
				if (j!=k)
				{
					a=max(a,dp[j]+old[k]);
				}
			}
			dp[j]=a;
		}
		old=dp;
	}

	//debug(old);
	sort(old.begin(),old.end());
	cout << *(old.end()-1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{   int a,b,c,d,sum;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    sum=0;
    if(a>b)
        sum=b;
    else
        sum=a;
    if(c>d)
        sum+=d;
    else
        sum+=c;
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    for (int t = x;; t++) {
        int b = 1;
        for (int i = 2; i * i <= x; i++) {
            if (t % i == 0) {
                b = 0;
                break;
            }
        }
        if (b) {
            cout << t << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> a(n),sum_a(n+1,0),sum_aplus(n+1,0);
    loop(i,n)cin >> a[i];
    rep(i,1,n+1)sum_a[i]=sum_a[i-1]+a[i-1];
    rep(i,1,n+1)sum_aplus[i]=sum_aplus[i-1]+max(0LL,a[i-1]);
    ll ans=0;
    loop(i,n-k+1){
        //i,i+1,...,i+k-1は同じ色で塗る
        ll tmp1=max(0LL,sum_a[i+k]-sum_a[i]);
        //0,...,i-1とi+k,...,n-1は任意の色で塗る
        ll tmp2=sum_aplus[i]+sum_aplus[n]-sum_aplus[i+k];
        ans=max(ans,tmp1+tmp2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int K,T,a,ma;
	cin>>K>>T;
	while(T--){
		cin>>a;
		ma=max(ma,a);
	}
	cout<<max(2*ma-K-1,0)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>

using namespace std;

int main() {

	int s[8];
	int d;
	char g[8];
	int kari;
	int l1,l2,l3,l4,l5,l6;


	cin >> d;

	for (int i = 0; i < d; i++) {
		cin >> g[0] >> g[1] >> g[2] >> g[3] >> g[4] >> g[5] >> g[6] >> g[7];

		for (int i = 0; i < 8; i++) {
			s[i] = g[i] - '0';
		}
		for (int i = 7; i > 0 ; i--) {
			for (int j = 0; j < i; j++) {
				if (s[j] > s[j+1]) {
					kari = s[j];
					s[j] = s[j+1];
					s[j+1] = kari;
				}
			}
		}

		l1 = s[0] * 1000 + s[1] * 100 + s[2] * 10 + s[3];
		l2 = s[4] * 1000 + s[5] * 100 + s[6] * 10 + s[7];
		l3 = s[7] * 1000 + s[6] * 100 + s[5] * 10 + s[4];
		l4 = s[3] * 1000 + s[2] * 100 + s[1] * 10 + s[0];

		l5 = l3 - l1;
		l6 = l4 - l2;

		if (l6 < 0) {
			l5--;
			l6 += 10000;
		}

		if (l5 >0) {
			cout << l5 << l6 << endl;
		} else {
			cout << l6 << endl;
		}
	}



	return 0;
}

Measured memory_bytes: 1160
import scala.annotation.tailrec

object Main extends App {
  import scala.io.StdIn._
  solve
  @tailrec def solve: Unit = {
    val Array(a, l) = readLine.trim.split(' ').map(_.toInt)
    if (l == 0) return
    var single = a
    var double = next(a, l)
    while (single != double){
      single = next(single, l)
      double = next(next(double, l), l)
    }
    var count = 1
    double = next(single, l)
    while(single != double){
      count += 1
      double = next(double, l)
    }
    double = a
    for (_ ← 0 until count){
      double = next(double, l)
    }
    var j = 0
    single = a
    while(single != double){
      j += 1
      single = next(single, l)
      double = next(double, l)
    }
    println(s"$j $single $count")
    solve
  }
  def next(number: Int, length: Int): Int = {
    val list = number.toList(length)
    list.sorted(Ordering[Int].reverse).toInt - list.sorted.toInt
  }
  implicit class ImplicitIntToList(private val number: Int) {
    def toList(length:Int): List[Int] = {
      toList(length, number)
    }
    private def toList(length: Int, number: Int, result: List[Int] = Nil): List[Int] = {
      length match{
        case 0 ⇒ result
        case _ ⇒ toList(length - 1, number / 10, number % 10 ::result)
      }
    }
  }
  implicit class ImplicitListToInt(private val list:List[Int]) {
    def toInt: Int = list.foldLeft(0){case (i, n) ⇒ i * 10 + n}
  }
}



Measured memory_bytes: 50452
#include "bits/stdc++.h"
using namespace std;

int main() {

	int N, L;
	cin >> N >> L;
	vector<string> vec(N);
	for (int i = 0; i < N; i++) cin >> vec.at(i);

	sort(vec.begin(), vec.end());

	string res;
	for (int i = 0; i < N; i++) res += vec.at(i);
	cout << res << endl;

	return 0;
}

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

int main(void){
  int a[3],d = 0,e = 0;
  for(int i = 0;i < 3;i++)cin >> a[i];
  for(int i = 0;i < 3;i++){
    if(a[i] == 5)d += 1;
    else if(a[i] == 7)e += 1;
  }
  if(d == 2 && e == 1)cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main(){
    ll r;
    cin >> r;
    ll ans = 3 * r * r;
    cout << ans << endl;


}

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

void solve(long long x) {
  if (x < 1200) cout << "ABC";
  else cout << "ARC";
  cout << endl;
}

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

  long long x;
  scanf("%lld", &x);
  solve(x);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a - (b < a) << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split())) 

l.sort()

ans = 0

for i in range(n):
    for j in range(0, i):
        for k in range(0, j):
            if (l[k] != l[j]) and (l[i] != l[j]) and (l[k] + l[j] > l[i]):
                ans += 1

print(ans)


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

vector<vector<int>> s;

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

  vector<int> k(m), p(m);
  s.resize(m);
  for(int i = 0; i < m; i++) {
    cin >> k[i];
    s[i].resize(k[i]);
    for(int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for(int i = 0; i < m; i++) cin >> p[i];

  int cnt = 0;
  for(int bit = 0; bit < (1 << n); bit++) { // 全スイッチの組み合わせ
    bool all_light = true;
    for(int bulb = 0; bulb < m; bulb++) { // 全電球が点灯するか確認
      bool light = true;
      int sw_cnt = 0;
      for(int sw = 0; sw < k[bulb]; sw++) { // 電球の点灯する条件を確認
        if(bit & (1 << s[bulb][sw]-1)) {
          sw_cnt++;
        }
      }
      //cout << bit << " " << bulb << " "  << sw_cnt << endl;
      if(sw_cnt%2 != p[bulb]) {
        all_light = false;
      }
    }
    if(all_light) {
      cnt++;
    }
  }

  cout << cnt << endl;
    
  return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    while(1){
        int n;
        double s, ave1, ave2, r, sum1 = 0, sum2 = 0;
        cin >> n;
        if(n == 0) break;
        for(int i = 0; i < n; i++){
            cin >> s;
            sum1 += s;
            sum2 += s*s;
        }
        ave1 = sum1 / n;
        ave2 = sum2 / n;
        r = sqrt(ave2-ave1*ave1);
        printf("%.8f\n", r);
    }
    return 0;
}


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

int main(){
    string S;  cin >> S;
    for(int i=0; i<8; i++){
        int tmp = i;
        int calc = S[0] - '0';
        string ans = S.substr(0, 1);
        for(int j=0; j<3; j++){
            if(tmp%2==0){
                calc += S[j+1] - '0';
                ans += "+" + S.substr(j+1, 1);
            } else {
                calc -= S[j+1] - '0';
                ans += "-" + S.substr(j+1, 1);
            }
            tmp /= 2;
        }
        // cout << ans << " " << calc << endl;
        if(calc == 7){
            cout << ans + "=7" << endl;
            return 0;
        }
    }
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    long long n;
    cin>>n;
    vector<long long>A(n);
    rep(i,n)cin>>A[i];

    //sort(A.begin(),A.end());
    //reverse(A.begin(),A.end());

    map<long long,int>mp;

    rep(i,n){
        if(mp.find(-A[i])==mp.end()){
            mp.emplace(make_pair(-A[i],1));
        }
        else{
            mp[-A[i]]++;
        }
    }
    auto it=mp.begin();
    long long ans=1;
    bool one=false;
    while(1){
        if(it==mp.end()){
            ans=0;
            break;
        }
        int cnt=it->second;

        if(cnt>=2){
            ans*=it->first;
            if(one)break;
            one=true;
        }
        if(cnt>=4){
            ans=it->first*it->first;
            break;
        }
        
        it++;
    }

    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 7296
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
bool judge(ll k,V vec,ll &a,ll &b){
    rep(i,vec.size()){
        vec[i] -= b*k;
    }
    sort(all(vec), greater<ll>());
    ll cnt = 0;
    rep(i,vec.size()){
        if(vec[i]<=0){
            break;
        }
        if(vec[i]%a==0){
            cnt += vec[i] / a;
        }else{
            cnt += vec[i] / a + 1;
        }
    }
    return cnt <= k;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,c;
    cin >> n >> c;
    vector<VP> vec(c);
    rep(i,n){
        ll s,t,c;
        cin >> s >> t >> c;
        c--;
        vec[c].push_back({s, t});
    }
    V res(1e5+1);
    rep(i,c){
        V temp(1e5+1);
        rep(j,vec[i].size()){
            rep3(k,vec[i][j].F,vec[i][j].S+1){
                temp[k] = 1;
            }
        }
        rep(i,1e5+1){
            if(temp[i]){
                res[i]++;
            }
        }
    }
    ll Res = 0;
    rep(i,1e5+1){
        chmax(Res, res[i]);
      //  cout<<res[i]<<" ";
    }
  //  cout<<endl;
    cout << Res << endl;
}


Measured memory_bytes: 4352
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var w = int.Parse(line[0]);
        var h = int.Parse(line[1]);
        var c = line[2][0];
        var a1 = '+' + new string('-', w - 2) + '+';
        var a2 = '|' + new string('.', w - 2) + '|';
        var z = (w - 3) / 2;
        var a3 = '|' + new string('.', z) + c + new string('.', z) + '|';
        Console.WriteLine(a1);
        for (int i = 0; i < (h - 3) / 2; i++) Console.WriteLine(a2);
        Console.WriteLine(a3);
        for (int i = 0; i < (h - 3) / 2; i++) Console.WriteLine(a2);
        Console.WriteLine(a1);
    }
}



Measured memory_bytes: 9000
#include <stdio.h>
//#include <stdlib.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int d, g;
  scanf("%d%d", &d, &g);
  int p[d], c[d], ans = 1001;
  for (int i=0; i<d; i++) scanf("%d%d", p+i, c+i);
  for (int i=0; i<(1<<d); i++) {
    int point = 0, cnt = 0;
    for (int j=0; j<d; j++) {
      if ((i & (1<<j)) != 0) {
        point += 100*(j+1)*p[j] + c[j];
        cnt += p[j];
      }
    }
    if (g<=point) ans = (ans > cnt) ? cnt : ans;
    else {
      int j=d-1;
      while (((1<<j) & i) != 0 && j>0) j--;
      if ((g-point-1)/(100*(j+1))+1 < p[j]) {
        cnt += (g-point-1)/(100*(j+1))+1;
        ans = (ans > cnt) ? cnt : ans;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
fn input() -> String {
    let mut buf = String::new(); //A
    std::io::stdin().read_line(&mut buf).unwrap(); //B
    buf.trim().to_string() //C
}

fn main() {
    let line = &input();
    let seg: Vec<i32> = line
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    time(seg);
    // println!("{:?}", seg);
}

fn time(line: Vec<i32>) {
    let h: i32 = line[0] / 3600;
    let m: i32 = line[0] % 3600 / 60;
    let s: i32 = line[0] % 60;
    println!("{}:{}:{}", h, m, s);
}


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

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

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

  sort(a.begin(),a.end());
  int answer = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if(a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) continue;

        if(a[i] + a[j] > a[k]) answer ++;
      }
    }
  }

  cout << answer << '\n';

}

Measured memory_bytes: 3664
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n;
int t[20][20];
int dp[1 << 20];

int main() {
	while (cin >> n&&n) {
		REP(i, (1 << 20))dp[i] = HINF<int>();
		dp[0] = 0;
		REP(i, n) {
			REP(j, n + 1) {
				cin >> t[i][j];
			}
		}
		REP(i, (1 << n)) {
			REP(j, n) {
				if (!(i&(1 << j))) {
					int v = t[j][0];
					REP(k, n)if (i&(1 << k))v = min(v, t[j][k + 1]);
					dp[i + (1 << j)] = min(dp[i + (1 << j)], dp[i] + v);
				}
			}
		}
		cout << dp[(1 << n) - 1] << endl;
	}
}


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

import sys

N,P = map(int, raw_input().split())
a = map(int, raw_input().split())

count_0 = 0
count_1 = 0
number = 0

def comb(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= numerator[k]
    return result

for i in range(N):
    if a[i] % 2 == 0:
        count_0 += 1
    else:
        count_1 += 1


if P == 0:
    if count_1 == 0:
        number = 1
    else:
        for j in range(count_1 /2 +1):
            number += comb(count_1,2*j)
else:
    if count_1 != 0:
        if count_1 % 2 == 0:
            for j in range(1,count_1 / 2 + 1):
                number += comb(count_1,2*j - 1)
        else:
            for j in range(1,count_1/2 + 2):
                number += comb(count_1, 2*j - 1)

if number != 0:
    print number * (2**count_0)
else:
    print number


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

using namespace std;

struct die_t {
	int top, front, right, left, back, bottom;

	die_t (int t, int f, int r, int l, int bk, int b)
		: top(t), front(f), right(r), left(l), back(bk), bottom(b) { }
	void rotate_swap ( int &a, int &b, int &c, int &d ) {
		swap(a, b); swap(b, c); swap(c, d);
	}
	void rotate_right( void ) { rotate_swap(top,left,bottom,right); }
	void rotate_left( void ) { rotate_swap(top,right,bottom,left); }
	void rotate_front( void ) { rotate_swap(top,back,bottom,front); }
	void rotate_back( void ) { rotate_swap(top,front,bottom,back); }
	void rotate_cw( void ) { rotate_swap(back,left,front,right); }
	void rotate_ccw( void ) { rotate_swap(back,right,front,left); }
};

int main ( void )
{
	int n;

	while (cin >> n, n) {
		die_t d(1, 2, 3, 4, 5, 6);
		int sum = 1;
		for (int i = 0; i < n; ++i) {
			string str;
			cin >> str;

			switch (str[0]) {
				case 'N': d.rotate_back(); break;
				case 'E': d.rotate_right(); break;
				case 'W': d.rotate_left(); break;
				case 'S': d.rotate_front(); break;
				case 'R': d.rotate_cw(); break;
				case 'L': d.rotate_ccw(); break;
			}

			sum += d.top;
		}

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

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char[] rp = s.toCharArray();
		int paper = 0;
		int rock = 0;
		int win = 0;
		int lose = 0;
		int turn = 0;
		while(turn<rp.length){
			if (rp[turn]=='g'){
				if (paper<rock){
					paper++;
					win++;
				}
				else{
					rock++;
				}
			}
			else if (rp[turn]=='p'){
				if (paper<rock){
					paper++;
				}
				else{
					rock++;
					lose++;
				}
			}
			turn++;
		}
		System.out.println(win-lose);
	}

}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int A=c/b;
  int B=a/d;
   if(c%b)
    A++;
   if(a%d)
     B++;
  
  if(A<=B)
     cout<<"Yes\n";
  else
    cout<<"No\n";
 return 0; 
}

Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 1000
#define mod 1000000007

int main(){
    int n,m;
    cin>>n>>m;
    char arr[n][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>arr[i][j];
        }
    }

    ll dp[MAX][MAX];
    memset(dp, 0, sizeof(dp));
    
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(arr[i][j] == '#'){
                dp[i][j]=0;
                continue;
            }
            if(i==0 && j==0){
                dp[i][j]=1;
            }
            if(i>0) dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;
            if(j>0) dp[i][j] = (dp[i][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[n-1][m-1]<<endl;
    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
int knapSack(int W,int wt[],ll val[],int n) { 
   int i,w; 
   ll K[n+1][W+1]; 
   for(i=0;i<=n;i++){ 
       for(w=0;w<=W;w++){ 
           if (i==0||w==0) 
               K[i][w]=0; 
           else if(wt[i-1]<=w) {
           		if(val[i-1]+K[i-1][w-wt[i-1]]>K[i-1][w])
           			K[i][w]=val[i-1]+K[i-1][w-wt[i-1]];
     	      	else
        	   		K[i][w]=K[i-1][w];
        	}
           else
                K[i][w] = K[i-1][w]; 
        //	cout<<K[i][w]<<endl;
       } 
   } 
	cout<<K[n][W];
} 
void solve(){
	int n,W;
	cin>>n>>W;
	ll v[n];
   	int w[n];
   	rep(i,0,n){
   		cin>>w[i]>>v[i];
	}
   	knapSack(W,w,v,n);
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


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

int countSeat(int l, int r)
{
  return r-l+1;
}

int main()
{
  int N;  // 団体数N
  cin>>N;

  vector<int> l(N);
  vector<int>r(N);
  for(int i=0; i<N; i++)
    cin>>l[i]>>r[i];

  int count = 0;
  for(int i=0; i<N; i++)
    count += countSeat(l[i], r[i]);

  cout<<count<<endl;

  return 0;
}


Measured memory_bytes: 256
main = getContents >>= print.f.map read.words
f[q,h,s,d,n]
    | even n = div n 2 * y
    | otherwise = min (n * x) $ x + div n 2 * y
  where
    x = minimum xs
    y = minimum ys
    xs = [4*q, 2*h, s]
    ys = [8*q, 4*h, 2*s, d]

Measured memory_bytes: 508
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>

#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;

int main()
{
    ll n,ans=0;
    sf(n);
    for(ll i=0;i<n;i++)
    {
      ll x;
      sf(x);
      ans+=x;
    }
    ans-=n;
    pf(ans);
}

Measured memory_bytes: 3224
#include "bits/stdc++.h"
#include <queue>

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;



void solve() {
	int a, b;
	cin >> a >> b;

	if (a <= b)
		cout << a << endl;
	else
		cout << a - 1 << endl;
}


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

	solve(); 
	return 0;
}

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


using namespace std;

int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    int A=abs(a-x);
    int B=abs(b-x);
    if(B<=A)
        puts("B");
    else
        puts("A");
    return 0;
}


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

int main() {
    long long x, k, d, p;
    cin >> x >> k >> d;

    x = abs(x);
    if (x/d >= k) cout << x-k*d << endl;
    else { 
        k = k - (x/d);
        if (k%2 == 0) cout << x%d << endl;
        else cout << d-x%d << endl;
    }
}


Measured memory_bytes: 3628