akhauriyash/Code-Regression huggingface dataset:
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
//M, A, R, C or H.
ll arr[1233];
int main(){
    std::ios::sync_with_stdio(false);
    int n,i,j,k;
    cin>>n;
    ll tot=0,ans1,ans,ans2;
    string s;
    set<int> seti;
    rep(i,n){
    	cin>>s;
    	arr[s[0]]++;
    }
    s="MARCH";
    rep(i,s.length()){
    	seti.insert((int)s[i]);
    }
    //seti.insert(int('M'));
    rep(i,1000){
    	if(seti.find(i)==seti.end())
    		continue;
    	ans=arr[i];
    	f(j,i+1,1000){
    		if(seti.find(j)==seti.end())
    			continue;
    		ans1=arr[j]*ans;
    		f(k,j+1,1000){
    			if(seti.find(k)==seti.end())
    				continue;
    			ans2=ans1*arr[k];
    			tot+=ans2;
    		}
    	}
    }
    cout<<tot<<endl;
    return 0;  
    
}



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

using namespace std;

int main() {
  int n; scanf("%d", &n);
  vector<int> a(n);
#ifdef DEBUG
  for(int i = 0; i < n; i++) {
    a.push_back(i+1);
    reverse(a.begin(), a.end());
  }
  for(int i = 0; i < n; i++) {
    if(i > 0) cout << " ";
    cout << a[i];
  }
#endif
  for(int i = 0; i < n; i++) cin>>a[i];
  for(int i = n-1; i >= 0; i-=2) {
    if(i != n-1) cout << " ";
    cout << a[i];
  }
  for(int i = n%2; i < n; i += 2) {
    cout << " " << a[i];
  }
  cout << endl;

  return 0;


}


Measured memory_bytes: 3072
from math import radians, sin, cos

a, b, C = [int(i) for i in input().split()]
t = radians(C)

s = 0.5 * a * b * sin(t)
c2 = a * a + b * b - 2 * a * b * cos(t)
l = a + b + c2**0.5
h = b * sin(t)

print(s)
print(l)
print(h)


Measured memory_bytes: 5732
n = int(input())
s_list = [input() for i in range(n)]

m = {}
for s in s_list:
  if s in m:
    m[s] += 1
  else:
    m[s] = 1

ans = []
maxi = 0
for k, v in m.items():
  if v > maxi:
    ans.clear()
    maxi = v
  elif v < maxi:
    continue
  ans.append(k)

ans.sort()

for a in ans:
  print(a)



Measured memory_bytes: 35220
S=input()
T=input()

ls=len(S)
lt=len(T)
commons=[]

for i in range(ls-lt+1):
    x=S[i:i+lt]
    count=0
    for j in range(lt):
        if x[j]==T[j]:
            count+=1
    commons.append(lt-count)
    
print(min(commons))

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

long long int n,W,i,j,weight[1005],val[1005],mat[105][100005];

int main()
{
    cin>>n>>W;
    for(i=0;i<n;i++)
    {
        cin>>weight[i]>>val[i];
    }
    for(i=0;i<=W;i++)
    mat[0][i] = 0;
    for(i=0;i<=n;i++)
    mat[i][0] = 0;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=W;j++)
        {
            if(weight[i-1]<=j)
            {
                mat[i][j] = max(mat[i-1][j],val[i-1]+mat[i-1][j-weight[i-1]]);
            }
            else
            {
                mat[i][j] = mat[i-1][j];
            }
        }
    }
    cout<<mat[n][W]<<endl;
}

Measured memory_bytes: 80128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}	
char mem[214514];
char t[214514];
char c[214514];
string s[214514];
int el[314514],wl[314514];
int er[314514],wr[314514];
signed main(){
	ic(n)
	sc(s)
	int e=0,w=0;
	rep(0,i,n){
		if(s[i]=='E')e++;
		else w++;
	}
	int ecnt=0,wcnt=0;
	rep(0,i,n){
		el[i]=ecnt;
		wl[i]=wcnt;
		if(s[i]=='E')ecnt++;
		else wcnt++;	
		er[i]=e-ecnt;
		wr[i]=w-wcnt;
	}
	int ans=314514;
	rep(0,i,n)if(wl[i]+er[i]<ans)ans=wl[i]+er[i];
	c(ans)
}			
			
			


Measured memory_bytes: 12164
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
a,b,c = LI()
if a <= c <= b:
    print("Yes")
else:
    print("No")
#B

#C

#D
"""
def bellman_ford(start):
    dist = [float("inf") for i in range(n)]
    dist[start] = 0
    for i in range(n-1):
        update = False
        for j, k, l in adj:
                if dist[k] > dist[j] + l:
                    dist[k] = dist[j] + l
                    update = True
        if not update:
            break
    negative = [False for i in range(n)]
    for j, k, l in adj:
        if dist[k] > dist[j] + l:
            dist[k] = dist[j] + l
            negative[k] = True
    return dist,negative[n-1]
n,m = LI()
adj = []
for i in range(m):
    a,b,c = LI()
    a -= 1
    b -= 1
    adj.append([a,b,-c])
d,ne = bellman_ford(0)
if ne:
    print("inf")
else:
    print(-d[-1])
"""

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define ull signed long long

int main (){
  ull N, K;
  cin >> N >> K;
  ull A[N];
  for (ull i = 0; i < N; ++i) {
    cin >> A[i];
  }

  sort (A, A + N);
  ull sum = 0;
  for (ull i = 0; i < N - K; ++i) {
    sum += A[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<String>();
    let answer = if n == "Sunny" {
        "Cloudy"
    } else if n == "Cloudy" {
        "Rainy"
    } else {
        "Sunny"
    };


    println!("{}", answer);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 3000 + 1000;

int n, a[MAXN];
vector<int> edg[MAXN];

bool dfs(int x, int fa)
{
	for(int i = 0; i < edg[x].size(); i++)
		if(edg[x][i] != fa)
		{
			int y = edg[x][i];
			if(a[y] < a[x] && !dfs(y, x))
				return true;
		}
	return false;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n - 1; i++)
	{
		int x, y;
		cin >> x >> y;
		edg[x].push_back(y), edg[y].push_back(x);
	}
	for(int i = 1; i <= n; i++)
		if(dfs(i, 0))
			cout << i << ' ';
	cout << endl;

	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define FORL(n) for(long long int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRF(f) printf("%.10lf\n",f)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll a[26];
int main(void){
  ll n;
  scanf("%lld",&n);
  char s[n+1],t[n+1];
  scanf("%s %s",s,t);
  a[s[0]-'a']=1;
  for(ll i=1;i<n-1;i++){
    a[s[i]-'a']+=a[t[i]-'a'];
    a[s[i]-'a']%=mod;
  }
  PRL(a[t[n-1]-'a']);
  return 0;
}



Measured memory_bytes: 2132
#include<stdio.h>
int main(void)
{
	int a,b,c,cnt,x;
	cnt=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d\n",&c);
	for(x=a;x<=b;x++)
	{
		if(c%x==0){
			cnt++;
		}else{
		}
	}
	printf("%d\n",cnt);
	return 0;
}
		

Measured memory_bytes: 600
#include <algorithm>
#include <array>
#include <complex>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

inline bool valid(const int x, const int r) { return 0 <= x && x < r; }

void initIOStream() {
  ios::sync_with_stdio(false); // stdin????????¨???????????????
  cin.tie(0); // cin?????????flush?????????
  cout.setf(ios::fixed);
  cout.precision(10); // ?????¨?????\?????????????????°??¨???
}

const int MAX_V = 20;

vector<int> ans;
vector<int> G[MAX_V];
bool vis[MAX_V];
int ind[MAX_V];

void dfs(int p){
  vis[p] = true;
  for(size_t i = 0, size = G[p].size(); i < size; ++i) {
    const auto& j = G[p][i];
    if(!vis[j]){
      dfs(j);
    }
  }
  ans.push_back(p);
}

int main() {
  initIOStream();

  int m, n;
  cin >> m >> n;
  memset(ind, 0, sizeof(ind));
  for(int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    G[b - 1].push_back(a - 1);
    ++ind[a - 1];
  }
  memset(vis, 0, sizeof(vis));
  for(int i = 0; i < m; ++i) {
    if(ind[i] == 0 && !vis[i]){
      dfs(i);
    }
  }
  for(auto x : ans){
    cout << x + 1 << endl;
  }
}

Measured memory_bytes: 1216
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 25 21:09:40 2020

@author: NEC-PCuser
"""

N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N - K):
    if A[i] < A[i + K]:
        print("Yes")
    else:
        print("No")

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  bool f = false;
  rep(i, n) {
    int a;
    cin >> a;
    f |= (a % 2);
  }
  cout << (f ? "first" : "second") << endl;
}


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

int main(){
    std::string s;
    int a = 0;
    int b = 0;
    int ans;

    std::cin >> s;

    while(1){
        if(s[a] == 'A'){
            break;
        }
        a++;
    }

    while(1){
        if(s[s.size() - b] == 'Z'){
            break;
        }
        b++;
    }
    ans = (s.size() - b) - a + 1;

    std::cout << ans << std::endl;

    return 0;    
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e'|| c == 'o') {
      printf("vowel");
  }
  else printf("consonant");

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

// ?????????????´???????????????????
void trace(int arr[], int n) {
	int i;
	for (i = 0; i < n; i++) {
		// ??£??\????????????????????????????????????????????????
		if (i > 0) printf(" ");
		printf("%d", arr[i]);
	}
	printf("\n");
}

// ?????\?????????
void insertionSort(int arr[], int n) {
	int index, beforeIndex, target;
	for (index = 1; index < n; index++) {
		target = arr[index];
		beforeIndex = index - 1;
		while (beforeIndex >= 0 && arr[beforeIndex] > target) {
		    arr[beforeIndex + 1] = arr[beforeIndex];
		    beforeIndex--;
		}
		arr[beforeIndex + 1] = target;
		trace(arr, n);
	}
}

int main() {
	int n, i, j;
	int arr[100];

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

	trace(arr, n);
	insertionSort(arr, n);

	return 0;
}

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

using namespace std;

int n, a[201], ans;

int main() {
    scanf("%d", &n); n <<= 1; 
    for(int i = 1;i <= n; ++i)
        scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    for(int i = 1;i <= n; i += 2)
        ans += a[i];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
set<string>s[5];
int main(void)
{
    long long n;
    cin>>n;
    string x;
    long long a,b,c,d,e;
    for(long long i=0;i<n;++i)
    {
        cin>>x;
        if(x[0]=='M')
        {
            s[0].insert(x);
        }
        if(x[0]=='A')
        {
            s[1].insert(x);
        }
        if(x[0]=='R')
        {
            s[2].insert(x);
        }
        if(x[0]=='C')
        {
            s[3].insert(x);
        }
        if(x[0]=='H')
        {
            s[4].insert(x);
        }
    }
    a=s[0].size();
    b=s[1].size();
    c=s[2].size();
    d=s[3].size();
    e=s[4].size();
    cout <<a*b*c+
         a*b*d+
         a*b*e+
         a*c*d+
         a*c*e+
         a*d*e+
         b*c*d+
         b*c*e+
         b*d*e+
         c*d*e<<endl;
    return 0;
}


Measured memory_bytes: 9600
# -*- coding: utf-8 -*-
import random

H, W = map(int, input().split())

A = []
for i in range(H):
    for c in list(input()):
        A.append(c)

dict = {}
for a in A:
    if a in dict:
        dict[a] += 1
    else:
        dict[a] = 1


if H % 2 != 0 and W % 2 != 0:
    g1 = 1
    g2 = int(H//2) + int(W//2)
    g3 = int(H//2) * int(W//2)
else:
    g1 = 0
    if H % 2 == 0 and W % 2 == 0:
        g2 = 0
    else:
        if H % 2 == 0:
            g2 = int(H//2)
        else:
            g2 = int(W//2)
    g3 = int((H * W - g1 - g2 * 2) // 4)

for _ in range(g1):
    stack = []
    for c in dict:
        if dict[c] % 4 == 1 or dict[c] % 4 == 3:
            stack.append(c)
    if len(stack) > 1:
        x = stack.pop(random.randint(0, len(stack)-1))
        dict[x] -= 1
    elif len(stack) == 1:
        dict[stack[0]] -= 1
    else:
        pass


for _ in range(g2):
    stack = []
    for c in dict:
        if dict[c] % 4 == 2:
            stack.append(c)
    if len(stack) > 1:
        x = stack.pop(random.randint(0, len(stack)-1))
        dict[x] -= 2
    elif len(stack) == 1:
        dict[stack[0]] -= 2
    else:
        pass


for _ in range(g3):
    stack = []
    for c in dict:
        if dict[c] % 4 == 0 and dict[c] != 0:
            stack.append(c)
    if len(stack) > 1:
        x = stack.pop(random.randint(0, len(stack)-1))
        dict[x] -= 4
    elif len(stack) == 1:
        dict[stack[0]] -= 4
    else:
        pass

count = 0
for c in dict:
    if dict[c] % 4 != 0:
        count += 1
if count == 0:
    print('Yes')
else:
    print('No')

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;

class node{
public:
    node(){
        key = 0;
        parent = NULL;
        left = NULL;
        right = NULL;
    }

    node(int i, node* p, node* l, node* r){
        key = i;
        parent = p;
        left = l;
        right = r;
    }

    int key;
    node* parent;
    node* left;
    node* right;
};

node* root = NULL;

void pre_search(node* v){
    cout << " " << v->key;
    if(v->left != NULL)
        pre_search(v->left);
    if(v->right != NULL)
        pre_search(v->right);
    return;
}

void in_search(node* v){
    if(v->left != NULL)
        in_search(v->left);
    cout << " " << v->key;
    if(v->right != NULL)
        in_search(v->right);
    return;
}

void insert(int key){
    if(root == NULL){
        root = new node(key, NULL, NULL, NULL);
        return;
    }
    node* y = NULL;
    node* x = root;
    while(x != NULL){
        y = x;
        if(key < x->key)
            x = x->left;
        else
            x = x->right;
    }
    node* add = new node(key, y, NULL, NULL);
    if(key < y->key)
        y->left = add;
    else
        y->right = add;
    return;
}

int main() {
    int k;
    string order;
    int num;
    cin >> k;
    REP(i, k){
        cin >> order;
        if(order == "insert"){
            cin >> num;
            insert(num);
        } else if (order == "print"){
            in_search(root);
            cout << endl;
            pre_search(root);
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24656
# ABC121B

import numpy as np
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [0] * n
for i in range(n):
    a[i] = list(map(int, input().split()))
a = np.array(a)
b = np.array(b)
print(sum(np.dot(a, b) +c > 0))


Measured memory_bytes: 12420
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, T; cin >> N >> T;
  int A[N]; rep(i,N) cin >> A[i];

  int m[N] = {};
  for(int i=N-1; i>=0; i--) {
    if (i==N-1) m[i] = A[i];
    else m[i] = max(m[i+1],A[i]);
  }

  int result = 0, diff = 1;
  rep(i,N) {
    if (m[i]-A[i]==diff) result++;
    else if (m[i]-A[i]>diff) { diff = m[i]-A[i]; result=1; }
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
from bisect import bisect


def main():
    N, M = map(int, input().split())
    PY = [[int(j) for j in input().split()] for i in range(M)]

    a = collections.defaultdict(list)
    for x, y in sorted(PY):
        a[x] += [y]

    for x, y in PY:
        z = bisect(a[x], y)
        print("%06d%06d" % (x, z))


if __name__ == "__main__":
    main()


Measured memory_bytes: 41028
import sys
import time
import copy

N = int(input())
b = [int(b) for b in input().split()]
h = {}

t1 = time.time()

def f(b):
  t2 = time.time()
  if t2 - t1 > 1.5:
    print(-1)
    sys.exit()
  
  key = "".join([str(x) for x in b])
  if key in h:
    return copy.copy(h[key])
  
  if len(b) == 1:
    h[key] = b if b[0] == 1 else []
    return copy.copy(h[key])
  
  for i in range(len(b)):
    i = len(b) - 1 - i
    if b[i] == i + 1:
      b_sub = copy.copy(b)
      b_i = b_sub.pop(i)
      a = f(b_sub)
      if len(a) != 0:
        a.append(b_i)
        h[key] = a
        return copy.copy(h[key])
  
  h[key] = []
  return copy.copy(h[key])

a = f(b)
if len(a) == 0:
  print(-1)
else:
  for i in range(N):
    print(a[i])

Measured memory_bytes: 44936
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll n,ans=0ll;

void dfs(ll x, int c){
	if(x<=n){
		if(c==7){
			++ans;
		}
		dfs(x*10+3,(c|1));
		dfs(x*10+5,(c|2));
		dfs(x*10+7,(c|4));
	}
}

int main(void){
	cin >> n;
	dfs(0ll,0);
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666;
int n,m,T,A[N],B[N];char s[N];
namespace one{
bool ok[N];
bitset<50005>f[50005],ans;
void solve(){
	rep(i,1,n)f[i][i]=1;
	per(i,m,1){
		f[A[i]]|=f[B[i]];f[B[i]]=f[A[i]];
	}
	ans=f[1];rep(i,1,n)ans&=f[i];
	if(!ans.count()){puts("-1");return;}
	ok[ans._Find_first()]=1;
	per(i,m,1){
		if(ok[A[i]]&&!ok[B[i]]){
			s[i]='^';ok[B[i]]=1;
		}
		else if(!ok[A[i]]&&ok[B[i]]){
			s[i]='v';ok[A[i]]=1;
		}
	}
	rep(i,1,m)printf("%c",s[i]);puts("");
}
}
namespace two{
	set<int>Set[N];
	bool f[455][455],a[101000][455],b[101000][455];
	void ckans(){
		static bool f[N];
		rep(i,1,n)f[i]=1;
		rep(i,1,m)
			if(s[i]=='v'){
				if(f[A[i]])f[A[i]]=0,f[B[i]]=1;
			}
			else{
				if(f[B[i]])f[B[i]]=0,f[A[i]]=1;
			}
		int cnt=0;rep(i,1,n)cnt+=f[i];assert(cnt>=2);
	}
	void solve(){
		rep(i,1,m)Set[A[i]].insert(B[i]),Set[B[i]].insert(A[i]);
		rep(i,1,n)rep(j,i+1,n)if(!Set[i].count(j)){
			rep(k,1,m){
				bool a=A[k]==i||A[k]==j,b=B[k]==i||B[k]==j;
				if(!a&&b)s[k]='v';
				if(a&&!b)s[k]='^';
			}
			rep(i,1,m)printf("%c",s[i]);puts("");return;
		}
		rep(i,1,n)rep(j,1,n)if(i!=j)f[i][j]=1;
		rep(j,1,m){
			rep(i,1,n)a[j][i]=f[i][A[j]],b[j][i]=f[i][B[j]];
			f[A[j]][B[j]]=f[B[j]][A[j]]=0;
			rep(i,1,n)if(i!=A[j]&&i!=B[j]){
				f[A[j]][i]=f[i][A[j]]=f[B[j]][i]=f[i][B[j]]=f[A[j]][i]|f[B[j]][i];
			}
		}
		int x=0,y=0;
		rep(i,1,n)rep(j,i+1,n)if(f[i][j])x=i,y=j;
		if(!x&&!y){puts("-1");return;}
		per(j,m,1){
		//	printf("qwq %d %d\n",x,y);
			if(A[j]==x||A[j]==y){
				if(A[j]==y)swap(x,y);s[j]='^';
				if(!a[j][y])x=B[j],assert(b[j][y]);
			}
			else if(B[j]==x||B[j]==y){
				if(B[j]==y)swap(x,y);s[j]='v';
				if(!b[j][y])x=A[j],assert(a[j][y]);
			}
			assert(x!=y);
		}
		rep(i,1,m)printf("%c",s[i]);puts("");return;
	}
}
int main() {
	read(n);read(m);read(T);
	rep(i,1,m)read(A[i]),read(B[i]),s[i]='^';
	if(T==1){one::solve();return 0;}
	if(T==2){two::solve();return 0;}
	return 0;
}


Measured memory_bytes: 322176
N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  M[0],M[1]=M[1],M[0]
  task.append(M)
task.sort()
K = 0
ans = 1
for i in range(N):
  K += task[i][1]
  if (K>task[i][0]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")
  

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

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];
    ll ans = 0;
    for (int i = 1; i <= N-1; i++) ans += min(A*(X[i]-X[i-1]), B);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> LP;
typedef double db;
using namespace std;
ll mod = 1000000007;
ll kaijo[201];
ll P[201][201];
ll mp[201][100001];

ll N;
ll S[201],X;




inline ll f(ll n, ll k){
  if(k==0) return 0;
  if(n==0) return k;
  if(n==1) return k%S[0];
  if(mp[n][k] != -1) return mp[n][k];
  ll res = 0;
  ll _n = upper_bound(S, S+n, k) - S;
  ll ext = n - _n;
  if(_n == 0) return mp[n][k]=(k*kaijo[n])%mod;
  if(ext != 0){
    res = (res + ext * f(n-1, k))% mod;
  }
  rep(i, _n){
    res = (res + (f(i, k%S[i]) * P[n-1][n-1 - i])%mod ) % mod;
  }
  return mp[n][k]=res;
}


// ll f(ll n, ll k){
//   ll res = f1(n,k);
//   // cout<<n<<" "<<k<<" "<<res<<endl;
//   // cout>>n>>" ">>k>>" ">>res>>endl;
//   return res;
// }

int main(){
  kaijo[0]=1;
  rep1(i,200){
    kaijo[i]=(kaijo[i-1]*i)%mod;
  }
  P[0][0] = 1;
  rep1(i,200){
    P[i][0] = 1;
    rep1(j,i){
      P[i][j] = (P[i][j-1] * (i - j + 1)) % mod;
    }
  }
  cin>>N>>X;
  rep(i,N+1) rep(j,X+1) mp[i][j]=-1;
  rep(i,N) cin>>S[i];
  sort(S, S+N);
  cout<<f(N, X)<<endl;
}


Measured memory_bytes: 157696
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    vl = list(map(int, input().split()))

    vl.sort()

    ans = (vl[0] + vl[1]) / 2
    for v in vl[2:]:
        ans = (ans + v) / 2

    print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll h,a,ans=0;
    cin >> h >> a;
    ans=h/a;
    if (h%a!=0)ans++;
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int num = stdin.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < num; i++) {
			list.add(stdin.nextInt());
		}

		Collections.sort(list);
		Collections.reverse(list);
		int sumA = 0;
		int sumB = 0;
		for (int i = 0; i < list.size(); i += 2) {
			sumA += list.get(i);
		}
		for (int i = 1; i < list.size(); i += 2) {
			sumB += list.get(i);
		}

		System.out.println(sumA - sumB);
	}

}


Measured memory_bytes: 23764
using System;
using System.Linq;
using System.Collections.Generic;
class AC
{
    static void Main(string[] args)
    {
        var S = Cin.Int();
        const int mod = 1000000007;
        var dp = new long[S + 1];
        dp[0] = 1;
        for(var i = 3; i <= S; i++)
        {
            dp[i] = dp[i - 1] + dp[i - 3];
            dp[i] %= mod;
        }
        Console.WriteLine(dp[S]);
    }
}
static class Cin
{
    public static string Str() => Console.ReadLine();
    public static int Int() => int.Parse(Cin.Str());
    public static long Long() => long.Parse(Cin.Str());
    public static double Double() => double.Parse(Cin.Str());

    private static T Conv<T>(string value) => (T)Convert.ChangeType(value, typeof(T));
    public static (T, U) ReadTuple<T, U>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]));
    public static (T, U, V) ReadTuple<T, U, V>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]));
    public static (T, U, V, W) ReadTuple<T, U, V, W>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]), Conv<W>(input[3]));
    public static (T, U, V, W, X) ReadTuple<T, U, V, W, X>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]), Conv<W>(input[3]), Conv<X>(input[4]));

    public static (T, U) Input<T, U>() => ReadTuple<T, U>(ReadSplit());
    public static (T, U, V) Input<T, U, V>() => ReadTuple<T, U, V>(ReadSplit());
    public static (T, U, V, W) Input<T, U, V, W>() => ReadTuple<T, U, V, W>(ReadSplit());
    public static (T, U, V, W, X) Input<T, U, V, W, X>() => ReadTuple<T, U, V, W, X>(ReadSplit());

    public static string[] ReadSplit() => Console.ReadLine().Split();
    public static string[] ReadSplit(char separator) => Console.ReadLine().Split(separator);
    public static int[] ReadSplitInt() => Array.ConvertAll(ReadSplit(), int.Parse);
    public static long[] ReadSplitLong() => Array.ConvertAll(ReadSplit(), long.Parse);
    public static double[] ReadSplit_Double() => Array.ConvertAll(ReadSplit(), double.Parse);
}


Measured memory_bytes: 27424
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        for (double i=1; i<50000; i++){
            double tmp = i*1.08;
            if ((int)tmp==n){
                System.out.println((int)i);
                return;
            }
        }
        System.out.println(":(\n");
        return;

    }
}

Measured memory_bytes: 21588
def calcdp(i, s):
    # i番目の男性まで評価しときに、女性のマッチング状態がsとなる組み合わせの数
    global dp, MOD, N, A
    if dp[i][s] != -1:
        return dp[i][s]
    
    r = 0
    for j in range(N):
        if A[i-1][j] and s & (1 << j):
            r += calcdp(i - 1, s ^ (1 << j))
    
    dp[i][s] = r = r % MOD
    return r


N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]
MOD = 10**9 + 7

dp = [[-1] * 2**N for _ in range(N+1)]
dp[0][0] = 1

print(calcdp(N, 2**N-1))


                

Measured memory_bytes: 398600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 string s;
 cin>>s;
 for(ll i=0;i<s.size();i++)if( s[i] == '?' ) cout<<'D';
 else cout<<s[i];
 cout<<endl;
    return 0;
}


Measured memory_bytes: 3756
# シカのAtCoDeerくんは二つの正整数 a, b を見つけました。
# a と b の積が偶数か奇数か判定してください。

# 標準入力から整数 a, b を取得する
a, b = map(int, input().split())

# a と b の積が奇数か否かを判定し、結果を出力する
input_product_num = a * b

result = 'Odd'
if (input_product_num % 2) == 0:
    result = 'Even'

print(result)


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,h,w; cin>>n>>h>>w;
	cout<<(n-h+1)*(n-w+1)<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace UI
{
    class ほあたては元気な子
    {
        static void Main(string[] args)
        {//樹乱れ？
            int[] x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            string s = Console.ReadLine();
            int a = x[1] + x[2];
////しね
            for (int i = 0; i < x[0]; i++)
            {
                if (a > 0)
                {
                    switch (s[i])
                    {
                        case ('a'):
                            {
                                Console.WriteLine("Yes");
                                a--;
                                break;
                            }
                        case ('b'):
                            {
                                if (x[2] > 0)
                                {
                                    Console.WriteLine("Yes");
                                    a--;
                                    x[2]--;
                                }
                                else
                                {
                                    Console.WriteLine("No");
                                }
                                break;
                            }
                        default:
                            {
                                Console.WriteLine("No");
                                break;
                            }
                    }
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }
}

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

 
vector<ll> w,v;
ll dp[109][100009];
 
ll maxi(ll n, ll W)
{
    if(n<0 || W<=0)
        return 0;      
    if(dp[n][W]!=-1)
        return dp[n][W];
    if(w[n]>W)
        dp[n][W]=maxi(n-1,W);
    else
        dp[n][W] = max(maxi(n-1,W),maxi(n-1,W-w[n])+v[n]);
    return dp[n][W];
}
 
int main()
{
    ll N,W,a,b,i,j;
    cin>>N>>W;
    for(i=0;i<N;i++)
    {
        cin>>a>>b;
        w.push_back(a);
        v.push_back(b);
    }
    for(i=0;i<N;i++)
        for(j=0;j<=W;j++)
        {
            dp[i][j]=-1;
        }
    maxi(N-1,W);
    cout<<dp[N-1][W];
}

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

int main(void){
    string s;
    cin >> s;
    int n = s.length() - 2;
    for(;n>=2;n-=2){
        bool b = true;
        for(int i=0;i<n/2;i++){
            if(s[i] != s[n/2+i]){
                b = false;
                break;
            }
        }

        if(b) {
            cout << n << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int x = sc.nextInt();
		sc.close();
		
		// 結果の出力
		System.out.println(x == 0? 1 : 0);
	}
}


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

void solve() {
	int x;
	scanf("%d", &x);
	if (x == 1)
		printf("%d\n", 0);
	else
		printf("%d\n", 1);

}

int main()
{
	startTime = clock();
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//scanf("%d", &t);
	while (t--) solve();

	return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
using namespace std;


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;++i) cin >> vec[i];
    int count = 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(vec[i] != vec[j] && vec[j] != vec[k] && vec[i] != vec[k]){
                    vector<int> temp {vec[i], vec[j], vec[k]};
                    sort(temp.begin(), temp.end());
                    if(temp[0] + temp[1] > temp[2]) count++;
                }
            }
        }
    }
    cout << count << '\n';
    return 0;
}

Measured memory_bytes: 3664
#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("sumsqr.in");ofstream out("sumsqr.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll a,k;
vec<vec<ll>> l;
int o = 0;
vec<ll> m, us;

void dfs(int v){
    us[v] = 1;
    ll mx = -1e18;
    for(int h : l[v]){
        mx = max(mx, m[h]);
        if(us[h]) continue;
        dfs(h);
    }
    o += m[v] > mx;
}

int main() {
    fast;
    cin>>a>>k;
    m = vec<ll>(a);
    us = vec<ll>(a);
    for(int q=0; q<a; q++) cin>>m[q];
    l = vec<vec<ll>>(a, vec<ll>());
    for(int q=0; q<k;q ++){
        int x,y; cin>>x>>y; x--, y--;
        l[x].pb(y);
        l[y].pb(x);
    }
    for(int q=0; q<a; q++){
        if(!us[q]) dfs(q);
    }
    cout<<o;
}

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

int main () {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    sort (a, a+3);

    if ((a[0] == 5) && (a[1] == 5) && (a[2] == 7)) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
// review
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 100010;
const int MOD = 1e9+7;
int n_;
int a[MAXN];
bool exist[MAXN];
ll dp[MAXN];

void init() {
  dp[0] = dp[1] = 1;
  for (int i=2;i<MAXN;i++) {
    dp[i] = i * dp[i-1] % MOD;
  }
}

ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}

ll nCr(ll n, ll r) {
  if (n < r) {
      return 0;
  }
  return (dp[n] * mod_inv(dp[r]) % MOD) * mod_inv(dp[n-r]) % MOD;
}

void solve() {
  init();
  int first = 0, second = 0;
  for (int i=0;i<=n_;i++) {
    if (exist[a[i]]) {
      second = i;
      break;
    }
    exist[a[i]] = true;
  }
  for (int i=0;i<=n_;i++) {
    if (a[i] == a[second]) {
      first = i;
      break;
    }
  }
  for (int i=1;i<=n_+1;i++) {
    ll ans = (nCr(n_ + 1, i) - nCr(first+n_-second, i-1) + MOD) % MOD;
    cout << ans << endl;
  }
}

int main() {
  cin >> n_;
  for (int i=0;i<=n_;i++) {
    cin >> a[i];
  }
  solve();
}


Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            int n = Integer.parseInt(br.readLine());

            if(n == 0){
                break;
            }

            long[] input = new long[n];
            for(int i = 0; i < n; i++){
                input[i] = Long.parseLong(br.readLine());
            }


            System.out.println(calcSumOfArray(input));
        }
    }

    static long calcSumOfArray(long[] input){
        int n = input.length;
        long maxSum = input[0];

        for(int i = 0 ; i < n ;i++){
            int sum = 0;

            for(int j = i; j < n; j++){
                sum += input[j];

                maxSum = Math.max(maxSum, sum);
            }
        }

        return maxSum;
    }
}


Measured memory_bytes: 25216
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  return min(s.count('0'),s.count('1'))*2

print(main())


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a){cout<<((a)?"Yes":"No")<<endl;}
void YESNO(int a){cout<<((a)?"YES":"NO")<<endl;}
void AorB(int a,string b,string c){cout<<((a)?b:c)<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,ans=0;
    cin>>n;
    Vi a(n),wa(n);
    REP(i,0,n) cin>>a[i];
    SORT(a);
    wa[0]=a[0];
    REP(i,1,n) wa[i]=wa[i-1]+a[i];
    REP(i,0,n-1){
        if(wa[i]*2<a[i+1]) ans=i+1;
    }
    cout<<n-ans<<endl;
    return 0;
}


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

using namespace std;

int main() {

	long a,b;
	cin >> a >> b;

	if (a + b == 3) {
		cout << 3 << endl;
		return 0;
	}

	if (a + b == 4) {
		cout << 2 << endl;
		return 0;
	}
	if (a + b == 5) {
		cout << 1 << endl;
		return 0;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if( a == b ) {
        printf("a == b\n");
    } else {
        if (a > b) {
            printf("a > b\n");
        } else {
            printf("a < b\n");
        }
    }
}


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

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

    long long a[50];
    long long max=-1000001,min=1000001;
    int imax=0,imin=0;

    for(int i=0;i<N;i++){
        cin >> a[i];
        if(a[i]>max){ max=a[i]; imax=i+1; }
        if(a[i]<min){ min=a[i]; imin=i+1; }
    }

    if(min>=0){
        cout << (N-1) << endl;
        for(int i=1;i<=N-1;i++) cout << i << ' ' << (i+1) << endl;
    }else if(max<=0){
        cout << (N-1) << endl;
        for(int i=N-1;i>=1;i--) cout << (i+1) << ' ' << i << endl;
    }else if(max>=-min){
        cout << (2*N-1) << endl;
        for(int i=1;i<=N;i++) cout << imax << ' ' << i << endl;
        for(int i=1;i<=N-1;i++) cout << i << ' ' << (i+1) << endl;        
    }else{
        cout << (2*N-1) << endl;
        for(int i=1;i<=N;i++) cout << imin << ' ' << i << endl;
        for(int i=N-1;i>=1;i--) cout << (i+1) << ' ' << i << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
//auto mod int

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){} //初期化指定子
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator++() {
      if ((x++) >= mod) x-= mod;
      return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator--() {
      if ((x += mod-1) >= mod) x-= mod;
      return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> nv(26);
    rep(i,n) nv[s[i]-'a']++;
    mint ans = 1;
    rep(i,26){
        ans*=(nv[i]+1);
    }
    --ans;
    cout << ans.x << endl;

    return 0;
}

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

int main(){
	int n,x;
	cin >> n >> x;
	int l[1000];
	int a[1002]={0};
	int sum=0;
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	for(int i=1;i<n+1;i++){
		a[i]+=a[i-1]+l[i-1];
	}
	for(int i=0;i<n+1;i++){
		if(a[i]<=x){
			sum++;
		}
	}
	cout << sum;
}


Measured memory_bytes: 256
from collections import deque
def main():
  d=deque(list(input()))
  Q=int(input())
  rev=0
  for i in range(Q):
    q=list(map(str, input().split()))
    if q[0]=='1':
      rev+=1
    else:
      if (int(q[1])+rev)%2==1:
        d.appendleft(q[2])
      else:
        d.append(q[2])
  if rev%2==0:
    print(''.join(list(d)))
  else:
    d.reverse()
    print(''.join(list(d)))
main()

Measured memory_bytes: 8804