akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N,A;
  cin>>N>>A;

  cout<<N*N-A;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int m, n;
	while (scanf("%d%d", &m, &n), m|n)
	{
		bool alive[1000];
		fill(alive, alive+m, true);
		int p = 0;
		int left = m;
		for (int i = 1; i <= n; ++i)
		{
			char buf[32];
			scanf("%s", buf);
			if (left == 1)
				continue;

			char ans[32];
			if (i % 15 == 0)
				strcpy(ans, "FizzBuzz");
			else if (i % 3 == 0)
				strcpy(ans, "Fizz");
			else if (i % 5 == 0)
				strcpy(ans, "Buzz");
			else
				sprintf(ans, "%d", i);

			if (strcmp(ans, buf))
			{
				alive[p] = false;
				--left;
			}
			do
			{
				p = (p + 1) % m;
			} while (!alive[p]);
		}

		for (int i = 0, j = 0; i < m; ++i)
		{
			if (alive[i])
			{
				printf("%d", i + 1);
				++j;
				if (j == left)
					printf("\n");
				else
					printf(" ");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int faces[1+6];

void roll(int f){
	int tmp = faces[f];
	faces[f] = faces[1];
	faces[1] = faces[7-f];
	faces[7-f] = faces[6];
	faces[6] = tmp;
}

int main(){
	int input[1+6];
	for(int i = 1; i <= 6; i++){
		cin >> input[i];
	}

	int n, top, front, right, topNum;
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= 6; j++){
			faces[j] = input[j];
		}
		cin >> top >> front;
		for(int j = 1; j <= 6; j++){
			if(top == faces[j]){
				top = j;
				continue;
			}
			if(front == faces[j]){
				front = j;
				continue;
			}
		}

		topNum = faces[top];
		switch(front){
		case 6:
			break;
		case 1:
			roll(top); roll(top);
			break;
		default:
			roll(front);
			break;
		}

		for(int i = 1; i <= 6; i++){
			if(topNum == faces[i]){
				top = i;
				break;
			}
		}

		switch(top){
		case 2:
			right = 3;
			break;
		case 3:
			right = 5;
			break;
		case 5:
			right = 4;
			break;
		case 4:
			right = 2;
			break;
		}

		cout << faces[right] << endl;
	}

	return 0;
}

Measured memory_bytes: 3092
program abc157b
      implicit none
      integer,dimension(3,3)::A
      integer,allocatable,dimension(:)::B
      integer::N,i,j,k,judge1,judge2,judge3,judge4

      do i=1,3
         read *,A(i,1:3)
      end do
      read *,N
      allocate(B(N))
      do i=1,N
         read *,B(i)
      end do

      do i=1,N
         do j=1,3
            do k=1,3
               if (B(i)==A(j,k)) A(j,k)=0
            end do
         end do
      end do

      do i=1,3
         judge1=3
         do j=1,3
            if (A(i,j)==0) judge1=judge1-1
         end do
         if (judge1==0) then
            print *,'Yes'
            go to 10
         end if
      end do

      do i=1,3
         judge2=3
         do j=1,3
            if (A(j,i)==0) judge2=judge2-1
         end do
         if (judge2==0) then
            print *,'Yes'
            go to 10
         end if
      end do

      judge3=3
      do i=1,3
         if (A(i,i)==0) judge3=judge3-1
         if (judge3==0) then
            print *,'Yes'
            go to 10
         end if
      end do

      judge4=3
      do i=1,3
         if (A(i,3-i+1)==0) judge4=judge4-1
         if (judge4==0) then
            print *,'Yes'
            go to 10
         end if
      end do

      if (judge1/=0.and.judge2/=0.and.judge3/=0.and.judge4/=0) &
         print *,'No'
10    continue
      stop

   end program abc157b

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long I,O,T,J,L,S,Z;
    cin>>I>>O>>T>>J>>L>>S>>Z;
    
    long long sum=O;
    if(I&&J&&L){
        sum+=max((I/2+J/2+L/2)*2,3LL+((I-1)/2+(J-1)/2+(L-1)/2)*2);
    }else sum+=(I/2+J/2+L/2)*2;
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int maxn = 510;

int main()
{
    int k;
    while (cin >> k) {
        int a,b; a = b = 0;
        FOR(i,1,k+1) {
            if (i&1)
                a++;
            else
                b++;
        }
        cout << a*b << endl;
    }
    return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            string str1 = imp[0];
            string str2 = imp[1];
            string str3 = imp[2];

            Console.Write(str1[0]);
            Console.Write(str2[0]);
            Console.Write(str3[0]);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstdio>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000
#define MAXB 40



signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int hoge[MAXB+2] = {}, fuga[MAXB+2] = {};
	int t = 1ll<<MAXB, ans = 0;
	int N, K, num;
	
	cin>>N>>K;
	
	rep(i,N){
		// cin>>num;
		scanf(" %lld", &num);
		for(int i = 0; num; i++,num >>= 1) hoge[i] += num&1;
	}
	

	
	for(int i = 0, r = 1; i <= MAXB; i++, r <<= 1){
		fuga[i] += max(hoge[i],N-hoge[i])*r;
		fuga[i+1] += fuga[i];
	}
		
	for(int i = MAXB, temp = 0; i >= 0; i--, t>>=1){
		if((K>>i)&1){
			if(i)ans = max(ans,temp+fuga[i-1]+hoge[i]*t);
			temp += (N-hoge[i])*t;
		} else temp += hoge[i]*t;
		if(!i) ans = max(ans,temp);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

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

  cout << "Christmas";
  for (ll i = 0; i < 25-d; i++) {
    cout << " Eve";
  }
  cout << endl;

  return 0;
}

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

using namespace std;

int main (){
string s ,t;
cin >> s >> t;
int x = stoi(s+t);
for (int i=1; i<=1000; i++){
if (i*i == x){
puts("Yes");
return 0;
}
}
puts("No");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	char c[3][3];

	for(int i=0; i<3; i++)
		for(int j=0; j<3; j++)
			cin >> c[i][j];

	cout << c[0][0] << c[1][1] << c[2][2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int i,j,k,N,A[1005],v,temp;

   scanf("%d",&N);
   for(i=0;i<N;i++){
   scanf("%d",&A[i]);
   }

   for(i=0;i<N;i++){
	   v=A[i];
	   j=i-1;
	   while(j>=0 && A[j]>v){
		   temp=A[j+1];
		   A[j+1]=A[j];
		   A[j]=temp;

		   j--;
		   A[j+1]=v;
	   }
      for(k=0;k<N-1;k++){  printf("%d ",A[k]);}
      printf("%d\n",A[k]);

   }
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    long ans = a[0];
    int m = (n-2)/2;
    long num = 0;
    for(int i=1; i<=m; i++){
        ans += a[i] *2;
    }
    if(n % 2 == 1) ans += a[m+1];

    cout << ans << endl;
}

Measured memory_bytes: 4040
//C - Many Formulas:  
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

ll ans = 0;

void solve(string s, int idx, int ini, ll soma, int size) {
    string aux;
    if(idx >= s.size()) {
        if(ini < s.size()) {
            aux = s.substr(ini, s.size());
            soma += stol(aux);
        }
        ans += soma;
        return;
    }
    if(idx+1 < s.size()) solve(s, idx+1, ini, soma, size+1);
    aux = s.substr(ini, size);
    soma += stol(aux);
    solve(s, idx+1, idx+1, soma, 1);

}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s;

    cin >> s;
    solve(s, 0, 0, 0, 1);
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int k,n;
	cin >> k >> n;
	vector <int>a(n);
	vector <int>ans(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (i == n - 1) {
			ans[i] = k - a[n - 1] + a[0];
		}
		else ans[i] = a[i + 1] - a[i];
	}
	auto iter = std::max_element(ans.begin(), ans.end());
	size_t index = distance(ans.begin(), iter);
	print(k - ans[index]);
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1e8
#define ALL(a) a.begin(), a.end()
#define MAXEL max_element
#define MINEL min_element
#define POW (long long)pow
#define BIT(i) (long long)pow(2, i)
typedef long long Lint;

int main() {
  int n;
  cin >> n;
  vector<int> vcModified; // A_1-1, A_2-2, ..., A_n-n
  REP(i, n) {
    int a;
    cin >> a;
    vcModified.push_back(a - (i + 1));
  }
  sort(ALL(vcModified));
  vector<int> median{vcModified[(n - 1) / 2], vcModified[(n + 1) / 2]};
  vector<Lint> ans{0, 0};
  REP(k, 2) {
    REP(i, n) { ans[k] += abs(vcModified[i] - median[k]); }
  }
  cout << min(ans[0], ans[1]) << endl;
}


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

int main ()
{
    int a,b,c,d,e,f,g,h;
    cin >> a >> b >> c >> d;
    e=c-(d-b);
    f=d+(c-a);
    g=a-(d-b);
    h=b+(c-a);

    cout <<e<<" "<<f<<" "<<g<<" "<<h<< endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
const int maxn=20+10,mo=1000000007;
int dp[2][maxn][(1<<21)+10],nxt[(1<<21)+10][maxn];
int bz[maxn][maxn];
int i,j,k,l,r,s,t,n,m,p,ans,now;
int main(){
    scanf("%d%d%d",&n,&m,&p);
    n--;
    fo(i,0,(1<<n)-1){
        t=-1;
        fd(j,n-1,0){
            if ((i&(1<<j))) t=j;
            nxt[i][j]=t;
        }
    }
    fo(i,1,m)
        fo(j,0,n-1)
            bz[i][j]=-1;
    fo(i,1,p){
        scanf("%d%d%d",&j,&k,&l);
        bz[j][k-1]=l;
    }
    dp[0][n][0]=1;
    now=1;
    fo(i,1,m){
        fo(s,0,(1<<n)-1) dp[now][0][s]=dp[1-now][n][s];
        fo(j,0,n)
            fo(s,0,(1<<n)-1)
                dp[1-now][j][s]=0;
        fo(j,0,n-1)
            fo(s,0,(1<<n)-1)
                if (dp[now][j][s]){
                    fo(k,0,1){
                        if (bz[i][j]!=-1&&bz[i][j]!=k) continue;
                        t=(s&(1<<j));
                        if (t) t=1;
                        if (k==0&&t==1) continue;
                        if (k==t) (dp[now][j+1][s]+=dp[now][j][s])%=mo;
                        else{
                            r=nxt[s][j];
                            if (r==-1) (dp[now][j+1][s|(1<<j)]+=dp[now][j][s])%=mo;
                            else (dp[now][j+1][(s|(1<<j))-(1<<r)]+=dp[now][j][s])%=mo;
                        }
                    }
                }
        now=1-now;
    }
    fo(s,0,(1<<n)-1) (ans+=dp[1-now][n][s])%=mo;
    (ans+=mo)%=mo;
    printf("%d\n",ans);
}

Measured memory_bytes: 227456
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let mut vec: Vec<i32> = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    let mut before = 0;
    let mut ans = 0;
    let mut now = 0;
    for v in vec {
        if before >= v {
            now += 1;
            ans = std::cmp::max(ans, now);
        } else {
            ans = std::cmp::max(ans, now);
            now = 0;
        }
        before = v;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
#diverta2019_2 B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
ans = float('inf')
if n == 1:
    print(1)
    quit()
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        p,q = xy[j][0] - xy[i][0],xy[j][1] - xy[i][1]
        cost = n
        for k in range(n):
            for l in range(n):
                a,b = xy[k][0] - xy[l][0],xy[k][1] - xy[l][1]
                #print('p',p,'q',q,'a',a,'b',b,'cost',cost)
                if p == a and q == b:
                    cost -= 1
        ans = min(cost,ans)
print(ans)


Measured memory_bytes: 42844
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    string S;
    cin >> S;
    int res1 = 0;
    REP(i, S.length()){
        if(i % 2 == 0 && S.substr(i,1)!="0") res1++;
        if(i % 2 == 1 && S.substr(i,1)!="1") res1++;
    }
    int res2 = 0;
    REP(i, S.length()){
        if(i % 2 == 0 && S.substr(i,1)!="1") res2++;
        if(i % 2 == 1 && S.substr(i,1)!="0") res2++;
    }
    cout << min(res1, res2) << endl;
    return 0;
}

Measured memory_bytes: 512
n, x=gets.split.map(&:to_i)

if x==1 or x==n*2-1
  puts 'No'
  exit 0
else 
  puts 'Yes'
end

arr=(0..(n*2-1)).to_a
idx=arr.index(x)
arr[n], arr[idx]=arr[idx], arr[n]
idx=arr.index(x-1)
arr[n-1], arr[idx]=arr[idx], arr[n-1]
idx=arr.index(x+1)
arr[n+1], arr[idx]=arr[idx], arr[n+1]

(1..(n*2-1)).each{|i| puts arr[i]}

=begin

def func(arr)
  if arr.size==1
    arr[0]
  else
    m, nex=arr.size, []
    (1...(m-1)).each do |i|
      med=[arr[i-1], arr[i], arr[i+1]].sort[1]
      nex.push(med)
    end
    func(nex)
  end
end

n=5
freq=Array.new(n*2, 0)
(1..(n*2-1)).to_a.permutation do |arr|
  # puts func(arr)
  freq[func(arr)]+=1
end

(1..(n*2-1)).each do |i|
  if freq[i]>0
    puts "#{i} : ok"
  else
    puts "#{i} : ng"
  end
end

=end

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

int b, e, n, q, t;

int main() {
    cin >> n;
    int a[n], r[n];
    for (int i=0; i<n; i++) {
        cin >> a[i]; r[i] = a[i];
    }
    cin >> q;
    for (int i=0; i<q; i++) {
        cin >> b >> e >> t;
        for (int j=0; j<e-b; j++) {
            r[t+j] = a[b+j];
            r[b+j] = a[t+j];
        }
        for (int k=0; k<n; k++) a[k] = r[k];
    }
    for (int i=0; i<n-1; i++) cout << a[i] << " ";
    cout << a[n-1] << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> cd;

const int LOG = 20;
const int N = 1 << LOG;
const ld PI = acos(-1);

cd w[N];

void init() {
    for (int i = 0; i < N; i++) {
        w[i] = cd(cos(i * 2 * PI / N), sin(i * 2 * PI / N));
    }
}

static void fft(vector<cd> &A, int _LOG) {
    int _N = 1 << _LOG;
    vector<int> rev(_N);
    for (int i = 1; i < _N; i++) {
        rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (_LOG - 1));
        if (i < rev[i]) {
            swap(A[i], A[rev[i]]);
        }
    }
    for (int lvl = 0; lvl < _LOG; lvl++) {
        int len = (1 << lvl);
        for (int i = 0; i < _N; i += 2 * len) {
            for (int j = 0; j < len; j++) {
                cd x = A[i + j], y = A[i + len + j] * w[j << (LOG - 1 - lvl)];
                A[i + j] = x + y;
                A[i + len + j] = x - y;
            }
        }
    }
}

vector<ll> operator*(vector<ll> a, vector<ll> b) {
    int n = max(a.size(), b.size());
    int _N = 1, _LOG = 0;
    while (_N <= 2 * n) {
        _N *= 2;
        _LOG++;
    }
    vector<cd> A(a.begin(), a.end()), B(b.begin(), b.end());
    A.resize(_N);
    B.resize(_N);
    fft(A, _LOG);
    fft(B, _LOG);
    for (int i = 0; i < _N; i++) {
        A[i] *= B[i];
    }
    fft(A, _LOG);
    reverse(A.begin() + 1, A.end());
    vector<ll> c(_N);
    ll carry = 0;
    for (int i = 0; i < _N; i++) {
        c[i] = round(A[i].real() / _N) + carry;
    }
    return c;
}

int main() {
    cout.precision(20); cout << fixed;
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    init();
    int mod = 200003;
    int g = 2;
    vector<int> root(mod);
    vector<int> pw(1e6);
    int y = 1;
    for (int i = 0; i < mod; i++) {
        root[y] = i;
        y = (y * g) % mod;
    }
    y = 1;
    for (int i = 0; i < 1e6; i++) {
        pw[i] = y;
        y = (y * g) % mod;
    }
    int n;
    cin >> n;
    vector<ll> a(mod), v;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x != 0) {
            v.push_back(x);
            a[root[x]]++;
        }
    }
    n = v.size();
    a = a * a;
    for (int i = 0; i < n; i++) {
        a[root[v[i]] * 2]--;
    }
    ll ans = 0;
    for (int i = 0; i < a.size(); i++) {
        ans += (a[i] / 2) * pw[i];
    }
    cout << ans;
}


Measured memory_bytes: 53428
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    string S;

    cin >> S;

    if(S[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    if(65 <= S[1] && S[1] <= 90){
        cout << "WA" << endl;
        return 0;
    }

    bool C = false;

    for(int i = 2; i < S.length()-1; i++){
        if(C){
            if(65 <= S[i] && S[i] <= 90){
                cout << "WA" << endl;
                return 0;
            }
        }else{
            if(S[i] == 67){
                C = true;
            }
        }
    }

    if(65 <= S[S.length()-1] && S[S.length()-1] <= 90){
        cout << "WA" << endl;
        return 0;
    }

    if(C){
        cout << "AC" << endl;  
    }else{
        cout << "WA" << endl;  
    }
 
    return 0;
}

Measured memory_bytes: 256
import sys
import itertools as it
input = sys.stdin.readline

N, M, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
AS = list(it.accumulate(A))
BS = list(it.accumulate(B))
AS.insert(0,0)
BS.insert(0,0)
max, j = 0, M
for i in range(N+1):
    if AS[i] > K:
        break
    while i + j > max:
        if AS[i] + BS[j] <= K:
            max = i + j
            break
        j -= 1

print(max)

Measured memory_bytes: 124252
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        s: chars,
        t: chars,
    }
    let mut s = s;
    let mut t = t;
    s.sort();
    t.sort();
    t.reverse();
    puts!("{}\n", if s < t { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define ll long long
#define mod (ll)(1e9+7)
#define inf (ll)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define prique priority_queue
using namespace std;
typedef pair<ll,ll> P;
prique<ll>que;
ll a[114514];
signed main(){
	ll n,m,ans=0;
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,n)que.push(a[i]);
	rep(i,n)ans+=a[i];
	rep(i,m){
		ll p=que.top();
		ans-=(p+1)/2;
		que.pop();
		que.push(p/2);
	}
	cout<<ans<<endl;
}


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

int lcm(int a, int b){
  int g = __gcd(a, b);
  return a / g * b;
}

int countDivisble(int l, int r, int d){
  return (r / d - (l - 1) / d);
}

int32_t main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int range = b - a + 1;
  int ans = range;
  ans -= countDivisble(a, b, c);
  ans -= countDivisble(a, b, d);
  ans += countDivisble(a, b, lcm(c, d));
  cout << ans << endl;
} 

Measured memory_bytes: 256
/*
	* ernestvw
	* C++
	* May 2020
*/

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

#define int long long

#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define veci vector<int>
#define vecs vector<string>
#define amax(x, v) x = max(x, (v))
#define amin(x, v) x = min(x, (v))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define nl '\n'

using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

const int oo = 1e9; // INT_MAX
const long long OO = 1e18; // LLONG_MAX
const double eps = 1e-9;
const int p197 = 1000000007;
const int p998 = 998244353;
const int p103 = 1000003;

#define TEST_CASES 0

void solve(int test_case);

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

	int T = 1;
	if(TEST_CASES) cin >> T;
	for(int t = 1; t <= T; t++)
		solve(t);

	return 0;
}

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

int x;

void solve(int test_case) {
	cin >> x;
	int cnt = 0;
	int y = 100;
	while(y < x) {
		y = floor((double)y * 1.01);
		cnt++;
	}
	cout<<cnt<<endl;
}



















































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

int main()
{
	int a, b;

	cin >> a >> b;
	
	if (a < b) cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else cout << "a == b" << endl;

	return (0);
}

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

#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";
#define pb push_back

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
    os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
    for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
    os << "("; os << v.first << ", " << v.second << ")"; return os;
}
void go() {
    cin.tie(nullptr) -> sync_with_stdio(false);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
#define int long long
const int mod = 1e9 + 7, N = 1e6 + 5;
int32_t main() {
    go();
    int n; cin >> n;
    vector<int> a(N), b(N), c(N);
    a[0] = 1; b[0] = 1; c[0] = 1;
    for (int i = 1; i <= n; i++) {
        a[i] = (a[i - 1] * 10) % mod;
        b[i] = (b[i - 1] *  9) % mod;
        c[i] = (c[i - 1] *  8) % mod;
    }
    cout << ((a[n] - 2 * b[n] + c[n]) % mod + mod) % mod;
}


Measured memory_bytes: 26688
H, W = map(int, input().split())

# #で上下左右隣接するマスに#がなければNo
s = []
for h in range(H):
    s.append(input())

for h in range(H):
    for w in range(W):
        if s[h][w] == '.':
            continue

        above = s[h - 1][w] if h >= 1 else '.'
        if above == '#':
            continue

        below = s[h + 1][w] if h < len(s) - 1 else '.'
        if below == '#':
            continue

        left = s[h][w - 1] if w >= 1 else '.'
        if left == '#':
            continue

        right = s[h][w + 1] if w < len(s[h]) - 1 else '.'
        if right == '#':
            continue

        print('No')
        exit(0)

print('Yes')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
long long int a[100010],n;



int main(){
	cin >> n;
	int e=0;
	long long int w = 1000000010;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] <= 0) {
			e++;
			a[i] = -a[i];	
		}
		if (a[i] < w) {
			w = a[i];
			}
	}
	long long int ans=0;
	for (int i = 0; i < n; i++) {
			ans += a[i];
		}

	if (e % 2 == 1) {
		ans -= 2*w;
	}
	cout << ans << endl;

return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int a[10];
int main()
{
	int n, total = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; scanf("%d", &a[i++])){}
	sort(a, a + n);
	for(int i = 0; i < n - 1; total += a[i++]){}
	printf(total > a[n - 1] ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; string s; cin >> n >> s;
	ll q; cin >> q;
	while(q--){
		ll k; cin >> k;
		ll m=0,c=0,cnt=0;
		ll ans = 0;
		rep(i,k-1){
			if(s[i]=='M') m++;
			if(s[i]=='C') cnt += m, c++;
		}
		rep(i,n){
			if(i+k<=n) if(s[i+k-1]=='C') c++, cnt += m;
			if(i+k<=n) if(s[i+k-1]=='M') m++;
			if(s[i]=='D') ans += cnt;
			if(s[i]=='M') m--, cnt -= c;
			if(s[i]=='C') c--;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1948
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, k = na()
aaa = na()
ans = 1
n -= k
if n == 0:
    pass
elif n % (k - 1) == 0:
    ans += n // (k - 1)
else:
    ans += n // (k - 1) + 1
print(ans)


Measured memory_bytes: 15948
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a * b / gcd(a, b);
}

void solve() {
    ll n; cin >> n;
    // ll h[11000] = {0};
    Vl h(n, 0);
    rep(i, 0, n) cin >> h[i];
    rep(i, 0, n-1){
        if(h[i] == h[i+1]){
            h.erase(h.begin()+i);
            n--; i--;
        }
    }
    if(n == 1){
        cout << h[0] << endl;
        return;
    }
    if(n == 2){
        cout << max(h[0], h[1]) << endl;
        return;
    }
    // rep(i, 0, n) cout << h[i] << " ";
    // cout << endl;
    ll r[11000] = {0}, l[11000] = {0};
    rep(i, 1, n) if(h[i] >= h[i-1]) r[i]++;
    rep(i, 0, n-1) if(h[i] >= h[i+1]) l[i]++;
    // rep(i, 0, n) cout << r[i];
    // cout << endl;
    // rep(i, 0, n) cout << l[i];
    // cout << endl;
    ll ans = 0;
    if(l[0]) ans += h[0];
    if(r[n-1]) ans += h[n-1];
    rep(i, 1, n-1){
        if(r[i] && l[i]) ans += h[i];
        if(!r[i] && !l[i]) ans -= h[i];
    }
    cout << ans << endl;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

int main(int argc, char *argv[]) {
	int n;
	scanf("%d",&n);
	long long lucas[100];
	lucas[0]=2;
	lucas[1]=1;
	for(int i=2;i<=n;i++){
		lucas[i]=lucas[i-2]+lucas[i-1];
	}
	printf("%lld",lucas[n]); 
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  rep (i, s.size() - 2) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
package main
import "fmt"
 
func main() {
  var n, a int
  maxVal := 0
  secondVal := 0
  maxIdx := 0
  
  fmt.Scanln(&n)
  
  for i := 0; i < n; i++ {
    fmt.Scanln(&a)
    
    if(a >= maxVal) {
      secondVal = maxVal
      maxVal = a
      maxIdx = i
    } else if( a >= secondVal) {
      secondVal = a
    }
  }
  
  for i := 0; i < n; i++ {
    if(i == maxIdx) {
      fmt.Printf("%d\n", secondVal)
    } else {
      fmt.Printf("%d\n", maxVal)
    }
  }
}

Measured memory_bytes: 7684
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem (B) in C++
// MAIN IDEA   : brute force on length + divisors
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e6 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
vl v;
int main() {
#ifdef ONLINE_JUDGE
    FAST
#endif
	int n;
	ll d;
	cin >> n >> d;
	lp(i,1,n)
	{
		ll x;
		cin >> x;
		v.pb(abs(x - d));
	}
	sort(all(v));
	ll g=0;
	for (auto u:v)
		g=__gcd(u,g);
	f(g);
	return 0;
}

Measured memory_bytes: 1400
let iota n =
    let rec f acc = function
        | -1 -> acc
        | 0 -> 0 :: acc
        | n -> f (n :: acc) (n - 1)
    in f [] (n-1)

let rec all = function
    | [] -> true
    | true :: t -> all t
    | false :: t -> false

let rec any = function
    | [] -> false
    | true :: t -> true
    | false :: t -> any t

let ans yes no = function
    | true -> yes
    | false -> no

let () = Scanf.scanf "%d %d %d\n" @@ fun a b c ->
    iota b
    |> List.map (fun n -> (a * (n+1)) mod b = c)
    |> any
    |> ans "YES" "NO"
    |> Printf.printf "%s"


Measured memory_bytes: 384
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

func main() {
	inputs := scanIntNums()
	A := inputs[0]
	B := inputs[1]
	//C := inputs[2]
	K := inputs[3]

	var ans int
	if K > A {
		if K-A-B >= 0 {
			ans = A - (K - A - B)
		} else {
			ans = A
		}
	} else {
		ans = K
	}
	fmt.Println(ans)
}


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

long long dp[3010][3010], l[3010];

long long solve(int i, int j, int v){
	
	if(i > j) return 0;
	
	if(dp[i][j] == 3000000000000) {
		if(v) dp[i][j] = max(solve(i + 1, j, !v) + (v ? 1 : -1) * l[i], solve(i, j - 1, !v) + (v ? 1 : -1) * l[j]);
		else dp[i][j] = min(solve(i + 1, j, !v) + (v ? 1 : -1) * l[i], solve(i, j - 1, !v) + (v ? 1 : -1) * l[j]);
	}
	
	return dp[i][j];
}

int main(){
	
	int n;
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++) scanf(" %lld", &l[i]);
	
	for(int i = 0; i < n + 1; i++) for(int j = 0; j < n + 1; j++) dp[i][j] = 3000000000000;
	
	printf("%lld\n", solve(0, n - 1, 1));
	return 0;
}


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


void solve(long long A, long long B, long long C, long long K){
    int ans = 0;
    if(A < K) {
        K -= A;
        ans += A;
    }else {
        cout << K << endl;
        return;
    }

    if(B < K) {
        K -= B;
    } else { 
        cout << ans << endl;
        return;
    }

    if(C < K) {
        cout << ans  - C << endl;
        return;
    }else {
        cout << ans -  K << endl;
        return;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3760
#define P(x) cout << #x " = " << x << endl
#define PP(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl

#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int r, g, b, n;
int main()
{
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int rc = 0; rc <= (n + r - 1) / r; ++rc) {
        for (int gc = 0; gc <= (n + g - 1) / g; ++gc) {
            int rest = n - rc * r - gc * g;
            if (rest >= 0 && rest % b == 0) {ans++;}
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
  int n=0;
  int abc_cnt=0;
  int check[3] = {0};
  string s;

  cin >> n;
  cin >> s;

  int pre_i[3]={-100};

  if (n>50)
  {
    n = 50;
  }

  if (n>2){
    for (size_t i = 0; i < n; i++)
    {
      if (s[i]=='A')
      {
          check[0] = 1;
          pre_i[0] = i;
      } else if (s[i]=='B' && pre_i[0]==i-1)
      {
          check[1] = 1;
          pre_i[1] = i;
      }
      else if (s[i] == 'C' && (pre_i[0] == i - 2 && pre_i[1] == i - 1))
      {
          check[2] = 1;
          pre_i[2] = i;
      }

      if (check[0]*check[1]*check[2] == 1)
      {
        abc_cnt++;
        for (size_t j = 0; j < 3; j++)
        {
          check[j] = 0;
          pre_i[j] = -100;
        }
      }
    }
  }

  cout << abc_cnt << endl;
  return 0;
}



Measured memory_bytes: 256
N = int(input())
C = {i:0 for i in range(1,N+1)}
for x in range(1,142):
    for y in range(1,142):
        for z in range(1,142):
            a = (x+y)**2+(y+z)**2+(z+x)**2
            if a%2==0 and a//2<=N:
                C[a//2] += 1
for i in range(1,N+1):
    print(C[i])

Measured memory_bytes: 75044
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 1000000007;

int main() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> P(a), Q(b), R(c);
    for (auto & p : P) {
        cin >> p;
    }
    for (auto & q : Q) {
        cin >> q;
    }
    for (auto & r : R) {
        cin >> r;
    }
    sort(P.begin(), P.end(), greater<ll>());
    sort(Q.begin(), Q.end(), greater<ll>());
    sort(R.begin(), R.end(), greater<ll>());
    for (ll i = 0; i < x; ++i) {
        R.push_back(P[i]);
    }
    for (ll i = 0; i < y; ++i) {
        R.push_back(Q[i]);
    }
    sort(R.begin(), R.end(), greater<ll>());
    ll res = 0;
    for (ll i = 0; i < x + y; ++i) {
        res += R[i];
    }
    cout << res << endl;

}


Measured memory_bytes: 5872
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

const long long MOD = 1000000007;

ll P[200010];
ll ans[200010] = {};

void solve(long long N){
    ans[0] = 1;
    fill(P, P + 200010, -1);
    loop1 (N, i) {
        int c; cin >> c;
        ans[i] = ans[i - 1];
        if (P[c] >= 0) {
            int p = P[c];
            if (p <= i - 2) {
                ans[i] = (ans[i] + ans[p]) % MOD;
            }
        }
        P[c] = i;
    }
    cout << ans[N] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}



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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int p, q, r; cin >> p >> q >> r;
  int ans = INT_MAX;
  chmin(ans, p+q);
  chmin(ans, q+r);
  chmin(ans, r+p);
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

ll n, w;

const ll V_MAX = 100000+10;
const ll N_MAX = 100+10;

ll value[N_MAX], weight[N_MAX];
ll dp[N_MAX][V_MAX]; // dp[i][j] = i番目までの品物を選んだ時の価値j以下における重さの最小値

ll q(ll x, ll y){
    if(dp[x][y]!=LINF) return dp[x][y];

    if(y<value[x]) dp[x][y] = q(x-1,y);
    else dp[x][y] = min(q(x-1,y),q(x-1,y-value[x])+weight[x]);

    return dp[x][y];
}

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

    cin >> n >> w;
    ll sum = 0;
    REP(i,n){
        cin >> weight[i+1] >> value[i+1];
        sum += value[i+1];
    }

    REP(i,N_MAX){
        REP(j,V_MAX){
            if(i==0) dp[i][j] = LINF+1;
            else dp[i][j] = LINF;
        }
    }
    dp[0][0] = 0;

    while(1){
        if(q(n,sum)<=w){
            cout << sum << endl;
            break;
        }
        sum--;
    }

    
    return 0;
}



Measured memory_bytes: 89604