akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

long long *a{};
int n, k;

bool need(long long, long long, int, int);

int main()
{
	scanf("%d%d", &n, &k);
	a = new long long[n];
	for (int i = 0; i < n; i++) scanf("%lld", a + i);
	std::sort(a, a + n, std::greater<long long>());
	int need_count{};
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= k || need(k - a[i], k, n - 1, i))
			need_count++;
	}
	printf("%d\n", n - need_count);

	delete[] a;
	return 0;
}

bool need(long long left, long long right, int a_index, int ignore)
{
	if (left <= 0 && right > 0) return true;
	if (a_index == -1 || right <= 0) return false;

	if (a_index == ignore)
		return need(left, right, a_index - 1, ignore);
	// 連結なら連結したやつを渡す
	if (right - a[a_index] >= left)
		return need(left - a[a_index], right, a_index - 1, ignore);
	// 非連結なら[left, right)に
	return need(left, right, a_index - 1, ignore) || need(left - a[a_index], right - a[a_index], a_index - 1, ignore);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000007;

int main() {
    int N, B[101], C[101], sum=0;
    cin >> N;
    for (int i=1;i<N;i++) {
        cin >> B[i];
    }
    B[0] = B[N] = inf;
    for (int i=1;i<=N;i++) {
        C[i] = min(B[i], B[i-1]);
        sum += C[i];
    }
    cout << sum << '\n';
}


Measured memory_bytes: 256
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


int main()
{
    int a, b ;
    cin >> a >> b ;
    cout << max(a+b , max(a*2-1 , b*2-1)) << endl ;
    return 0 ;
}

Measured memory_bytes: 256
//  atcodder.xcode
//  main.cpp
//  Created by conan1024hao on 2019/11/09.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリ
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
#define WHITE 0
#define GRAY 1
#define BLACK 2
ll n,m;
vector<pair<ll,ll> >adj[200001];//邻接表表示
vector<ll>d;
void dijkstraplus(){
    d.resize(n+m);
    priority_queue<pair<ll,ll> > pq;
    ll color[200001];
    for(ll i=0;i<n+m;i++){
        d[i]=INF;
        color[i]=WHITE;
    }
    d[0]=0;
    pq.push(make_pair(0,0));//pq和adj里面的元素是反的
    color[0]=GRAY;
    while(!pq.empty()){
        pair<ll,ll> f=pq.top();
        pq.pop();
        ll u=f.second;
        color[u]=BLACK;
        if(d[u]<f.first*(-1)) //pq是从大到小所以要*-1 如果不是最小路径则忽略
            continue;
        for(ll j=0;j<adj[u].size();j++){
            ll v=adj[u][j].first;
            if(color[v]==BLACK)
                continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                pq.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY;
            }
        }
    }
    //for(int i=0;i<n;i++)
     //   cout<<d[i]<<endl;
    if(d[n-1]==INF)
       d[n-1]=-1;
    cout<<d[n-1]<<endl;
}
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    
    cin>>n>>m;
    for(int i=1;i<n;i++)
        adj[i].push_back(make_pair(i-1,0));
    for(ll i=0;i<m;i++)
    {
        ll l,r,c;
        cin>>l>>r>>c;
        l--;
        r--;
            { adj[l].push_back(make_pair(r,c));
                }
    }
    dijkstraplus();
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 14840
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int ans = 1000000000;
		for(int i = 0;i < Math.max(X,Y) + 1;i++){
			ans = Math.min(ans,2 * C * i + A * seisu(X - i) + B * seisu(Y - i));
		}
		System.out.println(ans);
	}
	public static int seisu(int a){
		if(a > 0){
			return a;
		}
		return 0;
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,d;
    scanf("%lld %lld",&a,&b);
    d=a+b;
    if(d%2!=0)
    {
        printf("IMPOSSIBLE\n");
    }
    else printf("%lld\n",d/2);
    return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int x;
    cin >> x;

    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

ll n, c;
ll x[100000], v[100000];
priority_queue<P, vector<P> > que1, que2;

int main() {
    cin >> n >> c;
    rep(i,n) {
        cin >> x[i] >> v[i];
    }
    ll now = 0;
    ll ans = 0;
    rep(i,n) {
        now += v[i];
        que1.push(P(now-x[i]*2,i));
        ans = max(ans, now-x[i]);
    }
    now = 0;
    for (int i = n-1; i >= 0; i--) {
        now += v[i];
        que2.push(P(now-(c-x[i])*2, i));
        ans = max(ans, now-(c-x[i]));
    }
    now = 0;
    rep(i,n) {
        now += v[i];
        while (!que2.empty() && que2.top().second <= i) que2.pop();
        if (que2.empty()) break;
        P q = que2.top();
        ans = max(ans, que2.top().first+now-x[i]);
    }
    now = 0;
    for (int i = n-1; i >= 0; i--) {
        now += v[i];
        while (!que1.empty() && que1.top().second >= i) que1.pop();
        if (que1.empty()) break;
        P q = que1.top();
        ans = max(ans, que1.top().first+now-(c-x[i]));
    }
    cout << ans << endl;
}


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

using namespace std;

const int N = 200002;
vector<int> g[N];
int sz[N];

const long long MOD = 1000000007;

long long binpow(long long a, long long x) {
    if (x == 0) return 1;
    if (x % 2 == 0) {
        long long t = binpow(a, x/2);
        return t * t % MOD;
    } else {
        return a * binpow(a, x-1) % MOD;
    }
}

long long inv(long long x) {
    return binpow(x, MOD-2);
}

long long fact[N];
long long ifact[N];

long long ans = 1;
long long part[N];
long long res[N];

void go(int v, int p) {
    sz[v] = 0;
    for (int nxt : g[v]) {
        if (nxt == p) continue;
        go(nxt, v);
        sz[v] += sz[nxt];
        ans *= ifact[sz[nxt]];
        ans %= MOD;
        part[v] *= ifact[sz[nxt]];
        part[v] %= MOD;
    }
    ans *= fact[sz[v]];
    ans %= MOD;
    part[v] *= fact[sz[v]];
    part[v] %= MOD;
    sz[v]++;
}

int n;

void go2(int v, int p) {
    res[v] = ans;

    for (int nxt : g[v]) {
        if (nxt == p) continue;

        long long opv = part[v];
        long long opn = part[nxt];
        long long osv = sz[v];
        long long osn = sz[nxt];
        long long oa = ans;

        ans *= inv(part[v]);
        ans %= MOD;
        ans *= inv(part[nxt]);
        ans %= MOD;

        //recalc part[v] and part[nxt]
        part[v] = part[v] * ifact[sz[v]-1] % MOD;
        part[v] = part[v] * fact[sz[nxt]] % MOD;
        part[nxt] = part[nxt] * ifact[sz[nxt]-1] % MOD;
        //recalc sz[v] ans sz[nxt]
        int nv = n - sz[nxt];
        sz[nxt] = n;
        sz[v] = nv;
        part[v] = part[v] * fact[sz[v]-1] % MOD;
        part[nxt] = part[nxt] * fact[sz[nxt]-1] % MOD;
        part[nxt] = part[nxt] * ifact[sz[v]] % MOD;

        ans *= part[v];
        ans %= MOD;
        ans *= part[nxt];
        ans %= MOD;

        go2(nxt, v);

        part[v] = opv;
        part[nxt] = opn;
        sz[v] = osv;
        sz[nxt] = osn;
        ans = oa;
    }
}

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

    fact[0] = fact[1] = 1;
    ifact[0] = ifact[1] = 1;
    for (int i = 2; i < N; i++) {
        fact[i] = fact[i-1] * i % MOD;
        ifact[i] = inv(fact[i]);
    }

    cin >> n;
    for (int j = 0; j < n-1; j++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for (int i = 0; i < n; i++) part[i] = 1;
    go(0, -1);

    go2(0, -1);

    for (int i = 0; i < n; i++) {
        cout << res[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 20980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  string S;
  cin >> S;
  for (int i = 0; i < int(S.size()); i += 2) {
    cout << S[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 592
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
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 NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

n=I()
t=[0]*102
for i in range(100):
    for j in range(100):
        t[min(101,4*i+7*j)]=1

print(['No','Yes'][t[n]])




Measured memory_bytes: 39788
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		int a = sc.nextInt();
		int b = sc.nextInt();
		int one = a-b;
		int two = a+b;
		int three = a*b;
		int four = Math.max(one,two);


		System.out.println(Math.max(three,four));

	}
}


Measured memory_bytes: 24276
# ノイローゼなりかけたので答え見た
# unionfind使うのはわかったけど与えられた配列とどうやって合わせて実装するかわからずさらにノイローゼに


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

arr = list(map(lambda x: int(x) - 1, input().split()))
par = [i for i in range(n)]


def root(i):
    if i == par[i]:
        return i
    else:
        _i = root(par[i])
        par[i] = _i
        return _i


def union(x, y):
    x, y = root(x), root(y)
    if x != y:
        # yの親をxにする
        par[y] = x


def same(nx, ny):
    return root(nx) == root(ny)


for _ in range(m):
    x, y = map(lambda x: int(x) - 1, input().split())
    union(x, y)

ans = 0
for i in range(n):
    if same(i, arr[i]):
        ans += 1
print(ans)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
int main(){
  ll k,x; cin >> k >> x;
  ll maxx = 1000000;
  ll minx = -1*maxx;
  for(ll i=minx; i<=maxx; i++){
    if(x-k<i&&i<x+k) cout << i << " ";
  }
  return 0;
}


Measured memory_bytes: 256
use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::collections::vec_deque::VecDeque;
use std::i64::MAX;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.parse::<usize>();
    let l = sc.parse::<i64>();
    let t = sc.parse::<i64>();

    let mut x: Vec<i64> = vec![0; n];
    let mut w: Vec<usize> = vec![0; n];

    for i in 0..n {
        x[i] = sc.parse::<i64>();
        w[i] = sc.parse::<usize>();
    }

    let mut cross_count: Vec<i64> = vec![0; n];
    for i in 1..n {
        let w0 = w[0];
        let wi = w[i];
        if w0 == wi {
            continue;
        }

        let interval;
        if w0 == 1 {
            interval = x[i] - x[0];
        } else {
            interval = x[0] + l - x[i];
        }

        if interval > t * 2 {
            continue;
        }

        let time = t * 2 - interval;
        cross_count[i] = time / l + 1;
        if time % l == 0 && w[0] == 1 {
            cross_count[i] -= 1;
        }
    }

    let count_sum: i64 = cross_count.iter().sum::<i64>() % (n as i64);
    let position;
    let num;
    if w[0] == 1 {
        position = (x[0] + t) % l;
        num = count_sum;

    } else {
        position = (x[0] - (t % l) + l) % l;
        num = (n as i64) - count_sum;
    }

    let mut positions: Vec<i64> = Vec::new();
    for i in 0..n {
        let p;
        if w[i] == 1 {
            p = (x[i] + t) % l;
        } else {
            p = (x[i] - (t % l) + l) % l;
        }
        positions.push(p);
    }

    positions.sort();

    let mut a = 0;
    for i in 0..n {
        if positions[i] == position {
            a = i;
            break;
        }
    }

    let mut ans: Vec<i64> = vec![0;n];
    for i in 0..n {
        let idx = (i + num as usize) % n;
        let p = (a + i as usize) % n;
        ans[idx] = positions[p];
    }

    for a in &ans {
        println!("{}", a);
    }

}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

Measured memory_bytes: 11388
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;


int main()
{
    int R[200000]={0}, n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>R[i];
    int minv = R[0];
    int maxv = -2000000000;

    for(int i=1; i<n; i++)
    {
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }

    cout<<maxv<<endl;





    return 0;
}

Measured memory_bytes: 3876
#include <stdio.h>

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

  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a+b > c+d)
  {
    printf("Left\n");
  }
  else if(a+b == c+d)
  {
    printf("Balanced\n");
  }
  else
  {
    printf("Right\n");
  }

  return 0;
}

Measured memory_bytes: 128
N, K = list(map(int, input().split()))
C = [0]*(10**5+1)
S=set()
for _ in range(N):
    a, b = list(map(int, input().split()))
    C[a] += b
    S.add(a)

L = list(S)
L.sort()
i = 0
ct = C[L[0]]
while ct < K:
    i += 1
    ct += C[L[i]]
print(L[i])


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  string s,t; cin >> s >> t;
  vector<char> x(s.size()),y(t.size());
  rep(i,s.size()) x[i]=s[i];
  rep(i,t.size()) y[i]=t[i];
  sort(all(x));
  sort(y.rbegin(),y.rend());
  string u,v;
  rep(i,s.size()) u+=x[i];
  rep(i,t.size()) v+=y[i];
  if(u<v) cout << "Yes";
  else cout << "No";
  cout << endl;
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    S = input().strip("\n")
    T = input().strip("\n")
    DP = [0] * N
    mod = 7 + 10 ** 9
    if S[0] == T[0]: DP[0] = 3
    else: DP[0] = 6

    for i in range(1, N):
        if S[i] == S[i-1]: #ドミノが横向き
            DP[i] = DP[i-1]
        else: #ドミノの境目
            if S[i-1] == T[i-1]: #左のドミノが縦向き
                DP[i] = (2 * DP[i-1]) % mod
            else: #左のドミノが横向き
                if S[i] == T[i]: #自身は縦向き
                    DP[i] = DP[i-1]
                else: #横向き
                    DP[i] = (3 * DP[i-1]) % mod
    print(DP[N-1])


    return  0

if __name__ == "__main__":
    solve()

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int p[8], q[8], a[8];
    for(int i=0;i<n;++i) cin >> p[i];
    for(int i=0;i<n;++i) cin >> q[i];

    int ord = 0, x, y;
    iota(a, a+n, 1);
    do{
        ++ord;
        bool flg[2] = { true, true };
        for(int i=0;i<n;++i){ if(p[i] != a[i]){ flg[0] = false; break; } }
        for(int i=0;i<n;++i){ if(q[i] != a[i]){ flg[1] = false; break; } }
        if(flg[0]) x = ord;
        if(flg[1]) y = ord;
    }while(next_permutation(a, a+n));

    cout << abs(x-y) << endl;
    return 0;
}

Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer(16) :: h,w,a,b,i,j,c1,c2,ans
integer(16),parameter :: intm = 1000000007
integer(16),allocatable :: k(:),k_r(:)

read(*,*) h,w,a,b
allocate(k(0:h+w-2),k_r(0:h+w-2))

k(0) = 1
k_r = 1

do i = 1, h+w-2
  k(i) = mod(k(i-1)*i,intm)
end do

do i = 1, h+w-2
  k_r(i) = pow(k(i),intm-int(2,16))
end do

ans = 0
do i = b, w-1
  c1 = mod(k(h-a-1+i)*k_r(i)*k_r(h-a-1),intm)
  c2 = mod(k(a+w-i-2)*k_r(w-1-i)*k_r(a-1),intm)
  ans = mod(ans+c1*c2,intm)
end do

print'(i0)', ans

contains
recursive integer(16) function pow(x,n) result(ret)
  implicit none
  integer(16) :: x,n
  if ( n == 0 ) then
    ret = 1
  else if ( n == 1 ) then
    ret = mod(x,10**9+7)
  else if ( mod(n,2) == 0 ) then
    ret = mod((pow(x,n/2))**2,10**9+7)
  else
    ret = mod((pow(x,n/2))**2*x,10**9+7)
  end if
end function pow

END PROGRAM ATCODER


Measured memory_bytes: 6528
class Dice:	
	def __init__( self, nums ):
		self.face = nums
	
	def rolltoTopIndex( self, faceindex ):	
		if faceindex == 1:
			self.roll( "N" )
		elif faceindex == 2:
			self.roll( "W" )
		elif faceindex == 3:
			self.roll( "E" )
		elif faceindex == 4:
			self.roll( "S" )
		elif faceindex == 5:
			self.roll( "NN" )
	
	def roll( self, actions ):
		for act in actions:
			t = 0
			if act == "E":
				t =   self.face[0]
				self.face[0] =   self.face[3]
				self.face[3] =   self.face[5]
				self.face[5] =   self.face[2]
				self.face[2] = t
			elif  act == "N":
				t =   self.face[0]
				self.face[0] =   self.face[1]
				self.face[1] =   self.face[5]
				self.face[5] =   self.face[4]
				self.face[4] = t
			elif  act == "S":
				t =  self.face[ 0]
				self.face[0] =  self.face[4]
				self.face[4] =  self.face[5]
				self.face[5] =  self.face[1]
				self.face[1] = t	
			elif  act == "W":
				t =  self.face[0]
				self.face[0] =  self.face[2]
				self.face[2] =  self.face[5]
				self.face[5] =  self.face[3]
				self.face[3] = t	
			elif  act == "M":
				t =  self.face[1]
				self.face[1] =  self.face[2]
				self.face[2] =  self.face[4]
				self.face[4] =  self.face[3]
				self.face[3] = t

def isDiffDice( dice1, dice2 ):
	diceface = dice2.face
	cnt = 0
	for i in range( 6 ):
		if dice1.face[0] == dice2.face[i]:
			dice2.rolltoTopIndex( i )
			for j in range( 1, 5 ):
				if dice1.face[1] == dice2.face[1]:
					cnt = 0
					for k in range( 6 ):
						if dice1.face[k] == dice2.face[k]:
							cnt += 1
					if cnt == 6:
						break
				dice2.roll( "M" )
		if cnt == 6:
			break
		dice2.face = diceface
			
	if cnt == 6:
		return False
	else:
		return True


n = int( input( ) )
dices = [ Dice( [ int( val ) for val in input( ).split( " " ) ] ) for i in range( n ) ]

isdiff = True
for i in range( 0, n-1 ):
	for j in range( i+1, n ):
		if not isDiffDice( dices[i], dices[j] ):
			print( "No" )
			isdiff = False
			break
	if not isdiff:
		break

if isdiff:
	print( "Yes" )

Measured memory_bytes: 6864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		int flag = 0;
		for(int i=0;i<a.length();i++) {
			if(i%2==0) {
				if(a.charAt(i)!='h') {
					flag = 1;
					break;
				}
			}else {
				if(a.charAt(i)!='i') {
					flag = 1;
					break;
				}
			}
		}
		if(a.length()%2!=0) {
			flag=1;
		}
		if(flag==1) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}


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

vector<pair<int,int> > v[6005],v2[6005];
map<string,int> mp;
int mpn,n,m,k;
bool c[6005];
unsigned dis[6005];
char a[20];
int b[305];
queue<int> q;

inline int s2i(string x)
{
    if(!mp.count(x))
        return mp[x]=mpn++;
    return mp[x];
}

void spfa(int st)
{
    int i,j,x,y;
    memset(dis,-1,sizeof(dis));
    dis[st]=0;
    q.push(st);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        for(i=0,j=v[x].size();i<j;i++)
        {
            y=v[x][i].first;
            if(dis[x]+v[x][i].second>(unsigned)k||dis[x]+v[x][i].second>dis[y])
                continue;
            dis[y]=dis[x]+v[x][i].second;
            q.push(y);
        }
    }
    for(i=0;i<mpn;i++)
        if(c[i]&&i!=st&&dis[i]!=-1)
            v2[st].push_back(make_pair(i,dis[i]));
}

int main()
{
    int st,ed,i,j,x,y,w;
    while(~scanf("%d%d%d",&n,&m,&k)&&(n+m+k))
    {
        memset(c,0,sizeof(c));
        mpn=0;k*=10;
        scanf("%s",a);st=s2i(a);
        scanf("%s",a);ed=s2i(a);
        for(i=0;i<n;i++)
        {
            scanf("%s",a);x=s2i(a);
            scanf("%s",a);y=s2i(a);
            scanf("%d",&w);
            v[x].push_back(make_pair(y,w));
            v[y].push_back(make_pair(x,w));
        }
        for(i=0;i<m;i++)
        {
            scanf("%s",a);
            c[b[i]=s2i(a)]=1;
        }
        c[st]=c[ed]=1;
        spfa(st);
        for(i=0;i<m;i++)
            spfa(b[i]);
        memset(dis,-1,sizeof(dis));
        dis[st]=0;
        q.push(st);
        while(!q.empty())
        {
            x=q.front();
            q.pop();
            for(i=0,j=v2[x].size();i<j;i++)
            {
                y=v2[x][i].first;
                if(dis[x]+v2[x][i].second<dis[y])
                {
                    dis[y]=dis[x]+v2[x][i].second;
                    q.push(y);
                }
            }
        }
        printf("%d\n",dis[ed]);
        for(i=0;i<mpn;i++)
            v[i].clear(),v2[i].clear();
        mp.clear();
    }
	return 0;
}

Measured memory_bytes: 4472
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m): uf.union(*map(lambda x: int(x)-1, input().split())) # unite
ans = 0
for i in range(n): ans = max(ans, uf.size(i))
print(ans)

Measured memory_bytes: 84016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
double a,b,h;
cin>>a>>b>>h;
cout<<(a+b)*h/2<<endl;
    return 0;
}

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

typedef long long ll;
const ll MOD = 1e9+7;

int dp[3005][3005],dir[3005][3005];
string s,t;
int n,m;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>s>>t;
    n=s.length();
    m=t.length();

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
                dir[i][j]=0;
            }else{
                if(dp[i-1][j]<dp[i][j-1])dir[i][j]=1;
                else dir[i][j]=2;
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    int i=n,j=m;
    vector<char>ans;

    while(true){
        if(!i||!j)break;
        if(s[i-1]==t[j-1]){
            ans.push_back(s[i-1]);
            i--;
            j--;
        }else{
            if(dp[i-1][j]>dp[i][j-1])i--;
            else j--;
        }
    }

    reverse(ans.begin(),ans.end());
    for(auto e:ans)cout<<e;


    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <deque>

using namespace std;

int main()
{
    long long q;
    cin>>q;
    deque <int> aha;
    while(q--)
    {
         int a;
         cin>>a;
         if(a==0)
         {
             int d;
             long long x;
             cin>>d>>x;
             if(d==0)
             {
                 aha.push_front(x);
             }
             else
             {
                 aha.push_back(x);
             }
         }
         else if(a==1)
         {
             long long p;
             cin>>p;
             cout<<aha[p]<<endl;
         }
         else
         {
             int d;
             cin>>d;
             if(d==0)
             {
                 aha.pop_front();
             }
             else
             {
                 aha.pop_back();
             }
         }
    }
    return 0;
}



Measured memory_bytes: 4612
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int n;cin>>n;
  int a[n];
  int b[n];
  rep(i, n){
    cin>>a[i]>>b[i];
  }
  vector<tuple<int, int, int>> x;
  rep(i, n){
    x.pb(make_tuple(a[i] + b[i], a[i], b[i]));
  }
  sort(all(x));
  reverse(all(x));
  dump(x);

  int T = 0;
  int A = 0;
  rep(i, n){
    if (i%2) A+= get<2>(x[i]);
    else T += get<1>(x[i]);
  }
  dump(T, A);
  cout << T - A << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 6516
#include <iostream>
#include <string>

int N;
int p[5];
int main()
{
    std::cin >> N;
    for (int i = 0; i < N; ++i)
    {
        std::string temp;
        std::cin >> temp;
        switch (temp[0])
        {
        case 'M':
            ++p[0];
            break;
        case 'A':
            ++p[1];
            break;
        case 'R':
            ++p[2];
            break;
        case 'C':
            ++p[3];
            break;
        case 'H':
            ++p[4];
            break;
        }
    }

    long long ans = 0;
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 2; ++j)
            for (int k = 0; k < 2; ++k)
                for (int l = 0; l < 2 && i + j + k + l < 4; ++l)
                    for (int m = 0; m < 2 && i + j + k + l + m < 4; ++m)
                    {
                        if (i + j + k + l + m != 3)
                            continue;
                        long long res = 1;
                        if (i == 1)
                            res *= p[0];
                        if (j == 1)
                            res *= p[1];
                        if (k == 1)
                            res *= p[2];
                        if (l == 1)
                            res *= p[3];
                        if (m == 1)
                            res *= p[4];
                        ans += res;
                    }

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int n, a;
	cin >> n >> a;
	while (n >= 500) {
		n -= 500;
	}
	if (n <= a)print("Yes"); else print("No");





	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int x;cin>>x;
    if(x>=30) cout<<"Yes\n";
    else cout<<"No\n";
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] B = new int[N];

    for(int i = 1; i < N; i++) {
      B[i] = sc.nextInt();
    }

    sc.close();

    int[] A = new int[N+1];

    A[N] = B[N-1];

    for (int i = N-1; 1 < i; i--) {
      if (B[i-1] <= B[i]) {
        A[i] = B[i-1];
      } else {
        A[i] = B[i];
      }
    }

    A[1] = B[1];

    int max = 0;

    for (int i = 1; i < N+1; i++) {
      max += A[i];
    }

    System.out.println(max);

  }

}


Measured memory_bytes: 21844
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut edges = vec![];

    let mut left = 0;
    let mut right = 0;
    for i in 0..n {
        let a: u64 = sc.read();
        let b: u64 = sc.read();
        left += a;
        right += b;
        edges.push((a, i, true));
        edges.push((b, i, false));
    }
    edges.sort();

    let mut ans = cmp::min(left, right);

    let mut count = vec![0; n];
    let mut sum = 0;
    for i in 0..n {
        let (cost, i, _) = edges[i];
        count[i] += 1;
        sum += cost;
    }

    if count.iter().any(|&x| x != 1) {
        println!("{}", cmp::min(ans, sum));
        return;
    }

    if edges[n - 1].1 != edges[n].1 {
        sum -= edges[n - 1].0;
        sum += edges[n].0;
        println!("{}", cmp::min(ans, sum));
        return;
    }

    ans = cmp::min(ans, sum - edges[n - 2].0 + edges[n].0);
    ans = cmp::min(ans, sum - edges[n - 1].0 + edges[n + 1].0);
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 13432
#include<bits/stdc++.h>
using namespace std;
int fa[100007];
int find_(int x){
    if(fa[x]!=x)
        return fa[x]=find_(fa[x]);
    return fa[x];
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)
        fa[i]=i;
    for(int i=1;i<=m;++i){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        int xx=find_(x);
        int yy=find_(y);
        if(xx!=yy)
            fa[xx]=yy;
    }
    int cnt=0;
    for(int i=1;i<=n;++i){
        if(fa[i]==i)
            cnt++;
    }
    printf("%d",cnt);
    return 0;
}



Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  int n, i, x, d, c = 1, s = 0;
  cin >> n >> x;
  int a[n], b[n];
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    s = s + a[i];
    if (s <= x) c++;
  }
  cout << c << endl;
}

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

int euclidean_gcd(int a, int b){
    if(a<b)return euclidean_gcd(b,a);
    int r;
    while(r=a%b){
        a=b;
        b=r;
    }
    return b;
}

int main(){
    int n; cin>>n;
    int a[100010];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=a[0];
    for(int i=1;i<n;i++){
        ans=euclidean_gcd(ans, a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


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


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


n, i = inl()
print(n - i+ 1)




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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;

void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	int n, c, k;
	cin >> n >> c >> k;
	VI v(n);

	rep(i, n) cin >> v[i];

	sort(all(v));

	int num = 0, ans = 0, lim = 0;
	int i = 0;
	while(i < n) {
		lim = v[i] + k;
		num = 1;
		i++;
		while (i < n && v[i] <= lim && num < c) {
			num++;
			i++;
		}
		ans++;
	}
	cout << ans << endl;
}




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


	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;

int main(){
	int N;
	cin >> N;
	int d[N];
	char s[2][N];
	for(int i=0; i<2; i++){
		for(int j=0; j<N; j++){
			cin >> s[i][j];
		}
	}
	for(int i=0; i<N; i++){
		d[i] = 0;
		if(s[0][i] == s[1][i]) d[i] = 1;
		if(i>0){
			if(s[0][i] == s[0][i-1]) d[i] = 2;
		}
	}
	long long int dp[N];
	if(d[0]){
		dp[0] = 3;
		for(int i=1; i<N; i++){
			if(d[i] == 1){
				if(d[i-1] == 1){
					dp[i] = (dp[i-1]*2)%mod;
				}else{
					dp[i] = dp[i-1];
				}
			}
			if(d[i] == 2){
				if(d[i-2] == 1){
					dp[i] = (dp[i-2]*2)%mod;
				}else{
					dp[i] = (dp[i-2]*3)%mod;
				}
			}
		}
	}else{
		dp[1] = 6;
		for(int i=2; i<N; i++){
			if(d[i] == 1){
				if(d[i-1] == 1){
					dp[i] = (dp[i-1]*2)%mod;
				}else{
					dp[i] = dp[i-1];
				}
			}
			if(d[i] == 2){
				if(d[i-2] == 1){
					dp[i] = (dp[i-2]*2)%mod;
				}else{
					dp[i] = (dp[i-2]*3)%mod;
				}
			}
		}
	}
	cout << dp[N-1] << endl;
	return 0;
}

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

int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x >= r && (x+r) <= w && y >= r && (y+r) <= h){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
using namespace std;
int main(int a, char *arr[])
 {
 
        int n, k, sum = 0;
        cin >> n >> k;
        int fruits[n] = {};
 
        for(int i = 0; i < n; i++) {
                cin >> fruits[i];
        }
 
        sort(&fruits[0], &fruits[n]);
        for(int i = 0; i < k; i++) 
{
                sum += fruits[i];
        }
 
        cout << sum << endl;
        return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rep(i,n) for (int i = 0; i < (n); ++i)

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

    vector<int> mod_zero;
    vector<int> mod_half;

    for ( int i = 1; i <= n; i++ ) {
        if ( i % k == 0 ) {
            mod_zero.push_back(i);
        }
        else if ( k % 2 == 0 && i % k == k / 2 ) {
            mod_half.push_back(i);
        }
    }

//    printf("%d %d\n", mod_zero.size(), mod_half.size());

//    rep(i, mod_zero.size()) {
//        cout << mod_zero[i] << endl;
//    }
//    rep(i, mod_half.size()) {
//        cout << mod_half[i] << endl;
//    }

    cout << mod_zero.size() * mod_zero.size() * mod_zero.size() + mod_half.size() * mod_half.size() * mod_half.size() << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    if(n&1){cout<<"No";return 0;}
    n/=2;
    if(s.substr(0,n)==s.substr(n,n))cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N;
  cin >> N;
  int A[N];
  int Num[N+10] = {0};
  for (int i = 1; i < N; ++i) {
    cin >> A[i];
    ++Num[A[i]-1];
  }
  for (int i = 0; i < N; ++i) {
    printf("%d\n", Num[i]);
  }
}

Measured memory_bytes: 5256
// Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1){
		prime[0] = false;
	}
	if(n>=2){
		prime[1] = false;
	}

	for(int i=2; i<n; i++){
		prime[i] = true;
	}

	for(int i=2; i*i<n; i++){
		if(!prime[i])
			continue;

		for(int j=i+i; j<n; j+=i){
			prime[j] = false;
		}
	}
}

int main()
{
	bool P[10001];
	eratos(P, 10001);

	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		for(int i=n; i>=5; i--){
			if(P[i]&&P[i-2]){
				cout << i-2 << ' ' << i << '\n';
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 872
a, b = map(int, input().split())

def f(H, W):
    tmp = 100000000000
    for h in range(1, H):
        s = []
        s.append(h * W)
        s.append((H - h) // 2 * W)
        s.append((((H - h) // 2) + (H - h) % 2) * W)
        s.sort()
        tmp = min(tmp, s[2] - s[0])
        s = []
        s.append(h * W)
        s.append(W // 2 * (H - h))
        s.append((W // 2 + W % 2) * (H - h))
        s.sort()
        tmp = min(tmp, s[2] - s[0])
    return tmp

ans = min(f(a, b), f(b, a))

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int f[310][310],sf[310][310],C[310][310];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),k=gi()+1,mod=gi();
	C[0][0]=1;
	for(int i=1;i<=n;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int i=1;i<=k;++i)f[1][i]=1,sf[1][i]=k-i+1;
	for(int i=2;i<=n+1;++i)
		for(int j=k;j;--j){
			for(int o=1;o<i;++o)f[i][j]=(f[i][j]+1ll*C[i-2][o-1]*f[i-o][j]%mod*sf[o][j+1])%mod;
			sf[i][j]=(f[i][j]+sf[i][j+1])%mod;
		}
	printf("%d\n",f[n+1][1]);
	return 0;
}


Measured memory_bytes: 1408
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#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 ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())

    if N == 1:
        print('Hello World')
    else:
        A = int(input())
        B = int(input())
        print(A + B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64364
package main

import "fmt"

var (
	xs []int
	s  [][]int
	p  []int
)

func dfs(cur int, sw int) int {
	if cur != 0 {
		xs[cur-1] = sw
	}
	if cur == len(xs) {
		for i := range s {
			var light int
			for j := range s[i] {
				light += xs[s[i][j]-1]
			}
			if light%2 != p[i] {
				return 0
			}
		}
		return 1
	}
	var sum int
	sum += dfs(cur+1, 0)
	sum += dfs(cur+1, 1)
	return sum
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	s = make([][]int, m)
	var k int
	for i := range s {
		fmt.Scan(&k)
		s[i] = make([]int, k)
		for j := 0; j < k; j++ {
			fmt.Scan(&s[i][j])
		}
	}
	p = make([]int, m)
	for i := range p {
		fmt.Scan(&p[i])
	}
	xs = make([]int, n)
	fmt.Println(dfs(0, 0))
}


Measured memory_bytes: 512
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a = input().rstrip()
    print(chr(ord(a)+1))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024