akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  
  vector<int> cont(N);
  map<int , int> mmm;
  
  for(int i = 0 ; i < N ; i++){
    int a;
    cin >> a;
    cont.at(i) = a;
    
    if(mmm.count(a)){
      
      mmm[a]++;
      
    }else{
      mmm[a] = 1;
    }
  }
  
  vector<int> cont_X = cont;
  
  sort(cont.begin() , cont.end() );
  reverse(cont.begin() , cont.end());
  
  
  for(int i = 0 ; i < N ; i++){
    
    if(mmm[cont_X.at(i)] > 1){
      
      cout << cont.at(0) << endl;
    }else{
      
      if(cont_X.at(i) == cont.at(0)){
        
        cout << cont.at(1) << endl;
        
      }else{
        
        cout << cont.at(0) << endl;
      }
      
    }
  }
}
      
    
    

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,d,a;cin >> n >> d >> a;
    vector<P> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;

    sort(p.begin(),p.end());
    ll tot = 0;
    queue<pair<ll,ll>> q;
    ll ans = 0;
    rep(i,n){
        ll x = p[i].first;
        ll h = p[i].second;
        while(q.size() && q.front().first < x){
            tot -= q.front().second;
            q.pop();
        }

        h -= tot;
        if(h>0){
            ll num = dup(h, a);
            ans += num;
            ll damage = num * a;
            tot += damage;
            q.emplace(x+2*d, damage);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n+1))
        self.rank = [0] * (n+1)
        self.size = [1]*(n+1)

    # 検索
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        else:
            if self.size[x] < self.size[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def cnt(self, x):
        # サイズの取得
        return self.size[self.find(x)]


n, m, k = list(map(int, input().split()))

union_find = UnionFind(n)
num_friends = [0]*(n+1)
num_block = [0]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    num_friends[a] += 1
    num_friends[b] += 1
    union_find.union(a, b)
# cd = [[_c, _d] for (_c, _d) in map(int, input().split())]
for i in range(k):
    # c[i], d[i] = map(int, input().split())
    c, d = map(int, input().split())
    if union_find.same_check(c, d):
        num_block[c] += 1
        num_block[d] += 1


num_suggest_friend = [0]*(n+1)  # 自分自身を引いておくので-1で初期化

for i in range(1, n+1):
    num_suggest_friend[i] = union_find.cnt(i) - \
        num_friends[i] - num_block[i] - 1

print(*num_suggest_friend[1:], sep=' ')


Measured memory_bytes: 16560
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

eat = p[:x] + q[:y] + r
eat.sort(reverse=True)
ans = eat[:x+y]

print(sum(ans))

Measured memory_bytes: 112236
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void start()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
    //   freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE
}
int32_t main()
{
	start();
    int n; cin >> n;
    string ch; cin >> ch;
    int ctR = 0, ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(ch[i] == 'R')ctR++;
    }
    for(int i = 0; i < ctR; i++)
    {
        if(ch[i] == 'W')ans++;
    }
    cout << ans << endl;
	return 0;
}


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

using namespace std;

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

//constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

class Add_Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	long long int ret;
	int num;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		v[place] = Update(place * 2) + Update(place * 2 + 1);
		return v[place];
	}
	void Sum(int a, int b, int place) {
		if (l[place] >= a&&r[place] <= b) {
			ret += v[place];
			return;
		}
		if (l[place] > b || r[place] < a) return;
		Sum(a, b, place * 2);
		Sum(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Add_Segment_Tree(int n) {
		n++;
		num = 1;
		while (num < n * 2)num *= 2;
		l.resize(num);
		r.resize(num);
		v.resize(num, 0);
		Left(1);
		Right(1);
	}
	void Add(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] += num;
		if (!update)return;
		place /= 2;
		while (place) {
			v[place] = v[place * 2] + v[place * 2 + 1];
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int Sum(int a, int b) {
		ret = 0;
		Sum(a, b, 1);
		return ret;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>K;
	vector<int>v(N);
	for(auto &i:v)cin>>i;
	long long int box=0;
	Add_Segment_Tree asg(N+1);
	for(int i=0;i<N;i++){
		box+=asg.Sum(v[i],N);
		asg.Add(v[i],1,true);
	}
	if(box%2&&K%2){
		cout<<"No\n";
		return 0;
	}
	if(N==K){
		for(int i=0;i<N;i++){
			if((v[i]+1)%N!=(v[(i+1)%N])%N){
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}


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

int main() {
  int A,B;
  cin >>A >>B;
  if(A+B>A-B){
    if(A+B>A*B){
      cout <<A+B <<endl;
    }
    else{
      cout <<A*B <<endl;
    }
  }
  else{
    if(A-B>A*B){
      cout <<A-B <<endl;
    }
    else{
      cout <<A*B <<endl;
    }
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

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

  for(int i=N;i>=0;i--){
    for(int j=N-i;j>=0;j--){
      for(int k=N-i-j;k>=0;k--){
	if(i+k+j!=N)continue;
	if(i*10000+j*5000+k*1000==Y){
	  cout<<i<<" "<<j<<" "<<k<<endl;
	  return 0;
	}
      }
    }
  }
  printf("-1 -1 -1\n");


  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 REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
}

Measured memory_bytes: 256
mo=10**9+7
h,w=map(int,input().split())
m=[[0]*(w+2) for i in range(h+2)]
for i in range(h):
    for (j,s) in enumerate(input()):
        m[i+1][j+1]=0 if s=='#' else 1

for i in range(1,h+1):
    for j in range(1,w+1):
        if i*j==1:
            0
        elif m[i][j]!=0:
            m[i][j]=m[i-1][j]+m[i][j-1]
            m[i][j]%=mo
        
print(m[h][w]%mo)

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

#include <bits/stdc++.h>

using namespace std;

class sh18_c {
public:
    void solve(istream& in, ostream& out) {
        long long n, m, d;
        in >> n >> m >> d;
        double res = 0;
        for (int i = 1; i <= n; ++i) {
            res += (i - d >= 1) + (d && (i + d <= n));
        }
        res *= m - 1;
        res /= n * (n);
        out.precision(17);
        out << fixed << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	sh18_c 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 rep(i,n) for(int i=0;i<(int)(n);++i)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ALL(a) (a).begin(),(a).end()
#define F first
#define S second
typedef pair<int,int> PI;

int main(){
  
  vector<pair<int,PI> > in;
  
  rep(i,150)rep(j,150){
    int h=i+1;
    int w=j+1;
    if(w > h)
      in.pb(mp(h*h+w*w,mp(h,w)));
  }

  sort(ALL(in));
  
  int h,w;
  while(cin >> h >> w && h){
    vector<pair<int,PI> >::iterator p=upper_bound(ALL(in),mp(h*h+w*w,mp(h,w)));
    cout << p->S.F << " " << p->S.S << endl;
  }
}

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



int main(){
    double l;
    cin>>l;
    double a=l/3;
    cout<<fixed<<setprecision(10)<<a*a*a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a;
    cin >> a ;
    
    /*
    if(a < b){
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
    */
    
    cout << a * 800 - a / 15 * 200 << endl;

    return 0; 
}


Measured memory_bytes: 3600
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    a[i] *= -1

heapq.heapify(a)

for i in range(m):
    ref = heapq.heappop(a)*-1
    ref //= 2
    heapq.heappush(a, -ref)

print(sum(a)*-1)

Measured memory_bytes: 20548
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [(usize, usize); n]
    }
    let sum = v.iter().map(|&x| x.0).sum();
    let mut d = sum;
    for &(a, b) in &v {
        if a > b {
            d = min(d, b);
        }
    }
    println!("{}", sum - d);
}


Measured memory_bytes: 4476
import sys

input = sys.stdin.readline

def main():
    a,b = map(int, input().split())
    s = []
    for i in range(a):
        temp = list(map(int, input().split()))
        s.append(temp)
    for i in range(a):
        temp_sum = sum(s[i])
        s[i].extend([temp_sum])
        print(*s[i])
    last = []
    temp_sum = 0
    for i in range(b+1):
        temp_sum = 0
        for k in range(a):
            temp_sum += s[k][i]
        last.append(temp_sum)
    print(*last)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 6248
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a;
  cin>>a;
    string d="es",e="s";
 int b=a.size();
  char c=a.at(b-1);
  if(c=='s')
    cout<<a+d;
  else
    cout<<a+e;
  
 return 0;
}


Measured memory_bytes: 3040
def int
  gets.to_i
end

def ints
  gets.split.map(&:to_i)
end

N = int
A = int
B = int
C = int
D = int
E = int

cap = [A, B, C, D, E]

min_cap = cap.min

puts 5 + (N.to_f / min_cap).ceil - 1


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

class Rolling_Hash {// ローリングハッシュ
public:
	Rolling_Hash() {
		v.clear();
	}
	void process(const ll* str, int n, int width) {// 文字列と、全長と、切り出す長さを指定
		if (width > n) { return; }
		v.resize(n - width + 1);
		ll p1 = 0, p2 = 0;
		ll t1 = 1, t2 = 1;
		{
			ll k = width;
			ll d1 = digit1;
			ll d2 = digit2;
			while (k > 0) {
				if (k & 1) {
					t1 *= d1;
					t1 %= mod1;
					t2 *= d2;
					t2 %= mod2;
				}
				k /= 2;
				d1 = (d1 * d1) % mod1;
				d2 = (d2 * d2) % mod2;
			}
		}
		for (int i = 0; i < width; i++) {
			p1 *= digit1; p1 += str[i]; p1 %= mod1;
			p2 *= digit2; p2 += str[i]; p2 %= mod2;
		}
		int j = 0;
		v[j] = (p1 << 30) + p2; j++;
		for (int i = width; i < n; i++, j++) {
			p1 *= digit1; p1 += str[i] - str[i - width] * t1; p1 %= mod1;
			p2 *= digit2; p2 += str[i] - str[i - width] * t2; p2 %= mod2;
			if (p1 < 0) { p1 += mod1; }
			if (p2 < 0) { p2 += mod2; }
			v[j] = (p1 << 30) + p2;
		}
	}

private:
	const ll digit1 = 10007LL;
	const ll digit2 = 10009LL;
	const ll mod1 = 1000000007LL;
	const ll mod2 = 1000000009LL;

public:
	vector<ll> v;
};

int main() {
	int N; cin >> N;
	vector<ll> A0(N), B0(N), A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A0[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B0[i];
	}
	for (int i = 0; i < N; i++) {
		A[i] = A0[(i + 1) % N] ^ A0[i];
	}
	for (int i = 0; i < N; i++) {
		B[i] = B0[(i + 1) % N] ^ B0[i];
	}
	for (int i = 0; i < N - 1; i++) {
		A.push_back(A[i]);
	}

	Rolling_Hash Ra, Rb;
	Ra.process(A.data(), A.size(), N);
	Rb.process(B.data(), B.size(), N);
	for (int i = 0; i < N; i++) {
		if (Ra.v[i] == Rb.v[0]) {
			cout << i << " " << (A0[i] ^ B0[0]) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 12772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    map<string, int> mp;
    rep(i,n)
    {
        string tmps;
        cin >> tmps;
        if (mp[tmps]==0)
        {
            mp[tmps] = 1;
        }
        else
        {
            mp[tmps]++;
        }
    }

    int n_max = 0;
    for (auto itr=mp.begin();itr!=mp.end();++itr)
    {
        n_max = max(n_max, itr->second);
    }

    vector<string> ans;
    for (auto itr=mp.begin();itr!=mp.end();++itr)
    {
        if (n_max == itr->second)
        {
            ans.push_back(itr->first);
        }
    }

    sort(ans.begin(), ans.end());
    for (auto itr=ans.begin();itr!=ans.end();++itr)
    {
        cout << *itr << endl;
    }
    
    
    
}




Measured memory_bytes: 25584
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  string s1,s2;
  int t=0,h=0;
  
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    //compare用来比较前后两个字符串的大小，相等时等于0，前者大时大于0
    if(s1.compare(s2)==0) {
      t++;h++;
    }else if(s1.compare(s2)>0) t+=3;
    else h+=3;
  }
  cout << t << " " << h << endl;
}


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

int left(int i){ return 2*i; }
int right(int i){ return 2*i+1; }
int parent(int i){ return i/2; }

int main(){
   int H;
   int heap[251];
   cin >> H;
   for(int i=1; i<H+1; i++){
      cin >> heap[i];
   }
   for(int i=1; i<H+1; i++){
      cout << "node " << i << ": ";
      cout << "key = " << heap[i] << ", ";
      if(parent(i)) cout << "parent key = " << heap[parent(i)] << ", ";
      if(left(i)<=H) cout << "left key = " << heap[left(i)] << ", ";
      if(right(i)<=H) cout << "right key = " << heap[right(i)] << ", ";
      cout << endl;
   }
}


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

using namespace std;

const int inf{ int(1e9) };

int main() {
	int N, T;
	cin >> N >> T;
	vector<int> c(N), t(N);
	int MAX = 1 << 30;
	int ans = MAX;

	for (int i = 0; i < N; i++) {
		cin >> c[i] >> t[i];
		if (t[i] <= T) {
			ans = min(ans, c[i]);
		}
	}
	if (ans < MAX) {
		cout << ans << endl;
	}
	else {
		cout << "TLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n=int(input())
points = []
for _ in range(n):
  k =[int(i) for i in input().split()]
  points.append(k)
#print(points)

total=0

for i in range(n):
  for j in range(i+1,n,1):
    x =(points[i][0]-points[j][0])**2
    y =(points[i][1]-points[j][1])**2
    total += (x+y)**(1/2)
    #print(i,j)
#print(total/7641.9817824387)
ave=total*2/n
print(ave)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
using namespace std;

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

ll f=0;

for(ll i=0;i<s.size();i+=2){
if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
f=1;
}

for(ll i=1;i<s.size();i+=2){
if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')
f=1;
}

if(f==0){
  cout<<"Yes"<<endl;
}
else{
  cout<<"No"<<endl;
}

return 0;

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


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

Measured memory_bytes: 512
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG2
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N;
	cin >> N;

	vector<int> A(N), B(N), C(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) cin >> C[i];

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	vector<lint> memo(N + 1);
	for (int i = 0; i < N; i++) memo[i] = N - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
	for (int i = N - 1; i >= 1; i--) memo[i - 1] += memo[i];

	lint ans = 0;
	for (int i = 0; i < N; i++) ans += memo[(upper_bound(B.begin(), B.end(), A[i]) - B.begin())];

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A=sc.nextLong(),B=sc.nextLong(),X=sc.nextLong();
		long a;
		if(X>=B) {
			a=B-1;
		}else {
			a=X;
		}
		long ans= (A*a)/B -A*(a/B);
		System.out.println(ans);
	}

}

Measured memory_bytes: 35752
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 2005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

vector<int> adj[N];
int ans[N];

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, x, y; cin>>n>>x>>y;
    memset(ans, 0, sizeof(ans));
    for(int i=1; i<n; i++){
        adj[i].pb(i+1);adj[i+1].pb(i);
    }
    adj[x].pb(y);
    adj[y].pb(x);
    for(int i=1; i<=n; i++){
        bool vis[n+1];
        memset(vis, false, sizeof(vis));
        queue<pii> q;
        q.push({i, 0});
        vis[i]=true;
        while(!q.empty()){
            pii p = q.front();
            q.pop();
            int d = p.S;
            int u = p.F;
            ans[d]++;
            for(int v: adj[u]){
                if(!vis[v]){
                    vis[v]=true;
                    q.push({v, d+1});
                }
            }
        }
    }
    for(int i=1; i<=n-1; i++){
        cout<<ans[i]/2<<"\n";
    }
    return 0;
}






Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>

using namespace std;

const long long kModulo = 998244353LL;

long long solve1(vector<int> &a)
{
  int N = a.size();
  long long num = 1;
  for (int i = 0; i < N; ++i) {
    num *= 3;
    num %= kModulo;
  }
  return num;
}

long long solve23(vector<int> &a, int mode)
{
  int N = a.size();
  int M = *max_element(a.begin(), a.end()) * N + 1;
  vector<long long> v(M, 0);
  v[0] = 1;
  for (int i = 0; i < N; ++i) {
    vector<long long> tmp(M, 0);
    for (int j = 0; j < M; ++j) {
      if (v[j] == 0) continue;
      tmp[j + a[i]] += v[j];
      tmp[j + a[i]] %= kModulo;
      if (mode == 2) {
	tmp[j] += 2 * v[j];
      }
      else {  // mode = 3
	tmp[j] += v[j];
      }
      tmp[j] %= kModulo;
    }
    v = tmp;
  }
  int S = accumulate(a.begin(), a.end(), 0);
  if (mode == 2) {
    int begin = S / 2;
    if (S % 2 != 0) begin += 1;
    long long ans = 0;
    for (int i = begin; i < M; ++i) {
      ans += v[i];
      ans %= kModulo;
    }
    return ans;
  }
  else {  // mode = 3
    if (S % 2 != 0) {
      return 0;
    }
    else {
      return v[S / 2];
    }
  }
}

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }

  long long num1 = solve1(a);
  long long num2 = solve23(a, 2);
  long long num3 = solve23(a, 3);
  long long ans = (num1 - 3LL * num2 + 3LL * num3) % kModulo;
  if (ans < 0) ans += kModulo;
  cout << ans << endl;
  
  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    for(int i=0; i<s.size()+1; i++){
        for(int j=i; j<s.size()+1; j++){
            string t = s.substr(0,i) + s.substr(j);
            // cout << t << endl;
            if(t == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll a,b;
	cin>>a>>b;
	if(a>b)swap(a,b);
	if(b==1)cout<<1<<endl;
	else if(a==1)cout<<b-2<<endl;
	else cout<<(a-2)*(b-2)<<endl;
}






Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);

    long ans;
    foreach (i ; 1 .. N + 1) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 2696
import math
a, b, x = map(int, input().split())
x/=a

if(x <= a*b/2):
    print(90-math.degrees(math.acos(b/math.sqrt((x/b*2)**2+b**2))))
else:
    print(math.degrees(math.acos(a/math.sqrt(((a*b-x)/a*2)**2+a**2))))
    

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if(A1+A2+A3 <=21) cout << "win" << endl;
    else cout << "bust" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

vector<vector<pair<ll, ll>>> net;
vector<ll> dist;

void dfs(ll cur, ll d){
    dist.at(cur) = d;
    for(auto p : net.at(cur)){
        if(dist.at(p.first) != -1){ continue; }
        dfs(p.first, d + p.second);
    }
}

int main(){
    ll n;
    cin >> n;
    net.resize(n);
    for(int i = 0; i < n - 1; ++i){
        ll ai, bi, ci;
        cin >> ai >> bi >> ci;
        ai--; bi--;
        net.at(ai).push_back(make_pair(bi, ci));
        net.at(bi).push_back(make_pair(ai, ci));
    }

    ll q, k;
    cin >> q >> k;
    k--;

    dist.resize(n, -1);
    dfs(k, 0);

    vector<ll> ans(q);
    for(int i = 0; i < q; ++i){
        ll xi, yi;
        cin >> xi >> yi;
        xi--; yi--;
        ans.at(i) = dist.at(xi) + dist.at(yi);
    }

    for(int i = 0; i < q; ++i){
        cout << ans.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}


int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	foreach(i,l)cin>>i;
	cout << min_element(all(l))-l.begin()+1 << endl;
}



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

int main(){
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    vector<int> left(k), right(k);
    int count = 0;
    for(int i=0; i<n; i++){
        if(s[i] == 'o'){
            left[count] = i + 1;
            count += 1;
            i += c;
            if(count == k) break;
        }
    }
    count = k-1;
    for(int i=n-1; i>=0; i--){
        if(s[i] == 'o'){
            right[count] = i + 1;
            count -= 1;
            i -= c;
            if(count == -1) break;
        }
    }
    /*
    for(int i=0; i<k; i++) cout << left[i] << " ";
    cout << endl;
    for(int i=0; i<k; i++) cout << right[i] << " ";
    cout << endl;
    */
    for(int i=0; i<k; i++){
        if(left[i] == right[i]) cout << left[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5124
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

x = inp()
for i in range(10**3):
    for j in range(-2000,2000):
        if pow(i,5) - pow(j,5) == x:
            print(i,j)
            quit()

Measured memory_bytes: 72912
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define se second
#define fi first
#define ss size()
#define pb push_back
#define mp make_pair
#define ins insert
#define ll long long
#define y1 y12313312312
#define endl '\n'
#define gcd __gcd
//#define int ll

using namespace std;
//using namespace __gnu_pbds;

//template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e3 + 40, T = 4 * N, inf = 1e9 + 7;

int n, m, f, r, l, e, w, o, z, test, id, x, y;
int d[N][N], mx;
string s1, s2, s;

void freop()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

void boos()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

main()
{
    //freop();
    boos();
    cin >> s1 >> s2;
    for (int i = 0; i < s1.ss; i++)
    {
        for (int j = 0; j < s2.ss; j++)
        {
            if (i == 0 && j == 0)
            {
                if (s1[i] == s2[j]) d[i][j] = 1;
                continue;
            }
            if (s1[i] == s2[j])
            {
                if (!i || !j) d[i][j] = 1;
                else d[i][j] = d[i - 1][j - 1] + 1;
                if (mx < d[i][j])
                {
                    x = i;
                    y = j;
                    mx = d[i][j];
                }
                continue;
            }
            if (!i)
            {
                d[i][j] = d[i][j - 1];
            }
            else if (!j) d[i][j] = d[i - 1][j];
            else
            {
                d[i][j] = max(d[i - 1][j], d[i][j - 1]);
            }
            if (mx < d[i][j])
            {
                x = i;
                y = j;
                mx = d[i][j];
            }
        }
    }
    if (s1[x] == s2[y])
    {
        s = s1[x] + s;
        mx--;
    }
    for (int i = x - 1; i >= 0; i--)
    {
        for (int j = y - 1; j >= 0; j--)
        {
            if (s1[i] == s2[j] && d[i][j] == mx)
            {
                s = s1[i] + s;
                x = i;
                y = j;
                mx--;
                break;
            }
        }
    }
    cout << s;
}
/*


   i
sasdaf
 j
asdfab


d[i][j] =
? s[i] == s[j]
    max(d[0...i - 1][0...j-1])

max(d[i][j - 1], d[i - 1][j]);

*/





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

int main() {
  int X, Y; cin >> X >> Y;
  bool ans = false;
  for (int i = 0; i <= X; i++) {
    if (2 * i + 4 * (X - i) == Y) ans = true;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++){
		if (s[i] + n > 'Z'){
			s[i] = 'A' + (s[i] + n - 'Z'-1);
		}
		else s[i] += n;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int l=s.length();
	int t=0;
	while(s[t]!='A') t++;
	int end=l-1;
	while(s[end]!='Z') end--;
	cout<<end-t+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N, L;
ll a[100000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>L;
    rep(i,0,N){
        cin>>a[i];
        if(i&&a[i]+a[i-1]>=L){
            cout <<"Possible"<<"\n";
            rep(j,1,i) cout <<j<<"\n";
            rer(j,N,i+1) cout <<j<<"\n";
            cout <<i<<"\n";
            return 0;
        }
    }
    cout <<"Impossible"<<"\n";
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    ll ans = 0, n;
    cin >> n;
    ll a[n];
    forn(i, 0, n){
        cin>>a[i];
        if(i%2==0 && a[i]%2==1){
            ans++;
        }
    } 
    cout<<ans<<endl;
}

Measured memory_bytes: 3440
def is_even(num):
    return num % 2 == 0
def goback(M, x, Sx):
    k = M // 2
    if M == 0:
        return L - x[0]
    elif M == 1:
        return 2 * (L - x[1]) + x[0]
    elif is_even(M):
        return 2 * Sx[k - 1] - 2 * (Sx[M] - Sx[M - k]) - x[M - k] + L * (2 * k + 1)
    else:
        return 2 * Sx[k - 1] + x[k] - 2 * (Sx[M] - Sx[M - k - 1]) + L * 2 * (k + 1)

L, N = (int(i) for i in input().split())
ans = 0

pl = []
for i in range(N):
    pl.append(int(input()))
sumpl = [pl[0]]
for i in range(1, N):
    sumpl.append(sumpl[i - 1] + pl[i])
for i in range(0, N):
    ans = max(ans, goback(i, pl, sumpl))

revpl = [L - p for p in pl[::-1]]
sumrevpl = [revpl[0]]
for i in range(1, N):
    sumrevpl.append(sumrevpl[i - 1] + revpl[i])
for i in range(0, N):
    ans = max(ans, goback(i, revpl, sumrevpl))

print(ans)

Measured memory_bytes: 37904
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T=ll>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

class mod_int{
private:
    unsigned long long num;
public:
    static constexpr auto mod=static_cast<unsigned long long>(1e9+7);
    static mod_int pow(mod_int x,unsigned long long y)
    {
        return y==0?1:y%2==0?pow(x*x,y/2):x*pow(x,y-1);
    }
    mod_int()=default;
    mod_int(unsigned long long n):num(n%mod)
    {
    }
    explicit operator unsigned long long()const
    {
        return num;
    }
    bool operator==(const mod_int&mi)const
    {
        return num==mi.num;
    }
    bool operator!=(const mod_int&mi)const
    {
        return !operator==(mi);
    }
    mod_int operator~()const
    {
        return pow(*this,mod-2);
    }
    mod_int operator+(const mod_int&mi)const
    {
        return num+mi.num;
    }
    mod_int operator-(const mod_int&mi)const
    {
        return num+mod-mi.num;
    }
    mod_int operator*(const mod_int&mi)const
    {
        return num*mi.num;
    }
    mod_int operator/(const mod_int&mi)const
    {
        return num*(~mi).num;
    }
    mod_int&operator+=(const mod_int&mi)
    {
        return*this=operator+(mi);
    }
    mod_int&operator-=(const mod_int&mi)
    {
        return*this=operator-(mi);
    }
    mod_int&operator*=(const mod_int&mi)
    {
        return*this=operator*(mi);
    }
    mod_int&operator/=(const mod_int&mi)
    {
        return*this=operator/(mi);
    }
};
class combination_modulo:mod_int{
private:
    vector<mod_int>factorial_mod;
public:
    combination_modulo(unsigned long long max_n):factorial_mod(max_n+1)
    {
        factorial_mod[0]=1;
        for(unsigned long long i=1;i<=max_n;++i)factorial_mod[i]=factorial_mod[i-1]*i;
    }
    mod_int operator()(unsigned long long n,unsigned long long r)
    {
        return n<r?0:factorial_mod[n]/(factorial_mod[r]*factorial_mod[n-r]);
    }
};
int main()
{
    ll x=in(),y=in();
    if((2*y-x)%3!=0||(2*x-y)%3!=0){
        cout<<0<<endl;
    }else{
        ll a=(2*y-x)/3,b=(2*x-y)/3;
        if(a<0||b<0){
            cout<<0<<endl;
        }else{
            combination_modulo cm(a+b);
            cout<<(unsigned long long)cm(a+b,a)<<endl;
        }
    }
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
vector<int> num;
vector<int> prime;
bool is_prime[300000 + 1];

int sieve() {
	int p = 0;
	for (int i = 0; i <= num.size(); i++)is_prime[num[i]] = 1;
	is_prime[0] = is_prime[1] = 0;
	for (int i = 0; i <= num.size(); i++) {
		if (is_prime[num[i]]) {
			prime.push_back(num[i]);
			for (int j = num[i] * 2; j <= 300000; j += num[i])is_prime[j] = 0;
		}
	}
	return p;
}

int main() {
	REP(i, 300001) {
		if (i % 7 == 1 || i % 7 == 6)num.push_back(i);
	}

	sieve();
	//REP(i, 20)cout << prime[i] << " ";
	//cout << num.size() << endl;
	while (cin >> n&&n != 1) {
		cout << n << ":";
		REP(i, prime.size()) {
			if (n%prime[i] == 0)cout << " " << prime[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3672
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

const ll INF = 1LL << 50;

double f(const vector<double>& x, const vector<double>& y, const vector<char>& d, double t) {
    double max_x = -INF;
    double min_x = INF;
    double max_y = -INF;
    double min_y = INF;
    rep(i, 0, x.size()) {
        double now_x = x[i];
        double now_y = y[i];
        if (d[i] == 'U') now_y += t;
        else if (d[i] == 'D') now_y -= t;
        else if (d[i] == 'L') now_x -= t;
        else now_x += t;
        max_x = max(max_x, now_x);
        min_x = min(min_x, now_x);
        max_y = max(max_y, now_y);
        min_y = min(min_y, now_y);
    }
    return (max_x - min_x) * (max_y - min_y);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<double> X(N), Y(N);
    vector<char> D(N);
    rep(i, 0, N) cin >> X[i] >> Y[i] >> D[i];
    double l = 0.0, r = 1e10;
    rep(i, 0, 500) {
        double t1 = (2 * l + r) / 3;
        double t2 = (l + 2 * r) / 3;
        if (f(X, Y, D, t1) < f(X, Y, D, t2)) {
            r = t2;
        }
        else l = t1;
    }
    cout << fixed << setprecision(10) << f(X, Y, D, l) << endl;
    return 0;
}

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

int main() {

	string s;
	int a = 700;
	cin >> s;
	if (s[0] == 'o') a = a + 100;
	if (s[1] == 'o') a = a + 100 ;
	if (s[2] == 'o') a = a + 100;

	cout << a << endl;

	return 0;
 }

Measured memory_bytes: 3584
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

n,X,Y,Z=MI()
t=1<<(X+Y+Z)
haiku=( (1<<(X+Y+Z)) + (1<<(Y+Z)) + (1<<Z) )>>1
dp=[[0]*t for _ in range(n+1)]
dp[0][0]=1


for i in range(n):
    for k in range(t):
        for d in range(10):
            m=((k<<(d+1))+(1<<d))&(t-1)
            if m&haiku == haiku:
                continue
            else:
                dp[i+1][m]+=dp[i][k]
                dp[i+1][m]%=mo
sub=0
for i in range(t):
    sub+=dp[n][i]
ans=pow(10,n,mo)-sub
print(ans%mo)


Measured memory_bytes: 84188
import java.util.Scanner;
import java.math.*;
import java.text.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int cur = 100;
		for(int i = 0; i < n; i++){
			cur = (int)Math.ceil(cur*1.05);
		}
		System.out.println(cur*1000);
	}

}

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

const int M = 2010;
int blue[M][M] = {}, x_next[M][M] = {}, y_next[M][M] = {}; //1-indexed

int blue_sum(int x1, int y1, int x2, int y2) {
    return blue[x2][y2] + blue[x1 - 1][y1 - 1] - blue[x1 - 1][y2] - blue[x2][y1 - 1];
}

int x_sum(int x1, int y1, int x2, int y2) {
    x2--;
    return x_next[x2][y2] + x_next[x1 - 1][y1 - 1] - x_next[x1 - 1][y2] - x_next[x2][y1 - 1];
}

int y_sum(int x1, int y1, int x2, int y2) {
    y2--;
    return y_next[x2][y2] + y_next[x1 - 1][y1 - 1] - y_next[x1 - 1][y2] - y_next[x2][y1 - 1];
}

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

    int n, m, q;
    cin >> n >> m >> q;
    string s[n + 1];

    rep(i, n) {
        cin >> s[i];
        s[i].push_back('0');
    }
    s[n].assign(m + 1, '0');

    //sの添え字は1つ前にずらす
    REP(j, 1, m + 1) REP(i, 1, n + 1) blue[i][j] = blue[i - 1][j] + (s[i - 1][j - 1] - '0');
    REP(i, 1, n + 1) REP(j, 1, m + 1) blue[i][j] += blue[i][j - 1];
    REP(j, 1, m + 1) REP(i, 1, n + 1) x_next[i][j] = x_next[i - 1][j] + (s[i - 1][j - 1] == '1' && s[i + 1 - 1][j - 1] == '1');
    REP(i, 1, n + 1) REP(j, 1, m + 1) x_next[i][j] += x_next[i][j - 1];
    REP(i, 1, n + 1) REP(j, 1, m + 1) y_next[i][j] = y_next[i][j - 1] + (s[i - 1][j - 1] == '1' && s[i - 1][j + 1 - 1] == '1');
    REP(j, 1, m + 1) REP(i, 1, n + 1) y_next[i][j] += y_next[i - 1][j];

    rep(i, q) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        cout << blue_sum(x1, y1, x2, y2) - x_sum(x1, y1, x2, y2)
                - y_sum(x1, y1, x2, y2) << endl;
    }

    return 0;
}


Measured memory_bytes: 56832