akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

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

        String S = sc.next();
        int format = Integer.parseInt(S);
        int left = format / 100;
        int right = format % 100;

        if (left >= 1 && left <= 12) {
            if (right >= 1 && right <= 12) {
                System.out.println("AMBIGUOUS");
            } else {
                System.out.println("MMYY");
            }
        } else if (right >= 1 && right <= 12) {
            System.out.println("YYMM");
        } else {
            System.out.println("NA");
        }

    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  set<ll> cnt;
  for(ll i=0;i<3;i++) {
    ll tmp;
    cin >> tmp;
    cnt.insert(tmp);
  }
  cout << cnt.size() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct {int parent, left , right;} Node;

Node T[MAX];
int n,D[MAX], H[MAX];

void setDepth(int u , int d) {
  if ( u == NIL) return ;
  D[u]  = d;
  setDepth(T[u].left , d + 1);
  setDepth(T[u].right, d + 1);

}

int setHeight(int u)  {
  int h1 = 0, h2 = 0;
  if( T[u].left != NIL)
  h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
  h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
  return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
  return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  int i,c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
    int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ", deg );
  printf("depth = %d, ", D[u] );
  printf("height = %d, ", H[u] );

  if(T[u].parent == NIL) printf("root\n");
  else if (T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
  else printf("internal node\n");

}

int main()  {
  int i,v,l,r ,root = 0;
  scanf("%d\n",  &n);

  for(i = 0; i < n;i++) T[i].parent = NIL;

  for(i = 0 ; i < n ; i++) {
    scanf("%d %d %d \n", &v , &l , &r);
    T[v].left = l;
    T[v].right = r;
    if ( l != NIL) T[l].parent = v;
    if ( r != NIL) T[r].parent = v;
  }

  for(i = 0; i < n ;i++) if ( T[i].parent == NIL) root = i;

  setDepth(root , 0);
  setHeight(root);

  for ( i = 0; i  < n; i++) print(i);

  return 0;
}

Measured memory_bytes: 628
from collections import deque
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a-1)]
d=[[]for i in range(a)]
for i in range(a-1):
  ca=c[i][0]
  cb=c[i][1]
  d[ca-1].append(cb-1)
  d[cb-1].append(ca-1)
g=[0 for i in range(a)]
q=deque()
q.append(0)
e=b
while len(q):
  i=q.pop()
  h=len(d[i])
  g[i]=1
  if i==0:
      f=b-1
  else:
    f=b-2
  g[i]=1
  for j in range(h):
    if g[d[i][j]]==0:
      q.append(d[i][j])
      e=(e*f)%1000000007
      f-=1


print(e%1000000007)
  

Measured memory_bytes: 43608
import sys
sys.setrecursionlimit(10**9)
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
E = []
for i in range(N):
    E.append([])
for i in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)

ans = 0
for i in range(N):
    ok = True
    for to in E[i]:
        if(H[i] <= H[to]):
            ok = False
    if ok:
        ans += 1
print(ans)


Measured memory_bytes: 29432
from math import floor
n=int(input())
s=input()
r=0
g=0
b=0
for i in range (len(s)):
  if s[i]=='R':
    r+=1
  elif s[i]=='B':
    b+=1
  else:
    g+=1
c=0
for i in range(n - 2):
    for k in range(i + 2, n):
        if ( i + k ) % 2 != 0:
            continue
        j = ( i + k ) // 2
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            c += 1
 
      
ans=r*g*b-c;
print(ans)


Measured memory_bytes: 67952
#include <iostream>
#include <set>

int main()
{
	std::set<int> si;
	int q;
	std::cin >> q;
	while (q--) {
		int a, v;
		std::cin >> a >> v;
		if (a == 0) {
			si.insert(v);
			std::cout << si.size() << std::endl;
		} else if (a == 1) {
			if (si.count(v) == 1) {
				std::cout << 1;
			} else {
				std::cout << 0;
			}
			std::cout << std::endl;
		}
	}

	return 0;
}


Measured memory_bytes: 12436
n, k = [int(i) for i in input().split(' ')]
a, d = [], []
for i in range(2*k):
  if (i%2)==0:
    d.append(int(input()))
  else:
    a.extend([int(j) for j in input().split(' ')])

ans = n - len(set(a))
print(ans)

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

int main() {
	int n;
	cin >> n;
	string  str;
	cin >> str;
	int mid;
	int j;
	int flag=0;
	int size=str.size();
	//cout << size;
	if(size%2==1)
	cout << "No";
	else
	{
	    mid=size/2;
	    j=mid;
	    for(int i=0;i<mid;i++)
	    {
	      //  cout << j;
	        if(str[i]==str[j])
	        {
	           // cout << str[i]<<str[j];
	            j++; 
	            continue;
	           
	        }
	        else
	        {
	            //cout <<str[i]<<str[j]<<"me";
	            flag=1;
	        break;
	        }
	       
	    }
	    if(flag==1)
	    {
	        cout <<"No";
	    }
	    else
	    {
	        cout << "Yes";
	    }
	}
	
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();

		long ac = a*c;
		long ad = a*d;
		long bc = b*c;
		long bd = b*d;

		long maxa = Math.max(ac, ad);
		long maxb = Math.max(bc, bd);

		long maxall = Math.max(maxa, maxb);

		System.out.println(maxall);
	}
}

Measured memory_bytes: 35616
#include <iostream>
#include <cstdio>

using namespace std;

const int maxn=500005;
typedef long long ll;

int read()
{
	int f=0; char c=getchar();
	while(c>'9' || c<'0') c=getchar();
	while(c<='9' && c>='0') {f=f*10+c-'0'; c=getchar();}
	return f;
}
int n;
int a[maxn];

int main()
{
	cin>>n;
	int x;
	for(int i=2;i<=n;i++)
	{
		x=read();
		a[x]++;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define ll long long
#define P pair<int,int>
#define MP(a,b) make_pair(a,b)
using namespace std;
int n,m,dis[200005],head,tail,t,h[200005];
priority_queue<P> q;
set<int> in[200005];
struct E{int v,c,next;}g[400005];
void ins(int u,int v,int c){g[++t].v=v,g[t].c=c,g[t].next=h[u],h[u]=t;}
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	memset(dis,0x3f,sizeof dis);
	n=read(),m=read();
	for(int i=1;i<=m;++i){
		int u,v,c;
		u=read(),v=read(),c=read();
		ins(u,v,c); ins(v,u,c);
	}
	q.push(MP(0,1)); dis[1]=0;
	while(!q.empty()){
		int u=q.top().second,cost=-q.top().first;
		q.pop();
		if(cost>dis[u]) continue;
		for(int j=h[u];j;j=g[j].next){
			int v=g[j].v,c=g[j].c,d=dis[u]+(!in[u].count(c));
			if(d>dis[v]) continue;
			if(d<dis[v]){
				q.push(MP(-d,v));
				dis[v]=d;
				in[v].clear();
			}
			in[v].insert(c);
		}
	}
	printf("%d",dis[n]==1061109567?-1:dis[n]);
}

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

int main()
{
  
    string a;
    cin >> a;
   
    string b;
    cin >> b;
    // 文字列の入力
    // 出力
    int length_a =a.size();
    int length_b =b.size();
    if(length_b-length_a ==1){
        b.erase(length_b-1);

        if(b==a){
           cout << "Yes"  << endl;
        }else{
            cout << "No"  << endl;
        } 
    }else{
         cout << "No"  << endl;
    }  
    return 0;
}

Measured memory_bytes: 3568
import itertools

N = int(input())
L = list(map(int, input().split()))

if N < 3:
    print(0)
    exit()

ans = 0

for bars in itertools.combinations(L, 3):
    if max(bars) >= sum(bars) - max(bars):
        continue
    if bars[0] == bars[1]:
        continue
    if bars[1] == bars[2]:
        continue
    if bars[0] == bars[2]:
        continue
    ans += 1

print(ans)


Measured memory_bytes: 9180
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let mut A = buf_it.next().unwrap().parse::<isize>().unwrap();
    let mut B = buf_it.next().unwrap().parse::<isize>().unwrap();
    let K = buf_it.next().unwrap().parse::<usize>().unwrap();
    for i in 0..K{
        if i%2==0{
            A /= 2;
            B += A;
        } else {
            B /= 2;
            A += B;
        }
    }
    println!("{} {}",A,B);
}

Measured memory_bytes: 4352
def main():

    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    dp = [float('inf') for _ in range(N)]
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, K+1):
            if i - j >=0:
                dp[i] = min(dp[i], dp[i-j] + abs(H[i] - H[i-j]))

    return dp[N-1]

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 56928
import java.util.Scanner;

public class Main {
    public static int INF = Integer.MAX_VALUE;
    static Scanner sc;

    public static void main(String[] args) {
        init();

        while (true) {
            int a = ni();
            // System.out.println("-- " + a);
            if (a == 0) {
                break;
            }
            int[] words = new int[a];
            nl();
            for (int i = 0; i < a; i++) {
                words[i] = nl().length();
            }
            int i = 0;
            for (i = 0; i < a; i++) {
                int[] ks = { 5, 7, 5, 7, 7};
                int ki = 0;
                int t = 0;
                // System.out.println("c: " + i);
                for (int j = i; j < a; j++) {
                    t += words[j];
                    if (t == ks[ki]) {
                        ki++;
                        t = 0;
                        if (ki == 5) {
                            break;
                        }
                    } else if (t > ks[ki]) {
                        break;
                    }
                }
                if (ki == 5) {
                    break;
                }
            }
            if (i != a) {
                // System.out.println(i + 1);
                System.out.println(i + 1);
            }
        }
        end();
    }

    public static void init() {
        sc = new Scanner(System.in);
    }

    public static void end() {
        sc.close();
    }

    public static int ni() {
        return sc.nextInt();
    }

    public static String nl() {
        return sc.nextLine();
    }
}

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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
vector<ll> factor; 
void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        factor.push_back(2); 
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            factor.push_back(i);  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        factor.push_back(n);  
}

void solve()
{
    factor.clear();
    ll n;
    cin>>n;
    primeFactors(n);

    map<ll,ll> m;
    for(auto i: factor){
        m[i]++;
    }
    ll ans=0;
    for(auto i: m){
        ll temp=i.ss;
        ll temp1=1;
        while(temp>0){
            if(temp>=temp1){
                temp-=temp1;
                ans++;
            }else{
                break;
            }
            temp1++;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3680
#include<cstdio>
#include<vector>
std::vector<int> p;
int n,m,ans;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i*i<=m;i++)
	    if (m%i==0)
	    {
		    p.push_back(i);
		    if (i*i!=m) p.push_back(m/i); 
	    }
	for (int i=0;i<p.size();i++) if (p[i]>ans&&1ll*p[i]*n<=m) ans=p[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, m;
    cin >> n >> m;
    
    vector<string> vec(n);
    for (auto &s : vec) cin >> s;
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (vec[i][j] == '#') {
                if (i != n-1 and vec[i+1][j] == '#') continue;
                if (j != m-1 and vec[i][j+1] == '#') continue;
                if (i and vec[i-1][j] == '#') continue;
                if (j and vec[i][j-1] == '#') continue;
                return cout << "No\n", 0;
            }
        }
    }
    
    cout << "Yes\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  string s;
  cin >> s;
  string t = s.substr(0,3);
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>
using namespace std;

const int INF = 1001001001;
const int LIM_M = 10000;
const int LIM_N = 500;

int M, N;
int P[LIM_M + 10];
int C[LIM_N + 10], E[LIM_N + 10];

int PSum[LIM_M + 10];
int dp[LIM_M + 10];

int main() {
	int i, j;
	
	scanf("%d%d", &M, &N);
	for (i = 0; i < M; ++i) {
		scanf("%d", &P[i]);
	}
	for (j = 0; j < N; ++j) {
		scanf("%d%d", &C[j], &E[j]);
	}
	
	//	PSum[i] := maximum price for selling i manjus.
	sort(P, P + M, greater<int>());
	for (i = 0; i < M; ++i) {
		PSum[i + 1] = PSum[i] + P[i];
	}
	
	//	dp[i] := minimum expense for boxes to pack i manjus.
	//	invariant: dp[0] <= dp[1] <= ... <= dp[M].
	for (i = 0; i <= M; ++i) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for (j = 0; j < N; ++j) {
		for (i = M; i >= 0; --i) {
			if (dp[i] > dp[max(i - C[j], 0)] + E[j]) {
				dp[i] = dp[max(i - C[j], 0)] + E[j];
			}
		}
	}
	
	int ans = 0;
	for (i = 0; i <= M; ++i) {
		if (ans < PSum[i] - dp[i]) {
			ans = PSum[i] - dp[i];
		}
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1324
fun list() = readLine()!!.split(" ").map {it.toInt()}

class UF(size:Int) {
	private val a = IntArray(size) {-1}

	fun root(t:Int):Int = if(a[t]<0) t else root(a[t]).also {a[t] = it}

	fun isConnected(a:Int,b:Int) = root(a)==root(b)
	fun groupSize(t:Int) = -a[root(t)]

	fun connect(p:Int,q:Int):Boolean {
		val r = root(p)
		val s = root(q)
		if(r==s) return false
		if(a[r]>a[s]) {
			a[s] += a[r]
			a[r] = s
		} else {
			a[r] += a[s]
			a[s] = r
		}
		return true
	}
}

fun main() {
	val (n,q) = list()
	val uf = UF(n)

	for(i in 1..q) {
		val (t,u,v) = list()
		if(t==0)
			uf.connect(u,v)
		else
			println(if(uf.isConnected(u,v)) 1 else 0)
	}
}


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

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

    int n, d;
    cin >> n >> d;

    vector<int> hoge(n);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (hoge[i]) continue;
        cnt++;
        for (int j = i; j < min(n, i + 2 * d + 1); j++) {
            hoge[j] = 1;
        }
    }
    cout << cnt << endl;
}


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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  for (int i = 0; i < N; ++i)
    cin >> w[i] >> v[i];
  vector<vector<long long>> dp(N + 1, vector<long long>(W + 1));
  for (int i = 0; i < N; ++i) {
    for (int sum_w = 0; sum_w <= W; ++sum_w) {
      if (sum_w - w[i] >= 0)
        dp[i + 1][sum_w] = max(dp[i][sum_w - w[i]] + v[i], dp[i + 1][sum_w]);
      dp[i + 1][sum_w] = max(dp[i][sum_w], dp[i + 1][sum_w]);
    }
  }
  cout << dp[N][W] << endl;
}


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

int main(){
    
    int n;
    cin >> n;
    vector <double> c(n+1);
    vector < vector <double> > dp(n+1,vector <double>(n+1));
    dp[0][0]=1;
    for(int i =1;i<=n;i++){
        cin >> c[i];

        dp[0][i] = dp[0][i-1]*(1-c[i]);
        for(int heads = 1;heads<=i;heads++){
            dp[heads][i] = dp[heads-1][i-1]*c[i] + dp[heads][i-1]*(1-c[i]);
        }
    }
    double ans = 0;
    for(int i = n/2+1;i<=n;i++){
        ans+=dp[i][n];
    }
    printf("%.10f\n",ans);
}


Measured memory_bytes: 71040
//AOJ-GRL-7-A
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long MOD = 1e9 + 7;

struct BiMatch{
    int V, time;
    vector<vector<int>> G;
    vector<int> match, used;
    vector<bool> dead;

    BiMatch(int V) : V(V), time(0), G(V), match(V, -1), used(V, -1), dead(V, false){} 

    void add_edge(int u, int v){
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    bool dfs(int v){
        used[v] = time;
        for(int u : G[v]){
            if(dead[u]) continue;
            int w = match[u];
            if((w < 0) || (used[w] < time && dfs(w))){
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

    int build(){
        int res = 0;
        for(int v = 0; v < V; v++){
            if(dead[v]) continue;
            if(match[v] < 0){
                time++;
                res += dfs(v);
            }
        }
        return res;
    }
};

signed main(){
    int X,Y,e;
    cin >> X >> Y >> e;
    int V = X + Y;
    BiMatch bi(V);
    int x,y;
    REP(i,e){
        cin >> x >> y;
        bi.add_edge(x, X + y);
    }
    cout << bi.build() << endl;
    return 0;
}


Measured memory_bytes: 3256
##入力
N, M = list(map(int,input().split()))
sc = [list(map(int,input().split())) for _ in range(M)]
##最小の値を先にいれておく(10...0)
numl = [0 for _ in range(N)]
##2桁以上と分かっている場合1桁目は1以上でなくてはならない
if N >= 2:
  numl[0] = 1
flag = 0
s = [sc[i][0] for i in range(M)]
c = [sc[i][1] for i in range(M)]
##数字を桁ごとにリストに入れる
for i in range(M):
  numl[s[i]-1] = c[i]
##最初の桁が0で2桁以上ならだめ
if numl[0] == 0 and N >= 2:
  flag += 1
##同じ桁で違う数字を指定されたらだめ
for i in range(0, M-1):
  for j in range(i+1, M):
    if s[i] == s[j] and c[i] != c[j]:
      flag += 1
 
#結果
if flag != 0:
  print(-1)
else:
  Numl = [str(a) for a in numl]
  num=''.join(Numl)
  print(num)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));

            String result = "No";
            if (input.get(0).equals(input.get(1))) {
                result = "Yes";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


// Modint
struct Mint {
	static const long long mod = (long long)(1e9 + 7);
	long long val;

	Mint() { val = 0; }
	Mint(long long a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(long long p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0)
			std::cerr << "WARNING: inv() is called with 0." << std::endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	long long ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	long long ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

Mint pow(Mint a, long long b) {
	return a.pow(b);
}


int main() {
	int n, k; std::cin >> n >> k;
	std::vector<Mint> d(k + 1);
	Mint ans = 0;
	for (int i = k; i >= 1; i--) {
		Mint t = pow(Mint(k / i), (long long)n) - d[i];
		ans += Mint(i)*t;
		for (int j = 1; j*j <= i; j++) {
			if (i%j != 0) continue;
			d[j] += t;
			if (j*j != i) d[i/j] += t;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define H 255

int main(){
  int heap[H];
  int n,i;

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&heap[i]);

  for(i=1;i<=n;i++){
    printf("node %d: ",i);
    printf("key = %d, ",heap[i]);
    if(i/2 != 0)   printf("parent key = %d, ",heap[i/2]);
    if(2*i <= n)   printf("left key = %d, ",heap[2*i]);
    if(2*i+1 <= n) printf("right key = %d, ",heap[2*i+1]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    double x1,y1,x2,y2;
    int q;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    for(int i=1; i<=q; i++){
        double xp,yp,x,y;
        cin >> xp >> yp;
        double a,b,f;
        if(x1==x2){
            printf("%.12lf %.12lf\n",x1,yp);
        }
        else if(y1==y2){
            printf("%.12lf %.12lf\n",xp,y1);
        }
        else{
            a=(y2-y1)/(x2-x1);
            b=y1-a*x1;
            f=yp+1.0/a*xp;
            x=(f-b)/(a+1.0/a);
            y=a*x+b;
            printf("%.12lf %.12lf\n",x,y);
        }
    }
    return 0;
}


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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;

int main() {
    ios::sync_with_stdio(false);
    int k,x;
    cin >> k >> x;
    k--;

    for(int i = x-k; i <= x+k; i++) cout << i << " ";
    cout << endl;

    return 0;
}


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

int n;
pair<string,pair<int,int> > a[105];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second.first;
        a[i].second.first=-a[i].second.first;
        a[i].second.second=i;
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        cout<<a[i].second.second+1<<endl;
    }

    return 0;
}

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

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

using namespace std;

void dfs(int i,int n,const string dic[100],const bool b[300][100],vector<string> &tmp,vector<string> &ans){
if(i<-1) return;
	if(i==-1){
		string res;
		for(int j=(int)tmp.size()-1;j>=0;j--){
			res+=tmp[j];
			if(j>0) res+=' '; else res+='.';
		}
		ans.push_back(res);
	}

	rep(j,n) if(b[i][j]) {
		int m=dic[j].length();
		tmp.push_back(dic[j]);
		dfs(i-m,n,dic,b,tmp,ans);
		tmp.pop_back();
	}
}

int main(){
	char f[128];
	f['a']='2'; f['b']='2'; f['c']='2';
	f['d']='3'; f['e']='3'; f['f']='3';
	f['g']='4'; f['h']='4'; f['i']='4';
	f['j']='5'; f['k']='5'; f['l']='5';
	f['m']='6'; f['n']='6'; f['o']='6';
	f['p']='7'; f['q']='7'; f['r']='7'; f['s']='7';
	f['t']='8'; f['u']='8'; f['v']='8';
	f['w']='9'; f['x']='9'; f['y']='9'; f['z']='9';

	for(int n;cin>>n,n;){
		string dic[100];
		rep(i,n) cin>>dic[i];
		string seq; cin>>seq;

		string num[100];
		rep(i,n) rep(j,dic[i].length()) num[i]+=f[dic[i][j]];

		bool b[300][100]={}; // b[i][j] := ( num[j] が seq[0..i] の suffix かどうか )
		int cnt[300]={};
		rep(i,seq.length()){
			rep(j,n){
				int m=num[j].length();
				if(m<=i+1 && num[j]==seq.substr(i-m+1,m) && (i-m==-1 || cnt[i-m]>0)){
					b[i][j]=true;
					cnt[i]++;
				}
			}
		}

		vector<string> ans,tmp;
		dfs(seq.length()-1,n,dic,b,tmp,ans);
		rep(i,ans.size()) cout<<ans[i]<<endl;
		cout<<"--"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1272
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n: usize = read();
    let m: usize = read();
    let x: usize = read();
    let mut c: Vec<usize> = Vec::new();
    let mut a: Vec<Vec<usize>> = Vec::new();
    for _ in 0..n {
        let ci: usize = read();
        c.push(ci);
        let ai: Vec<usize> = (0..m).map(|_| read()).collect();
        a.push(ai);
    }
    let u: Vec<usize> = vec![0; m];
    let ans = rcs(0, 0, n, m, x, &c, &a, &u);
    if let Some(l) = ans {
        println!("{}", l);
    } else {
        println!("-1");
    }
}

fn rcs(i: usize, k: usize, n: usize, m: usize, x: usize, c: &Vec<usize>, a: &Vec<Vec<usize>>, u: &Vec<usize>) -> Option<usize> {
    let mut flag = true; 
    for j in 0..m {
        if u[j] < x {
            flag = false;
            break;
        }
    }
    if flag {
        return Some(k);
    }
    if i == n {
        return None;
    }
    let mut cu = u.clone();
    for j in 0..m {
        cu[j] += a[i][j];
    }
    let p = rcs(i+1, k+c[i], n, m, x, c, a, &cu);
    let q = rcs(i+1, k, n, m, x, c, a, u);
    if p.is_some() {
        if q.is_some() {
            return Some(std::cmp::min(p.unwrap(), q.unwrap()));
        } else {
            return p;
        }
    } else {
        if q.is_some() {
            return q;
        } else {
            return None;
        }
    }
    
}

Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>

int main()
{
    long N;
    long A[100000]={};
    std::cin >> N;
    for(long i=0; i<N; i++){
        std::cin >> A[i];
    }
    long pairs=0;
    for(long i=0; i<N-1; i++){
        if(A[i]%2==0){
            pairs+=A[i]/2;
            A[i]=0;
        }else{
            pairs+=A[i]/2;
            A[i]=1;
            if(A[i+1]>0){
                pairs+=1;
                A[i]=0;
                A[i+1]-=1;
            }
        }
    }
    pairs+=A[N-1]/2;
    std::cout << pairs << std::endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import deque
 
n,m = map(int,input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
path = [[] for _ in range(n+1)]
 
for a,b in ab:
    path[a].append(b)
    path[b].append(a)
 
q = deque([1])
ans = [0] * (n+1)
while q:
    v = q.popleft()
    for w in path[v]:
        if ans[w] == 0:
            ans[w] = v
            q.append(w)
 
print('Yes')
print(*ans[2:], sep="\n")

Measured memory_bytes: 59484
N, x = [ int(x) for x in input().split() ]
a = [ int(x) for x in input().split() ]

a = sorted(a)
sum = 0
count = 0
for i in a:
    sum += i
    if sum > x:
        break
    else:
        count += 1
if sum < x:
    count -= 1
print(count)


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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}



int main()
{

string s;cin>>s;
ll M=2019;
int n=s.length();
vector<int>save(M);
save[0]++;
int suf=0,total=0;
int pot=1;
for(int i=n-1;i>=0;i--)
{
int digit=s[i]-'0';
suf=(suf+pot*digit)%M;
pot=pot*10%M;
total+=save[suf];
save[suf]++;
}


cout<<total<<"\n";


  return 0;

}






Measured memory_bytes: 3720
import java.util.*;

public class Main {

	public static void main(String[] args) {
			
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		if (H == 1 || W == 1) {
			System.out.println(1);
		} else if (H % 2 == 1 && W % 2 == 1) {
			System.out.print(H*W/2+1);
		} else {
			System.out.print(H*W/2);
		}
	}
}

Measured memory_bytes: 21332
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define int long long

#if defined(_MSC_VER)
#pragma warning(disable : 4996)  // VSでscanfを使う．
#endif

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

  vector<int> a(n + 1);
  vector<int> b(n);

  for (int i = 0; i < n + 1; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }

  int p = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int t = min(a[i], p);
    a[i] -= t;

    int x = a[i];
    int u = min(x, b[i]);

    p = max(0ll, b[i] - x);

    ans += t + u;
  }

  ans += min(p, a[n]);

  cout << ans << endl;

  return 0;
}


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

int main(){
    string S;
    cin >> S;
    int ans = 0;
    if(S == "SUN")ans = 7;
    else if(S == "MON")ans = 6;
    else if(S == "TUE")ans = 5;
    else if(S == "WED")ans = 4;
    else if(S == "THU")ans = 3;
    else if(S == "FRI")ans = 2;
    else if(S == "SAT")ans = 1;
    cout << ans << endl;

}

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

using namespace std;

int main(){

  int n;

  while(cin>>n,n){
    int x,y;
    int stone[21][21]={0};
    for(int i=0;i<n;++i){
      cin>>x>>y;
      stone[x][y]=1;
    }
    
    int m;

    cin>>m;

    char dir;
    int dis;
    int x_n=10;
    int y_n=10;
    int cnt=0;

    for(int i=0;i<m;++i){
      cin>>dir>>dis;

      if(dir=='N'){
	for(int j=0;j<dis;++j){
	  y_n++;
	  if(stone[x_n][y_n]==1){
	    cnt++;
	    stone[x_n][y_n]=0;
	  }
	}
      }

      else if(dir=='E'){
	for(int j=0;j<dis;++j){
	  x_n++;
	  if(stone[x_n][y_n]==1){
	    cnt++;
	    stone[x_n][y_n]=0;
	  }
	}
      }

      else if(dir=='S'){
	for(int j=0;j<dis;++j){
	  y_n--;
	  if(stone[x_n][y_n]==1){
	    cnt++;
	    stone[x_n][y_n]=0;
	  }
	}
      }

      else if(dir=='W'){
	for(int j=0;j<dis;++j){
	  x_n--;
	  if(stone[x_n][y_n]==1){
	    cnt++;
	    stone[x_n][y_n]=0;
	  }
	}
      }
    }
    if(cnt==n)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}

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

int main(void){
    int x;
    cin >> x;
    int a = x/500;
    x = x%500;
    int b = x/5;
    cout << a*1000+b*5 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int i,j,k;
    cin >> n;
    string s;
    cin >> s;
    string alp="abcdefghijklmnopqrstuvwxyz";
    int h=0;

    for(i=1;i<n;i++){
        int tmp=0;
        string hid=s.substr(0,i);
        string mig=s.substr(i,n-i);
        for(j=0;j<26;j++){

            bool hidF= false;
            bool migF= false;

            for(k=0;k<hid.size();k++){
                if(hid.at(k)==alp.at(j)){
                    hidF=true;
                }
            }

            for(k=0;k<mig.size();k++){
                if(mig.at(k)==alp.at(j)){
                    migF=true;
                }
            }

            if(hidF&&migF)tmp++;
        }
    h=max(tmp,h);
    }
    cout << h << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

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

  ll m = INF;
  rep(i, 5) {
    ll a;
    cin >> a;
    if (m > a) {
      m = a;
    }
  }

  if (N % m == 0) {
    COUT(N / m + 4);
  } else {
    COUT(N / m + 1 + 4);
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n;
long long p = 1000000007;
long long x, s, a;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &x);
		a += p - x * x % p;
		a %= p;
		s += x;
		s %= p;
	}
	a += s * s;
	a %= p;
	printf("%lld\n", a * 500000004 % p);
}

Measured memory_bytes: 1724
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int a[1000 * 100 + 5];
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1 , a + n + 1);
	int s = 0, t;
	for(int i = 1; i <= n; i++){
		if(2 * s < a[i])
			t = i;
		s += a[i];
	}
	cout << n - t + 1 << endl;
	return 0;
}


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

int main(){
  
  vector<int> v = {0, 1, 0, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1};
  int x, y;
  cin >> x >> y;
  
  string ans = "No"; 
  if (v[x] * v[y] == 1){
    ans = "Yes";
  }

  cout << ans << endl;

}

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

using namespace std;

int n;
int arr[100];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	long double sum = arr[0];
	for (int i = 1; i < n; i++) {
		sum = (sum + arr[i]) / 2;
	}
	cout.precision(20);
	cout << fixed << sum << '\n';
	return 0;
}


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

string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s;
	for(int i = 0; i < (int)s.length(); i++) cout << "x";
	cout << "\n";
	return 0;
}

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


int main(void){

int c[5];
int ans,sum;



for(int i =0; i < 6; i++){
    cin >> c[i];
}

  sum = c[0] * 1;
  sum = (c[1] * 5) + sum;
  sum = (c[2] * 10) + sum;
  sum = (c[3] * 50) + sum;
  sum = (c[4] * 100) + sum;
  sum = (c[5] * 500) + sum;
  
  if(sum >= 1000)
      ans = 1;
  else
    ans = 0;
      
      
 cout  << ans   << endl;

}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s,t;
    cin >> s >> t;
    if(t==s+t[t.size()-1])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;

template <typename T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}

template <typename T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


int main() {
	int N, K;
	cin >> N >> K;
	int keta = ceil(log(N) / log(K));
	if (keta == 0)keta = 1;
	cout << keta << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
int main(){

 //   freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
	
	int n,k;cin>>n>>k;
	string s;cin>>s;
	int diff[n];
	
	forn(i,n -1)
	{	
		if(s[i] == 'R' && s[i+1] == 'L') diff[i] = 1;
		else if(s[i] == 'L' && s[i+1] == 'R') diff[i] = -1;
		else diff[i] = 0;
	}        
	int ng = 0, pos = 0;
	int ans = 0;
	forn(i, n - 1){
		if(diff[i] == 1)pos ++;	
		if(diff[i] == -1) ng ++;
		if(diff[i] == 0)ans++;
	}	

	int add = min(ng, pos);
	ng -= add;
	pos -= add;
	add = min(k, add);
	k -= add;

	ans += 2*add;
	if(k == 0) cout<<ans;
	else{
		if(ng > 0 && s.back() == 'R')ans++;
		if(pos > 0 && s.back() == 'L') ans++;
		cout<<ans<<endl;
	}
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 848
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)
string name[100000];
int tim[100000];
int indexo[100000];
int tmstmp=0;
queue<int> Q;
int n, q;


int main() {
	rep(i, 100000) indexo[i] = i;
	//入力
	cin >> n >> q;
	rep(i,n) {
		cin >> name[i] >> tim[i];
		Q.push(indexo[i]);
		Q.push(tim[i]);
		//pairでqueueに格納できるとうれしいんだけどな！！！無理そう！！
	}
	while (!Q.empty()) {
		int curi = Q.front();
		Q.pop();
		int curt = Q.front();
		Q.pop();
		if (curt > q) {
			curt -= q;
			Q.push(curi);
			Q.push(curt);
			tmstmp += q;
		}
		else if(curt<=q){
			tmstmp += curt;
			cout << name[curi] << " " << tmstmp << endl;;
		}
	}
	return 0;
}


Measured memory_bytes: 7232
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

int main() {		
	int n;
	scanf ("%d", &n);
	ll res = (ll) n * (n + 1) / 2;
	ll a = n / 3;
	res -= a * (a + 1) / 2 * 3;
	ll b = n / 5;
	res -= b * (b + 1) / 2 * 5;
	ll c = n / 15;
	res += c * (c + 1) / 2 * 15;
	printf ("%lld", res);
	
	
	return 0;
}


Measured memory_bytes: 3828
import java.util.*
import kotlin.math.*

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


fun main(){
	
	val n=readLine()!!.toLong()
	for(i in -120L..120L){
	   for(j in -120L..120L){
	       val x:Long =i*i*i*i*i
	       val y:Long =j*j*j*j*j
	       if(x-y==n){
	          print("${i} ${j}")
	          return

	       }
	   }
	}
}

Measured memory_bytes: 34468
#include<bits/stdc++.h>
using namespace std;
string s;
int k;
vector<string>v;
set<string>ss;
int main()
{
	cin>>s>>k;
	for(int i=0;i<s.size();i++)
	{
		for(int j=1;j<=5;j++)
		{
			if(i+j>s.size())
			{
				break;
			}
			ss.insert(s.substr(i,j));
		}
	}
	for(set<string>::iterator it=ss.begin();it!=ss.end();it++)
	{
		v.push_back(*it);
	}
	sort(v.begin(),v.end());
	cout<<v[k-1]<<endl;
	return 0;
}


Measured memory_bytes: 1920
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll sum = 0;
    ll a[N];
    rep(i, N){
        cin >> a[i];
        sum += a[i];
    }

    ll cost1 = 0;
    ll cost2 = 0;
    ll center1 = sum / N;
    ll center2 = sum / N + 1;
    rep(i, N){
        cost1 += (center1 - a[i]) * (center1 - a[i]);
        cost2 += (center2 - a[i]) * (center2 - a[i]);
    }
    
    cout << min(cost1, cost2) << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 998244353;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 

int main() {
  fastio;
	ll m,d;
	cin>>m>>d;
	ll ans = 0;
	for(ll i=1;i<=m;i++) {
		for(ll j=1;j<=d;j++) {
			ll d1 = j%10,d2=(j/10)%10;
			if(d1>=2 and d2>=2 and d1*d2==i) ans++; 
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256