akhauriyash/Code-Regression huggingface dataset:
class UnionFindVerSize():
    def __init__(self, N):
        self._parent = [n for n in range(0, N)]
        self._size = [1] * N

    def find_root(self, x):
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x])
        return self._parent[x]

    def unite(self, x, y):
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

import sys

input = sys.stdin.readline

N,M = map(int,input().split())
uf = UnionFindVerSize(N)
for i in range(M):
    u,v = map(int,input().split())
    uf.unite(u-1,v-1)

print(uf.calc_group_num()-1)

Measured memory_bytes: 80288
#124
n=input()
def check(n,st_num):
    count=0
    dic={1:1,0:2}
    for i in range(1,-(-len(n)//2)):
        try:
            if n[2*i]+n[2*i+1]==st_num:
                count+=0
            else:
                count+=dic[abs(int(n[2*i])+int(n[2*i+1])-1)]
        except:
            if n[2*i]!=st_num[0]:
                count+=1
    
    return count
    
if '1' not in n:
    print(len(n)//2)
    exit()
if n[:2]=="10":
    print(check(n,"10"))
elif n[:2]=="01":
    print(check(n,"01"))
else:
    print(0 if len(n)==1 else min([check(n,"10")+1,check(n,"01")+1]))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

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

		if ((N % 10) == 7 || ((N / 10) % 10) == 7 || (N / 100) == 7) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


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

int main(){
    int N; cin >> N;
    string s; cin >> s;
    int dp[N+1][N+1];
    memset(dp,0,sizeof(dp));
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(s[i]==s[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }
            ans=max(ans,min(j-i,dp[i+1][j+1]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 97920
#include<bits/stdc++.h>
using namespace std;
int main(){
  int food[5];
  for(int i=0; i<5; i++){
    cin >> food[i];
  }
  
  int num = food[0];
  int tmp = num % 10;
  int a;
  int ans = 0;
  for(int i=1; i<5; i++){
    a = food[i] % 10;
    if(a != 0 && a < tmp){
      if(tmp != 0){
        ans += num - tmp + 10;
      }else{
        ans += num;
      }
      tmp = a;
      num = food[i];
    }else{
      if(a != 0){
        ans += food[i] - a + 10;
      }else{
        ans += food[i];
      }
    }
  }
  cout << ans + num << endl;
  
  return 0;
}

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

int main(){
    int l, k;
    cin >> l >> k;
    LL ans = 0;
    int t = k+1;
    for(int nf=0; 1+nf*2 <= l; nf++){
        int ns = (l-(1+nf*2))/t;
        rep(j, ns+1){
            LL tmp = 1;
            rep(i, min(nf, j)){
                tmp *= (nf+j-i);
                tmp /= (i+1);
            }
            ans += tmp;
        }
    }
    for(int nf=0; k+nf*2 <= l; nf++){
        int ns = (l-(k+nf*2))/t;
        rep(j, ns+1){
            LL tmp = 1;
            rep(i, min(nf, j)){
                tmp *= (nf+j-i);
                tmp /= (i+1);
            }
            ans += tmp;
        }
    }
    cout << ans << endl;
}




    




Measured memory_bytes: 3120
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################




l , r , d = map(int , input().split())
ans = 0
for i in range(l,r+1):
	if i%d==0:
		ans+=1
print(ans)






Measured memory_bytes: 67316
using System;
class Program
{
    static void Main(string[] args)
    {
        bool isFirst = true;
        int[] coins = new int[] { 10, 50, 100, 500 };
        int range = coins.Length;
        int bill, ownedMoney, changeMoney;
        int[] ownedCoins = new int[range], changeCoins = new int[range], paymentCoins = new int[range];

        while (true)
        {
            bill = int.Parse(Console.ReadLine());
            if (bill == 0) break;
            if (isFirst) { isFirst = false; } else { Console.WriteLine(); }
            ownedCoins = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            ownedMoney = 0;
            for (int i = 3; i >= 0; i--)
                ownedMoney += coins[i] * ownedCoins[i];

            changeMoney = ownedMoney - bill;

            for (int i = 3; i >= 0; i--)
            {
                changeCoins[i] = changeMoney / coins[i];
                changeMoney = changeMoney % coins[i];
                paymentCoins[i] = ownedCoins[i] - changeCoins[i];
            }
            for (int i = 0; i <= 3; i++)
                if (paymentCoins[i] > 0) Console.WriteLine("{0} {1}", coins[i], paymentCoins[i]);
        }
    }
}


Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
int k;
void lunlun(vector<long long>& a) {
  int i = 0;
  while (a.size() < 100005) {
    if (a.at(i) % 10 == 9) {
      a.push_back(a.at(i) * 10 + a.at(i) % 10 - 1);
      a.push_back(a.at(i) * 10 + a.at(i) % 10);
    } else if (a.at(i) % 10 == 0) {
      a.push_back(a.at(i) * 10);
      a.push_back(a.at(i) * 10 + a.at(i) % 10 + 1);
    } else {
      a.push_back(a.at(i) * 10 + a.at(i) % 10 - 1);
      a.push_back(a.at(i) * 10 + a.at(i) % 10);
      a.push_back(a.at(i) * 10 + a.at(i) % 10 + 1);
    }
    i++;
  }
}

int main() {
  cin >> k;
  vector<long long> a;
  for (int i = 1; i <= 9; i++) a.push_back(i);
  lunlun(a);
  cout << a.at(k - 1);
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

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

    int n;
    cin >> n;

    vector<int> a(n);
    REP(i, n)
        cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[n - 1] - a[0] << '\n';
    return 0;
}

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

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

    string s;
    cin>>s;
    bool al[26];
    for(int i=0;i<26;i++)al[i]=true;
    for(int i=0;i<s.size();i++)al[s[i]-'a']=false;
    if(s.size()!=26){
        cout<<s;
        for(int i=0;i<26;i++){
            if(al[i]){
                cout<<(char)('a'+i)<<endl;
                return 0;
            }
        }
    }
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout<<-1<<endl;
        return 0;
    }
    bool ans[26];
    int pos;
    for(int i=0;i<26;i++)ans[i]=false;
    for(int i=25;i>=0;i--){
        ans[s[i]-'a']=true;
        if(s[i]>s[i-1]){
            pos=i-1;
            break;
        }
    }
    cout<<s.substr(0,pos);
    for(int i=0;i<26;i++){
        if(ans[i] && 'a'+i>s[pos]){
            cout<<(char)('a'+i)<<endl;
            return 0;
        }
    }
}

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

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

	int q;
	cin >> q;

	deque<int> A;

	for( int i = 0; i < q; ++i ) {
		int cmd, d, p, x;
		cin >> cmd;

		if( cmd == 0 ) { // push
			cin >> d >> x;

			if( d == 0 ) { A.push_front( x ); }
			else { A.push_back( x ); }
		}
		else if( cmd == 1 ) { // access
			cin >> p;
			cout << A.at( p ) << '\n';
		}
		else if( cmd == 2 ) { // pop
			cin >> d;

			if( d == 0 ) { A.pop_front(); }
			else { A.pop_back(); }
		}
	}
}



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

int main() {
	
	string S,T;
	cin >>S >>T;
	
	int count=0;
	
	for(int i=0; i<3; i++){
		
		if(S.at(i)==T.at(i)){
			count++;
		}
		
	}
	
	cout <<count <<endl;
}

Measured memory_bytes: 256
import sys

def solve(N: int, Y: int):
    max_i = int(Y//10000)
    for i in range(0,max_i+1):
        for j in range(N-i+1):
            k = N-i-j
            if 10000*i+5000*j+1000*k == Y:
                print(i,j,k)
                return 

    print(-1,-1,-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()

ll A, B, N;

ll f(ll x) {
	return (A*x) / B - A * (x / B);
}

int main(){
	cin >> A >> B >> N;
	ll ans;
	if(B - 1 <= N) {
		ans = f(B - 1);
	} else {
		ans = f(N);
	}
	cout << ans << endl;
}

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

using namespace std;

int solveYZ(int k, int s) {
  if (k * 2 < s) {
    return 0;
  }
  if (k * 2 == s) {
    return 1;
  }
  if (k >= s) {
    return s + 1;
  }

  return s + 1 - (s - k) * 2;
}

int solveXYZ(int k, int s) {
  int ret = 0;
  int const n = std::min(k, s);
  for (int x = n; x >= 0; --x) {
    int const yz = solveYZ(k, s - x);
    if (!yz) {
      break;
    }
    ret += yz;
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int k, s;
  std::cin >> k >> s;
  std::cout << solveXYZ(k, s) << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    int sum = 0;
    
    for(int i = 0; i<n.length(); i++){
      sum += Character.getNumericValue(n.charAt(i));
    }

    if(sum % 9 == 0){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
   
    sc.close();
    return;
  }
  
}


Measured memory_bytes: 40328
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;


long long int comb(int a, int b) {
	long double ans=1;
	for (int i = 0; i < a-b; ++i) {
		ans*=a-i;
	}

	for (int i = 0; i < a - b; ++i) {
		ans/=i+1;
	}

	return static_cast<long long int>(ans);
}
int main() {
	int N,A,B,C,D;cin>>N>>A>>B>>C>>D;
	int ans=min(((N-1)/A+1)*B,((N-1)/C+1)*D);
	cout<<ans<<endl;
	return 0;
}




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

using namespace std;

int main() {
    int n;
    cin >> n ;
    vector<int>p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];

    int min = 300000, ans = 0;
    for (int i = 0; i < n; i++) {
        if (min > p[i])min = p[i], ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rg register
#define ll long long
#define db double
#define N 100005
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(a*c<=b) printf("%d",c);
	else printf("%d",b/a);
	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void func(long long N, std::vector<long long> A){

    lli ans = 0;
    sort(A.rbegin(),A.rend());

    if(N==2){
        cout<<A[0]<<endl;
        return;
    }
    if(N==3){
        cout<<A[0]+A[1]<<endl;
        return;
    }
    REP(i,0,N/2){
        ans += A[i];
        if(i!=0)ans+=A[i];
    }
    if(N%2!=0){
        ans += A[N/2];
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4848
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)
ll MOD = 1000000007;
int main() {
    int a, b;
    cin >> a >> b;
    if (a <= b) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}



Measured memory_bytes: 3644
def main():
    n = int(input())
    gems = [int(x) for x in input().split()]
    cost = [int(x) for x in input().split()]
    res = []
    for i in range(n):
        res.append(gems[i] - cost[i])
    soma_n = sum([x if x > 0 else 0 for x in res])
    print(soma_n)
main()

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (A + B >= 10) {
            System.out.println("error");
        } else {
            System.out.println(A + B);
        }
    }
}


Measured memory_bytes: 21972
#include<stdio.h>
#define LIM 100

void *Sels(int *,int *);

int main() {

  int N,num[LIM];
  int i,j;

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&num[i]);

  j=N;
  Sels(num,&N);
  
  for(i=0;i<j;i++) {
    if(i>0) printf(" ");
    printf("%d",num[i]);
  }

  printf("\n%d\n",N);

  return 0;

}

void *Sels(int *num,int *a) {

  int N=*a;
  int minj;
  int i,j,k;
  *a=0;

  for(i=0;i<=N-1;i++) {
    minj = i;

    for(j=i;j<=N-1;j++) {
      if(num[j] < num[minj]) minj = j;
    }
    k=num[i]; num[i] = num[minj]; num[minj] = k;
    if(i!=minj) *a=*a+1;
  }
}


Measured memory_bytes: 2104
M=10**9+7
n,k=map(int,input().split())
l=[1]
f=1
for i in range(n):
  f=f*(i+1)%M
  l+=[f]
a=0
for i in range(min(n,k+1)):
  c=p=1
  c=c*l[n]*l[n-1]%M
  p=p*l[i]**2*l[n-i]*l[n-i-1]%M
  a+=c*pow(p,M-2,M)
print(a%M)

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

int main(){
    int num;
    std::cin >> num;
    std::vector<int> a(num);
    // int a[num];
    for (int i = 0; i < num; ++i)
    {
        int cnt = 0;
        std::cin >> a[i];
        if (a.at(i)%2 == 1)
        {
            a[i] = 0;
        }else{
            while (a.at(i)%2 == 0)
            {
                a[i] = a.at(i)/2;
                ++cnt;
            }
            a[i] = cnt;
        }
    }
    int ans = *std::min_element(a.begin(), a.end());
    std::cout << ans << "\n";
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll C, ll mod){
  ll ans = 1; C = min(C, N - C);
  for (ll i = 1; i <= C; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}


int main(){
  int H, N; cin >> H >> N;

  int A[N], B[N];
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

  int M = 0;
  for (int i = 0; i < N; i++) M = max(M, A[i]);

  int DP[H + M + 1];
  fill(DP, DP + H + M + 1, 1e9);
  DP[0] = 0;
  for (int i = 0; i < H + M + 1; i++){
    for (int j = 0; j < N; j++){
      if (i + A[j] < H + M + 1){
        DP[i + A[j]] = min(DP[i + A[j]], DP[i] + B[j]);
      }
    }
  }
  
  int ans = 1e9;
  for (int i = H; i < H + M + 1; i++){
    ans = min(ans, DP[i]);
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
	string s;
	cin >> s;
	while (cin){
		string aux;
		char a;
		int op, rev = 0;
		deque<char> d(s.begin(), s.end());
		cin >> op;
		cin.get(a);
		for (int i = 0; i < op; ++i){
			getline(cin, aux);
			if (aux[0] == '1')
				rev = (rev + 1) % 2;
			else{
				if ((aux[2] == '2' && rev == 0) || (aux[2] == '1' && rev == 1))
					d.push_back(aux[4]);
				else d.push_front(aux[4]);
			}
		}
		int k = d.size();
		if (rev == 0){
			for (int i = 0; i < k; ++i){
				cout << d.front();
				d.pop_front();
			}
		}
		else{
			for (int i = 0; i < k; ++i){
				cout << d.back();
				d.pop_back();
			}
		}
		cout << "\n";
		cin >> s;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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

int main(){

    vector<pair<string,int> >v;
    int n,t; string s;
    cin >> n;
    rep(i,n){

    cin >> s >> t;

    bool f=true;
    rep(j,v.size()){
    if(s==v[j].first){
    v[j].second+=t; f=false; break;
    }
    }

    if(f) v.push_back(make_pair(s,t));

    }

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

	ostringstream os;
	REP(j,1,5){
	rep(i,v.size()){
		if(v[i].first.size()==j){
		os << v[i].first << ' ' << v[i].second;
		cout << os.str() << endl;
		os.str("");
	}
	}
	}

	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// -------------------------------------------------------------------------------------

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

  if(b-a == c-b) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int a, b, k;

    cin >> k >> a >> b;

    for(int i = a;  i <= b; i++) {
        if(i%k == 0) {
            cout << "OK\n";
            return 0;
        }
    }

    cout << "NG\n";

  
    return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define sort_v(a) sort(a.begin(), a.end())

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

int main()
{
    string s, t;
    cin >> s >> t;

    int si = s.size();
    rep(i, 0, si)
    {
        bool f = true;
        rep(j, 0, si)
        {
            if (s[(i + j) % si] != t[j])
            {
                f = false;
                break;
            }
        }
        if (f)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    // 3桁整数の入力
//    val inputInt = sc.nextInt()
    val inputInt = sc.next()
    val inputList = inputInt.toString().split("")

    var flg = false
    inputList.forEach {
        if (it == "7") {
            flg = true
            return@forEach
        }
    }

    if (flg) {
        println("Yes")
    } else {
        println("No")
    }
}

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

int main() {
  int R, G, B, N, ans;
  cin >> R >> G >> B >> N;
  for (int r = 0; r < N+1; r++) {
    for (int g = 0; g < N+1; g++) {
      if (N - R*r - G*g >= 0 && (N - R*r - G*g) % B == 0)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

ll N, K;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N >> K;
    cout << min(N % K, K - (N % K));
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
n, m = map(int, input().split())
dic = {i: -1 for i in range(1, n + 1)}
for _ in range(m):
    s_, c_ = map(int, input().split())
    if dic[s_] == -1:
        dic[s_] = c_
    else:
        if dic[s_] != c_:
            print(-1)
            exit()
if n == 1:
    if dic[1] == -1:
        print(0)
    else:
        print(dic[1])
    exit()
if dic[1] == 0:
    print(-1)
    exit()
res = ""
keys = list(dic.keys())
keys.sort()
for k in keys:
    if dic[k] == -1:
        if k == 1:
            res += "1"
        else:
            res += "0"
    else:
        res += str(dic[k])
print(res)

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

using namespace std;

const int Dim = 5e3 + 5;
const int Mod = 1e9 + 7;

int mx[ Dim ], r[ Dim ], dp[ Dim ][ Dim ], sum[ Dim ];
int n, m, x, y;

char s[ Dim ];

int main() {
  //  freopen ("input.txt", "r", stdin);

    cin >> n >> m >> (s + 1);
    for (int i = 1; i <= n; ++ i) {
        r[ i ] = i;

        sum[ i ] = sum[i - 1];
        if (s[ i ] == '0')
            ++sum[ i ];
    }

    for (int i = 1; i <= m; ++ i) {
        cin >> x >> y;
        r[ x ] = max (r[ x ], y);
    }

    for (int i = 1; i <= n; ++ i) {
        mx[ i ] = max (r[ i ], mx[i - 1]);
    }

    mx[n + 1] = mx[ n ];
    dp[ 1 ][ sum[ r[ 1 ] ] ] = 1;

    for (int i = 1; i <= n; ++ i) {
        for (int j = 0; j <= m; ++ j) {
            if (dp[ i ][ j ] == 0)
                continue;

            int v1 = j;
            int v2 = mx[ i ] - i + 1 - v1;

            int nr1 = sum[ mx[i + 1] ] - sum[ mx[ i ] ];
            if (v1) {
                dp[i + 1][nr1 + j - 1] += dp[ i ][ j ];
                dp[i + 1][nr1 + j - 1] %= Mod;
            }

            if (v2) {
                dp[i + 1][nr1 + j] += dp[ i ][ j ];
                dp[i + 1][nr1 + j] %= Mod;
            }
        }
    }

    cout << dp[n + 1][ 0 ] << '\n';
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
        ll a, b, k;
        cin >> a >> b >> k;
        if (a < k) {
                b -= k - a;
                a = 0;
                if (b < 0)
                        b = 0;
        } else {
                a -= k;
        }
        cout << a << ' ' << b << endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b;
  cin >> a >> b;

  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	int a,b;
	int n =1000;
	cin >> a;
	cin >> b;
	if(a>b){dame}
	rep1(i,n+1){
	if(int{i*0.08} == a && int{i*0.1} == b){cout << i << endl;return 0;}
	
	}
	dame
	return 0;
	

}

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

#define ll long long
#define mod 1000000007
vector<ll>adj[100001];
ll dp[100001]={0};
bool vis[100001]={false};

void dfs(ll s){

    vis[s]=true;
    for(ll i=0;i<adj[s].size();i++){
        if(vis[adj[s][i]]==false)dfs(adj[s][i]);

        dp[s]=max(dp[s],1+dp[adj[s][i]]);
    }

}

int main() {

    ll n,m,x,y;
    cin>>n>>m;

    for(ll i=0;i<m;i++){
        cin>>x>>y;
        adj[x].push_back(y);
    }

    for(ll i=1;i<=n;i++){
        if(!vis[i])dfs(i);
    }
    ll ans=dp[1];
    for(ll i=1;i<=n;i++)ans=max(ans,dp[i]);
    cout<<ans<<endl;



    return 0 ;
}


Measured memory_bytes: 8576
#include<stdio.h> 
const int N = 305;
const int M = 305;
int main()
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == 0)
		{
			break;
		}
		for(int i = 0; i < m; i++)
		{
			printf("#");
		}
		 printf("\n");
		for(int i = 0; i < n-2; i++)
		{
			printf("#");
			for(int j = 0; j < m-2;j++)
			{
				printf(".");
			}
			printf("#");
			printf("\n");
		}
		for(int i = 0; i < m; i++)
		{
			printf("#");
		}
		printf("\n\n");
	}

	return 0;
}


Measured memory_bytes: 2624
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

const ll INF=1e15;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> A(n);
    for(auto &I:A){cin>>I;}
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(n+1,vector<ll>(n+1,-INF)));
    dp[0][0][0]=0;
    for(int i=0;i<=n;i++){
        for(int t=0;t<=n;t++){
            for(int j=0;j<=n;j++){
                if(i!=n){dp[i+1][t][j]=max(dp[i+1][t][j],dp[i][t][j]+A[i]);}
                if(i!=n && j!=n){dp[i+1][t][j+1]=max(dp[i+1][t][j+1],dp[i][t][j]);}
                if(t!=n){dp[i][t+1][j]=max(dp[i][t+1][j],dp[i][t][j]+A[n-t-1]);}
                if(t!=n && j!=n){dp[i][t+1][j+1]=max(dp[i][t+1][j+1],dp[i][t][j]);}
            }
        }
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        for(int t=0;t<=n;t++){
            for(int j=0;j<=n;j++){
                if(i+t+j<=k && i+t<=n){ans=max(ans,dp[i][t][j]);}
            }
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

string S, T;

int main() {

	cin >> S >> T;

	rep(i, S.size()) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	if (T.size() == S.size() + 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3612
#include<iostream>

using namespace std;
int main()
{
 int x[100000][3],arr[100000][3],q,n;
 cin>>n; 
 for(int i=0;i<n;i++)
 {
  cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
 }
 x[0][0]=(arr[0][1]>arr[0][2])?arr[0][1]:arr[0][2];
 x[0][1]=(arr[0][0]>arr[0][2])?arr[0][0]:arr[0][2];
 x[0][2]=(arr[0][1]>arr[0][0])?arr[0][1]:arr[0][0]; 
 for(int i=1;i<n;i++)
 { 
  x[i][0]=(x[i-1][1]+arr[i][1]>x[i-1][2]+arr[i][2])?x[i-1][1]+arr[i][1]:x[i-1][2]+arr[i][2];
  x[i][1]=(x[i-1][2]+arr[i][2]>x[i-1][0]+arr[i][0])?x[i-1][2]+arr[i][2]:x[i-1][0]+arr[i][0];
  x[i][2]=(x[i-1][0]+arr[i][0]>x[i-1][1]+arr[i][1])?x[i-1][0]+arr[i][0]:x[i-1][1]+arr[i][1];
 }
 q=max(max(x[n-1][0],x[n-1][1]),x[n-1][2]);
 cout<<q;
 return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
     
    #define REP(i,n) for(int i=0;i<(int)(n);++i)
    #define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
     
    using namespace std;
    typedef long long ll;
     
    int main(){
        int N;
        cin >> N;
        int H[N];
        REP(i,N){
            cin >> H[i];
        }

        for (int i = N-1;i > 0; i--){
            if(H[i-1] > H[i]){
                H[i-1]--;
                if(H[i-1] > H[i]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }

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

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int count = 0;
            for(int i = 0; i<S.Length;i++){
                if(S[i]=='R'){
                    if(i != 0){
                        if(S[i-1]=='R'){
                            count++;
                        }else{
                            count = 1;
                        }
                    }else{
                        count = 1;
                    }
                    
                }

            }
            Console.WriteLine(count);
        }
            
        
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 25972
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long

int main() {
	int n;
	bool s1[4] = { true,true,false,false };
	bool s2[4] = { true,false,true,false };
	bool s3[4] = { true,false,false,true };
	string s;
	cin >> n >> s;
	if (s[0] == 'x') {
		REP(i, 4) {
			if (s3[i]) s3[i] = false;
			else s3[i] = true;
		}
	}

	REP(k, 4) {
		bool tl[114514] = {}, ok1 = {}, ok2 = {};
		tl[0] = s1[k];
		tl[1] = s2[k];
		tl[n - 1] = s3[k];
		//n - 2までの判定
		FOR(i, 1, n - 2) {
			if (tl[i]) {
				if (s[i] == 'o') {
					if (tl[i - 1]) tl[i + 1] = true;
					else tl[i + 1] = false;
				}
				else {
					if (tl[i - 1]) tl[i + 1] = false;
					else tl[i + 1] = true;
				}
			}
			else {
				if (s[i] == 'o') {
					if (tl[i - 1]) tl[i + 1] = false;
					else tl[i + 1] = true;
				}
				else {
					if (tl[i - 1]) tl[i + 1] = true;
					else tl[i + 1] = false;
				}
			}
		}

		//一周して矛盾がないか
		if (tl[n - 2]) {
			if (s[n - 2] == 'o') {
				if (tl[n - 3] == tl[n - 1]) ok1 = true;
			}
			else {
				if (tl[n - 3] != tl[n - 1]) ok1 = true;
			}
		}
		else {
			if (s[n - 2] == 'o') {
				if (tl[n - 3] != tl[n - 1]) ok1 = true;
			}
			else {
				if (tl[n - 3] == tl[n - 1]) ok1 = true;
			}
		}

		if (tl[n - 1]) {
			if (s[n - 1] == 'o') {
				if (tl[n - 2] == tl[0]) ok2 = true;
			}
			else {
				if (tl[n - 2] != tl[0]) ok2 = true;
			}
		}
		else {
			if (s[n - 1] == 'o') {
				if (tl[n - 2] != tl[0]) ok2 = true;
			}
			else {
				if (tl[n - 2] == tl[0]) ok2 = true;
			}
		}

		if (ok1 && ok2) {
			string out;
			REP(i, n) {
				if (tl[i]) out.push_back('S');
				else out.push_back('W');
			}
			cout << out << endl;
			return 0;
		}

	}

	cout << -1 << endl;

}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,x,y,tot,ne[N],fi[N],zz[N];
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
int dfs(int x,int y){
	int s1=0,s2=0,p=0;
	for (int k=fi[x];k;k=ne[k])
		if (zz[k]!=y){
			int p=dfs(zz[k],x);
			s2|=s1&p;
			s1|=p;
		}
	while (((1<<p)<s2)||(s1&(1<<p)))p++;
	return (s1>>p<<p)|(1<<p);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		jb(x,y);jb(y,x);
	}
	printf("%d\n",(int)log2(dfs(1,0)));
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll n;
bool ok(vector<l_l> ls){
    ll h=0;
    rep(i,sz(ls)){
        ll b=ls[i].fi;
        if(h+b<0)return false;
        h+=ls[i].se;
    }
    return true;
}
int main(){
    cin>>n;
    vector<l_l> ls,rs;
    ll tot=0;
    rep(i,n){
        string s;cin>>s;
        ll h=0,b=0;
        rep(j,sz(s)){
            if(s[j]=='(')h++;
            else h--;
            b=min(b,h);
        }
        tot+=h;
        if(h>=0)ls.pb({b,h});
        else rs.pb({b-h,-h});
    }
    sort(ls.rbegin(),ls.rend());
    sort(rs.rbegin(),rs.rend());
    if(ok(ls)&&ok(rs)&&tot==0){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 34616
import itertools
N = int(input())
S = [input()[0] for i in range(N)]
march = ["M", "A", "R", "C", "H"]
sum = 0
for c in list(itertools.combinations(march,3)):
    sum += S.count(c[0]) * S.count(c[1]) * S.count(c[2])
print(sum)

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

int main(void){
    char x, y;
    cin >> x >> y;
    if(x < y){
        cout << '<' << endl;
    }else if(x > y){
        cout << '>' << endl;
    }else{
        cout << '=' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

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

    int N, x;
    cin >> N >> x;

    vector<int> a;
    int num;
    REP(_, N)
    {
        cin >> num;
        a.PB(num);
    }
    sort(ALL(a));

    int res = 0;
    int sum = 0;
    int i = 0;

    if (x >= a[0]){
        res--;
        while (i < N && sum <= x)
        {
            sum += a[i];
            i++;
            res++;
        }
        if(sum == x) res++;

    }
        

    

    cout << res;
}

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

int res,n;

void dfs(int x,int d,int p){
	if(x<=n&&p==7)res++;
	
	if(d==10)return ;
	else{
		dfs(x*10+3,d+1,p|1);
		dfs(x*10+5,d+1,p|2);
		dfs(x*10+7,d+1,p|4);
	}
}

signed main(){
	cin>>n;
	dfs(0,0,0);
	cout<<res<<endl;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

int main() {
  int s,w;
  cin>>s>>w;

  if(s<=w){
    ANS("unsafe");
  }else{
    ANS("safe");
  }
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int a,b;
    cin >> a >> b;

    if(a+b == 15){
        cout << "+" << endl;
    }else if(a*b == 15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int64_t no  =   999'999'999'999;
    int64_t yes = 9'999'999'999'999;
    while(no + 1L < yes) {
        int64_t mid = (no + yes) / 2;
        cout << "? " << mid << endl;
        char res;
        cin >> res;
        if(res == 'Y') {
            yes = mid;
        } else {
            no = mid;
        }
    }

    while(yes % 10L == 0) {
        yes /= 10L;
    }

    if(to_string(yes).size() != to_string(yes+1).size()) {
        cout << "! " << yes << endl;
        return 0;
    }

    while(true) {
        cout << "? " << yes+1L << endl;
        char res;
        cin >> res;
        if(res == 'Y') {
            cout << "! " << yes << endl;
            break;
        } else if(yes > 100'000'000) {
            cout << "! " << yes << endl;
        } else {
            yes *= 10L;
        }
    }
    return 0;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, a;
    cin >> n >> a;
    n %= 500;
    if (n <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

const int MAX_N = 200000;
    
class UnionFind {
private:
    int union_size[MAX_N];
    int rank[MAX_N];

public:
    int par[MAX_N];
    
    void init(int n)
    {
        for (int i=0; i<n; i++) {
            par[i]=i;
            rank[i]=0;
            union_size[i] = 1;
        }
    }
    
    // 木の根を求める
    int find(int x)
    {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    
    // xとyの属する集合を併合する
    void merge(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y) return;

        union_size[x] += union_size[y];
        union_size[y] = union_size[x];

        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
    
    // xとyが同じ集合に属するか判定する
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    
    // x が含まれる集合の要素数を返す
    int getUnionSize(int x)
    {
        return union_size[find(x)];
    }
};


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

    int N, K, L;
    cin >> N >> K >> L;

    UnionFind UF1, UF2;
    UF1.init(N), UF2.init(N);

    rep(i, K) {
        int P, Q;
        cin >> P >> Q;
        P--, Q--;
        UF1.merge(P, Q);
    }

    rep(i, L) {
        int R, S;
        cin >> R >> S;
        R--, S--;
        UF2.merge(R, S);
    }
    
    map<PII, int> ans;
    rep(i, N) {
        ans[PII(UF1.find(i), UF2.find(i))]++;
    }

    rep(i, N) {
        if (i > 0) cout << " ";
        cout << ans[PII(UF1.find(i), UF2.find(i))];
    }
    cout << endl;
}



Measured memory_bytes: 16640