akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

const mod = 1000000007

func mpow(x,n int) int {
	a := 1
	for ;; {
		if n&1 == 1 {
			a = a*x %mod
		}
		x = x*x %mod
		n = n >> 1
		if n == 0 {
			break
		}
	}
	return a
}

func perm(a,b int, fac,facp []int) int {
	if a == 0 && b == 0 {
		return 1
	}
	return fac[a]*facp[a-b]%mod
}

func dfs(pre,now,k int, t [][]int, fac,facp []int) int {
	color := k-2
	n := len(t[now])
	if now == 0 {
		color++
	} else {
		n--
	}

	if n > color {
		return 0
	}


	a := perm(color,n,fac,facp)

	for _, e := range t[now] {
		if e == pre {
			continue
		}

		a = a*dfs(now,e,k,t,fac,facp)%mod
	}

	return a

}

func main() {
	sc.Split(bufio.ScanWords)
	
	n,k := scanInt(),scanInt()
	t := make([][]int,n)
	for i := 0; i < n-1; i++ {
		a,b := scanInt()-1,scanInt()-1
		t[a] = append(t[a],b)
		t[b] = append(t[b],a)
	}

	fac := make([]int,k+1) // n!
	facp := make([]int,k+1) // n!^{mod-2}
	fac[0] = 1
	facp[0] = 1
	for i := 0; i < k; i++ {
		fac[i+1] = fac[i]*(i+1)%mod
		facp[i+1] = facp[i]*mpow(i+1,mod-2) %mod
	}

	fmt.Println(k*dfs(0,0,k,t,fac,facp)%mod)


}


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

int main(void){
	int A,B,C;
	cin>>A>>B>>C;

	int ans = (C - (A - B) );
	if(ans < 0){
		cout<< 0 << endl;
	}else{
		cout<< ans << endl;
	}
	return 0;
}


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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int q; cin >> q;
    while (q--) {
        int l, m, r;
        cin >> l >> m >> r;
        auto b = v.begin();
        swap_ranges(b + l, b + m, b + r);
    }
    rep(i, n) {
        if (i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}



Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
int t[200],a[200],b[200],c[200],dp[201][201],D,N;
int solve(int today,int yd){ //今日の日付, 昨日の服の番号
  if(today == D) return 0;
  if(dp[today][yd]) return dp[today][yd];
  int res = 0;
  for(int i = 0 ; i < N ; i++ ){
    if( t[today] >= a[i] && t[today] <= b[i] ){
      res = max(res,solve(today+1,i) + (today?abs(c[i]-c[yd]):0));
    }
  }
  return dp[today][yd] = res;
}
int main(){
  cin >> D >> N;
  rep(i,D) cin >> t[i];
  rep(i,N) cin >> a[i] >> b[i] >> c[i];
  cout << solve(0,0) << endl;
}

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

int main()
{
	int c1=0,c2=0,c3=0,c0=0;
	int n;
	string s;
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="AC")
		c0++;
		else if(s=="WA")
		c1++;
		else if(s=="TLE")
		c2++;
		else
		c3++;
		
	}
	
cout<<"AC x "<<c0<<endl
    <<"WA x "<<c1<<endl
    <<"TLE x "<<c2<<endl
    <<"RE x "<<c3<<endl; 
	return 0;
}

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

int main()
{
	int h, w;
	cin >> h >> w;
	vector<vector<char>> s(h+2, vector<char>(w+2));
	int i, j;
	for(i = 0; i < h+2; i++)
	{
		for(j = 0; j < w+2; j++)
		{
			if(i == 0 || i == h+1 || j == 0 || j == w+1)
			{
				s.at(i).at(j) = '.';
			}
			else
			{
				cin >> s.at(i).at(j);
			}
		}
	}
	bool clear = true;
	for(i = 0; i < h; i++)
	{
		for(j = 0; j < w; j++)
		{
			if(s.at(i).at(j) == '#')
			{
				if(s.at(i-1).at(j) == '.' && s.at(i+1).at(j) == '.' && s.at(i).at(j-1) == '.' && s.at(i).at(j+1) == '.')
				{
					clear = false;
				}
			}
		}
	}
	if(clear) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int head;
int tail;

typedef struct process{
  char name[10];
  int time;
}Process;

Process Q[MAX_SIZE];

void initialize();
bool isEmpty();
bool isFull();
void enqueue(Process NewElement);
Process dequeue();


int main()
{
    initialize();

    int n, q;
    cin >> n >> q;
    rep(i, n) cin >> Q[i].name >> Q[i].time;

    head = 0;
    tail = n;

    int totaltime = 0;

    while(!(isEmpty())){
        Process nowstep = dequeue();
        if (nowstep.time > q){
            totaltime += q;
            nowstep.time -= q;
            enqueue(nowstep);
        }else{
            totaltime += nowstep.time;
            cout << nowstep.name << " " << totaltime << endl;
        }
    }

    return 0;
}

void initialize() //スタックの初期化
{
    head = tail = 0;
    return;
}

bool isEmpty() //スタックが空の時Trueを返す
{
    return head == tail;
}

bool isFull() //スタックが満タンの時Trueを返す
{
    return head == (tail + 1) % MAX_SIZE; // headが5, MAX_SIZEが100ならtailは104のとき。"tail == head + MAX_SIZE - 1" でも良さそう。
}

void enqueue(Process NewElement) //末尾に要素を追加
{
    if (isFull()){
        printf("オーバーフロー\n");
        return;
    }
    Q[tail] = NewElement;
    if (tail + 1 == MAX_SIZE){
        tail = 0;
    }else{
        ++tail;
    }

    return;
}

Process dequeue() //要素を先頭から1つ取り出す
{
    if (isEmpty()){
        printf("アンダーフロー\n");//本当はここで例外処理をしたい
    }

    Process ans = Q[head];

    if (head + 1 == MAX_SIZE){
        head = 0;
    }else{
        ++head;
    }

    return ans;
}


Measured memory_bytes: 4572
#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 k , s; cin >> k >> s;
    int res = 0;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            int z = s - x - y;
            if(z <= k && z >= 0) res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=std::numeric_limits<int>::max(); 

int main()
{
	int n,i,j,k;
	cin>>n>>k;
	int h[n+1];
	int dp[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>h[i];
		dp[i]=MAXN;
	}
		

	dp[0]=0;
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(i=3;i<=n;i++)
		for(j=1;j<=min(i,k) && i!=j;j++)
			dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]),dp[i]);
	
	cout<<dp[n]<<endl;
	
	
}

Measured memory_bytes: 1024
In = [int(i) for i in input()]
flag = 0
for op1 in ["+","-"]:
    for op2 in ["+","-"]:
        for op3 in ["+","-"]:
            if eval("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}".format(In[3]))==7:
                print("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}=7".format(In[3]))
                exit()

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**6)
a,b,h,m = map(int, input().split())

import math

h_rad = 30*(h+m/60)
m_rad = 6*m
diff_rad = min(abs(h_rad-m_rad),360-abs(h_rad-m_rad))
cos = math.cos(math.radians(diff_rad))

ans = math.sqrt(a*a+b*b-2*a*b*cos)
print(ans)

Measured memory_bytes: 9512
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	LLI n, k;
	cin >> n >> k;
	vector<LLI> a(n);
	REP(i, n)
	{
		cin >> a[i];
		a[i]--;
	}


	vector<LLI> v(n);

	LLI cnt = 1;
	int pos = a[0];
	LLI start = 0;
	LLI loop = 0;
	while (pos != 0)
	{
		if (v[pos] != 0)break;
		v[pos] = cnt;
		pos = a[pos];
		cnt++;
	}
	start = pos;
	loop = cnt - v[pos];

	REP(i, n)
	{
		if (v[i] == k)
		{
			cout << i + 1;
			return 0;
		}
	}


	k = (k - v[start]) % loop;
	pos = start;
	REP(i, k)
	{
		pos = a[pos];
	}
	cout << pos + 1;
	return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;


int main() {
	int N, M;
	priority_queue<int> A;
	priority_queue<pair<int,int>> B;
	int i,j;
	cin >> N >> M;
	rep(i, N) {
		int tmp;
		cin >> tmp;
		A.push(-tmp);
	}
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		B.push(make_pair(b, a));
	}
	rep(i, M) {
		int a, b;
		b = B.top().first;
		a = B.top().second;
		rep(j, a) {
			int x = A.top();
			if (x > -b) {
				A.pop();
				x = -b;
				A.push(x);
			}
			else {
				long long ans = 0;
				rep(i, N) {
					ans -= A.top();
					A.pop();
				}

				cout << ans;
				return 0;


			}

		}
		B.pop();


	}
	long long ans = 0;
	rep(i, N) {
		ans -= A.top();
		A.pop();		
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 1784
import math
b = 0
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    grid.append(array)

for box1 in grid:
    x1 = box1[0]
    y1 = box1[1]

    for box2 in grid:
        x2 = box2[0]
        y2 = box2[1]
        a = (x1 - x2) ** 2 + (y1 - y2) ** 2
        
        b +=math.sqrt(a)
print(b/N)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int K,N;
    cin >> N >> K;
    vector<ll> p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }

    ll sum=0;
    for(int i=0;i<K;i++){
        sum+=(p[i]+1);
    }

    ll sum_best=sum;
    for(int i=K;i<N;i++){
        sum+=(ll)(p[i]+1);
        sum-=(ll)(p[i-K]+1);
        sum_best=max(sum,sum_best);
    }
    printf("%.7f",(double)sum_best/(double)2);


}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
 
class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    double m = sc.nextLong();
    long result = (long)Math.round(m*100);
    
    result = result*n/100;
    
    System.out.println(result);
  }
}

Measured memory_bytes: 35820
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);
const int zero = 12826;

#define l_ength size

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

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bitset<zero*2> dp[88][88];
int a[88][88];

int main(void){
	int h,w,i,j,k,b;
	cin >> h >> w;
	for(k=0; k<2; ++k){
		for(i=0; i<h; ++i){
			for(j=0; j<w; ++j){
				cin >> b;
				a[i][j] += b;
				a[i][j] = (k?((int)abs(a[i][j])):(-a[i][j]));
			}
		}
	}
	dp[0][0].set(zero+a[0][0]);
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			dp[i+1][j] |= (dp[i][j]<<a[i+1][j]);
			dp[i+1][j] |= (dp[i][j]>>a[i+1][j]);
			dp[i][j+1] |= (dp[i][j]<<a[i][j+1]);
			dp[i][j+1] |= (dp[i][j]>>a[i][j+1]);
		}
	}
	--h; --w;
	for(k=0; k<zero; ++k){
		if(dp[h][w][zero+k] || dp[h][w][zero-k]){
			cout << k << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 22656
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
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 lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb(s) push_back(s)
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vvpl=vector<vector<pl>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }

ll PS(ll x) {
  ll c=1;
  rep(i,x) {
    c=c*2;
  }
  return c;
}


int main() {
char x;
  cin >>x;
  if((x=='a') ||(x=='b') ||(x=='c') ||(x=='d') ||(x=='e')||
    (x=='f') ||(x=='g') ||(x=='h') ||(x=='i') ||(x=='j') ||
    (x=='k') ||(x=='l') ||(x=='m') ||(x=='n') ||(x=='o') ||
    (x=='p') ||(x=='q')||(x=='r') ||(x=='s')||(x=='t') ||
    (x=='u') ||(x=='v') ||(x=='w') ||(x=='x') ||(x=='y') ||(x=='z')) {
cout<<"a"<<endl;
  }
  else {
cout<<"A"<<endl;
  }

}



Measured memory_bytes: 3556
n = int(input())
x = 0

for i in range(1, n+1):
    if   i % 3  == 0:
        print("", i,end="")
    else:
        x = i
        while (x):
            if x % 10 == 3:
                print("", i,end="")
                break
            x //= 10
print()


Measured memory_bytes: 6164
/*
verified on 2020/3/1
http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4221790
*/

#include <iostream>
#include <vector>
#include <queue>
#include <string>

using namespace std;

using ll = long long;


/* snippet starts */

#include <limits>

// 各点への最短経路 dijkstra
template<typename dist_t>
class Dijkstra {
    using elem_t = pair<dist_t, int>;

    int n, // 頂点数
        input_edge_num; // 辺の数

    bool directed,           // 有向グラフかどうか
         edge_length_input,  // 入力で辺の長さが与えられるかどうか(ない場合全て1に)
         zero_indexed_input; // 入力で与えられる頂点が0-indexedかどうか
    vector<elem_t> *G;

public:

    static const dist_t INF;

    Dijkstra(int _n) : n(_n), G(new vector<elem_t>[(size_t)n]) {}

    Dijkstra(int _n, vector<elem_t>* &_G) : n(_n), G(_G) {}

    inline void add_edge(int from, int to, dist_t dist=1) {
        G[from].push_back(elem_t{dist, to});
    }

    struct result {
        result(int _n, int k) : n(_n), d(new dist_t[(size_t)_n]) {
            fill(d, d+n, INF); 
            d[k] = 0;
        }
        auto &operator[](int i) { return d[i]; } 
        auto begin() { return d; }
        auto end()   { return d + n; }
        operator dist_t*() { return d; } // dist_t* へのキャスト

        bool unreachable(int i) { return d[i] == INF; }  // 視点から到達不可能かどうか
    private:
        const int n;
        dist_t *d;
    };

    inline result operator()(int start) {
        result d(n, start);

        priority_queue< elem_t, vector<elem_t>, greater<elem_t> > que;
        que.push(elem_t{0, start});

        while (!que.empty()) {
            elem_t p = que.top(); que.pop();
            int now = p.second;
            if (d[now] < p.first) continue;

            for (auto &g:G[now]) {
                int to = g.second;
                dist_t newd = g.first + d[now];

                if (d[to] > newd) {
                    d[to] = newd;
                    que.push(elem_t(d[to], to));
                }
            }
        }
        return d;
    }

    auto &operator[](int i) { return G[i]; } 
    auto begin() { return G; }
    auto end()   { return G + n; }
};

template<typename dist_t>
const dist_t Dijkstra<dist_t>::INF = numeric_limits<dist_t>::max();

/* Constructers
 *
 * Dijkstra(int _n) 
 * Dijkstra(int _n, vector<elem_t>* &_G)
 */

/* snippet ends */

int main() {
    int n, m, s;
    cin >> n >> m >> s;
    Dijkstra<ll> dijk(n);
    for (int i=0, u, v, d; i<m; i++) {
        cin >> u >> v >> d;
        dijk.add_edge(u, v, d);
    }
    for (auto &di:dijk(s)) cout << (di < Dijkstra<ll>::INF ? to_string(di) : "INF") << '\n';
    return 0;
}


Measured memory_bytes: 19400
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  string ans="Yes";
  if(N%2==1) {
    ans="No";
  }
  
  for(int i=0;i<N/2;i++) {
    if(S.at(i)!=S.at(N/2+i)) {
      ans="No";
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}
    

Measured memory_bytes: 256
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if v!=w:
    c=(max(a,b)-min(a,b))/(v-w)
else:
    c=-1

if 0<=c<=t:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9132
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main()
{
ll ans=0,n,x;
ll mo=1000000007;
cin >> n>>x;
 
ll table[n]={};
rep(i,n) {
    cin >> table[i];
}
sort(table, table + n, greater<ll>());
//cout << 'b' ;
//ll dp[n+1][x+1];
vector< vector<int> > dp(n+1, vector<int>(x+1,0) );
//cout << 'b' ;
dp[0][x]=1;

rep(i,n){rep(j,x+1){
    if(dp[i][j]!=0){
        dp[i+1][j]+=(dp[i][j]*(n-i-1))%mo;
        dp[i+1][j]=(dp[i+1][j])%mo;
        dp[i+1][j%table[i]]+=dp[i][j];
        dp[i+1][j%table[i]]=(dp[i+1][j%table[i]])%mo;
    }
      //cout << 'a' ;
}
/* for (int d = 0; d < x; ++d) {
    cout << dp[i][d] << " ";
    }cout  << endl; */
  
}
/* for (int d = 0; d < x; ++d) {
    cout << dp[n][d] << " ";
    }cout  << endl; */

rep(i,x){
    ans=(ans+(i)*dp[n][i])%mo;
}
cout << ans << endl;
return 0;
}





Measured memory_bytes: 79360
a,b = map(int,input().split())
p = list(map(int,input().split()))
ans = sum(p[:b])
count = ans
for i in range(1,a-b+1):
  count = count-p[i-1]+p[i+b-1]
  if count > ans:
    ans = count
print((ans+b)/2)
  

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  string a, b;cin>>a>>b;
  if(a.size()!=b.size()){
    if(a.size()>b.size())cout << "GREATER" << endl;
    else cout << "LESS" << endl;
  }else{
    for(int i=0;i<a.size();i++){
      if(a[i]>b[i]){cout<<"GREATER"<<endl;break;}
      else if(a[i]<b[i]){cout<<"LESS"<<endl;break;}
      else if(i==a.size()-1){cout<<"EQUAL"<<endl;break;}
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll N=1e5+5,M=1e6+5;
const ll INF=2147483647;
struct node{
    ll u,v,w,nxt;
}edge[M];
ll head[N],mcnt;
void nosolution(){
    puts("0");
    exit(0);
}
void add_edge(ll u,ll v,ll w){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].w=w;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
ll vmin=0,vmax=INF,qinding=-1;
ll val[N][2];
bool vis[N];
void dfs(ll u){
    for(ll i=head[u];i;i=edge[i].nxt){
        ll v=edge[i].v,w=edge[i].w;
        if(vis[v]){
            if(val[u][1]+val[v][1]==0){
                if(val[u][0]+val[v][0]!=w)
                    nosolution();
            }
            if(val[u][1]+val[v][1]==2){
                ll cnt=w-val[u][0]-val[v][0];
                if(cnt<=0||cnt&1)
                    nosolution();
                cnt/=2;
                if(qinding==-1||qinding==cnt)
                    qinding=cnt;
                else
                    nosolution();
            }
            if(val[u][1]+val[v][1]==-2){
                ll cnt=val[u][0]+val[v][0]-w;
                if(cnt<=0||cnt&1)
                    nosolution();
                cnt/=2;
                if(qinding==-1||qinding==cnt)
                    qinding=cnt;
                else
                    nosolution();
            }
        }
        else{
            vis[v]=1;
            val[v][0]=w-val[u][0];
            val[v][1]=-val[u][1];
            if(val[v][1]>0)
                vmin=max(vmin,-val[v][0]);
            else
                vmax=min(vmax,val[v][0]);
            dfs(v);
        }
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(ll i=1;i<=m;i++){
        ll u,v,w;
        scanf("%lld%lld%lld",&u,&v,&w);
        add_edge(u,v,w);
        add_edge(v,u,w);
    }
    vis[1]=1;
    val[1][0]=0,val[1][1]=1;
    dfs(1);
    vmin++,vmax--;
    if(qinding==-1)
        printf("%lld\n",max(vmax-vmin+1,0ll));
    else
        if(qinding>=vmin&&qinding<=vmax)
            puts("1");
        else
            puts("0");
}


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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
  return 0;
}

Measured memory_bytes: 1176
X = int(input())

if X <= 599:
    print(8)
elif X >= 600 and X<= 799:
    print(7)
elif X >= 800 and X<= 999:
    print(6)
elif X >= 1000 and X<= 1199:
    print(5)
elif X >= 1200 and X<= 1399:
    print(4)
elif X >= 1400 and X<= 1599:
    print(3)
elif X >= 1600 and X<= 1799:
    print(2)
else:
    print(1)


Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#define N 205
using namespace std;

int n, m, ans, M = 1e9, d[N][N];
char a[N][N];
int main()
{
	int i, j;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		scanf ("%s", &a[i]);
	}
	d[0][0] = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (i == 0 && j == 0) continue;
			d[i][j] = M;
			if (i > 0) d[i][j] = min(d[i - 1][j] + (a[i - 1][j] != a[i][j]), d[i][j]);
			if (j > 0) d[i][j] = min(d[i][j - 1] + (a[i][j - 1] != a[i][j]), d[i][j]);
		}
	}
	ans = d[n - 1][m - 1] + 1;
	if (a[0][0] == '#') ans++;
	cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define FF first
#define SS second
#define pii pair<int,int>
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
#define mp make_pair
#define Mod 1000000007
typedef long long int ll;

vector<int> dp(100001, 0);
vector<int> ans(100001, 0);

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// #endif

	// dp[i][j] ->  i for string s and j for string t

	string s, t;
	string ans = "";

	cin >> s >> t;
	int n = s.length(), m = t.length();
	int i, j;

	vector< vector<pii> > dp(n+1, vector<pii>(m+1));

	for(i = 0; i <= n; i++)
		dp[i][0] = {0, 0};
	for(i = 0; i <= m; i++)
		dp[0][i] = {0, 0};

	for(i = 1; i <= n; i++){
		for(j = 1; j <= m; j++){
			if(s[i-1] == t[j-1])
				dp[i][j] = {1, dp[i-1][j-1].se+1};
			else
				dp[i][j] = mp(0, max(dp[i][j-1].se, dp[i-1][j].se));
			// cout<<dp[i][j].se<<" ";
		}
		// cout<<"\n";
	}

	// cout<<dp[n][m]<<"\n";
	i = n, j = m;
	while(i > 0 && j > 0){
		if(dp[i][j].se == dp[i-1][j-1].se+1 && dp[i][j].fi == 1){
			// cout<<j<<"\n";
			ans += t[j-1];
			i -= 1;
			j -= 1;
		}
		else if(dp[i][j].se == dp[i-1][j].se && dp[i][j].fi == 0)
			i -= 1;
		else if(dp[i][j].se == dp[i][j-1].se && dp[i][j].fi == 0)
			j -= 1;
	}

	// cout<<reverse(ans.begin(), ans.end());
	// cout<<reverse(ans.begin(), ans.end())<<"\n";
	for(i = ans.length()-1 ; i >= 0; i--)
		cout<<ans[i];
	cout<<"\n";

}  

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

using namespace std;

int main() {
    int N; cin>>N;
    vector<int> B(N);

    for (int i=0;i<N-1;i++) {
        cin >> B[i];
        // cout << B[i] << " ";
    }
    // cout << endl;

    vector<int> A(N);
    A[0] = B[0];
    B[N-1] = 10e5+1;
    for (int i=1;i<N;i++) {
        A[i] = min(B[i-1], B[i]);
    }

    int sum=0;
    for (int i=0;i<N;i++) {
        // cout << A[i] << " ";
        sum += A[i];
    }
    // cout << endl;

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int a[20000];
int main(){
    int n,s = 0;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d",&a[i]);
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;a[i] % 2 == 0 ;j++){
            s++;
            a[i] /= 2;
        }
    }
    printf("%d\n",s);
    
}

Measured memory_bytes: 256
/*
 *    author:  gantheory
 *    created: 2018-06-03 22:38:29
 */
#include <bits/stdc++.h>

using namespace std;

// Mod Integer {{{
const int MOD = 998244353;
template <int _MOD>
class ModInt {
 public:
  static const auto MOD = _MOD;
  template <class T>
  using integral_only = typename enable_if<is_integral<T>::value>::type;

  int x;
  constexpr ModInt() : x() {}
  template <class T, integral_only<T>* = nullptr>
  ModInt(T _x) {
    x = _x % MOD;
    if (x < 0) x += MOD;
  }
  ModInt operator-() const { return {x == 0 ? 0 : MOD - x}; }
  ModInt& operator+=(ModInt rhs) {
    x += rhs.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }
  ModInt& operator-=(ModInt rhs) {
    x -= rhs.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(ModInt rhs) {
    x = (long long)x * rhs.x % MOD;
    return *this;
  }
  ModInt& operator/=(ModInt rhs) { return *this *= rhs.inv(); }
  ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
  ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
  ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
  ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
  ModInt inv() const {
    // should work for non-prime MOD if gcd(x, MOD) = 1
    int a = x, b = MOD, u = 1, v = 0;
    while (b != 0) {
      int t = a / b;
      a -= t * b;
      u -= t * v;
      swap(a, b);
      swap(u, v);
    }
    return u;
  }
  template <class T, integral_only<T>* = nullptr>
  ModInt pow(T e) {
    ModInt r = 1, p = *this;
    while (e) {
      if (e & 1) r *= p;
      p *= p;
      e >>= 1;
    }
    return r;
  }
  bool operator==(ModInt rhs) const { return x == rhs.x; }
  bool operator!=(ModInt rhs) const { return x != rhs.x; }
  bool operator<(ModInt rhs) const { return x < rhs.x; }
  bool operator<=(ModInt rhs) const { return x <= rhs.x; }
  bool operator>(ModInt rhs) const { return x > rhs.x; }
  bool operator>=(ModInt rhs) const { return x >= rhs.x; }
  friend string to_string(ModInt i) { return to_string(i.x); }
  friend ostream& operator<<(ostream& os, ModInt o) { return os << o.x; }
  friend istream& operator>>(istream& is, ModInt& i) {
    return is >> i.x;
    i.x %= MOD;
    if (i.x < 0) i.x += MOD;
  }
};
using mint = ModInt<MOD>;
// }}}

const int N = 3e5 + 10;

long long n, a, b, k;
mint f[N];

mint C(int x, int y) { return f[x] / f[y] / f[x - y]; }
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  cin >> n >> a >> b >> k;

  f[0] = 1;
  for (int i = 1; i <= n; ++i) f[i] = f[i - 1] * i;

  mint ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (a * i > k) continue;
    long long res = k - a * i;
    if (res % b) continue;
    res /= b;
    if (res > n) continue;
    ans += C(n, i) * C(n, res);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1408
/*
 * D.cpp
 *
 *  Created on: 2012-8-25
 *      Author: Administrator
 */
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int n, m;
int h, w;
struct page {
	string name;
	int bn;
	int pt[105];
	int x1[105];
	int x2[105];
	int y1[105];
	int y2[105];
} site[105];
int buffer[10000];
string its[105];
int bfend;
int pointer;

int main() {
	while (cin >> n && n) {
//		memset(site, 0, sizeof(site));
		map<string, int> ma;
		cin >> h >> w;
		int cp = 1;
		string name;
		int b;
		while (n--) {
			cin >> name >> b;
			if (ma[name] == 0) {
				its[cp] = name;
				ma[name] = cp++;
			}
			int currpage = ma[name];
//			cout << "currpage " << currpage << endl;
			site[currpage].bn = b;
//			cout << "b " << b << endl;
			int x1, y1, x2, y2;
			string pp;
			for (int i = 0; i != b; i++) {
				cin >> x1 >> y1 >> x2 >> y2 >> pp;
//				cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<pp<<endl;
				if (ma[pp] == 0) {
					its[cp] = pp;
					ma[pp] = cp++;
				}
				int ipp = ma[pp];
				site[currpage].x1[i] = x1;
				site[currpage].x2[i] = x2;
				site[currpage].y1[i] = y1;
				site[currpage].y2[i] = y2;
				site[currpage].pt[i] = ipp;
			}
		}
		pointer = 0;
		bfend = 0;
		buffer[pointer] = 1;
		cin >> m;
		string command;
		while (m--) {
//			cout<<pointer<<endl;
			cin >> command;
			if (command == "show") {
				cout << its[buffer[pointer]] << endl;
			}
			if (command == "forward") {
				if (pointer < bfend)
					pointer++;
			}
			if (command == "back") {
				if (pointer > 0)
					pointer--;
			}
			if (command == "click") {
				int x, y;
				cin >> x >> y;
				int page = buffer[pointer];
				int nextpage;
				bool flag = false;
				for (int i = 0; i != site[page].bn; i++) {
					int x1 = site[page].x1[i];
					int x2 = site[page].x2[i];
					int y1 = site[page].y1[i];
					int y2 = site[page].y2[i];
					if (x >= x1 && x <= x2 && y >= y1 && y <= y2) {
						nextpage = site[page].pt[i];
						flag = true;
						break;
					}
				}
				if (flag) {
					bfend = pointer + 1;
					pointer++;
					buffer[pointer] = nextpage;
				}
			}
		}
	}
}

Measured memory_bytes: 1440
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-ffloat-store")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define endl "\n"
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define inf  1e18
#define ps(x,y)   fixed<<setprecision(y)<<x
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
 int n;
  cin >> n;
  vector < int > a (n), b (n);
  for (auto &i : a) cin >> i;
  for (auto &i : b) cin >> i;
 
  reverse (b.begin(), b.end());
  int l = -1, r = -2;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i]) {
      if (l == -1) l = r = i;
      else r++;
    }
  }
 
  if (l == -1) {
    cout << "Yes\n";
    for (auto i : b) cout << i << " ";
    cout << '\n';
    return 0;
  }
 
  int p = lower_bound (a.begin(), a.end(), a[l]) - a.begin() - 1;
  int q = upper_bound (a.begin(), a.end(), a[l]) - a.begin();
  int lo = 0, hi = n - 1, k = n;
  while (lo <= hi) {
    int mid = (hi - lo) / 2 + lo;
    if (b[mid] < a[l]) {
      k = mid;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  q = max (q, k);
  k = -1;
  lo = 0, hi = n - 1;
  while (lo <= hi) {
    int mid = (hi - lo) / 2 + lo;
    if (b[mid] > a[l]) {
      k = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  p = min (p, k);
  int idx = 0;
  if (p < 0) idx = q;
  for (int i = l; i <= r; i++) {
    if (idx == n) {
      cout << "No\n";
      return 0;
    }
    swap (b[i], b[idx]);
    idx++;
    if (idx == p + 1) idx = q;
  }
 
  cout << "Yes\n";
  for (auto i : b) cout << i << " ";
  cout << '\n';
return 0;   
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int factorial(int n);
int factorial(int n)
{
    if(n==1)
    {
        return 1;
    }
    else
    {
        return n*factorial(n-1);
    }

}

bool is_prime(ll n) {
    // Assumes that n is a positive natural number
    // We know 1 is not a prime number
    if (n == 1) {
        return false;
    }

    ll i = 2;
    // This will loop from 2 to int(sqrt(x))
    while (i*i <= n) {
        // Check if i divides x without leaving a remainder
        if (n % i == 0) {
            // This means that n has a factor in between 2 and sqrt(n)
            // So it is not a prime number
            return false;
        }
        i += 1;
    }
    // If we did not find any factor in the above loop,
    // then n is a prime number
    return true;
}
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
typedef unsigned long long  ull;

int check(int x,vector <int> a,int n)
{  int county=0;
  map <int,int> mapa;
    for(int i=0;i<n;i++)
    {
        mapa.insert(pair<int,int>(a[i],0));
    }
    for(int i=0;i<n;i++)
    {
        mapa[a[i]]++;
    }
   // cout<<mapa[1]<<mapa[2]<<mapa[3]<<mapa[4]<<mapa[5]<<endl;
    for(int i=0;i<a.size();i++)
    {   mapa[a[i]]--;
        if(mapa[abs(a[i]-x)]>0)
        {
            county++;


            mapa[abs(a[i]-x)]--;
        }


    }
    return county;
}

typedef unsigned int ui;

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

 int n,x,t;
 cin>>n>>x>>t;
 int d;
 if(n%x==0)
 {
     d=n/x;
 }
 else
 {
     d=n/x+1;
 }
 cout<<d*t<<endl;





}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(x,n) for(int i=x;i<n;i++)
#define REP(y,n) for(int j=y;j<n;j++)
#define vi vector<int>
#define vvi vector<vector<int>>
signed main(){
  string S,T;
  int c=0;
  cin>>S>>T;
  S+=S;
  rep(0,S.size()-T.size()){
    if(S[i]==T[0]){
      REP(i,i+T.size()+1){
        if(S[j]==T[j-i])c++;
      }
    }
    if(c==T.size())break;
    c=0;
  }
  c==T.size()?cout<<"Yes"<<endl:cout<<"No"<<endl;
}



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

int main() {
    long long int ans = 0;
    int n, k, r, s, p;
    string t, ans_t;
    cin >> n >> k >> r >> s >> p >> t;
    for(int i = 0; i < n; ++i) {
        if(i >= k) {
            if(t[i-k] == t[i] && ans_t[i-k] != 'a') {
                ans_t += 'a';
            } else {
                if(t[i] == 'r') ans_t += 'p';
                else if(t[i] == 's') ans_t += 'r';
                else ans_t += 's';        
            }
        } else {
            if(t[i] == 'r') ans_t += 'p';
            else if(t[i] == 's') ans_t += 'r';
            else ans_t += 's'; 
        }
    }
    for(int i = 0; i < n; ++i) {
        if(ans_t[i] == 'r') ans += r;
        else if(ans_t[i] == 's') ans += s;
        else if(ans_t[i] == 'p')ans += p; 
    }
    cout << ans << '\n';
}


Measured memory_bytes: 512
n,k=map(int,input().split())
sunuke=[i for i in range(1,n+1)]
for i in range(k):
    d=int(input())
    kashi=list(map(int,input().split()))
    for j in range(d):
        if kashi[j] in sunuke:
            sunuke.remove(kashi[j])
print(len(sunuke))

Measured memory_bytes: 67732
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
typedef long long ll;
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
int main(){ 
  int N,M;
cin>>N>>M;
  
  vector<bool>a(N+1,true);//ハズレの階段を記録
  
  for(int i=0;i<M;i++){
    int x;
    cin>>x;
    a[x]=false;
  }

  vector<long long int>dp(N+1);//階ごとにパターン数を記録
 dp[0]=1;
  
  for(int now=0;now<N;++now){//nextにはnext-1とnext-2からくるパターンがあるそれをたす
    for(int next=now+1;next<=min(N,now+2);++next){//nowはnext-1とnext-2
      if(a[next]){
dp[next]+=dp[now];
        dp[next]%=mod;//それぞれに%=が使える
      }
    }
  }
  //DPはその階にくるパターンがN回あり、それぞれパターンに到達するパターンを全てたす
cout<<dp[N]<<endl;
 
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}

void solve()
{
    int x=1+2+3;
    int a=nxt(),b=nxt();
    cout<<x-(a+b)<<endl;


}
int main()
{
    int tc=1;
    while(tc--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

char S[101010];

int main()
{
	scanf("%s", S);

	bool app[26];
	for (int i = 0; i < 26; ++i) {
		app[i] = false;
	}
	for (int i = 0; S[i] != '\0'; ++i) {
		app[S[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	puts("None");
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readInt()
  if (N % 2 == 1) {
    println(N * 2)
  } else {
    println(N)
  }
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;
  cin>>s;
  map<char, int> mp;
  for(int i=0;i<4;i++){
    char c = s[i];
    mp[c]++;
  }
  if(mp.size()!=2){
    cout<<"No"<<endl;
    return 0;
  }
  for (auto& kv : mp) {
    if(kv.second!=2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}
	

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

struct state{
    int cost,y,x,dir;
};

bool operator>(const state &a, const state &b){
    return a.cost > b.cost;
}

//           →↓←↑
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int X,Y;
int s[30][30];
int dp[30][30][4];
int c[4]; // straight, right, back, left, halt

void dijkstra(){
    using P = state;
    priority_queue<P,vector<P>,greater<P>> qu;
    qu.push({dp[0][0][0] = 0, 0,0,0});
    while(qu.size()){
        P cur = qu.top(); qu.pop();
        int y = cur.y;
        int x = cur.x;
        int dir = cur.dir;
        if(y == Y-1 && x == X-1) return;
        if(dp[y][x][dir] < cur.cost) continue;
        rep(i,4){
            int nd = (dir+i)%4;
            int ny = y + dy[nd];
            int nx = x + dx[nd];
            int cost = (i==s[y][x] ? 0 : c[i]);
            if(ny<0 || nx<0 || nx>=X || ny>=Y) continue;
            if( dp[ny][nx][nd] > dp[y][x][dir] + cost){
                dp[ny][nx][nd] = dp[y][x][dir] + cost;
                qu.push({dp[ny][nx][nd],ny,nx,nd});
            }
        }
    }
}

int main(void){
    while(cin>>X>>Y, X|Y){
        rep(y,30)rep(x,30)rep(i,4){
            dp[y][x][i] = INF;
        }
        rep(y,Y) rep(x,X) cin>>s[y][x];
        rep(i,4) cin>>c[i];
        dijkstra();
        int res = INF;
        rep(i,4){
            res = min(res, dp[Y-1][X-1][i]);
        }
        cout<<res<<endl;
    }
    return 0;
}



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

int main(){
  int n;
  while(cin >> n){
    int count = 0;
    for(int i = 0; i < 10; i++)
      for(int j = 0; j < 10; j++)
	for(int k = 0; k < 10; k++)
	  for(int l = 0; l < 10; l++)
	    if(i+j+k+l == n)
	      count++;
    cout << count << endl;
  }
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main {

  public static void main(String args[]){

    Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
  
        int b = sc.nextInt();

        int c = sc.nextInt();
        

        if((a == 5) && (b == 7) && (c == 5)){
           System.out.println("YES");
        }
        else if((a == 5) && (b == 5) && (c == 7)){
           System.out.println("YES");
        }
        else if((a == 7) && (b == 5) && (c == 5)){
           System.out.println("YES");
        }
        else{
           System.out.println("NO");
        }
  }

}

Measured memory_bytes: 9428
from math import inf
from random import randint,random
import time
START=time.time()
PROB=0.99

def f(a,d,T):
    try:
        return T[d:].index(a)+d
    except ValueError:
        return len(T)

from random import randint
A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))
 
def g(d,q,S,C,T):
    p=T[d]

    a=f(p,d+1,T)
    b=f(q,d+1,T)
    
    Y=0
    h=L[d-1][p]
    for i in range(d,a):
        h+=1
        Y+=h-L[i][p]
        
    m=0
    Z=0
    for j in range(d,b):
        Z-=m-L[j][q]
        m+=1
        
    return (S[d][q]-S[d][p])-Z*C[q]+Y*C[p]

T=[0]
L=[[0]*(A+1) for _ in range(D+1)]
for d in range(1,D+1):
    M=-inf
    E=0

    for j in range(1,A+1):
        X=0
        for k in range(1,A+1):
            if j!=k:
                X-=C[k]*L[d][k]
                
        if M<=X+S[d][j]:
            M=X+S[d][j]
            E=j

    T.append(E)
    for j in range(1,A+1):
        if j!=E:
            L[d][j]=L[d-1][j]+1
        else:
            L[d][j]=0

while time.time()-START<=1.70:
    e=randint(1,D)
    q=randint(1,A)

    V=g(e,q,S,C,T)
    if V>0 or random()>PROB:
        p=T[d]

        a=f(p,d+1,T)
        b=f(q,d+1,T)
        
        h=L[d-1][p]
        for i in range(d,a):
            h+=1
            L[i][p]=h

        m=0
        for j in range(d,b):
            L[j][q]=m
            m+=1
        T[d]=q

for i in range(1,D+1):
    print(T[i])


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

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

    vector<int> dp(n, INT32_MAX);

    for (int i = n - 1; i >= 0; --i)
    {
        int pos = upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
        dp[pos] = a[i];
    }

    int ans = 0;
    for (int i : dp)
        if (i == INT32_MAX)
            break;
        else
            ++ans;
    cout << ans << endl;
}


Measured memory_bytes: 4000
#include<stdio.h>
int gcd(int a, int b)
{
    int r;
    while (b != 0){
    	r = a % b;
    	a = b;
    	b = r;
    }
    return a;
}

int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d\n",1+x+y-gcd(x,y));
    return 0;
}

Measured memory_bytes: 2704
N, M = map(int, input().split())
Xs = sorted(list(map(int, input().split())))

if N >= M:
  print(0)
else:
  interval = [0] * (M-1)
  for i in range(M-1):
    interval[i] = Xs[i+1] - Xs[i]
  interval.sort(reverse = True)
  
  answer = Xs[M-1] - Xs[0]
  for i in range(N-1):
    answer -= interval[i]
  print(answer)


Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  cout << (a == b ? c : a == c ? b : a) << endl;
}

Measured memory_bytes: 256
R, G, B, N = map(int, input().split())

answer = 0
for r in range(N//R+1):
  for g in range(N//G+1):
    if r*R + g*G > N:
      break
    elif (N-r*R-g*G)%B != 0:
      continue
    else:
      answer += 1
print(answer)


Measured memory_bytes: 9100
class UnionFind:
    def __init__(self, n):
        self.v = [-1 for _ in range(n)]

    def find(self, x):
        if self.v[x] < 0:  # (負)は根
            return x
        else:
            self.v[x] = self.find(self.v[x])
            return self.v[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if -self.v[x] < -self.v[y]:
            x, y = y, x
        self.v[x] += self.v[y]
        self.v[y] = x

    def root(self, x):
        return self.v[x] < 0

    def size(self, x):
        return -self.v[self.find(x)]


mx = 10 ** 5 + 10

n = int(input())

uf = UnionFind(mx * 2)

for _ in range(n):
    x, y = map(int, input().split())
    uf.unite(x, y + mx)

vx = [0] * (mx * 2)
vy = [0] * (mx * 2)

for i in range(mx):
    root = uf.find(i)
    vx[root] += 1

for i in range(mx, mx * 2):
    root = uf.find(i)
    vy[root] += 1

ans = -n
for xx, yy in zip(vx, vy):
    ans += xx * yy
print(ans)


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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    ll x;
//    x=1ll << 59;
//    ll y=(1ll << 59) - 1ll;
//    cout<<((double)(x)==(double)(x-1))<<endl;
    ll n,X=0,X2=0,X3=0,X4=0,X5=0;
    cin>>n;
    string l1[n+1];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
        if(l1[i][0]=='M')X++;
        else if(l1[i][0]=='R')X2++;
        else if(l1[i][0]=='A')X3++;
        else if(l1[i][0]=='C')X4++;
        else if(l1[i][0]=='H')X5++;
    }
    ll s=0;
    s+=(X*X2*X3);
    s+=(X*X2*X4);
    s+=(X*X2*X5);
    s+=(X*X4*X3);
    s+=(X*X5*X3);
    s+=(X*X4*X5);
    s+=(X2*X4*X3);
    s+=(X2*X5*X3);
    s+=(X2*X4*X5);
    s+=(X3*X4*X5);
    //if(X+X2+X3+X4+X5<3)cout<<0;
    cout<<s;
}


Measured memory_bytes: 6744
#include<stdio.h>
int main(void){
  long int l[87],n,i;
  scanf("%ld",&n);
  l[0]=2;
  l[1]=1;
  for(i=2;i<=n||i<87;i++){
    l[i]=l[i-1]+l[i-2];
  }
  printf("%ld",l[n]);
  return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
    int N;
    string S,T;
    cin >> N >> S >> T;

    for (int i = 0; i < N; i++) {
        cout << S.at(i) << T.at(i);
    }
    
    

}


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

using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	b ^= a;
	
	int cnt = 0;
	for(int bit = 0;bit < n;bit++){
		if(b & (1 << bit)) cnt++;
	}
	if(cnt % 2 == 0){
		cout << "NO";
		return 0;
	}
	cout << "YES\n";
	vector<int> numbers;
	
	int have = false;
	int f = -1;
	int s = -1;
	
	int seq1[8] = {0,0,1,1,1,1,0,0};
	int seq2[8] = {0,1,1,0,0,1,1,0};
	int seq3[8] = {0,0,1,1,1,0,0,1};
	int seq4[8] = {0,1,1,0,0,0,1,1};
	for(int bit = 0;bit < n;bit++){
		if(b & (1 << bit)){
			if(!have){
				numbers.push_back(0);
				numbers.push_back(1 << bit);
				have = true;
			}
			else{
				if(f == -1){
					f = 1 << bit;
				}
				else{
					s = 1 << bit;
					
					vector<int> nxt;
					for(int i = 0;i < numbers.size();i++){
						for(int j = 0;j < 4;j++){
							if(i < numbers.size() - 2) nxt.push_back(numbers[i] + f * seq1[(i*4+j)%8] + s * seq2[(i*4+j)%8]);
							else nxt.push_back(numbers[i] + f * seq3[(i*4+j)%8] + s * seq4[(i*4+j)%8]);
						}
					}
					numbers = nxt;
					f = -1;
					s = -1;
				}
			}
		}
	}
	
	for(int bit = 0;bit < n;bit++){
		if((b & (1 << bit)) == 0){
			vector<int> nxt;
			for(int i = 0;i < numbers.size();i++){
				if(i % 2 == 0){
					nxt.push_back(numbers[i]);
					nxt.push_back(numbers[i] + (1<<bit));
				}
				else{
					nxt.push_back(numbers[i] + (1<<bit));
					nxt.push_back(numbers[i]);
				}
			}
			numbers = nxt;
		}
	}
	
	for(int x : numbers) cout << (x ^ a) << " ";
	
	for(int i = 0;i < numbers.size() - 1;i++){
		int d = numbers[i] ^ numbers[i+1];
		if(d & (d-1)) cout << i << "!\n";
	}
}


Measured memory_bytes: 1720
from sys import stdin
from collections import deque, defaultdict as ddic
from itertools import combinations, permutations, product
import bisect
import heapq

rs = lambda: stdin.readline().strip()
ri = lambda: int(rs())
rsl = lambda: stdin.readline().split()
rim = lambda: map(int, rsl())
ril = lambda: list(rim())

a, b = rim()
ans = 0
if a > b:
    ans += a
    a -= 1
else:
    ans += b
    b -= 1
    
if a > b:
    ans += a
    a -= 1
else:
    ans += b
    b -= 1

print(ans)

Measured memory_bytes: 3436
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
int main(){
	vector<int> list {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;
	cin >> K;
	cout << list[K-1];
}


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

int main(int argc, char const *argv[])
{
    int a;
    string s;

    cin >> a >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
    return 0;
}


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

bool p[1000000];

int main()
{

	for (int i = 2; i < 1000000; i++){
		p[i] = true;
	}

	for (int i = 2; i * i < 1000000; i++){
		if (p[i]){
			for (int j = i * 2; j < 1000000; j += i){
				p[j] = false;
			}
		}
	}

	int n;
	while (cin >> n, n){
		int c = 0;
	    long long sum = 0;
		
		for (int i = 2; c != n; i++){
			if (p[i]){
				sum += i;
				c++;
			}
		}
		cout << sum << endl;
	}
	return (0);
}

Measured memory_bytes: 2132