akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
int n , vis[1000];
#define ll long long 
vector <int> g[1000];
void dfs ( int x ){
	vis[x]++ ;
	for(int i=1 ; i<=g[x].size() ; i++ ){
		int u=g[x][i];
		if(vis[u]==2 ){
			printf("%d" , i );
			exit(0);
		}
	}
}
ll a[200010];
int maia() {
	ll n;
	cin>>n;
	ll cnt=0;
	ll now=1;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(a[i]!=now){
			cnt++;
		}
		else{
			now++;
		}
	}
	if(n==cnt){
		cout << -1;
		return 0;
	}
	cout << cnt;
	// your code goes here
	return 0;
}
int gcd(int a, int b){
 
	if(a==b)
		return a;
	if(a>b)
		return gcd(a-b,b);
	if(b>a)
		return gcd(a,b-a);
 
}
 
int main(void) {
    ll a,b;
    cin>>a>>b;
    long long ans = a * b;
	if(a < b){swap(a, b);}
 
	int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  ans /= b;
  cout << ans << endl;
  return 0;
}
int maa() {
	scanf("%d" , &n );
	for(int a  , i=1 ; i<=n ;i++ ){
		scanf("%d" , &a );
		g[i].push_back(a);
	}
	for(int i=1 ; i<=n ;i++ ){
		dfs(i) ; 
	}
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x, y, z;
    int r;
    int ans;
    
    scanf("%d %d", &x, &y);
    
    if (y >= x) {
        z = x;
        x = y;
        y = z;
    }
    
    while (y > 0) {
        r = x % y;
        x = y;
        y = r;
    }
    
    printf("%d\n", x);
    
    return 0;
}



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

int main(){
    int n , q; cin >> n >> q;
    vector<list<int>> a(n);
    rep(i , q){
        int u , s , t , value;
        cin >> u;
        if( u == 0 ){
            cin >> t >> value;
            a[t].push_back(value);
        } else if ( u == 1 ){
            cin >> t;
            if(a[t].empty()) cout << endl;
            else { 
                auto itr2 = a[t].end();
                --itr2; 
                for(auto itr = a[t].begin() ; itr!=itr2 ;++itr){
                    cout << *itr << " ";
                }
            cout << *itr2 << endl;
            }
        } else if( u == 2 ){
            cin >> s >> t;
            a[t].splice(a[t].end(), move(a[s]));
            a[s].clear();
        }
    }
}


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

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);

  if (x / d > k) {
    cout << x - k * d << endl;
    return 0;
  }

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

  return 0;
}
/*
*/


Measured memory_bytes: 3632
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

import sys
N, X, Y = map(int, input().split())
CW = list(map(int, sys.stdin.read().split()))
C, W = CW[::2], CW[1::2]
mod = 10**9+7
comb = Combination(N+1)

Color_min = [10**10] * (N+1)
Color_argmin = [-1] * (N+1)
Color_2nd_min = [10**10] * (N+1)
all_min = 10**10
all_second_min = 10**10
all_min_color = -1
for i, (c, w) in enumerate(zip(C, W)):
    if Color_2nd_min[c] > w:
        Color_2nd_min[c] = w
        if Color_min[c] > w:
            Color_min[c], Color_2nd_min[c] = Color_2nd_min[c], Color_min[c]
            Color_argmin[c] = i
for c, w in enumerate(Color_min):
    if all_second_min > w:
        all_second_min = w
        if all_min > w:
            all_min, all_second_min = all_second_min, all_min
            all_min_color = c
    
In_cnt = [0] * (N+1)
Out_flag= [0] * (N+1)
for i, (c, w) in enumerate(zip(C, W)):
    if (i != Color_argmin[c] and Color_min[c] + w <= X) \
     or (Color_2nd_min[c] + w <= X) \
     or (c != all_min_color and all_min + w <= Y) \
     or (all_second_min + w <= Y):
        In_cnt[c] += 1
    if all_min + w <= Y:
        Out_flag[c] = 1
sum_in_out = 0
ans = 1
for c, f in zip(In_cnt, Out_flag):
    if f:
        sum_in_out += c
        ans = ans * comb.facinv[c] % mod
ans = ans * comb.fac[sum_in_out] % mod
#print(In_cnt)
#print(Out_flag)
print(ans)


Measured memory_bytes: 50428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x);
int main(){
    ll a, b, c, x, y, ans = 0;
    sc(a) sc(b) sc(c) sc(x) sc(y)
    while (x > 0 && y > 0 && a + b > 2*c){
        x -= 1; y -= 1;
        ans += 2*c;
    }
    ans += min(a*x, 2*x*c);
    ans += min(b*y, 2*y*c);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////



	
int main() {

	ll N;
	cin >> N;
	cout << N * N*N;
	system("PAUSE");


}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005


int main(){
    int h, w;
    cin >> h >> w;
    string s[h+2];
    rep(i,h+2){
        if(i == 0 || i == h + 1){
            rep(j,w+2)s[i] += '#';
        }else{
            string ss;
            cin >> ss;
            s[i] = '#' + ss + '#';
        }
    }
    int ans = 0;

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

    rep(i,h+2){
        rep(j,w+2){
            if(s[i][j] == '#')continue;
            int f[h+2][w+2];
            rep(k,h+2){
                rep(l,w+2){
                    if(s[k][l] == '#')f[k][l] = -1;
                    else f[k][l] = 1001001001;
                }
            }
            f[i][j] = 0;
            queue<P> que;
            que.push(P(i,j));
            while(que.size()){
                int x = que.front().first;
                int y = que.front().second;
                que.pop();
                rep(k,4){
                    if(f[x][y] + 1 < f[x+dx[k]][y+dy[k]]){
                        f[x+dx[k]][y+dy[k]] = f[x][y] + 1;
                        ans = max(ans, f[x+dx[k]][y+dy[k]]);
                        que.push(P(x+dx[k], y + dy[k]));
                    }
                }
            }
        }
    }

    cout << ans << endl;
}
 
 


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

int main(){
  int a,b,c,d,A,Q;
    cin >> a >> b >> c >> d;
    A = a * b;
    Q = c * d;
      if(Q==A){
	cout << Q << endl;
      }else if(Q>A){
	cout << Q << endl;
      }else{
	cout << A << endl;
      }
}


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

#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int INF = 1e9+100;
const ll LINF = 1e18+100;
const int MAXN = 2e5+100;
const double EPS = 1e-6;


int n, W;
int w[MAXN];
int v[MAXN];
ll dp[200][MAXN];

void solve() {
	cin >> n >> W;
	for(int i = 0; i < n; ++i)
		cin >> w[i] >> v[i];
	dp[0][w[0]] = v[0];
	for(int i = 1; i < n; ++i) {
		for(int wg = 0; wg <= W; ++wg) {
			dp[i][wg] = dp[i-1][wg];
			if(wg - w[i] >= 0) {
				dp[i][wg] = max(dp[i][wg], 
				dp[i-1][wg-w[i]] + v[i]);
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i <= W; ++i)
		ans = max(ans, dp[n-1][i]);
	cout << ans;
}

int main() {

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int t = 1;
//	cin >> t;
	while(t--) {
		solve();
	}
}

Measured memory_bytes: 156416
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; ++k)
#define trb(k,en,st) for(int k = en; k >= st ; --k)
using namespace std;

// n* k^k

void add_self(int& a, int b){
    a+=b;
    if (a >= mod) {
        a -= mod;
    }
    if (a < 0) {
        a += mod;
    }
}

int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n, k;
    cin>>n>>k;
    vector<int> dp(k+1);
    dp[0] = 1;
    for (int i = 0 ; i < n; i++) {
        int upto;
        cin>>upto;
        vector<int> fake(k+1);
        trb(used,k,0){
            int L = used + 1;
            int R = used + min(upto, k - used) + 1;
            if(L <= R and L <= k)
                add_self(fake[L], dp[used]);
            if (R <= k)
                add_self(fake[R], -1*dp[used]);
//            tr(here,1,min(upto, k - used)){
//                add_self(dp[used + here], dp[used]);
//            }
        }
        int prefix = 0;
        tr(i,0,k){
            add_self(prefix, fake[i]);
            add_self(dp[i],prefix);
        }
    }
    cout<<dp[k] % mod<<endl;
    return 0;
}



Measured memory_bytes: 4816
#include <stdio.h>
#include <string.h>

int main()
{
	char str[105];
	scanf("%s", str);
	int count = 0, len = strlen(str);
	for(int i=0; i<=len/2; i++)
		if(str[i]!=str[len-i-1])
			count++, str[len-i-1] = str[i];
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
while True:
    H, W = map(int, input().strip().split())
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if (i + j) % 2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        print()


Measured memory_bytes: 7000
N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(1, 2 ** N):
    flag = 0
    for j in range(N):
        if (i >> j) & 1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i >> x) & 1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)

Measured memory_bytes: 44140
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

vector<ll>adj[maxn];
ll a[maxn],lvl[maxn],p[maxn][20],h[maxn];
ll ans=0,A,T;
void dfs(ll u,ll par)
{
    h[u]=0;
    p[u][0]=par;
    lvl[u]=lvl[par]+1;
    for(auto v : adj[u])
    {
        if(v==par) continue;
        dfs(v,u);
        h[u]=max(h[u],h[v]+1);
    }
}
ll lca(ll u,ll v)
{
    ll i,lg;
    if(lvl[u]<lvl[v])swap(u,v);
    for(lg=0;(1<<lg)<=lvl[u];lg++);
    lg--;
    for(i=lg;i>=0;i--)
    {
        if((lvl[u]-(1<<i))>=lvl[v])
        u=p[u][i];
    }
    if(u==v) return u;
    for(i=lg;i>=0;i--)
    {
        if(p[u][i]!=-1&&p[u][i]!=p[v][i]){
            u=p[u][i];v=p[v][i];
        }
    }
    return p[u][0];
}
ll getAncestor(ll u,ll dis)
{
    dis=lvl[u]-dis;
    ll i,lg;
    for(lg=0;(1<<lg)<=lvl[u];lg++);
    lg--;
    for(i=lg;i>=0;i--)
    {
        if(lvl[u]-(1<<i)>=dis)
        u=p[u][i];
    }
    return u;
}
ll dis(ll u,ll v)
{
    if(lvl[u]<lvl[v]) swap(u,v);
    ll w=lca(u,v);
    return lvl[u]+lvl[v]-2*lvl[w];
}

int main()
{
    ll i,u,v,j,n,x,y;
    cin>>n>>T>>A;
    for(i=1;i<n;i++){
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(i=0;i<20;i++)
    {
        for(j=1;j<=n;j++)
        {
            p[j][i]=-1;
        }
    }
    lvl[0]=-1;
    dfs(A,0);
    for(i=1;i<20;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(p[j][i-1]!=-1)
            p[j][i]=p[p[j][i-1]][i-1];
        }
    }
    if(p[T][0]==A){
        cout<<0;
        return 0;
    }
    ll cur=T;
    x=0;
    ll mv=T,mx=0;
    while(cur!=A){
        if(dis(T,cur)>=dis(A,cur)) break;
        if(x+h[cur]>mx){
            mx=x+h[cur];
            mv=cur;
        }
        x++;
        cur=p[cur][0];
    }
    y=mv;
    while(y!=A){
        ans++;
        y=p[y][0];
    }
    ans+=h[mv]-1;
    cout<<ans;
}


Measured memory_bytes: 27648
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[] H = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int[] ans = new int[N];
        for (int i = 1; i < N; i++)
        {
            if (H[i] <= H[i - 1])
                ans[i] = ans[i - 1] + 1;
            else
                ans[i] = 0;
        }
        Console.WriteLine(ans.Max());
		Console.ReadKey();
	}
}


//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 26588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		int sum = 0;

		for (int i = 1; i <= K; i++) {
			for (int j = 1; j <= K; j++) {
				for (int h = 1; h <= K; h++) {

					sum += gcd(i, gcd(j, h));
				}
			}
		}
		System.out.println(sum);

	}

	public static int gcd(int p, int q) {

		if (p % q == 0) {
			return q;
		}
		return gcd(q, p % q);
	}
}

Measured memory_bytes: 27256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
 ll n;
 cin >>n;
 double x;
 double ans=0;
 for(ll i=0;i<n;i++) {
   string u;
   cin >>x>>u;
   if(u=="JPY") ans+=x;
   else ans+=(x*380000.0);
 }
 cout <<ans<<endl;
}


Measured memory_bytes: 256
import itertools
import sys

n = int(input())
p_list = list(map(int, input().split()))
is_sorted = all(p_list[k] < p_list[k+1] for k in range(n - 1))
if is_sorted:
    print('YES')
    sys.exit()
for i, j in itertools.combinations(range(n), 2):
    p_list[i], p_list[j] = p_list[j], p_list[i]
    is_sorted = all(p_list[k] < p_list[k+1] for k in range(n - 1))
    if is_sorted:
        print('YES')
        sys.exit()
    p_list[i], p_list[j] = p_list[j], p_list[i]
print('NO')


Measured memory_bytes: 3064
import collections
n = int(input())
v = list(map(int,input().split()))
a = v[0::2]
b = v[1::2]
a = sorted(a)
b = sorted(b)
a = collections.Counter(a).most_common()
b = collections.Counter(b).most_common()

p,q = [],[]
r,s = n//2,n//2
for (c,d) in a:
    if d==a[0][1]:
        p.append(c)
    else:
        r = d
        break
for (c,d) in b:
    if d==b[0][1]:
        q.append(c)
    else:
        s = d
        break

if (len(a),len(b))==(1,1):
    if a==b:
        print(n//2)
    else:
        print(0)
elif len(a)==1:
    print(n//2-b[0][1])
elif len(b)==1:
    print(n//2-a[0][1])
elif (len(p),len(q))==(1,1) and p==q:
    print(min(n-a[0][1]-s,n-b[0][1]-r))
else:
    print(n-a[0][1]-b[0][1])


Measured memory_bytes: 20828
import java.util.Scanner;

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

        int[] cnt = new int[200];

        while(sc.hasNext()){
            String str = sc.next().toLowerCase();
            for(int i=0;i<str.length();i++){
                cnt[str.charAt(i)]++;
            }
        }

        for(char ch='a';ch<='z';ch++){
            System.out.println(ch+" : "+cnt[ch]);
        }


    }
}


Measured memory_bytes: 26064
#include<iostream>
#include<cstdio>
using namespace std ;
bool three (int x){
  if(x%3==0) return true;
  while(x>0){
    if(x%10==3)return true;
    x/=10;
  }
  return false;
}
int main(){
  int n,i;
  cin>>n;
  for(i=1;i<=n;i++){
    if(three(i))cout<<" "<<i;
  }
  cout<<endl;
 return 0;
}

Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
	private	static	BufferedReader	br = null;
	private	static	char[][]		wt = { { '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', '.', '?', '!', ' ' } };

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		String  stdin = null;
		while ((stdin = parseStdin()) != null) {
			int		i = 0;
			int		l = stdin.length();
			boolean	f = (l % 2 == 0);
			String	o = "";

			while (f && i < l) {
				int	j = (stdin.charAt(i)-'1');
				int	k = (stdin.charAt(i+1)-'1');

				if ((f = (0 <= j && j <= 5 && 0 <= k && k <= 4))) {
					o += wt[j][k];
					i+=2;
				}
			}

			System.out.println((f) ? o: "NA");
		}
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 17292
#include<bits/stdc++.h>
using namespace std;
typedef struct{
    int from;
    int to;
}RANGE;
int main(){
    vector<string> num;
    vector<vector<RANGE>> range(1,vector<RANGE>(10));
    for(int i=0; i<10; i++){
        num.push_back(to_string(i));
        range.at(0).at(i).from=i;
        range.at(0).at(i).to=i;
    }
    vector<RANGE> add(10);
    int lev=1,head=0,n=9,f,t;
    int K;
    cin >> K;
    while(1){
        if(n>=K) break;
        for(head=0; head<10; head++){
            add.at(head).from=num.size();
            if(head==0){
                f=range.at(lev-1).at(0).from;
                t=range.at(lev-1).at(1).to;
            }else if(head==9){
                f=range.at(lev-1).at(8).from;
                t=range.at(lev-1).at(9).to;
                n+=(t-f+1);
            }else{
                f=range.at(lev-1).at(head-1).from;
                t=range.at(lev-1).at(head+1).to;
                n+=(t-f+1);
            }
            for(int i=f; i<=t; i++){
                num.push_back(to_string(head)+num.at(i));
            }
            add.at(head).to=num.size()-1;
        }
        range.push_back(add);
        lev++;
    }
    int k=0;
    while(1){
        if(num.at(k).at(0)!='0'){
            K--;
        }
        if(K==0) break;
        else k++;
    }
    cout << num.at(k);
    return 0;
}


Measured memory_bytes: 11632
# -*- coding: utf-8 -*-
"""
Admission Fee
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0278

"""
import sys


def solve():
    x, y, b, p = map(int, input().split())
    p1 = x * b + y * p
    p2 = (x * max(b, 5) + y * max(p, 2)) * 8 // 10
    return min(p1, p2)


def main(args):
    N = int(input())
    for _ in range(N):
        ans = solve()
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 5624
program abc149_b
	implicit none
	integer(8) :: A, B, K
    read(*, *) A, B, K
    
    if( K >= A+B ) then
    	print *, 0, 0
    else if( A <= K .and. K < A+B ) then
    	print *, 0, B-K+A
    else
    	print *, A-K, B
    endif
end program abc149_b

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	ll n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<ll> lt(n);
	rep(i,n) lt[i] = 0;
	rep(i,n) {
		rep(j,n) {
			if(i==j) continue;
			if(a[i] > a[j]) lt[i]++;
		}
	}
	vector<ll> lta(n);
	rep(i,n) lta[i] = 0;
	rep(i,n) for(int j=i+1; j<n; j++) {
		if(a[i] > a[j]) lta[i]++;
	}
	vector<ll> ans(n);
	rep(i,n) ans[i] = 0;
	rep(i,n) {
		ll temp = lt[i];
		if(k%2==0) {
			temp *= k/2;
			temp %= MOD;
			temp *= k-1;
			temp %= MOD;
		}
		else {
			temp *= (k-1)/2;
			temp %= MOD;
			temp *= k;
			temp %= MOD;
		}
		ans[i] += temp;
		ans[i] %= MOD;
		ans[i] += lta[i] * k;
		ans[i] %= MOD;
	}
	ll answ = 0;
	rep(i,n) {
		answ += ans[i];
		answ %= MOD;
	}
	cout << answ << endl;


  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) {
        cin >> a[i];
        a[i]--;
    }

    int now = 0;
    REP(i, N) {
        if (now == 1) {
            std::cout << i << std::endl;
            return 0;
        }
        now = a[now];
    }

    std::cout << -1 << std::endl;

    return 0;
}

Measured memory_bytes: 640
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

import itertools

l = sorted(itertools.permutations(range(1, N + 1)))

for i, x in enumerate(l):
    x = list(x)

    if x == P:
        p = i

    if x == Q:
        q = i


print(abs(p - q))


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

using namespace std;

int n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    long long Sum = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            Sum = Sum + i;
        }
    }
    cout << Sum;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
int head[128],last[256],to[256],cnt=0;
int deg[128];
void add(int u,int v)
{
	cnt++;
	last[cnt]=head[u];
	head[u]=cnt;
	to[cnt]=v;
	deg[u]++;
}
int fa[128],dis[128];
void dfs(int u,int f,int d)
{
	fa[u]=f;
	dis[u]=d;
	for(int i=head[u];i;i=last[i])
	{
		int v=to[i];
		if(v==f)
		{
			continue;
		}
		dfs(v,u,d+1);
	}
}
int mx[128];
int len;
int n;
long long query()
{
	for(int i=0;i<len;i++)
	{
		mx[i]=0;
	}
	for(int i=1;i<=n;i++)
	{
		if(deg[i]-1>mx[dis[i]])
		{
			mx[dis[i]]=deg[i]-1;
		}
	}
	long long ans=1;
	for(int i=0;i<len-1;i++)
	{
		ans*=mx[i];
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	dfs(1,0,0);
	int u=0,d=-1;
	for(int i=1;i<=n;i++)
	{
		if(dis[i]>d)
		{
			u=i;
			d=dis[i];
		}
	}
	dfs(u,0,0);
	u=0,d=-1;
	for(int i=1;i<=n;i++)
	{
		if(dis[i]>d)
		{
			u=i;
			d=dis[i];
		}
	}
	len=(d>>1)+1;
	printf("%d ",len);
	for(int i=1;i<len;i++)
	{
		u=fa[u];
	}
	if(d&1)
	{
		int v=fa[u];
		dfs(u,v,0);
		dfs(v,u,0);
		printf("%lld\n",query()<<1);
		return 0;
	}
	dfs(u,0,0);
	deg[u]++;
	long long ans=query();
	deg[u]--;
	for(int i=head[u];i;i=last[i])
	{
		dfs(u,to[i],0);
		dfs(to[i],u,0);
		long long ans2=(query()<<1);
		if(ans2<ans)
		{
			ans=ans2;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 7/28/2018
 
 24:30-25:25 1WA
 
 7/29/2018
 
 15:30-
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int Inf=1e5+1;
string S;
void solve_wrong() {
  int N=SZ(S);

  int G0=0,G1=0;
  int len0=0,len1=0,res=Inf;
  
  int i=0;
  while(i<N&&S[i]==S[0]) (S[i]=='0'?len0:len1)++,++i;
  if(i==N) res=S[0]=='1'?1:0;
  else {
    for(; i<N; ++i) {
      if(S[i-1]!=S[i]) {
        (S[i-1]=='0'?G0:G1)++;
//        dump3(i,len0,len1);
        if(G0>0&&G1>0)SMIN(res,len0+len1);
        if(S[i-1]=='0') len1=0;
        else len0=0;
      }
      (S[i]=='0'?len0:len1)++;
    }
    SMIN(res,len0+len1);
    (S[N-1]=='0'?G0:G1)++;
    assert(G0+G1>=2);
//    dump2(G0,G1);
    if(G0==1&&G1==1) res=max(len1,len0);
  }
  cout<<res<<endl;
}

void solve() {
  int N=SZ(S);
  int res=0;
  REP(d,2) {
    int K=N/2+d;
    int L=Inf;
    int i=K;
    while(i<N&&S[i]==S[K]) ++i;
    SMIN(L,i);
    i=K;
    while(i>=0&&S[i]==S[K]) --i;
    SMIN(L,N-i-1);
    SMAX(res,L);
  }
  cout<<res<<endl;
}

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


Measured memory_bytes: 512
import sys

n, m, *ab = map(int, sys.stdin.read().split())
graph = [[] for _ in range(n)]
for a, b in zip(*[iter(ab)] * 2):
    a -= 1; b -= 1
    graph[a].append(b)
    graph[b].append(a)

def main():
    stack = [(0, 0)]
    paths = 0
    while stack:
        i, visited = stack.pop()
        visited |= 1 << i
        if visited == (1 << n) - 1:
            paths += 1
            continue
        for j in graph[i]:
            if visited >> j & 1: continue
            stack.append((j, visited))
    print(paths)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  ld a, b, x; cin >> a >> b >> x;
  bool tmp = x < a * a * b - x;
  if(tmp) {
    ld t = 2 * x / a / b;
    cout << atan(b/t) / M_PI * 180 << endl;
  } else {
    x = a * a * b - x;
    ld t = 2 * x / a / a;
    cout << atan(t/a) / M_PI * 180 << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    int a;
    vector<int> A;

    cin >> n;
    vector<int> ans(n);

    for (int i = 0; i < n-1; i++)
    {
        cin >> a;
        A.push_back(a);
    }
    
    for (int i = 0; i < n-1; i++)
    {
        ans[A[i]-1] += 1;
    }
    
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << endl;
    }
    
    return 0;
}


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

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    bool ok = true;
    if (S.size() + 1 != T.size())
    {
        ok = false;
    }

    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
            ok = false;
    }

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3640
# coding:utf-8

INF = float('inf')


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


N, M = inpl()
move = [inpl() for _ in range(M)]

ans = [0 for _ in range(N)]
ans[0] = 1
box = [1 for _ in range(N)]
# print(ans, box)
for i in range(M):
    x, y = move[i]
    box[x - 1] -= 1
    box[y - 1] += 1
    if ans[x - 1]:
        ans[y - 1] = 1
        if box[x - 1] == 0:
            ans[x - 1] = 0
    # print(ans, box)


print(sum(ans))

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


ll gcd(ll a, ll b){
  ll temp;
  while(a%b !=0){
    temp = b;
    b = a % b;
    a = temp;
  }
  return b;
}



int main(){
  ll a, b;
  ll c, d;
  cin >> a >> b >> c >> d;

  ll e = c*d/gcd(c, d);

  ll num_b = b/c + b/d - b/e;
  ll num_a = (a-1)/c + (a-1)/d - (a-1)/e;
  ll ans = b - num_b - ( a - 1 - num_a );
  cout << ans << endl;
  return 0;
  
}


Measured memory_bytes: 256
N = int(input())
n = 0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            # divisors.append(i)
            if i != n // i and n % (n // i - 1) != 0:
                divisors.append(n//i)
    return divisors

lists = make_divisors(N)
print(sum(lists)-len(lists))

Measured memory_bytes: 3060
# coding:UTF-8
import sys
from math import factorial

MOD = 10 ** 9 + 7
INF = float('inf')

# 約数列挙
def divisorList(a):
    l = 0
    for i in range(1, int(a**0.5)+1):
        if a % i == 0:
            l += 1
            ii = a / i
            if i != ii:
                l += 1
    return l


N = int(input())    # 数字
res = 0
for i in range(1, N+1):
    if i % 2 == 1:
        if divisorList(i) == 8:
            res += 1

print("{}".format(res))


Measured memory_bytes: 62672
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long[] S = new long[str.Length];
		long t = 1;
		long At = 0;
		long Bt = 0;
		long Ct = 0;
		for(var i=0;i<str.Length;i++){
			if(str.Substring(i,1)=="A"){
				At = At + t;
			}
			else if(str.Substring(i,1)=="B"){
				Bt = Bt + At;
			}
			else if(str.Substring(i,1)=="C"){
				Ct = Ct + Bt;
			}
			else {
				Ct = Ct * 3 + Bt;
				Bt = Bt * 3 + At;
				At = At * 3 + t;
				t = t * 3;
			}
			t = t % 1000000007;
			At = At % 1000000007;
			Bt = Bt % 1000000007;
			Ct = Ct % 1000000007;
		}
		Console.WriteLine(Ct % 1000000007);
	}
}

Measured memory_bytes: 16220
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

int main(){
    string S;
    cin >> S;
    int k = S.length();
    int cnt = 0;

    for(int i = 0; i < k; i++){
        if(S[i] == 'x') cnt++;
    }

    if(cnt <= 7) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long s=0,n,i,k,a,b,c;
  scanf("%lld %lld",&n,&k);
  if(k==0){
    printf("%lld\n",n*n);
    return 0;
  }
  for(i=k+1;i<=n;i++){
    a=i-k;
    b=(n+1)/i;
    c=b*i;
    c=n-c-k+1;
    s+=a*b;
    if(c>0)s+=c;
    //printf("%lld %lld %lld %lld\n",i,a,b,c);
  }
  printf("%lld\n",s);   
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int tinh(int n)
{
    n/=2;
    int res = 0;
    for (int i=5;i<=n;i*=5)
        res += n/i;
    return res;
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>n;
    if(n%2==1) {cout<<0; return 0;}
    cout<<tinh(n);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define MOD 1000000007LL
using namespace std;

long long int inv(long long int x){
	long long int xpow[30], c[30];
	for(int i=0; i<30; i++){
		if(i==0){
			xpow[i]=x;
			c[i]=1;
		}else{
			xpow[i]=xpow[i-1]*xpow[i-1]%MOD;
			c[i]=c[i-1]*2;
		}
	}
	long long int r=MOD-2, xinv=1;
	for(int i=29;i>=0; i--){
		if(r>=c[i]){
			xinv=xinv*xpow[i]%MOD;
		}
		r=r%c[i];
	}
	return xinv;
}

int main()
{
	long long int f[200001];
	for(long long int i=0; i<=200000;i++){
		if(i==0){
			f[i]=1;
		}else{
			f[i]=i*f[i-1]%MOD;
		}
	}

	long long int h, w, a, b, ans=0;
	scanf("%lld %lld %lld %lld", &h, &w, &a, &b);
	for(int i=1; i<=w-b; i++){
		ans=(ans+f[h-a-1+b+i-1]*inv(f[h-a-1])%MOD*inv(f[b+i-1])%MOD*f[w-b-i+a-1]%MOD*inv(f[w-b-i])%MOD*inv(f[a-1])%MOD)%MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define pb(i) push_back(i)
#define mk(x,y) make_pair(x,y)
#define F first
#define S second
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
using namespace std;
int main(){
	FIO;
	ll n,a,sum=0;cin>>n;
	while(n--){
		cin>>a;
		while(a%2==0){
			sum++;
			a=a/2;
		}
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int n;
char str[1001],str2[1001];

int main(void){
	scanf("%d",&n);
	int i,dd;
	for(dd=0;dd<n;dd++){
		scanf("%s%s",str,str2);
		int c=0;
		int f=1;
		int len=strlen(str);
		for(i=0;i<len;i++){
			if(str[i]>='2' && str[i]<='9'){
				f=str[i]-'0';
			}
			if(str[i]=='m'){
				c+=1000*f;
				f=1;
			}
			if(str[i]=='c'){
				c+=100*f;
				f=1;	
			}
			if(str[i]=='x'){
				c+=10*f;
				f=1;	
			}
			if(str[i]=='i'){
				c+=f;
				f=1;	
			}
		}
		f=1;
		len=strlen(str2);
		for(i=0;i<len;i++){
			if(str2[i]>='2' && str2[i]<='9'){
				f=str2[i]-'0';
			}
			if(str2[i]=='m'){
				c+=1000*f;
				f=1;
			}
			if(str2[i]=='c'){
				c+=100*f;
				f=1;	
			}
			if(str2[i]=='x'){
				c+=10*f;
				f=1;	
			}
			if(str2[i]=='i'){
				c+=f;
				f=1;
			}
		}
		int k=1000;
		while(k>0){
			int d=c/k;
			if(d>=1){
				if(d>=2)printf("%d",d);
				if(k==1000)printf("m");
				if(k==100)printf("c");
				if(k==10)printf("x");
				if(k==1)printf("i");
			}
			c%=k;
			k/=10;
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 604
n=int(input())
s=['']*n

for i in range(n):
  tmp=input()
  s[i]=str(sorted(tmp))
s.sort()

c=0
t=0
for i in range(n-1):
  if s[i]==s[i+1]:
    c+=1
  elif c!=0:
    t+=(c+1)*c//2
    c=0
if c!=0:
  t+=(c+1)*c//2

print(t)


Measured memory_bytes: 15408
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector <int> a(N);

    int sum_a = 0;

    REP(i,N)
    {
        cin >> a[i];
        sum_a += a[i];
    }


    if(sum_a % 10 == 0)
    {
        sort(a.begin(),a.end());
        REP(i,N)
        {
            if((sum_a - a[i]) % 10 != 0)
            {
                sum_a -= a[i];
                break;
            }
        }
    }

    if(sum_a % 10 == 0)sum_a = 0;

    cout << sum_a << endl;
}



Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
using namespace std;
const int MAXN = (int) 105;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int m,n;
int a[MAXN][MAXN];
int mark[MAXN][MAXN];

void work(){
    int QvQ; scanf("%d",&QvQ);
    while(QvQ--){
        scanf("%d%d",&n,&m);
        for(int i=0;i<=n;i++){
            for(int j=0;j<=m;j++) mark[i][j]=0;
        }
        int x; scanf("%d",&x);
        while(x--){
            int aa,bb,cc,dd;
            scanf("%d%d%d%d",&aa,&bb,&cc,&dd);
            if(aa==cc){
                int y=max(bb,dd);
                mark[aa][y]+=1;
            }
            else{
                int y=max(aa,cc);
                mark[y][bb]+=2;
            }
        }
        for(int i=0;i<=n;i++){
            for(int j=0;j<=m;j++){
                if(i==0&&j==0) a[i][j]=1;
                else{
                    a[i][j]=0;
                    if(j>0&&(mark[i][j]&1)==0) a[i][j]+=a[i][j-1];
                    if(i>0&&(mark[i][j]&2)==0) a[i][j]+=a[i-1][j];
                }
            }
        }
        if(a[n][m]==0) printf("Miserable Hokusai!\n");
        else printf("%d\n",a[n][m]);
    }
}

int main(){
//    freopen("data.in","r",stdin);
    work();
    return 0;
}





Measured memory_bytes: 3144
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 2000
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};



//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    string s, t;
    cin>>s>>t;
    int ss = s.size(), tt = t.size();
    int ans = INT_MAX;
    for(int i = 0; i <= ss-tt ; i++)
    {
        int ac = 0;
        for(int j = 0; j< tt; j++)
            if(s[i+j] != t[j])
                ac++;
        ans = min(ans, ac);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3644
import collections

N, A = [int(s) for s in input().split()]

x = [int(s) for s in input().split()]

S = [collections.Counter() for _ in range(51)]

S[0][0] = 1
for i, xi in enumerate(x):
    prev = [(k,s,c) for k in range(i+1) for s,c in S[k].items()]
    for (k,s,c) in prev:
        S[k+1][s+xi] += c
    #print(sum(sum(S[k].values()) for k in range(i+1)))

ans = 0
for (k, s, c) in ((k,s,c) for k in range(1,N+1) for s,c in S[k].items()):
    if A*k == s:
        ans += c

print(ans)

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long long int> h(n);
    for(int i=0; i<n; i++) cin >> h[i];

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

    while(k>0){
        if(h.empty()) break;
        h.pop_back();
        k--;
    }
    long long int ans = 0;

    for(int i=0; i<h.size(); i++){
        ans += h[i];
    }

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

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

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	vector<long long int> b(n);
	for (long long int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	long long int ans = 0;
	for (long long int i = n-1; i >= 0; i--) {
		long long int k = (a[i]+ans) % b[i];
		if (k != 0) {
			ans += b[i] - k;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include "iostream"

#define H_MAX 55
#define W_MAX 55

using namespace std;

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

char c[H_MAX][W_MAX];

int main() {
    cin >> H >> W;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> c[i][j];
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (c[i][j] == '#') {
                bool flag = false;
                for (int k = 0; k < 4; k++) {
                    int ty = i + dy[k];
                    int tx = j + dx[k];

                    if (1 <= ty && ty <= H && 1 <= tx && tx <= W && c[ty][tx] == '#') {
                        flag = true;
                    }
                }
                
                if (!flag) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

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

Measured memory_bytes: 256
import numpy as np
w,h,n=map(int,input().split())
xya=[list(map(int,input().split())) for i in range(n)]
x=[xya[i][0] for i in range(n)]
y=[xya[i][1] for i in range(n)]
a=[xya[i][2] for i in range(n)]
s=np.array([[1]*w]*h)

for i in range(n):
  for j in range(h):
    for k in range(w):
      if a[i]==1 and k<x[i]:
        s[j,k]=0
      elif a[i]==2 and k>=x[i]:
        s[j,k]=0
      elif a[i]==3 and j<y[i]:
        s[j,k]=0
      elif a[i]==4 and j>=y[i]:
        s[j,k]=0
print(sum(sum(s)))

Measured memory_bytes: 12536
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n,k,q; cin>>n>>k>>q;
    int arr[n+1];
    for(int i=1;i<=n;i++) arr[i] = 0;
    for(int i=1;i<=q;i++)
    {
        int a; cin>>a;
        arr[a]++;
    }
    for(int i=1;i<=n;i++)
    {
        arr[i] += k;
    }
    for(int i=1;i<=n;i++)
    {
        arr[i] -= q;
    }
    for(int i=1;i<=n;i++)
    {
        if(arr[i] <= 0) cout<<"No"<<endl;
        else  cout<<"Yes"<<endl;
    }
    return 0;
}

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

int main(){
double a,b,tempa,tempb;
cin>>a>>b;
for(int i=1;i<=1000;i++)
{
    if(floor(i*0.08)==a&&floor(i*0.1)==b)
    {
        cout<<i;
        return 0;
    }
}
cout<<"-1";

}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int a[2010][2010],ans[2010];
int main(){
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			a[i][j]=abs(i-j);
		}
	}
	a[x][y]=1;
	a[y][x]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			a[i][j]=min(a[i][j],a[i][x]+1+a[y][j]);
			a[i][j]=min(a[i][j],a[i][y]+1+a[x][j]);
		}
	}
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=n-1;i++){
		for(int j=i+1;j<=n;j++){
			ans[a[i][j]]++;
		}
	}
	for(int i=1;i<=n-1;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 16000
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        s: i64,
    }

    let y = s / 100;
    let m = s % 100;
    let is_yymm = 1 <= m && m <= 12;
    let is_mmyy = 1 <= y && y <= 12;
    if is_yymm && is_mmyy {
        println!("AMBIGUOUS");
    } else if is_yymm {
        println!("YYMM");
    } else if is_mmyy {
        println!("MMYY");
    } else {
        println!("NA");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int X;
  cin >> X;
  if(X==3 || X==5 || X==7){
    cout << "YES" <<endl;
  }else{
    cout << "NO" <<endl;
  }
  
  return 0;

}

Measured memory_bytes: 256
s=str(input())
L = list(s)
count = 0
n = 0
for i in L:
  n += 1
  if n % 2 == 0:
    if i == "R":
      count += 1
  else:
    if i == "L":
      count += 1
if count == 0:
  print("Yes")
else:
  print("No")
    


Measured memory_bytes: 2940