akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
ll h,w,k;
cin>>h>>w>>k;
vector<string> s(h);
rep(i,h)cin>>s[i];
ll ans=0;
rep(is,1<<h){rep(js,1<<w){
    int cnt = 0;
    rep(i,h)rep(j,w){
        if(is>>i&1)continue;
        if(js>>j&1)continue;
        if(s[i][j]=='#')cnt++;
    }
    if(cnt==k)ans++;
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 3612
s=input()
ans=0
def two(x):
	p=bin(x)
	return "0"*(len(s)-len(p)+1)+p[2:]
for i in range(2**(len(s)-1)):
	p=two(i)
	q=s[0]
	k=0
	for j in range(len(s)-1):
		if p[j]=="1":
			q+=s[j+1]
		else:
			k+=int(q)
			q=s[j+1]
	if len(q)>0:
		k+=int(q)
	ans+=k
print(ans)



Measured memory_bytes: 3064
class Array
  alias_method :enq, :push
  alias_method :deq, :shift
end

class Pro
  attr_accessor :name, :time
  def initialize(name,time)
    @name = name
    @time = time
  end
end

queue = []
n,q = gets.chomp.split(" ").map{|x| x.to_i}
for i in 1..n do
  name,time = gets.chomp.split(" ")
  queue.enq(Pro.new(name,time.to_i))
end

t = 0
while queue.size > 0 do
  p = queue.deq
  if p.time > q
    t += q
    p.time -= q
    queue.enq(p)
  else
    t += p.time
    printf("%s %d\n",p.name,t)
  end
end


Measured memory_bytes: 13684
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n =sc.nextInt();
    double t = sc.nextDouble();
    double a = sc.nextDouble();
    double h[] = new double[n];
    double dist[] = new double[n];
    int answer =0;
    double tmp=10000000;
    for(int i=0;i<n;i++){
      h[i]=sc.nextDouble();
    }
    for(int i=0;i<n;i++){
      dist[i]=Math.abs(a-(t-h[i]*0.006));
    }
    for(int i=0;i<n;i++){
      if(tmp>dist[i]){
        answer =i;
        tmp=dist[i];
      }
    }
    System.out.println(answer+1);
    
    
    
    
  }
  

  
}

Measured memory_bytes: 27376
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

int main()
{
  unsigned int N,a[100001],xo=0,cnt=0;
  cin >> N;
  REP(i,N){
    cin >> a[i];
  }
  REP(i,N){
    xo ^= a[i];
  }
  set<int> sets;
  REP(i,N){
    int las=0;
    while((a[i] &(1 << (las)))==0){
      las++;
    }
    sets.insert(las);
  }
  REP(i,31){
    if((xo >> (30-i)) & 1){
      if(sets.count(30-i)){
        xo = xo ^ ((1 << (31 - i))-1);
        cnt++;
      }else{
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    ll ans=0;
    for(ll i=1; i<=N; i++){
        ll j=N/i;
      	ll k=N%i;
      	if(k==0) j-=1;
        ans+=j;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 999999;
char s[N];int n,cnt[27];ll res;
int main() {
	scanf("%s",s+1);n=strlen(s+1);rep(i,1,n)cnt[s[i]-'a']++;
	res=1LL*n*n;rep(i,0,25)res-=1LL*cnt[i]*cnt[i];res/=2;
	cout<<res+1;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n, d, r, i, j, c=0;
    cin >> n >> d >> r;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin >> a[i];
    }
    for(i=0; i<n; i++)
    {
        for(j=1; j<=d; j+=a[i])
        {
            c++;
        }
    }
    cout << c+r;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class C100To105 {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        int t = n%100;
        int tt;
        if(t%5!=0){
            tt = t/5+1;
        }else{
            tt= t/5;
        }
//        out <<tt << endl;
        if(tt*100>n){
            out << 0 << endl;
        }else{
            out << 1 << endl;
        }
	}
};


int main() {
	C100To105 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int dp[100][100][13000], a[100][100], b[100][100], sa[100][100];
signed main(){
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>b[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			sa[i][j] = abs( a[i][j] - b[i][j] );
		}
	}
	dp[1][0][0] = 1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			for(int k=0;k<=12900;k++){
				if( dp[i-1][j][k] == 1 || dp[i][j-1][k] == 1 ){
					dp[i][j][ k + sa[i][j] ] = 1;
					if( k >= sa[i][j] ) dp[i][j][ k - sa[i][j] ] = 1;
					else dp[i][j][ sa[i][j] - k ] = 1;
				}
			}
		}
	}
	for(int i=0;i<=12900;i++){
		if( dp[h][w][i] == 1 ){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 809344
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a1,b1,a2,b2,k;
	scanf("%d%d%d%d%d",&a1,&b1,&a2,&b2,&k);
	if (a2<a1||a2==a1&&b2<b1) a2+=24;
	int t=a2*60+b2-a1*60-b1;
	if (t<=k) printf("0\n"); else printf("%d\n",t-k); 
}

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

class text_editor {
private:
	string text;
public:

	void read_text(istream &in) {
		string line;
		getline(in,line);
		this->text = "^" + line;
	}

	void forward_char() {
		auto cursor = find(this->text.begin(),this->text.end(),'^');
		if (cursor + 1 != this->text.end()) { // if cursor not at the end of text
			swap(*cursor,*(cursor + 1));
		}
	}

	void forward_word() {
		auto cursor = find(this->text.begin(),this->text.end(),'^');
		while (cursor + 1 != this->text.end() && *(cursor + 1) == ' ') {
			swap(*cursor,*(cursor + 1));
			++cursor;
		}
		while (cursor + 1 != this->text.end() && *(cursor + 1) != ' ') {
			swap(*cursor,*(cursor + 1));
			++cursor;
		}
	}

	void backward_char() {
		auto cursor = find(this->text.begin(),this->text.end(),'^');
		if (cursor != this->text.begin()) {
			swap(*cursor,*(cursor - 1));
		}
	}

	void backward_word() {
		auto cursor = find(this->text.begin(),this->text.end(),'^');
		while (cursor != this->text.begin() && *(cursor - 1) == ' ') {
			swap(*cursor,*(cursor - 1));
			--cursor;
		}
		while (cursor != this->text.begin() && *(cursor - 1) != ' ') {
			swap(*cursor,*(cursor - 1));
			--cursor;
		}
	}

	void delete_char() {
		auto cursor = find(this->text.begin(),this->text.end(),'^');
		if (cursor + 1 != this->text.end()) {
			this->text.erase(cursor + 1);
		}
	}

	void delete_word() {
		auto cursor = find(this->text.begin(),this->text.end(),'^');
		auto pos = cursor + 1;
		while (pos != this->text.end() && *pos == ' ') {
			++pos;
		}
		if (pos != this->text.end()) {
			this->text.erase(cursor + 1,find(pos,this->text.end(),' '));
		}
	}

	void insert_any_text(string any_text) {
		this->text.insert(this->text.find('^'),any_text);
	}

	string get_text() {
		return this->text;
	}
};

int main() {
	text_editor edtr;
	int n; // number of texts
	cin >> n;
	cin.ignore();
	while (n--) {
		edtr.read_text(cin);
		int cmd_num; // number of commands
		cin >> cmd_num;
		cin.ignore();
		while (cmd_num--) {
			string cmd;
			getline(cin,cmd);
			if (cmd == "forward char") {
				edtr.forward_char();
			} else if (cmd == "forward word") {
				edtr.forward_word();
			} else if (cmd == "backward char") {
				edtr.backward_char();
			} else if (cmd == "backward word") {
				edtr.backward_word();
			} else if (cmd == "delete char") {
				edtr.delete_char();
			} else if (cmd == "delete word") {
				edtr.delete_word();
			} else { // insert "any-text"
				auto first_quot = cmd.find_first_of("\"");
				auto last_quot = cmd.find_last_of("\"");
				edtr.insert_any_text(cmd.substr(first_quot + 1,last_quot - first_quot - 1));
			}
		}
		cout << edtr.get_text() << endl;
	}
}

Measured memory_bytes: 3052
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;
typedef long long int ll;


int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    if ( A >= D || B <= C ) {
        cout << 0 << endl;
        return 0;
    }

    if ( A < C ) {
        if ( B >= D ) {
            cout << D - C << endl;
        }
        if ( B < D ) {
            cout << B - C << endl;
        }
    }
    if ( A >= C ) {
        if ( B >= D ) {
            cout << D - A << endl;
        }
        if ( B < D) {
            cout << B - A << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int INF=1<<30,N,M,b,i,j,c,K,a[1<<10],S[1<<10];
int main(){
	cin>>N>>M;
	for(i=0;i<M;i++){
		cin>>a[i];
		cin>>b;
		for(j=0;j<b;j++){
			cin>>c;
			S[i]+=1<<(c-1);
		}
	}
	K=1<<N;
	vector<int>dp(K,INF);
	dp[0]=0;
	for(i=1;i<K;i++)for(j=0;j<M;j++)dp[i]=min(dp[i],dp[i&~S[j]]+a[j]);
	cout<<(dp[K-1]==INF?-1:dp[K-1])<<endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

constexpr int MOD = 1000000007;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int main() {
    string s;
    cin >> s;
    const int N = s.size();

    int acc = 0;
    for (int j = 0; j < N; ++j) {
        if (s[j] == 'g') {
            ++acc;
        } else {
            --acc;
        }
    }
    cout << acc / 2 << endl;

    return 0;
}


Measured memory_bytes: 512
n,k = map(int,input().split())
h = list(map(int,input().split()))

def compare(num, d):
    ''' 
    num >= d --> true
    d < num --> false
    '''
    if num >= d:
        return True
    else:
        return False
ans = 0
for x in h:
    if compare(x,k):
        ans += 1
print(ans)

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

void fastInputOutput(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

ll GCD(ll a, ll b){ll gcd, g;g = __gcd(a, b);return g;}
ll LCM(ll a, ll b){ll gcd, g;g = __gcd(a, b);return (a/g)*b;}
ll PowFun(ll base, ll power){ll ans = 1;for(int i = 1; i <= power; i++){ans *= base;}return ans;}



const ll INF_LONG = 1LL<<61;
const unsigned int inf_int = 1<<31;
const ll mod = 1e9+7;
double phi = acos(-1);

int main()
{
    fastInputOutput();
    string ac;
    cin >> ac;
    if(ac.compare("ABC") == 0)
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!(usize; n);

    for i in 0..n {
        if a[i] > i {
            println!("-1");
            return;
        }
    }

    let mut map = BTreeMap::new();
    for i in 0..n {
        let entry = map.entry(i-a[i]).or_insert(Vec::new());
        entry.push(i);
    }

    let mut mn = std::usize::MAX;
    for (k,v) in map.iter().rev() {
        if mn < *v.iter().max().unwrap() {
            println!("-1");
            return;
        }
        mn = *v.iter().min().unwrap();
    }

    println!("{}", map.into_iter().map(|(_, v)| v.iter().map(|&i| a[i]).max().unwrap()).sum::<usize>());
}


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

int N, nxt[10004];

int getID(int x, int y) { return y * N + x; }

void solve() {
	int ans = 0;
	vector< bool > visited(N * N, false);
	for (int v=0; v<N*N; ++v) {
		if (visited[v]) continue;
		int p = v;
		set< int > tmp;
		while (!visited[p]) {
			tmp.insert(p);
			visited[p] = true;
			p = nxt[p];
		}
		if (tmp.count(p)) ++ans;
	}
	cout << ans << endl;
}

int main() {
	while (cin >> N, N) {
		for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) {
			int x, y;
			cin >> x >> y;
			nxt[getID(j,i)] = getID(x,y);
		}
		solve();
	}
}


Measured memory_bytes: 3052
S = input()
N = len(S)

S1 = S[::-1]
S21 = S[:(N - 1) // 2]
S22 = S21[::-1]
S31 = S[(N + 3) // 2 - 1:]
S32 = S31[::-1]

if S == S1 and S21 == S22 and S31 == S32:
    print("Yes")
else:
    print("No")


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

using namespace std;
#define ll long long
#define mem(a, b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define p_queue priority_queue
#define DBG printf("this is a input\n")
#define fi first
#define se second
#define mk(a, b) make_pair(a,b)
#define pb(a) push_back(a)
#define CLOSE ios::sync_with_stdio(0); cin.tie(0)

ll n, A , B , C ,D;
map <ll,ll> ma;
ll dfs(ll N)
{
    if(N == 0) return 0;
    if(N == 1) return D;
    if(ma.count(N))  return ma[N];
    ll l2 = (N/2)*2;
    ll r2 = ((N+1)/2)*2;
    ll l3 = (N/3)*3;
    ll r3 = ((N+2)/3)*3;
    ll l5 = (N/5)*5;
    ll r5 = ((N+4)/5)*5;

    ll ans = 1e18;
    if(N < ans/D) ans = N*D;

    ans = min(ans, abs(l2-N)*D + A + dfs(l2/2));
    ans = min(ans, abs(r2-N)*D + A + dfs(r2/2));

    ans = min(ans, abs(l3-N)*D + B + dfs(l3/3));
    ans = min(ans, abs(r3-N)*D + B + dfs(r3/3));

    ans = min(ans, abs(l5-N)*D + C + dfs(l5/5));
    ans = min(ans, abs(r5-N)*D + C + dfs(r5/5));

    ma[N] = ans;
    return ans;
}
int main(void)
{
    int T;
    cin >> T;
    while (T --)
    {
        ma.clear();
        cin >> n >> A >> B >> C >> D;
        cout << dfs(n) << endl;
    }
}

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


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			string str = Console.ReadLine();
			double r = double.Parse(str);

			double area = r * r * 3.14159265358979;
			double circle = 2 * r *  3.14159265358979;

			Console.WriteLine("{0:f6} {1:f6}", area, circle);

			Console.ReadKey();

		}
	}
}



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

using namespace std;

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

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

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

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



int n, a[202020];
map<int,int> mp;
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		mp[a[i]]++;
	}
	sort(a,a+n);
	
	int cnt = 0;
	for(int i = n-1; i > 0; i--){
		if(mp[a[i]] == 0) continue;
		for(i64 j = 1; j < 2*INF; j*=2){
			if(j <= a[i]) continue;
			if(j-a[i] == a[i]){
				if(mp[a[i]] >= 2){
					mp[a[i]] -= 2;
					cnt++;
					break;
				}
			}
			else if(mp[j-a[i]] > 0 && mp[a[i]] > 0){
				mp[j-a[i]]--;
				mp[a[i]]--;
				cnt++;
				break;
			}
		}
	}
	cout << cnt << endl;
}

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

Measured memory_bytes: 29824
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	char a,b;
	string x,y;
	cin >> a >> b;
	for (int i = 0; i < b - '0'; i++) {
		x += a;
	}
	for (int i = 0; i < a - '0'; i++) {
		y += b;
	}
	if (x <=y) {
		cout << x << endl;
	} else {
		cout << y << endl;
	}
}



Measured memory_bytes: 256
N, T = map(int, input().split())
A = list(map(int, input().split()))

right = [0] * (N+1)
for i in range(N-1,-1,-1):
    right[i+1] = max(right[i], A[i])
left = [10 ** 9 + 7] * (N+1)
for i in range(N):
    left[i+1] = min(left[i], A[i])

profit = 0
cnt = 0
for i in range(1,N+1):
    if profit == right[i]-left[i]:
        cnt += 1
    elif profit < right[i]-left[i]:
        cnt = 1
        profit = right[i]-left[i]

print(cnt)



Measured memory_bytes: 62704
/*

Author : AllKilled
Date   : 201911166

Contest: AtCoder Beginner Contest 145.
Problem: Task C.
Result : AC

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

typedef long long LL;

const LL MAXN = 1e6+7;

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

int n, x[11], y[11], vis[11], dp[11], tot;
double ans = 0.0;

double dist(int a, int b){
    return sqrt(1.0 * a *a + 1.0 * b * b);
}

void dfs(int p, int num){
    if(p > num) return ;
    if(num == 1) {
        double res = 0;
        for(int i = 2; i <= n; ++i) {
            int u = dp[i], v = dp[i-1];
            res += dist(x[u] - x[v], y[u] - y[v]);
        }
        ans += res;
        return ;
    }
    swap(dp[p], dp[num]);
    dfs(1, num - 1);
    swap(dp[p], dp[num]);
    dfs(p + 1, num);
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        dp[i] = i;
        cin >> x[i] >> y[i];
    }
    tot = n;
    dfs(1, tot);
    vector<int> f;
    int cnt = 1;
    for(int i = 1; i <= n; ++i) f.push_back(i), cnt *= i;
  /*  
    do {
        for(int i = 1; i < n; ++i){
            int u = f[i], v = f[i-1];
            ans += dist(x[u] - x[v], y[u] - y[v]);
        }
    } while (next_permutation(f.begin(), f.end()));
  */
    ans /= cnt;
    printf("%.12f\n", ans);
    return 0;
}


Measured memory_bytes: 256
first = input()
second = input()

row_1 = [w for w in first]
row_2 = [w for w in second]

if row_1[0] == row_2[2] and row_1[1] == row_2[1] and row_1[2] == row_2[0]:
    ans = 'YES'
else:
    ans = 'NO'

print(ans)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
	int N,Z,W;
	int a[2050];
	cin >> N >> Z >> W;
	REP(i,N){cin >> a[i];}
	if(N==1){
	    cout << abs(a[0]-W) << endl;
	}else{
	    cout << max(abs(a[N-1]-W),abs(a[N-2]-a[N-1])) << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#AGC027 A
'''
問題
N人の子供がいる
x個のお菓子をすべて配り切らなければならない
お菓子をもらわないこどもがいてもよい
子供iはちょうどai個のおかしをもらうと喜ぶ
喜ぶ子供の人数の最大値は?

考察
aiを小さい順にソートし,xから順番にaiを引いていく
'''

N,x = map(int,input().split(' '))
A = sorted(list(map(int,input().split(' '))))

ans = 0

for a in A:
	if x>=a:
		ans += 1
		x -= a
	elif x<a:
		break

#お菓子が最終的に余った場合の処理
if ans==N and x>0:
	ans -= 1

print(str(ans))

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

string str[101];
int H,W,cnt;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
char ch;

void dfs(int x,int y){
  if(x < 0 || x >= H || y < 0 || y >= W||ch != str[x][y]) return;
  str[x][y] = '0';

  for(int i = 0 ; i < 4 ; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    dfs(nx,ny);
  }  
}

int main(){
  while(cin >> H >> W ,H + W){
    for(int i = 0 ; i < H ; i++){
      cin >> str[i];
    }

    cnt = 0;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	if(str[i][j] != '0'){
	  ch = str[i][j];
	  dfs(i,j);
	  cnt++;
	}
      }
    }
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1688
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let path = read::<String>();
    if path == "AAA" || path == "BBB" {
        println!("No");
    } else {
        println!("Yes");
    }
}

Measured memory_bytes: 4352
//Create Time: 2018-04-21 20:03:02
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
/****head****/
int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans=1ll<<60;
    int up=2*max(x,y)+1;
    for(int i=0;i<up;i+=2){
        chmin(ans,1ll*i*c + 1ll*a*max(0,x-i/2) + 1ll*b*max(0,y-i/2));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

bool isbits1(int bits){
  int num = 0;
  int mask = 1;
  while(mask!=0){
    if(bits&mask)++num;
    mask<<=1;
  }
  return num==1;
}

const int N_MAX = 1e5+10;
int n_2[N_MAX];
void init(){
  int n = 1;
  rep(i,N_MAX){
    n_2[i] = n;
    if(2*n==i)n<<=1;
  }
}

int main(void){
  SPEEDUP
  init();
  cout << setprecision(15);
  int N;cin >> N;
  if(isbits1(N)){
    cout << "No" << endl;
    return 0;
  }
  bool check = false;
  if((N&1) == 0) check = true;
  cout << "Yes" << endl;
  cout << N+1 SP N+2 << endl;
  repp(i,1,(N-1)/2+1){
    cout << 2*i+N SP 2*i+1 << endl;
    cout << 2*i+1 SP 1 << endl;
    cout << 1 SP 2*i << endl;
    cout << 2*i SP 2*i+N+1 << endl;
  }
  if(check){
    cout << N SP n_2[N]  << endl;
    int n = N - n_2[N] + 1;
    cout << n SP 2*N << endl;
  }
  return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>

int main()
{
    int i, N, c = 0;
    scanf("%d", &N);
    int a[N];
    for (i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
        if (i % 2 == 0 && a[i] % 2 != 0)
        {
            c++;
        }
    }
    printf("%d", c);
    return 0;
}

Measured memory_bytes: 1728
n=int(input())
A=[int(input()) for i in range(n)]
flag=0
ans=-1
C=[0 for i in range(n+1)]

for j in range(n):#0,n-1
    if j==0:#1回目の操作はj=0, Aの1番目を参照したい
        C[j]=A[0]-1
    else:#j=1からn-1
        C[j]=A[C[j-1]]-1
        if C[j]==1:
            ans=j+1
            flag=1
            break
        else:
            continue
        if flag: break
        else: continue
    if flag:break
    else:continue
if A[0]==2:
    ans=1
print(ans)

Measured memory_bytes: 11052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int n,m,k;
  cin >> n >> m >>k;
  bool res = false;
  for(int i = 0;i <= n;i++){
    for(int j = 0;j <= m;j++){
      if(i * (m - j) + j * (n - i) == k)res = true;
    }
  }
  if(res)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
map <string,bool> mp;
int main() {
    int n;
    string l;
    cin >> n;
    for (int i=0;i<n;i++) {
        string s;
        cin >> s;
        if (i==0) l=s;
        else if (s[0]!=l[l.length()-1]||mp[s]) return cout << "No" << endl,0;
        mp[s]=true;
        l=s;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
flush= sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**25)

def iin(): return int(input())
def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input


def main():
    h, a = lin()
    print((h+a-1)//a)



            
        

        
main()
# threading.Thread(target=main).start()


Measured memory_bytes: 38340
#include <stdio.h>
#include <unistd.h>

#define L 6
#define putchar_buf(X) do{ buf[point] = X; point++; }while(0)
#define putlong_buf(X) \
    do{ \
        long n=X; \
        char c[L]; \
        long i=L-1; \
        do{ c[i]=n%10+'0'; n/=10; i--; }while(n>0); \
        for(i++;i<L;i++){ putchar_buf(c[i]); } \
    }while(0)
#define puts_buf(X) \
    do { \
        for(size_t i=0; X[i]!='\0'; i++){ \
            putchar_buf(X[i]); \
        } \
        putchar_buf('\n'); \
    }while(0)

int data[1<<17];
char buf[819200];

static void solve(long a, long b, const size_t sp, const size_t ep, long mask){
    if(ep-sp<=2){
        data[sp+0] = a;
        data[sp+1] = b;
    }else{
        const long t = a^b;
        const long d = t&(-t);
        mask ^= d;
        const long ad = a&d;
        const long bd = b&d;
        a &= mask;
        b &= mask;
        const long ab = a ^ (mask&(-mask));
        const size_t mp = (sp+ep)/2;
        //printf("%ld %ld %ld\n", aa, ab, bb);
        solve(a, ab, sp, mp, mask);
        solve(ab, b, mp, ep, mask);
        for(size_t i=sp; i<mp; i++){ data[i] |= ad; }
        for(size_t i=mp; i<ep; i++){ data[i] |= bd; }
    }
}

int main(void){
    long n, a, b;
    scanf("%ld %ld %ld", &n, &a, &b);
    if(__builtin_parity(a) == __builtin_parity(b)){
        puts("NO");
    }else{
        solve(a, b, 0, 1<<n, 0xFFFFFFFFFFFFFFFF);
        const size_t m = 1<<n;
        size_t point=0;
        puts_buf("YES");
        for(size_t i=0; i<m-1; i++){
            putlong_buf(data[i]);
            putchar_buf(' ');
        }
        putlong_buf(data[m-1]);
        putchar_buf('\n');
        write(1, buf, point);
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n;
	cin>>n;

	lli a,b;
	for(lli i=1;i*i<=n;i++){
		if(n%i==0){
			a = i;
			b = n/i;
		}
	}

	cout<<a+b-2<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
using namespace std;
int main(){

    string s;
    cin>>s;
    int l=s.size();
    int c=0;
    for(int i=0;i<l;i++){
        if(s.at(i)=='7'){
            c++;
            break;
        }
    }
    if(c!=0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }



}






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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int x = 0;
  int m = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'I') x++;
    if (s[i] == 'D') x--;
    m = max(m, x);
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int Parent(vector<int>&A, int i){
	while(A[i]!=i) i=A[i];
	return i;
}
void setParent(vector<int>&A,int i, int p){
	while(A[i]!=p){
		int a=A[i];
		A[i]=p;
		i=a;
	}
}
int solve(){
	int n,m,x,y,p1,p2;
	cin>>n>>m;
	vector<int>P(n+1);
	iota(P.begin(),P.end(),0);
	while(m--){
		cin>>x>>y;
		p1=Parent(P,x);
		p2=Parent(P,y);
		setParent(P,x,min(p1,p2));
		setParent(P,y,min(p1,p2));
	}
	vector<int>A(n+1);
	x=0;
	for(int i=1;i<=n;i++){
		p1=Parent(P,i);
		setParent(P,i,p1);
		A[p1]++;
		x=max(x,A[p1]);
	}
	return x;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<solve()<<"\n";
}

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

struct node {
	node *p, *l, *r;
	int cnt;
	void Init(node *p_) {
		p = p_;
		l = r = nullptr;
		cnt = 0;
	}
};

int it;
node pool[10000000];

node *new_node(node *p) {
	pool[it].Init(p);
	return &pool[it++];
}

class uint_Trie {
	node *root;
	int siz;
public:
	uint_Trie() : root(new_node(nullptr)) {}
	int size() {
		return root->cnt;
	}
	void insert(unsigned val) {
		// if (find(val)) return; // multiset ???????¶????
		node *t = root;
		for (int i = 30; i >= 0; i--) {
			t->cnt++;
			if (val & (1 << i)) {
				if (t->r == nullptr) {
					t->r = new_node(t);
				}
				t = t->r;
			}
			else {
				if (t->l == nullptr) {
					t->l = new_node(t);
				}
				t = t->l;
			}
		}
		t->cnt++;
	}
	void erase(unsigned val) {
		node *t = root, *ne;
		for (int i = 30; i >= 0; i--) {
			t->cnt--;
			if (val & (1 << i)) {
				if (t->r == nullptr) return;
				t = t->r;
			}
			else {
				if (t->l == nullptr) return;
				t = t->l;
			}
		}
		t->cnt--;
		while (t != root && t->cnt == 0) {
			ne = t->p;
			(t == ne->l ? ne->l : ne->r) = nullptr;
			t = ne;
		}
	}
	bool find(unsigned val) {
		node *t = root;
		for (int i = 30; i >= 0; i--) {
			if (val & (1 << i)) {
				if (t->r == nullptr) return false;
				t = t->r;
			}
			else {
				if (t->l == nullptr) return false;
				t = t->l;
			}
		}
		return true;
	}
	unsigned max() {
		assert(root->cnt >= 1);
		node *t = root;
		unsigned res = 0;
		for (int i = 30; i >= 0; i--) {
			assert(t->l != nullptr || t->r != nullptr);
			if (t->r != nullptr) {
				res |= 1 << i;
				t = t->r;
			}
			else {
				t = t->l;
			}
		}
		return res;
	}
	unsigned min() {
		assert(root->cnt >= 1);
		node *t = root;
		unsigned res = 0;
		for (int i = 30; i >= 0; i--) {
			assert(t->l != nullptr || t->r != nullptr);
			if (t->l != nullptr) {
				t = t->l;
			}
			else {
				res |= 1 << i;
				t = t->r;
			}
		}
		return res;
	}
};

int main()
{
	cin.sync_with_stdio(false);
	uint_Trie ut;
	string com;
	int k;
	while (cin >> com, com != "end") {
		if (com == "insert") {
			cin >> k;
			ut.insert(k);
		}
		else {
			int res = ut.max();
			printf("%d\n", res);
			ut.erase(res);
		}
	}
	return 0;
}

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

int main(){
  string s,t;
  cin>>s>>t;
  int ans=t.size();
  rep(i,s.size()-t.size()+1){
    int cnt=0;
    rep(j,t.size()){
      if(t[j]!=s[i+j]){
        cnt++;
      }
    }
    ans=min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = (1LL<<31) - 1;
const long long int base1 = 48271;
const long long int base2 = 69621;
vector<int> match;

void contain(string a, string b, long long int BASE){// find a from b
    if(a.length() > b.length()) return ;

    long long int powB = 1;
    for(int i=0; i<a.length(); i++){
        powB *= BASE;
        powB %= MOD;
    }

    // Hash
    long long int hash_a = 0;// a[0] * BASE^(la-1) + ... + a[la-2] * BASE + a[la-1] 
    long long int hash_b = 0;
    for(int i=0; i<a.length(); i++){
        hash_a = hash_a * BASE + a[i];
        hash_b = hash_b * BASE + b[i];// hash of b.substr(0, a.length())

        hash_a %= MOD;
        hash_b %= MOD;
    }

    // Roll
    for(int i=0; i+a.length()<=b.length(); i++){
        if(hash_a == hash_b){// b.substr(i,la) == a
            match[i] += 1;
        }
        
        if(i + a.length() < b.length()){
            hash_b = hash_b * BASE + b[i+a.length()] - b[i] * powB;
            hash_b = (hash_b % MOD + MOD) % MOD;
        }
    }
    return ;// i + a.length() == b.length() : coudln't find
}

vector<vector<int>> graph, inv_graph;
vector<int> dp;
vector<bool> visited;

long long int DFS(int v){
    if(visited[v] == true) return dp[v];
    visited[v] = true;

    if(graph[v].empty() == false){
        int len = DFS(graph[v][0]);
        if(len != -1) return dp[v] = len + 1;
        else return -1;
    }

    return dp[v] = 0;// empty
}

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

    while(s.length() < t.length()){
        s += s;
    }
    int n = s.length();
    match.resize(2*n);
    graph.resize(n);
    inv_graph.resize(n);
    dp.assign(n, -1);

    s += s;
    contain(t, s, base1);
    contain(t, s, base2);
    //for(int i=0; i<2*n; i++) cout << match[i] << " ";
    //cout << endl;

    int m = t.length();
    for(int i=0; i<n; i++){
        if(match[i] == 2){
            //cout << i << " ";
            graph[i].push_back((i+m) % n);
            inv_graph[(i+m) % n].push_back(i);
        }
    }
    //cout << endl;

    long long int ans = -1;
    visited.assign(n, false);
    for(int i=0; i<n; i++){
        long long int len = DFS(i);
        if(len == -1){
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, len);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 134440
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	cout<<(1000 - N % 1000) % 1000<<endl;
}

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

int main() {
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  int A_shou,A_amari,B_shou,B_amari;
  A_shou = A / K;
  A_amari = A % K;
  B_shou = B / K;
  B_amari = B % K;
  if((B_shou>A_shou)||A_amari == 0 || B_amari == 0 ){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3612
N, *AB = map(int, open(0).read().split())
AB = [(a, b) for a, b in zip(*[iter(AB)] * 2)]
AB.sort(key=lambda x: x[0] + x[1], reverse=True)
ans = sum(a for a, _ in AB)
for a, b in AB[1::2]:
    ans -= a + b
print(ans)


Measured memory_bytes: 31640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  string T[] = {"dream", "dreamer", "erase", "eraser"};
  vector<bool> able(N+1);
  rep(i, N) rep(j, 4) {
    if(S.substr(i, T[j].size()) == T[j]) {
      if(i == 0) able[i+T[j].size()] = true;
      else able[i+T[j].size()] = able[i];
    }
  }
  cout << (able[N] ? "YES" : "NO") << endl;
  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    double x, y;
    int goukei = 0;

    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        double kekka = sqrt(x * x + y * y);
        if (kekka <= d) {
            goukei++;
        }
    }
    cout << goukei << endl;
}

Measured memory_bytes: 3804
#include<stdio.h>
#include<algorithm>
using std::sort;
#include<iostream>
using std::cin;
using std::cout;
#include<string>
using std::string;

int n;
string str[100];

int main(void){
	register int i;
	scanf("%d%*d",&n);
	for(i=0;i<n;i++)
		cin>>str[i];
	sort(str,str+n);
	for(i=0;i<n;i++)
		cout<<str[i];
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int n, q;
	queue<string> N;
	queue<int> T;
	string na;
	int ti;

	cin >> n >> q;
	for (int i = 0; i < n; i++)
	{
		cin >> na >> ti;
		N.push(na);
		T.push(ti);
	}

	int now = 0;

	while (N.size() != 0)
	{
		na = N.front();
		ti = T.front();
		N.pop();
		T.pop();

		if (ti <= q)
		{
			now += ti;
			cout << na << " " << now << endl;
		}
		else
		{
			now += q;
			N.push(na);
			T.push(ti - q);
		}
	}

	return 0;
}


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

string a;
int n;
int edge[200010][26];
int dp[200010];
int nxt[200010];
char c[200010];

int dfs(int from) {
	if(dp[from] != -1) return dp[from];
	int ret = 1e9;
	for(int i = 25; i >= 0; --i) {
		int to = dfs(edge[from][i]) + 1;
		if(to <= ret) {
			ret = to;
			nxt[from] = edge[from][i];
			c[from] = (char)('a' + i);
		}
	}
	dp[from] = ret;
	return ret;
}

int main() {
	cin >> a;
	a = "$" + a;
	n = a.size();
	int nidx[26]; for(int i = 0; i < 26; ++i) nidx[i] = n;
	for(int i = n - 1; i >= 0; --i) {
		for(int j = 0; j < 26; ++j) {
			edge[i][j] = nidx[j];
		}
		if(i > 0) {
			nidx[a[i] - 'a'] = i;
		}
	}
	for(int i = 0; i < 200010; ++i) {
		dp[i] = -1;
	}
	dp[n] = 0;
	dfs(0);
	string ans;
	int now = 0;
	while(now < n) {
		ans += c[now];
		now = nxt[now];
		if(now == n) break;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 26296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  bool ok=true;
  int mx = 0;
  rep(i,n) {
    if (mx - 1 > a[i]) ok = false;
    mx =max(mx, a[i]);
  }
  ok();
  return 0;
}

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

#pragma warning(disable:4996)
char S[100000 + 1];

int main(void) {

	scanf("%s", &S[0]);
	int N = strlen(S);

	int ret = 0;
	int A = 0; // start with 0
	int B = 0; // start with 1
	for (int i = 0; i < N; ++i) {
		if (i%2 == 1) {
			if (S[i] == '0') {
				++A;
			}
			else {
				++B;
			}
		}
		else {
			if (S[i] != '0') {
				++A;
			}
			else {
				++B;
			}

		}
		
	}
	if (A < B) {
		ret = A;
	}
	else {
		ret = B;
	}
	printf("%d", ret);

	return 0;
}

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

using namespace std;

const int N=200;

string n;

ll k,mem[N][5][2];

ll dp(int pos,int cnt,bool flag)
{
    if (pos==n.length())
    {
        return (cnt==0);
    }
    if (mem[pos][cnt][flag]!=-1)return mem[pos][cnt][flag];
    ll ans=0;
    for (char ch='0';ch<='9';ch++)
    {
        if (ch=='0')ans+=dp(pos+1,cnt,flag||(ch<n[pos]));
        else if (cnt)
        {
            if ((ch>n[pos]&&flag)||ch<=n[pos])ans+=dp(pos+1,cnt-1,flag||(ch<n[pos]));
        }
    }
    return mem[pos][cnt][flag]=ans;
}

int main()
{
    memset(mem,-1,sizeof mem);
    cin >> n >> k;
    cout << dp(0,k,0) << endl;
    return 0;
}



Measured memory_bytes: 256