akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int par[10000], rank[10000];

void init(int n) {
  for (int i=0; i<n; i++) {
    par[i]=i;
    rank[i]=0;
  }
}
int find(int val) {
  if (val==par[val]) {
    return val;
  } else {
    par[val]=find(par[val]);
    return par[val];
  }
}
void unite(int x,int y) {
  x=find(par[x]);
  y=find(par[y]);
  par[x]=y;
  if (x==y) {
    return;
  }
  /*if (rank[x]<rank[y]) {
    par[x]=y;
  } else {
    par[y]=x;
    if (rank[x]==rank[y]) {
      rank[x]++;
    }
    }*/
}
bool same(int x,int y) {
  x=find(x);
  y=find(y);
  return x==y;
}
int main() {
  int n, q;
  cin >> n >> q;
  init(n);
  for (int i=0; i<q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com==0) {
      unite(x,y);
    } else {
      printf("%d\n",same(x,y));
    }
  }
  return 0;
}

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

 int main() {
     int A, B, C;
     cin >> A >> B >> C;
     
     if ((A<C && B<C) || (A>C && B>C)){
     cout << "No"<< endl;

 }

    else {
     cout << "Yes" << endl;
 }
 }


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

int main(){

  int n,a,b;

  scanf("%d %d %d", &n, &a, &b);

  if(n*a < b) printf("%d\n", n*a);

  else printf("%d\n", b);
  
  return 0;
}


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

int h,w;
char g[105][105];
int d[105][105];

int main(){

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

    cin>>h>>w;
    for(int i=1;i<=h;i++){
        cin>>g[i]+1;
    }
    memset(d,0x3f3f3f3f,sizeof(d));
    queue<pair<int,int> > q;
    q.push(make_pair(1,1));
    d[1][1]=g[1][1]=='#';
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;
        q.pop();
        if(x<h&&d[x+1][y]>d[x][y]+(g[x][y]=='.'&&g[x+1][y]=='#')){
            d[x+1][y]=d[x][y]+(g[x][y]=='.'&&g[x+1][y]=='#');
            q.push(make_pair(x+1,y));
        }
        if(y<w&&d[x][y+1]>d[x][y]+(g[x][y]=='.'&&g[x][y+1]=='#')){
            d[x][y+1]=d[x][y]+(g[x][y]=='.'&&g[x][y+1]=='#');
            q.push(make_pair(x,y+1));
        }
    }
    cout<<d[h][w]<<endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

long long int euclid(const long long int x, const long long int y) 
{
  long long int r;
  long long int temp_x = x, temp_y = y;

  while (!((r = temp_x % temp_y) == 0)) {
    temp_x = temp_y;
    temp_y = r;
  }

  return temp_y;
}

int main(void)
{
  long long int k;
  long long int a, b, c;
  long long int sum = 0, sum_temp = 0, sum_temp2 = 0, sum_temp3 = 0;
  long long int i;
  long long int gcd_bc, gcd;

  scanf("%lld", &k);

  /*a==b==c*/
  for (i = 1; i <= k; i++)
    sum += i;

  /*a > b > c*/
  for (a = 1; a <= k; a++) {
    for (b = 1; b < a; b++) {
      for (c = 1; c < b; c++) {
	gcd_bc = euclid(b, c);
	gcd = euclid(a, gcd_bc);
	sum_temp += gcd;
      }
    }
  }
  sum += (6 * sum_temp);

  /*a = b > c*/
  for (a = 1; a <= k; a++) {
    for (c = 1; c < a; c++) {
      gcd = gcd_bc = euclid(a, c);
      sum_temp2 += gcd;
    }
  }
  sum += (3 * sum_temp2);

  /*a > b = c*/
  for (a = 1; a <= k; a++) {
    for (b = 1; b < a; b++) {
      gcd = gcd_bc = euclid(a, b);
      sum_temp3 += gcd;
    }
  }
  sum += (3 * sum_temp3);

  /*sum*/
  printf("%lld", sum);

  return 0;
}


Measured memory_bytes: 1728
#include <stdio.h>

int main(void)
{ 
  int n, k, h;
  int cnt = 0;
  
  scanf("%d %d", &n, &k);
  
  for (int i = 0; i < n; i++) {
    scanf("%d", &h);
    if (h >= k)
      cnt++;
  }
    
  printf("%d", cnt);
  
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

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

long long min(long long a,long long b){
  if(a < b){
    return a;
  }
  return b;
}

long long gcd(long long a,long long b){
  if(b == 0) return a;
  else gcd(b,a%b);
}

int main(void){
  int N;
  scanf("%d",&N);
  long long T[N];
  long long ans = 1;

  for(int i = 0;i < N;i++){
    scanf("%lld",&T[i]);
  }

  for(int i = 0;i < N;i++){
    ans = ans/gcd(max(ans,T[i]),min(ans,T[i]))*T[i];
  }
  
  printf("%lld",ans);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

set<int> st = {7,5,3};
int X; cin >> X;
st.insert(X);
if(st.size() == 3) cout << "YES" << endl;
else cout << "NO" << endl;

return 0;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Int (Int64)
import Data.Coerce
import qualified Data.ByteString.Char8 as BS
import Control.Exception (assert)

main = do
  n <- readLn
  s <- BS.getLine
  assert (BS.length s == 2 * n) $ return ()
  let loop :: N -> Int -> Int -> N
      loop !acc !k !i | BS.length s == i = if k == 0 then acc else 0
                      | BS.index s i == 'W' = if even k
                                              then loop (acc * fromIntegral k) (k-1) (i+1)
                                              else loop acc (k+1) (i+1)
                      | otherwise = if even k
                                    then loop acc (k+1) (i+1)
                                    else loop (acc * fromIntegral k) (k-1) (i+1)
  print $ loop (product (coerce ([1..fromIntegral n] :: [Int64]) :: [N])) 0 0

--
-- Modular Arithmetic
--

modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined

{-# RULES
"^9/Int" forall x. x ^ (9 :: Int) = let u = x; v = u * u * u in v * v * v
"^9/Integer" forall x. x ^ (9 :: Integer) = let u = x; v = u * u * u in v * v * v
 #-}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int a,b,c,d;
void solve(){
	cin >> a >> b >> c >> d;
	
	if((a+d-1)/d >= (c+b-1)/b){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3636
private val map = LinkedHashMap<Long, Long>()

fun main() {
    val (n, m) = readLine()!!.split(" ").map { it.toLong() }
    repeat(n.toInt()) { _ ->
        val (a, b) = readLine()!!.split(" ").map { it.toLong() }
        map[a] = (map[a] ?: 0) + b
    }

    var count = m
    var result = 0L
    map.toSortedMap().forEach {
        val index = it.key
        val i = it.value

        val take = if (i <= count) {
            i
        } else {
            count
        }
        result += take * index
        count -= take
        if (count == 0L) {
            println(result)
            return
        }
    }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  int sum = 1;
  if (b == 1) cout << 0 << endl;
  else {
    rep(i,1000) {
      sum += a - 1;
      cnt++;
      if (sum >= b) {
        cout << cnt << endl;
        break;
      }
    }
  }
}

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

int t[100005], x[100005], y[100005];

int main(){
    int n; cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> t[i] >> x[i] >> y[i];
    for(int i = 1; i <= n; i++){
        int dist = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
        int dif = (t[i]-t[i-1])-dist;
        if(dif < 0 || dif%2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }

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


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N,M;
	cin >> N>>M;
	int arr[N+1] = {0};
	vector<int> ab[N+1];
	for(int i =1; i<=N;i++)
	{
		cin >> arr[i];
	}
	for(int i = 0; i<M;i++)
	{
		int a,b;
		cin >>a>>b;
		if(arr[a] <= arr[b])
			ab[a].push_back(b);
		if(arr[b] <= arr[a])
			ab[b].push_back(a);
	}
	int sum = 0;
	for(int i = 1;i<=N;i++)
	{
		if(ab[i].size() == 0)
			sum++;
	}
	cout << sum<<endl;


}


Measured memory_bytes: 8188
s = input()

count = 0
left, right = 0, len(s)-1
while True:
    if s[left] == s[right]:
        left, right = left+1, right-1
    elif s[left] == 'x':
        left = left+1
        count += 1
    elif s[right] == 'x':
        right = right-1
        count += 1
    else :
        count = -1
        break
    if left >= right:
        break
print(count)

Measured memory_bytes: 3316
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()

l = [0]*9
for i in A:
    l[min(i//400,8)] += 1

lf = l[:-1]
ans = 8-lf.count(0)
print(max(1,ans),ans+l[8])


Measured memory_bytes: 3060
//08
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  for(double d;cin>>d,d;){
    double px,py,dx,dy;
    cin>>px>>py>>dx>>dy;
    if(px*dy-py*dx){
      goto fail;
    }else{
      double cd=sqrt(px*px+py*py);
      double td=(px*dx+py*dy>0)?2-cd:cd;
      if(d<td){
	goto fail;
      }else{
	cout<<fixed<<td<<endl;
	continue;
      }
    }
  fail:
    cout<<"impossible"<<endl;
  }
  return 0;
}

	

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

char vec[12][13];

void def(int x, int y) {
    vec[x][y] = '0';
    if(vec[x+1][y]=='1') 
        def(x+1, y);
    if(vec[x][y+1]=='1')
        def(x, y+1);
    if(vec[x-1][y]=='1')
        def(x-1, y);
    if(vec[x][y-1]=='1')
        def(x, y-1);
}

int main() {
    while(1) {
        for(int i = 0; i < 12; i++) {
            for(int j = 0; j < 12; j++) {
                cin >> vec[i][j];
            }
        }
        if(cin.eof())return 0;

        int ans = 0;
        for(int i = 0; i < 12; i++) {
            for(int j = 0; j < 12; j++) {
                if(vec[i][j] == '1') {
                    ans++;
                    def(i, j);
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3076
A, B, K = map(int, input().split())

if B - A + 1 < 2*K:
    for i in range(A, B+1):
        print(i)
else:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;
char s[100005];
int pan[100];
int sum = 0;
int ans = 0;
int n, m, k;
int main()
{
	scanf("%s", s + 1);
	int len = strlen(s + 1);
	int vis = 1;
	if(s[1] != 'A')vis = 0;
	if(s[2] == 'C' || s[len] == 'C')vis = 0;
	int cnt = 0;
	for(int i = 1 ; i <= len ; i++){
		if(s[i] >= 'A' && s[i] <= 'Z')cnt++;
	}
	if(cnt != 2)vis = 0;
	if(vis == 1)printf("AC\n");
	else printf("WA\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  int sum = 0;
  cin >> n >> k;
  
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    int a = (x - 0) * 2;
    int b = (k - x) * 2;
    if (a < b) sum += a;
    else sum += b;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());

int main()
{
    string s, t;
    cin >> s >> t;
    vector<int> a, b;
    rep(i, s.size())
    {
        a.push_back(s[i] - '0');
    }
    rep(j, t.size())
    {
        b.push_back(t[j] - '0');
    }
    SORT(a);
    SORT_INV(b);
    rep(i, min(s.size(), t.size()))
    {
        if (a[i] == b[i])
            continue;
        else if (a[i] < b[i])
        {
            cout << "Yes" << endl;
            return 0;
        }
        else if (a[i] > b[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if (a.size() < b.size())
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 100010;
bool ok = true;
int b[N], visit[N];
vector<P> graph[N];
VI ans;

void dfs(int now){
    visit[now] = 1;
    for (P p : graph[now]){
        int next = p.first;
        int id = p.second;
        if (visit[next]) continue;
        dfs(next);
        if (b[next]){
            ans.push_back(id);
            b[now] ^= 1;
        }
    }
}

int main(void){
    int n, m;
    cin >> n >> m;
    vector<P> p(n);
    REP(i,n){
        p[i].first = in();
        p[i].second = in();
    }
    sort(ALL(p));
    VI a(n);
    REP(i,n) a[i] = p[i].first;
    REP(i,n-1) b[i + 1] = (p[i].second ^ p[i+1].second);
    b[0] = p[0].second;
    b[n] = p[n - 1].second;
    VI u(m), v(m);
    REP(i,m){
        int l = in(), r = in();
        u[i] = lower_bound(ALL(a), l) - a.begin();
        v[i] = upper_bound(ALL(a), r) - a.begin();
    }
    REP(i,m){
        if (u[i] != v[i]){
            graph[u[i]].push_back(P(v[i], i));
            graph[v[i]].push_back(P(u[i], i));
        }
    }
    REP(i,n){
        if (visit[i]) continue;
        dfs(i);
        if (b[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    sort(ALL(ans));
    cout << ans.size() << endl;
    for (int x : ans) cout << x + 1 << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 17532
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ll = - 10**18 - 1
rr = 10**18 + 1
while ll + 1 < rr:
  x = (ll + rr) // 2
  tot = 0
  for i in range(N):
    if A[i] < 0:
      l = -1
      r = N
      while l + 1 < r:
        c = (l + r) // 2
        if A[i] * A[c] < x:
          r = c
        else:
          l = c
      tot += N - r
    else:
      l = -1
      r = N
      while l + 1 < r:
        c = (l + r) // 2
        if A[i] * A[c] < x:
          l = c
        else:
          r = c
      tot += r
    if A[i] * A[i] < x:
      tot -= 1
  tot //= 2
  if tot < K:
    ll = x
  else:
    rr = x
print(ll)

Measured memory_bytes: 104888
#include<stdio.h>
int main(void){
        int a[6]={};
        int val[6]={1,5,10,50,100,500};
        int i,x=0;
        for(i=0;i<6;i++){
                scanf("%d",&a[i]);
                x=x+a[i]*val[i];
        }
        if(x>=1000)
                puts("1");
        else
                puts("0");
        return 0;
}

Measured memory_bytes: 1800
import java.util.Scanner;

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

		n = sc.nextInt();
		while (n != 0) {
			a = new int[n][n];
			int i = n / 2 + 1;
			int j = n / 2;
			int number = 1;
			while (n * n >= number) {
				if (a[i % n][j % n] == 0) {
					a[i % n][j % n] = number;
					number++;
					i++;
					j++;
				} else {
					i++;
					j--;
					a[i % n][j % n] = number;
					number++;
					i++;
					j++;
				}
			}
			for (int k = 0; k < n; k++) {
				for (int l = 0; l < n; l++) {
					System.out.printf("%4d", a[k][l]);
				}
				System.out.println();
			}
			n = sc.nextInt();
		}
	}
}

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

class UnionFind{
    vector<int>p,sz;
public:
    UnionFind(int n){
        p.resize(n,-1);
        sz.resize(n,1);
    }
    int find(int x){
        if(p[x] == -1)return x;
        else return p[x] = find(p[x]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)return;
        if(sz[x] > sz[y])swap(x,y);
        p[x] = y;
        sz[y] += sz[x];
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>p(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    UnionFind uf(n);
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        uf.unite(a,b);
    }
    int ans=0;
    rep(i,n){
        if(uf.same(p[i],p[p[i]]))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4576
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
using namespace std;
int main(int argc,char** argv){
  int a,b;
  cin >> a >> b;
  if(a % 2 == 0 || b % 2 == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	enum Go {
		W, B;
		static Go of(String s) {
			return ("0".equals(s)) ? W : B;
		};
	};

	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		for (int n; (n = in.nextInt()) != 0;) {
			Deque<Integer> table = new LinkedList<Integer>();
			Go nowLast = null;
			for (int posi = 1; posi <= n; posi++) {
				Go put = Go.of(in.next());
				if (put.equals(nowLast)) {
					table.addLast(Integer.valueOf(table.removeLast() + 1));
				} else {
					if (posi % 2 == 1) {
						table.addLast(Integer.valueOf(1));
					} else {
						int add = 1 + table.removeLast().intValue();
						Integer prepre = table.pollLast();
						if (prepre != null) {
							add += prepre.intValue();
						}
						table.addLast(Integer.valueOf(add));
					}
				}
				nowLast = put;
			}
			if (nowLast.equals(Go.B)) {
				table.removeLast();
			}
			int counter = 0;
			for (; !table.isEmpty();) {
				counter += table.removeLast().intValue();
				table.pollLast();
			}
			System.out.println(counter);
		}
		in.close();
	}
}

Measured memory_bytes: 69600
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;
using Graph = vector<vector<int>>;

signed _main(){
  int N,M; cin >> N >> M;
  int ans=0;
  v<int> H(N);
  Graph G(N);
  rep(i,N) cin >> H[i];
  rep(i,M){
    int a,b; cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i,N){
    int tmp=0;
    fore(j,G[i]){
      if(H[i]<=H[j]) tmp++;
    }
    if(tmp!=0);
    else ans++;
  }
  cout << ans << endl;
  return 0;
}


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

//https://qiita.com/tubo28/items/e6076e9040da57368845
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 s: Vec<char> = read::<String>().chars().collect();

    for c in 0..3{
        print!("{}",s[c]);
    }
    println!();
}


Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

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

	for (int i=0; i<3; i++) {
		if (s[i] == t[i]) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 888
using System;
using static System.Console;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] input = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int count_5 = 0;
        int count_7 = 0;

        foreach (int n in input)
        {
            if (n == 5)
            {
                count_5++;
            }
            else if (n == 7)
            {
                count_7++;
            }
        }

        if (count_5 == 2 && count_7 == 1)
        {
            WriteLine("YES");
        }
        else
        {
            WriteLine("NO");
        }

        ReadKey();
    }
}

Measured memory_bytes: 13396
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	cin >> N;
	vector<string>s(N);
	for (auto &i : s)cin >> i;
	vector<int>mi(N, 0);
	vector<int>sum(N, 0);
	for (int i = 0; i < N; i++) {
		int box = 0;
		for (auto j : s[i]) {
			if (j == '(')box++;
			else box--;
			mi[i] = min(mi[i], box);
		}
		sum[i] = box;
	}
	vector<pair<int, int>>l;
	vector<pair<int, int>>r;
	for (int i = 0; i < N; i++) {
		if (sum[i] >= 0) {
			l.emplace_back(mi[i], sum[i]);
		}
		else {
			mi[i] = 0;
			sum[i] = 0;
			reverse(s[i].begin(), s[i].end());
			int box = 0;
			for (auto &j : s[i]) {
				if (j == ')')box++;
				else box--;
				mi[i] = min(mi[i], box);
			}
			sum[i] = box;
			r.emplace_back(mi[i], sum[i]);
		}
	}
	sort(l.rbegin(), l.rend());
	sort(r.rbegin(), r.rend());
	int lsum = 0, rsum = 0;
	bool flag = true;
	for (auto i : l) {
		if (i.first + lsum < 0)flag = false;
		lsum += i.second;
	}
	for (auto i : r) {
		if (i.first + rsum < 0)flag = false;
	
		rsum += i.second;
	}
	if (lsum != rsum)flag = false;
	if (flag)cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n,m,p,q;
  	cin>>n>>m;
  	if(n<2&&m<2)cout<<0<<endl;
  	else
    {
      p=(n>2)?(n*(n-1)/2):1;
      q=(m>2)?(m*(m-1)/2):1;
      if(n<2)p=0;
      if(m<2)q=0;
      cout<<p+q;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seqS = new int[n];
      String[] line = br.readLine().split(" ");
      int c=0;
      for (String s : line)
        seqS[c++] = Integer.parseInt(s);

      int q = Integer.parseInt(br.readLine());
      line = br.readLine().split(" ");
      
      int cnt=0;
      for (String ref : line) {
        if( isExistSeachByBinary(seqS, Integer.parseInt(ref)) )
          cnt++;
      }

      System.out.println(cnt);
    }
  }

  static boolean isExistSeachByBinary(int[] tar, int ref) {
    int left = 0;
    int right= tar.length;
    int mid;
    while( left < right ) {
      mid  = (left + right) / 2;
      if( tar[mid] == ref ) return true;
      else if( tar[mid] > ref ) right = mid;
      else left = mid + 1;
    }

    return false;
  }
}


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

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

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

int m;

int get (const string& s) {
  int n = (int) s.size();
  vector <int> z(n);
  for (int i = 1, l = 0, r = 0; i < n; i++) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n and s[z[i]] == s[i + z[i]]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  vector <bool> vis(n, false);
  int ans = 0;
  for (int i = m; i < n; i++) {
    if (vis[i]) continue;
    vis[i] = true;
    if (z[i] >= m) {
      int cnt = 1;
      int j = i;
      while (j + m < n and z[j + m] >= m) {
        j += m;
        vis[j] = true;
        cnt++;
      }
      ans = max(ans, cnt);
    }
  }
  return ans;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  string s, t;
  cin >> s >> t;
  m = sz(t);
  string S = s;
  while (sz(S) < sz(t)) S = S + S;
  string X = S + S;
  string Y = X + S;
  string Z = Y + S;
//  int ans1 = get(t + X);
  double t1 = clock();
  int ans2 = get(t + Y);
  double t2 = clock();
  if ((t2 - t1) / CLOCKS_PER_SEC > 1.2) {
    cout << -1 << endl;
    return (0);
  }
  int ans3 = get(t + Z);
  if (ans2 != ans3) {
    cout << -1 << endl;
    return (0);
  } else {
    cout << ans2 << endl;
  }
  return (0);
}


Measured memory_bytes: 35928
n = int(input())
for i in range(1, n+1) :
    x = i
    if (x%3 == 0) :
        print(' %d' % i, end = '')
    else :
        while (x) :
            if (x%10 == 3) :
                print(' %d' % i, end = '')
                break
            x //= 10
print('')


Measured memory_bytes: 5872
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;


int main(){
  
  ll a,b,c,d; cin>>a>>b>>c>>d;
  cout<<max({a*c,a*d,b*c,b*d})<<endl;
  
  
}


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

int main(){
    int n; cin>>n;
    vector<pair<int,int>> p(n);
    for(int i=0;i<n;i++){
        int a,b; 
        cin>>a>>b;
        p[i]=make_pair(b,a);
    }
    sort(p.begin(),p.end());
    long long sum=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        sum+=p[i].second;
        if(sum>p[i].first) flag=false;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 1792
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 2e5 + 20;
const int inf = 1e9 + 7;

int n;
int a[N], h[N];
ll dp[N];
ll t[4 * N];

void upd(int v, int tl, int tr, ll x, int pos)
{
	if(tl == tr) { t[v] = max(t[v], x); re; }
	int c = (tl + tr) >> 1;
	if(pos > c) upd(2 * v + 2, c + 1, tr, x, pos);
	else upd(2 * v + 1, tl, c, x, pos);
	t[v] = max(t[2 * v + 1], t[2 * v + 2]);
}
ll get(int v, int tl, int tr, int l, int r)
{
	if(l > tr || r < tl) re -inf;
	if(l <= tl && tr <= r) re t[v];
	int c = (tl + tr) >> 1;
	re max(get(2 * v + 1, tl, c, l, r), get(2 * v + 2, c + 1, tr ,l, r));
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) 
		scanf("%d", h + i);
	for (int i = 0; i < n; i++) 
		scanf("%d", a + i);
	for (int i = 0; i < n; i++) {
		ll cur = max(get(0, 0, N, 0, h[i] - 1), (ll) 0);
		dp[i] = cur + a[i];
		upd(0, 0, N, dp[i], h[i]);
	}
	cout << *max_element(dp, dp + n);
}

Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main() {
    int n; cin >> n;
    for(int i = 1; i<10;i++) {
        for(int j = 1; j<10; j++) {
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>


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

using namespace std;

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

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

  if (N == 0)
  {
    cout << X << endl;
    return 0;
  }

  int num_min = 1000;
  int num = 0;
  bool isOK=false;
  while (1)
  {
    auto res1 = find(p.begin(), p.end(), X+num);
    if (res1 == p.end())
    {
      num_min = min(num_min, X + num);
      isOK = true;
    }

    auto res2 = find(p.begin(), p.end(), X - num);
    if (res2 == p.end())
    {
      num_min = min(num_min, X - num);
      isOK = true;
    }

    if (isOK)
    {
      cout << num_min << endl;
      return 0;
    }

    num++;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int n;
int F[110][15];
int f[110];
long long P[110][15];
int main() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 10; ++j) {
            cin >> F[i][j];
        }
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 11; ++j) {
            cin >> P[i][j];
        }
    }
    for(int i = 0; i < n; ++i) {
        int sum = 0;
        int pos = 0;
        for(int j = 9; j >= 0; --j) {
            if(F[i][j]) {
                sum += pow(2, pos);
            }
            pos++;
        }
        f[i] = sum;
    }

    long long ans = -1e12;
    for(int bit = 1; bit < (1<<10); ++bit) {
        long long ansc = 0;
        for(int i = 0; i < n; ++i) {
            int cnt = 0;
            int check = (bit & f[i]);
            for(int j = 0; j < 10; ++j) {
                if(check & (1<<j)) cnt++;
            }
            ansc += P[i][cnt];
        }
        ans = max(ans, ansc);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
signed main() {
    ll n,m;
    while(true){
        cin>>n>>m;
        if(n==0&&m==0)break;
        cout<<min(n,m)<<" "<<max(n,m)<<endl;
    }


}


Measured memory_bytes: 3084
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		boolean[] ary = new boolean[8];
		Arrays.fill(ary, Boolean.FALSE);
		int maximum = 0;
		int minimum = 0;
		
		int t = 0;
		for ( int i = 0; i < n; i++ ) {
			t = in.nextInt();
			if ( t >= 1 && t <= 399 )
				ary[0] = true;
			else if ( t >= 400 && t <= 799 )
				ary[1] = true;
			else if ( t >= 800 && t <= 1199 )
				ary[2] = true;
			else if ( t >= 1200 && t <= 1599 )
				ary[3] = true;
			else if ( t >= 1600 && t <= 1999 )
				ary[4] = true;
			else if ( t >= 2000 && t <= 2399 )
				ary[5] = true;
			else if ( t >= 2400 && t <= 2799 )
				ary[6] = true;
			else if ( t >= 2800 && t <= 3199 )
				ary[7] = true;
			else if ( t >= 3200 )
				maximum++;
		}
		
		for (int i = 0; i < 8; i++ ) {
			if (ary[i]) {
				minimum++;
				maximum++;
			}
		}
		
		if ( minimum == 0 && maximum > 0 )
			minimum = 1;
		
		System.out.println(minimum + " " + maximum);
	}
}

Measured memory_bytes: 21972
#include <iostream>

using namespace std;

int main()
{
    int n, i;
    bool ok = false;
    cin>>n;
    for(int i = 9;i >= 1 && !ok;i--)
    {
        if(n % i == 0 && n/i <= 9)
        {
            cout<<"Yes";
            ok = true;
        }
    }
    if(!ok)
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int a,b,k,m=0,j,t;
cin>>a>>b>>k;
if(a<b)
    {
        t=a;
        a=b;
        b=t;
    }
    for( j=b;j>0;j--)
    {
        if(b%j==0&&a%j==0)
            m++;
           if(m==k)
              {

               cout<<j<<endl;
          return 0; }

    }


}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    map<string ,ll> mp;
    rep(i,0,n){
        string s;cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] << "\n";

}

Measured memory_bytes: 3648
#include <iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<vector>
using namespace std;

void debugout ( long long value ){
    cout << value  << endl;
}

int main(){

    long long a, b, c;
    cin  >> a >> b >> c;

    if( c <= a || c <= b || c <= a+b || 4*a*b >= (c-a-b)*(c-a-b)){
        cout << "No" << endl;
    } else if( 4*a*b < (c-a-b)*(c-a-b) ){
        cout << "Yes" << endl;
    }
    return 0;
}



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

int main() {
    int a;
    char S[11], T[12];
    scanf("%s%s", S, T);
    //printf("%s%s", S, T);
    //printf("%d", strlen(S));
    for (int i = 0; i < strlen(S); i++) {
        if (S[i] != T[i]) {
           // printf("%c%c", S[i], T[i+1]);
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N;
int main(){
  cin >> N;
  if (N<=9) cout << N << endl;
  else if (N<=99) cout << 9 << endl;
  else if (N<=999) cout << N-90 << endl;
  else if (N<=9999) cout << 909 << endl;
  else if (N<=99999) cout << N-9090 << endl;
  else if (N<=999999) cout << 90909 << endl;
}


Measured memory_bytes: 888
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}


int gcd(int a,int b){
  if(a%b)return gcd(b,a%b);
  else return b;
}
int main(){
  int n,x;cin>>n>>x;
  int nw = 0;
  for(int i = 0; n > i; i++){
    int t;cin>>t;
    nw += t;
    if(x < nw){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << n+1 << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;

int main() {
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (S[i] == '+')
			ans++;
		else if (S[i] == '-')
			ans--;
	}
	cout << ans << endl;
	//cin >> S;

		return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
    int n, num = 0;
    scanf("%d", &n);
    int p[n];
    for (int i = 0; i < n; i++ )
        scanf("%d",&p[i]);
    for (int i = 1; i < n-1; i++ )
    {
        if ( (p[i]-p[i-1])*(p[i]-p[i+1])<0 )
        num++;
    }
    printf("%d", num);
    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	var a, b int
	q := make([]int, N+1)
	for i := 0; i < M; i++ {
		fmt.Scan(&a, &b)
		q[a]++
		q[b]++
	}
	ans := "YES"
	for _, cnt := range q {
		if cnt%2 == 1 {
			ans = "NO"
		}
	}
	// log.Println(q)
	fmt.Println(ans)
}


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

#include <atcoder/math>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using namespace atcoder;

int64_t test(int64_t a, int64_t b) {
    auto [y, z] = crt({0L, -1L}, {a, b});

    if (y == 0 && z == 0) {
        return 1L << 60;
    }

    if (y == 0) {
        return z;
    }

    return y;
}

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

    auto m = 2 * n;

    int64_t ans = 2 * n - 1;
    for (int64_t x = 2; x * x <= m; ++x) {
        if (m % x > 0) {
            continue;
        }

        ans = min({ans, test(x, m / x), test(m / x, x)});
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
public class Main {

	private static void solve() {
		int n = ni();
		
		int ng = 0;
		int ok = n;
		while (Math.abs(ok - ng) > 1) {
			int k = (ng + ok ) / 2;
			
			
			int now = n;
			for (int i = k; i >= 1; i --) {
				if (now >= i) {
					now -= i;
				}
			}
			if (now == 0) {
				ok = k;
			} else {
				ng = k;
			}
		}
		int now = n;
		for (int i = ok; i >= 1; i --) {
			if (now >= i) {
				now -= i;
				System.out.println(i);
			}
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = args.length > 0 ? args[0] : null;
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}


Measured memory_bytes: 22356
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}

int main() {
	int Q; cin >> Q;
	for (int i = 0; i < Q; ++i) {
		string st; cin >> st;
		bitset<32>bs;
		for (int j = 0; j < 8; ++j) {
			int num;
			if (isdigit(st[j])) {
				num = st[j] - '0';
			}
			else {
				num = st[j] - 'a' + 10;
			}
			for (int k = 0; k < 4; ++k) {
				bs[j * 4 + 3 - k] = num % 2;
				num /= 2;
			}
		}
		bool isminus = bs[0];
		long long int si = 0;
		long long int bo = 128;
		for (int i = 1; i < 32; ++i) {
			si += bs[i] * powint(2, 31-i);
		}
		if (isminus) {
			cout << '-';
		}
		const long long int integ = si / bo;
		cout << integ;
		cout << ".";
		si %= bo;
		if (si) {
			while (1) {
				si *= 10;
				cout << si / bo;
				si %= bo;
				if (!si)break;
			}
			cout << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3172
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print(A[k-1])

Measured memory_bytes: 2940