akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

using namespace std;

char s[10'009];

int main() {
  int m;
  scanf("%d%s", &m, s);
  for (int i = 0; s[i]; ++i) {
    int t = ((int)(s[i] - 'A') + m) % 26;
    putchar((char)('A' + t));
  }
  putchar('\n');
}


Measured memory_bytes: 128
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int n,i,j,k,b,f,r,v;
        int house[][][]= new int[4][3][10];
        n=input.nextInt();
        for(i=0; i<n; i++){
            b=input.nextInt();
            f=input.nextInt();
            r=input.nextInt();
            v=input.nextInt();
            house[b-1][f-1][r-1]+=v;
        }
        for (i=0;i<4;i++){
            for (j=0;j<3;j++){
                for(k=0;k<10;k++){
                    System.out.print(" "+house[i][j][k]);
                }
                System.out.println();
            }
            if (i < 3){
                System.out.println("####################");
            }
        }
    }
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    int lon = s.length(),n_b=0,n_w=0;
    vector<int> w(lon),b(lon);
    for(int i=0;i<lon;i++){
        w[i]= (i+1)%2;
        b[i]= i%2;
    }
    for(int h=0;h<lon;h++){
        if(s[h]-'0'==w[h]){
            n_b++;
        }else{
            n_w++;
        }
    }
    cout << min(n_b,n_w)<<endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int x;
    cin >> x;
    x /= 50;

    int r = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (i * 10 + j * 2 + k == x) r++;
            }
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;


class DICE
{
private:
	void swapMap(string a, string b);
public:
	map<string,int> dice;
	DICE(vector<int> &v);
	~DICE();
	void turnDice(char c);
	void rotateDice(char c);
	void setDice(string s1, string s2, int a, int b);
	void printDice(string s);
	bool judgeSame(DICE &d);
};

DICE::DICE(vector<int> &v){
	dice["top"] = v[0];
	dice["front"] = v[1];
	dice["right"] = v[2];
	dice["left"] = v[3];
	dice["back"] = v[4];
	dice["bottom"] = v[5];
}

DICE::~DICE(){
	
}

void DICE::swapMap(string a, string b){
	if(dice.end() == dice.find(a) || dice.end() == dice.find(b)) return;
	int tmp;
	tmp = dice[a];
	dice[a] = dice[b];
	dice[b] = tmp;
}

void DICE::turnDice(char c){
	switch(c){
		case 'N':
			swapMap("top","back");
			swapMap("top","bottom");
			swapMap("top","front");
			break;
		case 'E':
			swapMap("top","right");
			swapMap("top","bottom");
			swapMap("top","left");
			break;
		case 'S':
			swapMap("top","front");
			swapMap("top","bottom");
			swapMap("top","back");
			break;
		case 'W':
			swapMap("top","left");
			swapMap("top","bottom");
			swapMap("top","right");
			break;
		default :
			break;
	}
}

void DICE::rotateDice(char c){
	switch(c){
		case 'R':
			swapMap("front","right");
			swapMap("front","back");
			swapMap("front","left");
			break;
		case 'L':
			swapMap("front","left");
			swapMap("front","back");
			swapMap("front","right");
			break;
		default :
			break;
	}
}

void DICE::setDice(string s1, string s2, int a, int b){
	int cnt = 0;
	while(dice[s1] != a && cnt < 6){
		if(cnt % 2 == 0) this->turnDice('E');
		else this->turnDice('N');
		cnt++;
	}
	cnt = 0;
	while(dice[s2] != b && cnt < 4){
		this->rotateDice('R');
		cnt++;
	}
}

void DICE::printDice(string s){
	cout << dice[s] << endl;
}

bool DICE::judgeSame(DICE &d){
	DICE tmp(d);
	int cnt = 0;
	while(cnt < 6){
		if(cnt % 2 == 0) tmp.turnDice('E');
		else tmp.turnDice('N');
		if(this->dice["top"] != tmp.dice["top"]){
		}
		else{
			for(int i = 0; i < 4; i++){
				tmp.rotateDice('R');
				if(	(this->dice["right"] == tmp.dice["right"]) &&
					(this->dice["left"] == tmp.dice["left"]) &&
					(this->dice["front"] == tmp.dice["front"]) &&
					(this->dice["back"] == tmp.dice["back"]) &&
					(this->dice["bottom"] == tmp.dice["bottom"])) 
					return true;
			}
		}
		cnt++;
	}
	return false;
}

int main(){
	vector<int> v1, v2;
	int q;
	for(int i = 0; i < 6; i++){
		int tmp;
		cin >> tmp;
		v1.push_back(tmp);
	}
	for(int i = 0; i < 6; i++){
		int tmp;
		cin >> tmp;
		v2.push_back(tmp);
	}
	DICE dice1(v1),dice2(v2);
	cout << (dice1.judgeSame(dice2) ? "Yes": "No") << endl;
}

Measured memory_bytes: 1248
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

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

    TreeMap<String, Integer> hashMap = new TreeMap<>();

    for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      if (hashMap.containsKey(s_)) {
        Integer v_ = hashMap.get(s_);
        hashMap.put(s_,v_ + 1);
      } else { 
        hashMap.put(s_,1);
      }
    }

    sc.close();

    for (Map.Entry<String, Integer> map : hashMap.entrySet()) {
      for (int i = 0; i < map.getValue(); i++) {
        System.out.print(map.getKey());
      }
    }

    System.out.println("");

  }

}

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  int a[m], b[m];
  for (int i = 0; i < m; i++) cin >> a[i] >> b[i];
  int cnt[n]; memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < m; i++) {
    cnt[a[i] - 1]++;
    cnt[b[i] - 1]++;
  }
  for (int i = 0; i < n; i++) {
    if (cnt[i] % 2) {
      cout << "NO" << "\n";
      return 0;
    }
  }
  cout << "YES" << "\n";
  return 0;
}

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

typedef long long LL;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;
const int maxn = 2e5 + 10;

template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

LL n, l, r, k;
char st[maxn];
LL nxt[maxn], ans[30];

void solve(LL len, LL flag) {
    if(len <= n) {
        for(int i = 0; i < len; i++) ans[st[i] - 'a'] += flag;
    }else {
        LL ts, tt;
        LL s = 1, t = 0, ls = 0, lt = 1;

        while(s*n + t*k < len) {
            ts = ls, tt = lt;
            ls = s, lt = t;
            s += ts, t += tt;
        }

        solve(len - ls*n - lt*k, flag);

        for(int i = 0; i < k; i++) ans[st[i] - 'a'] += flag * lt;
        for(int i = 0; i < n; i++) ans[st[i] - 'a'] += flag * ls;
    }
}

void get_nxt() {

    n = strlen(st) / 2; 
    nxt[0] = nxt[1] = 0;
    for(int i = 1; i < n; i++) {
        int j = nxt[i];
        while(j && st[j] != st[i]) j = nxt[j];

        nxt[i+1] = j + (st[j] == st[i]);
    }

    k = n - nxt[n];
    //cerr << (k) << endl;
}

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    scanf("%s%lld%lld", st, &l, &r);

    get_nxt();
    solve(r, 1);
    solve(l-1, -1);

    for(int i = 0; i < 26; i++) printf("%lld ", ans[i]);
    puts("");

    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

int main(void)
{
   int n, m, a[10000], s=0, i;

   scanf("%d%d",&n,&m);
   for(i=0;i<m;i++){
      scanf("%d",&a[i]);
      s=s+a[i];
   }

   if(n<s) printf("-1\n");
   else printf("%d\n",(n-s));
   return 0;
}

Measured memory_bytes: 1744
#include <iostream>
#include <set>
#include <map>
#include <vector>

using namespace std;
typedef long long ll;
int main(int argc, const char * argv[]) {
  ll N;
  cin >> N;
  map<char, ll> sum;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    map<char, ll> m;
    for(int j = 0; j < s.size(); j++) {
      m[s[j]]++;
    }
    if (i == 0) {
      sum = m;
    } else {
      for (auto itr = sum.begin(); itr != sum.end(); itr++) {
        sum[itr->first] = min(sum[itr->first], m[itr->first]);
      }
    }
  }
  string ret = "";
  for (auto itr = sum.begin(); itr != sum.end(); itr++) {
    for (int i = 0; i < itr->second; i++) {
      ret += itr->first;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
# ABC137(AB).py

SELECT = "AB"[1]

if SELECT == "A":  # +-x

    a, b = map(int, input().split())
    plu = a + b
    dis = a - b
    multi = a * b
    print(max(plu, dis, multi))

else:  # OneClue

    k, x = tuple(map(int, input().split()))
    xs = [i for i in range(x - (k - 1), (x + k))]
    print(" ".join(map(str, xs)))  # 数列をスペース区切りで連結して出力する


Measured memory_bytes: 3060
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 700 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int dp[N][N], n, m, adj[N][N], mark[N], sz, cnt, col[N];

void DFS(int v){
	mark[v] = 1;
	sz ++;
	if (col[v] == 0) cnt++;
//	cout << v << ' ' << col[v] << '\n';/
	for (int i = 1; i <= n; i++){
		if (i == v) continue;
		if (adj[v][i] == 1 && mark[i] == 0){
			col[i] = (col[v] + 1) % 2;
			DFS(i);
		}else if(adj[v][i]){
			if (col[i] == col[v]){
				cout << -1;
				exit(0);
			}
		}
	}
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) adj[i][j] = 1;
	for (int i = 1; i <= m; i++){
		int v, u;
		cin >> v >> u;
		adj[v][u] = adj[u][v] = 0;
	}
//	for (int i = 1; i <= n; i++){
//		cout << i << ": ";
//		for (int j = 1; j <= n; j++) cout << adj[i][j];
//		cout << '\n';
//	}
	vector<pair<int, int>> num;
	for (int i = 1; i <= n; i++){
		if (!mark[i]){
			sz = 0;
			cnt = 0;
			DFS(i);
			num.pb({cnt, sz - cnt});
//			cout << cnt << ' ' << sz - cnt << '\n';
		}
	}
	dp[0][0] = 1;
	for (int i = 1; i <= num.size(); i++){
		for (int j = 1; j <= n; j++){
			if (j >= num[i - 1].F)dp[i][j] |= dp[i - 1][j - num[i - 1].F];
			if (j >= num[i - 1].S) dp[i][j] |= dp[i - 1][j - num[i - 1].S];
		}
	}
	int mx = 0;
	for (int i = 1; i <= n / 2; i++){
		if (dp[num.size()][i] == 1) mx = i;
	}
	cout << (mx * (mx - 1) / 2 + (n - mx) * (n - mx - 1) / 2);







	return 0;
}


Measured memory_bytes: 7452
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

tmp = []
s = 0
for i in a:
    if s + i <= k:
        tmp.append(i)
        s += i
    else:
        break
a = tmp
tmp = []
s = 0
for i in b:
    if s + i <= k:
        tmp.append(i)
        s += i
    else:
        break
b = tmp
line = b[::-1] + a

ans = 0
right = 0
sum_ = 0
for left in range(len(line)):
    while right < len(line) and sum_ + line[right] <= k:
        sum_ += line[right]
        right += 1
    l = right -left 
    if l > ans:
        ans = l

    if right == left: right += 1
    else: sum_ -= line[left]

print(ans) 

Measured memory_bytes: 41120
#include<bits/stdc++.h>
#include <iomanip>
#define ll long long int
#define ld long double
#define IOS cin.tie(NULL);cout.tie(NULL)
#define f first
#define inf 100000000000000000
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define sc(i) scanf("%lld",&i);
#define s second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
ll const mod=1000000007;
 
// ll arr1[10000009];
// vector<ll> sieve;
// void sievefun(ll n){
//     for(ll i=2;i<=n;i++){
//         if(arr1[i]==0){
//             for(ll j=i*i;j<=n;j+=i){
//                 arr1[j]=1;
//             }
//         }
//     }
//     for(int i=2;i<=n;i++){
//     	if(arr1[i]==0)sieve.pb(i);
//     }
// }
 
ll countDivisors(ll n)
{
    ll cnt = 0;
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            // If divisors are equal,
            // count only one
            if (n / i == i)
                cnt++;
 
            else // Otherwise count both
                cnt = cnt + 2;
        }
    }
    return cnt;
}
ll power(ll x, ll y) {
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2);
	if (y%2 == 0)
		return ((temp)*(temp));
	else
		return (((x))*((temp*temp)));
}
ll gcd1(ll a, ll b){
if (a == 0)
    return b;
return gcd1(b % a, a);
}
ll lcm(ll a, ll b)
{
return (a*b)/gcd1(a, b);
}
ll dp[10009][109][2];
ll fun(string s,int d,int ind,int n,int rem,int flag){
	if(ind==n){
		if(rem==0)return 1;
		else return 0;
	}
	if(dp[ind][rem][flag]!=-1)return dp[ind][rem][flag]%mod;
	ll ans=0;
	if(flag){
		forn(i,s[ind]){
			ans+=fun(s,d,ind+1,n,(rem+i%d)%d,0);
			ans%=mod;
		}
		ans+=fun(s,d,ind+1,n,(rem+s[ind]%d)%d,1);
		ans%=mod;
	}else{
		forn(i,10){
			ans+=fun(s,d,ind+1,n,(rem+i%d)%d,0);
			ans%=mod;
		}
	}
	return dp[ind][rem][flag]=ans;
}
int main()
{	//sievefun(10000007);
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	forn(i,s.length())s[i]-='0';
	ll d;
	cin>>d;
	forn(i,s.length()){
		forn(j,d){
			forn(k,2){
				dp[i][j][k]=-1;
			}
		}
	}
	fun(s,d,0,s.length(),0,1);
	cout<<(dp[0][0][1]-1+mod)%mod<<endl;
	// forn(i,s.length()){
	// 	forn(j,2){
	// 		forn(k,d){
	// 			cout<<dp[i][k][j]<<" ";
	// 		}cout<<endl;
	// 	}cout<<endl<<endl;
	// }

}

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

int main(){
  int n, m; 
  cin >> n >> m;
  vector<vector<int>> bulbs(m, vector<int>(n));
  for(int i = 0; i < m; i++){
    int k; cin >> k;
    for(int j = 0; j < k; j++){
      cin >> bulbs.at(i).at(j);
    }
  }
  vector<int> num(m);
  for(int i = 0; i < m; i++){
    cin >> num.at(i);
  }
  int ans = 0;
  //二進数の一桁目がスイッチ１
  for(int i = 0; i < (1 << n); i++){
    int cnt = 0;
    for(int j = 0; j < m; j++){
      int swtch = 0;
      //必要なスイッチが何個onになっているか
      for(int l : bulbs.at(j)){
        //二進数の１がon 
        if((1 << l - 1) & i){
          swtch++;
        }
      }
      if(swtch % 2 == num.at(j)){
        cnt++;
      }
    }
    if(cnt == m){
      ans++;
    }
  }
  cout << ans << endl;
}
        
      
      
  
  

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

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

ll n,m,x,k,d,i,j,index,flag=0,mini,count=0,result,odd,even,sum=0,temp,five=0,seven=0;
//cin>>n;
//string str;
//cin>>str;
ll a[20];
//ll b[200005];
for(i=0;i<3;i++)
{
    cin>>a[i];
    if(a[i]==5)  five++;
    else if(a[i]==7) seven++;
}

if(five == 2 && seven==1) cout<<"YES";
else cout<<"NO";
    return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int a,b;
int main(){
	cin >> a >> b;
	for(int i = 1; i < 1251; i++){
		int tmp1 = i * 0.08;
		int tmp2 = i * 0.1;
		if(tmp1 == a and tmp2 == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> T(N), A(N);
    for ( int i = 0; i < N; i++ ) cin >> T[i];
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    ll m = 0;
    for ( int i = 0; i < N; i++ ) {
        m = max(m, T[i]);
        m = max(m, A[i]);
    }
    int it = 0, ia = N-1;
    for ( int i = 0; i < N; i++ ) {
        if ( T[i] == m ) {
            it = i;
            break;
        }
    }
    for ( int i = N-1; i >= 0; i-- ) {
        if ( A[i] == m ) {
            ia = i;
            break;
        }
    }
    for ( int i = it; i < N; i++ ) {
        if ( T[i] != m ) return 0;
    }
    for ( int i = ia; i >= 0; i-- ) {
        if ( A[i] != m ) return 0;
    }
    if ( it > ia ) return 0;
    const ll MOD = 1e9 + 7;
    auto Add = [&](ll& x, ll y) { x = ( x % MOD + y % MOD ) % MOD; };
    auto Mul = [&](ll& x, ll y) { x = ( x % MOD * y % MOD ) % MOD; };
    ll ans = 1;
    for ( int i = 1; i < N-1; i++ ) {
        if ( T[i] != T[i-1] || A[i] != A[i+1] ) continue;
        Mul(ans, min(T[i], A[i]));
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: Chars,
    }

    let mut ans = 0;

    for i in n {
        let a = i.to_digit(10).unwrap();
        ans += a;
    }

    if ans % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2980
import sys
sys.setrecursionlimit(100000)


def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int, ins()))
def lin(): return list(input())
def iin(): return map(int, ins())

from collections import defaultdict
from math import sqrt

arr = []
max_p = int(500000)
l1 = [1 for i in range(max_p)]
l2 = set()
l2.add(2)
for i in range(max_p):
    if not l1[i]:
        continue
    l2.add(2*i+3)
    for j in range(3*i+3, max_p, 2*i+3):
        l1[j] = 0

n = int(input())
#n = 10 ** 12
dic = defaultdict(int)
for i in l2:
    while n % i == 0:
        n //= i
        dic[i] += 1
if n != 1:
    dic[n] += 1

ans = 0
for i in dic.values():
    ans += (-1 + sqrt(1 + 8 * i))//2
print(int(ans))


Measured memory_bytes: 17672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll n;
  cin>>n;
  vll a(n);
  for (ll i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  cout << a[n-1]-a[0];
}

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

const ll INF = 1LL << 60;

ll H, W;
int main() {
    cin >> H >> W;

    ll ans = INF;

    // 縦分割
    if (H % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll pat1_max = ((H / 3) + 1) * W;
    ll pat1_min = ((H / 3)) * W;
    ll pat1_area = pat1_max - pat1_min;
    ans = min(ans, pat1_area);

    ll pat2_max = ((W / 3) + 1) * H;
    ll pat2_min = ((W / 3)) * H;
    ll pat2_area = pat2_max - pat2_min;
    ans = min(ans, pat2_area);


    // pat3 ( | 分割)
    ll w1 = (W / 2);
    ll w2 = ceil(W / 2.0);

    // h を動かす
    for (int h = 1; h <= H - 1; h++) {
        ll a1 = h * W;
        ll a2 = (H - h) * w1;
        ll a3 = (H - h) * w2;
        vector<ll> v1 = {a1, a2, a3};
        // cout << a1 << " " << a2 << " " << a3 << endl;
        sort(v1.begin(), v1.end());
        ll pat3_area = v1[2] - v1[0];
    
        ans = min(ans, pat3_area);
    }
    // cout << w1 << " " << w2 << endl;

    // pat4 ( - 分割)
    ll h1 = H / 2;
    ll h2 = ceil(H / 2.0);
    for (int w = 1; w <= W - 1; w++) {
        ll a1 = w * H;
        ll a2 = (W - w) * h1;
        ll a3 = (W - w) * h2;
        vector<ll> v1 = {a1, a2, a3};
        // cout << a1 << " " << a2 << " " << a3 << endl;
        sort(v1.begin(), v1.end());
        ll pat4_area = v1[2] - v1[0];
        ans = min(ans, pat4_area);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1;
  string s2;
  cin>>s1;
  cin>>s2;
   int i;
  if(s1.length()==0 || s2.length()==0)
    return 0;
  for(i=0;i<s1.length();i++)
  {
    if(s1[i]<'a' || s1[i]>'z')
      return 0;
  }
   for(i=0;i<s2.length();i++)
  {
    if(s2[i]<'a' || s2[i]>'z')
      return 0;
  }
 	
  if((s1.length()+1)!=s2.length())
    cout<<"No";
  else
  {
	for(i=0;i<s1.length();i++)
    {
      if(s1[i]!=s2[i])
        break;
    }
    if(i==s1.length())
    {
      cout<<"Yes";
    }
    else
      cout<<"No";
  }
 return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
//const ll mod = 1000000007LL;
const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}
//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

#define rep(i,x) for(int i = 0;i<x;i++)
#define REP(i,x) for(int i = 1;i<=x;i++)

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    map<ll,ll> ma;
    ll n,up = 0;
    rep(i,N){
        cin >> n;
        if(i == 0 && n != 0){
            cout << "0\n";
            return 0;
        }
        chmax(up,n);
        ma[n]++;
    }
    if(ma[0] > 1){
        cout << "0\n";
        return 0;
    }
    ll ans = 1;
    rep(i,up){
        if(ma[i + 1] == 0){
            cout << "0\n";
            return 0;
        }
        ans *= modpow(ma[i],ma[i + 1],mod);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9604
a, b, c = map(int, input().split())
l = [a, b, c]
l.sort()
ans = l[2]-l[1]
l_ = [l[0]+ l[2]-l[1], l[2], l[2]]

if l_[0]%2 == l_[2]%2:
    ans += (l_[2]-l_[0])//2
else:
    ans += (l_[2]+1-l_[0])//2+1

print(ans)


Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
int main() {
	vector<int>A(3);
	for (int i = 0; i < 3; i++) {
		cin >> A.at(i);
	}
	int K;
	cin >> K;
	for (int i = 0; i < K; i++) {
		sort(A.begin(), A.end(), greater<int>());
		A.at(0) *= 2;
	}
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		ans += A.at(i);
	}
	cout << ans << endl;
}

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

template <class T> inline void chadd(T &a, const T &b) { a += b; }

int main() {
  // Input
  int numDish;
  std::cin >> numDish;
  assert(1 <= numDish and numDish <= 300);
  std::vector<int> sushiCount(1 + numDish);
  for (int n = 1; n <= numDish; ++n) {
    std::cin >> sushiCount[n];
    assert(1 <= sushiCount[n] and sushiCount[n] <= 3);
  }

  // Initialization
  std::vector<std::vector<std::vector<double>>> dp(1 + numDish + 1);
  for (int i = 0; i <= numDish + 1; ++i) {
    dp[i].assign(1 + numDish + 1, {});
    for (int j = 0; j <= numDish + 1; ++j) {
      dp[i][j].assign(1 + numDish + 1, 0);
    }
  }

  // Initial condition
  dp[0][0][0] = 0;
  for (int i = 0; i <= numDish; ++i) {
    for (int j = 0; j <= numDish; ++j) {
      for (int k = 0; k <= numDish; ++k) {
        if (i == 0 and j == 0 and k == 0)
          continue;
        if (i + j + k > numDish)
          continue;
        dp[i][j][k] = static_cast<double>(numDish - i - j - k) / (i + j + k);
      }
    }
  }

  // DP main
  for (int k = 0; k <= numDish; ++k) {
    for (int j = 0; j <= numDish; ++j) {
      for (int i = 0; i <= numDish; ++i) {
        if (i + j + k > numDish)
          continue;
        chadd(dp[i + 1][j][k], (static_cast<double>(i + 1) / (i + j + k + 1)) *
                                   (1 + dp[i][j][k]));
        if (i >= 1)
          chadd(dp[i - 1][j + 1][k],
                (static_cast<double>(j + 1) / (i + j + k)) * (1 + dp[i][j][k]));
        if (j >= 1)
          chadd(dp[i][j - 1][k + 1],
                (static_cast<double>(k + 1) / (i + j + k)) * (1 + dp[i][j][k]));
      }
    }
  }

  // Output
  int i = 0;
  int j = 0;
  int k = 0;
  for (int n = 1; n <= numDish; ++n) {
    if (sushiCount[n] == 1)
      i += 1;
    else if (sushiCount[n] == 2)
      j += 1;
    else if (sushiCount[n] == 3)
      k += 1;
    else
      assert(false);
  }
  printf("%.12f\n", dp[i][j][k]);

  return 0;
}


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

int main() {
  ll n, i, j, asum = 0, bsum = 0, ans = 0, s = 0;
  cin >> n;
  vector<ll> a(n), b(n), plus, minus;
  for (i = 0; i < n; ++i) {
    cin >> a[i];
    asum += a[i];
  }
  for (i = 0; i < n; ++i) {
    cin >> b[i];
    bsum += b[i];
  }
  for (i = 0; i < n; ++i) {
    if (a[i] < b[i]) {
      minus.push_back(b[i] - a[i]);
      s += b[i] - a[i];
      ++ans;
    } else {
      plus.push_back(a[i] - b[i]);
    }
  }

  if (asum - bsum < 0) {
    ans = -1;
  } else if (minus.size() == 0) {
    ans = 0;
  } else {
    sort(plus.rbegin(), plus.rend());
    for (i = 0; i < plus.size(); ++i) {
      s -= plus[i];
      ++ans;
      if (s <= 0) {
        break;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>

int main(void){
	int x,i,tf;
	
	for (i=1;i<i+1;i++){
		scanf("%d",&x);
		
		if (x==0) break;
		
		printf("Case %d: %d\n",i,x);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
int main(void){
    int a, b, c, n, i;
    scanf("%d %d %d", &a, &b, &c);
    n=a;
    i=0;

    while(n <= b){
        if(c%n == 0){
            i++;
        }
        n++;
    }
    printf("%d\n", i);
    return 0;

}


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

int main() {
    int a, b, x=0;
    cin>>a>>b;
    if(a>b){
        x=a+(a-1);
    }
    else if(a==b){
        x=a+b;
    }
    else{
        x=b+(b-1);
        }
    cout<<x;
}

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

using namespace std;

int main() {
    vector<int> x(5);
    for(int i = 0; i < 5; i++) {
        cin >> x[i];
        if(x[i] == 0) {
            cout << i + 1 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3576
/**
 * Created by hiramekun at 22:39 on 2019-08-27.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vl a(x), b(y), c(z);
    cin >> a >> b >> c;
    sort(all(a), greater<>()), sort(all(b), greater<>()), sort(all(c), greater<>());

    ll s = -1, e = a[0] + b[0] + c[0] + 1;
    auto solve = [&](ll p) -> bool {
        ll cnt = 0;
        rep(i, x) {
            rep(j, y) {
                rep(l, z) {
                    ll val = a[i] + b[j] + c[l];
                    if (val < p) break;
                    if (++cnt >= k) {
                        return true;
                    }
                }
            }
        }
        return false;
    };
    while (e - s > 1) {
        ll mid = (s + e) / 2;
        if (solve(mid)) s = mid;
        else e = mid;
    }
    vl ans;
    rep(i, x) rep(j, y) rep(l, z) {
                ll val = a[i] + b[j] + c[l];
                if (val < s + 1) break;
                ans.eb(val);
            }
    while (ans.size() < k) ans.eb(s);
    sort(all(ans), greater<>());
    each(val, ans) cout << val << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}



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

using namespace std;

int main(int argc, char** argv){
    int A, B;
    cin >> A >> B;
    if(A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}


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

int main()
{
    int n, m, S, T;
    while(cin >> n >> m && n && m) {
        vector<int> s(n),t(m);
        int ss, st;
        
        ss = st = 0;
        for(int i = 0; i < n; i++) {
            cin >> s[i];
            ss += s[i];
        }

        for(int i = 0; i < m; i++) {
            cin >> t[i];
            st += t[i];
        }
        
        int u = 9999, v = 9999;
        int sum = u + v;
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                if((ss + 2 * t[j]) == (st + 2 * s[i])) {
                    if(sum > (s[i] + t[j])) {
                        u = s[i]; v = t[j];
                        sum = u + v;
                    }
                }
            }
        }
        if(u == 9999 && v == 9999) {
            cout << -1 << endl;
        } else {
            cout << u << " " << v << endl;
        }
    }
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int[] a = new int[m];
        
        boolean[] arr = new boolean[n+1];
        
        for(int i = 0; i < m; i++){
            a[i] = sc.nextInt();
            arr[a[i]] = true;
        } 
        
        int[] dp = new int[n+10];
        
        int mod = 1_000_000_007;
        
        dp[0] = 1;
        dp[1] = arr[1] ? 0 : 1;
        
        for(int i = 2; i <= n; i++) if(!arr[i]) dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
        
        System.out.println(dp[n]);
    }
}


Measured memory_bytes: 48024
#include <bits/stdc++.h>
using namespace std;
#define LL long int

const LL N = 1000000009;

LL f(LL n,LL p){
    LL ans = 0;
    while(n > 0){
        n /= p;
        ans ++;
    }
    return ans;
}

int main(){
    LL n,k;
    cin >> n >> k;
    cout << f(n,k) << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#ifdef ONLINE_JUDGE
#define assert(...) /* nothing */
#endif
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
const int mn=(2e5)+4;
vector<int> g[mn];
class Diameter {
public:
	int dist[mn];
	int n;
	void init(int _n) {n=_n;}
	pii bfs(int init) {
		if (init==-1) return MP(-1,-1);
		for (int x=1;x<=n;x++) {dist[x]=INF;}
		queue<int> q;
		q.push(init);
		dist[init]=0;
		while(!q.empty()) {
			int x=q.front(); q.pop();
			int cand=dist[x]+1;
			for (auto &y:g[x]) {
				if (dist[y]>cand) {
					dist[y]=cand;
					q.push(y);
				}
			}
		}
		pii ans=MP(-1,-1);
		for (int x=1;x<=n;x++) {
			chkmax(ans,MP(dist[x],x));
		}
		return ans;
	}
	pii getp(int init) {
		pii x=bfs(init);
		pii y=bfs(x.snd);
		return MP(x.snd,y.snd);
	}
	int getdiam(int init) {
		pii x=bfs(init);
		pii y=bfs(x.snd);
		//printf("F %d %d\n",x.fst,x.snd);
		//printf("S %d %d\n",y.fst,y.snd);
		return y.fst;
	}
};
Diameter diam;

int f[mn];
void solve(long long n, vector<long long> a, vector<long long> b){
	int m=a.size();
	for (int i=0;i<m;i++) {
		int x=a[i],y=b[i];
		g[x].PB(y); g[y].PB(x);
		//printf("%d - %d\n",x,y);
	}
	diam.init(n);
	int d=diam.getdiam(1);
	f[0]=1;
	f[1]=0;
	for (int x=2;x<mn;x++) {
		f[x]=(1-f[x-1])|(1-f[x-2]);
	}
	//printf("d:%d\n",d);
	if (f[d]) printf("First\n");
	else printf("Second\n");


}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a((N-1)-1+1);
	vector<long long> b((N-1)-1+1);
	for(int i = 0 ; i <= (N-1)-1 ; i++){
		scanf("%lld",&a[i]);
		scanf("%lld",&b[i]);
	}
	solve(N, a, b);
	return 0;
}



Measured memory_bytes: 20596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int N;
    cin >> N;
    int x = N / 1000, y = (N % 1000) / 100, z = (N % 100) / 10, w = N % 10;
    if ((x == y && y == z) || (y==z && y==w)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i, j;
	cin >> n;
	vl a(3*n);
	for (i = 0; i < 3 * n; i++) {
		cin >> a[i];
	}
	priority_queue<ll> b;
	priority_queue<ll, vector<ll>, greater<ll> > f;
	vl M(3*n), m(3*n);
	for (i = 0; i < n; i++) {
		M[n] += a[i];
		f.push(a[i]);
	}
	for (i = n+1; i <= 2 * n; i++) {
		f.push(a[i-1]);
		M[i] = M[i - 1] + a[i-1] - f.top();
		//cout << f.top() << endl;
		f.pop();
	}
	for (i = 2*n; i < 3 * n; i++) {
		m[2*n] += a[i];
		b.push(a[i]);
	}
	for (i = 2*n - 1; i >= n; i--) {
		b.push(a[i]);
		m[i] = m[i + 1] + a[i] - b.top();
		//cout << b.top() << endl;
		b.pop();
	}
	/*
	for (i = n; i <= 2*n; i++) {
		cout << M[i] << " " << m[i] << endl;
	}*/

	ll ans = -INF;
	for (i = n; i <= 2 * n; i++) {
		ans = max(ans, M[i] - m[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
const int maxn=1e5+10;
const int mod=1e9+7;
int fa[maxn];
int Find(int n)
{
    if(n==fa[n]) return n;
    else return fa[n]=Find(fa[n]);
}
struct node
{
    int a,b;
    friend bool operator<(node x,node y)
    {
        return x.b>y.b;
    }
};
node book[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<=m;i++) fa[i]=i;
    for(int i=0;i<n;i++) cin>>book[i].a>>book[i].b;
    sort(book,book+n);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(book[i].a>m) continue;
        int f=Find(m-book[i].a+1);
        if(f==0) continue;
        else
        {
            ans+=book[i].b;
            fa[f]=Find(f-1);
        }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int  main(){
  int n;
  cin >> n;
  vector<int> d(n);
  int mx = 0;
  for(int i=0; i<n; ++i)cin >> d[i];
  sort(d.begin(), d.end());

  int ans = d[d.size()/2] - d[d.size()/2-1];

  cout << ans;
  return 0;
}

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

using namespace std;

const int MOD = 1000000007;

int main(){
    vector<vector<long long>> powTable(401, vector<long long>(401, 0));
    for(int i=1;i<=400;i++){
        powTable[0][i] = 1;
        for(int j=1;j<=400;j++){
            powTable[j][i] = (powTable[j-1][i] * i) % MOD;
        }
    }
    for(int i=0;i<=400;i++){
        for(int j=1;j<=400;j++){
            powTable[i][j] += powTable[i][j-1];
            powTable[i][j] %= MOD;
        }
    }
    int N, C;
    while(cin >> N >> C){
        vector<int> A(N), B(N);
        for(auto& t : A) cin >> t;
        for(auto& t : B) cin >> t;
        vector<vector<long long>> dp(N, vector<long long>(C+1, 0));
        for(int i=0;i<=C;i++){
            dp[N-1][i] += (powTable[i][B[N-1]] - powTable[i][A[N-1]-1] + MOD);
            dp[N-1][i] %= MOD;
        }
        for(int i=N-2;i>=0;i--){
            for(int j=0;j<=C;j++){
                for(int k=0;k<=j;k++){
                    long long c = 0;
                    c += (powTable[k][B[i]] - powTable[k][A[i]-1] + MOD);
                    c %= MOD;
                    c *= dp[i+1][j-k];
                    c %= MOD;
                    dp[i][j] = (dp[i][j] + c) % MOD;
                }
            }
        }
        cout << dp[0][C] << endl;
    }
}


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

int main()
{
  int n;
  cin >> n;
  cout << n + pow(n,2) + pow(n,3) << endl;

  return 0;
}

Measured memory_bytes: 4152
N, K = map(int, input().split())
H = []
for _ in range(N):
    H.append(int(input()))
H.sort()
D = []
# print(H)
for i in range(N-K+1):
    # print(i, i+K-1)
    D.append(H[i+K-1] - H[i])
# print(D)
print(min(D))

Measured memory_bytes: 11292
#include<iostream>
using namespace std;
int t;
int j;
int s;
int h;
int n;
int main(){
	cin >> t;
	cin >> j;
	cin >> s;
	cin >> h;
	cin >> n;
	if (t < 40){
		t = 40;
	}
	if (j < 40){
		j = 40;
	}
	if (s < 40){
		s = 40;
	}
	if (h < 40){
		h = 40;
	}
	if (n < 40){
		n = 40;
	}
	cout << (t + j + s + h + n) / 5 << endl;

	return 0;
}

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = ReadInts();
            var p = ReadInts();
            var ans = 0;
            Array.Sort(p);
            for (int i = 0; i < NK[1]; i++)
            {
                ans += p[i];
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27884
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define d double
#define INF LONG_LONG_MAX
#define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;

int n;
int arr[401];
ll dp[401][401];
ll cost[401][401];

ll solve( int L, int R ){

    if( L == R ) return 0;
    if( dp[L][R] != -1 ) return dp[L][R];

    ll minRes = INF;
    for(int i=L;i<R;i++){

        minRes = min( minRes, solve( L, i ) + solve( i+1, R ) + cost[L][R] );

    }

    return dp[L][R] = minRes;

}

void findCost(){

    for(int i=0;i<n;i++){
        cost[i][i] = arr[i];
        for(int j=i+1;j<n;j++){
            cost[i][j] = cost[i][j-1] + arr[j];
        }
    }

}

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

    memset( dp, -1, sizeof dp );

    cin >> n; for(int i=0;i<n;i++) cin >> arr[i];

    findCost();

    cout << solve( 0, n-1 ) << endl;

}

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

int main(void){
    char c[4];
    for(int i=0;i<4;i++){
        cin>>c[i];
    }

    int i, j=0;

    for(i=0;i<3;i++){
        if(c[i] == c[i+1]){
            cout<<"Bad"<<endl;
            j = 1;
            break;;
        }
    }
    if(j==0) cout<<"Good"<<endl;

}

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

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

  int n=0,m=0,p=0;
  for(;;){
    for(;n<s.size();n++)
      if(s[p]==s[n]){
	p++; n++; break;
      }
    if(n==s.size()){
      if(p==n){
	cout<<"Yes"<<endl; return 0;
      } else break;
    }
    for(;m<t.size();m++)
      if(s[p]==t[m]){
	p++; m++; break;
      }
    if(m==t.size()){
      if(p==m){
	cout<<"Yes"<<endl; return 0;
      } else break;
    }
  }
  n=0; m=0; p=0;
  for(;;){
    for(;m<t.size();m++)
      if(s[p]==t[m]){
	p++; m++; break;
      }
    if(m==t.size()){
      if(p==m){
	cout<<"Yes"<<endl; return 0;
      } else break;
    }
    for(;n<s.size();n++)
      if(s[p]==s[n]){
	p++; n++; break;
      }
    if(n==s.size()){
      if(p==n){
	cout<<"Yes"<<endl; return 0;
      } else break;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3196
import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())
edge = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
# -1 → 0,1に塗っていきます
color=[-1 for i in range(n)]
def dfs(pos):
    ret = True
    for i in range(len(edge[pos])):
        to = edge[pos][i]
        if color[to] == -1:
            color[to] = 1 ^ color[pos]
            ret &= dfs(to)
        else:
            ret &= not (color[to]==color[pos])
    return ret

color[0]=0
if dfs(0):
    black, white = 0, 0
    for i in range(n):
        if color[i]==0:
            black += 1
        else:
            white += 1
    print(black*white-m)
else:
    print(n*(n-1)//2-m)

Measured memory_bytes: 43796
/*
Author: CNYALI_LK
LANG: C++
PROG: A.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int read(){
	int s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WriteIntBuffer[1024];
template<class T>void write(T a,char end){
	int cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WriteIntBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WriteIntBuffer[cnt]);--cnt;}
	putchar(end);
}
int c[233333];
int cmp(int a,int b){return a>b;}
int main(){
#ifdef cnyali_lk
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
#endif
	int n,k;
	n=read();k=read();
	for(int i=1;i<=n;++i)++c[read()];
	sort(c+1,c+n+1,cmp);
	for(int i=1;i<=k;++i)n-=c[i];
	printf("%d\n",n);
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    IO
    ll k,a,b;
    cin>>k>>a>>b;
    ll ans=(b/k)-(a/k);
    if(ans==0 && (b%k!=0) && (a%k!=0))
    cout<<"NG";
    else
    cout<<"OK";
    return 0;
}

Measured memory_bytes: 3652
use proconio::input;
use std::collections::VecDeque;


fn main() {
    let (n,g) = {
        input! {
            n:usize,
            m:usize,
            ab:[(usize,usize);m],
        };
        let mut g = vec![Vec::<usize>::new();n];
        ab.into_iter().for_each(|(a,b)|{
            g[a-1].push(b-1);
            g[b-1].push(a-1);
        });
        (n,g)
    };
    let mut ans:Vec<Option<usize>> = vec![None;n];
    let mut que = VecDeque::<usize>::new();
    que.push_front(0);
    while let Some(v) = que.pop_front() {
        for &to in &g[v] {
            if to!=0 && ans[to].is_none() {
                ans[to] = Some(v);
                que.push_back(to);
            }
        }
    }
    println!("Yes");
    
    let mut iter = ans.iter();
    iter.next();
    for &v in iter {
        let p = match v {
            Some(x) => x as i32,
            _ => -1
        };
        println!("{}",p+1);
    }
}


Measured memory_bytes: 16064
#include <iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main(){
  long long n;
  cin >> n;
  char a[50]; a[1]='a';
  int b[50];
  rep(i,25){
    a[i+2] = a[i+1] + 1;
    b[i]=0;
  }
  
  for(int i=0; n>0; i++){
    b[i] = n % 26;
    if(b[i] == 0){b[i] = 26;}
    n = (n-1) / 26;
  }
  
  for(int i=20; i>=0; i--){
    if(b[i] != 0){
      cout << a[b[i]];
    }
  }
  
  return 0;
}


Measured memory_bytes: 3636