akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll ans=0;
    for(int a=1;a<=n;a++){
        int b=n/a;
        ans+=b;
        if(n%a==0) ans--;
    }
    cout << ans << endl;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() 
{
int i,m;
string n;

 cin>>n;
 m=0;
 for(i=0;i<n.size();i++)
 {
     if(i%2==0)
     {
         if(n[i]=='R'||n[i]=='U'||n[i]=='D')
       {
         m++;
       }
     
     }
     else
     {
        if(n[i]=='L'||n[i]=='U'||n[i]=='D')
       {
         m++;
       } 
     }
 }
 if(m==n.size())
 {
     cout<<"Yes"<<endl;
 }
 else
 {
     cout<<"No"<<endl;
 }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  char a[100][101], b[102][102];
  int H, W;
  cin >> H >> W;
  rep(i, H)
  {
    cin >> a[i];
  }
  // #いっぱい
  rep(i, H + 2)
  {
    rep(j, W + 2)
    {
      b[i][j] = '#';
    }
  }
  // copy
  rep(i, H)
  {
    rep(j, W)
    {
      b[i + 1][j + 1] = a[i][j];
    }
  }
  rep(i, H + 2)
  {
    rep(j, W + 2)
    {
      cout << b[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>


using namespace std;


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

	cout << max({A+B,A-B,A*B});
	return 0;
}


Measured memory_bytes: 256
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect
 
# from operator import mul
 
sys.setrecursionlimit(100001)
 
 
# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)
 
# ===FUNCTION===
 
def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]
 
    return outputDataList
 
 
def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)
 
    return outputDataList
 
 
def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)
 
    return outputDataList
 
 
# ===CODE===
 
n = int(input())
s = list(input())
 
ruisekiwa = []
tmp = [0 for _ in range(3)]
 
for si in s:
    if si == "R":
        tmp[0] += 1
    elif si == "G":
        tmp[1] += 1
    else:
        tmp[2] += 1
    tmpra = copy.deepcopy(tmp)
    ruisekiwa.append(tmpra)
 
ans = 0
for j in range(1, n - 1):
    sj = 0
    if s[j] == "R":
        sj = 0
    elif s[j] == "G":
        sj = 1
    else:
        sj = 2
 
    tmpa = ruisekiwa[j - 1]
    tmpb = [0 for _ in range(3)]
    for tmp in range(3):
        tmpb[tmp]=ruisekiwa[n - 1][tmp] - ruisekiwa[j][tmp]
 
    for a in range(3):
        for b in range(3):
            if a == b:
                continue
            if a == sj or b == sj:
                continue
            ans += tmpa[a] * tmpb[b]
 
    hikukazu = 0
    for e in range(1, 4000):
        if not(-1< j-e < j+e < n):
            break
        if s[j-e] != s[j] and s[j] != s[j+e] and s[j-e] != s[j+e]:
            hikukazu += 1
 
    ans -= hikukazu
 
print(ans)

Measured memory_bytes: 77112
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

const int maxn=200000;
const int maxv=99999999;
const double pi=acos(-1);
const double D=11.4159265358979323846264338328;
const double K=-4.2920367320510338076867830836;

struct point
{
  int x,y;

  bool operator <(const point &other) const
  {
    return x<other.x;
  }
};

int n,a[maxn+10],f[maxn+10],sx,sy,tx,ty;
point p[maxn+10];

int main()
{
  sx=read();
  sy=read();
  tx=read();
  ty=read();
  n=read();
  for(int i=1; i<=n; ++i)
    {
      p[i].x=read();
      p[i].y=read();
    }
  if(sx>tx)
    {
      std::swap(sx,tx);
      std::swap(sy,ty);
    }
  if(sy>ty)
    {
      sy=maxv-sy;
      ty=maxv-ty;
      for(int i=1; i<=n; ++i)
        {
          p[i].y=maxv-p[i].y;
        }
    }
  std::sort(p+1,p+n+1);
  int tot=0;
  for(int i=1; i<=n; ++i)
    {
      if((p[i].x>=sx)&&(p[i].y>=sy)&&(p[i].x<=tx)&&(p[i].y<=ty))
        {
          a[++tot]=p[i].y;
        }
    }
  int cnt=0;
  memset(f,63,sizeof f);
  for(int i=1; i<=tot; ++i)
    {
      int pos=std::lower_bound(f+1,f+cnt+1,a[i])-f;
      f[pos]=a[i];
      if(pos>cnt)
        {
          ++cnt;
        }
    }
  double ans=100.0*(tx-sx+ty-sy);
  if(cnt==std::min(tx-sx,ty-sy)+1)
    {
      ans+=(cnt-1)*K+D;
    }
  else
    {
      ans+=cnt*K;
    }
  printf("%.15lf\n",ans);
  return 0;
}


Measured memory_bytes: 3328
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;

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

		HashSet<String> set = new HashSet<>();
		Map<String, Integer> map = new HashMap<>();

		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			String s = sc.next();
			set.add(s);
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			} else {
				map.put(s, 1);
			}
		}

		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			String s = sc.next();
			set.add(s);
			if(map.containsKey(s)) {
				map.put(s, map.get(s)-1);
			} else {
				map.put(s, -1);
			}
		}
		int max = set.stream().mapToInt(e -> map.get(e)).max().getAsInt();
		System.out.println(max < 0 ? 0 : max);
	}
}

Measured memory_bytes: 28244
#include <iostream>

int main() {
    const int ARG_COUNT = 3;
    int xs[3] = {0, 0, 0};

    std::cin >> xs[0] >> xs[1] >> xs[2];

    for (int i = 0; i < ARG_COUNT; i++) {
        for (int j = (i + 1); j < ARG_COUNT; j++) {
            if (xs[i] > xs[j]) {
                int temp = xs[i];
                xs[i] = xs[j];
                xs[j] = temp;
            }
        }
    }

    for (int i = 0; i < ARG_COUNT; i++) {
        if (i > 0) {
            std::cout << ' ';
        }
        std::cout << xs[i];
    }

    std::cout << std::endl;

    return 0;
}


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

int main() {
    ll N, M; cin >> N >> M;
    vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> cum(N); cum[0] = A[0] % M;
    for (int i = 1; i < N; i++) cum[i] = (cum[i-1] + A[i]) % M;
    map<ll, ll> group;
    group[0]++;
    for (int i = 0; i < N; i++) {
        group[cum[i]]++;
    }
    ll ans = 0;
    for (auto x : group) {
        ans += x.second * (x.second - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define M 1000000007
#define pb push_back
#define fs first
#define se second
using namespace std;
int main()
{
    ll n,k;
    cin>>n;
    string s;
    cin>>s;
    cin>>k;
    char ch=s[k-1];
    for(ll i=0;i<n;i++)
        if(ch!=s[i])
            s[i]='*';
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
    const auto INF = numeric_limits< T >::max();
    vector< T > dist(g.size(), INF);

    using Pi = pair< T, int >;
    priority_queue< Pi, vector< Pi >, greater< Pi > > que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()) {
        T cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}


signed main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    WeightedGraph<int> G(N + 1);
    vector<int> ans(N + 1, 0);
    for (int i = 1; i <= N - 1; i++) {
        G[i].emplace_back(i + 1, 1);
        G[i + 1].emplace_back(i, 1);
    }
    G[X].emplace_back(Y, 1);
    G[Y].emplace_back(X, 1);
    for (int i = 1; i < N; i++) {
        auto dist = dijkstra(G, i);
        for (int j = i + 1; j <= N; j++) {
            ans[dist[j]]++;
        }
    }
    for (int k = 1; k <= N - 1; k++) {
        cout << ans[k] << endl;
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<long long> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(), h.end());
    long long sum = 0;
    for(int i = 0; i < n - k; i++) sum += h[i];
    cout << sum;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<double> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    while((int)v.size() != 1)
    {
        sort(v.begin(), v.end(), greater<double>());
        double a = v.back();
        v.pop_back();
        double b = v.back();
        v.pop_back();
        double res = (a + b) / 2.0;
        v.push_back(res);
    }
    cout << v.back() << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    double n; cin >> n;
    double a = n - int(n / 2);
    cout << fixed << setprecision(8) << a / n << endl;
}

Measured memory_bytes: 256
def judge(m,f,r):
    if (m == -1 or f == -1) or 30 > m+f:
        return 'F'
    elif m+f >= 80:
        return 'A'
    elif 80 > m+f >= 65:
        return 'B'
    elif 65 > m+f >= 50 or (50 > m+f >= 30 and r >= 50):
        return 'C'
    else:
        return 'D'

m,f,r = map(int,input().split())
while True:
    print(judge(m,f,r))
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break




Measured memory_bytes: 5596
import copy


class Card :
        def __init__(self, char, num) :
                self.text = char
                self.value = num


def bubble_sort(Card, n) :
    for i in range(n) :
        for j in reversed(range(i+1, n)) :
            if Card[j].value < Card[j-1].value :
                Card[j], Card[j-1] = Card[j-1], Card[j]


def selection_sort(Card, n) :
    for i in range(n) :
        minj = i
        for j in range(i, n) :
            if Card[j].value < Card[minj].value :
                minj = j
        Card[i], Card[minj] = Card[minj], Card[i]


def is_stable(lst_bubble, lst_sel) :
    for i in range(len(lst_bubble)) :
        if lst_bubble[i].text != lst_sel[i].text :
            return False
    return True


def print_result(lst, n) :
    for i in range(n-1) :
        print(lst[i].text + str(lst[i].value), end = "")
        print(" ", end = "")
    print(lst[-1].text + str(lst[-1].value))


def main() :
    n = int(input())
    lst1 = input().split()
    card_list1 = []
    for i in range(n) :
        card = Card(lst1[i][0], int(lst1[i][1]))
        card_list1.append(card)

    card_list2 = copy.deepcopy(card_list1)

    bubble_sort(card_list1, n)
    selection_sort(card_list2, n)

    print_result(card_list1, n)
    print("Stable")
    print_result(card_list2, n)
    if (is_stable(card_list1, card_list2)) :
        print("Stable")
    else :
        print("Not stable")


if __name__ == '__main__' :
        main()

Measured memory_bytes: 8300
#include<stdio.h>
#include<math.h>

int main(){
  int x=0,n;
  int i,j;

  int bool=0,check=0;
  double sqrtN;

  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<n;i++){
    if(A[i]==2) {
      x++;
      continue;
    }
    else if(A[i]%2==0) continue;

    sqrtN = sqrt(A[i]);
    for(j=3;j<=sqrtN;++j){
      if(A[i]%j==0){
	       bool = 1;
	       break;
      }
    }
    if(bool==0) x++;
    bool = 0;
  }

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

  return 0;
}



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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> X, dis_X;
    for (int i = 0; i < M; i++){
        int element;
        cin >> element;
        X.push_back(element);
    }
    if (M == 1){
        cout << 0 << endl;
    }
    else if (N >= M){
        cout << 0 << endl;
    }
    else{
        sort(X.begin(), X.end());
        int first, last;
        first = X[0];
        last = X[X.size() - 1];
        int distance = last - first;
        for (int i = 1; i < M; i++){
            int dis = X[i] - X[i - 1];
            dis_X.push_back(dis);
        }
        sort(dis_X.begin(), dis_X.end());
        int count = 0;
        for (int i = 0; i <= dis_X.size() - N; i ++){   
            count += dis_X[i];
        }
        cout << count << endl;

    }
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstring>

using namespace std;

long long dp[101][10][1001];

long long dfs(int now, int select, int score) {
    if(select == 0){
        return score == 0;
    }
    if(score == 0){
        return select == 1 && now == 0;
    }
    if(100 < now) return 0;
    if(~dp[now][select][score]) return dp[now][select][score];
    return dp[now][select][score] = dfs(now + 1, select, score) + dfs(now + 1, select - 1, score - now);
}

int main(){
    int n, s;
    memset(dp, -1, sizeof dp);
    while(cin >> n >> s && n){
        cout << dfs(0, n, s) << "\n";
    }
}


Measured memory_bytes: 10980
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
bool func(int n){
  bool h=false;
  string s="";
  if(n==0)return true;
  else {
    while(n){
      s+=n%10+'0';
      n/=10;
    }
    string tmp=s;
    reverse(s.begin(),s.end());
    if(s==tmp)h=true;
  }
  return h;
}
int main(){
  int in;
  int a=1e8,b=1e8;
  cin>>in;
  bool h=false;
  int i;
  for(i=in;i>=0;i--)if(func(i)){h=true;break;}
  if(h)a=i;
  h=false;
  for(i=in;i<10010;i++)if(func(i)){h=true;break;}
  if(h)b=i;
  if((in-a)>(b-in))cout<<b<<endl;
  else cout<<a<<endl;
}
    

Measured memory_bytes: 1216
import itertools
 
N=int(input())
L=list(map(int,input().split()))

count=0

if len(L)<3:
    Lis=[]
else:
    Lis=list(itertools.combinations(L,3))
 
numb=len(Lis)

for i in range(numb):
    if len(L)<3:
        break
 
    if Lis[i][0]==Lis[i][1] or Lis[i][0]==Lis[i][2] or Lis[i][1]==Lis[i][2]:
        pass
    else:
        bpc=Lis[i][1]+Lis[i][2]
        bmc=abs(Lis[i][1]-Lis[i][2])
        if bmc<Lis[i][0] and Lis[i][0]<bpc:
            #if Lis[i][0]<bpc:
            count+=1
 
print(count)

Measured memory_bytes: 20628
#include<iostream>
#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n,0);
  int b;
  for(int i=0;i<n;i++){
    cin >> b;
    a[b]++;
  }
  bool c=true;
  if(n%2)if(a[0]!=1)c=false;
  for(int i=1+n%2;i<n;i+=2){
    if(a[i]!=2)c=false;
  }
  int ans=0;
  if(c){
    ans++;
    for(int i=0;i<n/2;i++){
      ans*=2;
      ans%=1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int i,j;ll cnt=0;
  int n,c,k;
  cin>>n>>c>>k;
  int t[n];
  for(i=0;i<n;i++)cin>>t[i];
  sort(t,t+n);
  for(i=0;;){
    for(j=0;j<c;j++){
      if(i+j==n)break;
      if(t[i+j]-t[i]>k)break;
    }
    cnt++;
    i+=j;
    if(i==n)break;
  }
  cout<<cnt;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1!=m2){
        cout << 1 << endl; 
    }else cout << 0 << endl;
}


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

l=[list(map(int,input().split())) for i in range(n)]
l.insert(0,[0,0,0])
c=[]
for i in range(n):
  t=l[i+1][0]-l[i][0]
  x=l[i+1][1]-l[i][1]
  y=l[i+1][2]-l[i][2]

  if t >=abs(x+y):
    if t%2 == (x+y)%2:
      c.append("Y")
    else:
      print("No")
      c.append("N")
      break
  else:
    print("No")
    c.append("N")
    break

if not "N" in c:
  print("Yes")

Measured memory_bytes: 28256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=100233,MAXH=205;
int n,h,in[MAXH<<1],out[MAXH<<1];
int fa[MAXH<<1];
bool ok[MAXH<<1];
int get(int x) {
	return x==fa[x]?x:fa[x]=get(fa[x]);
}
int main() {
	scanf("%d%d",&n,&h);
	for(int i=1;i<=2*h;i++) fa[i]=i;
	for(int i=1;i<=n;i++) {
		int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d);
		int x=c?h+c:a,y=d?d:h+b;
		++out[x],++in[y];
		int fx=get(x),fy=get(y);
		if(fx!=fy) fa[fx]=fy;
	}
	for(int i=1;i<=h;i++)
		if(in[i]>out[i]) return puts("NO"),0;
	for(int i=h+1;i<=2*h;i++)
		if(in[i]<out[i]) return puts("NO"),0;
	for(int i=1;i<=2*h;i++)
		if(in[i]!=out[i]) ok[get(i)]=1;
	for(int i=1;i<=2*h;i++)
		if(fa[i]==i&&(in[i]||out[i])&&!ok[i])
			return puts("NO"),0;
	return puts("YES"),0;
}

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

long long n;
vector<long long> f;

long long calc(long long x) {
  if(f[x] != -1) return f[x];
  return f[x] = calc(x - 1) + calc(x - 2);
}

int main() {
  cin >> n;
  f.assign(n + 1, -1);
  f[0] = f[1] = 1;
  cout << calc(n) << endl;
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
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;}

vector<vector<int>> s(366,vector<int>(26));
vector<int> c(26);
vector<int> last(26,0);
vector<int> t(366,-1);
vector<int> v(366,0);

int calc_down(int d){
  int ans=0;
  for(int i=0;i<26;i++){
    ans+=c.at(i)*(d-last.at(i));
  }
  return ans;
}

int calc(int d,int now){
  int ans=s.at(d).at(now);
  int tmp=last.at(now);
  last.at(now)=d;
  ans-=calc_down(d);
  last.at(now)=tmp;
  return ans;
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int D;
  cin >> D;
  for(int i=0;i<26;i++) cin >> c.at(i);
  for(int i=1;i<D+1;i++){
    for(int j=0;j<26;j++) cin >> s.at(i).at(j);
  }

  for(int i=1;i<D+1;i++){
    int ans=v.at(i-1);
    int tmp_ma=-1e9;
    int tmp_t=-1;
    for(int j=0;j<26;j++){
      int tmp=calc(i,j);
      if(tmp>tmp_ma){
        tmp_ma=tmp;
        tmp_t=j;
      }
    }
    t.at(i)=tmp_t;
    last.at(t.at(i))=i;
    ans+=s.at(i).at(t.at(i));
    ans-=calc_down(i);
    v.at(i)=ans;
  }
  for(int i=1;i<D+1;i++)  cout << t.at(i)+1 << endl;
  //cout << v.at(D) << endl;

  return 0;
}


Measured memory_bytes: 3712
N = int(input())
r = sorted([list(map(int,input().split())) for i in range(N)],key = lambda x: -1*x[1])
b = sorted([list(map(int,input().split())) for i in range(N)])
ans = 0
for xb,yb in b:
    for xr,yr in r:
        if xr <xb and yr<yb:
            r.remove([xr,yr])
            ans+=1
            break
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll K,A,B;
int main(){
    cin>>K>>A>>B;
    for(ll i=A;i<=B;i++){
        if(i%K==0){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

int a,b,c,d;
int score(int i,int y){
  return a*i + b*y + (i/10)*c + (y/20)*d;
}

signed main(){
  int i1,y1;
  cin>>i1>>y1;
  int i2,y2;
  cin>>i2>>y2;
  cin>>a>>b>>c>>d;
  
  
  int A = score(i1,y1);
  int B = score(i2,y2);

  if(A>B) cout<<"hiroshi"<<endl;
  else if(A<B) cout<<"kenjiro"<<endl;
  else cout<<"even"<<endl;
  return 0;
}

Measured memory_bytes: 3076
#include <string.h>
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;
typedef long long unsigned int ll;

#define N 10+1
#define M 10+1

int main() {
    int n,m = 0;
    int k[M];
    int s[M][M] = {0};
    int q[M];
    int index;
    int ans;
    
    cin >> n >> m;

    for(int i = 0; i < m; i++){
        cin >> k[i];
        for(int j =0; j < k[i]; j++){
            cin >> index;
            s[i][index-1] = 1;
        }
    }

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

    
    for (int tmp = 0; tmp < (1 << n); tmp++) {
        bool true_f = true;
        bitset<N> bit(tmp);
        //cout << s << endl;
        for(int i = 0; i < m;i++){
            int sum = 0;
            for(int j = 0; j < n;j++){
                if(bit[j]){
                    sum += s[i][j];
                }
            }
            //true_f &= (sum % 2 == q[i] && sum >= 1);
            true_f &= (sum % 2 == q[i]);
        }
        if (true_f){
            //cout << bit << endl;
            ans++;
        }
    }
    cout << ans << endl;
//   for(int i = 0; i < m; i++) {
//       for(int j = 0; j < k[i]; j++){
//           cout << s[i][j];
//       }
//       cout << endl;
//   }

}



Measured memory_bytes: 256
while True:
    try:
        ans=1000000
        n=int(input())
        ls=list(map(int,input().split()))
        ls.sort()
        for i in range(1,n):
            if ls[i]-ls[i-1]<ans:
                ans=ls[i]-ls[i-1]
        print(ans)
    except:
        break;



Measured memory_bytes: 5632
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 12 18:50:46 2019
AIsingD
@author: maezawa
"""

h, w = list(map(int, input().split()))
a = [list('*'*(w+2))]
for _ in range(h):
    a.append(['*']+list(input())+['*'])
a.append(list('*'*(w+2)))
b = [[0]*(w+2) for _ in range(h+2)]
#print(a)

dirs = [(-1,0),(0,1),(1,0),(0,-1)]
ans = 0

for i in range(1, h+1):
    for j in range(1, w+1):
        if a[i][j] == '#' and b[i][j] == 0:
            stackb = [(i, j)]
            cntb = 0
            cntw = 0
            stackw = []
            while stackb:
                inext, jnext = stackb.pop(-1)
                if b[inext][jnext] != 0:
                    continue
                cntb += 1
                b[inext][jnext] = 1
                for direction in dirs:
                    inextb = inext + direction[0]
                    jnextb = jnext + direction[1]
                    if a[inextb][jnextb] == '.' and b[inextb][jnextb] == 0:
                        stackw.append((inextb,jnextb))
                while stackw:
                    inext, jnext = stackw.pop(-1)
                    if b[inext][jnext] != 0:
                        continue
                    cntw += 1
                    b[inext][jnext] = 1
                    for direction in dirs:
                        inextw = inext + direction[0]
                        jnextw = jnext + direction[1]
                        if a[inextw][jnextw] == '#' and b[inextw][jnextw] == 0:
                            stackb.append((inextw,jnextw))

            #print((i,j),cntb, cntw)
            ans += cntb*cntw
print(ans)
            
        

Measured memory_bytes: 15192
/**
 *    Creator :  bizarre
 *    Date : 3/2020
 *    Problem Number : 378
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}
int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2;i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }
        }
    }
}
*/
const int inf = 2e9, mod = 1e9 + 7,N=1e6+5;
long long fact[N], inv[N];
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int main()
{
    pre(100005);
  long long n,k,ans=0;
  cin>>n>>k;
  long long arr[n+2];
  for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);

    for(int i=0;i<n-k+1;i++)
    {
        ans=(ans+((arr[n-i-1]-arr[i])%mod)*(ncr(n-i-1,k-1)%mod))%mod;
    }
    cout << (ans+mod)%mod;
    return 0;
}


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

using namespace std;

int main(void){
  string old_name, new_name;

  cin >> old_name >> new_name;

  if( old_name.length()+1 == new_name.length() && old_name == new_name.substr(0,old_name.length()) ){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3020
def dfs(curr, visit_state, adj_list, count, num_vertex):
    if count == num_vertex:
        return 1
    if all(visit_state[i] for i in adj_list[curr]) and count != num_vertex:
        return 0
    result = 0
    for nb in adj_list[curr]:
        if not visit_state[nb]:
            visit_state[nb] = True
            result += dfs(nb, visit_state, adj_list, count + 1, num_vertex)
            visit_state[nb] = False
    return result


n, m = map(int, input().split())
adj = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)
visited = [False] * n
visited[0] = True
print(dfs(0, visited, adj, 1, n))


Measured memory_bytes: 3064
N = int(input())
h = list(map(int, input().split()))
def func(n):
    return n - 1
ans = 0
flag = True
flag2 = False
while True:
    for i in h:
        if i > 0:
            if flag2 == False:
                ans += 1
            flag = False
            flag2 = True
        else:
            flag2 = False
    if flag:
        break
    h = list(map(func, h))
    flag = True
    flag2 = False
    #print(h)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    vvint a(n, vint(n));
    rep(i, m)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        a[l][r]++;
    }
    vvint c(n + 1, vint(n + 1));
    rep(i, n) rep(j, n)
    {
        c[i + 1][j + 1] = c[i + 1][j] + c[i][j + 1] - c[i][j] + a[i][j];
    }

    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        l--;
        int ans = c[r][r] - c[l][r] - c[r][l] + c[l][l];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include <vector>
#include <string>
using namespace std;
const int NIL = -2;
class bintree{
public:
	int left;
	int right;
	int parent;
	int key;
	bintree():left(NIL),right(NIL),parent(NIL),key(0){
	}
};

void PrintID(int key) {
	cout << " " << key;
}

void TraversePrint_Preorder(vector<bintree> & T,int id) {
	bintree & t = T[id];
	PrintID(t.key);
	if (t.left != NIL) {
		TraversePrint_Preorder(T,t.left);
	}
	if (t.right != NIL) {
		TraversePrint_Preorder(T,t.right);
	}
}
void TraversePrint_Inorder(vector<bintree> & T,int id) {
	bintree & t = T[id];
	if (t.left != NIL) {
		TraversePrint_Inorder(T,t.left);
	}
	PrintID(t.key);
	if (t.right != NIL) {
		TraversePrint_Inorder(T,t.right);
	}
}
void TraversePrint_Postorder(vector<bintree> & T,int id) {
	bintree & t = T[id];
	if (t.left != NIL) {
		TraversePrint_Postorder(T,t.left);
	}
	if (t.right != NIL) {
		TraversePrint_Postorder(T,t.right);
	}
	PrintID(t.key);
}
void TreeInsert(vector<bintree> & T,int &top,int z){
	int y = NIL;
	int x = top;
	while (x != NIL){
		y = x;
		if (T[z].key < T[x].key) {
			x = T[x].left;
		}
		else {
			x = T[x].right;
		}
	}
	T[z].parent = y;
	if (y == NIL) {
		top = z;
	} else if (T[z].key < T[y].key) {
		T[y].left = z;
	} else {
		T[y].right = z;
	}
}
int main(){
	vector<bintree> T;
	int n;
	cin >> n;
	T.resize(n);
	int top = NIL;
	for(int z=0;z<n;++z) {
		string op;
		cin >> op;
		if (op == "insert") {
			cin >> T[z].key;
			TreeInsert(T,top,z);
		} else if (op == "print") {
			TraversePrint_Inorder(T,top);
			cout << std::endl;
			TraversePrint_Preorder(T,top);
			cout << std::endl;
		}
	}
}

Measured memory_bytes: 8984
def solve(n, k):
    list1 = []
    for i in range(1, n+1):
        cnt = 0
        while True:
            if i * 2 ** cnt >= k:
                list1 += [cnt]
                break
            cnt += 1
        
    m = max(list1)
    list2 = list(map(lambda x: m-x, list1))
    list2 = list(map(lambda x: 2**x, list2))
    return sum(list2) / (n * 2**m)

n, k = map(int, input().split())
print(solve(n, k))

Measured memory_bytes: 48736
class Dice

  def initialize (given_ary)
    @ary = given_ary
  end

  def topface(val)
    4.times do
      self.roll("E")
      if self.top == val
        return
      end
    end
    3.times do
      self.roll("N")
      if self.top == val
        return
      end
    end
  end

  def frontface(val)
    4.times do
      tmp = @ary[1]
      @ary[1] = @ary[2]
      @ary[2] = @ary[4]
      @ary[4] = @ary[3]
      @ary[3] = tmp
     if @ary[1] == val
       return
     end
   end
 end

 def checkall(givendice)
   4.times do
     self.roll("E")
     4.times do
       tmp = @ary[1]
       @ary[1] = @ary[2]
       @ary[2] = @ary[4]
       @ary[4] = @ary[3]
       @ary[3] = tmp
      if identical(givendice)
        return true
      end
    end
  end
  3.times do
    self.roll("N")
    4.times do
      tmp = @ary[1]
      @ary[1] = @ary[2]
      @ary[2] = @ary[4]
      @ary[4] = @ary[3]
      @ary[3] = tmp
      if identical(givendice)
        return true
      end
    end
  end
  return false
end

def roll (direction)
case direction.downcase
when "e"
  tmp = @ary[0]
  @ary[0] = @ary[3]
  @ary[3] = @ary[5]
  @ary[5] = @ary[2]
  @ary[2] = tmp
when "w"
  tmp = @ary[0]
  @ary[0] = @ary[2]
  @ary[2] = @ary[5]
  @ary[5] = @ary[3]
  @ary[3] = tmp
when "s"
  tmp = @ary[0]
  @ary[0] = @ary[4]
  @ary[4] = @ary[5]
  @ary[5] = @ary[1]
  @ary[1] = tmp
when "n"
  tmp = @ary[0]
  @ary[0] = @ary[1]
  @ary[1] = @ary[5]
  @ary[5] = @ary[4]
  @ary[4] = tmp
 end
end

  def top
   @ary[0]
  end

  def front
    @ary[5]
  end

  def right
    @ary[2]
  end

  def vals
    @ary
  end

  def compare(givendice)
    4.times do
      self.roll("E")
      if identical(givendice)
        return true
      end
    end
    3.times do
      self.roll("N")
      if identical(givendice)
        return true
      end
      4.times do
        self.roll("E")
        if identical(givendice)
          return true
        end
      end

    end
    false

    end

  def identical(givendice)
    @ary.zip(givendice.vals).map{ |x,y| (x-y).abs}.inject(:+) == 0
  end

end

  dices = Array.new()
  gets.to_i.times do
    dices << Dice.new(gets.split.map(&:to_i))
end
  result = ""
  dices.each do |outer|
    dices.each do |inner|
      if outer === inner
        next
      end
      if outer.checkall(inner)
        puts "No"
        exit
      end
    end
  end
 puts "Yes"

Measured memory_bytes: 8928
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    bool flag = true;
    int n, in;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> in;
        if (in % 2 == 0){
            if ( (in % 3 != 0) && (in % 5 != 0) ){
                flag = false;
                break;
            }
        }
    }
    if (flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, s, cnt = INT_MAX;
  cin >> N;
  for (int i = 0; i < N; i++)
  { 
    cin >> s; 
    int j = 0;
    while(1)
    {
      if (s % 2 != 0)
      {
        if ( j < cnt ) { cnt = j; }
        break;
      }
      s /=2;
      j++;
      if ( j > cnt ) { break; }
    }  
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        for (int i = 0; i < 5; i++) {
            a[i] = sc.nextInt();
        }
        k = sc.nextInt();

        if (a[4] - a[0] > k) {
            System.out.println(":(");
        }
        else {
            System.out.println("Yay!");
        }
    }
}


Measured memory_bytes: 22484
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;




int main() {


	int a, b, c, d, tmp;
	string fmr;
	cin >> tmp;

	d = tmp % 10; tmp /= 10;
	c = tmp % 10; tmp /= 10;
	b = tmp % 10; tmp /= 10;
	a = tmp % 10;

	tmp = 0;




	int bit = (1 << 3);
	for (int bt = 0; bt < bit; bt++) {

		if (bt & 1) {
			tmp = a - b;
		}
		else
		{
			tmp = a + b;
		}

		if (bt & 2) {
			tmp = tmp - c;
		}
		else
		{
			tmp = tmp + c;
		}

		if (bt & 4) {
			tmp = tmp - d;
		}
		else
		{
			tmp = tmp + d;
		}

		fmr = to_string(a) + ((bt & 1) ? "-" : "+") + to_string(b);
		fmr += ((bt & 2) ? "-" : "+") + to_string(c);
		fmr += ((bt & 4) ? "-" : "+") + to_string(d) + "=7";

		if (tmp == 7) {
			cout << fmr << endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read(){
	int sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
int n;
int main(){
	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2];
	return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    ll K;
    cin >> S >> K;
    if(S[0] != '1'){
        cout << S[0] << endl;
        return 0;
    }
    int index = S.length()-1;
    char c;
    rep(i,0,S.length()){
        if(S[i] != '1'){
            index = i - 1;
            c = S[i];
            break;
        }
    }
    if(K-1 <= index)cout << 1 << endl;
    else          cout << c << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
h, w = min(h, w), max(h, w)
if h == 1:
    if w == 1:
        ans = 1
    elif w == 2:
        ans = 0
    else:
        ans = w - 2
elif h == 2:
    ans = 0
else:
    ans = (h - 2) * (w - 2)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<fstream>
#include <map>
#include<math.h>
#include <bitset>
#include <set>
using namespace std;

int main(){
	std::istream & c_in = cin;
	map<int, int> t;
	int n;
	c_in >> n;
	int a = n;
	int i = 2;
	while (a != 1)
	{
		if ((a % i) == 0) {
			a /= i;
			t[i]++;
			continue;
		}
		i += 1 + (i & 1);
		if (i > ::sqrt(a))
		{
			t[a]++;
			break;
		}
	}

	const long N = 1000000000;
	std::bitset<N/2+1> *pflg = new bitset <N/2+1>();
	std::bitset<N/2+1> & flg = *pflg;
	flg.set(0);
	int even = 0;
	bool haseven = t.find(2) != t.end();
	if (haseven){
		even = (n - 2) / 2;
		t.erase(t.find(2));
	}
	for (map<int, int>::iterator r = t.begin(); r != t.end(); ++r)
	{
		for (int i = 1; i*r->first< n; i+=2)
		{
			flg.set((i*r->first-1)/2);
		}
	}
	int odds = flg.count();
	if (!haseven)
	{
		flg.reset();
		for (map<int, int>::iterator r = t.begin(); r != t.end(); ++r)
		{
			for (int i = 2; i*r->first< n; i += 2)
			{
				flg.set( i*r->first / 2);
			}
		}
		even = flg.count();
	}
	cout << n - odds - even << endl;
}

Measured memory_bytes: 62244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
//
int main(){
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    ll now = A[0];
    for(int i=1;i<N;i++){
        if(A[i]<now){
            ans += now-A[i];
        }else{
            now = A[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int Ans;
int N;

int fastpow(int x,int p) {
	int res = 1,tot = x;
	while(p) {
		if(p&1) res*= tot;
		p >>= 1;
		tot *= x;
	}
	return res;
}

int main() {
	cin >> N;
	if(N == 1 || N == 2 || N == 3) {cout << 1 <<endl; return 0;}
	for(int i = 2; i <= N; i++)
		for(int j = 2; fastpow(i,j) <= N; j++)
			Ans = max(Ans,fastpow(i,j));
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
K = int(input())
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]
print(a[K-1])

Measured memory_bytes: 38384
package main

import "fmt"

func solve() {
	var H, W int
	fmt.Scan(&H, &W)
	s := make([]string, H)
	po := make([][]int, H)
	for i := range po {
		po[i] = make([]int, W)
	}
	for i := range s {
		fmt.Scan(&s[i])
		for j, ss := range s[i] {
			if ss == '#' {
				if i > 0 {
					if j > 0 {
						po[i-1][j-1]++
					} else {
						po[i-1][j]++
					}
					if j+2 < W {
						po[i-1][j+2]--
					}
				}

				if j > 0 {
					po[i][j-1]++
				} else {
					po[i][j]++
				}
				if j+2 < W {
					po[i][j+2]--
				}

				if i+1 < H {
					if j > 0 {
						po[i+1][j-1]++
					} else {
						po[i+1][j]++
					}
					if j+2 < W {
						po[i+1][j+2]--
					}
				}
			}
		}
	}

	for i := range s {
		p := 0
		for j, ss := range s[i] {
			p += po[i][j]
			if ss == '#' {
				fmt.Print(string(ss))
				continue
			}
			fmt.Print(p)
		}
		fmt.Println()
	}
}

func main() {
	solve()
}


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

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

  	sort(a.begin(), a.end());
  	sort(f.rbegin(), f.rend());
  	ll l = -1, r = 1e12;
  	while(l+1 < r){
    	ll c = (l+r)/2;
      
      	bool ok = [&]{
        	ll s = 0;
          	rep(i, n){
            	s += max(0ll, a[i]-c/f[i]);
            }
          	return s <= k;
        }();
      
      	if(ok) r = c;
      	else l = c;
    }
  
  	cout << r << endl;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007
int main(){
  lli a,b;
  cin >> a >> b;
  lli x;
  cin >> x;
  if(a!=0)
  cout << b/x-(a-1)/x << endl;
  else
  cout << b/x+1 << endl;
    
}


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

#ifdef GCC
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define log(x) cout << (x) << "\n"
#define loop(i, begin, end)for(__typeof(end) i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define rep(i, n) loop(i, 0, n)

using ll = long long;
using vll = vector<ll>;

int main() {
    ll x, y, z, K;
    cin >> x >> y >> z >> K;
    vll A(x), B(y), C(z), S;

    rep (i, x) cin >> A[i];
    rep (i, y) cin >> B[i];
    rep (i, z) cin >> C[i];

    sort(all(A), greater<>());
    sort(all(B), greater<>());
    sort(all(C), greater<>());

    rep (i, x) {
        rep (j, y) {
            rep (k, z) {
                if (i*j*k > K) break;
                S.eb(A[i]+B[j]+C[k]);
            }
        }
    }
    sort(all(S), greater<>());
    rep (l, K) log(S[l]);
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int x; cin >> x;
  int goal = x / gcd(x, 360) * 360;

  cout << goal / x << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  
  if(S=="SUN"){
  cout<<7<<endl;
  }
  
  else if(S=="MON"){
    cout<<6<<endl;
  }
  
  else if(S=="TUE"){
    cout<<5<<endl;
  }

  else if(S=="WED"){
    cout<<4<<endl;
  }
  
  else if(S=="THU"){
    cout<<3<<endl;
  }
  
  else if(S=="FRI"){
    cout<<2<<endl;
  }
  
  else if(S=="SAT"){
    cout<<1<<endl;
  }

  return 0;
}

Measured memory_bytes: 256