akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

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

    int len = to_string(n).size();
    int odd = len/2;

    int add = pow(10, odd*2-2) * 9;

    int ans = 0;
    while (odd > 0) {
        ans += add;
        add /= 100;
        odd--;
    }

    if (len%2)
        ans += n - (pow(10, len-1) - 1);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
    int n,ans = 0;
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n-1; ++i) {
        cin >> b[i];
    }
    ans += b[0];
    for (int i = 1; i <= n-2; ++i) {
        ans += min(b[i-1],b[i]);
    }
    ans += b[n-2];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___combination___////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

///////////////////////////////////////////////////////////
int h,w;
int f(int a, int b, int c){
  return max({a,b,c}) - min({a,b,c});
}
signed main(){
  cin>>h>>w;
  int ans = INF;
  repd(i,1,h){
    int a = w*i, r = h-i;
    chmin(ans, f(a, w*(r/2), w*(r-r/2)));
    chmin(ans, f(a, r*(w/2), r*(w-w/2)));
  }
  repd(i,1,w){
    int a = h*i, r = w-i;
    chmin(ans, f(a, h*(r/2), h*(r-r/2)));
    chmin(ans, f(a, r*(h/2), r*(h-h/2)));
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int k,x;
    cin>>k>>x;
    for(int i=(x-(k-1));i<=(x+(k-1));i++)
    cout<<i<<" ";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e6 + 9;


int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    int x;
    cin >> x;
    cout << ( x >= 30 ? "Yes" : "No" );

}




Measured memory_bytes: 3632
def topological_sort(N, edges):
    from collections import deque
    nps=[0]*N
    for _, dsts in enumerate(edges):
        for dst in dsts:
            nps[dst]+=1
    
    q = deque([])
    for i, np in enumerate(nps):
        if np==0:
            q.append(i)
    
    rets = [0]*N
    cnt=0
    while q:
        src = q.popleft()
        rets[src]=cnt
        cnt+=1
        for dst in edges[src]:
            nps[dst]-=1
            if nps[dst]==0:
                q.append(dst)
    return rets

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
revedges=[[] for _ in range(N)]

for _ in range(N-1+M):
    a,b=map(int,input().split())
    edges[a-1].append(b-1)
    revedges[b-1].append(a-1)

inds = topological_sort(N, edges)
parents=[-1]*N
for dst in range(N):
    if len(revedges[dst])==0:
        parents[dst]=0
    else:
        _,parents[dst] = max([(inds[src],src+1) for src in revedges[dst]])

for p in parents:
    print(p)

Measured memory_bytes: 83632
class card:
    def __init__(self, card):
        self.suit = card[0]
        self.value = int(card[1])

    def __repr__(self):
        return self.suit + str(self.value)


def selectionSort(a, n):
    r = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if a[j].value < a[minj].value:
                minj = j
        a[i], a[minj] = a[minj], a[i]


def bubbleSort(a, n):
    flag = True
    while flag:
        flag = False
        for j in range(n - 1, 0, -1):
            if a[j].value < a[j - 1].value:
                a[j], a[j - 1] = a[j - 1], a[j]
                flag = True


def copycard(cards):
    r = []
    for c in cards:
        r.append(card(c.suit + str(c.value)))
    return r


def compareCard(c1,c2):
    for i in range(len(c1)):
        if c1[i].suit != c2[i].suit or c1[i].value != c2[i].value:
            return False
    return True


n = int(input())
cards = list(map(card, input().split()))
cards1 = copycard(cards)
cards2 = copycard(cards)
bubbleSort(cards1, n)
print(*cards1)
print("Stable")
selectionSort(cards2, n)
print(*cards2)
if compareCard(cards1,cards2):
    print("Stable")
else:
    print("Not stable")




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

mod = int(1e9 + 7)
ans = 0
for i in range(61):
    t = 0
    for a in A:
        if a >> i & 1:
            t += 1
    ans = (ans + pow(2, i, mod) * t * (n-t)) % mod
print(ans)

Measured memory_bytes: 122808
#include"bits/stdc++.h"

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;

using namespace std;

int main(void) {
	int N, A, B; cin >> N >> A >> B;
	string S; cin >> S;
	vector<bool> ans(S.length(), false);
	int a = 0, b = 0;

	for (int i = 0; i < S.length();i++) {
		switch (S[i]) {
		case'a':
			if (a + b < A + B) {
				a++;
				ans[i] = true;
			}
			break;
		case'b':
			if (a + b < A + B && b < B) {
				b++;
				ans[i] = true;
			}
			break;
		case'c':
			break;
		}
	}

	for (bool flag : ans) {
		cout << (flag ? "Yes" : "No") << endl;
	}

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(void){
    int c1,c5,c10,c50,c100,c500,c;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    
    c = c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;
    
    if(c >= 1000){
        cout << "1";
    }
    else{
        cout << "0";
    }
    cout << endl;
}


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++){
        cnt+=(n-1)/i;
    }
    cout<<cnt<<endl;
    //getchar();
    //getchar();
    return 0;
}

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

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

    int a,b;
    cin>>a>>b;
    if(a%k==0 or b%k==0 or(b/k>a/k))
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** Problem0227 : Thanksgiving **/
int main()
{
	int N, M;
	while (cin>>N>>M, N||M) {
		vector<int> v(N);
		rep(i, N) cin>>v[i];
		sort(v.begin(), v.end(), greater<int>());
		int ans=0;
		int t=1;
		rep(i, N) {
			if (t!=M) {
				t++;
				ans+=v[i];
			} else {
				t=1;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1216
# 整数の入力
n = gets.to_i

works = []

# スペース区切りの整数の入力
for num in 1..n
    b,c=gets.chomp.split(" ").map(&:to_i);
    works.push([b,c])
end

works.sort_by! {|x| [x[1],x[0]]}

time = 0
time_over = false
for work in works
    time += work[0]
    if time > work[1]
        time_over = true
        print("No")
        exit
    end
end
print("Yes")


Measured memory_bytes: 28432
#include<bits/stdc++.h>
    using namespace std;
    int dp[3001][3001];
    int lcs(string &s,string &t,int n,int m)
    {
    	if(n>=s.size()||m>=t.size())
    		{dp[n][m]=0;
    		return 0;}
    	if(dp[n][m]!=-1)
    		return dp[n][m];
    	int ans;
    	if(s[n]==t[m])
    	{
    		if(dp[n+1][m+1]==-1)
    			dp[n+1][m+1]=lcs(s,t,n+1,m+1);
    		ans=1+dp[n+1][m+1];
    	}
    	else
    	{
    		if(dp[n][m+1]==-1)
    			dp[n][m+1]=lcs(s,t,n,m+1);
    		if(dp[n+1][m]==-1)
    			dp[n+1][m]=lcs(s,t,n+1,m);
    		if(dp[n+1][m]>dp[n][m+1])
    			ans=dp[n+1][m];
    		else
    			ans=dp[n][m+1];
    	}
    	dp[n][m]=ans;
    	return ans;
    }
    int main()
    {
    	for(int i=0;i<3000;i++)
    		for(int j=0;j<=3000;j++)
    			dp[i][j]=-1;
    	string s,t;cin>>s>>t;
      	lcs(s,t,0,0);
      string str="";
      int i=0,j=0;
      while(i<s.size() && j<t.size())
      {
        if(s[i]==t[j])
        {
          str+=s[i];
          i++;
          j++;
        }
        else if(dp[i+1][j]>dp[i][j+1])
          i++;
        else
          j++;
      }
    	cout<<str<<endl;
    	return 0;
    }

Measured memory_bytes: 35840
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> vec[i];
	}
	for (int i = n - 1; i >= 1; --i)
	{
		cout << vec[i] << " ";
	}
	cout << vec[0] << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;

int main() 
{
    ll a,b,c = 0;
    cin >> a >> b;
    vector<ll>  han(a, 0);
    for(ll i = 0; i < b; i++) {
        ll t;   cin >> t;
        for(ll j = 0; j < t; j++) {
            ll s; cin >> s;
            han.at(s - 1) = 1;
        }
    }

    for(ll i = 0; i < a; i++) {
        c += han.at(i);
    }

    cout << a - c << endl;
}

Measured memory_bytes: 3632
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp*/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;

    while (cin>>n && n>0){
        vector<int> s;

        for (int i=0;i<n;i++){
            int tmp;

            cin>>tmp;
            s.push_back(tmp);
        }
        sort(s.begin(),s.end());
        cout<<accumulate(++s.begin(),--s.end(),0)/(n-2)<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string string_X = "";
    string string_Y = s;
    int biggest = 0;
    for (int i = 0; i < n; i++) {
        //remove first
        string_Y = string_Y.substr(1, string_Y.size() - 1);
        //add next
        string_X += s[i];
        //conv to sets
        set<char> set_x = set<char>(string_X.begin(), string_X.end());
        set<char> set_y = set<char>(string_Y.begin(), string_Y.end());
        int overlap = 0;
        for (auto i : set_x) {
            if (set_y.find(i) != set_y.end()) {
                overlap++;
            }
        }
        biggest = max(biggest, overlap);
    }
    cout << biggest;
}

Measured memory_bytes: 3668
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <stack>
#define maxn 100009
using namespace std;
int R, C, n;
vector<pair<int,int> >a, b, c, d;
vector<int> G;
bool vis[maxn];
string S;
bool onside(int x, int y){
	return x == 0 || x == R || y == 0 || y == C;
}
void add(int id, int x, int y){
	if(x == 0 && 0 <= y && y < C)
		a.push_back(make_pair(y, id));
	if(y == C && 0 <= x && x < R)
		b.push_back(make_pair(x, id));
	if(x == R && y <= C && y > 0)
		c.push_back(make_pair(-y, id));
	if(y == 0 && x <= R && x > 0)
		d.push_back(make_pair(-x, id));
}
stack<int>stk;
bool check(){
	for(auto x: G){
		if(!vis[x]){
			stk.push(x);
			vis[x] = 1;
		}
		else{
			if(stk.empty())
				return 0;
			if(stk.top() != x)
				return 0;
			stk.pop();
		}
	}
	return 1;
}
int main(){
	cin >> R >> C >> n;
	for(int i = 0; i < n; i++){
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		if(onside(x1, y1) && onside(x2, y2)){
			add(i, x1, y1);
			add(i, x2, y2);
			//cout << i << endl;
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	sort(d.begin(), d.end());
	for(auto x: a)
		G.push_back(x.second);
	for(auto x: b)
		G.push_back(x.second);
	for(auto x: c)
		G.push_back(x.second);
	for(auto x: d)
		G.push_back(x.second);
	if(check())
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 3796
use std::{cmp::{max, min}, collections::{BTreeMap, BTreeSet, VecDeque}};

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_lines<R, T: Fn(&str)->R> (count: usize, transformer: T) -> Vec<R> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(transformer(buffer.trim()));
    }
    vec
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_tabulate<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.parse().ok().expect("Can't Parse"));
    }
    vec
}
macro_rules! assign {
    () => {};
    ($($token:tt)*) => {
        let mut iter = read_values::<String>().into_iter();
        assign_iter!(iter, $($token)*);
    };
}
macro_rules! assign_iter {
    ($iter:expr) =>{};
    ($iter:expr,) =>{};
    ($iter:expr, $id:ident:$t:tt $($tail:tt)*) => {
        let $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*);
    };
    ($iter:expr, mut $id:ident:$t:tt $($tail:tt)*) => {
        let mut $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*)
    };
}
macro_rules! freeze {
    ($($id:ident), *) => {
        $(let $id = $id;)*
    };

}

fn main() {
    let str = read_line().trim().chars().collect::<Vec<_>>();
    if (str.first() != str.last()) ^ (str.len() & 1 == 0) {
        println!("First");
    }else {
        println!("Second");
    }
}


Measured memory_bytes: 2592
N,M = map(int,input().split(' '))
D = []
for i in [0]*N:
	a,b = map(int,input().split(' '))
	D.append([a,b])

D.sort(key = lambda x : x[0])

ans = 0
for c, s in D:
	if s < M:
		M -= s
		ans += c * s
	else:
		ans += M * c
		break
print(ans)
 


Measured memory_bytes: 21144
N=int(input())
K=int(input())
n=1 # 最初の整数

# N回繰り返す
for _ in range(N):
    if n<=K: # 2倍した方が小さい場合、2倍する
        n*=2
    else: # Kを足した方が小さい場合、Kを足す
        n+=K

print(n)

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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class C100To105 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int X;
	    in >> X;
	    if (X < 2100) {
	        REP(i,1,21) {
	            if (i * 100 <= X && X <= i * 105) {
	                out << 1 << "\n";
	                return;
	            }
	        }
	    } else {
	        out << 1 << "\n";
	        return;
	    }
        out << 0 << "\n";
	}
};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define int long long
typedef pair<int,int> pii;

const int mod = 1e9 + 7;
const int MOD = 998244353;
const int N = 5e5 + 5;


void solve(){
    int n , m; cin >> n >> m;
    vector<string> v(n);
    for(int i = 0 ;i <  n ;i++){
        cin >> v[i];
    } 
    int dp[n][m];
    memset(dp , 0, sizeof(dp));
    for(int j = m - 2 ; j >= 0 ; j--){
        if(v[n - 1][j] == '#'){
            break;
        }
        dp[n - 1][j] = 1;
    }
    for(int i = n - 2 ; i >= 0; i --){
        if(v[i][m - 1] == '#'){
            break;
        }
        dp[i][m - 1] = 1;
    }
    for(int i = n - 2 ; i >= 0 ; i--){
        for(int j = m - 2 ; j >= 0 ; j--){
            if(v[i][j] == '#') continue;
            if(i + 1 < n)
                dp[i][j] = (dp[i][j] + dp[i + 1][j])%mod;
            if(j + 1 < m)
                dp[i][j] = (dp[i][j] + dp[i][j + 1])%mod;
        }
    }
    cout << dp[0][0] << endl;

}

int32_t main(){
    // ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for(int T = 1 ; T <= t ; T++){
        // cout << "Case #" << T << ": " << endl;
        solve();
    }
}

Measured memory_bytes: 9088
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 入力文字の種類 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			System.out.println((N == IntStream.range(0, s.length).map(i -> s[i]).distinct().count()) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 36064
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
int n,k;
vector<int> a;
int dp[100010]; //石がx個残っている場合の勝ち負けを判断、0の場合負け

int main(){
 cin >> n >> k;
 a.resize(n);
 for(int i = 0; i < n; ++i)cin >> a[i];

 //dp[0] = 0; //残りの石が0個の場合負け

 for(int i = 0; i <= k; ++i){
   for(int j = 0; j < n; ++j){
     if(i - a[j] >= 0 && dp[i - a[j]] == 0){
       dp[i] = 1;
     }
   }
 }
 if(dp[k])cout << "First" << endl;
 else cout << "Second" << endl;
 return 0;
}

Measured memory_bytes: 640
n = int(input())
Ps =  list(map(int,input().split(" ")))
ans = 0
for i in range(0,n-2):
    a,b,c = Ps[i:i+3]
    temp = Ps[i:i+3]
    temp.sort()
    if temp[1] == b:
        ans += 1
print(ans)



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

int main() {
  int N;
  cin >> N;
  bool flag = true;
  for (int i = 0; i < 3; i++) {
    if (N % 10 == 7) {
      cout << "Yes" << endl;
      flag = false;
      break;
    } else {
      N /= 10;
    }
  }
  if (flag) {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector <int> a(3);
  for(int i=0;i<3;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  cout<<a.at(0)+a.at(1);
  
  
}


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

using namespace std;

template<int mod>
struct Ring_mod {
    int val;
    Ring_mod(): val(0) {}
    Ring_mod(long long x)
    {
        if (x < 0) x += mod;
        if (x >= mod) x -= mod;
        if (x >= mod) x %= mod;
        val = x;
    }
    explicit operator int() { return val; }
    Ring_mod operator+(const Ring_mod& b) { return Ring_mod(val + b.val); }
    Ring_mod operator-(const Ring_mod& b) { return Ring_mod(val - b.val); }
    void operator+=(const Ring_mod& b) { val = Ring_mod(val + b.val).val; }
    void operator-=(const Ring_mod& b) { val = Ring_mod(val - b.val).val; }
    Ring_mod operator*(const Ring_mod& b) { return Ring_mod((long) val * b.val); }
};

const int MOD = 1e9 + 7;
typedef Ring_mod<MOD> int_mod;

template<typename T>
struct Matrix {
    Matrix(int r, int c) : _r(r), _c(c), a(r * c) {}
    T* operator[](int r) { return r * _c + a.data(); }
    int _r, _c;
    vector<T> a;
};

int main()
{
    int h, w;
    cin >> h >> w;
    Matrix<char> grid(h, w);
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> grid[i][j];
    Matrix<int_mod> num_paths(h, w);

    auto f = [&](int i, int j) {
        if (i < 0 || j < 0 || grid[i][j] == '#') return int_mod(0);
        return num_paths[i][j];
    };
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
            if (i == 0 && j == 0) {
                num_paths[i][j] = 1;
                continue;
            }
            if (grid[i][j] != '#')
                num_paths[i][j] = f(i - 1, j) + f(i, j - 1);
        }
    cout << (int) num_paths[h - 1][w - 1];
    return 0;
}


Measured memory_bytes: 5120
#include <cstdio>
#include <vector>
using namespace std;

int x, n, NR = 0, NR2, h, ni, g, g2, ja, jb, aux[100005], List[100005], List2[100005];
bool f[100005];
vector <int> v[100005];
inline void dfs(int nod, int ad){
    if(nod == n) {
        h = ad - 1; g = ni;
        for(int i = 0; i < ad  ; ++i)
            List[i] = aux[i];
        return ;
    }
    ++NR;
    for(auto it : v[nod]){
        if(f[it] == 1) continue ;
        f[it] = 1;
        if(ad == 0) ni = it;
        aux[ad] = it;
        dfs(it, ad + 1);
        f[it] = 0;
    }
}
inline void dfs3(int nod){
    for(auto it : v[nod]){
        if(f[it] == 1) continue ;
        f[it] = 1; ++x;
        dfs3(it);
    }
}
int main(){
    scanf("%d", &n);
    for(int i = 1; i < n ; ++i){
        int x, y;
        scanf("%d%d", &x, &y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    f[1] = 1;
    dfs(1, 0);
    f[n] = 1;
    for(int i = 0; i < h ; ++i)
        List2[i] = List[h - i - 1];
    List2[h] = 1;
    int i1 = 0, i2 = 0;
    for(int i = 0; i < h ; ++i){
        if(i % 2 == 0){
            ++ja;
            f[List[i1]] = 1;
            for(auto it : v[List[i1]]){
                if(it == 1 || it == n || it == List[i1 + 1]) continue ;
                f[it] = 1;
                x = 1; dfs3(it); ja += x;
            }
            ++i1;
        }
        else{
            ++jb;
            f[List2[i2]] = 1;
            for(auto it : v[List2[i2]]){
                if(it == 1 || it == n || it == List2[i2 + 1]) continue ;
                f[it] = 1;
                x = 1; dfs3(it); jb += x;
            }
            ++i2;
        }

    }
    x = 0; dfs3(1); ja += x; x = 0;
    dfs3(n); jb += x;
    if(ja > jb) printf("Fennec");
    else printf("Snuke");
    return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;cin>>k;
    int n=50;
    ll a,b;
    a = k/n;
    b = k%n;
    cout<<n<<endl;
    REP(i,n) cout<<n-1+a-b+(i<b)*n<<" ";
    cout<<endl;
}


Measured memory_bytes: 256
W,a,b=map(int,input().split())
thre =0 
res =0
if a<=b:
  thre = a+W
  if thre >= b:
    res = 0
  else:
    res = b-thre
else:
  thre=b+W
  if thre >= a:
    res = 0
  else:
    res = a-thre
print(res)

Measured memory_bytes: 9068
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N, K;
int H[200010];

signed main()
{
	cin >> N >> K;
	REP(i, N) cin >> H[i];

	ARY_SORT(H, N);

	int sum = 0;
	for (int i = 0; i < N - K; i++)
	{
		sum += H[i];
	}
	cout << sum << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  bool ans[50] = {false};
  rep(i, s.size()){
    if(ans[(int)(s[i] - 'a')]){
      cout << "no\n";
      return 0;
    } else {
      ans[(int)(s[i] - 'a')] = true;
    }
  }
  cout << "yes\n";
  return 0;
}


Measured memory_bytes: 256
#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() {
    int a,b,c,x;
    cin >> a >> b >> c;
    x = a;
    a = b;
    b = x;

    x = a;
    a = c;
    c = x;
    
    cout << a << " " << b << " " << c << endl;

return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    string s,t;
    cin >> s >> t;
    vii dp(3100,vi(3100,0));


    for(int i=0;i<(int)s.size();i++){
        for(int j=0;j<(int)t.size();j++){
            if(s[i]==t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }

    //cout << dp[(int)s.size()][(int)t.size()] << endl;
    string ans = "";
    int i = (int)s.size();
    int j = (int)t.size();
    while(i>0 && j>0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }else if(dp[i][j] == dp[i][j-1]){
            j--;
        }else{
            ans = s[i-1] + ans;
            --i;--j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 37888
#include<stdio.h>
int main()
{
	int n,a[200001]={0},i,t;
	scanf("%d",&n);
	for(i=2;i<=n;i++)
	{
		scanf("%d",&t);
		a[t]++;
	} 
	for(i=1;i<=n;i++)
	{
		printf("%d\n",a[i]);
	}
	return 0;
}

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

using namespace std;

const int MX = 100 * 1000 + 7;

int add[MX];

bool check(const string &S, int k) {
    memset(add, 0, sizeof(add));
    string s(S);

    int mod = 0;
    long long sm = 0, smd = 0;
    int n = s.length();

    for (int i = 0; i < k; i++) {
        smd += add[i];
        sm += smd;
        int x = s[i] - '0';

        if ((x ^ mod) != 0) {
            if (i + k - 1 < n) {
                mod ^= 1;
                add[i + k]++;
            } else if (sm > 0) {
                mod ^= 1;
                sm--;
            } else {
                return false;
            }
        }
    }

    return true;
}

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

    int l = 1, r = s.length() + 1;

    while (r - l > 1) {
        int m = (l + r) >> 1;
        if (check(s, m)) {
            l = m;
        } else {
            r = m;
        }
    }

    cout << l << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;


int main() {

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

	if (a >= 10 || b  >= 10) {
		cout << -1;
	}
	else {
		cout << a*b;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  private static Scanner sc;

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


  private void solve() {
    int N = sc.nextInt();
    int ans = 0;
    for (int i = 0; i < N; i++) {
      ans += sc.nextInt() - 1;
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 27348
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int dx=x2-x1,dy=y2-y1;
    int x3,y3,x4,y4;
    x3=x2-dy;
    y3=y2+dx;
    x4=x1-dy;
    y4=y1+dx;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int t;
    cin >> t;
    rep(_, t) {
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        string s;
        cin >> s;

        set<int> dp;
        bool ok = true;
        repd(i, n) {
            int val = a[i];
            itrepd(it, dp) mins(val, val ^ *it);
            if (s[i] == '0') {
                if (val != 0) dp.emplace(val);
            } else {
                if (val != 0) {
                    ok = false;
                    break;
                }
            }
        }

        cout << (ok ? 0 : 1) << '\n';
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

void dfs(string cur, ll m, ll rest){
  if (rest==0){
    cout << cur << "\n";
  }  else {
    REP(i,m+1){
      char next = 'a' + i;
      dfs(cur+next, max(i+1,m), rest-1);
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  dfs("", 0, N);
  return 0;
}


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

int main() {
  int N, Y;
  cin >> N >> Y;
  bool is_found = false;
  for (int i=0; i<=N; i++) {
    for (int j=0; j<=N-i; j++) {
      int k = N - i - j;
      if (10000 * i + 5000 * j + 1000 * k == Y) {
        cout << i << ' ' << j << ' ' << k << endl;
        is_found = true;
        break;
      }
    }
    if (is_found) break;
  }
  if (!is_found) cout << "-1 -1 -1" << endl;
}

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

const ULL M = 1000000007;

ULL powm(ULL a, ULL i) {
    if (!i) return 1;
    if (i & 1) return powm(a * a % M, i >> 1) * a % M;
    return powm(a * a % M, i >> 1);
}

ULL F[10001], I[10001], iF[10001];

ULL C(ULL n, ULL r) { return F[n] * iF[r] % M * iF[n - r] % M; }
ULL P(ULL n, ULL r) { return F[n] * iF[n - r] % M; }
ULL H(ULL n, ULL r) { return C(r + n - 1, n - 1); }

struct Problem {

    void Solve() {
        F[0] = 1; for (UL i = 1; i <= 10000; i++) F[i] = F[i - 1] * i % M;
        I[1] = 1; for (UL i = 2; i <= 10000; i++) I[i] = M - M / i * I[M % i] % M;
        iF[0] = 1; for (UL i = 1; i <= 10000; i++) iF[i] = iF[i - 1] * I[i] % M;
        ULL N, K; cin >> N >> K;
        if (N > K) cout << 0 << endl;
        else cout << 1 << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}



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

int N,M;
int D[100010] = {0};

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        D[a]++;
        D[b]++;
    }
    for(int i = 1; i < M + 1; i++)
    {
        if(D[i] % 2)
        {
            printf("NO\n");
            break;
        }
        if(i == M)
        {
            printf("YES\n");
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	int ul = 200001;
	int primes[ul];
	for(int i = 2; i < ul; i++){
		primes[i] = 1;
	}
	for(int i = 2; i < ul; i++){
		if (primes[i] == 1){
			int fact = 2;

			while(fact*i < ul){
				primes[fact*i] = 0;
				fact++;
			}
		}
	}
	int odds[ul];
	for(int i = 2; i < ul; i++){
		odds[i] = 0;
	}
	for(int i = 3; i < ul; i+=2){
		if (primes[i] != 1) continue;
		if (primes[(i+1)/2] == 1) odds[i] =1;
	}

	int q;
	cin>>q;
	vector<int> l,r;
	l.resize(q);
	r.resize(q);
	int maxr;
	maxr = -1;
	for(int i = 0; i < q; i++){
		cin>>l[i]>>r[i];
		maxr = max(r[i], maxr);
	}
	int prefsum[maxr + 1];
	prefsum[0] = 0;
	prefsum[1] = 0;
	prefsum[2] = 0;
	for(int i = 3; i < maxr + 1; i++){
		if(odds[i] == 1) prefsum[i] = prefsum[i - 1] + 1;
		else prefsum[i] = prefsum[i - 1];
	}
	for(int i = 0; i < q; i++){
		cout<<prefsum[r[i]] - prefsum[l[i] - 1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
char a[110];
int main()
{
	gets(a);
	int ans=0,s;
	for(int i=0;i<sizeof(a);++i)
	 {
	 	if(a[i]=='C')
	 	{
	 		for(int j=i;j<sizeof(a);++j)
			  if(a[j]=='F')
			  ans++; 	
		}
	 } 
	if(ans!=0)
	 cout<<"Yes";
	else
	 cout<<"No";
	return 0;
}

Measured memory_bytes: 256
//
//  Created by TaoSama on 2016-09-24
//  Copyright (c) 2016 TaoSama. All rights reserved.
//
#pragma comment(linker, "/STACK:102400000,102400000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int n, a[N];

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);


    while(cin >> n) {
        for(int i = 1; i <= n; ++i) cin >> a[i];
        int ans = 0;
        for(int i = 1; i <= n; ++i) {
            if(a[a[i]] == i) ++ans;
        }
        cout << ans / 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 640
class FUnionFind
  attr_reader :nodes, :parents, :ranks

  def initialize(n)
    @parents = (0...n).to_a
    @nodes = @parents.map{ |x| [x] }
  end

  def find(i)
    @parents[i]
  end

  def union(i,j)
    i = @parents[i]; j = @parents[j]
    return if i == j
    j,i = i,j if @nodes[i].size < @nodes[j].size
    #p [i,j,@nodes[i],@nodes[j]]
    #p [i,j,@nodes[i].size,@nodes[j].size]
    @nodes[j].each{ |k| @parents[k] = i }
    @nodes[i].concat(@nodes[j])
    @nodes[j].clear
  end

  def setsize(i)
    @nodes[find(i)].size
  end
end

N = gets.to_i
Towns = (0...N).map{ |i| [i, *gets.split.map(&:to_i)] }
Edges = []
Towns.sort_by!{ |i,x,y| x }
(0...N-1).each{ |k|
  t1 = Towns[k]; t2 = Towns[k+1]
  Edges << [t1[0], t2[0], t2[1]-t1[1]]
}
Towns.sort_by!{ |i,x,y| y }
(0...N-1).each{ |k|
  t1 = Towns[k]; t2 = Towns[k+1]
  Edges << [t1[0], t2[0], t2[2]-t1[2]]
}
Edges.sort_by!{ |u,v,cost| cost }
uf = FUnionFind.new(N)
ans = 0
Edges.each{ |u,v,cost|
  if uf.find(u) != uf.find(v)
    ans += cost
    uf.union(u,v)
  end
}
p ans


Measured memory_bytes: 30724
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 10000;/// 1e9 + 7;
const long long INF = 1e9;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, D;
	cin >> N >> D;
	int ans = 0;
	for (int n = 0; n < N; n++) {
		LL x, y;
		cin >> x >> y;
		if (x * x + y * y <= D * D)ans++;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3164
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, h = list(map(int, input().rstrip('\n').split()))
    md = 0
    dl = []
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        md = max(md, a)
        dl.append(b)
    dl.sort(reverse=True)
    cnt = 0
    for v in dl:
        if v > md:
            h -= min(h, v)
            cnt += 1
            if h == 0:
                print(cnt)
                exit()
        else:
            break
    cnt += (h + md - 1) // md
    print(cnt)
    exit()


if __name__ == '__main__':
    solve()


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n, m;
  string s, t;
  map<string, int> map;

  cin >> n;
  re(i, n) {
    cin >> s;
    map[s]++;
  }
  cin >> m;
  re(i, m) {
    cin >> t;
    map[t]--;
  }

  int x = 0;
  for(auto m : map) {
    x = max(x, m.second);
  }
  cout << x << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static final int MOD = 1_000_000_007;

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

        int N = sc.nextInt();
        int L = sc.nextInt();

        int sum = 0;
        int[] apples = new int[N];
        for (int i = 0; i < N; i++) {
            apples[i] = L + i;
            sum += apples[i];
        }

        Arrays.sort(apples);

        int min = Integer.MAX_VALUE;
        int index = 0;
        for (int i = 0; i < N; i++) {
            int abs = Math.abs(apples[i]);

            if (min > abs) {
                min = abs;
                index = i;
            } else {
                break;
            }
        }

        System.out.println(sum - apples[index]);
    }

}


Measured memory_bytes: 23892
<?php
/**
 * Created by PhpStorm.
 * User: wahho
 * Date: 2016/08/28
 * Time: 20:56
 */
fscanf(STDIN, "%d", $in_n);
fscanf(STDIN, "%d", $in_k);
fscanf(STDIN, "%d", $in_x);
fscanf(STDIN, "%d", $in_y);

$ans_l = 0;
$ans_k = $in_k;
if($in_n > $in_k){
    $ans_l = $in_n - $in_k;
}else{
    $ans_k = $in_n;
}

$ans_sum = ($in_x * $ans_k)+($in_y * $ans_l);

echo "$ans_sum\n";
?>

Measured memory_bytes: 2812
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int main(void) {
	string s1("AIDUNYAN"), s2("AIZUNYAN");
	string D;
	cin >> D;

	for (int i = 0; i < (int)(D.size() - s1.size() + 1); i++) {
		sort(s1.begin(), s1.end());
		do {
			if (equal(s1.begin(), s1.end(), D.substr(i, s1.size()).begin())) {
				D.replace(i, s2.size(), s2);
				i += s2.size() - 1;
				break;
			}
		} while (next_permutation(s1.begin(), s1.end()));
	}

	cout << D << endl;

	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long int;

ll MOD;
const int MAXN = 3010;
ll comb[MAXN + 10][MAXN + 10];

ll mod_pow(ll N, ll K, ll mod=MOD) {
    ll ret = 1; N %= mod;
    for(; K>0; K>>=1) {
        if(K & 1) (ret *= N) %= mod;
        (N *= N) %= mod;
    }
    return ret;
}

void init() {
    for(int i=0; i<MAXN; i++) {
        comb[i][0] = 1;
        for(int j=1; j<MAXN; j++) {
            comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % MOD;
        }
    }
}

ll dp[3010][3010], ways[3010], ans;
int main() {
    int N; cin >> N >> MOD; init();// MOD はグローバル
    // dp (ways2 を求める)
    dp[0][0] = 1;
    for(int i=1; i<=N; i++) for(int j=0; j<=i; j++) {
        if(j > 0) (dp[i][j] += dp[i-1][j-1]) %= MOD;
        (dp[i][j] += dp[i-1][j] * (j+1)) %= MOD;
    }
    // ways1 を求め、答えに足す
    for(int i=0; i<=N; i++) {
        for(int j=0; j<=i; j++) {
            (ways[i] += dp[i][j] * mod_pow(2, (N-i)*j)) %= MOD;
        }
        (ways[i] *= mod_pow(2, mod_pow(2, N-i, MOD-1))) %= MOD;
        ll val = ways[i] * comb[N][i] % MOD;
        if(i % 2 == 0) ans = (ans + val      ) % MOD;
        else           ans = (ans - val + MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 140416
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(fabs(a-b)<=d&&fabs(b-c)<=d)
	{
		cout<<"Yes"<<endl;
		return 0;
	}	
	if(fabs(a-c)<=d)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N,K;
	cin >> N >> K;
	int res = 1;
	for (int i = 0; i < N; ++i)
	{
		if(res * 2 > res + K){
			res += K;
		}else{
			res *= 2;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256