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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 1e18;
const int MAXN = 1e6 + 5;
const int MOD = 20200429;

int n, m, a[MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	int sum = 0;
	for(int i=1; i<=n; i++) cin >> a[i], sum += a[i];
	sort(a+1, a+1+n, greater<int>());
	int c = sum / (4*m);
	if(sum % (4 * m)) c++;
	for(int i=1; i<=m; i++) if(a[i] < c) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define f(i,a,b) for(i=a;i<b;i++)

using namespace std;

int main() {
    int n,i;
    cin>>n;
    
    string s;
    
map<string,int>m;
f(i,0,n)
{
    cin>>s;
    m[s]++;
}

cout<<"AC x "<<to_string(m["AC"])<<'\n';
cout<<"WA x "<<to_string(m["WA"])<<'\n';
cout<<"TLE x "<<to_string(m["TLE"])<<'\n';

cout<<"RE x "<<to_string(m["RE"])<<'\n';

}

Measured memory_bytes: 3696
import java.util.*;
import java.lang.*;

public class Main {
	static long mod = 1000000007;
	static int h;
	static int w;
	static int k;
	static long[][] dp;
	static int i;
	static int j;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		k = sc.nextInt();
		dp = new long[h + 1][w + 2];
		dp[0][1] = 1;
		for (i = 1; i <= h; i++) {
			for (j = 1; j <= w; j++) {
				dfs(1, false, false, false);
			}
		}
		System.out.println(dp[h][k]);
	}
	static void dfs(int now, boolean te, boolean mae, boolean ato) {
		if (now == w) {
			if (mae) {
				dp[i][j] += dp[i - 1][j - 1];
				dp[i][j] %= mod;
			} else if (ato) {
				dp[i][j] += dp[i - 1][j + 1];
				dp[i][j] %= mod;
			} else {
				dp[i][j] += dp[i - 1][j];
				dp[i][j] %= mod;
			}
			return;
		}
		if (te) {
			dfs(now + 1, false, mae, ato);
		} else if (now == j - 1) {
			dfs(now + 1, true, true, false);
			dfs(now + 1, false, mae, ato);
		} else if (now == j) {
			dfs(now + 1, true, mae, true);
			dfs(now + 1, false, mae, ato);
		} else {
			dfs(now + 1, true, mae, ato);
			dfs(now + 1, false, mae, ato);
		}

	}
}

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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  int a;
  cin >> a;
  string s,t;
  cin >> s >> t;
  rep(i,a){
    cout << s[i] << t[i] ;
  }
  
  return 0;

}

Measured memory_bytes: 3608
s=j=0
a=[];b=[];d=[]
for i,x in enumerate(input()):
    if x=='\\':a+=[i]
    elif x=='/' and a:
        j=a.pop()
        c=i-j;s+=c
        while b and b[-1]>j:c+=d.pop();b.pop()
        b+=[j];d+=[c]
print(s)
print(len(b),*(d))



Measured memory_bytes: 6244
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;
//配列要素数
static const int MAX = 200000;
//値
static const ll MX = 1e18;

using namespace std;

//#include "./lib/generic/search.h"

#define M 1064527

int main(){
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    ll An=A, Bn=B;
    REP(i, T){
        if(An>Bn){
            Bn-=W;
            An-=V;
            if(An<=Bn){
                cout << "YES" << endl;
                return 0;
            }
        }
        else if(An<Bn){
            Bn+=W;
            An+=V;
            if(An>=Bn){
                cout << "YES" << endl;
                return 0;
            }
        }
        else if(An==Bn){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3632
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [u32; n],
    }

    let mut ans = 0;
    for i in 0..n - 1 {
        if a[i] == (i + 1) as u32 {
            a.swap(i, i + 1);
            ans += 1;
        }
    }
    if a[n - 1] == n as u32 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
 
int main()
{
  int N; cin >> N;
  vector<int> X;
  X.resize(N+1);
  for (int i = 1; i <= N; ++i) cin >> X[i];
  
  int ans = INT32_MAX;
  for (int p = 1; p <= 100; ++p) {
    ll total_cost = 0;
    for (int i = 1; i <= N; ++i) {
      int cost = (X[i] - p) * (X[i] - p);
      total_cost += cost;
    }
    ans = min(total_cost, (ll)ans);
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    int num[40] = {0};
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        int x, tmp;
        scanf("%d", &x);
        for (int j = 0; j < x; j++)
        {
            scanf("%d", &tmp);
            num[tmp]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= m; i++)
        if (num[i] == n)
            ans++;
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#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;
const int inf = 1001001001;

int modpow(ll a, ll n, ll p){
  if(n==0) return 1;
  if(n==1) return a%p;
  if(n%2 == 1) return (a*modpow(a,n-1,p))%p;
  ll t = modpow(a,n/2, p);
  return (t*t)%p;
 }

ll modnCa(ll n, ll a, ll p){
  ll upper = 1;
  ll lower = 1;
  for(ll i = 1; i <= a; i++){
    upper *= n-i+1;
    upper %= p;
    lower *= i;
    lower %= p;
  }
  ll inv_lower = modpow(lower, p-2, p);
  return (upper * inv_lower)%p;
}


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

  ll m = s/3;

  ll ans = 0;
  for(int i = 1; i<= m; i++){
    ans += modnCa(s-3*i+i-1, i-1, 1000000007);
    ans %= 1000000007;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <algorithm>
#include <string.h>

int t1,t2,t3;

int n;
int a[305][305];

struct edge{int u,v,w;};
bool esort(edge e1,edge e2)
{
    return e1.w<e2.w;
}
edge e[90005];
int e2=0;

long long g[305][305];      // graph weights as it is constructed

long long ans=0;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            scanf("%d",&a[i][j]);
            if (i<j) {
                e[e2].u=i;
                e[e2].v=j;
                e[e2].w=a[i][j];
                e2++;
            }
        }
        memset(g[i],0x3f,sizeof g[i]);
        g[i][i]=0;
    }
    std::sort(e,e+e2,esort);
    for (int i=0; i<e2; i++) {
        t1=e[i].u;
        t2=e[i].v;
        t3=e[i].w;
        if (g[t1][t2]<t3) {
            printf("-1\n");
            return 0;
        }
        if (g[t1][t2]==t3) {
            continue;
        }
        // add an edge
        //printf("%d add edge %d %d %d\n",g[t1][t2],t1,t2,t3);
        ans+=t3;
        g[t1][t2]=t3;
        for (int j=0; j<n; j++) {
            for (int k=0; k<n; k++) {
                if (g[j][k]>g[j][t1]+t3+g[t2][k]) {
                    g[j][k]=g[j][t1]+t3+g[t2][k];
                }
                if (g[j][k]>g[j][t2]+t3+g[t1][k]) {
                    g[j][k]=g[j][t2]+t3+g[t1][k];
                }
            }
        }
        /*for (int j=0; j<n; j++) {
            for (int k=j+1; k<n; k++) {
                if (g[j][k]!=0x3f3f3f3f3f3f3f3f) printf("HAVE %d %d\n",j,k);
            }
        }*/
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    string s;
    cin >> s;
    int flaga = 0;
    int flagb = 0;
    for(int i=0; i<3; i++){
        if(s[i] == 'A') flaga = 1;
        else flagb = 1;
    }
    if(flaga == 1 && flagb == 1) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const ll INF = 1e16 + 7;
const int MAXN = 5e3 + 50;
const int MAXK = 2e2 + 5;
const double eps = 1e-9;
ll di[MAXN], b[MAXN][MAXK], a[MAXN];
int st[MAXK][MAXN], tmp[MAXK];ll sm[MAXN];

int main()
{
    int n, m;
    ni(n), ni(m);
    for (int i = 2; i <= n; i++) {
        nl(a[i]);
        di[i] = di[i - 1] + a[i];
    }
    ll ans = -INF;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            nl(b[i][j]);
            int t = 0;
            while (tmp[j] > 0 && b[i][j] >= (t = b[st[j][tmp[j]]][j])) {
                sm[st[j][tmp[j]]] -= t;
                sm[st[j][tmp[j] - 1]] += t;
                tmp[j]--;
            }
            sm[i] += b[i][j];
            sm[st[j][tmp[j]]] -= b[i][j];
            st[j][++tmp[j]] = i;
        }
        ll cur = 0;
        for (int j = i; j > 0; j--) {
            cur += sm[j];
            ans = max(ans, cur - di[i] + di[j]);
        }
    }
    prl(ans);
    return 0;
}


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

int main(){
    int n,sum=0;
    cin>>n;
    string ans="No";
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(l.begin(),l.end());
    rep(i,n-1) sum+=l[i];
    if (l[n-1]<sum) ans="Yes";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class CarryCheese
    {
        public static void Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                var length = new int[3];
                length[0] = int.Parse(input[0]);
                length[1] = int.Parse(input[1]);
                length[2] = int.Parse(input[2]);
                if (length[0] == 0) { break; }

                Array.Sort(length);
                int x = length[0];
                int y = length[1];
                double dia = Math.Sqrt((x * x) + (y * y));

                int cnt = int.Parse(Console.ReadLine());
                for (int i = 0; i < cnt; i++)
                {
                    int r = int.Parse(Console.ReadLine());
                    if (dia < 2 * r) { Console.WriteLine("OK"); }
                    else { Console.WriteLine("NA"); }
                }
            }
        }
    }
}

Measured memory_bytes: 9068
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines = br.readLine().split(" ");
      int m = Integer.parseInt(lines[0]);
      int f = Integer.parseInt(lines[1]);
      int b = Integer.parseInt(lines[2]);

      if( b <= m ) System.out.println(0);
      else if( b <= m + f ) System.out.println(b - m);
      else System.out.println("NA");
    }
  }
}


Measured memory_bytes: 24216
#include<bits/stdc++.h>
#define mod 1000000007L
using namespace std;

int main()
{
  int h, w;
  scanf("%d%d", &h, &w);
  string c[h];
  for(int i = 0; i < h; i++)
  {
    cin >> c[i];
  }
  long long dp[h + 1][w + 1];
  memset(dp, 0, sizeof dp);
  dp[1][1] = 1;
  for(int row = 1; row <= h; row++)
  {
    for(int col = 1; col <= w; col++)
    {
      if(c[row - 1][col - 1] == '#')
        dp[row][col] = 0;
      else
        dp[row][col] += dp[row - 1][col] + dp[row][col - 1];
      dp[row][col] %= mod;  
    }
  }
  printf("%lld", dp[h][w]);
  
  return 0;
}


Measured memory_bytes: 9088
N,A,B = map(int,input().split())
K = N%(A+B)
L = N//(A+B)*A
if A == 0:
    print(0)
elif N<A:
    print(N)
elif A==N:
    print(A)
elif N<=(A+B):
    print(A)
else:
    if N%(A+B) > A:
        print(L+A)
    else:
        print(L+K)


Measured memory_bytes: 3060
# N回操作した時の最小値を求める
# ただし、前回の値にしか操作は影響されないから、
# 各回で小さくなる操作を選べば良い

n = int(input())
k = int(input())
ans = 1
for i in range(n):
    ans = min(ans+k,ans*2)
print(ans)


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

int main() {
  string S;
  cin >> S;
  int s = S.size();
  bool ans = true;
  for (int i = 0; i < s; i++) {
    if (i % 2 == 0 && S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
      ans = false;
      break;
    }
    else if (i % 2 == 1 && S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n, r; cin >> n >> r;
  cout << (n >= 10 ? r : r+100*(10-n)) << endl;


  return 0;
}

// EOF


Measured memory_bytes: 256
import numpy as np


def main():
	#N, D = [int(x) for x in input().split()]
	N = int(input())
	
	max_num = 0
	sub_max = 0
	index = 0
	for i in range(N):
		num = int(input())
		if num > max_num:
			index = i
			sub_max = max_num
			max_num = num
		elif num > sub_max:
			sub_max = num

	for i in range(N):
		if i == index:
			print(sub_max)
		else:
			print(max_num)

if __name__ == "__main__":
	main()


Measured memory_bytes: 21496
numberOfDiscountTickets=input().split()[2]
refrigirators=input().split()
microwaves=input().split()
discounts=[]
for i in range(int(numberOfDiscountTickets)):
 discounts.append(input().split())
temp1=sorted(refrigirators)
temp2=sorted(microwaves)
minimumPrice=int(temp1[0])+int(temp2[0])
checkMin=0
for discount in discounts:
 checkMin=int(refrigirators[int(discount[0])-1])+int(microwaves[int(discount[1])-1])-int(discount[2])
 if checkMin<minimumPrice:
  minimumPrice=checkMin
print(minimumPrice)



Measured memory_bytes: 52356
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
signed main()
{
	cin>>n>>m;
	if(n==1&&m==1)cout<<1;
	else if(n==1)cout<<m-2;
	else if(m==1)cout<<n-2;
	else cout<<(n-2)*(m-2);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		 Scanner sc = new Scanner(System.in);
	        int s, m, h;
	        s = sc.nextInt();

	        h = s / 3600;
	        m = (s%3600) / 60;
	        s = s % 60;

	        System.out.println(h+":"+m+":"+s);
	        sc.close();
	}
}



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


int main() {
    int N, num = 1, ans;
    cin >> N;
    vector<int> s(N);
    for(int i =0; i<N; i++) cin >> s[i];
    for(int i = 0; i<N; i++) if(s[i] == num) num++;
    ans = N - (num-1);
    if(num == 1) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	char op;
	while(true){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '?') break;
		switch(op){
		case '+':
			printf("%d\n",a+b);
			break;
		case '-':
			printf("%d\n",a-b);
			break;
		case '/':
			printf("%d\n",a/b);
			break;
		case '*':
			printf("%d\n",a*b);
			break;
		}
	}
}



Measured memory_bytes: 2692
#include<stdio.h>

int main()
{
	long long l,h;
	scanf("%lld%lld",&h,&l);
	if (h==1||l==1)
	{
		printf("1");
		return 0;
	}
	long long half1,half2;
	half1=h/2;
	if (h%2==1) ++half1;
	half2=l/2;
	if (l%2==1) ++half2;
	long long ans;
	ans=half1*half2+(h-half1)*(l-half2);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N = int(input())

A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
import numpy as np

N, L = map(int, input().split())

arr = np.arange(1, N+1)
taste = arr + L - 1
total = sum(taste)

min_sa = INF
ans = 0
for a in taste:
    ext = total - a
    sa = abs(total - ext)
    if min_sa > sa:
        ans = ext
        min_sa = sa

print(ans)


# def main():

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


Measured memory_bytes: 12256
import sys
N, K = map(int, input().split())
mod = 7 + 10 ** 9
fact = [1] * (N + 1)
for i in range(1, N + 1): fact[i] = (i * fact[i-1]) % mod
revfact = [1] * (N + 1)
revfact[N] = pow(fact[N], mod - 2, mod)
for i in reversed(range(1, N)): revfact[i] = (revfact[i+1] * (i + 1)) % mod

def comb(n, r):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod

def solve():
    Ans = [0] * K
    for i in range(K):
        if i + 1 > N - K + 1: continue
        place = comb(N - K + 1, i + 1)
        rem = K - i - 1
        remPatt = comb(rem + i, i)
        Ans[i] = (place * remPatt) % mod
    print("\n".join(map(str, Ans)))

    return 0

if __name__ == "__main__":
    solve()

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

using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

using num = modnum<998244353>;

vector<num> fact = {1};

void init(){
	for(int i = 1; i < 5100000; i++){
		fact.push_back(fact[i-1] * i);
	}	
}

num ncr(int a, int b){
	if(b > a || b < 0) return 0;
	return fact[a] / fact[a-b] / fact[b];
}


int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	init();
	int n, m;
	cin >> n >> m;
	num ans = 0;
	ans += ncr(3*m + n-1, n-1);
	ans -= ncr(m-1 + n-1, n-1) * n;
	for(int odd = m+2; odd <= n; odd += 2){
		ans -= ncr(n, odd) * ncr((3*m-odd)/2 + n-1, n-1);
	}
	cout << (int)ans << '\n';
}

Measured memory_bytes: 35172
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll x;
  vector<ll> a;
  cin >> x;
  a.push_back(0);
  map<ll, int> map;
  map[0] = 0;
  REP(i, 1000) {
    ll tmp = pow(i + 1, 5);
    a.push_back(tmp);
    a.push_back(-tmp);
    map[tmp] = i + 1;
    map[-tmp] = -(i + 1);
  }

  for(auto i : a) {
    for(auto j : a) {
      if(i - j == x) {
        cout << map[i] << " " << map[j] << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4216
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long[][] xy=new long[n][3];
        for(int i=0;i<n;i++){
            for(int j=0;j<2;j++){
                xy[i][j]=Long.parseLong(sc.next());
            }
            xy[i][2]=i;
        }
        sc.close();
        Arrays.sort(xy, (u,v)->u[0]>v[0]?1:u[0]<v[0]?-1:0);
        Edge[] edges=new Edge[2*(n-1)];
        for(int i=0;i<n-1;i++){
            edges[i]=new Edge((int) xy[i][2], (int) xy[i+1][2], xy[i+1][0]-xy[i][0]);
        }
        Arrays.sort(xy, (u,v)->u[1]>v[1]?1:u[1]<v[1]?-1:0);
        for(int i=0;i<n-1;i++){
            edges[i+n-1]=new Edge((int) xy[i][2], (int) xy[i+1][2], xy[i+1][1]-xy[i][1]);
        }
        Edge[] mst=kruskal(n, edges);
        long ans=0;
        for(Edge e: mst){
            ans+=e.cost;
        }
        System.out.println(ans);
    }

    public static Edge[] kruskal(int n, Edge[] edges){
        UnionFindTree uft=new UnionFindTree(n);
        PriorityQueue<Edge> pq=new PriorityQueue<>((u, v)->u.cost>v.cost?1:u.cost<v.cost?-1:0);
        for(Edge e:edges) pq.add(e);
        Edge[] ret=new Edge[n-1];
        int index=0;
        while(pq.size()>0 && index<n){
            Edge e=pq.poll();
            if(uft.unite(e.u, e.v)) ret[index++]=e;
        }
        return ret;
    }

    static class Edge{
        int u, v;
        long cost;
        public Edge(int u, int v, long cost){
            this.u=u;
            this.v=v;
            this.cost=cost;
        }
    }

    static class UnionFindTree{
        private int[] parent, rank;
        UnionFindTree(int n){
            parent=new int[n];
            rank=new int[n];
            for(int i=0;i<n;i++) parent[i]=i;
        }
        int root(int x){
            if(parent[x]==x) return x;
            parent[x]=root(parent[x]);
            return parent[x];
        }
        boolean unite(int x, int y){
            int xr=root(x);
            int yr=root(y);
            if(xr==yr) return false;
            if(rank[xr]<rank[yr]) parent[xr]=yr;
            else{
                parent[yr]=xr;
                if(rank[xr]==rank[yr]) rank[xr]++;
            }
            return true;
        }
    }
}


Measured memory_bytes: 66468
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;


void solve(){

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(max(a*c,a*d), max(b*c,b*d)) << endl;

}

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


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int ans = -1;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            int now = A[i] * A[j];
            int d = now % 10;
            now /= 10;
            bool is_ok = true;
            while (now > 0) {
                if (d - 1 != now % 10) {
                    is_ok = false;
                    break;
                }
                d = now % 10;
                now /= 10;
            }
            if (is_ok) {
                ans = max(ans, A[i] * A[j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3232
#include<stdio.h>


#define max(a,b) ((a>b)?a:b)

int main(void){
    int r,c,n,map[10][10000],ans,tmp,i,j,h,digit[10]={1,2,4,8,16,32,64,128,512,1024},status[10],line;
    scanf("%d%d",&r,&c);
    while(r!=0 || c!=0){
        n = 1;
        ans = 0;
        for(i=0; i<r; i++){
            n*=2;
            for(j=0; j<c; j++){
                scanf("%d",&map[i][j]);
            }
        }
        for(i=0; i<n; i++){
            tmp = 0;
            for(j=0; j<r; j++){
                status[j] = (i&digit[j])?1:0;
            }
            for(j=0; j<c; j++){
                line = 0;
                for(h=0; h<r; h++){
                    line+=(map[h][j]^status[h]);
                }
                tmp+=max(line,r-line);
            }
            if(ans<tmp){
                ans = tmp;
            }
        }
        printf("%d\n",ans);
        scanf("%d%d",&r,&c);
    }
    return 0;
}

Measured memory_bytes: 1420
#include <bits/stdc++.h>
            using namespace std;
             
            int main(){
              int n;
              cin >> n;
              vector<int> card(n);
              for(int i=0; i<n; i++){
                cin >> card.at(i);
              }
              sort(card.begin(), card.end());
              reverse(card.begin(), card.end());
              bool flag = true;
              int alice= 0;
              int bob = 0;
              for(int i=0; i<n; i++){
                if(flag){alice += card.at(i);flag = false;}
                else{bob += card.at(i);flag = true;}
              }
              cout << alice - bob << endl;
              return 0;
            }


Measured memory_bytes: 256
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
Left  = A.index(1)
Right = (N-1)-Left
Count = (Right%(K-1)!=0)+Right//(K-1)
Left -= ((K-1)-Right%(K-1))%(K-1)
Count += (Left%(K-1)!=0)+Left//(K-1)
print(Count)

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

#define int long long

using namespace std;

const int MAXN = 2e5 + 100;

vector<int> L[MAXN];

bool mk[MAXN];

int cont = 0;

void DFS(int nodo)
{
	cont++;
	mk[nodo] = true;

	for(auto v : L[nodo])
	{
		if(!mk[v])
		{
			DFS(v);
		}
	}
}

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

    int N, M;
    cin >> N >> M;

    for(int i = 0 ; i < M ; i++)
    {
    	int a, b;
    	cin >> a >> b;
    	L[a].push_back(b);
    	L[b].push_back(a);
    }

    int res = 0;

    for(int i = 1 ; i <= N ; i++)
    {
    	if(!mk[i])
    	{
    		cont = 0;
    		DFS(i);
    		res = max(res, cont);
    	}
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 20972
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int t = b - a;
	int x = 0;
	for (int i = 0; i <= t; i++)x += i;
	
	cout << x - b << endl;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


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

  if(a%2==0||b%2==0||c%2==0){
  cout << 0 << endl;
  }
  
  else if(max(max(a,b),c)==a){
  cout << b*c << endl;
  }
  
  else if(max(max(a,b),c)==b){
  cout << a*c << endl;
  }
  
  else{
  cout << b*a << endl;
  }
  
}


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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second

typedef long long int ll;

const ll INF = 1e10;
ll p[100];


main(){
	IOS;
	ll n;
	string s;
	cin>>s;
	cin>>n;
	ll len = s.length();
	for(int i=0;i<len;i++){
		if(s[i] == '1'){
			p[i] = 1;
		}
		else if(s[i] == '2'){
			p[i] = 2;
		}
		else if(s[i] == '3'){
			p[i] = 3;
		}
		else if(s[i] == '4'){
			p[i] = 4;
		}
		else if(s[i] == '5'){
			p[i] = 5;
		}
		else if(s[i] == '6'){
			p[i] = 6;
		}
		else if(s[i] == '7'){
			p[i] = 7;
		}
		else if(s[i] == '8'){
			p[i] = 8;
		}
		else {
			p[i] = 9;
		}
	}

	ll ans = 0;
	
	for(int i=0;i<len;i++){
		if (p[i] != 1){
			ans = i;
			break;
		}
	}
	ans = ans + 1;
	if(n < ans){
		cout<<"1"<<endl;
	}
	else{
		cout<<p[ans-1]<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
def diff(num)
  num % 10 != 0 ? num % 10 : 10
end

dishes = 5.times.map { gets.to_i }
last = dishes.min { |a, b| diff(a) <=> diff(b) }

ans = 0
calculated_last = false

dishes.each do |d|
  if d == last && !calculated_last
    ans += d
    calculated_last = true
  else
    ans += d + (10 - diff(d)).abs
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
    	string str;
    	cin>>str;
    	ll k; cin>>k;
    	vl vec;
    	ll n = s(str);
    	char x ='#';
    	ll cur = 0;
    	ll ans = 0;
    	rep(i, n){
    		if(str[i] == x)	cur++;
    		else{ 
    			x = str[i];if(cur) vec.pb(cur);
    			cur = 1;
    		}
    	}
    	vec.pb(cur);
    	if(s(vec) == 1){
    		ans = (n*k)/2;
    	}else{
    		ll m = s(vec);
    		for(ll u : vec)	ans += k*(u/2);
    		if(str[0] == str[n-1] && vec[0] & 1 && vec[m-1] & 1)	ans += (k-1);
    	}
    	cout<<ans;

    }
}

Measured memory_bytes: 3576
h,w = map(int,input().split())
if h == 1 or w == 1:
    print(1)
else :
    a = int((h / 2) + (h % 2)) * int((w / 2) + (w % 2)) 
    b = int(h / 2) * int(w / 2)
    print(a + b)

Measured memory_bytes: 3316
N, X = map(int, input().split())
*V, = map(int, input().split())

MOD = 10**9 + 7

V.sort()

S = [0]*(X+1)
S[X] = 1
T = [0]*(X+1)
zeros = [0]*(X+1)
for i in range(N-1, -1, -1):
    T[:] = zeros
    for k in range(X+1):
        S[k] %= MOD
        T[k] += S[k] * i % MOD
        T[k % V[i]] += S[k]
    S, T = T, S
print(sum(k*S[k] % MOD for k in range(V[0])) % MOD)

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

void comb(std::vector<std::vector<unsigned long long int>> &c)
{
    for (int i = 0; i < c.size(); i++)
    {
        c[i][0] = 1;
        c[i][i] = 1;
    }
    for (int i = 1; i < c.size(); i++)
    {
        for (int j = 1; j < i; j++)
        {
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
        }
    }
}

int main(){
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<unsigned long long int>> c(n + m + 1, std::vector<unsigned long long int>(n + m + 1));

    comb(c);

    std::cout << c[n + m][2] - n * m << std::endl;

    return 0;
}

Measured memory_bytes: 3904
#include <iostream>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;

#define all(c) (c).begin(), (c).end()
int const inf = 1<<29;

struct MCF {
    typedef int Weight;
    typedef int Capacity;
    struct Edge;
    int n;
    vector<vector<Edge> > g;
    vector<Weight> level;
    vector<Weight> iter;

    struct Edge {
        int src, dst;
        Capacity cap;
        int rev;
        bool isRev;
        Edge(int src, int dst, Capacity cap, int rev, bool isRev)
            :src(src), dst(dst), cap(cap), rev(rev), isRev(isRev) {}
    };

    MCF(int n_)
        : n(n_), g(vector<vector<Edge> >(n_)), level(n_), iter(n_) {}

    void add_edge(int src, int dst, Capacity cap) {
        g[src].push_back(Edge(src, dst, cap, g[dst].size(), false));
        g[dst].push_back(Edge(dst, src, 0, g[src].size() - 1, true));
    }

    void bfs(int s) {
        fill(all(level), -1);
        queue<Weight> q;
        level[s] = 0;
        q.push(s);
        while (q.size()) {
            int v = q.front(); q.pop();
            for(int i = 0; i < (int)g[v].size(); i++){
                Edge& e = g[v][i];
                if (e.cap > 0 && level[e.dst] < 0) {
                    level[e.dst] = level[v] + 1;
                    q.push(e.dst);
                }
            }
        }
    }

    Capacity dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < (int)g[v].size(); i++) {
            Edge &e = g[v][i];
            if (e.cap > 0 && level[v] < level[e.dst]) {
                int d = dfs(e.dst, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    g[e.dst][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    Capacity max_flow(int src, int dst) {
        int flow = 0;
        while(1){
            bfs(src);
            if (level[dst] < 0) return flow;
            fill(all(iter), 0);
            int f;
            while ((f = dfs(src, dst, inf)) > 0) {
                flow += f;
            }
        }
    }

    void view(){
        for(int i=0;i<g.size();i++){
            for(int j=0;j<g[i].size();j++){
                auto & e=g[i][j];
                printf("%d->%d (%d)\n", e.src, e.dst, e.cap);
            }
        }
    }
};

int main(){
    int X,Y,E;
    cin >> X >> Y >> E;
    int N=X+Y;
    MCF mcf(N+2);
    int S=N, T=N+1;
    for(int i=0;i<E;i++){
        int x, y;
        cin >> x >> y;
        mcf.add_edge(x,y+X,1);
    }
    for(int i=0;i<X;i++){
        mcf.add_edge(S,i,1);
    }
    for(int i=0;i<Y;i++){
        mcf.add_edge(i+X,T,1);
    }
    cout << mcf.max_flow(S,T) << endl;
    // printf("X : {");
    // for(int i=0;i<X;i++){
    //     printf("%d%s",i,i==X-1?"}\n":",");
    // }
    // printf("Y : {");
    // for(int i=0;i<Y;i++){
    //     printf("%d%s",i+X,i==Y-1?"}\n":",");
    // }
    // mcf.view();
}

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

long long int ans = 0;
long long int n,x,y,z;

bool check(long long int* a){
  long long int u,b;
  u = 0;  b = 10000000000002000;
  for(int i=0;i<n;i++){
    if(a[i] > u){
      u = a[i];
      y = i;
    }
    if(a[i] < b){
      b = a[i];
      x = i;
    }
  }
  z = ( u - b ) / (n + 1);

  return ( u - b >= n + 1 );
}

void sub(long long int* a){
  for(int i=0;i<n;i++){
    if(i == y)
      a[i] -= n * z;
    else
      a[i] += z;
  }
  ans += z;
}


int main()
{
  cin >> n;
  long long int a[50]={};

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

  //minとmaxの差を埋める
  while(check(a)){
    sub(a);
  }

  //minを下げる
  if(a[x] >= n){
    long long int tmp = a[x] + 1 - n;
    for(int i=0;i<n;i++)
      a[i] -= tmp;
    ans += tmp * n;
  }

  //あとは普通にやる
  while(true){
    sort(a,a+n);
    if(a[n-1]<n)
      break;

    for(int i=0;i<n;i++){
      if(i != n-1)
        a[i] ++;
      else
        a[i] -= n;
      }
      ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int main(){
	char p[7][19] = {"1100000011", "10000000100000001", "1111", "1000000110000001", "11000000011", "100000001100000001", "110000011"};
	char f[65];
	char t;
	while(1 + scanf("%c", &t)){
		while(t == 10){
			scanf("%c", &t);
		}
		f[0] = t;
		for(int i = 1; i < 64; i++){
			scanf("%c", &t);
			while(t == 10){
				scanf("%c", &t);
			}
			f[i] = t;
		}
		f[64] = '\0';
		for(int i = 0; i < 7; i++){
			if(strstr(f, p[i])){
				printf("%c\n", i + 'A');
			}
		}
		scanf("%c", &t);
	}
	return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define inf 2e18
using namespace std;
typedef long long ll;
typedef pair<ll,ll>p;
int main()
{
    //freopen("in.txt", "r", stdin);
    ll n;
    cin>>n;
    ll mn=inf;
    ll a=n,b=1;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
           if(abs(n/i-i)<mn){
            mn=abs(n/i-i);
            a=n/i;
            b=i;
           }
        }
    }
    if(a<10 && b<10){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    rep(i, a+1){
      rep(j, b+1){
        rep(k, c+1){
          if(500 * i + 100 * j + 50 * k == x) ans++;
        }
      }
    }
    print(ans);
}

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

#define endl '\n'

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

    long long h, qtd=1, ans=0; cin >> h;
    while(h > 1){
        h >>= 1LL;
        ans+= qtd;
        qtd *= 2LL;
    }
    cout << ans + qtd << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int main() {
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	if(H%h==0 && W%w==0)return !printf("No");
	puts("Yes");
	fup(i,0,H-1,1)
	{
		fup(j,0,W-1,1)
		{
			if(i%h==0 && j%w==0)printf("%d ",1000*(h*w-1)-1);
			else printf("-1000 ");
		}
		puts("");
	}
}

Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }


int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	int *L = (int *)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}
	qsort(L, N, sizeof(int), cmp_r);
	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += L[i];
	}
	int ans;
	ans = sum;
	printf("%d\n", ans);






#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
condition = []
for i in range(M):
    s, c = map(int, input().split())
    condition.append([s,c])

if N>1:
    start = 10**(N-1)
    end = 10**N-1
else:
    start = 0
    end = 9

end_flag = 0

for i in range(start, end+1):
    flag = 1
    for elem in condition:
        if str(i)[elem[0]-1] != str(elem[1]):
            flag = 0
    if flag == 1:
        end_flag = 1
        print(i)
        break

if end_flag == 0:
    print(-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    rep(i, n) cin >> as[i];
    int ma = -1;
    for(int a :  as) ma = max(ma, a);
    int ha = ma/2; 
    int hdiff = numeric_limits<int>::max(); 
    int ta; 
    for(int a :  as) {
        if (a == ma) continue;
        if (abs(a-ha) < hdiff) {
            hdiff = abs(a-ha);
            ta = a; 
        }
    }
    cout << ma << " " << ta << endl; 
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
int w,n;
cin>>w>>n;
vector<int> number(w);
REP(i, w){
	number[i]=i+1;
}
REP(i,n){
string s,s2;
	getline(cin, s,',');
	getline(cin, s2);
	int a,b;
	a = atoi(s.c_str());
	b = atoi(s2.c_str());
	int t=number[a-1];
	number[a - 1] = number[b-1];
	number[b - 1]=t;
}
REP(i, w)
cout << number[i]<<endl;
}

Measured memory_bytes: 3124