akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  long long n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<string> in(n);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  if (a + b + c == 0) {
    cout << "No\n";
    return 0;
  }
  vector<char> ans;
  for (int i = 0; i < n; i++) {
    string ss = in[i];
    if (ss == "AB") {
      if (a == 0 && b == 0) {
        cout << "No\n";
        return 0;
      }
      if (a != b || a + b > 2 || i == n - 1) {
        if (a >= b) {
          a--;
          b++;
          ans.push_back('B');
        } else {
          a++;
          b--;
          ans.push_back('A');
        }
      } else {
        string sss = in[i + 1];
        if (sss == "AB") {
          a--;
          b++;
          ans.push_back('B');
        }
        if (sss == "AC") {
          a++;
          b--;
          ans.push_back('A');
        }
        if (sss == "BC") {
          a--;
          b++;
          ans.push_back('B');
        }
      }
    } 
    if (ss == "AC") {
      if (a == 0 && c == 0) {
        cout << "No\n";
        return 0;
      }
      if (a != c || a + c > 2 || i == n - 1) {
        if (a >= c) {
          a--;
          c++;
          ans.push_back('C');
        } else {
          a++;
          c--;
          ans.push_back('A');
        }
      } else {
        string sss = in[i + 1];
        if (sss == "AB") {
          a++;
          c--;
          ans.push_back('A');
        }
        if (sss == "AC") {
          a++;
          c--;
          ans.push_back('A');
        }
        if (sss == "BC") {
          a--;
          c++;
          ans.push_back('C');
        }
      }
    }
    if (ss == "BC") {
      if (b == 0 && c == 0) {
        cout << "No\n";
        return 0;
      }
      if (b != c || b + c > 2 || i == n - 1) {
        if (b >= c) {
          b--;
          c++;
          ans.push_back('C');
        } else {
          b++;
          c--;
          ans.push_back('B');
        }
      } else {
        string sss = in[i + 1];
        if (sss == "AB") {
          c--;
          b++;
          ans.push_back('B');
        }
        if (sss == "AC") {
          b--;
          c++;
          ans.push_back('C');
        }
        if (sss == "BC") {
          b--;
          c++;
          ans.push_back('C');
        }
      }
    }
  }
  cout << "Yes\n";
  for (auto& c : ans) {
    cout << c << '\n';
  }
  return 0;
}

Measured memory_bytes: 6696
#include<bits/stdc++.h>
using namespace  std;
int main(){
    int n;
    cin>>n;
    int sum;
    int ans=0;
    for(int i=1;i<=n;i+=2){
        sum=0;
        for(int j=1;j<=i;j+=2){
            if(i%j==0) sum++;
        }
        if(sum==8) ans++;
    }
    cout<<ans<<endl;
    return 0;
}



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

def rotete(S, T):
    S_len = len(S)
    
    for _ in range(S_len):
        if S == T:
            return "Yes"
        S = S[S_len-1] + S[:S_len-1]
        
    return "No"

print(rotete(S, T))

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

using namespace std;

int main(void){
    int N;
    cin>>N;
    bool flg=false;
    if(N/1000==(N/100)%10&&N/1000==(N/10)%10)   flg=true;
    if((N/100)%10==(N/10)%10&&(N/100)%10==N%10) flg=true;
    if(flg)     cout<<"Yes"<<endl;
    else        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void countingSort(int a[], int c[], int n) {
  int b[2000001];
  for (int i = n; 0 < i; i--) {
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  }
  for (int i = 1; i <= n; i++) {
    if (i == n) {
      printf("%d\n", b[i]);
    } else {
      printf("%d ", b[i]);
    }
  }
}

int main() {
  int n;
  int a[2000001];

  int c[10000];
  int c2[10000];
  int a_max = 0;

  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a_max < a[i]) {
      a_max = a[i];
    }
    c2[a[i]]++;
  }
  // Cの累積和を求める
  for (int i = 0; i <= a_max; i++) {
    for (int j = 0; j <= i; j++) {
      c[i] += c2[j];
    }
  }
  countingSort(a, c, n);
  return 0;
}



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

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

  //順列を格納する
  vector<int> p(n),q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];

  vector<int> a(n);
  rep(i,n) a[i] = i+1;//1からnまでのNoを用意する
  
  map<vector<int>, int> mp;//キーに順列を入れて判定する
  do {
    mp[a] = mp.size();//何番目かを判定する
  } while (next_permutation(a.begin(), a.end())); //辞書順で次の順列を作成して上書する。「next_permutation」は次の順列が存在する場合はtrueを返し、そうでなければfalseを返す

  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
}


Measured memory_bytes: 5248
S = []
flag = 0

for _ in range(5):
    S.append(int(input()))

k = int(input())

for i in range(5):
    for j in range(i+1,5):
        if S[j] - S[i] > k:
            flag = 1
            break
    
    if(flag):
        break

print('Yay!' if flag == 0 else ':(')

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define Max 1000
int push(int *, int);
int pop(int *);
int isEmpty(int);
int isFull(int);
int calc(int *, int);
static int top=0;

int main(){
  int S[Max];
  int i,a;
  char x[Max];
  char c;

  while(1){
    if(scanf("%s",x)==EOF) break;
    if(x[0]>='0' && x[0]<='9'){
      a = atoi(x);
      push(S,a);
    }
    else if(x[0]=='+' || x[0]=='-' || x[0]=='*'){
      c = x[0];
      calc(S,c);
    }   
  }
  
  printf("%d\n",S[top]);
  
  return 0;
}


int push(int *S,int x)
{
  // if(isFull(top)==0) exit(8);
  top++;
  S[top] = x;
  return S[top];
}

int calc(int *S,int x){
  int Ans=0;
  if(x=='+')       Ans = S[top-1] + S[top];
  else if(x=='-')  Ans = S[top-1] - S[top];
  else if(x=='*')  Ans = S[top-1] * S[top];
  pop(S);
  S[top] = Ans;
  return S[top];
}

int pop(int *S)
{
  //if(isEmpty(top)==0) exit(8);
  top--;
  return S[top+1];
}

/*int isFull(int top)
{
  if(top>=Max-1) return 0;
  else return 1;
}

int isEmpty(int top)
{
  if(top<=0) return 0;
  else return 1;
}
*/

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

int main(){
	string a,b,c ;
	cin >> a >> b >> c ;
	int A = a.size() ;
	int B = b.size() ;
	int C = c.size() ;
	int i,j,k ;
	i = j = k = 0 ;
	int turn = 1 ;
	while(1){
		if(turn==1&&i==A){
			cout << 'A' << endl ;
			return 0 ;
		}
		if(turn==2&&j==B){
			cout << 'B' << endl ;
			return 0 ;
		}
		if(turn==3&&k==C){
			cout << 'C' << endl ;
			return 0 ;
		}
		if(turn==1){
			turn = a.at(i)-'a'+1 ;
			i++ ;
		}else if(turn==2){
			turn = b.at(j)-'a'+1 ;
			j++ ;
		}else{
			turn = c.at(k)-'a'+1 ;
			k++ ;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {  
        
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

int32_t main()
{
    speed upp
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
N,K = [int(x) for x in input().split()]
H = [0]*N
for i in range(N):
  H[i] = int(input())
H.sort(reverse=True)
ans = 100000000000000000
for i in range(N-K+1):
  ans = min(ans,H[i]-H[i+K-1])
print(ans)

Measured memory_bytes: 7472
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;


int main()
{
    int n, x, a[100];
    cin >> n >> x;
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        x -= a[i];
        if (x < 0)
        {
            ans = i;
            break;
        }
        else if (x == 0)
        {
            ans = n;
        }
        else
        {
            ans = n - 1;
        }
        
    }
    cout << ans << endl;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    vector<int> start(26, -1), goal(26, -1);
    for (int i = 0; i < s.size(); ++i) {
        int a = s[i] - 'a';
        int b = t[i] - 'a';
        if ((start[a] != -1 || goal[b] != -1) && (start[a] != b || goal[b] != a)) {
            cout << "No" << endl;
            return 0;
        }
        start[a] = b;
        goal[b] = a;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 776
def main():
  n, m = map(int, input().split())
  a = [list(map(int, input().split())) for _ in range(m)]
  r = [0] * m
  pr = [[] for _ in range(n)]
  for i, x in enumerate(a):
    pr[x[0]-1].append([i, x[1]])
  pr = list(map(lambda x: sorted(x, key=lambda y: y[1]), pr))
  for i, x in enumerate(pr):
    for j, a in enumerate(x):
      r[a[0]] = str(i+1).zfill(6)+str(j+1).zfill(6)
  for x in r:
    print(x)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 59168
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vec a(N);
    rep(i, N) cin >> a[i];

    ll ans = INF;
    for(ll y = -200; y <= 200; ++y){
        ll cost = 0;
        rep(i, N) cost += (a[i] - y) * (a[i] - y);
        chmin(ans, cost);
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    sort(S.begin(), S.end());
    
    if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
X=int(input())
flag = True
if X == 2:
    print(X)
else:
    while flag:
        i = 2
        while i<X:
            if X%i == 0:
                break
            if i == X-1:
                print(X)
                flag = False
                break
            i = i+1
        X = X+1

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

int main(){
	
	int N;
    vector<int> H;
	
    cin >> N;
    int tmp;
    for (int i = 0; i < N; i++){
        cin >> tmp;
        H.push_back(tmp);    
    }

    int s;
    int count = 0;
    int maxc = 0;
    for (int i = 0; i < N-1; i++){
        s = H[i] - H[i+1];
        if (s>=0){
            count++;
        }else{
            count=0;
        }

        if (count > maxc){
            maxc = count;
        }
    }
    cout << maxc << endl;

	return 0;
}



Measured memory_bytes: 892
#include <iostream>

int main()
{
    int h[10];

    for (int i = 0; i < 10; i++)
    {
        std::cin >> h[i];
    }

    for (int i = 0; i < 10; i++)
    {
        for (int n = 0; n < 9; n++)
        {
            if (h[n] < h[n+1])
            {
                std::swap(h[n], h[n+1]);
            }
        }
    }
    
    for (int i = 0; i < 3; i++)
    {
        std::cout << h[i] << std::endl;
    }

    return 0;
}



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

int main () {
    int a,b,c;
    double p=3.14159265359;
    scanf("%d%d%d",&a,&b,&c);
    double s,d,h,r;
    r=c/180.0*p;
    s=a*b*sin(r)/2.0;
    d=sqrt(pow(a,2)+pow(b,2)-2.0*a*b*cos(r));
    h=b*sin(r);
    printf("%.8lf\n%.8lf\n%.8lf\n",s,a+b+d,h);
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	ll x,y;
	cin>>x>>y;
	ll a=1145141919810,b=1145141919810,c=1145141919810,d=1145141919810;
	if(y>=x){ a = y-x;}
	if(-y>=x){ b = (-y)-x+1;}
	if(y>=-x){ c = y-(-x)+1;}
	if(-y>=-x){ d = (-y)-(-x)+2;}
	cout<<min(a,min(b,min(c,d)))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	ll dp[n+1]={0};
	rep(i,0,n)
	{
		cin>>a[i];
	}
	dp[0]=0;
	for(ll i=1;i<n;i++)
	{
		ll mn=LLONG_MAX;
		for(ll j=1;j<=k && i-j>=0;j++)
		{
			mn=min(mn,dp[i-j]+abs(a[i]-a[i-j]));
		}
		dp[i]=mn;
	}
	cout<<dp[n-1];
}
int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << std::endl; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; // OST: find_by_order, order_of_key
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//#pragma GCC optimize("Ofast")
//optimize("unroll-loops")
//target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//https://codeforces.com/blog/entry/60737
//gp_hash_table has far superior performance for insertions/deletions, while cc has marginally better performance for reads/writes
//gp_hash_table<int, int> table;
//const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
//struct chash {
//  int operator()(int x) const { return x ^ RANDOM; }
//};
//gp_hash_table<key, int, chash> table;
using ll = long long;

const int maxn = 2e5 + 5;
int h[maxn];
ll dp[maxn];
int n;
ll c;

ll cost(int i, int j) {
  return dp[j] + ll(h[i] - h[j])*(h[i] - h[j]) + c;
}

void solve() {
  vector<pair<int,int>> v;
  dp[n] = 0;
  v.emplace_back(n - 1, n);
  for (int i = n - 1; i >= 1; i--) {
    int opt = (lower_bound(v.rbegin(), v.rend(), make_pair(i, 0)))->second;
    dp[i] = cost(i, opt);
    while (!v.empty() && v.back().first < i && cost(v.back().first, i) <= cost(v.back().first, v.back().second)) {
      v.pop_back();
    }
    int l = 1, r = min(i - 1, v.back().first);
    int j = v.back().second;
    while (l <= r) {
      int mid = (l + r)/2;
      if (cost(mid, i) <= cost(mid, j)) l = mid + 1;
      else r = mid - 1;
    }
    if (l - 1 >= 1) {
      v.emplace_back(l - 1, i);
    }
  }
}

int main() {
  cin >> n >> c;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }

  solve();

  cout << dp[1] << '\n';

  return 0;
}

Measured memory_bytes: 4724
#include <algorithm>
#include <iostream>
#include <stdio.h>

#define MAX_N 200'001

using namespace std;

int64_t A[MAX_N];
int64_t B[MAX_N];

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

  A[0] = 0;
  B[0] = 0;
  for (int i = 0; i < N; ++i) {
    A[i + 1] += A[i];
  }
  for (int i = 0; i < M; ++i) {
    B[i + 1] += B[i];
  }

  int res = 0;
  int j = M;
  for (int i = 0; i <= N; ++i) {
    if (A[i] > K) {
      break;
    }
    while (B[j] > K - A[i]) {
      --j;
    }
    res = max(res, i + j);
  }
  printf("%d\n", res);
}

Measured memory_bytes: 6344
import java.util.Scanner;

/**
 * @author yousack
 */
public class Main {
    static Scanner in = new Scanner(System.in);
    
    public static void main(String[] args) {
        while (true) {
            int n = in.nextInt();
            int p = in.nextInt();
            if (n == 0 && p == 0) {
                break;
            } else {
                solve(n, p);
            }
        }
    }
    
    public static void solve(int n, int p) {
        int[] cand = new int[n];
        int tmpP = p;
        cand[0] += 1;
        tmpP -= 1;

        for (int i = 1; ; i = (i + 1) % n) {
            if (tmpP == 0) {
                tmpP = cand[i];
                cand[i] = 0;
            } else {
                tmpP -= 1;
                cand[i] += 1;
            }
            
            if (cand[i] == p) {
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 20224
BLACK = '#'
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
a = [x for x in a if x.count(BLACK) != 0]
H = len(a)
idx = []
for j in range(W):
    if [a[i][j] for i in range(H)].count(BLACK) == 0:
        idx.append(j)
a = [[x for j, x in enumerate(a[i]) if j not in idx] for i in range(H)]
for i in range(H):
    print(''.join(a[i]))

Measured memory_bytes: 39408
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

// Utility for binomial coefficient
ll ncr(ll n,ll k)
{
    if(n<k)
        return 0;
    ll C[n + 1][k + 1];
    ll i,j;
    for(i=0;i<=n;i++){
        for(j=0;j<=min(i,k);j++){
            if (j==0 || j==i)
                C[i][j]=1;
            else
                C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    return C[n][k];
}

void solve(){
	//code
	int n;
	cin>>n;
	if(n==0)
		cout<<1;
	else if(n==1)
		cout<<0;
}

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


Measured memory_bytes: 3636
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
#print(a)
asum=[0]
bsum=[0]
cnt=0
for i in range(n):
    cnt+=a[i]
    asum.append(cnt)
#    if cnt>k:
#        amx=i
#        break
#    amx=i
#print("amx=",amx)

cnt=0
for i in range(m):
    cnt+=b[i]
    bsum.append(cnt)
#    if cnt>k:
#        bmx=i
#        break
#    bmx=i
#print("bmx=",bmx)

ans=0
j=m
for i in range(n+1):
    c=k-asum[i]
#    print("i=",i)
#    print("c=",c)
    if c<0:
        continue
    while c<bsum[j] and j>0:
        j-=1
    ans=max(ans,i+j)
#    print("ans=",ans)
print(ans)


Measured memory_bytes: 47272
N,C=map(int,input().split())
Time=[[0]*(10**5+1) for c in range(C)]
for i in range(N):
  s,t,c=map(int,input().split())  
  Time[c-1][s-1:t] = [1]*(t-s+1)
Times=max(map(sum,zip(*Time)))
print(Times)

Measured memory_bytes: 28532
#include <stdio.h>

int a, b, aux=0, cont = 0;
char n[10];
bool flag;

int main(){
    scanf("%d %d", &a, &b);
    for(int i=a; i<= b; i++){
        int j= i, idx = 0;
        flag = true;
        while(j > 0){
            aux = j % 10;
            j=j/10;
            n[idx] = aux - '0';
            idx ++;
        }
        for(int j=0; j<idx/2; j++){
            if(n[j] != n[idx-j-1]){
                flag = false;
            }
        }
        if(flag)
            cont +=1;
    }
    printf("%d\n", cont);
}


Measured memory_bytes: 128
import math

N = int(input())

flag = True
currentt = 0
currentx = 0
currenty = 0

for i in range(N):
    tmp = input().split()
    nextt = int(tmp[0])
    nextx = int(tmp[1])
    nexty = int(tmp[2])
    
    subt = nextt - currentt
    subx = abs(nextx - currentx)
    suby = abs(nexty - currenty)

    if (subx + suby) > subt:
        flag = False
    
    tmp = subt - (subx + suby)
    if tmp % 2 == 1:
        flag = False

    currentt = nextt
    currentx = nextx
    currenty = nexty


if flag:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 3064
N, Q = map(int, input().split())
S = input()
S = S.replace('AC', 'ac')
ans = [0] * N
LR = [list(map(int, input().split())) for _ in range(Q)]

flag = False
count = 0
for num, s in enumerate(S):
    if flag is False:
        if s == 'a':
            flag = True
            ans[num] = count
            continue
        else:
            ans[num] = count
    else:
        if s == 'c':
            count += 2
            ans[num] = count
            flag = False
            continue
        else:
            ans[num] = count
            flag = False

for lr in LR:
    l, s = lr[0], lr[1]
    print((ans[s - 1] - ans[l - 1]) // 2)


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    int p[N],q[N];
    for(int i=0;i<N;i++) cin >> p[i];
    for(int j=0;j<N;j++) cin >> q[j];
    int ind[N];
    for(int i=0;i<N;i++) ind[i]=i+1;
    int P,Q;
    int ind1=0,ind2=0;
    int ans1,ans2;
    do{
        bool one,two;
        one=two=true;
        ind1++;ind2++;
        for(int i=0;i<N;i++){
            //cout << ind[i] << " ";
            if(ind[i]==p[i]) continue;
            one=false;
            break;
        }
        for(int i=0;i<N;i++){
            if(ind[i]==q[i]) continue;
            two=false;
            break;
        }
        if(one) ans1=ind1;
        if(two) ans2=ind2;
        //cout << endl;
    }while(next_permutation(ind,ind+N));
    cout << abs(ans1-ans2) << endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc122/tasks/abc122_b
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

/**
 * @statement
 * 入力で与えられる文字列をTとする
 * Tの"連続した"部分文字列(空文字列も含む）のうち，
 * 最も長いACGT文字列の長さを答えよ
 *
 * ACGT文字列とは，A,C,G,Tのみで構成された文字列である
 * ・ACGT文字列の例 : "A","AC","AACCGGTT"
 * ・非ACGT文字列の例 : "B", "AB"
 *
 * Tの先頭と末尾から0文字以上を取り去って得られる文字列
 * 例：ATCODER -> TCO
 * ATCODER
 * --TCO---
 * TCOは先頭から2文字，末尾から3文字取り去った文字列
 */
/**
 * @brief
 * SがACGT文字列かどうかの判定をする
 * @param S
 */
bool checkACGT(string S) {
    REP(i, (int)S.size()){
        if(S[i]!='A'&&S[i]!='C'&&S[i]!='G'&&S[i]!='T'){
            return false;
        }
    }
    return true;
}
void componentTest(){
    assert(checkACGT("A")==true);
    assert(checkACGT("C")==true);
    assert(checkACGT("G")==true);
    assert(checkACGT("T")==true);
    assert(checkACGT("AC")==true);
    assert(checkACGT("BBBB")==false);
    assert(checkACGT("BAGT")==false);
    assert(checkACGT("ACGTZ")==false);
}
int main()
{
    componentTest();
    string S;
    cin >> S;
    int res = INT_MIN;
    REP(i, (int)S.size()){
        REP(j, (int)S.size()-i+1){
            string tmp = S.substr(i, j);
            if( checkACGT(tmp) ){
                res = max(res, (int)tmp.size());
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
a,b = map(int, input().split())
sum = 0
if a == 1:
  sum = sum + 300000
elif a == 2:
  sum = sum + 200000
elif a == 3:
  sum = sum + 100000

if b == 1:
  sum = sum + 300000
elif b == 2:
  sum = sum + 200000
elif b == 3:
  sum = sum + 100000

if a == 1 and b == 1:
  sum = sum + 400000

print(sum)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] array = new int[num];
        for(int i = 0; i < num; i++){
            array[i] = sc.nextInt();
        }
        int count = 0;
        boolean flag = true;
        for(int i = 0; flag; i++){
            flag = false;
            for(int j = num - 1; j >= i + 1; j--){
                if(array[j - 1] > array[j]){
                    int temp = array[j - 1];
                    array[j - 1] = array[j];
                    array[j] = temp;
                    flag = true;
                    count++;
                }
            }
        }
        System.out.print(array[0]);
        for(int i = 1; i < num; i++){
            System.out.print(" " + array[i]);
        }
        System.out.println("\n" + count);
        
    }
}


Measured memory_bytes: 26392
import Data.List

main = do
    [a, b, x] <- map read . words <$> getLine :: IO [Double]
    print $ solve a b x

solve a b x | a*a*b < 2*x = (atan (2 * (a*a*b - x) / (a ** 3))) / pi * 180
            | otherwise = (atan (a*b*b / (2*x))) / pi * 180

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100000 + 100;
int N;
int main()
{
	scanf("%d", &N);
	int Sum_odd = 0, Sum_even = 0;
	int x;
	for (int i = 1; i <= N; ++i)
	{
		scanf("%d", &x);
		if (x & 1) Sum_odd ++;
		else Sum_even ++;
	}
	if (Sum_odd & 1)
	{
		if (Sum_even)cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
	else cout<<"YES"<<endl;
	return 0;
}

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

string s, t;
int len = 0;

int main() {
    cin>>s>>t;
    for(int i = 0; i < s.size(); i++)
        if(s[i] == t[i])
            len++;
    if(len == s.size())
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
int N, M;
int s, t;
vector<vector<int> > G;

int solve() {
    vector<vector<int> > dist(N, vector<int>(3, -1));
    dist[s][0] = 0;
    queue<pair<int, int> > q;
    q.push(make_pair(s, 0));
    while(!q.empty()){
        int v = q.front().first;
        int party = q.front().second;
        q.pop();
        
        for(int i = 0; i < G[v].size(); i++){
            int np = (party + 1) % 3;
            if(dist[G[v][i]][np] == -1) {
                dist[G[v][i]][np] = dist[v][party] + 1;
                q.push(make_pair(G[v][i], np));
            }
        }
    }
    
    if(dist[t][0] == -1) return -1;
    return dist[t][0] / 3;
}

int main(void){
    // Your code here!
    cin >> N >> M;
    G.assign(N, vector<int>());
    
    for(int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
    }
    
    cin >> s  >> t;
    s--;
    t--;
    cout << solve() << endl;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359;
#define inf (1 << 21);
#define mod 1000000007;

int main() {
    string S; cin >> S;
    char first = S.at(0),second;
    if (first == '0') {
        second = '1';
    }
    else {
        second = '0';
    }
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S.at(i) != first) {
                ans++;
            }
        }
        else {
            if (S.at(i) != second) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        char n;
        cin >> n;

        if('A' <= n && n <= 'Z')
            cout << 'A';
        else
            cout << 'a';
    }
    
    return 0;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
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 reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


int N, M;
vector<int> a, b;
vector<vector<bool>> G;
vector<bool> seen;

void input(){
    cin >> N >> M;
    seen.resize(N, false);
    a.resize(M), b.resize(M);
    G.resize(N, vector<bool>(N, false));
    rep(i, M){
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
        G[a[i]][b[i]] = G[b[i]][a[i]] = true;
    }
}

void dfs(int i){
    seen[i] = true;
    rep(j, N) if(G[i][j]==true && seen[j]==false) dfs(j);
}

void solve(){
    int ans = 0;
    rep(i, M){
        G[a[i]][b[i]] = G[b[i]][a[i]] = false;

        rep(i, N) seen[i] = false;
        dfs(0);
        if(any_of(seen.begin(), seen.end(), [](auto val){ return !val; })) ++ans;

        G[a[i]][b[i]] = G[b[i]][a[i]] = true;
    }
    cout << ans << endl;
}

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

    input();
    solve();

    
    return 0;
}

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

using namespace std;

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);++(i))
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define ppb(x) pop_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  int n, m;
  ll a;
  priority_queue<ll,vector<ll>> q;
  fscanf(stdin, "%d%d ", &n, &m);
  REP(i,n) {
    fscanf(stdin, "%lld ", &a);
    q.push(a);
  }
  while (q.top() && m) {
    ll p = q.top(); q.pop();
    p /= 2;
    q.push(p);
    m--;
  }
  ll res = 0;
  while (q.size()) {
    res += q.top();
    q.pop();
  }
  fprintf(stdout, "%lld\n", res);
  return 0;
}


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

const int MAXN = 505;
const int MAXM = 505 * 505;

int n, p[MAXM], d[MAXN][MAXN];
bool v[MAXN][MAXN];
queue < pair <int, int> > q;

int di[] = {1, -1, 0, 0};
int dj[] = {0, 0, 1, -1};

int main(){
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	for(int j = 0; j < n; j++){
		d[i][j] = min(min(i + 1, n - i), min(j + 1, n - j));
		v[i][j] = true;
	}
	
	long long res = 0;
	for(int i = 0; i < n * n; i++){
		scanf("%d", &p[i]);
		p[i]--;
		
		int x = p[i] / n;
		int y = p[i] % n;
		
		d[x][y]--;
		v[x][y] = false;
		q.push(make_pair(x, y));
		res += d[x][y];
		
		while(!q.empty()){
			pair <int, int> t = q.front();
			q.pop();
			
			for(int dir = 0; dir < 4; dir++){
				int nx = t.first + di[dir];
				int ny = t.second + dj[dir];
				
				if(nx < 0 || nx >= n || ny < 0 || ny >= n)continue;
				
				if(d[t.first][t.second] + v[nx][ny] < d[nx][ny]){
					d[nx][ny]--;
					q.push(make_pair(nx, ny));
				}
			}
		}
	}
	printf("%lld\n", res);

	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min({a + c,a + d,b + c,b + d}) << '\n';
    return 0;   
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int b[3];
	scanf("%d%d%d",&b[0],&b[1],&b[2]);
	if(b[0]==1&&b[0]==b[1]||b[2]==1){
		printf("Open\n");
	}
	else{
		printf("Close\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,c;
  while(cin >> r >> c,r||c){
    int se[10][10000]={{}};
    int i,j,k;
    for(i=0;i<r;i++){
      for(j=0;j<c;j++){
	cin >> se[i][j];
      }
    }
    int o=0;
    for(i=0;i<1<<r;i++){
      int sum[10000]={};
      for(j=0;j<r;j++){
	if(i>>j&1){
	  for(k=0;k<c;k++){
	    if(se[j][k]==0) sum[k]++;
	  }
	}else{
	  for(k=0;k<c;k++){
	    if(se[j][k]==1) sum[k]++;
	  }
	}
      }
      j=0;
      for(k=0;k<c;k++)
	j+=max(sum[k],r-sum[k]);
      o=max(o,j);
    }
    
    cout << o << endl;
  }
  return 0;
}

Measured memory_bytes: 1596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll k, a, b;

int main() {
    cin >> k >> a >> b;
    if (a+2 < b) {
        if (k <= a-1) {
            cout << 1+k << endl;
        } else {
            k -= a-1;
            ll add = k%2;
            cout << a + (k/2) * (b-a) + add << endl;
        }
    } else {
        cout << 1+k << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	while (1) {
		int n;

		cin >> n;

		if (n == 0) {
			break;
		}

		int sum = 0, min = 1001, max = -1, temp;
		for (int i = 0; i < n; i++) {
			cin >> temp;

			sum += temp;

			if (min > temp) {
				min = temp;
			}
			if (max < temp) {
				max = temp;
			}
		}

		sum -= (min + max);

		cout << sum / (n - 2) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#include <cmath>
#include <bitset>
#include <string>
#include <queue>

using namespace std;

#define int long long

signed main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        mp[b] += a;
    }

    int total = 0;
    for(auto i = mp.begin(); i != mp.end(); i++) {
        int limit = i -> first;
        int time = i -> second;
        total += time;
        if(total > limit) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define pi              acos(-1)
#define ll              long long
#define ld              long double
#define gcd             __gcd
#define bitscount       __builtin_popcount
#define ff              first
#define ss              second
#define MAXX            1e18
#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL)
//__builtin_popcount()  -->  counts how many 1 s are in a binary represented integer
//accumulate() --> finds sum of an array of integers
using namespace std;
int main()
{
    unordered_map<string, ll> mp;
    ll n, i;
    cin>>n;
    string s;
    for(i=0; i<n; i++){
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, PP> PPP;
typedef pair<string, int > Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;

bool jewel[21][21];
bool can[21][21];
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int main(){
	int n, m;
	while(cin >> n&& n){
		memset(jewel, false, sizeof(jewel));
		memset(can, false, sizeof(can));
		for(int i = 0; i < n; i++){
			int x, y;
			cin >> x >> y;
			jewel[x][y] = true;
		}
		cin >> m;
		int c = 0;
		int x = 10;
		int y = 10;
		can[x][y] = true;
		for(int i = 0; i < m; i++){
			int d;
			int dire;
			char to;
			cin >> to >> d;
			if(to == 'N'){
				dire = 0;
			}else if(to == 'E'){
				dire = 1;
			}else if(to == 'S'){
				dire = 2;
			}else {
				dire = 3;
			}
			for(int j = 0; j < d; j++){
				x += dx[dire];
				y += dy[dire];
				can[x][y] = true;
			}
		}
		
		for(int i = 0; i <= 20; i++){
			for(int j = 0; j <= 20; j++) if(can[i][j] && jewel[i][j]) c++;
		}
		if(c == n) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
from collections import defaultdict

sys.setrecursionlimit(100000)
input = sys.stdin.readline

N = int(input())
G = defaultdict(list)
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append((v - 1, w))
    G[v - 1].append((u - 1, w))
res = [None] * N


def dfs(v, c):
    res[v] = c
    for u, w in G[v]:
        if res[u] is not None:
            continue
        if w % 2 == 0:
            dfs(u, c)
        else:
            dfs(u, 1 - c)


dfs(0, 0)
for x in res:
    print(x)


Measured memory_bytes: 88064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    ll r, g, b, n;
    cin >> r >> g >> b >> n;
    ll ans = 0;
    rep(i, 3001) rep(j, 3001){
        if(i*r + j*g <= n && (n - (i*r + j*g))%b == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.lang.Math;

class Main{
    public static void main(String[] args){
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(inputStreamReader);
        
        String str;
        int[] num;
        
        try {
            while(reader.ready()){
                str = reader.readLine();
                num = getNum(str);
                System.out.println(cntIntegers(num[0]));
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static int cntIntegers(int n) {
        int cnt = 0;

        for (int a = 0; a <= 9; a++) {
            for (int b = 0; b <= 9; b++) {
                for (int c = 0; c <= 9; c++) {
                    for (int d = 0; d <= 9; d++) {
                        if (a + b + c + d == n) {
                            cnt++;
                        }
                    }
                }
            }
        }

        return cnt;
    }

    private static int[] getNum(String str){
        String[] data = str.split(" "); 
        int[] num = new int[data.length];

        for (int i = 0; i < data.length; i++){
            num[i] = Integer.parseInt(data[i]);
        }
        return num;
    }

}


Measured memory_bytes: 24672
n = gets
array = gets.split.map(&:to_i)

array.sort!


def zikkou(array, p)
  array.inject(0) do |result, item|
    result + ((item - p) * (item - p))
  end
end


p = (array.first + array.last / 2)
ans = Float::INFINITY

if zikkou(array, p) < zikkou(array, p + 1)
  loop do
    if ans < tmp = zikkou(array, p)
      break
    else
      ans = tmp
      p -= 1
    end
  end
else
  loop do
    if ans < tmp = zikkou(array, p)
      break
    else
      ans = tmp
      p += 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
def main
  str = gets.strip
  until str.empty?
    if str.start_with?('eraser')
      str.slice!(0, 6)
    elsif str.start_with?('erase')
      str.slice!(0, 5)
    elsif str.start_with?('dreamera')
      str.slice!(0, 5)
    elsif str.start_with?('dreamer')
      str.slice!(0, 7)
    elsif str.start_with?('dream')
      str.slice!(0, 5)
    else
      puts 'NO'
      return
    end
  end
  puts 'YES'
end

main


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

int main(){
	/*input*/
	int a, b;	cin >> a >> b;
	/*calculation*/
	bool isok = false;	//true:Yay! false::(
	if(a <= 8 && b <= 8){
		isok = true;
	}else{
		isok = false;
	}
	/*output*/
	if(isok){
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
ball = list(map(int, input().split()))
ball.sort(reverse = True)
ok = {}
for x in ball:
    if x in ok:
        ok[x] += 1
    else:
        ok[x] = 1
ans = 0
for x in ball:
    if ok[x] != 0:
        y = 2**(x.bit_length()) - x
        if y in ok:
            if ok[y] != 0:
                if y == x and ok[y] == 1: 
                    continue
                ans += 1
                ok[x] -= 1
                ok[y] -= 1
print(ans)



Measured memory_bytes: 33696
C=str(input())
abc=['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']
print(abc[abc.index(C)+1])


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 1000010

using namespace std;

int a, b, c, x;

int main()
{
	cin >> a >> b >> c >> x;
	
	int ans = 0;
	for(int i = 0; i <= a; i++)
		for(int h = 0; h <= b; h++)
			for(int j = 0; j <= c; j++)
				if(i*500+h*100+j*50 == x) ans++;
	
	cout << ans;
}

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

long long N, C, K;
vector<long long> T;

int main(){
  cin >> N >> C >> K;
  T.resize(N);
  for(int i = 0; i < N; ++i) cin >> T[i];
  sort(T.begin(), T.end());
  long long num = 0;
  int res = 1;
  int ans = 1;
  for(int i = 1; i < N; ++i){
    if(res < C && T[i] - T[i-1] + num <= K){
      num += T[i] - T[i-1];
      res++;
    }
    else{
      res = 1;
      num = 0;
      ans++;
    }
  }
  cout << ans << endl;
}
        

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main() {
	string S;
	cin >> S;

	char A = S[2];
	char B = S[3];
	char C = S[4];
	char D = S[5];
	
	if (A == B && C == D) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
     
    int main(void){
        int X;
        scanf("%d", &X);
        if( (X<-40) || (X> 40) ){
          printf("input temperature is out of range!\n");
          return 1;
        }else if( X < 30 ){
          printf("No");
        }else{
          printf("Yes");
        }
        return 0;
    }

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
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; }
//end

template<unsigned mod=1000000>struct mint {
   unsigned val;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=ll(val)*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=ll(val)*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
}; using Mint=mint<>;
struct factorial {
   vector<Mint> Fact,Finv,Inv;
   factorial(int maxx){
      Fact.resize(maxx); Finv.resize(maxx); Inv.resize(maxx);
      Fact[0]=Fact[1]=Finv[0]=Finv[1]=Inv[1]=1; unsigned mod=Mint::get_mod();
      rep(i,2,maxx){
         Fact[i]=Fact[i-1]*i;
         Inv[i]=Inv[mod%i]*(mod-mod/i);
         Finv[i]=Finv[i-1]*Inv[i];
      }
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint inv(int n){return Inv[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

int n; vector<int> g[1010];
Mint C[1010][1010];
int cnt[1010]; Mint dp[1010];
void dfs(int v){
   dp[v]=1; cnt[v]=0;
   for(int nxt:g[v]){
      dfs(nxt);
      cnt[v]+=cnt[nxt]+1;
      dp[v]*=C[cnt[v]][cnt[nxt]+1]*dp[nxt];
   }
}

int main(){
   rep(i,0,1010){
      C[i][0]=C[i][i]=1;
      rep(j,1,i){
         C[i][j]=C[i-1][j-1]+C[i-1][j];
      }
   }
   cin>>n; bool used[1010]={};
   rep(_,0,n-1){
      int x,y; cin>>x>>y;
      x--; y--; used[y]=1;
      g[x].push_back(y);
   }
   rep(i,0,n)if(!used[i]){
      dfs(i);
      cout<<dp[i].val<<endl;
   }
   return 0;
}


Measured memory_bytes: 7200