akhauriyash/Code-Regression huggingface dataset:
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s; cin>>s;
	if((s[2]==s[1])&&(s[0]==s[1] || s[3]==s[2])) cout<<"Yes";
	else cout<<"No";
	return cout<<endl,0;
}

Measured memory_bytes: 256
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long
vector<vector<ll>> dp;
vector<vector<ll>> abc;
ll N;

#define A_ACT 0
#define B_ACT 1
#define C_ACT 2
#define NO_ACT 3

// 前回のアクションがprevActのときの、i日目に得られる最大幸福度
ll res(ll i, ll prevAct)
{
    if (i < 0)
    {
        return 0;
    }

    if (dp.at(i).at(prevAct) != -1)
    {
        return dp.at(i).at(prevAct);
    }

    ll ret = -1;
    if (prevAct != A_ACT)
    {
        ret = max(ret, res(i - 1, A_ACT) + abc.at(i).at(A_ACT));
    }
    if (prevAct != B_ACT)
    {
        ret = max(ret, res(i - 1, B_ACT) + abc.at(i).at(B_ACT));
    }
    if (prevAct != C_ACT)
    {
        ret = max(ret, res(i - 1, C_ACT) + abc.at(i).at(C_ACT));
    }

    return dp.at(i).at(prevAct) = ret;
}

void solve()
{
    cin >> N;
    dp = vector<vector<ll>>(N, vector<ll>(4, -1));
    abc = vector<vector<ll>>(N, vector<ll>(3));
    for (ll i = 0; i < N; i++)
    {
        cin >> abc[i][A_ACT] >> abc[i][B_ACT] >> abc[i][C_ACT];
    }

    ll ret = -1;
    ret = max(ret, res(N - 1, A_ACT));
    ret = max(ret, res(N - 1, B_ACT));
    ret = max(ret, res(N - 1, C_ACT));

    cout << ret << endl;

    return;
}

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


Measured memory_bytes: 18944
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string s;
    cin >> s;
    cout << s.substr(0,5)+ " " +s.substr(6,7)+" "+s.substr(14) << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
import math
from queue import Queue
import sys
from copy import copy, deepcopy
from collections import defaultdict, Counter, deque
from itertools import combinations, permutations
from heapq import heapify, heappop, heappush

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

inf = float("inf")


def main():

    H, W = map(int, readline().split())
    S = [[s for s in input()] for h in range(H)]
    
    ret = 0
    delta = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    
    for h in range(H):
        for w in range(W):
            if S[h][w] == '.':
                tmp_ret = 0
                maze = deepcopy(S)
                maze[h][w] = tmp_ret
                
                q1 = Queue()
                q1.put((h, w))
                
                q2 = Queue()
                
                while not (q1.empty() and q2.empty()):
                    while not q1.empty():
                        h, w = q1.get()
                        for dh, dw in delta:
                            if h + dh < H and h + dh >= 0 \
                            and w + dw < W and w + dw >= 0 \
                            and maze[h + dh][w + dw] == '.':
                                maze[h + dh][w + dw] = '#'
                                q2.put((h + dh, w + dw))

                    if not q2.empty():
                        q1 = q2
                        q2 = Queue()
                        tmp_ret += 1
                        
                ret = max(ret, tmp_ret)
    
    print(ret)


if __name__ == "__main__":
    main()

Measured memory_bytes: 62292
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int N,K;
	cin >> N >> K;
	int x,res = 0;
	for (int i = 0; i < N; ++i) {
		cin >> x;
		res += 2 * min(K-x,x);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;


main(){
    int n,x,t;
    cin>>n>>x>>t;
    int temp = n/x;
    ll ans;
    temp*= t;
    if(n%x == 0) cout<<temp;
    else cout<<temp+t;
}

Measured memory_bytes: 3636
//PseudoName

    #pragma GCC optimize("O3")
    #include <bits/stdc++.h>
/*
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
    #define FOR(i,n) for(i=0;i<n;i++)
    #define FOR1(i,n) for(i=1;i<=n;i++)
    #define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
    #define pb push_back
    #define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
    #define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
    #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define endl "\n"
    #define min3(a,b,c) min(a,min(b,c))
    #define forr(n) for(int i=0;i<n;i++)
    #define frr(n) for(int i=1;i<=n;i++)
    #define MAX 100005
    #define inf 200008

    using namespace std;

    typedef long long ll;
    typedef long li;
    typedef vector<int> vi;
    typedef vector<ll> vli;
    typedef vector<vi> vvi;
    typedef vector<vli> vvli;
    typedef pair<int,int> pi;
    typedef pair<ll,ll> pli;
    typedef vector<pi> vpi;
    typedef vector<pli> vpli;

    ll c2(ll n)
    {
        return (n*(n-1))/2;
    }

    int main() {
        fast();
      int n;
      cin>>n;
      ll a[n];
      forr(n)cin>>a[i];

      map<ll,ll> cnt;
      forr(n)cnt[a[i]]++;
      ll ans=0;
      for(auto p:cnt)
      {
          ans+=c2(p.second);
      }
      ll mid;

      forr(n)
      {
          int k=cnt[a[i]];
          if(k==1){cout<<ans<<endl;continue;}
          mid=ans-c2(k)+c2(k-1);
          cout<<mid<<endl;
      }
    }


Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,max=0;
	cin>>n;
	for(int i=1;i<=n;i*=2){
		if(i>=max){
			max=i;
		}
	}
	
	cout<<max<<endl;
	
}

Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let (n, _): (usize, usize) = parse_line().unwrap();
    let a: Vec<usize> = parse_line().unwrap();

    let mut min = a[0];
    let mut max_profit = 0;
    for i in 0..n {
        if a[i] < min {
            min = a[i];
        } else if a[i] - min > max_profit {
            max_profit = a[i] - min;
        }
    }

    let mut min = a[0];
    let mut ret = 0;
    for i in 0..n {
        if a[i] < min {
            min = a[i];
        } else if a[i] - min == max_profit {
            ret += 1;
        }
    }
    println!("{}", ret);
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n, 0);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    ++v[a-1];
    ++v[b-1];
  }
  rep(i, n) cout << v[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e9;

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

    vector<pair<int, int>> key;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b) {
            int c;
            cin >> c;
            c--;
            s |= 1<<c;
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    rep(s, 1<<n) {
        rep(i, m) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }

    int ans = dp.back();
    if(ans == INF) {
        ans = -1;
    }

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

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

int main(){
	int H,N,sum=0,i;
	cin>>H>>N;
	int a[N+1];
	
	for(i=1;i<=N;i++)
		cin>>a[i];
		
	for(i=1;i<=N;i++)
		sum+=a[i];
		
	if(sum>=H)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		
	return 0;	
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int mod = 998244353;
const double eps = 1e-8;
int a[107];
bool cmp(int c,int b){
	return c > b;
}
int main(){
	int n,m;
	cin >> n >> m;
	int sum = 0;
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		sum += a[i];
	}
	sort(a+1,a+1+n,cmp);
	int fl = 0;
	for(int i = 1;i <= m;i++){
		if(a[i] * 4 * m >= sum) continue;
		else{
			fl = 1;
			break;
		}
	}	
	if(fl) cout << "No"<<endl;
	else cout << "Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5+10;
struct node{
	int x,y;
}a[N];
int cx[N],cy[N],idx,idy;
vector<int>xx,yy;
map<long long,int>mp;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<k;i++){
		scanf("%d %d",&a[i].x,&a[i].y);
		cx[a[i].x]++,cy[a[i].y]++;
		if(cx[a[i].x]>cx[idx])idx=a[i].x;
		if(cy[a[i].y]>cy[idy])idy=a[i].y;
		mp[1LL*a[i].x*N+a[i].y]=1;
	}
	for(int i=1;i<=n;i++){
		if(cx[i]==cx[idx])xx.push_back(i);
	}
	for(int i=1;i<=m;i++){
		if(cy[i]==cy[idy])yy.push_back(i);
	}
	int f=1;
	for(int i=0;i<xx.size();i++){
		if(!f)break;
		for(int j=0;j<yy.size();j++){
			if(mp[1LL*xx[i]*N+yy[j]]==0){
				f=0;break;
			}
		}
	}
	printf("%d\n",cx[idx]+cy[idy]-f);
}

Measured memory_bytes: 30968
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int;  // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n) {
  int ret = 1;
  for (int i = 1; i < n + 1; ++i) {
    ret = ret * i;
  }
  return ret;
}

/* 最大公約数 */
template <typename T>
T gcd(T x, T y) { return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>
T lcm_n(vector<T> &numbers) {
  T l;
  l = numbers[0];
  for (int i = 1; i < numbers.size(); ++i) {
    l = lcm(l, numbers[i]);
  }
  return l;
}

/*
 * DP向け
 */
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;
}

/*
 * グラフ
 */
class Graph {
 public:
  vector<vector<int>> G;
  vector<int> Trans;
  vector<int> inDeg;
  int numV;

  Graph(int numV) {
    this->numV = numV;
    inDeg.assign(numV, 0);
    Trans.assign(numV, 0);
    G.assign(numV, vector<int>());
  }

  int topologicalSort(int v, vector<int> &dp) {
    if (dp[v] != -1) {
      return dp[v];
    }

    int res = 0;

    for (auto to : G[v]) {
      chmax(res, topologicalSort(to, dp) + 1);
    }

    return dp[v] = res;
  }
};

void dfs(ll val, ll N, ll &count) {
  vector<bool> flag(3, false);

  for (auto s : to_string(val)) {
    if (s == '3') flag[0] = true;
    if (s == '5') flag[1] = true;
    if (s == '7') flag[2] = true;
  }

  if (val <= N) {
    if (flag[0] && flag[1] && flag[2]) {
      ++count;
    }

    dfs(10 * val + 3, N, count);
    dfs(10 * val + 5, N, count);
    dfs(10 * val + 7, N, count);
  }
}

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

  ll count = 0;

  dfs(0, N, count);

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int N, K;

void solve() {
    if (N % K == 0) {
        cout << 0 << endl;
        return;
    }
    if (N > K) {
        N = ((N - K) % K) + K;
    }
    if (N > K)
        N -= K;
    cout << min(N, K - N) << endl;
    return;
}

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

    cin >> N >> K;

    solve();
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
if a == 1 and b ==2:
    print(3)
if a == 1 and b ==3:
    print(2)
if a == 2 and b ==1:
    print(3)
if a == 2 and b ==3:
    print(1)
if a == 3 and b ==1:
    print(2)
if a == 3 and b ==2:
    print(1)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  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");
  }
    return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int a;
    cin >> a;
    cout << a + pow (a, 2) + pow (a, 3) << endl;
    return 0;
}

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

int main()
{
int N,A,B,san=0,kai=1;scanf("%d %d %d",&N,&A,&B);
char S[N];scanf("%s",S);
for(int i=0;i<N;i++)
{
  if(S[i]=='a'&&san<A+B){printf("Yes\n");san++;}
  else if(S[i]=='b'&&san<A+B&&kai<=B){printf("Yes\n");san++;kai++;}
  else printf("No\n");
}
}

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

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  ll sum=0;
  vector<int> possible(N,0);
  possible.at(N-1)=1;
  for(int i=0;i<N-1;i++){
    sum+=A.at(i);
    if(2*sum>=A.at(i+1)){
      possible.at(i)=1;
    }
  }
  int ans=0;
  for(int i=N-1;i>=0;i--){
    if(possible.at(i)==1){
      ans++;
    }else{
      break;
    }
  }
  cout<<ans<<endl;
}


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

const int MAX = 100000;

void solve(vector<int> G[],int V[],int C[], int v,int& c){
    V[v] = 0;
    for(int i = 0;i < G[v].size();i++){
        if(V[G[v][i]] != -1)continue;
        solve(G,V,C,G[v][i],c);
    }
    V[v] = C[c++];
}

int main(){
    int N;
    int A[MAX],B[MAX],C[MAX];
    int V[MAX];
    vector<int> G[MAX];
    
    cin >> N;
    for(int i = 0;i < N-1;i++){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }

    for(int i = 0;i < N;i++){
        cin >> C[i];
    }
    sort(C,C+N);

    for(int i = 0;i < N;i++)V[i] = -1;

    int c = 0;
    int ans = 0;
    solve(G,V,C,0,c);
    
    for(int i = 0;i < N-1;i++){
        ans += min(V[A[i]],V[B[i]]);
    }

    cout << ans << endl;
    for(int i = 0;i < N;i++)cout << V[i] << ' ';
    cout << endl;

    return 0;
}


Measured memory_bytes: 3840
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())
 
AB = [[int(x) for x in input().split()] for _ in range(N-1)] 
PX = [[int(x) for x in input().split()] for _ in range(Q)] 
 
graph = [[] for _ in range(N+1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p, x in PX:
    value[p] +=x
 
def dfs(v, parent, add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x, v, value[v])
 
dfs(1, 0, 0)
ans = ' '.join(map(str,value[1:]))
print(ans)

Measured memory_bytes: 285828
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int A[MAX_N];
int L[MAX_N + 1];
int R[MAX_N + 1];
int M[MAX_N + 1];

int gcdd(int a, int b)
{
  if (b == 0) {
    return a;
  }
  return gcdd(b, a % b);
}

int gcd(int a, int b)
{
  if (a == 0) {
    return b;
  }
  else if (b == 0) {
    return a;
  }
  return gcdd(a, b);
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  REP(i, N) cin >> A[i];

  ll sum = 0;
  L[0] = 0;
  for (int i = 0; i < N; i++) {
    L[i + 1] = gcd(L[i], A[i]);
  }

  R[N] = 0;
  for (int i = N - 1; i >= 0; i--) {
    R[i] = gcd(R[i + 1], A[i]);
  }

  for (int i = 0; i < N; i++) {
    M[i] = gcd(L[i], R[i + 1]);
  }

  int ans = 0;
  REP(i, N) { ans = max(ans, M[i]); }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
N = int(input())
H = []
for i in range(N):
    a = list(map(int, input().split()))
    H.append(a)

DP = []
for i in range(N+1):
    DP.append([0]*3)

for i in range(1, N+1):
    for j in range(3):
        for k in range(3):
            if j != k:
                DP[i][j] = max(DP[i][j], H[i-1][j] + DP[i-1][k])

# for i in range(N+1):
#     print(DP[i])
ans = max(DP[N])
print(ans)

Measured memory_bytes: 73088
import numpy as np 
n = int(input())
size_ls = list(map(int, input().split()))
size_ls.sort()
csum_size = list(np.cumsum(size_ls))

can_ls = [0] * n
can_ls[-1] = 1
for i in range(n-1):
    if 2 * csum_size[i] >= size_ls[i+1]:
        can_ls[i] = 1
ans = 0
for i in range(n-1,-1,-1):
    if can_ls[i] != 1:
        break
    ans += 1
print(ans)



Measured memory_bytes: 23332
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int cnt[100010];

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

	vector<int> a;
	inputVector(a, n);

	sort(all(a));

	vector<pair<int, int>> v;

	int tmp = 1;
	REP(i, 1, n - 1) {
		if (a[i] == a[i - 1]) {
			tmp++;
		} else {
			v.push_back(make_pair(a[i - 1], tmp));
			tmp = 1;
		}
	}
	v.push_back(make_pair(a[n - 1], tmp));

	int num = 0;
	bool over = false;
	rep(i, v.size()) {
		num += v[i].second - 1;
		over |= v[i].second > 1;
	}

	if (num % 2) num++;

	int ret = n - num;

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top,S[1000];

void push(int x)
{
  S[++top] = x;
}

int pop()
{
  top--;
  return S[top+1];
}

int main()
{
  int a,b;
  char s[100];
  top = 0;

  while(scanf("%s",s) !=EOF)
    {
      if(s[0] == '+')
	{
	  a = pop();
	  b = pop();
	  push(a + b);
	}
      else if(s[0] == '-')
	{
	  b = pop();
	  a = pop();
	  push(a - b);
	}
      else if(s[0] == '*')
	{
	  a = pop();
	  b = pop();
	  push(a * b);
	}
      else push(atoi(s));
    }
  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 2108
import heapq


def solve(string):
    n, m, *ab = map(int, string.split())
    ab = sorted([(a, b) for a, b in zip(*[iter(ab)] * 2)])
    hq, index, cap, count, ans = [], 0, 1, m, 0
    while index < n:
        _a, _b = ab[index]
        if _a > m:
            break
        if _a <= cap:
            heapq.heappush(hq, -_b)
            index += 1
        else:
            ans += -heapq.heappop(hq) if len(hq) > 0 else 0
            count += -1
            cap += 1
    ans += sum([-heapq.heappop(hq) for _ in range(count) if len(hq) > 0])
    return str(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 25832
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sol() {
  int h, a;
  int cnt = 0;
  cin >> h >> a;
  while(h > 0) {
    cnt++;
    h -= a;
  }
  cout << cnt;
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = list(str(input()))

alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
if len(set(s)) >= 26:
    print("None")
    exit()
for i in alph:
    for j in s:
        if not(i in s):
            print(i)
            exit()


Measured memory_bytes: 3956
fun main(){
    val k = readLine()!!.split(" ").map { it.toInt() }[0]
    val s = readLine()!!.split(" ")[0]
    val ssize = s.length
    if (k >= ssize){
        println(s)
    } else {
        val ans = s.subSequence(0, k)
        println("${ans}...")
    }
}

Measured memory_bytes: 36400
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll power(ll a,ll b)
{
    ll r = 1;
    while(b>0)
    {
        if(b%2 == 1)
        {
            r = r*a;
        }
        a = a*a;
        b = b/2;
    }
    return r;
}

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin>>s;

    if(s[1]=='B')
    {
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"ABC"<<endl;
    }

}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl a(n),b(n);rep(i,n)cin >> a[i];rep(i,n)cin >> b[i];
    ll ans=inf;
    rep(bit,1<<n){
        vpl even,odd;
        rep(i,n){
            if(bit&1<<i){
                if(i%2==0)even.pb({a[i],i});
                else odd.pb({a[i],i});
            }
            else{
                if(i%2==0)odd.pb({b[i],i});
                else even.pb({b[i],i});
            }
        }
        /*cout << bit <<endl;
        for(auto p:even)cout << p.fi <<" ";
        cout << endl;*/
        if(even.size()!=(n+1)/2)continue;
        sort(all(even)),sort(all(odd));
        vpl use(n);
        rep(i,n){
            if(i%2)use[i]=odd[i/2];
            else use[i]=even[i/2];
        }
        bool ok=true;
        rep(i,n-1)if(use[i+1].fi<use[i].fi)ok=false;
        if(ok){
            ll res=0;
            rep(i,n){
                repl(j,i+1,n){
                    if(use[i].se>use[j].se)res++;
                }
            }
            chmin(ans,res);
        }
    }
    if(ans<inf)cout << ans <<endl;
    else cout << -1 <<endl;
}   

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0LL, (a + b) - n) << endl;
}

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

int solve(int W, int H) {
    vector<vector<char>> field(H + 2, vector<char>(W + 2, '#'));
    vector<vector<int>> cost(H + 2, vector<int>(W + 2));
    queue<pair<int, int>> que;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> field[i][j];
            if (field[i][j] == '@') {
                que.push(make_pair(i, j));
                cost[i][j] = 1;
            }
        }
    }
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, 1, 0, -1};
    while (!que.empty()) {
        pair<int, int> p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int nx = p.second + dx[i];
            int ny = p.first + dy[i];
            if (field[ny][nx] == '#') continue;
            if (cost[ny][nx]) continue;
            cost[ny][nx] = 1;
            que.push(make_pair(ny, nx));
        }
    }
    int ret = 0;
    for (int i = 0; i < cost.size(); i++) {
        for (int j = 0; j < cost[i].size(); j++) {
            if (cost[i][j]) ret++;
        }
    }
    return ret;
}

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

    int W, H;
    while (1) {
        cin >> W >> H;
        if (!W & !H) break;
        cout << solve(W, H) << endl;
    }
}


Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  bool ret = false;
  for(int i = 1; i < B; i++){
    if((A * i) % B == C){
      ret = true;
      break;
    }
  }
  if(ret) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

# from collections import defaultdict
# d = defaultdict(list)

# from itertools import combinations
# comb = combinations(range(N), 2)

# 累積和
# from itertools import accumulate
# _list = list(accumulate(a_list)

# from functools import lru_cache
# @lru_cache(maxsize=None)
# def setUp(self):
#     dp.cache_clear()


def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy > 0:
        out = str(X_dumy % n) + out
        X_dumy = int(X_dumy / n)
    return out


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    N, K = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    print(len(Base_10_to_n(N, K)))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """11 2"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1010101 10"""
        output = """7"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """314159265 3"""
        output = """18"""
        self.assertIO(input, output)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

int N;
Graph<int> G;
vector<int> dp;
vector<int> modpow;

void dfs(int v, int p = -1) {
    dp[v] = 1;
    for (auto nv : G[v]) {
        if (nv == p)
            continue;
        dfs(nv, v);
        dp[v] += dp[nv];
    }
}

int dfs2(int v, int p = -1, int par = 0) {
    int res = modpow[N - 1] - 1;
    for (auto nv : G[v]) {
        if (nv == p)
            (res -= modpow[par] - 1) %= MOD;
        else
            (res -= modpow[dp[nv]] - 1) %= MOD;
    }

    for (auto nv : G[v]) {
        if (nv == p)
            continue;
        (res += dfs2(nv, v, dp[v] - dp[nv] + par)) %= MOD;
    }
    return res;
}

void extGCD(ll a, ll b, ll &p, ll &q) {
    if (b == 0) {
        p = 1, q = 0;
        return;
    }
    extGCD(b, a % b, q, p);
    q -= a / b * p;
}

int modinv(ll a, ll m) {
    ll p, q;
    extGCD(a, m, p, q);
    p %= m;
    if (p < 0)
        p += m;
    return p;
}

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

    cin >> N;
    G.resize(N);
    for (int i = 1; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    modpow.resize(N + 1);
    modpow[0] = 1;
    for (int i = 1; i <= N; ++i)
        modpow[i] = (modpow[i - 1] * 2) % MOD;

    dp.resize(N);
    dfs(0);
    ll res = dfs2(0);
    if (res < 0)
        res += MOD;
    (res *= modinv(modpow[N], MOD)) %= MOD;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 23936
import java.util.*;
public class Main {
    public static int L[], R[];
    public static long A[], B[];
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        L = new int[N];
        R = new int[N];
        for (int i = 0; i < N; ++i) {
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(L);
        for (int i = 0; 2*i < N-1; ++i) {
            L[i] += L[N-i-1];
            L[N-i-1] = L[i]-L[N-i-1];
            L[i] -= L[N-i-1];
        }
        Arrays.sort(R);

        A = new long[N+1];
        B = new long[N+1];
        long ans = 0;
        for (int i = 0; i < N; ++i) {
            A[i+1] = L[i]+A[i];
            B[i+1] = R[i]+B[i];
        }
        for (int i = 0; i < N; ++i) {
            ans = Math.max(A[i]-B[i+1], ans);
            ans = Math.max(A[i+1]-B[i], ans);
            ans = Math.max(A[i+1]-B[i+1], ans);
        }
        System.out.println(2*ans);
    }
}

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

void solve() 
{
    int a,b,c;cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, M;

ll count(vector<ll>& arr, ll M) {
    sort(ALL(arr));
    size_t size = arr.size();

    ll s = 0, i = 0, res = 0;
    while(s < M && i < size)
        s += arr[i++];
    res += (s - M) / 2;
    while(i < size)
        res += arr[i++] / 2;
    return res;
}

int main() {
    cin >> N >> M;
    ll x;
    map<ll,ll> A;
    vector<ll> B(M, 0);
    vector<vector<ll>> C(M, vector<ll>(0));
    REP(i, N) {
        cin >> x;
        if(A.find(x) == A.end()) A[x] = 0;
        A[x]++;
    }
    for(auto e : A) {
        B[e.first%M] += e.second;
        C[e.first%M].push_back(2*(e.second/2));
        if(e.second%2) {
            C[e.first%M].push_back(1);
        }
    }
    priv(B);
    REP(i, M) priv(C[i]);
    ll ans=B[0] / 2;
    ll i=1, j=M-1, a, b;
    while(i<=j) {
        if(i==j) {
            ans += B[i] / 2;
        } else {
            if(B[i] < B[j]) {
                ans += B[i];
                ans += count(C[j], B[i]);
            } else {
                ans += B[j];
                ans += count(C[i], B[j]);
            }
        }
        i++; j--;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll x,y,a,b,c; cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin>>p[i];
    rep(i,b) cin>>q[i];
    rep(i,c) cin>>r[i];
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    sort(p.begin(), p.end(), greater<>());
    sort(q.begin(), q.end(), greater<>());
    sort(r.begin(), r.end(), greater<>());
    rep(i,x) pq.push(p[i]);
    rep(i,y) pq.push(q[i]);

    rep(i,c) {
        if (pq.top() < r[i]) {
            pq.pop();
            pq.push(r[i]);
        }
    }

    ll ans = 0;
    while (!pq.empty()) {
        ans += pq.top(); pq.pop();
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7656
#116

n = int(input())

def f1(n):
    if(n%2==0):
        return int(n/2)
    else:
        return 3*n+1

a = [n]
i = 0
while a.count(f1(a[i]))!=1:
    a.append(f1(a[i]))
    i+=1

print(i+2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl

const ll INF=1e9+7;
const ll N = 100002;
string a,b,c;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int a,b,c,d,n,t;
	
	while(scanf("%d",&n)!=EOF){
		
		t=0;
		
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						
						if(a+b+c+d==n){
							
							t++;
						}
					}
				}
			}
		}
		printf("%d\n",t);
	}
	return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int>p(N),q(N),A(N),test(N);
    for(int i=0;i<N;i++){
        cin>>p.at(i);
        A[i]=i+1;
    }
    for(int i=0;i<N;i++){
        cin>>q.at(i);
    }

    int count=0,a=0,b=0,r=0,r1=0;
    do{
       count++;
       for(int i=0;i<N;i++){
           if(p[i]==A[i]){
               r++;
           }
           if(q[i]==A[i]){
               r1++;
           }
       }
       if(r==N){
           a=count;
       }
       if(r1==N){
           b=count;
       }
       r=0;r1=0;
      
    }while(next_permutation(A.begin(),A.end()));
    cout<<abs(a-b)<<endl;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int r,s,p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    int record[n];
    int score=0;
    bool changed[n];
    memset(changed,0,sizeof(changed));

    rep(i,n){
        int now;
        if(t[i]=='r'){
            score+=p;
            now=p;
            record[i]=3;
        }
        else if(t[i]=='s'){
            score+=r;
            now=r;
            record[i]=1;
        }
        else if(t[i]=='p'){
            score+=s;
            now=s;
            record[i]=2;
        }

        if(i>=k){
            if(record[i]==record[i-k]){
                if(changed[i-k]==false){
                    score-=now;
                    if(record[i]==3) record[i]=1;
                    else record[i]=record[i]+1;
                    changed[i]=true;
                }
                
            }
        }
    }

    cout << score << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

void dfs(vector<int> arr[], vector<int> &dis, int node){
	int temp = 0;
	for(int i:arr[node]){
		if(dis[i]==-1){
			dis[i]=0;
			dfs(arr,dis,i);
		}
		temp = max(temp, dis[i]+1);
	}
	dis[node] = max(dis[node], temp);
}

int solve(vector<int> arr[], int n){
	vector<int> dis(n+1,-1);

	for(int i=1;i<=n;i++){
		if(dis[i]==-1){
			dis[i]=0;
			dfs(arr,dis,i);
		}
	}

	int ans=0;
	for(int i=1;i<=n;i++){
		//cout<<dis[i]<<endl;
		ans = max(ans, dis[i]);
	}
	return ans;
}

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

	int a,b,n,m;
	cin>>n>>m;
	vector<int> arr[n+1];
	for(int i=0;i<m;i++){
		cin>>a>>b;
		arr[a].push_back(b);
	}

	cout<<solve(arr,n)<<endl;

	return 0;
}

Measured memory_bytes: 10240
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		Integer n = Integer.parseInt(sc.next());
		String nn =String.valueOf(n);
		String aaa = nn.substring(nn.length()-1);
		 n = Integer.parseInt(aaa);
		
		if(n==2||n==4||n==5||n==7||n==9) 
		{System.out.println("hon");
			
		}else if (n==0||n==1||n==6||n==8) {
			System.out.println("pon");
		}else {
			System.out.println("bon");
		}
	}

}


Measured memory_bytes: 35556
#include <bits/stdc++.h> // only for GCC
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n, m;

  while(cin >> n >> m, n) {
    map<string,int> prize;
    vector<string> v(m);

    REP(i, n) {
      string s;
      int x;
      cin >> s >> x;
      prize.insert(MP(s, x));
    }

    REP(i, m) cin >> v[i];

    int ans = 0;
    map<string, int>::iterator it = prize.begin();
    while(it != prize.end()) {
      REP(i, m) {
	bool b = true;
	REP(j, 8) {
	  if(it->first[j] == '*') continue;
	  else if(it->first[j] != v[i][j]) {
	    b = false;
	    break;
	  }
	}
	if(b) ans += it->second;
      }
      it++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1276
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


def solve(N):
    A = inpl()
    dp = [INF] * (A[0] * 2)
    for i in range(A[0]//2, A[0]*2):
        dp[i] = abs(i - A[0]) / A[0]  # A[0]の価格を変えたときのconfusion ratio

    for i in range(N-1):
        a1 = A[i + 1]
        nn = a1 * 2
        ndp = [INF] * nn  # ndp[A[i+1]の変更後の価値] = confusion ratioの最小値
        for j in range(1, len(dp)):
            if dp[j] == INF:
                continue

            t = dp[j]
            for k in range(j, nn, j):
                u = abs(a1 - k) / a1
                if u < t:  # A[i]とA[i+1]でconfusion ratioの大きい方をndpと比較
                    u = t
                if ndp[k] > u:  # A[1]~A[i+1]まで帳尻を合わせたときのconfusion ratioの最小値を格納
                    ndp[k] = u

        dp = ndp

    return '{:0.12f}'.format(min(dp))


N = int(input())
if N != 0:
    print(solve(N))



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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int a, b, c;
  cin >> a >> b >> c;
  int diff = a-b;
  cout << max(c-diff, 0);
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


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

    int n;
    cin >> n;
    vector<int> a(100010);
    int in;
    rep(i,n) {
        cin >> in;
        ++a[in];
    }
    int ans=0;
    rep(i,100000) {
        int tans=a[i]+a[i+1]+a[i+2];
        ans=max(ans,tans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    cin >> N;
    bool approved = true;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if(a%2) continue;
        if(a%3 && a%5) approved = false;
    }
    if(approved) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    l=[0]*4
    for i in range(n):
        s=input()
        if s=='AC':
            l[0]+=1
        elif s=='WA':
            l[1]+=1
        elif s=='TLE':
            l[2]+=1
        else:
            l[3]+=1
    print('AC x '+str(l[0]))
    print('WA x '+str(l[1]))
    print('TLE x '+str(l[2]))
    print('RE x '+str(l[3]))



    

    
resolve()

Measured memory_bytes: 73752