akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

int bfs(int h, int w, P start, std::vector<std::vector<int>> m) {
    if (m[start.second][start.first] != 0) return 0;
    std::vector<std::vector<int>> path(h);
    for (int i=0; i<h; ++i) {
        std::vector<int> vec(w, 0);
        for (int j=0; j<w; ++j) {
            vec[j] = -1;
        }
        path[i] = vec;
    }

    queue<P> que;
    que.push(start);
    path[start.second][start.first] = 0;

    std::vector<int> ind_x{1, 0, -1, 0};
    std::vector<int> ind_y{0, 1, 0, -1};


    while (! que.empty()) {
        P p = que.front(); que.pop();
        for (int i = 0; i < 4; ++i) {
            int x = p.first + ind_x[i];
            int y = p.second + ind_y[i];
            if (0 <= x && x < w && 0 <= y && y < h
                    && m[y][x] == 0 && path[y][x] == -1) {
                //cout << "  (" << x << y << ")" << endl;
                que.push(P(x, y));
                path[y][x] = path[p.second][p.first] + 1;
            }
        }
    }
    int ret{0};
    for (auto v : path) {
        for (auto e : v) {
            //cout << "    " << e << " ";
            ret = max(ret, e);
        }
        //cout << endl;
    }
    return ret;
}

int main(int argc, char **argv) {
    i64 h, w;
    cin >> h >> w;
    std::vector<std::vector<int>> m(h);

    for (int i=0; i<h; ++i) {
        std::vector<int> vec(w, 0);
        for (int j=0; j<w; ++j) {
            char c;
            cin >> c;
            //cout << c;
            //cout << " ";
            vec[j] = c == '.' ? 0 : 1;
        }
        m[i] = vec;
        //cout << endl;
    }

    int ans{0};
    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            ans = max(bfs(h, w, P(j, i), m), ans);
            //cout << j << " " << i << " :" << ans << endl;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> A(n);
  for (int i = 0; i < n; i++)
    cin >> A[i];
  vector<pair<ll, ll>> BC(m);
  for (int i = 0; i < m; i++) {
    pair<ll, ll> p;
    cin >> p.second >> p.first;
    BC[i] = p;
  }
  sort(A.begin(), A.end());
  sort(BC.begin(), BC.end(), greater<pair<ll, ll>>());

  ll sum    = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    if (BC.size() > index && A[i] < BC[index].first) {
      sum += BC[index].first;
      BC[index].second--;
      if (BC[index].second == 0) index++;
    } else {
      sum += A[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 2688
n = int(input())
s = []
for i in range(n):
    s.append(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    if s[i] == 'AC':
        ac += 1
    elif s[i] == 'WA':
        wa += 1
    elif s[i] == 'TLE':
        tle += 1
    elif s[i] == 'RE':
        re += 1

print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

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

int main(void){
	string S;

	cin >> S;

	if( (S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]) or
		(S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]) or
		(S[0]==S[3] and S[1]==S[2] and S[0]!=S[1])){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
/*input
*/
#include<bits/stdc++.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORd(i, a, b) for (ll i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
#define db(x) cerr << #x << " = " << (x) << " "<<endl;
#define endln cerr << "\n";
const ll MN = 1e6+3 ;
void output()
{
    ll x,y ;
    cin>>x>>y ;
    ll ans = 0 ;
    while(x<=y)
    {
        ans++ ;
        x*=2 ;
    }
    cout<<ans<<endl ;
}
int main()
{
    #ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1 ;
    FOR(i,0,t)
    {
        output() ;
    }
    return 0 ;
}

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

int main()
{
    int a,b,c;

    cin >> a >> b >> c;
    if (a==b && a!=c) cout << "Yes" << endl;
    else if (b==c && b!=a) cout << "Yes" << endl;
    else if (c==a && c!=b) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


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

int n, k;

int main () {
	scanf("%d%d", &n, &k);
	if (k > (n + 1 >> 1)) puts("-1");
	else {
		if (n & 1) {
			int m = n + 1 >> 1;
			for (int i = 0; i < m; i++) printf("%d %d %d\n", k + i, k + 3 * m - 2 + i, k + 4 * m - 2 + 2 * i);
			for (int i = 0; i < m - 1; i++) printf("%d %d %d\n", k + m + i, k + 2 * m - 1 + i, k + 4 * m - 1 + 2 * i);
		}
		else {
			int m = n >> 1;
			for (int i = 0; i < m; i++) printf("%d %d %d\n", k + i, k + 3 * m + i, k + 4 * m + 2 * i);
			for (int i = 0; i < m; i++) printf("%d %d %d\n", k + m + i, k + 2 * m + i, k + 4 * m + 1 + 2 * i);
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include <map>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, x[19], y[19], h[129][19][19], dp[65555][549]; bool vis[65555][549]; map<pair<int, int>, vector<pair<int, int> > > d; vector<vector<pair<int, int> > > v;
int gcd(int pa, int pb) {
	if (pb == 0) return pa;
	return gcd(pb, pa % pb);
}
int solve(int bit, int p1, int p2, int cur) {
	if (p1 == v.size()) return 0;
	if (p2 == v[p1].size()) {
		int res = solve(bit, p1 + 1, 0, 0);
		return res + cur * (cur - 1) / 2;
	}
	if (vis[bit][h[p1][p2][cur]]) return dp[bit][h[p1][p2][cur]];
	int pa = v[p1][p2].first, pb = v[p1][p2].second;
	int ret = solve(bit, p1, p2 + 1, cur);
	if (!(bit & (1 << pa)) && !(bit & (1 << pb))) {
		int res = solve(bit | (1 << pa) | (1 << pb), p1, p2 + 1, cur + 1);
		ret = max(ret, res);
	}
	vis[bit][h[p1][p2][cur]] = true;
	dp[bit][h[p1][p2][cur]] = ret;
	return ret;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int vx = x[j] - x[i], vy = y[j] - y[i];
			if (vy < 0) vy = -vy, vx = -vx;
			if (vy == 0 && vx < 0) vx = -vx;
			int g = gcd(abs(vx), vy);
			d[make_pair(abs(vx) / g * (vx > 0 ? 1 : -1), vy / g)].push_back(make_pair(i, j));
		}
	}
	for (pair<pair<int, int>, vector<pair<int, int> > > i : d) {
		v.push_back(i.second);
	}
	int curs = 0;
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			for (int k = 0; k <= j; k++) {
				h[i][j][k] = curs++;
			}
		}
	}
	int ret = solve(0, 0, 0, 0);
	cout << ret << endl;
	return 0;
}

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

int main()
{
    long long int n,k;
    cin>>n>>k;
    long long int a[n];
    for(long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long int l=1,r=a[n-1],ans=a[n-1];
    while(l<=r)
    {
        long long int mid=(l+r)/2 , req=0;
        for(long long int i=0;i<n;i++)
        {
            req+=a[i]/mid;
            if(a[i]%mid)
            req++;
            req--;
        }
        if(req>k)
        {
            l=mid+1;
        }
        else
        {
            r=mid-1;
            ans=min(ans,mid);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5152
a,b = [int(i) for i in input().split()]
l =  [int(i) for i in input().split()]
ans = [10**9 for _ in range(a+1)]       
ans[0] = 0          

for i in range(a+1):
    for j in l:
        if i + j < a+1:
            ans[i+j] = min(ans[i] + 1,ans[i+j])
            
print(ans[-1])


Measured memory_bytes: 7376
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N= int(input())
div = make_divisors(N)

minimum=N*2
for elem in div:
    A=elem
    B=N//elem
    if(A+B)<minimum:
        minimum=A+B
print(minimum-2)

Measured memory_bytes: 3264
main = do
  [r,d,x] <- map read . words <$> getLine
  putStrLn $ unlines $ map show (f r d x [])
f :: Int -> Int -> Int -> [Int] -> [Int]
f a b y ans
  | length ans < 10 = f a b (y*a-b) (ans ++ [y*a-b])
  | otherwise = ans


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N; cin >> N;
  vector<long long> A(27);
  long long cnt = 0;
  
  A.at(0) = 10LL;
  for(int i = 1; i < 27; ++i){
    A.at(i) = A.at(i-1) * 5LL;
  }
  
  if(N%2 == 0){
    for(int i = 0; i < 27; ++i){
      cnt += N / A.at(i);
    }
    cout << cnt << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define endl '\n'
using namespace std;
const int N=2e5+5;
int n,m,k,t,x,y,z;
int b[N];

void solve(int ans=0){
    string s;
    cin>>s;
    int n=s.size();
    vector<int> a(n+1);
    rep(i,n) a[i]=s[i-1]-'0';
    map<int,int> mp;
    int t=0,p;
    mp[0]=1;
    drep(i,n) {
        t+=a[i]*b[n-i+1];
        t%=2019;
        //cout<<t<<endl;
        ans+=mp[t];
        mp[t]++;
    }
    cout<<ans<<endl;
}

#undef int
int main(){
    ios::sync_with_stdio(false);
    //cin.tie(0);cout.tie(0);
    b[1]=1;
    rep(i,N-1) if(i>1) b[i]=(b[i-1]*10)%2019;
    solve();
}



Measured memory_bytes: 6724
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};
use std::collections::HashSet;

fn main() {
    input!{
        n: usize
    }
    if n == 2 {
        println!("1");
        return;
    }
    let mut set = HashSet::new();
    set.insert(n);
    set.insert(n - 1);
    for i in 2..n {
        if i * i > n {
            break;
        }
        if (n - 1) % i == 0 {
            if i * i == n - 1 {
                set.insert(i);
            } else {
                set.insert(i);
                set.insert((n - 1) / i);
            }
        }
        if n % i != 0 {
            continue;
        }
        let mut m = n;
        while m % i == 0 {
            m /= i;
        }
        if m % i == 1 {
            set.insert(i);
        }
        m = n;
        let j = n / i;
        while m % j == 0 {
            m /= j;
        }
        if m % j == 1 {
            set.insert(j);
        }
    }
    println!("{}", set.len());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int sum=0,n,x,k,ans=0;
int a[1000001];
map<int,int> m; 
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		m[x]++;
	}
	int q=m.size();
	map<int,int>::iterator it=m.begin();
	for(it;it!=m.end();it++)
	{
		a[++sum]=(*it).second;
	}
	sort(a+1,a+sum+1);
	for(int i=1;i<=q-k;i++)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 10368
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
  string s, t, u;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  cin >> u;
  
  map<string, int> x;
  x[s] = a;
  x[t] = b;
  x[u]--;
  
  cout << x[s] << " " << x[t] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(long long i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)
using Graph = vector<vector<int>>;
 
  int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,q,ans;
  cin>>n;
  ans=0;
  int arr[100001]={};
  fr(i,n){
    int s;
    cin>>s;
    ans+=s;
    ++arr[s];
  }
  cin>>q;
  fr(i,q){
    int b,c;
    cin>>b>>c;
    ans+=(c-b)*(arr[b]);
    arr[c]+=arr[b];
    arr[b]=0;
    cout<<ans<<"\n";
  }
}

Measured memory_bytes: 4040
use std::io;
use std::str::FromStr;

fn input_i32_vec() -> Vec<i32> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let vec = input_i32_vec();
    let mut five = 0;
    let mut seven = 0;
    for v in vec {
        if v == 5 {
            five += 1;
        } else if v == 7 {
            seven += 1;
        }
    }
    if five == 2 && seven == 1 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
S = input()

def solve(s):
    n = len(s)
    for i in range(n - 2):
        if s[i] == s[i + 1]:
            return i + 1, i + 2
        if s[i] == s[i + 2]:
            return i + 1, i + 3
    if s[n - 2] == s[n - 1]:
        return n - 1, n
    return -1, -1

print(*solve(S))


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

using namespace std;

int h,w,i;

int main(){
	scanf("%d%d", &h, &w);
	
	if(h % 3 == 0 || w % 3 == 0) return 0 * printf("0\n");
	
	long long res = min(h, w);
	
	for(i = 1; i < h; i++){
		long long a = (long long)i * w;
		int newh = h - i;
		long long b, c;
		
		if(w % 2 == 0){
			b = (long long)newh * (w / 2);
			c = (long long)newh * (w / 2);
		}
		else{
			b = (long long)newh * (w / 2);
			c = (long long)newh * (w / 2 + 1);
		}
		
		long long mx = max(max(a, b), c);
		long long mn = min(min(a, b), c);
		
		res = min(res, mx - mn);
	}
	
	for(i = 1; i < w; i++){
		long long a = (long long)i * h;
		int neww = w - i;
		long long b, c;
		
		if(h % 2 == 0){
			b = (long long)neww * (h / 2);
			c = (long long)neww * (h / 2);
		}
		else{
			b = (long long)neww * (h / 2);
			c = (long long)neww * (h / 2 + 1);
		}
		
		long long mx = max(max(a, b), c);
		long long mn = min(min(a, b), c);
		
		res = min(res, mx - mn);
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

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

int div(ll n)
{
    int sq = (int)sqrt(n) + 1, cnt = 0;
    for (int i = 2; i <= sq; ++i)
    {
        if (n % i == 0)
        {
            ++cnt;
            while ((n /= i) % i == 0);
            sq = (int)sqrt(n) + 1;
        }
    }
    return cnt + (n > 1 ? 1 : 0);
}

int main()
{
    ll a, b;
    cin >> a >> b;
    a = gcd(a, b);
    cout << div(a)+1;
    return 0;
}

Measured memory_bytes: 256
# ぶっちゃけアイデアを理解するのが難しかった。
# 詳細な解説は本を読もう
# 長さ2の配列ならば反転数をもとめるのは一瞬
# 2つの配列をソートしながらマージするときについでに反転数が求まるのが鍵で、これを実装に組み込む

INF = 10**9 + 1


def merge(A: list, left: int, mid: int, right: int) -> int:
    '''
    2つの配列をmergeする関数

    Aはこのプログラムで処理する配列。
    left, mid, rightはAのindex。
    '''
    cnt = 0  # mergeするときに何回反転するか
    n1 = mid-left  # 右の方の配列のlen (反転数を計算するときにこいつを使う)
    # n2 = right-mid  # 左の方の配列のlen ぶっちゃけいらない

    L = A[left:mid]  # python sliceはshallow copyらしい
    L.append(INF)  # 番兵
    R = A[mid:right]
    R.append(INF)  # 番兵

    i_l, i_r = 0, 0  # LとRのコントロール用idx
    for k in range(left, right):
        # L,Rの先頭を比較していって小さい方をAに打ち込む
        if L[i_l] <= R[i_r]:
            A[k] = L[i_l]
            i_l += 1
        else:
            A[k] = R[i_r]
            i_r += 1
            cnt += n1-i_l  # ここが重要 反転したときだけ反点数を足し込んでいく
    return cnt


def merge_sort(A: list, left: int, right: int):
    '''
    マージソートをしつつ、反転数を再帰的に計算する。

    ここではマージを再帰的に適応し反転数をどんどん上に伝播させていく仕組み
    '''
    if left + 1 >= right:  # 終了条件
        return 0

    mid = (left+right)//2
    v1 = merge_sort(A, left, mid)  # 右左にも再帰的にmerge_sortを適応
    v2 = merge_sort(A, mid, right)
    v3 = merge(A, left, mid, right)  # 右左整ったらmerge

    return v1+v2+v3


n = int(input())
A = list(map(int, input().split()))
print(merge_sort(A, 0, n))



Measured memory_bytes: 27480
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N; cin >> N;
  vector<int> v(N);
  rep(i,N) cin >> v[i];
  int s=INF;
  int ans=0;
  rep(i,N){
    if(v[i]<s){
      s=v[i];
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b;
  cin >> a >> b;
  cout << ((a <= 8 && b <= 8) ? "Yay!" : ":(") << endl;
}


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

#define ll long long

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}

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

int main() {
	int a=0,b=0;
	char op;
	for(;;)
	{
		cin>>a>>op>>b;
		if (op == '+') cout<<a+b<<endl;
		if (op == '-') cout<<a-b<<endl;
		if (op == '*') cout<<a*b<<endl;
		if (op == '/') cout<<a/b<<endl;
		if (op == '?') break;
	}
	return 0;
}



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

#define chmin(x,y) x=min(x,y)

int main(){
    int n;
    cin >> n;
    vector<int> dp(n+1,100000);
    dp[0]=0;
    for(int i=1; i<=n; i++){
        int power;

        chmin(dp[i],dp[i-1]+1);
  
        power = 6;
        while(power <= i){
            chmin(dp[i],dp[i-power]+1);
            power *= 6;
        }
        
        power = 9;
        while(power <= i){
            chmin(dp[i],dp[i-power]+1);
            power *= 9;
        }
    }
    cout << dp[n] << endl;

    return 0;
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, l[200];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n;
  for (int i = 0; i < 2 * n; i++)
    cin >> l[i];
  sort(l, l + 2 * n);
  int r = 0;
  for (int i = 0; i < 2 * n; i += 2)
    r += l[i];
  cout << r << "\n";
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int h,w,a,b;

signed main() {
    cin >> h >> w >> a >> b;
    if (!a)  {
         rep(i,h) {
             rep(j,w) {
                 if (i<b) cout << 1;
                 else cout << 0;
             }
             cout << endl;
         }
     } else if (!b) {
         rep(i,h) {
             rep(j,w) {
                 if (j<a) cout << 1;
                 else cout << 0;
             }
             cout << endl;
         }
     } else {
         rep(i,h) {
             rep(j,w) {
                 if (i<b ^ j<a) cout << 1;
                 else cout << 0;
             }
             cout << endl;
         }
     }

}


Measured memory_bytes: 1280
N = int(input())
def LI():
  return [int(s) for s in input().split()]

d_s = LI()
d_s = sorted(d_s)

if len(d_s) % 2 != 0:
  print(0)
  exit()
  
upper = len(d_s) // 2
lower = upper - 1

print(d_s[upper] - d_s[lower])

Measured memory_bytes: 14428
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;


int n;
int d[100010];


int main(){

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

    sort(d, d+n);

    cout << d[n/2] - d[n/2-1] << endl;

    return 0;
}

Measured memory_bytes: 640
from fractions import gcd
from itertools import chain


def eratosthenes_generator():
    yield 2
    n = 3
    h = {}
    while True:
        m = n
        if n in h:
            b = h[n]
            m += 2 * b
            while m in h:
                m += 2 * b
            h[m] = b
            del h[n]
        else:
            m += 2 * n
            while m in h:
                m += 2 * n
            h[m] = n
            yield n
        n += 2


def solve(n):
    if n == 2:
        return [[2, 3], [5, 4]]

    ans = [[0] * n for _ in range(n)]
    eg = eratosthenes_generator()
    primes = [next(eg) for _ in range(2 * n)]
    primes = list(chain.from_iterable(zip(primes, primes[::-1])))
    ps = primes[:n]
    qs = primes[n:2 * n]
    m = (n - 1) // 2

    for i in range(n):
        for j in range(i % 2, n, 2):
            l1 = ps[(i + j) // 2 - m]
            l2 = qs[(i - j) // 2]
            ans[i][j] = l1 * l2

    for i in range(n):
        for j in range((i % 2) ^ 1, n, 2):
            surroundings = []
            if i > 0:
                surroundings.append(ans[i - 1][j])
            if i < n - 1:
                surroundings.append(ans[i + 1][j])
            if j > 0:
                surroundings.append(ans[i][j - 1])
            if j < n - 1:
                surroundings.append(ans[i][j + 1])
            lcm = surroundings[0]
            for s in surroundings[1:]:
                lcm = lcm * s // gcd(lcm, s)
            ans[i][j] = lcm + 1

    return ans


def check(ans):
    for i in range(n):
        for j in range(n):
            x = ans[i][j]
            assert x <= 1e15, x
            if i > 0:
                y = ans[i - 1][j]
                assert max(x, y) % min(x, y) == 1
            if i < n - 1:
                y = ans[i + 1][j]
                assert max(x, y) % min(x, y) == 1
            if j > 0:
                y = ans[i][j - 1]
                assert max(x, y) % min(x, y) == 1
            if j < n - 1:
                y = ans[i][j + 1]
                assert max(x, y) % min(x, y) == 1
    print('OK')


n = int(input())
ans = solve(n)
# check(ans)
print('\n'.join(' '.join(map(str, row)) for row in ans))


Measured memory_bytes: 24672
# -*- coding: utf-8 -*-

n, m, x, y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
for z in range(x+1, y+1):
    war = False
    for _x in X:
        if _x >= z:
            war = True
    for _y in Y:
        if _y < z:
            war = True
    if not war:
        print('No War')
        exit()
print('War')


Measured memory_bytes: 3060
n = int(input())
x = [int(x) for i, x in enumerate(input().split())]
x = sorted(zip(x, range(1, n+1)))

stack = []
for v, i in x[::-1]:
    for _ in range(i-1):
        stack.append(i)

cur = 1
ans = []
res = []
cnt = [0]*(n+1)
for i in range(n):
    for _ in range(x[i][0]-cur):
        if stack:
            nxt = stack.pop()
        elif res:
            nxt = res.pop()
        else:
            print('No')
            exit()
        ans.append(nxt)
        cnt[nxt] += 1
    if cnt[x[i][1]] != x[i][1]-1:
        print('No')
        exit()
    ans.append(x[i][1])
    for _ in range(n-x[i][1]):
        res.append(x[i][1])
    cur = x[i][0]+1

ans += res

print('Yes')
print(*ans)


Measured memory_bytes: 104764
using System;

namespace A___Remaining_Time
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            Console.WriteLine((a + b) % 24);
        }
    }
}

Measured memory_bytes: 11092
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using static System.Console;

namespace ConsoleAppAtCoderABC172
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(ReadLine());
            var counter = new int[60001];

            for (int i = 1; i <= 100; i++)
            {
                for (int j = i; j <= 100; j++)
                {
                    for (int k = j; k <= 100; k++)
                    {
                        var n = i * (i + j) + j * (j + k) + k * (k + i);

                        if (i == j && j == k)
                            counter[n] += 1;
                        else if (i != j && j != k && k != i)
                            counter[n] += 6;
                        else
                            counter[n] += 3;
                    }
                }
            }

            for (int i = 1; i <= N; i++)
            {
                WriteLine(counter[i]);
            }
        }
    }
}


Measured memory_bytes: 27536
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	cout << (c >= a&&c <= b ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) cout<<"Case "<<n<<": "
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
#define MAX 1000007
#define all(x)(x.begin(),x.end())
#define debug(x,c) cout<<x<<": "<<c<<" ";
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main()
{
	float a,b,c;
	cin>>a>>b>>c;
	cout<<(((a/b)<=c)?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 3732
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

// ここまで

fn run() {
    input! {
        n: usize,
        a: [u32; n],
    }
    let mut dp = vec![0; 1];
    dp[0] = 1000000000 + 1;
    for &x in &a {
        if dp[dp.len() - 1] >= x {
            dp.push (x);
            continue;
        }
        let mut l = 0;
        let mut r = dp.len();
        while l + 1 < r {
            let m = (l + r) / 2;
            if dp[m] >= x {
                l = m;
            } else {
                r = m;
            }
        }
        dp[r] = x;
    }
    println! ("{}", dp.len() - 1);
}

fn main() {
    run();
}


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



void kock(int n, double p1x, double p1y, double p2x, double p2y) {
    if (n==0) return;
    double sx, sy, tx, ty, ux, uy;
    sx = (2*p1x + p2x)/3;
    sy = (2*p1y + p2y)/3;
    tx = (p1x + 2*p2x)/3;
    ty = (p1y + 2*p2y)/3;
    ux = (tx - sx)/2 - sqrt(3)*(ty - sy)/2  + sx;
    uy = sqrt(3)*(tx - sx)/2 + (ty - sy)/2  + sy;
    kock (n-1, p1x, p1y, sx, sy);
    cout << fixed << sx << " " << fixed << sy << endl;
    kock (n-1, sx, sy, ux, uy);
    cout << fixed << ux << " " << fixed << uy << endl;
    kock (n-1, ux, uy, tx, ty);
    cout << fixed << tx << " " << fixed << ty << endl;
    kock(n-1, tx, ty, p2x, p2y);
}

int main() {
    int N;
    cout << 0 << " " << 0 << endl;
    cin >> N;
    kock (N, 0, 0, 100, 0);
    cout << 100 << " " << 0 << endl;
}


Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(20)
#define Accepted_MAGIC cin.tie(0);ios::sync_with_stdio(false)

// typedef long long ll;
using Real = long double;
#define int long long

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
constexpr Real eps = 1e-9, pi = acos(-1);

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

signed main(void){
  Accepted_MAGIC;
  
  int K; cin >> K;
  queue<int> que;
  for(int i = 1; i <= 9; i++){
    que.push(i);
  }
  int cnt = 0, num;
  while(!que.empty()){
    num = que.front(); que.pop();
    cnt++;
    if(cnt == K) break;
    int nx[3] = {num%10-1, num%10, num%10+1};
    REP(i, 3){
      if(nx[i]<0 or nx[i]>9) continue;
      que.push(num*10 + nx[i]);
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 1792
//be naame khodaa

#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <sstream>
#define fi first
#define se second
#define rep(i, x, n) for (int i = x; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> VI;

int main()
{
	ios::sync_with_stdio(false);
	int k, n;
	cin >> k >> n;
	if (k%2 == 0){
		cout << k/2 << ' ';
		for (int i = 1; i < n; i++)
			cout << k << ' ';
		cout << endl;
		return 0;
	}
	vector <int> v(n, (k+1)/2);
	for (int i = 0; i < n/2; i++){
		if (v.back() == 1)
			v.pop_back();
		else {
			v.back()--;
			while (v.size() < n)
				v.push_back(k);
		}
	}
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,x,sum=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
			{
				if(i*500+j*100+k*50==x)
				sum++;
			}
			cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
template<typename T>
inline T GET() {
	T val;
	cin >> val;
	return val;
}


 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}

struct uni_find
{
	vector<int> par;
	vector<int> cnt;
	int sz;
	uni_find(){} 
	uni_find(int n) {init(n);}
	void init(int n) {
		par.resize(n);
		cnt.resize(n);
		rep(i, n) par[i] = i, cnt[i] = 1;
		sz = n;
	}
	int root(int x) {return par[x] == x ? x : par[x] = root(par[x]);}
	bool same(int x, int y) {return root(x) == root(y);}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (cnt[x] > cnt[y]) {
			par[x] = y;
			cnt[y] += cnt[x];
		}
		else {
			par[y] = x;
			cnt[x] += cnt[y];
		}
	}
	int size(int x) {
		return cnt[root(x)];
	}
};

uni_find a, b;
int N;

void init()
{
	int K, L;
	cin >> N >> K >> L;
	a.init(N);
	b.init(N);
	rep(i, K) {
		a.unite(GET<int>()-1, GET<int>()-1);
	}
	rep(i, L) {
		b.unite(GET<int>()-1, GET<int>()-1);
	}
}


void solve()
{
	map<pair<int,int> , int> m;
	rep(i, N) {
		m[MP(a.root(i), b.root(i))]++;
	}
	rep(i, N) {
		cout << m[MP(a.root(i), b.root(i))] << " \n"[i==N-1];
	}
}



Measured memory_bytes: 15104
fun main(arr:Array<String>) {
    val mondaiKount = readLine()!!.toInt()
    val haiten = (1..mondaiKount).map { readLine()!!.toInt() }
    var total = haiten.sum()
    if(total % 10 == 0) {
        total -= haiten.filter { it % 10 != 0 }.min()?:0
    }
    if(total % 10 == 0) {
        total = 0
    }
    println(total)
}

Measured memory_bytes: 33516
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
#define M 30005
using namespace std;

typedef long long ll;
typedef pair < ll , ll > ii;

ll n, m, ans = inf, a[N], b[N], dp[M][1005];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld",&m,&n);
	for(ll i = 1; i <= n; i++){
		scanf("%lld %lld",a + i, b + i);
	}
	dp[0][0] = 0;

	for(ll k = 1; k < M; k++)
		dp[k][0] = inf;

	for(ll i = 1; i <= n; i++){
		for(ll k = 0; k < M; k++){
			dp[k][i] = dp[k][i - 1];
			if(k >= a[i]){
				dp[k][i] = min(dp[k][i - 1], dp[k - a[i]][i] + b[i]);
			}
			if(i == n and k >= m)
				ans = min(ans, dp[k][i]);
			// cout << i << " " << k << " " << dp[k][i] << endl;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 239872
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
const int N(105);
int n, m, dp[N][N];
char mat[N][N];
int main() {
    DAU
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        cin >> (mat[i] + 1);
    for (int i = 0; i <= n + 1; ++i)
        for (int j = 0; j <= m + 1; ++j)
            dp[i][j] = 1e9;
    dp[1][1] = (mat[1][1] == '#');
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            dp[i+1][j] = min(dp[i][j] + (mat[i][j] == '.' && mat[i+1][j] != '.'), dp[i+1][j]),
            dp[i][j+1] = min(dp[i][j] + (mat[i][j] == '.' && mat[i][j+1] != '.'), dp[i][j+1]);
    cout << dp[n][m];
    PLEC
}


Measured memory_bytes: 256
// ABCABC078A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	char X, Y;
	cin >> X >> Y;

	if (X > Y) {
		cout << ">" << endl;
	} else if (X < Y) {
		cout << "<" << endl;
	} else {
		cout << "=" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "4", "0 1 1 2" ].parse.expand.solve == 2 );
	assert( [ "4", "1 1 1 1" ].parse.expand.solve == 0 );
	assert( [ "7", "0 3 2 1 2 2 1" ].parse.expand.solve == 24 );
	
	assert( [ "4", "0 0 1 1" ].parse.expand.solve == 0 );		// 追加ケース
	assert( [ "4", "1 0 1 1" ].parse.expand.solve == 0 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto ds = input.front.split.to!( long[] );
	return tuple( ds );
}

auto solve( long[] ds )
{
	// 頂点1と頂点1の距離が0じゃない訳がない
	if( ds[ 0 ] != 0 ) return 0;
	ds.popFront;
	
	// 頂点1を根にして、近い順に構築する
	auto ans = 1L;
	auto p = 1L;
	auto d = 1L;
	foreach( g; ds.sort().group )
	{
		// 子を付けられる適正距離の親が無い
		if( d != g[ 0 ] ) return 0;
		
		// 親子の組み合わせのパターン数を計算
		ans = ans.mulMod( p.powMod( g[ 1 ] ) );
		
		p = g[ 1 ];
		d++;
	}
	return ans;
}

// 掛け算
auto mulMod( long MOD = 998244353L )( long x, long y )
{
	return x * y % MOD;
}

// べき乗
auto powMod( long MOD = 998244353L )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}


Measured memory_bytes: 4476
#include"bits/stdc++.h"
#include<valarray>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define MAX 100002

int n;
int m;


vector<int> v[MAX];

bool use[MAX];

vector<pair<int,int> > ret;

int dep[MAX];


inline bool dfs(int b,int pr=-1,int d=0){
	use[b]=true;
	dep[b]=d;
	bool par=false;
	for(int go:v[b]){
		if(use[go]==false){
			bool ok=dfs(go,b,d+1);
			if(ok){
				ret.push_back(make_pair(b,go));
				par^=true;
			}
		}
		else{
			if(go==pr)continue;
			if(dep[b]>dep[go]){
				continue;
			}
			ret.push_back(make_pair(b,go));
			par^=true;
		}
	}
	if(par==false){
		return true;
	}
	ret.push_back(make_pair(b,pr));
	return false;
}

int main(){
	cin>>n;
	cin>>m;
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	if(m%2){
		puts("-1");
		return 0;
	}
	dfs(0);
	for(int i=0;i<ret.size();i++){
		printf("%d %d\n",ret[i].first+1,ret[i].second+1);
	}
	return 0;
}


Measured memory_bytes: 12404
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int s[120];

int memo[120][10];

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> s[i];
  }
  fill(&memo[0][0], &memo[0][0]+120*10, 0);
  for (auto i = 0; i < N; ++i) {
    for (auto j = 0; j < 10; ++j) {
      memo[i+1][j] = memo[i][j];
    }
    for (auto j = 0; j < 10; ++j) {
      int score = memo[i][j] + s[i];
      int shimo = score % 10;
      memo[i+1][shimo] = max(memo[i+1][shimo], score);
    }
  }
  memo[N][0] = 0;
  int maxi = 0;
  for (auto i = 0; i < 10; ++i) {
    maxi = max(maxi, memo[N][i]);
  }
  cout << maxi << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

//6/13
public class Main {


	/**与えられた命令の列を実行するプログラム
	 *
	 * @param args0:文字列、1:実行コマンド数 2~：コマンド
	 */
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){

		String target = scan.next();
		int set_num = scan.nextInt();
//		String target = args[0];
//		int set_num = Integer.parseInt(args[1]);

		for(int k = 0,  action = 0; action < set_num;action++){
			String command = scan.next();
//			String command = args[k + 2];

			int start,end;
			start = scan.nextInt();
			end = scan.nextInt() + 1;						//なぜ＋１しないといかんのかわからん
//			start = Integer.parseInt(args[k + 3]);
//			end = Integer.parseInt(args[k + 4]) + 1;		//なぜ＋１しないといかんのかわからん



			switch(command){
			case "print":
				//指定されたインデックス番号の位置から終端までの文字列を返します。
				System.out.println(target.substring(start,end));
				 k =k + 3;
				break;

			case "replace":
				StringBuffer sb = new StringBuffer(new String(target));
				
				target = sb.replace(start, end, scan.next()).toString();
				k = k + 4;
				break;

			case "reverse":

				//リバースする部分をとりだして（変数１）、反転した変数をつくる（変数２）
				//もとの文章に対して,もとの文章.replace(変数１、変数２）をプリントアウト
				String target_part = target.substring(start ,end );						//変数１
				StringBuffer reverse_part = new StringBuffer(new String(target_part));	//変数２
				
				reverse_part.reverse();
				target = target.replace(target_part, reverse_part);
				 k = k + 3;
				break;

			default:
				break;

			}
		}


	}
}



Measured memory_bytes: 29852
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
 
import java.util.*;
class Main {
     
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String tar = sc.next().toLowerCase();
        int count = 0;
        while(true) {
            String tmp = sc.next();
            if(tmp.equals("END_OF_TEXT")) break;
            if(tar.equals(tmp.toLowerCase())) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26376
import math

if __name__ == "__main__":
    n, m = map(int, input().split())
    if not abs(n - m) <= 1:
        print(0)
    elif abs(n - m) == 1:
        print(math.factorial(n) * math.factorial(m) % (10**9+7))
    else:
        print(math.factorial(n) * math.factorial(m) * 2 % (10**9+7))


Measured memory_bytes: 5180
f=input
from collections import deque
s=deque(f())
n=int(f())
t=0
for i in range(n):
  q=f()
  if q[0]=='1': t^=1
  elif int(q[2])+t==2: s.append(q[4])
  else: s.appendleft(q[4])
print(''.join([s,list(s)[::-1]][t]))

Measured memory_bytes: 10476
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
set<pair<int, int>> s;
vector<pair<int, int>> arr;
void solve() {
	int h, a;
	cin >> h >> a;
	int ans = 0;
	while (h > 0) {
		h -= a;
		ans++;
	}
	cout << ans;
}   

Measured memory_bytes: 256
//
// Created by shafquat on 4/6/19.
//

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

int main()
{
    int a[5], k;
    for(int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    cin >> k;
    sort(a, a + 5);
    if(a[4] - a[0] > k) {
        cout << ":(\n";
    } else {
        cout << "Yay!\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    int n, y;

    cin >> n >> y;

    y /= 1000;

    for(int i=n;i>=0;i--)
        for(int j=n-i;j>=0;j--)
            if(i*10+j*5+(n-i-j)==y){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256