akhauriyash/Code-Regression huggingface dataset:
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
	using namespace std;

	int n;
	cin >> n;

	vec<int> B(n - 1);
	for (auto& e : B)
		cin >> e;

	int ans{B.front() + B.back()};

	// cout << ans << endl;

	for (int i = 0; i < n - 2; ++i)
	{
		ans += min(B[i], B[i + 1]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $word);

$arr = str_split($word);

$a = array();
$b = array();

for($i=0;$i<count($arr);$i++) {
  if($i % 2 == 0) {
    array_push($a, $arr[$i]);
  } else {
    array_push($b, $arr[$i]);
  }
}

if(in_array('L', $a) || in_array('R', $b)) {
  echo 'No';
} else {
  echo 'Yes';
}


Measured memory_bytes: 4728
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a>b and b>c:
            print(c,b,a)
if a<b and b<c or a==b and a<c or a<b and b==c:
            print(a,b,c)
if(c>a and a>b or a>b and a==c):
            print(b,a,c)
if(b>a and a>c or a==b and a>c):
            print(c,a,b)
if(b>c and c>a or a<b and a==c):
            print(a,c,b)
if(a>c and c>b or a>b and b==c):
            print(b,c,a)
if(a==b and b==c):
            print(a,b,c)
        



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

typedef struct{
  char name[33];
  int num;
}WORD;

int main(void){
  WORD word[512];
  int i,j = 0,max_len = 511, max_num = 511;
  char str[33];

  word[511].name[0] = ' ';
  word[511].name[1] = '\0';
  word[511].num = 0;

  while(scanf("%s",str) != EOF){
    for(i=0;i<j;i++){
      if(strcmp(str,word[i].name) == 0){
	word[i].num++;
	break;
      }
    }

    if(i==j){
      strcpy(word[j].name,str);
      j++;
      word[j].num++;
    }
  }

  for(i=0;i<j;i++){
    if(strlen(word[max_len].name) < strlen(word[i].name)){
      max_len = i;
    }

    if(word[max_num].num < word[i].num){
      max_num = i;
    }
  }

  printf("%s %s\n",word[max_num].name,word[max_len].name);

  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define debug cout << "Ok" << endl;

using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	int n;

	cin >> n;

	if(n %2) n++;

	cout << n/2 << endl;
	
	return 0;
}

Measured memory_bytes: 3628
A=[]
for _ in range(3):
    A.append(int(input()))
a=A[0]
b=A[1]
c=A[2]
x=int(input())
count=0
for p in range(a+1):
    for q in range(b+1):
        for r in range(c+1):
            if 500*p+100*q+50*r==x:
                count=count+1
            else:
              count=count
print(count)

Measured memory_bytes: 3064
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx,avx2,fma")

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

#define ll long long
#define ull unsigned long long
#define dd double
#define ld long double
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define sd(n) scanf("%lf", &n)
#define pll pair <ll, ll>
#define pii pair <int, int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define inf (1LL << 62)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define for1(i, stop) for(ll i = 1; i <= stop; ++i)
#define for0(i, stop) for(ll i = 0; i < stop; ++i)
#define rep1(i, start) for(ll i = start; i >= 1; --i)
#define rep0(i, start) for(ll i = (start-1); i >= 0; --i)
#define ms(n, i) memset(n, i, sizeof(n))
#define casep(n) printf("Case %lld:", ++n)
#define pn printf("\n")
#define pf printf
#define EL '\n'
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll sz = 105;
ll ara[sz];

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

    for1(i, n) sl(ara[i]);
    sort(ara+1, ara+n+1);

    ll ans = 0;
    for1(i, n) {
        for(ll j = i+1; j <= n; j++) {
            if(ara[j] == ara[i])
                continue;

            for(ll k = j+1; k <= n; k++) {
                if(ara[k] == ara[j])
                    continue;
                if(ara[i] + ara[j] <= ara[k])
                    break;

                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#define PI 3.1415926535 / 180
using namespace std;
int main(){
	int a,b,h,m; cin>>a>>b>>h>>m;	
	double  radH = h * 30 + m/2.0 ,radm = m * 6;
	double rad = abs(radH - radm);
	if(rad > 180) rad = 360 - rad;
	double ret = sqrt(a*a + b*b - 2*a*b*cos(rad * PI));
	printf("%.9f",ret);
}

Measured memory_bytes: 3600
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let () =
  read_int ()
  |> flip (for_iter 0) (fun _ -> let [l; r] = read_ints 2 in r - l + 1)
  |> List.fold_left (+) 0
  |> printf "%d\n"



Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    k=int(input())
    p,r=divmod(k,50)
    L=100+p-r
    R=49+p-r
    ans=[L]*r+[R]*(50-r)
    print(50)
    print(*ans)
main()

Measured memory_bytes: 3064
<?php
fscanf(STDIN,'%d%d%d',$N,$A,$B);
$sum=0;
for ($i=1; $i <=$N ; $i++) { 
    # code...
    $Z=str_split($i);
    $ketasum=array_sum($Z);
    if($ketasum>=$A and $ketasum<=$B){
        $sum+=$i;
    }
}
echo $sum;
echo "\n";
?>

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

int main() {
    int64_t N, K; cin >> N >> K;
    if(N < K) {
        N = min(N, K - N);
        cout << N << '\n';
    } else {
        N %= K;
        N = min(N, K - N);
        cout << N << '\n';
    }
    return 0;
}


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

constexpr int MAX_NM = 50;

bool solve(int i, int j);

std::string A[MAX_NM], B[MAX_NM];
int n, m;

int main(){
	std::ios::sync_with_stdio(false);

	std::cin >> n >> m;

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


	for(int i = 0; i < m; ++i){
		std::cin >> B[i];
	}

	bool ans = false;
	for(int i = 0; i <= (n - m); ++i){
		for(int j = 0; j <= (n - m); ++j){
			if(solve(i, j)){
				ans = true;
			}	
		}
	}

	if(ans){
		std::cout << "Yes\n";
	}
	else{
		std::cout << "No\n";
	}

	return 0;
}

bool solve(int i, int j){
	for(int k = 0; k < m; ++k){
		for(int l = 0; l < m; ++l){
			if(A[i + k][j + l] != B[k][l]){
				return false;
			}
		}
	}
	return true;
}


Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N;
    cin>>N;

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

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

    vector<int>C(N-1);
    for(int i=0;i<N-1;i++)cin>>C[i];

    int ans=0;
    for(int i=0;i<N;i++){
        ans+=B[A[i]];
        if(i>0&&A[i]==A[i-1]+1){
            ans+=C[A[i-1]];
        }
    }

    cout<<ans<<endl;
}




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

int main(void){

  char s[3];

  if(scanf("%s",s)==1){}
  if(!strcmp(s,"ABC")){
    printf("ARC\n");
  }else if(!strcmp(s,"ARC")){
    printf("ABC\n");
  }

  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

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 (a > b) {
		a = b;
		return true;
	}
	return false;
}

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here

	int n; cin >> n;
	int idx[55][30]; //[i番目][a-z]
	memset(idx, 0, sizeof idx);
	string s;
	rep(i, n)
	{
		cin >> s;
		rep(j, s.length()) idx[i][s[j] - 'a']++;
	}

	int minidx[30];
	memset(minidx, 10000, sizeof minidx);
	rep(j, 27)rep(i, n) minidx[j] = min(minidx[j], idx[i][j]);

	rep(i, 27) rep(s,minidx[i])cout<<(char)(i+'a');
	cout << endl;



	return 0;

}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

int main(){
    int N;
    cin >> N;
    ll ans = 1000; //所持金
    ll num = 0; //株
    vector<ll> A(0,0);
    REP(i,N){
        ll a;
        cin >> a;
        A.push_back(a);
    }

    vector<ll> B(0,0);
    vector<ll> S(0,0);

    int down_up = 0; //up = 1,down = 0;
    int start = 0;
    REP(i,N-1){
        if(A[i]<A[i+1]){
            start = i;
            down_up = 1;
            B.push_back(i);
            break;
        }else if(A[i]>A[i+1]){
            start = i;
            down_up = 0;
            S.push_back(i);
            break;
        }
    }

    for(int i=start;i<N-1;i++){
        if(down_up == 1){
            if(A[i]>A[i+1]){
                down_up = 0;
                S.push_back(i);
            }
            if(i==N-2 && A[i] <= A[i+1]){
                S.push_back(i+1);
            }
        }else if(down_up == 0){
            if(A[i]<A[i+1]){
                down_up = 1;
                B.push_back(i);
            }

            if(i==N-2 && A[i] < A[i+1]){
                S.push_back(i+1);
            }
        }
    }

    if(S.size() == 0 || B.size() == 0){
        ans = ans;
    }
    else if(S[0]<B[0]){
        for(int i=0;i<S.size()-1;i++){
            num = ans/A[B[i]];
            ans -= num * A[B[i]];
            ans += num * A[S[i+1]];
        }
    }else{
        for(int i=0;i<S.size();i++){
            num = ans/A[B[i]];
            ans -= num * A[B[i]];
            ans += num * A[S[i]];
        }
    }

    cout << ans << endl;

}


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

//vector<int>のサイズnと要素の入力
vector<int> input_vector()
{
    int n;
    scanf("%d", &n);
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &vec[i]);
    }
    return vec;
}

//交換回数あり任意の要素
int selection_sort(vector<int> &vec)
{
    int n = vec.size();
    int m;    //変数交換用
    int minj; //暫定的な最小値アドレス
    int count = 0;
    for (int j = 0; j < n - 1; j++)
    { //jは未ソート部分の先頭アドレス
        minj = j;
        for (int i = j + 1; i < n; i++)
        {
            if (vec[i] < vec[minj])
            {
                minj = i;
            }
        }
        if(minj!=j){
        m = vec[minj];
        vec[minj] = vec[j];
        vec[j] = m;
        count++;
        }
    }
    return count;
}

//第１引数がvectorで第２引数がサイズのvector出力
void print_vector(vector<int> &vec)
{
    int N=vec.size();
    for (int i = 0; i < N; i++)
    {
        if (i != N - 1)
        {
            printf("%d ", vec[i]);
        }
        else
        {
            printf("%d\n", vec[i]);
        }
    }
}

int main(){
    vector<int> A=input_vector();
    int count=selection_sort(A);
    print_vector(A);
    cout<<count<<endl;
}



Measured memory_bytes: 3232
using System;
using System.Linq;

namespace _0033
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                bool ret = false;
                for (int j = 0; j < Math.Pow(2,10); j++)
                {
                    bool now = true;
                    int right = -1; int left = -1;
                    {
                        int a = j;
                        for (int k = 0; k < 10; k++)
                        {
                            if (a % 2 == 0)
                            {
                                if (right > x[k]) now = false;
                                right = x[k];
                            }
                            else
                            {
                                if (left > x[k]) now = false;
                                left = x[k];
                            }
                            a /= 2;
                        }
                    }
                    if (now) ret = true;
                }
                Console.WriteLine(ret ? "YES" : "NO");
            }
        }
    }
}


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

using namespace std;
const int maxn = 2e4 + 5;
int f[maxn];
int main() {
#ifdef LDT
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(f, 63, sizeof(f));
    int h, n;
    cin >> h >> n;
    f[0] = 0;
    for (int i = 1; i <= n; ++i) {
        int a, b;
        cin >> a >> b;
        for (int i = 0; i <= h; ++i)
            f[i + a] = min(f[i + a], f[i] + b);
    }
    cout << *min_element(f + h, f + 1 + h + (int) 1e4);
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int h1, h2;
	int k1, k2;
	int a, b, c, d;
	int hanazawa_kana, hayami_saori;
	if (scanf("%d%d", &h1, &h2) != 2) return 1;
	if (scanf("%d%d", &k1, &k2) != 2) return 1;
	if (scanf("%d%d%d%d", &a, &b, &c, &d) != 4) return 1;
	hanazawa_kana = a * h1 + c * (h1 / 10) + b * h2 + d * (h2 / 20);
	hayami_saori = a * k1 + c * (k1 / 10) + b * k2 + d * (k2 / 20);
	if (hanazawa_kana > hayami_saori) {
		puts("hiroshi");
	} else if (hanazawa_kana < hayami_saori) {
		puts("kenjiro");
	} else {
		puts("even");
	}
	return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int> > data(M, vector<int>(2));
    for (int i=0; i<M; i++) {
        for (int j=0; j<2; j++) {
            cin >> data.at(i).at(j);
        }
    }
    vector<int> cnt(N);
    for (int i=0; i<M; i++) {
        for (int j=0; j<2; j++) {
            cnt.at(data.at(i).at(j) - 1)++;
        }
    }
    for (int i=0; i<N; i++) {
        cout << cnt.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n;
    int t[101]; INITA(t, 0, 100, 0);
    int m;
    int tot = 0;
    cin >> n;
    FOR(i, 1, n) {
        cin >> t[i];
        tot += t[i];
    }
    cin >> m;
    REP(i, m) {
        int p, x;
        cin >> p >> x;
        cout << tot - t[p] + x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var ab = input.split(' ').map(Number);
var a = ab[0];
var b = ab[1];

var compare = function(a, b) {
	if  (a > b) {
	    return '>';
	} else if (a < b) {
        return '<';
    } else {
        return '==';
    }
}

console.log('a ' + compare(a, b) + ' b');

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

int main () {
  int n;
  cin >> n;
  vector<int> a(n);
  long x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    x += a.at(i);
  }
  long ans;
  for (int i = n-1; i > 0; i--) {
    x -= a.at(i);
    y += a.at(i);
    if (i == n-1) ans = abs(x-y);
    else ans = min(ans, abs(x-y));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
package main

import "fmt"

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	var ans = []int{-1, -1, -1}
	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			k := n - i - j
			if i*10000+j*5000+k*1000 == y {
				ans[0] = i
				ans[1] = j
				ans[2] = k
			}
		}
	}
	for _, v := range ans {
		fmt.Printf("%v ", v)
	}
	fmt.Println()
}


Measured memory_bytes: 512
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	
	sc2(n,m);
	if(n>m)prN;
	else prY;
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;


int main() {
    long long n, b;
    cin >> n >> b;
    long long lim = (b-1);
    long long dig = 1;
    long long p = (b-1);
    while(n > lim) {
        p = p * b;
        lim = lim + p;
        dig = dig + 1;
    }
    cout << dig << "\n";
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (x1, y1, x2, y2) = readInts()

  val x3 = x2 - (y2 - y1)
  val y3 = y2 + (x2 - x1)
  val x4 = x3 - (x2 - x1)
  val y4 = y3 - (y2 - y1)

  println("$x3 $y3 $x4 $y4")
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


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

using namespace std;
using ll = long long;

ll cnt[10005];
int dp[200005][50];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    if(p==2 || p==5){
        for(int i=0;i<n;i++){
            if(i!=0){
                for(int j=0;j<p;j++){
                    dp[i][(j*10 + (s[i]-'0'))%p] += dp[i-1][j];
                }
            }
            dp[i][(s[i]-'0')%p]++;
        }
        ll ans = 0;
        for(int i=0;i<n;i++)
            ans+=dp[i][0];
        cout<<ans;
        return 0;
    }
    ll ans = 0;
    int pow_mod = 1;
    int curr_mod = 0;
    for(int i=n-1;i>=0;i--){
        curr_mod += pow_mod * (s[i]-'0');
        curr_mod %= p;
        ans += cnt[curr_mod];
        cnt[curr_mod]++;
        if(curr_mod == 0) ans++;
        pow_mod = pow_mod*10 % p;
    }
    cout<<ans;
    return 0;
}

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

struct KMP {
  int len;
  string p;
  vector<int> fail;
  KMP() {}
  KMP(string p_) : p(p_), len(p_.length()) {
    fail.resize(len + 1, -1);
    for(int i=1, j=-1; i<=len; i++) {
      while(j >= 0 and p[j] != p[i-1]) j = fail[j];
      fail[i] = ++j;
    }

    /*
    fprintf(stderr, "fail:");
    for(int i=0; i<len+1; i++) {
      fprintf(stderr, " %d", fail[i]);
    }
    fprintf(stderr, "\n");
    */
  }

  vector<int> match(string s) {
    int N = s.length();
    vector<int> occur(N);
    for(int i=0, k=0; i<N; i++) {
      // fprintf(stderr, "s = %s, i = %d, k = %d\n", s.c_str(), i, k);
      while(k >= 0 and s[i] != p[k]) k = fail[k];
      if(++k == len) {
        // fprintf(stderr, "occur: %d\n", i - len + 1);
        occur[i-len+1] = true;
      }
    }
    return occur;
  }
};

int main() {
  int N, M;
  while(cin >> N >> M, N || M) {
    vector<string> pat(N);
    vector<KMP> kmps(N);
    for(int i=0; i<N; i++) cin >> pat[i], kmps[i] = KMP(pat[i]);

    string s = "";
    for(int i=0; i<M; i++) {
      string tmp; cin >> tmp;
      s += tmp;
    }
    
    // fprintf(stderr, "before match\n");
    int len = s.length();
    vector< vector<int> > match(N);
    for(int i=0; i<N; i++) match[i] = kmps[i].match(s);

    /*
    // for debug
    for(int i=0; i<N; i++) {
      for(int j=0; j<len; j++) {
        fprintf(stderr, "%d ", match[i][j]);
      }
      fprintf(stderr, "\n");
    }
    */

    vector<int> lens(1 << N);
    for(int bit=0; bit<(1<<N); bit++) {
      for(int i=0; i<N; i++) {
        if(bit >> i & 1) lens[bit] += pat[i].length();
      }
    }

    int whole_len = lens[(1 << N) - 1], ans = 0;
    for(int i=0; i<len-whole_len+1; i++) {
      vector<int> dp(1 << N);
      dp[0] = true;
      for(int bit=0; bit<(1<<N); bit++) {
        int cur_idx = i + lens[bit];
        for(int i=0; i<N; i++) {
          if(bit >> i & 1) continue;
          int nbit = bit | (1 << i);
          if(match[i][cur_idx]) dp[nbit] |= dp[bit];
        }
      }

      if(dp[(1 << N) - 1]) {
        // fprintf(stderr, "match %d\n", i);
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3280
#include<cstdio>
using namespace std;
int main(){
	int i;
	int t;
	while(scanf("%d",&t),t){
		int n;
		scanf("%d",&n);
		for(i=0;i<n;++i){
			int p,q;
			scanf("%d%d",&p,&q);
			t-=q-p;
		}
		if(t>0)
			printf("%d\n",t);
		else
			puts("OK");
	}
	return 0;
}

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

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int f[310][310];
int dis[310][310];

int main(){
    int n = inp();
    int m = inp();
    int l = inp();
    memset(f, 0x3f, sizeof(f));
    memset(dis, 0x3f, sizeof(dis));
    for(int i = 1; i <= m; i++){
        int u = inp();
        int v = inp();
        int w = inp();
        f[u][v] = w;
        f[v][u] = w;
    }
    for(int u = 1; u <= n; u++)
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                f[i][j] = std::min(f[i][j], f[i][u] + f[u][j]);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            if(f[i][j] <= l)
                dis[i][j] = 1;
    for(int u = 1; u <= n; u++)
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                dis[i][j] = std::min(dis[i][j], dis[i][u] + dis[j][u]);
    int q = inp();
    while(q--){
        int u = inp();
        int v = inp();
        if(dis[u][v] > 1e9)
            printf("-1\n");
        else
            printf("%d\n", dis[u][v] - 1);
    }
}

Measured memory_bytes: 1408
#include<cstdio>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    pair<int,int> p[m]; 
    for(int i = 0; i < m; i++){
        scanf("%d %d", &p[i].second, &p[i].first);
    }
    sort(p, p + m);
    int ans = 0;
    int c = -1;
    for(int i = 0; i < m; i++){
        if (p[i].first <= c || p[i].second > c) {
            c = p[i].first - 1;
            ans++;
        }
        
    }
    printf("%d\n", ans);


}

Measured memory_bytes: 896
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(n: usize, a: [u64; n]);

    let a = a.into_iter().sorted().collect_vec();
    let ans = (1..n).map(|i| a[n - i / 2 - 1]).sum::<u64>();

    println!("{}", ans);
}


Measured memory_bytes: 6236
#include<stdio.h>

#define N 8
#define FREE 1
#define NOT_FREE 0

int row[N],col[N],dpos[15],dneg[15],A[N][N];
int i,j,n,r,c;

void printBoard(){
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(A[i][j] && row[i] != j)return;
    }
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void putQueen(int i){
  int j;
  if(i == N){
    printBoard();
    return;
  }

  for(j = 0; j < N; j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE)continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    putQueen(i+1);
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

int main(){
  scanf("%d",&n);

  for(i = 0; i < 15; i++){
    dpos[i] = dneg[i] = FREE;
  }

  for(i = 0; i < N; i++){
    col[i] = row[i] = FREE;
    for(j = 0; j < N; j++){
      A[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    A[r][c]=90;
  }
  putQueen(0);
  return 0;
}




Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

bool isExist[5001][5001];

int main(void){
	int n;
	
	while(cin >> n && n){
		vector<pair<int,int> > vpii;
		int ret=0;
		
		memset(isExist, false, sizeof(isExist));
		
		int x, y;
		for(int i=0;i<n;i++){
			cin >> x >> y;
			vpii.PB(MP(x,y));
			isExist[x][y] = true;
		}
		
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				int dx = vpii[j].X - vpii[i].X;
				int dy = vpii[j].Y - vpii[i].Y;
				
				if(0 <= vpii[j].X + dy && vpii[j].X + dy < 5001 &&
				0 <= vpii[j].Y - dx && vpii[j].Y - dx < 5001 &&
				0 <= vpii[i].X + dy && vpii[i].X + dy < 5001 &&
				0 <= vpii[i].Y - dx && vpii[i].Y - dx < 5001){
					if(isExist[vpii[j].X + dy][vpii[j].Y - dx] && 
					isExist[vpii[i].X + dy][vpii[i].Y - dx]){
						ret = max(ret, (dx+dy)*(dx+dy) - (dx * dy)*2);
					}
				}
				
				if(0 <= vpii[j].X + dy && vpii[j].X + dy < 5001 &&
				0 <= vpii[j].Y - dx && vpii[j].Y - dx < 5001 &&
				0 <= vpii[i].X + dy && vpii[i].X + dy < 5001 &&
				0 <= vpii[i].Y - dx && vpii[i].Y - dx < 5001){
					if(isExist[vpii[j].X + dy][vpii[j].Y - dx] && 
					isExist[vpii[i].X + dy][vpii[i].Y - dx]){
						ret = max(ret, (dx+dy)*(dx+dy) - (dx * dy)*2);
					}
				}
				
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 24000
n = int(input())
factors = {}

for i in range(2, n+1):
    p = i

    while p > 1:
        f = False
        for j in range(2, int(p**0.5)+1):
            if p % j == 0:
                if j in factors:
                    factors[j] += 1
                else:
                    factors[j] = 1

                p //= j
                f = True
                break

        if not f:
            if p in factors:
                factors[p] += 1
            else:
                factors[p] = 1
            break

ans = 1
for f in factors.values():
    ans *= f+1

print(ans % 1000000007)

Measured memory_bytes: 9336
#include <stdio.h>
int main()
{
    int n;
    int a[4][3][10] = {0};
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int b, f, r, v;
        scanf("%d %d %d %d", &b, &f, &r, &v);
        a[b - 1][f - 1][r - 1] = a[b - 1][f - 1][r - 1] + v;
    }
    for (int b = 0; b < 4; b++)
    {
        for (int f = 0; f < 3; f++)
        {
            for (int r = 0; r < 10; r++)
            {
                printf(" %d", a[b][f][r]);
            }
            printf("\n");
        }
        if (b != 3)
        {
            for (int s = 1; s <= 20; s++)
            {
                printf("#");
            }
            printf("\n");
        }
    }
}


Measured memory_bytes: 2108
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#include<string>
using namespace std;

#define ll long long
typedef pair<ll , ll > pii;
const int MOD = 998244353;
const int N=500004;

vector<int> BIT;

void update(int i, int add)
{
    while (i > 0 && i < BIT.size())
    {
        BIT[i] += add;
        i = i + (i & (-i));
    }
}

int sum(int i)
{
    int ans = 0;
    while (i > 0)
    {
        ans += BIT[i];
        i = i - (i & (-i));
    }

    return ans;
}
int findKthSmallest(int k)
{
    int l = 0;
    int h = BIT.size();
    while (l < h)
    {
        int mid = (l + h) / 2;
        if (k <= sum(mid))
            h = mid;
        else
            l = mid+1;
    }

    return l;
}

void insertElement(int x)
{
    update(x, 1);
}

void deleteElement(int x)
{
    update(x, -1);
}

int findRank(int x)
{
    return sum(x);
}

///


void min_self(int &a , int b){
    a=min(a,b);
}

int add(int x, int y)
{
    return (x + y) % MOD;
}

int sub(int x, int y)
{
    return add(x, MOD - y);
}

int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}

int binpow(int x, int y)
{
    int z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}

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

int fact[N];

int C(int n, int k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}
/////-----//////





int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
   int n; cin>>n;
   ll p=1;
   ll inf=1e18;
   vector<ll> v(n);
   for(int i=0;i<n; i++){
       cin>>v[i];
       if(v[i] == 0 ) {
           cout<<0;
           return 0;
       }
   }
   for(int i=0; i<n; i++){
       ll x=v[i];
       if(x>inf/p) {
           p=-1;
       }
       else{
           p*=x;
       }
   }
   cout<<p<<endl;

   return 0;
}


Measured memory_bytes: 3992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		int min = Math.min(a, b);
		int count = 0;
		for(int i = min; i >0; i--) {
			if(a%i==0 && b%i==0) {
				count++;
			}
			if(count == k) {
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int zero=0;
    int one=0;
    REP(i,s.length()){
        if(s[i]=='1')one++;
        else zero++;
    }
    cout << min(zero,one)*2 << endl;
    return 0;
}

Measured memory_bytes: 512
N = int(input())
W = list(map(int, input().split()))

ans = 10 ** 6

for i in range(len(W) - 1):
    s1 = sum(W[:i+1])
    s2 = sum(W[i+1:])

    ans = min(ans, abs(s1-s2))

print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
 
 
class Main{
    public static void main(String[] args){


        Scanner sc = new Scanner(System.in);
	while(true){
        int H = sc.nextInt();
        int W = sc.nextInt();

        if(H==0 && W==0){
              break;
        }
        for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){

                            if((i + j) % 2 == 0){
                                  System.out.print("#");
                        }
                        else{
                            System.out.print(".");
                        }
                }
                System.out.print("\n");
        }
            System.out.print("\n");
        }        
    }
}


Measured memory_bytes: 38092
#include <iostream>
using namespace std;
int main() {
	int table[102][102];
	int N,H,W;
	int array[10002]={0};
	int  input;
	
	cin >> H >> W >> N;
	
	int a=0;
	for(int i=1;i<=N;i++){
		cin >> input;
		for(int j=1;j<=input;j++){
			a++;
			array[a]=i;
		}
	}
	
	a=0;
	
	for(int j=1;j<=H;j++){
		for(int i=1;i<=W;i++){
			a++;
			table[j][i]=array[a];
		}
		j++;
		if(j<=H){
			for(int i=W;i>=1;i--){
				a++;
				table[j][i]=array[a];
			}
		}
	}
	
	for(int j=1;j<=H;j++){
		for(int i=1;i<=W;i++){
			cout << table[j][i] << " ";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=105,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int s[105],dp[N][5005];
int n,k;

int main(){
#ifdef rqgao2014
	assert(freopen("input.txt","r",stdin));
#endif
	scanf("%d%d",&n,&k);
	for(int i=n;i;i--)
		s[i]=(i+s[i+1])/i+s[i+1];
	dp[n+1][0]=1;
	for(int i=n;i>=1;i--)
		for(int j=0;j<=s[i];j++){
			if(!dp[i+1][j]) continue;
			for(int c=0;c<=k;c++)
				if(c>i)
					ch(dp[i][j],dp[i+1][j]);
				else
					ch(dp[i][j+(j+c)/i],dp[i+1][j]);
		}
	int ans=(ll)n*k*(k+1)/2*exp(k+1,n-1)%mod;
//	debug(ans);
	for(int j=0;j<=s[1];j++)
		ch(ans,-(ll)dp[1][j]*j);
	if(ans<0) ans+=mod;
	printf("%d\n",ans);
	return 0;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int32_t main() {
	FIO;



	int n ;
	cin >> n;

	n & 1 ? cout << (2 * n) : cout << n;

	return 0;
}


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

bool isPrime( int x ) {
	if( x == 2 ) {
		return true;
	}

	if( x < 2 || (x & 1) == 0 ) {
		return false;
	}

	int rt = sqrt( x );

	for( int i = 3; i <= rt; i += 2 ) {
		if( x % i == 0 ) {
			return false;
		}
	}

	return true;
}

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

	int result = 0;

	for( int i = 0; i < n; ++i ) {
		int x;
		cin >> x;

		result += isPrime( x );
	}

	cout << result << endl;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000007;
const static int inf = INT_MAX;
const static llong INF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
    return a * b / my_gcd(a, b);    
}

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    bool flag = true;
    rep(i, n) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 && A[i] % 5) flag = false;
        }
    }
    if (flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 500001
#define SENTINEL 1000000005

int n, S[N];
int cnt = 0;

void merge(int left, int mid, int right){

    int n1 = mid - left;
    int n2 = right - mid;

    // 番兵用に一つ余分に確保
    int L[n1+1], R[n2+1];

    int i, j, k;

    // 配列を2つに分ける
    for(i = 0; i < n1; i++) L[i] = S[left + i];
    for(i = 0; i < n2; i++) R[i] = S[mid + i];

    // 配列の最後に番兵を設置
    L[n1] = R[n2] = SENTINEL;

    i = j =0;

    for (k = left; k < right; k++) {
        cnt++;
        if(L[i] <= R[j]) S[k] = L[i++];
        else S[k] = R[j++];
    }

    // int iw = 0, il = left, ir = mid;
    //
    // while(il < mid && mid < right){
    //     if(S[il] <= S[ir]) work[iw++] = S[il++];
    //     else  work[iw++] = S[ir++];
    // }
    //
    // while(il < mid) work[iw++] = S[il++];
    // while(ir < right) work[iw++] = S[ir++];
}

void mergeSort(int left, int right){
    int mid;

    // 配列の長さが1以下ならソート済
    if(right - left <= 1) return;

    // 配列をleft~mid, mid~rightの2つに分けてソート
    mid = (left + right) / 2;
    mergeSort(left, mid);
    mergeSort(mid, right);

    // 配列をマージ
    merge(left, mid, right);
}



int main() {

    int i;
    int left, right;

    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &S[i]);

    left = 0;
    right = n;

    mergeSort(left, right);

    for(i = 0; i < n-1; i++) printf("%d ", S[i]);
    printf("%d\n", S[n-1]);
    printf("%d\n", cnt);

    return 0;

}

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

mod = pow(10,9)+7
ans = pow(2,n,mod)
ans -= 1
def choose(n,k):
    x,y = 1,1
    for i in range(1,k+1):
        x *= (n-i+1)
        x %= mod
        y *= i
        y %= mod
    
    x *= pow(y,mod-2,mod)
    x %= mod
    return x

ans -= choose(n,a)
ans -= choose(n,b)
ans %= mod
print(ans)

Measured memory_bytes: 9160