akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    sort(whole(a));
    vector<bool> broken(n+1);
    rep(i, m) {
        broken[a[i]] = true;
    }
    vector<mint> dp(n+1);
    dp[0] = mint(1);
    for (int i=1; i<=n; i++) {
        if (broken[i]) continue;
        dp[i] += dp[i-1];
        if (i>1) dp[i] += dp[i-2];
    }
    mint ans = dp[n];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
package main

import (
	"fmt"
)

func main(){
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
		fmt.Printf("a > b\n")
	} else if a == b {
		fmt.Printf("a == b\n")
	} else{
		fmt.Printf("a < b\n")
	}
}



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

int main(){
  int N;
  cin>>N;
  if(N<105)
    cout<<0<<endl;
  else if(N<135)
    cout<<1<<endl;
  else if(N<165)
    cout<<2<<endl;
  else if(N<189)
    cout<<3<<endl;
  else if(N<195)
    cout<<4<<endl;
  else
    cout<<5<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 6000

struct Info{
	int A,B;
};


struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_rev_index){
		to = arg_to;
		capacity = arg_capacity;
		rev_index = arg_rev_index;
	}
	int to,capacity,rev_index;
};

int N,M;
int human_index[100],info_index[5050];
Info info[5050];


int V,E;
vector<Edge> G[NUM];
bool used[NUM];

void add_edge(int from,int to,int capacity){
	G[from].push_back(Edge(to,capacity,G[to].size()));
	G[to].push_back(Edge(from,0,G[from].size()-1));
}

int dfs(int node_id,int sink,int flow){
	if(node_id == sink)return flow;
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		Edge &e = G[node_id][i];
		if(used[e.to] == false && e.capacity > 0){
			int tmp_flow = dfs(e.to,sink,min(flow,e.capacity));
			if(tmp_flow > 0){
				e.capacity -= tmp_flow;
				G[e.to][e.rev_index].capacity += tmp_flow;
				return tmp_flow;
			}
		}
	}
	return 0;
}


int max_flow(int source,int sink){ //source:始点 sink:終点
	int flow = 0,add;
	while(true){ //増加パスが存在する限り、流量を追加し続ける
		for(int i = 0; i < V; i++)used[i] = false;
		add = dfs(source,sink,BIG_NUM);
		if(add == 0)break;
		flow += add;
	}
	return flow;
}

void delete_graph(){

	for(int i = 0; i < NUM; i++)G[i].clear();
}


void func(){

	for(int i = 0; i < M; i++){
		scanf("%d %d",&info[i].A,&info[i].B);
		info[i].A--;
		info[i].B--;
	}

	delete_graph();

	int min_max;
	int source = 0,sink = 1,index = 2;

	for(int i = 0; i < N; i++)human_index[i] = index++;
	for(int i = 0; i < M; i++)info_index[i] = index++;
	V = index;

	for(int i = 0; i < N; i++){
		add_edge(source,human_index[i],0);
	}

	for(int i = 0; i < M; i++){
		add_edge(human_index[info[i].A],info_index[i],1);
		add_edge(human_index[info[i].B],info_index[i],1);
		add_edge(info_index[i],sink,1);
	}

	min_max = 0;
	int flow = 0;

	for(int i = 1; i*N <= M; i++){

		for(int k = 0; k < G[source].size(); k++){
			G[source][k].capacity++;
		}

		flow += max_flow(source,sink);

		if(flow == N*i){
			min_max = i;
		}
	}

	delete_graph();

	for(int i = 0; i < N; i++){
		add_edge(source,human_index[i],0);
	}

	for(int i = 0; i < M; i++){
		add_edge(human_index[info[i].A],info_index[i],1);
		add_edge(human_index[info[i].B],info_index[i],1);
		add_edge(info_index[i],sink,1);
	}

	int max_min;
	flow = 0;

	for(int i = 1; i <= M; i++){

		for(int k = 0; k < G[source].size(); k++){
			G[source][k].capacity++;
		}

		flow += max_flow(source,sink);

		if(flow == M){
			max_min = i;
			break;
		}
	}

	printf("%d %d\n",min_max,max_min);
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int cnt=0,h,i,n;
	cin>>h>>n;
	int x;
	for(i=0;i<n;i++){
		cin>>x;
		cnt+=x;
		if(cnt>=h){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair
#define debug_var(x) cout << (#x) << ": " << x << "\n";
#define debug_vec(x, n) cout << (#x) << ": "; for(int i = 0; i < n; i++) cout << x[i] << (i == n - 1 ? "\n" : " ");
 
typedef long long ll;
typedef long double ld;

void solve(){
    ld r;
    cin >> r;
    ld PI = 3.14159265358979323846;
    cout << setprecision(12) << 2.0 * PI * r << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
 
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 1000000007;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 

int a[100005];
int tree[200005];

void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}

void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}

int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-a+b,0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool prim[10001];

int main(void){
  int n;
  for(int i=0; i < 10001; i++){
    prim[i] = true;
  }
  for(int i=2; i < sqrt(10001); i++){
    if(prim[i]){
      for(int j=0; i*(j+2) < 10001; j++){
        prim[i * (j+2)] = false;
      }
    }
  }

  while(cin >> n, n){
    int cnt = 0;
    vector<int> ans;
    for(int i=n; i > 0; i--){
      if(prim[i]){
        ans.push_back(i);
        cnt++;
      }
      if(cnt == 2){
        if(ans[0] - ans[1] == 2){
          cout << ans[1] << " " << ans[0] << endl;
          break;
        }else{
          ans.erase(ans.begin());
          cnt = 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

string s;
int N;
ll m, a, r, c, h;
ll D[5];
int P[10] = { 0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2 };
int Q[10] = { 1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3 };
int R[10] = { 2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4 };
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> s;
		if (s[0] == 'M') m++;
		if (s[0] == 'A') a++;
		if (s[0] == 'R') r++;
		if (s[0] == 'C') c++;
		if (s[0] == 'H') h++;
	}
	D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
	ll res = 0;
	for (int d = 0; d < 10; d++)
		res += D[P[d]] * D[Q[d]] * D[R[d]];
	printf("%lld\n", res);
}

Measured memory_bytes: 256
n,k = map(int,input().split())
A = list(map(int,input().split()))

if sum(A)-n <= k:
    print(1)
    exit()
elif k == 0:
    print(max(A))
    exit()
top = 10**9
bottom = 1
def ok(x):
    res = 0
    for a in A:
        res += (a-1)//x
    return res <= k
while top - bottom > 1:
    mid = (top + bottom)//2
    if ok(mid):
        top = mid
    else:
        bottom = mid
print(top)


Measured memory_bytes: 93804
def main():
    N, A = map(int, input().split())
    X = list(map(int, input().split()))
    dp = [[0]*(50*N+1) for _ in range(N+1)]
    dp[0][0] = 1
    for x in X:
        for i in range(N-1, -1, -1):
            for j in range(50*N+1):
                if j+x <= 50*N:
                    dp[i+1][j+x] += dp[i][j]
    ans = 0
    for i in range(1, N+1):
        ans += dp[i][i*A]
    print(ans)


if __name__ == "__main__":
    main()


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

int main(void) {
  ios::sync_with_stdio(false);
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  const int MAX = 3002;
  const int64_t MOD = 998244353;
  vector<vector<int64_t>> DP(MAX, vector<int64_t>(MAX, 0));
  DP[A][B] = 1;
  for(int h = A; h <= C; ++h) {
    for(int w = B; w <= D; ++w) {
      DP[h+1][w] = (DP[h+1][w] + (DP[h][w] * w) % MOD) % MOD;
      DP[h][w+1] = (DP[h][w+1] + (DP[h][w] * h) % MOD) % MOD;
      int64_t sub = (DP[h][w] * h * w) % MOD;
      DP[h+1][w+1] = ((DP[h+1][w+1] - sub) + MOD) % MOD;
    }
  }
  cout << DP[C][D] << endl;
  return 0;
}

Measured memory_bytes: 73728
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
Mod=10**9+7
h,w,K=map(int,input().split())
dp=[[0]*w for _ in range(h+1)]
dp[0][0]=1
n=2**(w-1)
for i in range(h):
    for j in range(w):
        for m in range(n):
            ok=True
            for k in range(w-2):
                if (m&(1<<k)) and (m&(1<<(k+1))):
                    ok=False
            if not ok:
                continue
            nj=j
            if (m & (1<<j)):
                nj=j+1
            elif j>0 and (m&(1<<(j-1))):
                nj=j-1
            dp[i+1][nj]+=dp[i][j]
            dp[i+1][nj]%=Mod
print(dp[h][K-1])


Measured memory_bytes: 9424
#include "bits/stdc++.h"
using namespace std;
#define test int t; cin >> t; while (t--)
#define fast ios::sync_with_stdio(NULL); cin.tie(NULL)
#define mod 1000000007
#define endl "\n"
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/GCD(m,n))
#define all(v) v.begin(),v.end()
#define ll long long
typedef vector<ll> vecll;
typedef vector<int> veci;
typedef vector<char> vecc;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define time 1.0 * clock() / CLOCKS_PER_SEC


int main(){
    fast;
    double t;cin>>t;
    cout<<fixed;
    cout<<setprecision(20)<<(2*22*t)/7.0;
    return 0;
}


Measured memory_bytes: 3768
#include <stdio.h>
using namespace std;

#define ll long long

int main() {
    ll N;
    scanf("%lld", &N);

    ll min_tra = 1000000000000001;
    int min_index = 0;
    for(int i = 0;i < 5;i++) {
        ll abc;
        scanf("%lld", &abc);

        if(abc < min_tra) {
            min_tra = abc;
            min_index = i;
        }
    }

    ll kaisu = N%min_tra ? N/min_tra + 1 : N/min_tra;
    printf("%lld\n", kaisu + 4);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int k;
	int a,b;
	int i;
	
	scanf("%d",&k);
	scanf("%d %d",&a,&b);
	
	for(i=a;i<=b;i++){
		if(i % k == 0){
			printf("OK");
			break;
		}
		if(i == b){
			printf("NG");
		}
	}
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, H;
	cin >> N >> H;
	vector<pair<int, int>> v(N);
	for (auto &x : v) {
		cin >> x.first >> x.second;
	}
	sort(v.begin(), v.end(), [](auto &a, auto &b) {
		return b.second < a.second;
	});

	auto m = max_element(v.begin(), v.end(), [](auto &a, auto &b) {
		return a.first < b.first;
	})->first;

	int ans = 0;
	for (auto &x : v) {
		if (x.second >= m) {
			H -= x.second;
			++ans;
		}
		if (H <= 0) {
			break;
		}
	}
	if (H > 0) {
		ans += (H + m - 1) / m;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <string.h>
// typedef long l;
// typedef long long ll;

int main(void){

  long i, j;
  long length;
  long r, l;//RLの境目のRLのインデックス
  long n_r, n_l;
  int f;//flag 1でL発見 2でR発見
  char str[(int)pow(10, 5)];

  scanf("%s", str);
  length=strlen(str);

  // printf("%ld\n", length);

  long num[length];//子供の人数
  memset(num, 0, sizeof(num));

  for(i=0; i<length; ){
    //RになってLになってRになるのを検知
    n_r=0;
    n_l=0;
    f=0;
    for(j=i; ;j++){
      // printf("%ld\n", j)
      if(str[j]=='R'){
        // printf("str[%ld]=R\n", j);
        if(f==0){
          n_r++;
        }else if(f==1){
          //jは次のi
          i=j;
          break;
        }
      }else if(str[j]=='L'){
        // printf("str[%ld]=L\n", j);
        if(f==0){
          r=j-1;
          l=j;
        }
        f=1;
        n_l++;
        if(j==length-1){
          i=j;
          break;
        }
      }
    }
    //子供の数の処理
    if((n_r+n_l)%2==0){
      num[r]=(n_r+n_l)/2;
      num[l]=(n_r+n_l)/2;
    }else{
      if(n_r%2==0){
        //n_r偶数、n_l奇数
        num[r]=(n_r/2)+(n_l/2);
        num[l]=(n_r/2)+(n_l/2)+1;
      }else{
        num[r]=(n_r/2)+(n_l/2)+1;
        num[l]=(n_r/2)+(n_l/2);
      }
    }
    if(j==length-1){
      break;
    }
  }

  for(i=0; i<length; i++){
    if(i!=length-1) printf("%ld ", num[i]);
    else printf("%ld\n", num[i]);
  }

  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(int)(n); ++i)
 
template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}
 
int main(){
    int n; cin >> n;
    int d[100];
    rep(i, n) cin >> d[i];

    int ans = 0;
    rep(i, n){
        rep(j, n){
            if(i==j)continue;
            ans += d[i] * d[j];
        }
    }
    cout << ans/2 << endl;

}

Measured memory_bytes: 256
(* O(n log k) *)
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let p = 1. /. float n
let ans = ref 0.
let _ =
  for i = 1 to n do
    let score = ref i in
    let j = ref 0 in
    while !score < k do score := !score * 2; incr j done;
    ans := !ans +. p *. 0.5 ** float !j done;
  Printf.printf "%.12f\n" !ans

Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc140
{
    class abc140a
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var r = Solve(n);
            Console.WriteLine(r);
        }

        static int Solve(int n)
        {
            return n * n * n;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	map<string,int> table;
	string s,f,l;
	size_t n=0;
	while(cin>>s){
		//if(s=="0") break;
		table[s]++;
		if(table[s]>n){
			n=table[s]; f=s;
		}if(s.size()>l.size()) l=s;
	}
	o(f<<" "<<l);
}

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

#define ll long long
#define pb push_back
#define mp make_pair
int main() 
{
	 ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     
		 int n;
		 cin>>n;
		 int a[n];
		 for(int i=0;i<n;i++)
		 cin>>a[i];
		 vector<int>v;
		 if(n%2==0)
		{ for(int i=n-1;i>0;i-=2)
		 {
			 v.pb(a[i]);
			
		 }
		 for(int i=0;i<n;i+=2)
		 v.pb(a[i]);}
		 else
		 {
			 for(int i=n-1;i>=0;i-=2)
		 {
			 v.pb(a[i]);
			
		 }
		 for(int i=1;i<n;i+=2)
		 v.pb(a[i]);}
		 
		 
		
		 for(auto x: v)
		 {
			 cout<<x<<" ";
		 }
		 
	
}


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

int main(){
    ll n;  cin >> n;
    ll sum=0;
    for(ll i=1; i<=n; i++){
        if(i%5==0 || i%3==0)    continue;
        sum += i;
    }
    cout << sum << endl;
}



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

int main() {
  int x; cin >> x;
  if (x < 100) {
    cout << 0;
    return 0;
  }
  if (x % 100 <= x / 100 * 5)
    cout << 1;
  else cout << 0;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

long mod = 1000000007;
int main() {
  int N;
  cin >> N;

  static long dp[101][4][4][4];
  dp[0][3][3][3] = 1;

  for (int i = 0; i <= N; i++) {
    for (int i1 = 0; i1 < 4; i1++) {
      for (int i2 = 0; i2 < 4; i2++) {
        for (int i3 = 0; i3 < 4; i3++) {
          for (int c = 0; c < 4; c++) {
            if (i2 == 0 && i3 == 1 && c == 2) continue;
            if (i2 == 0 && i3 == 2 && c == 1) continue;
            if (i2 == 1 && i3 == 0 && c == 2) continue;
            if (i1 == 0 && i3 == 1 && c == 2) continue;
            if (i1 == 0 && i2 == 1 && c == 2) continue;
            dp[i + 1][i2][i3][c] += dp[i][i1][i2][i3];
            dp[i + 1][i2][i3][c] %= 1000000007;
          }
        }
      }
    }
  }

  long sum = 0;
  for (int i1 = 0; i1 < 4; i1++) {
    for (int i2 = 0; i2 < 4; i2++) {
      for (int i3 = 0; i3 < 4; i3++) {
        sum += dp[N][i1][i2][i3];
        sum %= 1000000007;
      }
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    S.append("".join(sorted(list(input()))))
S.sort()
output = 0

t = 1
n=1
while t<N:
    if S[t-1]==S[t]:
        n+=1
    else:
        output += int(n*(n-1)*0.5)
        n=1
    t+=1
output += int(n*(n-1)*0.5)
print(output)

Measured memory_bytes: 57688
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<vector<int>>X(N,vector<int>(N,-1));
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    for(int j=0;j<A;j++){
      int a,b;
      cin>>a>>b;
      X.at(i).at(a-1)=b;
    }
  }
  int ans=0;
  for(int temp=0;temp<(1<<N);temp++){
    bitset<15>r(temp);
    string R=r.to_string();
    reverse(R.begin(),R.end());
    int honest=0;
    for(int i=0;i<N;i++){
      if(R.at(i)=='1'){
        honest=honest+1;
      }
    }
    bool flag=true;
    for(int i=0;i<N;i++){
      if(R.at(i)=='1'){
        for(int j=0;j<N;j++){
          if(X.at(i).at(j)==-1){
          }
          else if(X.at(i).at(j)!=(R.at(j)-'0')){
            flag=false;
            break;
          }
        }
      }        
    }
    if(flag==true){
      ans=max(ans,honest);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

cpp_int M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

cpp_int combination(cpp_int n, cpp_int r) {
	if (r * 2 > n) r = n - r;
	cpp_int dividend = 1;
	cpp_int divisor = 1;
	for (cpp_int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

int main()
{
	cpp_int n, k;
	cin >> n >> k;
	for (cpp_int i = 1; i < k + 1; i++) {
		if (n - k + 1 >= i) {
			cpp_int comb = combination(n - k + 1, i);
			//cout <<"a"<< comb << endl;
			comb *= combination(k - 1, i - 1);
			cout << comb % M << endl;
		}
		else {
			cout << 0 << endl;
		}
	}

}


Measured memory_bytes: 256
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 19260817
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline LL Scan(){
    long long res = 0;
    char ch = 0;
    while (ch < '0' || ch > '9')
        ch = getchar();
    while (ch >= '0' && ch <= '9')
    {
        res = res * 10 + ch - '0';
        ch = getchar();
    }
    return res;
}
int ps4[4][2]={0,1,0,-1,1,0,-1,0};
int ps8[8][2]={0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,-1,-1,1};
inline int min(int a,int b,int c) {return min(a,min(b,c));}
inline int max(int a,int b,int c) {return max(a,max(b,c));}
inline int min(int a,int b,int c,int d){return min(min(a,b,c),d);}
inline int max(int a,int b,int c,int d){return max(max(a,b,c),d);}
//struct Edge{int p, next, w;}edge[maxn];
//inline add_edge(int u, int v, int w){edge[cnt]=Edge{v,head[u],w}; head[u]=cnt++;}
const int N=100005;
///Code begin..................................................................

char s[10];
int a[5];
char ans[5];

int dfs(int cnt, int x){
    if (cnt>3) {
        if (x==7) return true;
        else return false;
    }
    ans[cnt]='+';
    if (dfs(cnt+1,x+a[cnt])) return true;
    ans[cnt]='-';
    if (dfs(cnt+1,x-a[cnt])) return true;
}
int main ()
{
    scanf("%s",s);
    FOR(i,0,3) a[i]=s[i]-'0';
    dfs(1,a[0]);
    printf("%d",a[0]);
    FOR(i,1,3) printf("%c%d",ans[i],a[i]);
    printf("=7\n");
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin>>a>>b>>c;
    if (a+b>=c){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,T;
	cin >> N >> T;
	vector<ll> A(N),mn(N),B(N);
	//mx[i] はi番目までのmn
	rep(i,N){
		cin >> A[i];
		if(i==0)mn[i] = A[i];
		else mn[i] = min(mn[i-1],A[i]);
	}
	rep(i,N){
		B[i] = A[i] - mn[i];
	}
	int ans = 0;
	int max = 0;
	rep(i,N){
		if(max==B[i] && max!=0)ans++;
		else if(max<B[i]){
			max = B[i];
			ans = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
ll inv(ll a, ll b){ return a<2 ? a : ((a-inv(b%a,a))*b+1)/a%b; }
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}


ll N,K;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> N >> K;
	
	ll i,res=0;
	for (ll rem=K; rem<N; rem++){
		ll val=N-rem;
		
		for (i=rem+1; ; i=val/(val/i)+1){
			ll r;
			if (val/i==0) r=N+1;
			else r=val/(val/i)+1;
			
			res+=(r-i)*((val/i)+1);
			if (rem==0) res-=(r-i);
			
			if (val/i==0) break;
		}
	}
	cout << res << "\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100010
int a[11],dp[N];
int c[10]={0,2,5,5,4,5,6,3,7,6};
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
        scanf("%d",&a[i]);

    dp[0]=1;
    for(int i=0;i<m;i++)
        for(int j=c[a[i]];j<=n;j++)
            dp[j]=max(dp[j],dp[j-c[a[i]]]+1);


    sort(a,a+m);
    m-=1;
    while(n>0)
    {
        if(n-c[a[m]]>=0 && dp[n]==dp[n-c[a[m]]]+1)
        {
            printf("%d",a[m]);
            n-=c[a[m]];
        }
        else
            m--;
    }
    return 0;
}


Measured memory_bytes: 256
#include <complex>
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>
#include <set>

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector <int> a;
    vector <int> vals = vector <int>(n);
    for (int i = 0; i < q; i++) {
        int aa = 0;
        cin >> aa;
        a.push_back(aa);
    }
    
    for (int i = 0; i < a.size(); i++) {
        vals[a[i]-1]++;
    }
    
     for (int i = 0; i < vals.size(); i++) {
         if (vals[i] + k - q <= 0) cout << "No" << endl;
         else cout << "Yes" << endl;
     }
   
     return 0;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
/*------------------------------------------------------------*/
int n,m;
int main(){
	in2(n,m);
	int c=2;
	FOR(i,2,m)c*=2;
	out((m*1900+(n-m)*100)*c);
} 

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

int main() {
  int n, a;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    a += (r - l + 1);
  }
  
  cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m,dp[8][8],a,b,ans;
void dfs(ll x,ll y){
    if(y==(1<<n)-1){ans++;return ;}
    for(int i=0;i<n;i++){
        //cout<<dp[x][i]<<" "<<((1<<i)&y)<<endl;
        if(dp[x][i]&&(!((1<<i)&y)))dfs(i,y|(1<<i));
    }
    return ;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        dp[a][b]++;
        dp[b][a]++;
    }
    dfs(0,1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
void insert(int k);
typedef struct node * Node;
void inorder(Node u);
void preorder(Node u);
#define NIL NULL
Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if(z -> key < x -> key)x=x->left;
    else x=x->right;
  }
  z -> parent = y;
  if(y==NIL)     root=z;
  else if(z->key < y->key)   y -> left=z;
  else y -> right=z;
}
void inorder(Node u){
  if(u==NIL)    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int  n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
    }
  }
  return 0;
}



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

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

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }

    reverse(a.begin(), a.end());

    for(int i=0; i<n; i++){
        cout << a.at(i);
        if(i==n-1) cout << endl;
        else cout << ' ';
    }
}


Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
#include<numeric>
#include<queue>
using namespace std;


int main(void) {

  int n;
  while(cin >> n){
    if( n == 0 ) break;
    bool l = false;
    bool r = false;
    bool p = false;
    int cnt = 0;
    for(int i=0; i<n; i++){
      string s;
      cin >> s;
      if( s == "lu" ) l = true;
      if( s == "ru" ) r = true;
      if( s == "ld" ) l = false;
      if( s == "rd" ) r = false;

      if( l == r && l != p ){
        cnt++;
        p = !p;
      }

    }
    cout << cnt << endl;


  }


  return 0;
}








//

Measured memory_bytes: 3068
def main():
    お寿司, 食べたい = map(int, input().split())
    築地 = [[] for _ in range(お寿司)]
    for _ in range(食べたい):
        鮪, 蛸 = map(lambda x: int(x) - 1, input().split())
        築地[鮪].append(蛸)
        築地[蛸].append(鮪)

    やってるかい = [False] * お寿司
    寿司くいねぇ = おなかすいた(0, 築地, やってるかい, 0)

    print(寿司くいねぇ)


def おなかすいた(市場, 築地, やってるかい, お勘定):
    やってるかい[市場] = True
    if all(やってるかい):
        return お勘定 + 1

    for 豪遊 in 築地[市場]:
        if やってるかい[豪遊]:
            continue
        お勘定 = おなかすいた(豪遊, 築地, やってるかい, お勘定)
        やってるかい[豪遊] = False

    return お勘定


if __name__ == '__main__':
    main()


Measured memory_bytes: 3320
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  int a[n];
  int s = 0;
  REP(i,n){
    cin>>a[i];
    s += a[i];
    a[i] *= n;
  }
  vector<pair<int, int>> vec;
  REP(i,n){
    vec.push_back(make_pair(abs(a[i]-s), i));
  }
  sort(ALL(vec));
  
  int ans = vec[0].second;
  cout<<ans<<endl;
  return 0;
}


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

void print(vector<int> V){
  for(vector<int>::iterator p = V.begin(); p != V.end(); p++){
    cout << *p << " ";
  }
  cout << endl;
}

int sosu(int n){
  if(n==2) return 1;
  if(n==1||n==0||n%2==0) return 0;
  for(int i = 3; i <= sqrt(n); i+=2){
    if(n%i == 0) return 0;
  }
  return 1;
}

bool a[300000] = {};

int main(){

  for(int i = 0; i < 300000; i++){
    if(sosu(i)) a[i] = true;
  }

  vector<int> V;
  for(int i = 2; i < 300000; i++){
    if(a[i]) V.push_back(i);
  }

  while(1){
    int N,P;
    cin >> N >> P; if(N==-1&&P==-1) break;
    //print(V);
    int p;
    for(int i = 0; i < V.size(); i++){
      if(N < V[i]){p = i; break;}
    }
    //cout << p << endl;

    vector<int> V2;
    for(int i = p; i < p+100; i++){
      for(int j = p; j <= i; j++){
        V2.push_back(V[i] + V[j]);
      }
    }
    sort(V2.begin(),V2.end());
    //print(V2);
    cout << V2[P-1] << endl;

  }

    return 0;
}



Measured memory_bytes: 3548
def dfs(count, n_1, n_2, n_3, z):
    if (count == n):
        return abs(a-n_1) + abs(b-n_2) + abs(c-n_3) + z * 10 if (n_1*n_2*n_3 != 0) else 10**9
    r0 = dfs(count+1, n_1, n_2, n_3, z)
    r1 = dfs(count+1, n_1+d[count], n_2, n_3, z+1)
    r2 = dfs(count+1, n_1, n_2+d[count], n_3, z+1)
    r3 = dfs(count+1, n_1, n_2, n_3+d[count], z+1)
    return min(r0, r1, r2, r3)
n, a, b, c = map(int, input().split())
d = []
for i in range(n):
    d.append(int(input()))


print(dfs(0,0,0,0, -3))

Measured memory_bytes: 3064
#include<stdio.h>

int m,n;

int main(void){
	register int i,j,k;
	scanf("%d%d",&m,&n);
	if(m*10000<n||m*1000>n||n%1000!=0)
		return puts("-1 -1 -1"),0;
	else
		for(i=0;i<=m;i++)
			for(j=0;j<=m;j++)
				for(k=0;k<=m,i+j+k<=m;k++)
					if(i+j+k==m&&i*1000+j*5000+k*10000==n)
						return printf("%d %d %d\n",k,j,i),0;
	puts("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    var min = n - 1
    val dList = divisor(n)
//    println(dList.joinToString(" "))
    for (d in dList) {
        min = Math.min(min, d + n/d - 2)
    }
    println(min)
}

fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

Measured memory_bytes: 44400
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
const string nyan("(=^・ω・^=)");

int gcd(int x, int y) {
	if (y)return gcd(y, x%y);
	return x;
}
int N, A[100000], L[100000], R[100000], res;
int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	L[0] = A[0];
	for (int i = 1; i < N; ++i) {
		L[i] = gcd(L[i - 1], A[i]);
	}
	R[N - 1] = A[N - 1];
	for (int i = N - 2; i >= 0; --i) {
		R[i] = gcd(R[i + 1], A[i]);
	}
	res = max(R[1], L[N - 2]);
	for (int i = 2; i < N ; ++i) {
		res = max(res, gcd(L[i - 2], R[i]));
	}
	cout << res << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#ifdef _debug
#define out(i) cout << #i << ' ' << i << ' '
#else 
#define out(i) //
#endif
using ll = long long;
using ull = unsigned long long;
const int maxn = 500001;
const int maxm = 2000000;
const int tomod = 998244353;
ll form(ll a){
	return (a + tomod) % tomod;
}
ll inv[maxm], fa[maxm];
void init(){
	fa[0] = fa[1] = 1;
	inv[0] = inv[1] = 1;
	for(int i = 2;i < maxm;++i){
		fa[i] = form(fa[i - 1] * (ll)i);
		inv[i] = form((tomod - tomod / i) * inv[tomod % i]);
	}
	for(int i = 2;i < maxm;++i)inv[i] = form(inv[i] * inv[i - 1]);
}
ll cof(int a, int b){
	return form(fa[a] * form(inv[b] * inv[a - b]));
} 
ll solve(int n, int k, const int max_odd){
	ll res = 0;
	for(int o = k&1;o <= max_odd;o += 2){
		res = form(res + form(
			cof(n, o) * 
			cof((k-o)/2+n-1, n-1)
		));
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	init();
	ll k, n;
	cin >> n >> k;
	ll res = solve(n, k * 3, min(n, k));
	res = form(res-form(
		n * form(solve(n, k, min(n, k)) - solve(n-1, k, min(n-1, k)))
	)
	);
	cout << res << '\n';
	assert(res>=0 and res<tomod);
}


Measured memory_bytes: 31616
import itertools
import sys

def score(abcd, A):
  ans = 0
  for a,b,c,d in abcd:
    if(A[b-1]-A[a-1])==c:
      ans += d
  return ans

N, M, Q = [int(x) for x in input().split()]
abcd = [ [int(x) for x in input().split()] for i in range(Q)]

a = itertools.combinations_with_replacement(range(1,M+1), N)
a = list(a)
Ans = 0
for i in range(len(a)):
  Ans = max(Ans,score(abcd,list(a[i])))
            
print(Ans)

Measured memory_bytes: 21768
#include <bits/stdc++.h>
using namespace std;
int a[501][501];
int main()
{
//	freopen("express.in","r",stdin);
//	freopen("express.out","w",stdout);
	int n,m,p,x,y;
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=m;i++)//O(nm)	(<=100000000(1s))
	{
		scanf("%d%d",&x,&y);
		if(y<x)	swap(x,y);
		for(int j=y;j<=n;j++)
			a[x][j]++;
	}
	for(int i=n-1;i>=1;i--)//O(n^2)	(<=250000)
		for(int j=1;j<=n;j++)
			a[i][j]+=a[i+1][j];
	for(int i=1;i<=p;i++)//O(p)	(<=100000)
	{
		scanf("%d%d",&x,&y);
		printf("%d",a[x][y]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1920
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int lim=1e9;
int get_res()
{
	char c=getchar();while(c!='Y' && c!='N') c=getchar();
	if(c=='Y') return 1;
	return 0;
}
void solve(int l,int r)
{
	int k;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		cout<<"? "<<mid<<"0"<<endl;
		fflush(stdout);
		int t=get_res();
		if(t) k=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<"! "<<k;
	fflush(stdout);
}
bool check(long long x)
{
	if(x>lim) return 0;
	cout<<"? "<<x-1<<"0"<<endl;
	fflush(stdout);
	int t=get_res();
	if(t==0) return 1;
	return 0;
}
int main()
{
	int now=999999999;
	while(now)
	{
		cout<<"? "<<now<<endl;
		fflush(stdout);
		int t=get_res();
		if(t==0) {solve(now+1,min(10ll*now+9,(long long)lim));return 0;}
		else
		{
			if(check(10ll*now+9)) {cout<<"! "<<10ll*now+9;fflush(stdout);return 0;}
			else now/=10;
		}
	}
	solve(1,9);
	return 0;
}

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

int main() {
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='?'){
      if(i!=1&&s[i-1]=='P'){
        s[i]='D';
      }
      else if(i!=s.size()-1&&s[i+1]=='D'){
        s[i]='P';
      }
      else if(i!=s.size()-1&&s[i+1]=='P'){
        s[i]='D';
      }
      else{
        s[i]='D';
      }
    }
  }
  cout<<s;
      
}


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

signed main() {
	vector<int> s(6);
	for (int i = 0; i < 6; ++i) {
		cin >> s[i];
	}

	string com;
	cin >> com;
	char tmp;

	for (int i = 0; i < com.size(); ++i) {
		if (com[i] == 'N') {
			tmp = s[5];
			s[5] = s[4];
			s[4] = s[0];
			s[0] = s[1];
			s[1] = tmp;
		}
		else if (com[i] == 'E') {
			tmp = s[5];
			s[5] = s[2];
			s[2] = s[0];
			s[0] = s[3];
			s[3] = tmp;
		}
		else if (com[i] == 'W') {
			tmp = s[5];
			s[5] = s[3];
			s[3] = s[0];
			s[0] = s[2];
			s[2] = tmp;
		}
		else if (com[i] == 'S') {
			tmp = s[5];
			s[5] = s[1];
			s[1] = s[0];
			s[0] = s[4];
			s[4] = tmp;
		}
	}
	cout << s[0] << endl;
}



Measured memory_bytes: 3224
n,m = map(int,input().split())
routing = [set([int(x) for x in input().split()][1:]) for _ in range(m)]
p = [int(x) for x in input().split()]
fail=0
for i in range(2**n):
    for k,x in enumerate(routing):
        num=0
        for j in range(n):
            if (i>>j)&1:
                if (j+1) in x:
                    num+=1
        if p[k]!=num%2:
            fail+=1
            break
print(2**n - fail)

Measured memory_bytes: 40560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.StringTokenizer;

public class Main {
	
	static class Point {
		
		int x, y;
		Point(int x, int y) {
			
			this.x = x;
			this.y = y;
		}
	}

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

		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt() - 1;
		int y = sc.nextInt() - 1;
		int a = sc.nextInt() - 1;
		int b = sc.nextInt() - 1;
		grid = new char[n][m];
		int[][] dist = new int[n][m];
		
		for (int i = 0; i < n; i++) {
			
			grid[i] = sc.next().toCharArray();
			Arrays.fill(dist[i], (int)1e8);
		}
		
		int[] dx = {1, -1, 0, 0};
		int[] dy = {0, 0, 1, -1};
		
		ArrayDeque<Point> q = new ArrayDeque<>();
		q.add(new Point(x, y));
		dist[x][y] = 0;
		
		while(!q.isEmpty()) {
			
			Point p = q.poll();
			//System.out.println(p.x + " " + p.y);
			// 0 cost edges
			for(int i = 0; i < 4; i++) {
				
				int newX = p.x + dx[i];
				int newY = p.y + dy[i];
				
				if(!isSafe(newX, newY))
					continue;
				
				if(dist[newX][newY] > dist[p.x][p.y]) {
					
					dist[newX][newY] = dist[p.x][p.y];
					q.addFirst(new Point(newX, newY));
				}
			}
			
			//1 cost edges
			for(int i = -2; i <= 2; i++) {
				for(int j = -2; j <= 2; j++) {
					
					int newX = p.x + i;
					int newY = p.y + j;
					
					if(!isSafe(newX, newY))
						continue;
					
					if(dist[newX][newY] > dist[p.x][p.y] + 1) {
						
						dist[newX][newY] = dist[p.x][p.y] + 1;
						q.addLast(new Point(newX, newY));
					}
				}
			}
		}
		
		/*for(int[] i : dist) {
			for(int p : i)
				System.out.print(p + " ");
			System.out.println();
				
		}*/
		pr.print(dist[a][b] >= (int)1e8 ? -1 : dist[a][b]);
		pr.close();
	}

	private static boolean isSafe(int x, int y) {

		if (x < 0 || y < 0 || x >= grid.length || y >= grid[0].length || grid[x][y] == '#')
			return false;

		return true;
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 58460