akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); 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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];
    bool ok = true;
    rep(i,N){
        if(A[i]%2==0)if (A[i] % 3 != 0 && A[i] % 5 != 0) ok = false;
    }
    if (ok) cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (max, left, right) = readLine()!!.split(" ").map(String::toInt)
    var total = 0
    for (num in 0..max) {
        val subtotal = num.toString().sumBy { Integer.parseInt(it.toString()) }
        if (left <= subtotal && subtotal <= right) total += num
    }
    print(total)
}

Measured memory_bytes: 40796
#include<stdio.h>
int main()
{
    char x,y;
    scanf("%c %c",&x, &y);
    if(x<y){
        printf("<\n");
    }
    else if(x==y){
        printf("=\n");
    }
    else{
        printf(">\n");
            }
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define drep(i,l,r) for(int (i)=(l);(i)>=(r);i--)
using namespace std;
int main(){
    ll n;
    cin>>n;
    vector<ll> a,b;
    rep(i,0,n){
        ll buf;
        cin>>buf;
        if(i%2) a.emplace_back(buf);
        else b.emplace_back(buf);
    }
    if(n%2){
        drep(i,(int)b.size()-1,0)cout<<b[i]<<" ";
        rep(i,0,(int)a.size())cout<<a[i]<<" ";
    }
    else{
        drep(i,(int)a.size()-1,0)cout<<a[i]<<" ";
        rep(i,0,(int)b.size())cout<<b[i]<<" ";
    }
    puts("");
}


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

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
  ll X,Y;
  cin >> X >> Y;
  if ((X + Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if (min(X,Y) * 2 < max(X,Y)) {
    cout << 0 << endl;
    return 0;
  }
  ll Mod = 1000000007;
  ll ans = 0;
  ll a = (X + Y) / 3;
  X = X - a;
  Y = Y - a;
  ll B[666669];
  B[0] = 1;
  B[1] = 1;
  for (int i = 2; i <= 666668; i++) {
    B[i] = B[i - 1] * i;
    B[i] %= Mod;
  }
  if (X > Y) {
    swap(X,Y);
  }
  ll n = (B[X] * B[Y]) % Mod;
  ll m = B[X+Y];
  cout << (modinv(n,Mod) * m) % Mod << endl;
  return 0;
}

Measured memory_bytes: 5504
using System;
class Program
{
	static void Main(string[] args)
	{
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int k = int.Parse(input[1]);
        int[] array = new int[n];
        string[] input2 = Console.ReadLine().Split(' ');
        for(int i=0; i<n; i++){
            array[i] = int.Parse(input2[i]);
        }
        Array.Sort(array);
        int sum = 0;
        for(int i=0; i<k; i++){
            sum += array[i];
        }	
        Console.WriteLine(sum);
	}
}

Measured memory_bytes: 18568
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for i in range(m):
  tmp = int(heapq.heappop(a) / 2)
  heapq.heappush(a, tmp)
print(-1 * sum(a))

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

int main()
{
	int N, T;
	cin >> N >> T;
	vector<int> pe(T + 1);
	for (int i = 0, l, r; i < N; i++) {
		cin >> l >> r;
		pe[l]++;
		pe[r]--;
	}
	int res = pe[0];
	for (int i = 1; i <= T; i++) {
		pe[i] += pe[i - 1];
		res = max(res, pe[i]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3108
N = int(input())
A = list(map(int, input().split()))

max_len = len((bin(max(A))[2:]))
for i in range(N):
    A[i] = '0' * (max_len - len(bin(A[i])[2:])) + bin(A[i])[2:]


flag = True
for i in range(len(A[0])):
    tmp = 0
    for j in range(N):

        if A[j][i] == '1':
            tmp += 1
            
    if tmp%2 == 0:
        flag = True
    else:
        flag = False
        break
               
if flag:
    print('Yes')
else:
    print('No')



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

int main() {
    int S;
    cin >> S;
    int h = S/3600;
    int m = (S-3600*h)/60;
    int s = S-(3600*h+60*m);
    cout << h << ":" << m << ":" << s << endl;
  return 0;
}


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

long long N, M, X;
vector<vector<long long>> A(15, vector<long long>(15));

int main(){
    
    cin >> N >> M >> X;

    for (int i=0; i<N; i++){
        for (int j=0; j<M+1; j++){
            cin >> A.at(i).at(j);
        }
    }

    long long price = 1e9, price_tmp = 0;
    vector<long long> skills(15);
    bool OK = false, flg = false;

    for (int tmp=0; tmp<(1<<N); tmp++){
        bitset<12> bits(tmp);
//        cout << "tmp = " << tmp << endl;

        price_tmp = 0;
        for (int j=1; j<M+1; j++){
            skills.at(j) = 0;
        }

        for (int i=0; i<N; i++){
            if (bits.test(i)){
                price_tmp += A.at(i).at(0);
                for (int j=1; j<M+1; j++){
                    skills.at(j) += A.at(i).at(j);
                }
            }
        }

        flg = true;

        for (int j=1; j<M+1; j++){
            if (skills.at(j) < X){
                flg = false;
                break;
            }
        }

//        cout << "price_tmp = " << price_tmp << endl;

        if (flg){
            price = min(price, price_tmp);
            OK = true;
        }
    }

    if (OK){
        cout << price << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s;
    s=sc.next();
    if(s.equals("Sunny")){
      System.out.println("Cloudy");
    }
    if(s.equals("Cloudy")){
      System.out.println("Rainy");
    }
    if(s.equals("Rainy")){
      System.out.println("Sunny");
    }
  }
}


Measured memory_bytes: 19796
//jika 3 dan 5 bisa membagi i, dan a ke i = FizzBuzz
//jika tidak, tapi 3 bisa = Fizz
//jika 5 doang = Buzz
//jika gaada, a ke i = i
//cari jumlah semua angka dengan batas N


#include <stdio.h>
int main(){
	int batas;
	scanf("%d", &batas);
	long long int count = 0;
	
	for(int i =0; i<=batas; i++)
	{
		if(i%3 == 0 && i%5 == 0)
		{
			count+=0;
		}
		else if(i%3 == 0)
		{
			count+=0;
		}
		else if(i%5 == 0)
		{
			count+=0;
		}
		else 
		{
			count+=i;
		}
	}
	
	printf("%lld\n", count);
	
	return 0;
}

Measured memory_bytes: 1716
#include<stdio.h>
#define MIN(x,y) x<y?x:y


int main(void){
    int n,m,x,num;
    scanf("%d %d %d",&n,&m,&x);
    int place[m];
    int sum_1=0,sum_2=0;
    for(int i = 0; i < m; i++) scanf("%d",&place[i]);

    for(int i = 0; i < m; i++){
        if(place[i] < x){
            sum_1 += 1;
        }else if(place[i] > x){
            sum_2 += 1;
        }
    } 
    printf("%d\n",MIN(sum_1,sum_2));
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

cnt =0
flag = 0
while True:
  a = list(map(lambda x: x/2, a))
  for i in range(n):
    print
    if not a[i].is_integer():
      flag = 1
      break
  if flag == 1:
    break
  cnt += 1

print(cnt)  

Measured memory_bytes: 9120
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(a>0&&c>0)
	{
		a-=d,c-=b;
	}
	if(c<=0) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int a;
string b;
// main solution goes here:
void execute(int test_number)
{
    cin>>a>>b;
    b = b.substr(0, 1) + b.substr(2, 2);
    int c = 0;
    for (int i=0; i<b.size(); i++) c = c*10 + (b[i] - '0');
    cout<<a*c/100;
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main()
{
	int X, A, B;
	cin >> X >> A >> B;
	if (B <= A) {
		cout << "delicious" << endl;
	}
	else if (B - A <= X) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
}


Measured memory_bytes: 256
/* in the name of allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, a[N], dp[N], k;

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

void solve() {
	memset(dp, 63, sizeof dp);
	dp[0] = 0;
	for (int i = 1; i < n; i++)
		for (int j = 1; j <= k; j++)
			dp[i] = min(dp[i], dp[max(0, i - j)] + abs(a[i] - a[max(0, i - j)]));
	cout << dp[n - 1] << endl;
}

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


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;





int main(void){
	ll n;
	vll a;
	vector<vector<LLPair>> xy;
	cin >> n;
	a.resize(n);
	xy.resize(n);
	rep(i, n){
		cin >> a[i];
		xy[i].resize(a[i]);
		rep(j, a[i]){
			ll x, y; cin >> x >> y;
			x--;
			xy[i][j] = make_pair(x, y);
		}
	}

	int ans = 0;
	for(int i=0; i<(1<<n); i++){
		int count = 0;
		for(int j=0; j<n; j++){
			if((i>>j) % 2 == 0) continue;
			count++;
			if(i==3){
				bool flag = true;
			}
			for(int k=0; k<a[j]; k++){
				if((i>>(xy[j][k].first)) % 2 != (xy[j][k].second)){
					count = -INF;
					break;
				}
			}
			if(count < 0) break;
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  if (N==1||N==2||N==3||N==5||N==6||N==9||N==10||N==13||N==17) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

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

int n;
int a[200005];

int main(){

    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,[](const int &a,const int &b){
        return a>b;
    });
    int tot=n-1;
    long long ans=0;
    for(int i=0;i<n;i++){
        if(tot){
            ans+=a[i];
            tot--;
        }
        if(tot&&i){
            ans+=a[i];
            tot--;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int tmp = x * x + y * y + z * z + x * z + x * y + y * z;
                if (tmp <= n) a[tmp]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

bool dp[6000][1<<13];

ll const B = 1000000007;
ull p[6000], thash[6000];
ull shash[13];

int n,m;
int len;
char t[6000];
char ss[13][22];
int sslen[13];

int solve(){
    rep(i,n){
        ull x = 0;
        for(int j=0;ss[i][j];j++){
            x = x*B + ss[i][j];
        }
        shash[i] = x;
    }
    p[0] = 1;
    thash[0] = 0;
    rep(i,len){
        p[i+1] = p[i]*B;
        thash[i+1] = thash[i]*B + t[i];
    }

    rep(i,len+1)rep(j,1<<n) dp[i][j] = false;
    rep(i,len+1) dp[i][0] = true;
    rep(pos,len){
        rep(mask,1<<n){
            if(!dp[pos][mask]) continue;
            rep(i,n){
                if(mask>>i&1) continue;
                if(pos+sslen[i] > len) continue;
                ull h1 = shash[i];
                ull h2 = thash[pos+sslen[i]] - thash[pos] * p[sslen[i]];
                // if(h1 != h2) continue;
                dp[pos+sslen[i]][mask|1<<i] |= h1 == h2; // t.substr(pos,ss[i].size()) == ss[i];
            }
        }
    }

    int ans = 0;
    rep(i,len+1){
        if(dp[i][(1<<n)-1]){
            ++ans;
        }
    }
    return ans;
}

signed main(){
    while(scanf("%d%d",&n,&m), n){
        len = 0;
        rep(i,n){
            scanf("%s",ss[i]);
            sslen[i] = strlen(ss[i]);
        }
        rep(i,m){
            static char buf[22];
            scanf("%s",buf);
            int l = strlen(buf);
            rep(i,l) t[i+len] = buf[i];
            len += l;
        }
        cout << solve() << endl;
    }
}

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

const int N=100100,mod=1000000007;
typedef long long ll;
int ksm(ll a,int b,int c=1){
	for(;b;b/=2,a=a*a%mod)
		if(b&1)c=c*a%mod;
	return c;
}
int jc[N],f[N],g[N],jc2[N],n,A,B,C,D; 
void init(){
	jc[0]=1;
	for(int i=1;i<=n;++i)jc[i]=(ll)jc[i-1]*i%mod;
	jc2[n]=ksm(jc[n],mod-2);
	for(int i=n;i;--i)jc2[i-1]=(ll)jc2[i]*i%mod;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>A>>B>>C>>D;init();
	f[0]=1;
	for(int i=A;i<=B;++i){
		g[0]=1;
		for(int j=1;j<=n;++j)g[j]=(ll)g[j-1]*jc2[i]%mod;
		for(int j=n;j>=0;--j)if(f[j])
			for(int k=C;k<=D&&i*k+j<=n;++k)
				f[i*k+j]=(f[i*k+j]+(ll)f[j]*g[k]%mod*jc2[k])%mod;
	}
	cout<<((ll)f[n]*jc[n]%mod)<<'\n';
	return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int gcd(int x, int y){
  if(y==0)return x;
  return gcd(y,x%y);
}

int cnter(int n){
  int cnt = 0;
  while(n&&n%2==0){
    cnt++;
    n/=2;
  }
  return cnt;
}

int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  if(a <= d && c <= b){
    cout << min(b,d) - max(a,c) << endl;
  } else {
    cout << 0 << endl;
  }
} 


Measured memory_bytes: 3596
def mul_square_matrix(a, b, mod):
    n = len(a)
    ret = [[0] * n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]) % mod
    return ret


def power_square_matrix(mat:list, k, mod):
    n = len(mat)
    ret = [[0] * n for _ in range(n)]
    for i in range(n):
        ret[i][i] = 1
    while k > 0:
        if k % 2 == 1:
            ret = mul_square_matrix(ret, mat, mod)
        mat = mul_square_matrix(mat, mat, mod)
        k //= 2
    return ret

l, a, b, m = map(int, input().split())
s_foot = a + b * (l - 1)
digit_n = len(str(s_foot))
count_digit_n = [0] * (digit_n + 1)
d = 1
for i in range(1, digit_n + 1):
    d *= 10
    x = min(d - 1, s_foot) - a
    if x < 0:
        continue
    n = x // b
    count_digit_n[i] = n + 1

for i in range(digit_n, 0, -1):
    count_digit_n[i]  -= count_digit_n[i - 1]

d = 1
x = [[0], [a], [1]]
for n in count_digit_n[1:]:
    d = d * 10 % m
    if n == 0:
        continue
    mat = [[d, 1, 0], [0, 1, b], [0, 0, 1]]
    mat = power_square_matrix(mat, n, m)
    for i in range(3):
        x[i][0] = sum([mat[i][j] * x[j][0] for j in range(3)]) % m
print(x[0][0])

Measured memory_bytes: 9332
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<random>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
int d;
int c[30]={};
int s[370][30];
int num=100000;
int calc(vector<int>const& t,vector<vector<int>>& last_list){
  int res=0;
  vector<int> last(30,0);
  rep1(i,d){
    res+=s[i][t[i]];
    last[t[i]]=i;
    last_list[i]=last;
    int buf=0;
    rep1(j,26){
      buf+=c[j]*(i-last[j]);
    }
    res-=buf;
    //cout<<res<<"\n";
  }
  return res;
}
int change(int nd,int nq,int& res,vector<int>& t,vector<vector<int>>& last_list){
  int flag_t=false;
  int flag_q=false;
  int x=t[nd];
  t[nd]=0;
  res+=s[nd][nq];res-=s[nd][x];
  for(int i=nd;i<=d;++i){
    if(flag_t&&flag_q)break;
    if(t[i]==x||flag_t)flag_t=true;
    else{
      res+=c[x]*(i-last_list[i][x]);
      last_list[i][x]=last_list[i-1][x];
      res-=c[x]*(i-last_list[i][x]);
    }
    if(t[i]==nq||flag_q)flag_q=true;
    else{
      res+=c[nq]*(i-last_list[i][nq]);
      last_list[i][nq]=nd;
      res-=c[nq]*(i-last_list[i][nq]);
    }
  }
  t[nd]=nq;
  return res;
}
vector<int> greedy(int d){
  vector<int> res(d+1,0);
  vector<int> last(30,0);
  rep1(i,d){
    int mx=-inf;
    int mx_ind=0;
    rep1(j,26){
      int tmp=s[i][j];
      rep1(k,26){
        if(k==j)continue;
        tmp-=c[k]*(i-last[k]);
      }
      if(mx<tmp){
        mx=tmp;
        mx_ind=j;
      }
    }
    last[mx_ind]=i;
    res[i]=mx_ind;
  }
  return res;
}
signed main(){
  cin>>d;
  rep1(i,26)cin>>c[i];
  rep1(i,d){
    rep1(j,26)cin>>s[i][j];
  }
  vector<int> t=greedy(d);
  vector<vector<int>> last_list(d+1,vector<int>(30,0));
  int res=calc(t,last_list);
  //cout<<res<<"\n";
  rep(xx,num){
    random_device rand;
    mt19937 mt(rand());
    vector<int> nd(5);rep(i,5)nd[i]=mt()%d+1;
    vector<int> nq(5);rep(i,5)nq[i]=mt()%26+1;
    vector<int> bq(5);rep(i,5)bq[i]=t[nd[i]];
    int bval=res;
    rep(i,5){
      change(nd[i],nq[i],res,t,last_list);
    }
    int yakinamasi=mt()%100;
    //if(yakinamasi<10)continue;
    if(bval>res){
      rep(i,5){
        change(nd[i],bq[i],res,t,last_list);
      }
    }
  }
  rep(xx,num){
    random_device rnd;
    mt19937 mt(rnd());
    int nd=mt()%d+1;
    int nq=mt()%26+1;
    int bq=t[nd];
    int bval=res;
    int hoge=change(nd,nq,res,t,last_list);
    if(hoge<bval){
      change(nd,bq,res,t,last_list);
    }
  }
  rep1(i,d){
    cout<<t[i]<<"\n";
  }
  //cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3820
#include<iostream>
#include<algorithm>
using namespace std;
int i[114514];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d=0,e;
	cin >>a>>b;
	c=a+b,d=a-b,e=a*b;
	cout <<max(c,max(d,e))<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  char s[16];
  for(int i=0;i<12;i++){
    cin>>s[i];
    char a=s[i];
    cout<<a;
    if(i==3)
      cout<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 256
object Main {
	val s = new java.util.Scanner(System.in)
	def main(args: Array[String]) {
		while (true) {
			var n, m = s.nextInt
			if (n + m == 0) sys.exit
			var r = 0
			Array.fill(n)(s.nextInt, s.nextInt).sortBy(_._2).reverse.foreach(v => {
				val min = math.min(v._1, m)
				r += (v._1 - min) * v._2
				m -= min
			})
			println(r)
		}
	}
}

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

int main(){
	int n, k;
  	cin>>n>>k;
  	int a[100001], b[100001]={0};
  	for(int i=1;i<=n;i++) cin>>a[i];
  	
  	for(int i=2;i<=n;i++){
      int j = max(1,i-k);
      int num = b[j] + abs(a[i] - a[j]);
      j++;
      while (j<i){
      	num = min(num, b[j] + abs(a[i] - a[j]));
        j++;
      }
      b[i] = num;
    }
  	cout<<b[n]<<endl;
  	
  return 0;
}

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

int popcnt(int n){
  int n_ = n;
  int res = 0;
  while(n_>0){
    if(n_%2==1) res++;
    n_ = n_ >> 1;
  }
  return res;
}

int func(int n){
  int n_ = n;
  int res = 0;
  while(n_>0){
    res++;
    n_ %= popcnt(n_);
  }
  return res;
}

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

  reverse(x.begin(),x.end());

  //popcount(x)
  int x_pop = 0;
  rep(i,n) if(x[i]=='1') x_pop++;

  //2^0...2^nをpopcount(x)+1で割ったあまり
  vector<int> r_p(n,1);
  for(int i=1; i<n; i++){
    r_p[i] = (r_p[i-1] * 2) % (x_pop + 1);
  }

  //2^0...2^nをpopcount(x)-1で割ったあまり
  vector<int> r_m(n,0);
  if(x_pop-1>0){
    r_m[0] = 1;
    for(int i=1; i<n; i++){
      r_m[i] = (r_m[i-1] * 2) % (x_pop - 1);
    }
  }

  //x % (popcount(x) + 1)
  //x % (popcount(x) - 1)
  ll x_r_p = 0;
  ll x_r_m = 0;
  rep(i,n){
    if(x[i]=='1'){
      x_r_p += r_p[i];
      if(r_m[i]==0) continue;
      x_r_m += r_m[i];
    }
  }

  //f(x_i)
  for(int i=n-1; i>=0; i--){
    int first;

    if(x[i]=='0'){
      first = (x_r_p + r_p[i]) % (x_pop + 1);
    }
    else if(x_pop-1>0){
      first = (x_r_m - r_m[i]) % (x_pop - 1);
    }
    else{
      cout << 0 << endl;
      continue;
    }

    cout << 1 + func(first) << endl;
  }

  return 0;
}

Measured memory_bytes: 5244
#include <iostream>
#include <vector>
#include <utility> // std::pair
#include <climits>
#include <list>

long long calc_npairs(long long n)
{
  return n * (n-1) / 2;
}

class Island {
  public:
    Island() { parent = nullptr; nislands = 1; }
    bool is_root() const { return this->parent == nullptr; }
    Island* get_root() {
      Island* result = this;
      while (!result->is_root()) {
        result = result->parent;
      }
      if (result != this) {
        this->parent = result;
      }
      return result;
    }
    Island* parent;
    long long nislands;
    long long calc_score() const { return calc_npairs(this->nislands); }
};

class Bridge {
  public:
    long long smaller;
    long long larger;
    Bridge() { smaller = INT_MIN; larger = INT_MIN; }
    Bridge(long long _smaller, long long _larger) { smaller = _smaller; larger = _larger; }
};

int main()
{
  long long nislands, nbridges;
  std::cin >> nislands >> nbridges;
  std::vector<Bridge> bridges(nbridges);
  for (long long i = 0; i < nbridges; i++) {
    long long smaller, larger;
    std::cin >> smaller >> larger;
    bridges.at(i).smaller = smaller;
    bridges.at(i).larger  = larger;
  }
  std::vector<Island> islands(nislands+1);
  long long score = calc_npairs(nislands);
  std::list<long long> score_history;
  for (auto it = bridges.rbegin(); it != bridges.rend(); it++) {
    score_history.push_front(score);
    Island* smaller_island = &islands.at(it->smaller);
    Island* larger_island  = &islands.at(it->larger);
    Island* smaller_root = smaller_island->get_root();
    Island* larger_root  = larger_island->get_root();
    if (smaller_root == larger_root) {
      continue;
    }
    larger_root->parent = smaller_root;
    score -= smaller_root->nislands * larger_root->nislands;
    smaller_root->nislands += larger_root->nislands;
  }
  for (const auto& x : score_history) {
    std::cout << x << '\n';
  }
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N,P;
LL w,b,v[MC];
LL s;

int main(){
	cin >> N >> P;
	repp(i,0,N){
		cin >> w >> b;
		s -= P * b;
		v[i] = P * b + (100-P) * w;
	}
	sort(v,v+N,greater<LL>());
	int ans = 0;
	while(s<0){
		s += v[ans];
		++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt64(scanner)
	a := getNextInt64(scanner)
	b := getNextInt64(scanner)

	fmt.Fprintln(writer, n/(a+b)*a+minint(n%(a+b), a))
}

func minint(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 640
s = input()

min_value = 10 ** 9

# 左端に置く場合
pivot = s[0]
result = 0
for c in s:
  if pivot != c:
    pivot = c
    result += 1
min_value = min(min_value, result)

# 右端に置く場合
result = 0
for c in reversed(s):
  if pivot != c:
    pivot = c
    result += 1
min_value = min(min_value, result)
print(min_value)

Measured memory_bytes: 9240
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long k = sc.nextLong();
//		int n = sc.nextInt();


		//-------------------------------------------------------------------------------------

		for(int i =0; i < 5; i++) {
			int n = sc.nextInt();
			if(n == 0) {
				System.out.println(i+1);
			}
		}

		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

//		System.out.println(ans);

		sc.close();
	}



}

Measured memory_bytes: 35684
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf 10000000000000000ll
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-9
#define endl "\n"
/*ll gcd(ll a,ll b)
{
    if(a==0){return b;}
    return gcd(b%a,a);
}
ll modexp(ll x,ll y,ll p)
{
    ll res=1;x%=p;
    while(y>0)
    {   if(y%2==1){res=(res*x)%p;}
        y=y>>1;x=(x*x)%p;
    }return res;
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll l,r;cin>>l>>r;
    ll m=2019;
    if(r-l+1>=m)
    {
        cout<<"0"<<"\n";
    }
    else
    {
        ll ans=2020;
        rep(i,l,r-1)
        {
            rep(j,i+1,r)
            {
                ans=min(ans,1ll*i*j%m);
            }

        }
        cout<<ans<<"\n";
    }




    return 0;

    /*check for long long or int*/
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }

int n;
ll a[1000005];
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];

    ll b = 0, ans = 0;
    rep(i, n) {
        if (b + 1 < a[i]) ans += (a[i] - 1) / (b + 1);
        if (b == 0 || b + 1 == a[i]) ++b;
    }
    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,a[100],res=0;
  cin >> N;
  for(int i=0;i<N;i++){
   cin >> a[i];
    if(i%2==0 && a[i]%2==1){
res++;    
    }
  }
  cout << res;
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	deque<int> u;
	for (int i = 0; i < n; i++) {
		int x = v[i];
		int p = lower_bound(ALL(u), x) - u.begin() - 1;
		if (p < 0) u.push_front(x);
		else u[p] = x;
	}
	cout << u.size() << endl;
}

Measured memory_bytes: 4036
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;


int a[200010];
int p[200010];
int sum[200010];
int ans = 0,n;


int main()
{
	cin>>n;
	for(int i = 1; i<=n; i++) 
	{
		cin>>a[i];
		p[a[i]] = i;
	}
	for(int i = 1; i<=n; i++)
	{
		if(p[a[i]-1]<i)
		{
			sum[i] = sum[p[a[i]-1]]+1;
		}
		else sum[i] = 1;
	}
	for(int i = 1; i<=n; i++)
		ans = max(sum[i],ans);
	cout<<n - ans<<endl;
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b) cout << c << endl;
	else if(b == c) cout << a << endl;
	else cout << b << endl;
	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 a = sc.nextInt();
    int b = sc.nextInt();
    if(a>=10||b>=10){
      System.out.println(-1);
      return;
    }
    System.out.println(a*b);
  }
}

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

const ll M = 1e9 + 7;

ll add(ll a, ll b) { return (a+b)%M; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  ll total = 0;
  for (int i = k; i <= n+1; ++i) {
    ll l = 1ll * (i-1) * i / 2;
    ll r = 1ll * (n+n-i+1) * i / 2;
    total = add(total, r-l+1);
  }
  cout << total << endl;
}

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

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; }

class UnionFind {
  vector<int> data;
  public:
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
      if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
  	return x != y;
  }
  bool findSet(int x, int y) {
  	return root(x) == root(y);
  }
  int root(int x) {
  	return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
  	return -data[root(x)];
  }
};

#define ll long long
const ll INF= 1LL << 60;
ll L;

int main(){
  cin>>L;
  ll r=(ll)log2(L);
  vector<vector<ll>> v;
  ll N=r+1;
  ll M=0;
  vector<pair<pair<ll,ll>,ll>> V;
  for(int i=1;i<N;i++){
    V.push_back(make_pair(make_pair(i,i+1),0));
    V.push_back(make_pair(make_pair(i,i+1),pow(2,i-1)));
  }
  for(int t=N-1;t>0;t--){
    if(L-pow(2,t-1)>=pow(2,r)){
      V.push_back(make_pair(make_pair(t,N),L-pow(2,t-1)));
      L-=pow(2,t-1);        
    }
  }
  M=V.size();
  
  cout << N<<" " <<M<<endl;
  
  for(auto v:V){
    cout<<v.first.first<<" "<< v.first.second<<" "<<v.second<<endl;
  }
  return 0;
}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  string ans;
  ans = "aaa";
  ans.at(0) = a.at(0) - 32;
  ans.at(1) = b.at(0) - 32;
  ans.at(2) = c.at(0) - 32;
  
  cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

int main(){
    int x;
    int a[1001];
    cin >> x;
    // padding array
    for(int i = 0; i <= 1000; i++){
        a[i] = 0;
    }
    a[1] = 1;
    for(int i = 2; i < 32; i++){
        for(int j = i*i; j <= 1000; j*=i){
            a[j] = 1;
        }
    }
    // find
    while(true){
        if(a[x] == 1){
            cout << x << endl;
            break;
        }else{
            x--;
        }
    }
    return 0;
}

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

def main():
    while True:
        try:
            d=int(input())
            count=d
            ans=0
            while count<600:
                ans+=(count**2)*d
                count+=d

            print(ans)
        except:
            break
            
    
if __name__ == '__main__':
    main()

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

int main(){
	int n, b, f, r, v;
	int room[5][4][11];
	for(int i = 1; i < 5; i++){
		for(int j = 1; j < 4; j++){
			for(int k = 1; k < 11; k++){
				room[i][j][k] = 0;
			}
		}
	}
	cin >> n;
	for(int m = 0; m < n; m++){
		cin >> b >> f >> r >> v;
		room[b][f][r] += v;
	}
	for(int i = 1; i < 5; i++){
		for(int j = 1; j < 4; j++){
			for(int k = 1; k < 11; k++){
				cout << " " << room[i][j][k];
			}
			cout << endl;
		}
		if(i < 4) cout << "####################" << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 1 << 16;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n >> m;
  cout << (n * 3 + m) / 2 << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int[] xl = new int[n];
        int[] yl = new int[m];
        int maxx = Integer.MIN_VALUE;
        int miny = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            xl[i] = sc.nextInt();
            if (maxx < xl[i])
                maxx = xl[i];
        }
        for (int j = 0; j < m; j++) {
            yl[j] = sc.nextInt();
            if (miny > yl[j])
                miny = yl[j];
        }

        for (int z = x + 1; z <= y; z++) {
            if (z > maxx && z <= miny) {
                System.out.println("No War");
                return;
            }
        }

        System.out.println("War");

    }
}


Measured memory_bytes: 81236
code = r"""
# distutils: language=c++
# cython: boundscheck=False, wraparound=False
from libcpp.set cimport set
from libcpp.vector cimport vector
from libc.stdio cimport getchar, printf
from cython.operator cimport dereference as deref
from cython.operator cimport preincrement as preinc, predecrement as predec
from cython.operator cimport postincrement as postinc, postdecrement as postdec
cdef int cin() nogil:
    cdef int b, c = 0
    while 1:
        b = getchar() - 48
        if b < 0: break
        c = c * 10 + b
    return c
cdef int n = cin(), i
cdef long c
cdef vector[long] a = vector[long](n)
for i in range(n): a[cin() - 1] = i
cdef set[long] s = set[long]([-1, n])
cdef set[long].iterator it
for i in range(n):
    it = s.lower_bound(a[i])
    c += (deref(postdec(it)) - a[i]) * (a[i] - deref(it)) * (i + 1)
    s.insert(a[i])
printf('%ld\n', c)
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 22332
import sys
 
input()
minv = int(input())
maxv = -1000000000
 
for r in map(int,sys.stdin.readlines()):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
 
print(maxv)

Measured memory_bytes: 21788
#include<iostream>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
  }
  if((n-1) % (k-1) != 0){
    cout << ((n-1) / (k-1)) + 1<< endl;
  } 
  else{
    cout << (n-1) / (k-1) << endl;
  }
  return 0;
}


Measured memory_bytes: 384
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = {}
for i in range(n):
	S,P = map(str,input().split())
	s[i+1] = [S, -int(P)]

note = sorted(s.items(), key=lambda x: x[1][0])
note.append( (10, ["LOL", 10] ) )
memo = note[0][1][0]
a = []
for i in note:
	if memo != i[1][0]:
		memo = i[1][0]
		a = sorted(a, key=lambda x: x[1][1])
		for j in range(len(a)):
			print(a[j][0])
		a = []
		a.append(i)
	else:
		a.append(i)

Measured memory_bytes: 9112
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

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

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<(abs(a-c)<=d||abs(a-b)<=d&&abs(b-c)<=d?"Yes":"No");
}

Measured memory_bytes: 256
position = input().split()

w = int(position[0])
h = int(position[1])
x = int(position[2])
y = int(position[3])
r = int(position[4])

if 0 > (x - r) or 0 > (y - r) or w < (x + r) or h < (y + r):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 7740