akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    ll num = atoi(n.c_str());
    ll sum = 0;
    REP(i,n.size()){
        sum += n[i]-48;
    }
    cout << ((num%sum)?"No":"Yes") << endl;
}


Measured memory_bytes: 256
k = int(input())
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[k-1])

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}

int main() {
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    if(K<=A){
        ans+=K;
        K=0;
    }else{
        ans+=A;
        K-=A;
    }
    if(K<=B){
        K=0;
    }else{
        K-=B;
    }
    ans-=K;
    cout << ans << endl;


}


Measured memory_bytes: 3628
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define gnr(i,l,r) for(int i=int(r); i>=int(l); i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;

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

  cin>>n; V(int)g[n];
  rep(i,n)rep(j,n){
    cin>>ch;
    if(ch-'0')g[i].eb(j);
  }
  V(int)an;
  rep(i,n){
  bool see[n]={}; int c[n]={};
  queue<int>q; q.push(i); c[i]=1; ok=true; see[i]=1;
  while(!q.empty()){
    x=q.front(); q.pop();
    for(int v:g[x]){
      if(!see[v]){
        c[v]=c[x]+1; 
        q.push(v);
        see[v]=1;
      }
      if(c[v]&&abs(c[v]-c[x])!=1){ok=0; break;}
    }
    if(!ok)break;
  }
  if(ok)an.eb(*max_element(c,c+n));
  }
  if(an.empty()){pri1(-1); return 0;}
  pri1(*max_element(ALL(an)));
}

Measured memory_bytes: 512
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int X = Integer.parseInt(sl[0]);
            int Y = Integer.parseInt(sl[1]);
            int Z = Integer.parseInt(sl[2]);

            int ans = 0;
            for (int i = 0; i <= 100000; i++) {
                if (X < i * Y + (i + 1) * Z) break;
                ans = i;
            }

            System.out.println(ans);
        }
    }
}


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

s_list = list(input())
t_list = list(input())

s_list.sort()
t_list.sort(reverse=True)

_s = ''.join(s_list)
_t = ''.join(t_list)

if _s < _t:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9

int main(){
    int n,k;
    cin>>n>>k;
    
    vector<int> x(n),y(n);
    vector<int> xary,yary;
    
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }
    
    sort(xary.begin(),xary.end());
    sort(yary.begin(),yary.end());
    
    ll ans=1LL*(xary[n-1]-xary[0])*(yary[n-1]-yary[0]);
    
    for(int xi=0;xi<n;xi++){
        for(int xj=xi+1;xj<n;xj++){
            for(int yi=0;yi<n;yi++){
                for(int yj=yi+1;yj<n;yj++){
                    int num=0;
                    ll lx=xary[xi],rx=xary[xj];
                    ll by=yary[yi],uy=yary[yj];
                    
                    for(int i=0;i<n;i++){
                        if(lx<=x[i] && x[i]<=rx && by<=y[i] && y[i]<=uy) num++;
                    }
                    
                    if(num>=k) ans=min(ans,1LL*(rx-lx)*(uy-by));
                }
            }
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#import numpy as np
#N = int(input())
A,B= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
S= str(input())

for i in range(len(S)):
    if i==A:
        if S[i]!='-':
            print("No")
            exit()


    elif S[i].isdigit() == False:
        print('No')
        exit()


print('Yes')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vvll vector<ll>
#define vll(a) vector<ll> a(MAXN)
#define pb push_back
#define fo(a) for(auto&a1:(a))
#define fd(a,b) for(int i=(a);i>=(b);i--)
#define fk(a,b) for(int k=(a);k<(b);k++)
#define fj(a,b) for(int j=(a);j<(b);j++)
#define f(a,b) for(ll i=(a);i<(b);i++)
#define forni(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define fdk(a,b) for(int k=(a);k>=(b);k--)
#define fdj(a,b) for(int j=(a);j>=(b);j--)
#define ri(n) scanf("%d",&(n));
#define rll(n) scanf("%lld",&(n));
#define T(t) int t;scanf("%d",&(t));while((t)--)
#define MAXN2 10000005
#define pll pair<ll,ll>
#define PI 3.14159265
#define mset(a) memset((a),0,sizeof((a)))
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sortv(a) sort(a.begin(),a.end())
#define v2d vector<vvll>
#define v3d vector<v2d>
#define max_value(a,b) a=max(a,b)
#define min_value(a,b) a=min(a,b)
using namespace std;
const ll MAXN=205;
const ll mod=1e9+7;
vector<ll> tr[MAXN];
bool vis[MAXN];
int main()
{
	string n;
	cin>>n;
	ll sum=0;
	fo(n)
	{
		sum+=a1-'0';
	}
	if(sum%9)
	cout<<"No\n";
	else
	cout<<"Yes\n";
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    long long int a[n+1], b[n], ans = 0;
    for(int i = 0; i < n+1; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; ++i) {
        if(b[i] >= a[i]) {
            ans += a[i];
            b[i] -= a[i];
            if(b[i] >= a[i+1]) {
                ans += a[i+1];
                a[i+1] = 0;
            } else {
                ans += b[i];
                a[i+1] -= b[i];
            }
        } else {
            ans += b[i];
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    string x, y;
    cin >> x >> y;
    if (x > y)
        cout << ">"
             << "\n";
    else if (x < y)
        cout << "<"
             << "\n";
    else
        cout << "="
             << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << (n + 110) / 111 * 111 << endl;

    return 0;
}

Measured memory_bytes: 256
// Tue Jun 30 14:06:52 IST 2020  
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define pb                 push_back
#define f1                 first 
#define s1                 second    
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()
const int MOD = 1e9+7;
const double pi = 3.141592653589793238;
using namespace  std ;       
using namespace __gnu_pbds;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 3e5+7; 
const int64 INF = INT64_MAX;  
int64 tests(){ 
    int L,R,d;
    cin  >> L >> R >> d;
    int ans = 0 ;
    for(int i = L ; i <= R ; i++ )
        ans += (i%d == 0);
    cout << ans << '\n';
    return 0;
}
int32_t main(){
    I__O ;     
    int cases = 1 ;  
    // cin >> cases ;  
    while(cases--) 
        tests();      
    return 0 ; 
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

string s;
ll ans;

void rec(int i, ll sum, string rem){
	if(i == s.size()+1){
		sum += stoll(rem);
		ans += sum;
		//cout << sum << endl;
		return;
	}
	//cout << rem << endl;
	rem += s[i];
	rec(i+1, sum + stoll(rem), "0");
	rec(i+1, sum, rem);
}
int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	cin >> s;

	rec(0, 0, "0");

	cout << ans/4 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>

using namespace std;


int main() {
  int N, X;
  cin >> N >> X;
    
  int L[1000];
  for (int i = 1; i <= N; i++) {
    cin >> L[i];
  }
  int D = 0;
  int bounds = 1;
  for (int i = 1; i <= N; i++) {
    D += L[i];
    if(D <= X){
      bounds ++;
    } else {break;}
  }
  
  cout << bounds << endl;
  
  return 0;
}


Measured memory_bytes: 256
//AtCoder Beginner Contest 098
//A - Add Sub Mul
#include<stdio.h>

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

	int add = a + b;
	int sub = a - b;
	int mul = a * b;

	if(add < sub){
		if(sub < mul){
			printf("%d\n", mul);
		} else{
			printf("%d\n", sub);
		}
	} else{
		if(add < mul){
			printf("%d\n", mul);
		} else {
			printf("%d\n", add);
		}
	}
}

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

using namespace std;

bool isprime(int p) {
	for (int i = 2; i * i <= p; i++) {
		if (p % i == 0)return false;
	}
	return true;
}

int main() {
	int N;
	cin >> N;
	vector<int> print;
	for (int i = 11; i <= 55555; i += 10) {
		if (isprime(i))print.push_back(i), N--;
		if (N == 0)break;
	}
	for (int i = 0; i < print.size(); i++) {
		cout << print[i];
		if (i != print.size() - 1)cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long ans = 0;
		for(int i=0;i<N-1;i++){
			if(A[i]+A[i+1] > X){
				long rem = A[i+1]+A[i]-X;
				ans += rem;
				if(A[i+1]>rem){
					A[i+1] -= rem;
				}else{
					A[i] -= (rem - A[i+1]);
					A[i+1] = 0;
				}
			}
		}
		Console.WriteLine(ans);
		
	}
	int N,X;
	long[] A;
	public Sol(){
		var  d = ria();
		N = d[0];
		X = d[1];
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17240
def q3():
    from collections import deque
    N = int(input())
    A = deque([int(i) for i in input().split()])
    ans = [0]*N
    for a in A:
        ans[a-1] += 1
    for i in ans:
        print(i)


if __name__ == '__main__':
    q3()


Measured memory_bytes: 33556
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,i,j,k,a,b,c,d,e,f,g,h,ans,have[20];
int main(){//freopen("1.in","r",stdin);freopen("1.out","w",stdout);
	scanf("%d",&n);
	for (a=3;a<=7;a+=2) for (b=3;b<=7;b+=2) for (c=3;c<=7;c+=2){
		have[a]++;have[b]++;have[c]++;if (have[3]&&have[5]&&have[7]&&a+10*b+100*c<=n) ans++;
		for (d=3;d<=7;d+=2){
			have[d]++;if (have[3]&&have[5]&&have[7]&&a+10*b+100*c+1000*d<=n) ans++;
			for (e=3;e<=7;e+=2){
				have[e]++;if (have[3]&&have[5]&&have[7]&&a+10*b+100*c+1000*d+10000*e<=n) ans++;
				for (f=3;f<=7;f+=2){
					have[f]++;if (have[3]&&have[5]&&have[7]&&a+10*b+100*c+1000*d+10000*e+100000*f<=n) ans++;
					for (g=3;g<=7;g+=2){
						have[g]++;if (have[3]&&have[5]&&have[7]&&a+10*b+100*c+1000*d+10000*e+100000*f+1000000*g<=n) ans++;
						for (h=3;h<=7;h+=2){
							have[h]++;if (have[3]&&have[5]&&have[7]&&a+10*b+100*c+1000*d+10000*e+100000*f+1000000*g+10000000*h<=n) ans++;
							for (i=3;i<=7;i+=2){
								have[i]++;if (have[3]&&have[5]&&have[7]&&a+10*b+100*c+1000*d+10000*e+100000*f+1000000*g+10000000*h+100000000*i<=n) ans++;have[i]--;
							}
							have[h]--;
						}
						have[g]--;
					}
					have[f]--;
				}
				have[e]--;
			}
			have[d]--;
		}
		have[a]--;have[b]--;have[c]--;
	}
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 256
int main(){
int n,m;
	for(;scanf("%d%d",&n,&m),n;){
		int t=1001,pre,ans,cnt=0,i;
		for(i=0;i<n;i++){
			int a; scanf("%d",&a);

			int j;
			for(j=m;j%a;j--);

			if(j<t || (j==t && a<=pre)){
				cnt=(j==t&&a==pre?cnt+1:1);
				t=j;
				pre=a;
				ans=i;
			}
		}

		printf("%d\n",cnt<2?ans+1:n);
	}

	return 0;
}

Measured memory_bytes: 0
n,k = map(int, input().split())
lag = []
for l in range(n):
    lag.append(int(input()))
w_max = 100000*100000
w_min = 0
while w_min < w_max:
    w_mid = (w_max + w_min) // 2
    tracks = 0
    current = 0
    for i in range(n):
        if lag[i] > w_mid:
            tracks = k
            break
        elif lag[i] + current > w_mid:
            tracks += 1
            current = lag[i]
        else:
            current += lag[i]
    if tracks < k:
        w_max = w_mid
    else:
        w_min = w_mid + 1
print(w_max)

Measured memory_bytes: 11564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			// ???????????????
			String x = scan.next();
			if (x.equals("-")) break;
			// ?????£??????????????°
			int m = scan.nextInt();
			// ?????????????????????????????????
			int l = x.length();
			// ?????£????????????????????????????´????????????°
			String kekka =  x;
			for(int i=0; i<m; i++){
				// ????????????????????????????´????????????°
				int h = scan.nextInt();
				String new_x = kekka.substring(0, h);
				String new_x2 = kekka.substring(h, l);
				kekka = new_x2 + new_x;
			}
			// ???????????????
			System.out.println(kekka);
		}

	}

}

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

using namespace std;

#define MAX 1010
#define MAX_M 101

int dp[MAX_M][MAX_M][MAX];

int main()
{
    int LIMIT, N, M, X;
    string name;
    while (cin >> LIMIT >> N >> M >> X, LIMIT) {
        vector<int> c(N), s(N);
        for (int i = 0; i < N; i++) {
            cin >> name >> c[i] >> s[i];
        }
        int max_s[MAX];
        fill(max_s, max_s + MAX, -1);
        for (int i = 0; i < N; i++) {
            max_s[c[i]] = max(max_s[c[i]], s[i]);
            for (int j = i + 1; j < N; j++) {
                max_s[c[i] + c[j]] = max(max_s[c[i] + c[j]], s[i] + s[j]);
            }
        }
        for (int i = 0; i < LIMIT; i++) {
            max_s[i+1] = max(max_s[i+1], max_s[i]);
        }
        vector<int> sc(M), ss(M);
        for (int i = 0; i < M; i++) {
            cin >> name >> sc[i] >> ss[i];
        }
        for (int i = 0; i <= M; i++) {
            for (int j = 0; j <= M; j++) {
                for (int k = 0; k <= LIMIT; k++) {
                    dp[i][j][k] = -1;
                }
            }
            dp[i][0][0] = 0;
        }
        
        for (int i = 0; i < M; i++) {
            for (int j = 0; j <= M; j++) {
                for (int k = LIMIT; k >= 0; k--) {
                    if (dp[i][j][k] == -1) continue;
                    int nk = k + sc[i];
                    dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);
                    if (nk <= LIMIT) {
                        dp[i+1][j+1][nk] = max(dp[i+1][j+1][nk], dp[i][j][k] + ss[i]);
                    }
                }
            }
        }  
        
        int res = 0;
        for (int i = 0; i <= LIMIT; i++) {
            if (max_s[i] == -1) continue;
            for (int j = 0; j <= M; j++) {
                for (int k = X; k <= M; k++) {
                    if (dp[j][k][LIMIT-i] == -1) continue;
                    res = max(res, max_s[i] + dp[j][k][LIMIT-i]);                   
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 41452
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LaL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  ll N,M;
  cin>>N>>M;
  
  if(N%2==1){
    for(int i=0; i<M; ++i){
      cout<<i+1;
      cout<<" ";
      cout<<N-i<<endl;
    }
    return 0;
  }
  
  vector<pair<int,int>> L;
  if(N%2==0){
    for(int i=1; i<N/2; ++i){
      if(i%2==1){
        L.push_back(make_pair(N/2-i/2,N/2+1+i/2));
      }
      else{
        L.push_back(make_pair(i/2,N-i/2));
      }
    }
  }
  
  for(int i=0; i<M; ++i){
    cout<<L[i].first<<" "<<L[i].second<<endl;
  }
  return 0;
}

Measured memory_bytes: 4252
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int max = Math.max(Math.max(a, b), c);
        int tri = max * 3;
        int sum = a + b + c;
        int diff = tri - sum;
        boolean isOdd = diff % 2 == 1;
        int result = isOdd ? diff / 2 + 2 : diff / 2;

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;

using ll = long long;

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

    int k, s;
    cin >> k >> s;

    int res = 0;
    for (int x = 0; x <= k; ++x) {
        for (int y = 0; y <= k; ++y) {
            if (0 <= s - x - y && s - x - y <= k) ++res;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import fractions
import math
n,m = map(int,input().split())
a = list(map(int, input().split()))
a = set(a)
c = set()
l = 1
for i in a:
    l = l * i // fractions.gcd(l,i)
    if l // 2 > m:
        ans = 0
        break
    count = 0
    while True:
        if (i>>count) % 2 == 0:
            count += 1
        else:
            c.add(count)
            break
    if len(c) > 1:
        ans = 0
        break
else:
    ans = (m + l // 2) // l

print(ans)

Measured memory_bytes: 16280
#include <bits/stdc++.h>
#define Task "C"
using namespace std;
const int maxN = 105;
long long n, a[maxN];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i<n; ++i) cin >> a[i];
    long long sum = 0;
    for(int i = 1; i<n-1; ++i) sum += min(a[i], a[i+1]);
    sum += a[1] + a[n-1];
    cout << sum;

    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#define N 510000
#define pb push_back
using namespace std;
struct node{int l,r,lc,rc,mx;}lt[2*N];
int n,m,a[N],tl,ans[N],head[N],siz[N];
bool b[N];
priority_queue<int> p;
vector<int> v[N];
void upd(int now)
{
	int lc=lt[now].lc,rc=lt[now].rc;
	lt[now].mx=max(lt[lc].mx,lt[rc].mx);
}
void bt(int l,int r)
{
	int now=++tl;
	lt[now].l=l;lt[now].r=r;
	if(l<r)
	{
		int mid=(l+r)/2,lc,rc;
		lc=lt[now].lc=tl+1;bt(l,mid);
		rc=lt[now].rc=tl+1;bt(mid+1,r);
		upd(now);
	}
	else lt[now].mx=a[l];
}
bool cmp(int x,int y)
{
	if(a[x]>a[y]) return 1;
	return 0;
}
void change(int now,int k)
{
	int lc=lt[now].lc,rc=lt[now].rc,mid=(lt[now].l+lt[now].r)/2;
	if(lt[now].l==lt[now].r) {lt[now].mx=0;return;}
	if(mid>=k) change(lc,k);
	else change(rc,k);
	upd(now);
}
int find(int now,int l,int r)
{
	int lc=lt[now].lc,rc=lt[now].rc,mid=(lt[now].l+lt[now].r)/2;
	if(lt[now].l==l && lt[now].r==r) return lt[now].mx;
	if(mid>=r) return find(lc,l,r);
	else if(l>mid) return find(rc,l,r);
	else return max(find(lc,l,mid),find(rc,mid+1,r));
}
void insert(int x)
{
	if(x<0 || b[x] || head[x]==siz[x]) return;
	int k=v[x][head[x]];
	if(find(1,max(1,k-m+1),min(n,k+m-1))==a[k]) 
		p.push(k),b[x]=1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	bt(1,n);
	for(int i=1;i<=n;i++) v[i/m].pb(i);
	for(int i=0;i<=n/m;i++) sort(v[i].begin(),v[i].end(),cmp);
	for(int i=0;i<=n/m;i++) siz[i]=v[i].size(),head[i]=0;
	for(int i=0;i<=n/m;i++) insert(i);
	for(int k=n;k>=1;k--)
	{
		int t=p.empty();
		int x=p.top();p.pop();
		ans[x]=k;
		head[x/m]++;b[x/m]=0;
		change(1,x);
		insert(x/m);
		insert(x/m+1);
		insert(x/m-1);
	}
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 61172
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=998244353;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2LL*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
int stf[3];
 
int main(void)
{
	int i;
	for(i=0 ; i<3 ; i++) cin>>stf[i];
  sort(stf,stf+3);
	if(stf[0]==5 && stf[1]==5 && stf[2]==7) printf("YES");
	else printf("NO"); return 0;
}
 
// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        int n=ni(),d=ni();
        pn(n/(2*d+1)+(n%(2*d+1)!=0?1:0));
    }


    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();

        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();

        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;
    static long mod=(long)1e9+7l;

    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n, m;
  cin >> n >> m;
  vector<int> x(m), diff(m-1);
  for(int &a:x) cin >> a;
  sort(x.begin(), x.end());
  REP(i, m-1) diff[i] = x[i+1] - x[i];
  sort(diff.begin(), diff.end());
  int answer = 0;
  REP(i, m-n) answer += diff[i];
  cout << answer << endl;
  return 0;
}


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

#define MAX_N 100000

using namespace std;

typedef long long lint;

const lint sqrInf = (1e18) - 1;

lint rez;

int n;
int v[(MAX_N << 1) + 1];
lint sum[(MAX_N << 1) + 1];

int a[MAX_N + 1];
int b[MAX_N + 1];

int cate(int i, int a, int b)
{
    //cout << "NUMARAM " << v[i] << " " << a << " " << b << "\n";

    if(v[i] < a)
        return i;

    if(v[i] >= a && v[i] < b)
        return i - 1;

    return i - 2;
}

lint cautBin(int a, int b)
{
    if(a > b)
        swap(a, b);

    int i = 0;
    int pas = 1 << 17;
    while(pas != 0)
    {
        if(i + pas <= (n << 1) && cate(i + pas, a, b) < n)
            i += pas;

        pas >>= 1;
    }

   // cout << "ELEM " << a << " SI " << b << "\n";
   // cout << "SUNTEM " << i + 1 << " AVEM " << cate(i + 1, a , b) << " SUMA " << sum[i + 1] << " SCAD " << a * (v[i + 1] >= a) << " " << b * (v[i + 1] >= b) << "\n";

    if(i < (n << 1) && cate(i + 1, a, b) == n)
    {
        return sum[i + 1] - a * (v[i + 1] >= a) - b * (v[i + 1] >= b);
    }

    return sqrInf;
}

int main()
{
    cin >> n;

    int i;
    int k = 0;
    lint sa = 0, sb = 0;
    for(i = 1; i <= n; i ++)
    {
        cin >> a[i] >> b[i];
        v[++ k] = a[i];
        v[++ k] = b[i];

        sa += a[i];
        sb += b[i];
    }

    sort(v + 1, v + k + 1);
    for(int i = 1; i <= k; i ++)
    {
        sum[i] = sum[i - 1] + v[i];
       // cout << v[i] << " ";
    }
   // cout << "\n";

    rez = min(sa, sb);

    for(i = 1; i <= n; i ++)
        rez = min(rez, cautBin(a[i], b[i]));

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 3328
import sys
from io import StringIO
import unittest

def resolve():

    # スペース区切りの整数の入力
    X, K, D = map(int, input().split())
    # 文字列の入力
    if abs(X)-K*D>0:
        print("{}".format(abs(X)-K*D))
    else:
        mod = abs(X)%D
        modk = int(abs(X)/D)
        if (K-modk)%2==0:
            print("{}".format(mod))
        else:
            print("{}".format(D - mod))

    # 出力


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6 2 4"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """7 4 3"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 1 2"""
        output = """8"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1000000000000000 1000000000000000 1000000000000000"""
        output = """1000000000000000"""
        self.assertIO(input, output)


if __name__ == "__main__":
	resolve()

Measured memory_bytes: 16332
def month(tuki):
    return 0 < tuki <= 12


s = input()
mae = int(s[:2])
ushiro = int(s[-2:])
p = ( "AMBIGUOUS" if month(mae) and month(ushiro) else
      "MMYY" if month(mae) else
      "YYMM" if month(ushiro) else
      "NA")
print(p)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vector<int> A, B;
string S, T;

int vv[MX] = {};
void input() {
  cin >> N;
  A.resize(N);
  rep(i, 0, N - 1) { cin >> A[i]; };
}
void solve() {
  // sort(all(A));
  map<int, int> mp;
  for (auto x : A) {
    mp[x]++;
  }
  for (auto x : mp) {
    vv[x.first] = x.second;
  }

  int ans = -INF;
  rep(i, 0, MX) {
    int tmp = 0;
    rep(j, -1, 1) {
      if (i + j >= 0 && i + j < MX) {
        tmp += vv[i + j];
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

ll d;
string s;
ll dp[10001][105][2];

ll solve(ll pos,ll sum,bool tight){
	if(pos == s.size())
		return sum == 0;
	if(dp[pos][sum][tight] != -1) 
		return dp[pos][sum][tight];

	ll ans = 0;
	ll end = (tight?(s[pos]-'0'):9);

	for(ll i = 0;i<=end;i++){
		ans = (ans + solve(pos+1,(sum+i)%d,tight&(i==end)))%mod;
	}
	return dp[pos][sum][tight] = ans;
}

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

	memset(dp,-1,sizeof dp);
	ll ans = solve(0,0,1);
	ans = (ans-1+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17408
def calc_second_arg(number_1, number_2):
    while number_2 < 10:
        multiple = number_1 * number_2
        print "%dx%d=%d" % (number_1, number_2, multiple)
        number_2 = number_2 + 1

def calc_first_arg():
    a = 1
    b = 1
    while a < 10:
        calc_second_arg(a, b)
        a = a + 1

calc_first_arg()
    

Measured memory_bytes: 6384
n=int(input())
a=list(map(int,input().split()))
x=[0]*n
for i in range(n):
  x[0]+=a[i]*(-1)**i
for i in range(1,n):
  x[i]=a[i-1]*2-x[i-1]
for _ in range(n):
  print(x[_])

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

using ll = long long;

constexpr ll inf = 1e18;

struct edge {
    int to;
    ll c1, c2;
};

using edges = vector<edge>;
using graph = vector<edges>;

int main() {
    int n, p;
    cin >> n >> p;
    graph g(n);
    for(int i = 0; i < p; ++i) {
        int s, e;
        ll t1, t2;
        cin >> s >> e >> t1 >> t2;
        g[s - 1].push_back(edge{e - 1, t1, t2});
    }

    vector<int> topo(n, -1);
    int idx = 0;
    function<void(int)> calc_topo = [&] (int v) {
        if(topo[v] != -1) return;
        for(auto& e : g[v]) {
            calc_topo(e.to);
        }
        topo[v] = idx++;
    };
    calc_topo(0);

    vector<vector<ll>> dist(n, vector<ll>(n, inf));
    dist[0][0] = 0;
    using state = tuple<ll, int, int>;
    priority_queue<state, vector<state>, greater<state>> que;
    que.emplace(0, 0, 0);
    while(!que.empty()) {
        ll cur_c;
        int fst_v, sec_v;
        tie(cur_c, fst_v, sec_v) = que.top();
        que.pop();
        if(fst_v == sec_v) {
            for(auto& e : g[fst_v]) {
                ll nxt_c = cur_c + e.c1 + e.c2;
                if(dist[e.to][e.to] > nxt_c) {
                    dist[e.to][e.to] = nxt_c;
                    que.emplace(nxt_c, e.to, e.to);
                }
            }

            for(auto& e1 : g[fst_v]) {
                for(auto& e2 : g[sec_v]) {
                    if(e1.to == e2.to) continue;
                    ll nxt_c = cur_c + e1.c1 + e2.c1;
                    if(dist[e1.to][e2.to] > nxt_c) {
                        dist[e1.to][e2.to] = nxt_c;
                        que.emplace(nxt_c, e1.to, e2.to);
                    }
                }
            }
        } else {
            if(topo[fst_v] > topo[sec_v]) {
                for(auto& e : g[fst_v]) {
                    ll nxt_c = cur_c + e.c1;
                    if(dist[e.to][sec_v] > nxt_c) {
                        dist[e.to][sec_v] = nxt_c;
                        que.emplace(nxt_c, e.to, sec_v);
                    }
                }
            } else {
                for(auto& e : g[sec_v]) {
                    ll nxt_c = cur_c + e.c1;
                    if(dist[fst_v][e.to] > nxt_c) {
                        dist[fst_v][e.to] = nxt_c;
                        que.emplace(nxt_c, fst_v, e.to);
                    }
                }
            }
        }
    }

    cout << dist[n - 1][n - 1] << endl;
}



Measured memory_bytes: 27316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
string s,t;int k,lst,n,cilen,fis;ll ans,s1,s2,len[10005];
map<string,int> m;
int main()
{
    fastio;
    cin>>s>>k;t=s;n=s.size();
    rep(j,1,k) {
        rap(i,lst,s.size()){
            if(s[i]==s[i-1]){
                ans++;
                rep(j,0,2)
                if(j+97!=s[i-1]&&(i+1>=s.size()||j+97!=s[i+1])) {s[i]=j+97;break;}
            }
        }
        lst=s.size();
        string nw=s.substr(lst-n);
        if(m[nw]!=0){
            int t=m[nw];
            fis=t;
            cilen=j-t;
            len[j]=ans;
            break;
        }
        m[nw]=j;
        s+=t;
        len[j]=ans;
    }
    if(cilen==0){cout<<len[k];return 0;}
    s=t;
    ans=0;int whole=cilen+fis;
    ans=len[fis-1];
    rep(i,1,cilen){
        ll count=(k-fis+1)/cilen;if((k-fis+1)%cilen>=i) count++;
        ans+=count*(len[i+fis-1]-len[i+fis-2]); 
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a = [ list(map(int,input().split())) for _ in range(h)]
ans=[]
for i in range(h):
    for j in range(w):
        if i==h-1 and j==w-1: continue
        if a[i][j] % 2==0: continue
        if j == w-1:      
            a[i+1][j] += 1
            ans.append((i+1,j+1,i+2,j+1))
        else:
            a[i][j+1] += 1
            ans.append((i+1,j+1,i+1,j+2))

print(len(ans))
for o in ans:
    print (*o)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

long long gcd(long long x, long long y){return x % y == 0 ? y : gcd(y, x%y);}

int main(void){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    ll g = A[0], mx=0;
    REP(i,N-1) g = gcd(g, A[i+1]);
    REP(i,N) chmax(mx, A[i]);

    cout << (K <= mx && K%g==0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    
    int a,b,c,d;
    
    cin>>a>>b>>c>>d;
    
    int a1=a*b;
    int a2=c*d;
    
    if(a1>=a2){cout<<a1<<endl;}
    else{cout<<a2;}
    
    
}

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

#define INF 9223372036854775807
#define int long long
#define pi 3.14159265

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector<string> ans(0);
    for(int i = 0; i  < s.size(); i++){
        for(int j = 0; j < k; j++){
            if(j + i + 1 > s.size()) continue;
            ans.push_back(s.substr(i,j+1));
        }
    }
    sort(ans.begin(), ans.end());
    unique(ans.begin(), ans.end());
    cout << ans[k-1] << endl;
}


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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int res = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                int total = 500 * i + 100 * j + 50 * k;
                if(total == X) res++;
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
    queue<int>q;
    int a[n],ans=0;
    r(i,n)cin>>a[i];
    int lcm=n*m/__gcd(n,m);
    r(i,lcm)q.push(a[i%n]);
    r(i,lcm){
        int l=1e9,r=0,p;
      for(int k=0;k<m;k++){
        p=q.front();q.pop();
        l=min(l,p);
        r=max(r,p);
        i++;
      }
      ans+=r-l;
      i--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6748
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
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 V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
vector<int> b;
int maxl = 0;
int main(){
    INIT;
    cin >> n;
    REP(i, n){
        int a;
        cin >> a;
        a--;
        maxl = max(a, maxl);
        b.emplace_back(a);
    }
    vector<int> ans;
    while(!b.empty()){
        bool flg = false;
        for(int i = min((int)b.size() - 1, maxl);i >= 0;i--){
            if(!flg && b[i] == i){
                ans.emplace_back(i);
                b.erase(b.begin() + i);
                flg = true;
            }
        }
        if(!flg){
            cout << -1 << endl;
            return 0;
        }
    }
    reverse(ALL(ans));
    REP(i, n){
        cout << ans[i] + 1 << endl;
    }
}

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

void Main() {
  int N, A, B;
  cin >> N;
  if (N == 1) cout << "Hello World" << endl;
  else {
    cin >> A >> B;
    cout << A + B << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256