akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

int N, MA, MB;
struct medic {
	int a, b;
	int c;
};
vector<medic> medics;
int NA, NB;
vector<vector<int>> deck;

int main() {
	cin >> N >> MA >> MB;
	NA = N / 2;
	NB = N - NA;
	medics.resize(N);
	for (int n = 0; n < N; n++) {
		cin >> medics[n].a >> medics[n].b >> medics[n].c;
	}
	deck.resize(201, vector<int>(201, INT_MAX));
	for (int code = 0; code < (1 << NB); code++) {
		int tempcost = 0, tempa = 0, tempb = 0;
		for (int n = 0; n < NB; n++) {
			if (((code >> n) & 1) == 1) {
				tempcost += medics[NA + n].c;
				tempa += medics[NA + n].a;
				tempb += medics[NA + n].b;
			}
		}
		deck[tempa][tempb] = min(deck[tempa][tempb], tempcost);
	}
	int ans = INT_MAX;
	for (int code = 0; code < (1 << NA); code++) {
		int tempcost = 0, tempa = 0, tempb = 0;
		for (int n = 0; n < NA; n++) {
			if (((code >> n) & 1) == 1) {
				tempcost += medics[n].c;
				tempa += medics[n].a;
				tempb += medics[n].b;
			}
		}
		int k = max(ceil((long double)tempa / MA), ceil((long double)tempb / MB));
		k = max(k, 1);
		while (true) {
			if (k * MA - tempa > 200 || k * MB - tempb > 200)break;
			if (deck[k * MA - tempa][k * MB - tempb] != INT_MAX)ans = min(ans, tempcost + deck[k * MA - tempa][k * MB - tempb]);
			k++;
		}
	}
	if (ans == INT_MAX)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define fr first
#define sc second
#define MAX ((ll)(1e18+100))
#define MOD ((ll)(1e9+7))
#define HSM ((ll)(307))
#define ARRS ((ll)(2e6+900))
#define pb push_back
#define mid ((l+r)>>1)
#define PI 3.14159265358979323846
#define MXN 500009
#define mep make_pair

ll a[400];
int main(){
	ios::sync_with_stdio(0);
	string s;
	cin>>s;
	for(int i=0; i<s.size(); i++){
		a[s[i]]++;
	}
	ll k,p,c;
	k=a['a'];
	p=a['b'];
	c=a['c'];
	if(max({k,p,c})>min({k,p,c})+1){
		cout<<"NO";
	}
	else cout<<"YES";

}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define l long

using namespace std;

int main()
{
    int n; cin >> n;
    ll sum = 0,summ=0;
    ll ans = 0;
    int a[n];
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        summ+=a[i];
    }
    for(int i=0; i<n; i++){
            sum=((summ-a[i])%MOD)*a[i];
            sum%=MOD;
            ans+=sum;
            ans%=MOD;
            summ-=a[i];
        }

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


Measured memory_bytes: 4416
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        ArrayList<Integer> result = new ArrayList<Integer>();
        Scanner insert = new Scanner(System.in);
        int n = -1;
        while(true) {
            String line = insert.nextLine();
            n = Integer.parseInt(line);
            if(n==0 ){
                break;
            }
            for(int i = 0; i < n;i++) {

            }
            line = insert.nextLine();
            String array2[] = line.split(" ");
            int[] input = new int[n];
            int sum = 0;
            for(int i =0; i < n; i++) {
                input[i] = (Integer.parseInt(array2[i]));
                sum+=input[i];
            }
            double avg = (double)sum/(double)n;
            int num = 0;
            for(int i =0; i < n; i++) {
                if(input[i] <= avg) {
                    num++;
                }
            }
            result.add(num);

        }
        for(int i = 0;i < (result.size());i++) {
            if(result.get(i) == -1) {
                System.out.println("NONE");
            }
            else {
                System.out.println(result.get(i));
            }
        }
    }
}



Measured memory_bytes: 64532
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

string S;
int Sprime[112345];
int l, cnt = 0;

int main(){
	cin >> S;
	
	l = S.length();
	
	REP(i,l){
		Sprime[i] = S[i]-'0';
	}
	
	FOR(i,1,l){
		if (Sprime[i] == Sprime[i-1]){
			cnt++;
			Sprime[i]++;
			Sprime[i] %= 2;
		}
	}
	
	cout << min(cnt,l-cnt) << endl;
	
	return 0;
}

Measured memory_bytes: 896
#ABC131B

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

azi = 0
for l in range(L, L+N):
    azi += l

azi_l = L
azi_r = L+N-1

if ( azi_l * azi_r < 0):
    azi_min = 0
else:
    if (abs(azi_l) < abs(azi_r)):
        azi_min = azi_l
    else:
        azi_min = azi_r

azi = azi - azi_min
print(azi)

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

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n; 
    string s;
    cin >> n >> s;
    vector< pair<char, int> > memo;
    
    vector< vector<int> > acc(2, vector<int>(n, 0) );
    
    acc[0][0] = (s[0] == '.');
    acc[1][0] = (s[0] == '#');

    for(int i = 1; i < n; ++i) {
        acc[0][i] = acc[0][i - 1] + (s[i] == '.');
        acc[1][i] = acc[1][i - 1] + (s[i] == '#');
    }

    int ans = min(acc[0][n - 1], acc[1][n - 1]);

    for(int p = 0; p < n; ++p) {
        // [0, p] vai ser white
        int cost = acc[1][p];

        int resto = (n - 1 - p);
        
        int sub = (acc[1][n - 1] - acc[1][p]);
        
        cost += (resto - sub);
        ans = min(ans, cost);
    }

    cout << ans << '\n';
    return 0;
    
}


Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
int n,m,a[105],sum=0;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    cin>>m;
    while(m--){
        int p,x;
        scanf("%d%d",&p,&x);
        printf("%d\n",sum-a[p]+x);
    }
    return 0;
}

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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();

    int[][] data =  new int[n+1][k+1];

    for (int i = 1; i < k+1; i++) {
      int d = sc.nextInt();
      for (int j = 0; j < d; j++) {
        data[sc.nextInt()][i]++;
      }
    }

    int count = 0;
    int ans = 0;

    for (int i = 1; i < n+1; i++) {
      for (int j = 1; j < k+1; j++) {
        if (data[i][j] != 0) {
          count++;
        }
      }
      if (count == 0) {
        ans++;
      }
      count = 0;
    }

    System.out.println(ans);




  }

}


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

int main(){
    int k,s;
    cin >> k >> s;
    int cnt = 0;
    for (int i = 0;i <= k;i++){
        for (int j = 0;j <= k;j++){
            if ((s - i - j) <= k && (s-i-j) >= 0){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cnt = 0
tmp = 0
tmp2 = 0

for i in range(N):
    if A[i] >= B[i]:
        cnt += B[i]
    else:
        tmp = B[i] - A[i]
        cnt += A[i]
        if A[i+1] >= tmp:
            cnt += tmp
            A[i+1] = A[i+1] - tmp
        else:
            cnt += A[i+1]
            A[i+1] = 0

print(cnt)

Measured memory_bytes: 18624
while 1:
    n,c=input(),0
    if int(n)==0:break
    if n.count(n[0])==4:
        print('NA')
        continue
    while n!='6174':
        n = str(int(''.join(reversed(sorted(list(n))))) - int(''.join(sorted(list(n))))).zfill(4)
        c+=1
    print(c)

Measured memory_bytes: 7672
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int num, i;
	double a, sum = 0.0;
	cin >> num;
	for (i = 0; i < num; i++) {
		cin >> a;
		sum += 1.0 / a;
	}
	printf("%.9lf\n", 1.0 / sum);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.8f\n",sqrt(pow(x2-x1,2)+pow(y2-y1,2)));
	return 0;
}

Measured memory_bytes: 656
#include <iostream>
#include <algorithm>
#include <fstream>

using namespace std;

void printArray(int A[], int num){
    for(int j=0; j<num; j++){
        if (j > 0) printf(" ");
        printf("%d", A[j]);
    }
    printf("\n");
}

int bubbleSort(int A[], int num){
    int sw = 0;
    for(int i=0; i<num-1; i++){
        for(int j=num-1; j>=i+1; j--){
            if (A[j-1] > A[j]){
                swap(A[j-1], A[j]);
                sw++;
            }
        }
    }
    return sw;
}

int main(){

    int num;
    int A[100];

    cin >> num;

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

    int sw = bubbleSort(A, num);

    printArray(A, num);

    cout << sw << endl;

    return 0;
}

Measured memory_bytes: 3252
from collections import defaultdict
N,M=map(int,input().split())
dict=defaultdict(int)
l1=[]
l2=[]
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        l1.append(b)
    if b==N:
        dict[a]=1
for i in l1:
    if dict[i]:
        print("POSSIBLE")
        quit()
print("IMPOSSIBLE")


Measured memory_bytes: 73816
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y; 
}


Measured memory_bytes: 3580
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    H, W = map(int, input().split())
    S = []
    Dx, Dy = [-1, 0, 0, 1], [0, -1, 1, 0]

    for i in range(H):
        S.append(input())

    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                flg = False
                for dx, dy in zip(Dx, Dy):
                    x = i + dx
                    y = j + dy

                    if not (0 <= x < H and 0 <= y < W):
                        continue

                    if S[x][y] == "#":
                        flg = True
                        break
                
                if not flg:
                    print("No")
                    sys.exit()
    
    print("Yes")


main()


Measured memory_bytes: 5292
n = int(input())
A = list(map(int, input().split()))
if n==0:
    print(1 if A[0] == 1 else -1)
    exit()
if A[0]>0:
    print(-1)
    exit()
if A[-1]>2**n:
    print(-1)
    exit()
node1=[0]*(n+1)
node1[0]=1
node2=[0]*(n+1)
node2[-1]=A[-1]
for i in range(n):
    x=(node1[i]-A[i])*2
    if x<1:
        print(-1)
        exit()
    node1[i+1]=x
#print(node1)
for i in range(n-1,-1,-1):
    x=(node2[i+1]+A[i])
    node2[i]=x
ans=[]

for i in range(n+1):
    x=min(node1[i],node2[i])
    if x<A[i]:
        print(-1)
        exit()
    ans.append(x)
print(sum(ans))


Measured memory_bytes: 707912
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

int main()
{
    string s;
    ll k;

    cin >> s >> k;

    int h = 0;
    for (int i = 0; i < k; i++)
        if (s[i] != '1')
        {
            cout << s[i] << endl;
            return 0;
        }

    cout << "1" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

struct edge{
    public:
        int to,dist,mu;
        edge(){}
        edge(int t,int d,int m) : to(t),dist(d),mu(m){}
};

using P = pair<int,pair<int,int>>; // killer , node ,remaining
P makeP(int i,int j,int k){
    return make_pair(i,make_pair(j,k));
}


void solve(int N,int M,int L){
    vector<vector<edge>> G(N);
    rep(i,M){
        int a,b,d,e;
        cin>>a>>b>>d>>e;
        a--;
        b--;
        G[a].push_back(edge(b,d,e));
        G[b].push_back(edge(a,d,e));
    }

    vector<vector<int>> vis(N+2,vector<int>(L+2,INF));
    priority_queue<P,vector<P>,greater<P>> que;
    que.push(makeP(0,0,L));
    vis[0][L]=0;
    while(!que.empty()){
        auto q = que.top();
        que.pop();
        int u = q.second.first;
        int rem = q.second.second;
        int killer = q.first;

//        cerr << "POP : u=" << u << " rem=" << rem << " killer=" << killer << endl; 

        if(u==N-1){
            cout << killer << endl;
            return;
        }


        if(vis[u][rem] < killer) continue;

        for(edge e : G[u]){
            int v=e.to;
            int cost=e.dist;
            int n_killer=e.mu;

            // not use
            if(vis[v][rem] > killer+n_killer){
                vis[v][rem] = killer + n_killer;
                que.push(makeP(vis[v][rem],v,rem));
            }

            if(rem-cost>=0 and vis[v][rem-cost]>killer){
                vis[v][rem-cost] = killer;
                que.push(makeP(vis[v][rem-cost],v,rem-cost));
            }
        }
    }
    assert(false);
}

int main(){
    int n,m,l;
    while(cin>>n>>m>>l){
        if(n==0 && m==0 && l==0) break;
        solve(n,m,l);
    }
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int s,w;
  cin >>s>>w;
  vector<string> vec(s);
  for (int i=0;i<s;i++){
    cin >>vec.at(i);
    vec.at(i) = "#" + vec.at(i) +"#";
  }
  for (int i=0;i<w+2;i++){
    cout <<"#";
  }
  cout << endl;
  for (int i =0;i<s;i++){
    cout <<vec.at(i)<<endl;
  }
  for (int i=0;i<w+2;i++){
    cout <<"#";
  }
  cout << endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
  int a = 0, b = 0;
  fscanf(stdin, "%d %d", &a, &b);
  fprintf(stdout, "%d %d", a * b, 2 * a + 2 * b);

  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <stdlib.h>

int main()
{
int n,m,s,k;

scanf("%d %d %d",&n,&m,&s);
if(n<=m)
{
if(s%m!=0)
        k=s/m+1;
        else
            k=s/m;

}
else
{
    if(s%n!=0)
    k=s/n+1;
    else
        k=s/n;
}

printf("%d\n",k);
    return 0;
}


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

int main() {
    int A, B, ans;
    cin >> A >> B;
    if (A <= 5) {
        ans = 0;
    } 
    else if (A <= 12) {
        ans = B/2;
    }
    else {
        ans = B;
    }
    cout << ans << endl;
}

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

#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

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

void maxi(ll&a, ll b){
    a = max(a, b);
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N;
    int W;

    vi w;
    vi v;

    cin >> N;
    cin >> W;

    w.resize(N);
    v.resize(N);

    for(int i=0; i < N; i++){
        cin >> w[i] >> v[i];
    }

    ll dp[W+1];
    for(int i=0; i <= W; i++){
        if(w[0] > i) dp[i] = 0;
        else dp[i] = v[0];
    }

    for(int i=1; i < N; i++){
        // end at w[i] since everything less must be from the array right before it (which is the same value in the 1D case)
        // start at W and go backwards since we do not want to update the new values and then use them again for the same row. Going backwards lets us use the old values (aka from the old line) to update new values
        for(int j=W; j >= w[i]; j--){
            // this works since 2D dp method only looks at the array right before it
            maxi(dp[j], dp[j-w[i]] + v[i]);
        }

    }

    ll ans = dp[W];
    cout << ans << endl;

    return 0;
}


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

int main()
{
	int n,num,cnt=0;
	cin >>n;
	for (int i = 0; i != n; ++i)
	{
		cin >> num;
		for (int j = 2; j <= sqrt(num);++j)
		{
			if (num%j == 0)
			{
				++cnt;
				break;
			}
		}
	}
	
	cout << n-cnt << endl;

	return 0;

}


Measured memory_bytes: 3072
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)

	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	var alice, bob int

	for i := N - 1; i >= 0; i-- {
		if i%2 == 0 {
			alice += a[i]
		} else if i%2 == 1 {
			bob += a[i]
		}
	}
	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!
SIZE=300000; MOD=10**9+7 #ここを変更する

inv = [0]*(SIZE+1)# inv[j] = j^{-1} mod MOD
fac = [0]*(SIZE+1)# fac[j] = j! mod MOD
finv = [0]*(SIZE+1)# finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1

for i in range(2,SIZE+1):
    inv[i] = MOD -(MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0

n,k = [int(i) for i in input().split()]


for i in range(1,k+1):
#    print(choose(k-1,i-1),choose(n-k+1,i))
    ans = choose(k-1,i-1)*choose(n-k+1,i)
    print(ans%MOD)
    











Measured memory_bytes: 38908
// Problem : D - String Equivalence
// Contest : Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

string s, s2;


int getDiff(string& s) {
	vi cnt(27);
	int ile = 0;
	REP(i, sz(s)) {
		int x = s[i] - 'a';
		if (cnt[x] == 0) {
			ile++;
			cnt[x] = 1;
		}
	}
	return ile;
}

vector<string> vec;
int n;

void generate() {
	REP(i, n - 1) {
		vector<string> vec2;
		for (auto x: vec) {
			int ile = getDiff(x);
			//cout << x << " " << ile << endl;
			for (char c = 'a'; c < 'a' + ile + 1; c++) {
				vec2.pb(x + c);
			}
		}
		vec = vec2;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	vec.pb("a");
	generate();
	for (auto k : vec) cout << k << "\n";
	return 0;
}


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

using namespace std;
typedef long long ll;

const int MN = 100010;
int n;
int c[MN][3];
int dp[MN][3];

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

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (i == 0 || j != k) {
                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + c[i][k]);
                }
            }
        }
    }
    cout << *max_element(dp[n], dp[n] + 3) << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int n; cin>>n; vector<int> p;
    for(int i=0;i<n;i++){
      int pp; cin>>pp; p.push_back(pp);
    }
    int cnt=0;
    for(int i=1;i<n-1;i++){
      int mmin = min(min(p[i-1], p[i]), p[i+1]);
      int mmax = max(max(p[i-1], p[i]), p[i+1]);
      if(p[i]!=mmin && p[i]!=mmax )  cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long  min, max, sum, n, i, times;
    cin >> times;
    cin >> n;
    max=n;
    min=n;
    sum=0;
    for(i=1;i<=times;i++){
        sum=sum+n;
        if (n>=max)
        max=n;
        if (n<=min)
        min=n;
        cin >> n;
    }
    cout << min << " "  << max << " "  << sum <<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <unordered_set>


int main() {
    int n;
    std::cin >> n;
    std::vector<std::pair<int, int>> red_points, blue_points;
    red_points.reserve(n);
    blue_points.reserve(n);
    for(int i = 0; i < n; i++) {
        int x, y;
        std::cin >> x >> y;
        red_points.emplace_back(x, y);
    }
    std::sort(
        red_points.begin(), red_points.end(),
        [](const std::pair<int, int>& p, const std::pair<int, int>& q) {
            return p.second > q.second;
        }
    );
    for(int i = 0; i < n; i++) {
        int x, y;
        std::cin >> x >> y;
        blue_points.emplace_back(x, y);
    }
    std::sort(
        blue_points.begin(), blue_points.end(),
        [](const std::pair<int, int>& p, const std::pair<int, int>& q) {
            return p.first < q.first;
        }
    );
    int ans = 0;
    for(const auto& blue_point : blue_points) {
        for(auto red_itr = red_points.begin(), red_end = red_points.end(); red_itr != red_end; ++red_itr) {
            if(red_itr->first < blue_point.first && red_itr->second < blue_point.second) {
                ans++;
                red_points.erase(red_itr);
                break;
            }
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
//#define vi vector<int>
#define vb vector<bool>
#define pii pair<int, int>
#define mii map<int, int>
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define inf (long long)1e18
#define F first
#define S second
#define SZ(x) ((int)(x).size())
//#define rep(i, n) for (int i = 0; i < n; i++)
//#define repd(i,n) for(int i=n-1;i>=0;i--)
//#define rep1(i,n) for(int i=1;i<=n;i++)
const int N = 1e9 + 7;

int pow(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = ((res) * (x));
        res %= N;
        y = y >> 1;
        x = ((x) * (x));
    }
    return res;
}
int powm(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll mxn(ll a, ll b)
{
    if (a > b)
        return a;
    else
    {
        return b;
    }
}
long long minl(long long a, long long b)
{
    if (a < b)
        return a;
    else
    {
        return b;
    }
}

void solve()
{
    int n;
    cin >> n;
    if (n == 0)
    {
        cout << 1;
    }
    else
    {
        cout << 0;
    }
}

int32_t main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;
    // while (t--)
    // {
    solve();
    // }
}

Measured memory_bytes: 3632
using System;

namespace ABC111A
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            int s = 111;
            if (a.Substring(0, 1) == "1")
                s = s + 800;
            if (a.Substring(1, 1) == "1")
                s = s + 80;
            if (a.Substring(2, 1) == "1")
                s = s + 8;
            Console.WriteLine(s);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
def main():
    n = int(input())
    ans = 0
    minr = int(input())
    ans = -1 * 10**9
    for i in range(n-1):
        r = int(input())
        ans = max(ans, r-minr)
        minr = min(minr, r)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5616
n = gets.to_i
ok = false
count = 0
n.times do
  d1, d2 = gets.split.map(&:to_i)
  if d1 == d2
    count += 1
  else
    count = 0
  end
  ok = true if count >= 3
end
puts ok ? "Yes" : "No"


Measured memory_bytes: 14380
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int A, B; cin >> A >> B;
    if(A>12) {
        cout << B << endl;
    }else if(A>5) cout << B/2 << endl;
    else cout << 0 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
const ll MOD=1e9+7;
using namespace std;

ll a[1005];
int main(){
  ll N;
  cin >> N;
  vector<ll> a(N),b;
  rep(i,N){
    cin >> a[i];
  }
  sort(All(a));
  for(ll i=N-1;i>=0;i--){
    if(a[i]==a[i-1]){
      b.push_back(a[i]);
      i--;
    }
    if(b.size()==2) {
      cout << b[0]*b[1] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
string s;
int k,dp[301][301][301];
int calc(int l, int r, int k){
	if(k<0)
		return -oo;
	if(l>r)
		return 0;
	if(l==r)
		return 1;
	int &ret=dp[l][r][k];
	if(ret!=-1)return ret;
	ret=max(calc(l+1,r,k),calc(l,r-1,k));
	if(s[l]==s[r])
		ret=max(ret, 2+calc(l+1,r-1,k));
	else
		ret=max(ret, 2+calc(l+1,r-1,k-1));
	return ret;
}
int main(){
	cin>>s>>k;
	memset(dp,-1,sizeof(dp));
	cout<<calc(0,s.size()-1,k)<<endl;
	return 0;	
}

Measured memory_bytes: 106880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ll x;
		cin>>x;
		if(i%2!=0&&x%2!=0){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3620
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    l, r, c = map(int, input().split())
    l, r = l - 1, r - 1
    G[l].append([r, c])

for i in range(1, N):
    G[i].append([i - 1, 0])


def dijkstra(graph, start, inf=float('inf')):
    import heapq
    n = len(graph)
    distances = [inf] * n
    distances[start] = 0
    visited = [False] * n

    # 距離・頂点
    hq = [(0, start)]
    while hq:
        dist, fr = heapq.heappop(hq)
        visited[fr] = True

        for to, cost in graph[fr]:
            new_dist = distances[fr] + cost
            if (visited[to]) or (distances[to] <= new_dist):
                continue

            distances[to] = new_dist
            heapq.heappush(hq, (new_dist, to))

    return distances


ans = dijkstra(G, 0)[N - 1]
print(ans if ans != float('inf') else -1)


Measured memory_bytes: 50288
#include<stdio.h>

int main(void){

int r=100000;
int n;

scanf("%d",&n);


for(int i = 0; i<n; i++){
 r = r*1.05;

if(r%1000 > 0){
r=r/1000*1000+1000;
}
}
printf("%d\n",r);

return 0;
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
int main(){
  	string S;
	cin >> S;
  	if(S[0]!=S[1]&&S[1]!=S[2]&&S[2]!=S[3]){
      cout << "Good" << endl;
    }else{
      cout << "Bad" << endl;
    }
}
      

Measured memory_bytes: 256
#include <iostream>
#include <numeric>

using namespace std;

int main(){
    long long A,B;

    cin >> A >> B;

    long long x = A*B;
    int r = A%B;

    while(r != 0){
        A = B;
        B = r;
        r = A%B;
    }

    cout << x/B << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b;
    cin >> a >> b;
    if(a > b){
        cout << a - 1 << endl;
    }else{
        cout << a << endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
using ll = long long int;

int n, m;
map<ll, ll> d;

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		ll di;
		cin >> di;
		d[di]++;
	}
	string ret = "YES";
	cin >> m;
	for (int i = 0; i < m; i++) {
		ll ti;
		cin >> ti;
		if (d[ti] > 0) {
			d[ti]--;
		}
		else {
			ret = "NO";
			break;
		}
	}
	cout << ret << endl;
	return 0;
}

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

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

    int n; cin >> n;

    map<string, int> cnt;
    REP(i, n) {
        string s; cin >> s;
        cnt[s]++;
    }

    int maxi = 0;
    for (auto i : cnt)
        maxi = max(maxi, i.second);

    for (auto i : cnt)
        if (i.second == maxi)
            cout << i.first << '\n';
    return 0;
}


Measured memory_bytes: 23808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class Main {
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] inStr= br.readLine().split(" ");
        int a = Integer.parseInt(inStr[0]);
        int b = Integer.parseInt(inStr[1]);
        double c = Integer.parseInt(inStr[2])*Math.PI/180;
        double h = b*Math.sin(c);
        double d = a - b*Math.cos(c);
        out.printf("%.4f\n",h*a/2);
        out.printf("%.4f\n",Math.sqrt(d*d + h*h)+a+b);
        out.printf("%.4f\n",h);
        out.flush();
    }
  
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}

Measured memory_bytes: 24632
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] col = {399,799,1199,1599,1999,2399,2799,3199};
		int[] colFlag = {0,0,0,0,0,0,0,0};
		int defCol = 0;
		int freeCol = 0;
		for(int i=0;i<N;i++){
			int temp = sc.nextInt();
			if(3200<=temp){
				freeCol++;
			}else{
				for(int j=0;j<col.length;j++){
					if(temp<=col[j]){
						if(colFlag[j]==0){
							defCol++;
							colFlag[j] = 1;
						}
						break;
					}
				}
			}
		}
		System.out.println((defCol!=0?defCol:1)+" "+(defCol+freeCol));
	}
}


Measured memory_bytes: 21588
H, N = map(int, input().split())
M = [tuple(map(int, input().split())) for _ in range(N)]

dp = [float('inf') for _ in range(H + 1)]

dp[0] = 0

for a, b in M:
    for i in range(H+1):
        d = min(H, i + a)
        dp[d] = min(dp[d], dp[i] + b)

print(dp[H])

Measured memory_bytes: 53084
#include<stdio.h>
int main()
{ int a,b;
    scanf("%d%d",&a,&b);
    if(a>b){
        printf("a > b\n");}
    else if(a<b){
        printf("a < b\n");}
    else{
        printf("a == b\n");}
    
    return 0; 
}



Measured memory_bytes: 2112
#include<iostream>
#include<queue>

using namespace std;

#define REP(i,a,e) for(int i = (a); i < (e); ++i)
#define MAX 101
#define INFTY 1000
#define NIL (-1)

bool visited[MAX];
int cost[MAX];
int G[MAX][MAX];
int W[MAX][MAX];

int MSTPrim(int nodes, int st){
	int ret = 0;

	for(int i = 0; i < nodes; ++i){
		visited[i] = false;
		cost[i] = INFTY;
	}

	cost[0] = 0;

	while( true ){
		int mincost = INFTY;
		int nmin = 0;

		/* EXTRACT-MIN() */
		for(int i = 0; i < nodes; ++i){
			if( !visited[i] && mincost > cost[i] ){
				mincost = cost[i];
				nmin = i;
			}
		}

		/* cannot extract */
		if( mincost == INFTY )
			break;

		visited[nmin] = true;

		for(int i = 0; i < nodes; ++i){
			/* not-connected */
			if( visited[i] || W[nmin][i] == INFTY )
				continue;

			if( W[nmin][i] < cost[i] ){
				cost[i] = W[nmin][i];
			}
		}
	}
	for(int i = 0; i < nodes; ++i){
		ret += cost[i];
	}

	return ret;
}

void ResetGraph(){
	REP(i,0,MAX)REP(j,0,MAX){
		W[i][j] = INFTY;
	}
}

int main(){
	while(true){
		int s, d;

		ResetGraph();

		scanf("%d%d", &s, &d);
		if( s == 0 && d == 0 )
			break;

		REP(i,0,s){
			REP(j,0,d){
				int w;
				scanf("%d", &w);
				W[i][s+j] = W[s+j][i] = w == 0 ? INFTY : w;
			}
			REP(j,0,s){
				W[i][j] = W[j][i] = 0;
			}
		}

		REP(i,0,d-1){
			REP(j,1,d-i){
				int w;
				scanf("%d", &w);
				W[i+s][i+j+s] = W[i+j+s][i+s] = w == 0 ? INFTY : w;
			}
		}

		cout << MSTPrim( s+d, 0 ) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, v, lg;
typedef std::pair<int, int> pr;
int g0[1 << 19], g1[1 << 19];
int x[maxn], ans[maxn];
std::vector<pr> vec[233];
inline void init(std::vector<pr> & v,int d) {
	int l = 1;
	for(int i = 2;i <= n;++i) if(x[i] - x[i - 1] > d)
		v.emplace_back(l, i - 1), l = i;
	v.emplace_back(l, n);
}
inline void up(int & x,int y) { if(x < y) x = y; }
inline void down(int & x,int y) { if(x > y) x = y; }
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> v;
	rep(i, 1, n) cin >> x[i];
	for(;v >> lg;++lg) if(v >> lg) init(vec[lg], v >> lg);
	init(vec[lg++], 0);
	if(vec[0].size() < 20) {
		std::fill(g1, g1 + (1 << lg), n + 1);
		rep(i, 0, (1 << lg) - 1) {
			rep(j, 1, lg - 1) if((i >> j & 1) == 0){
				int l = 0, r = vec[j].size();
				for(;l + 1 != r;) (vec[j][l + r >> 1].first <= g0[i] + 1 ? l : r) = l + r >> 1;
				up(g0[i | 1 << j], vec[j][l].second), l = -1, r = vec[j].size() - 1;
				for(;l + 1 != r;) (vec[j][l + r >> 1].second >= g1[i] - 1 ? r : l) = l + r >> 1;
				down(g1[i | 1 << j], vec[j][r].first);
			}
		}
		for(pr i : *vec) {
			for(int j = 0;j < 1 << lg;j += 2) {
				if(g0[j] >= i.first - 1 && i.second + 1 >= g1[~j & (1 << lg) - 1 & -2]){
					std::fill(ans + i.first, ans + i.second + 1, 1);
					break;
				}
			}
		}
	}
	rep(i, 1, n) {
		cout << (ans[i] ? "Possible" : "Impossible") << '\n';
	}
}


Measured memory_bytes: 10352
N=int(input())
T=[[] for _ in range(N)]
for i in range(N):
  n=int(input())
  for j in range(n):
    T[i].append(tuple(map(int,input().split())))
ans=0
for i in range(2**N):
  true,t,f=set(),set(),set()
  for j in range(N):
    if i>>j&1:
      true.add(j+1)
      for a,b in T[j]:
        if b:
          t.add(a)
        else:
          f.add(a)
  if t<=true and not(f&true):
    ans=max(ans,len(true))
print(ans)

Measured memory_bytes: 9040
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
using namespace std;

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

int n;
bool vis[100005];

struct P{
	LL a, b, c;
}s[100005], t[100005];

bool cmp1(P u, P v){
	if(u.a - v.b == v.a - u.b) return u.a > v.a;
	return u.a - v.b > v.a - u.b;
}

bool cmp2(P u, P v){
	if(u.b - v.a == v.b - u.a) return u.b > v.b;
	return u.b - v.a > v.b - u.a;
}


int main(){
	scanf(" %d", &n);
	for(int i = 1; i <= n; i ++){
		scanf(" %lld %lld", &s[i].a, &s[i].b);
		s[i].c = i;
		t[i] = s[i];
	}
	sort(s + 1, s + n + 1, cmp1);
	sort(t + 1, t + n + 1, cmp2);
	int pos1 = 1, pos2 = 1, cnt = 1;
	LL suma = 0, sumb = 0;
	while(cnt <= n){
		if(cnt % 2 == 1){
			while(vis[s[pos1].c]) pos1 ++;
			suma += s[pos1].a;
			vis[s[pos1].c] = 1;
		}
		else{
			while(vis[t[pos2].c]) pos2 ++;
			sumb += t[pos2].b;
			vis[t[pos2].c] = 1;
		}
		cnt ++;
	}
	printf("%lld\n", suma - sumb);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define repd(i,a,b) for (int i=a;i<int(b);i++)
#define rep(i,n) repd(i,0,n)
#define VARNAME(v) #v
using P = pair<int,int>;


int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  constexpr int BEAM = 510;
  int d;vector<int> c(26);cin>>d;rep(i,26)cin>>c[i];
  vector<array<int, 26>> s(d);
  rep(i,d)rep(j,26)cin>>s[i][j];
  vector<int> curs = {0};
  vector<array<int, 26>> curl(1);
  vector<vector<int>> cura(1);
  rep(i,d){
    int len = int(curs.size()) * 26, ind = 0;
    vector<P> nxs(len);
    vector<array<int, 26>> nxl(len);
    vector<vector<int>> nxa(len);
    rep(j, curs.size()){
      rep(t, 26){
        int score = curs[j];
        array<int, 26> last = curl[j];
        vector<int> ans = cura[j];
        score += s[i][t];
        last[t] = i+1;
        rep(k,26)score -= c[k]*(i+1 - last[k]);
        ans.emplace_back(t);
        nxs[ind] = P(score, ind);
        nxl[ind] = last;
        nxa[ind] = ans;
        ind++;
      }
    }
    sort(nxs.rbegin(), nxs.rend());
    len = min(len, BEAM);
    curs.resize(len);curl.resize(len);cura.resize(len);
    rep(j,len){
      curs[j] = nxs[j].first;
      curl[j] = nxl[nxs[j].second];
      cura[j] = nxa[nxs[j].second];
    }
  }
  int ans = 0;
  rep(i,min(int(curs.size()), BEAM)){
    if(curs[ans] < curs[i])ans = i;
  }

  for(auto x : cura[ans]){
    cout << x+1 << endl;
  }
}


Measured memory_bytes: 25396
//author: Harsh :)
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 100007
using namespace std;
string s="";
string solve(ll n){
  while(n){
    --n;
    s+=('a'+ n%26);
    n/=26;
  }
  reverse(s.begin(),s.end());
  return s;
}
int main(){
  fastio;
  ll n=0;
  cin>>n;
  cout<<solve(n);
  return 0;

}


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

int main() {
  string s;
  char ans='A';
  while(cin >> s) {
    if(s[0]==ans) ans=s[2];
    else if(s[2]==ans) ans=s[0];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1172
import java.util.Scanner;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
        //コード
      Scanner sc = new Scanner(System.in);
	  String n = sc.next();
      switch (n) {
        case "SUN":
            System.out.println(7-0);
            break;
        case "MON":
            System.out.println(7-1);
            break;
        case "TUE":
            System.out.println(7-2);
            break;
        case "WED":
            System.out.println(7-3);
            break;
        case "THU":
            System.out.println(7-4);
            break;
        case "FRI":
            System.out.println(7-5);
            break;
        case "SAT":
            System.out.println(7-6);
            break;
      }
    }
}

Measured memory_bytes: 21844
def solve(n)
    x=-1
    ans=0
    while true
        x+=1
        s=x.to_s(4).gsub("3","7").gsub("2","5").gsub("1","3")
        next if s.include?("0")
        if n<s.to_i
            break
        end
        if s.include?("3") && s.include?("5") && s.include?("7")
            ans+=1
        end
    end
    return ans
end

puts solve(gets.to_i)

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

int main() {

    double a, b, h, m; cin >> a >> b >> h >> m;

    double  theta1 = (double)(2 * M_PI * (double)(h  + m / 60 ) / 12 );
    double  theta2 = (double)(2 * M_PI * (double)(m / 60));

    double ans = 0;
    ans += (a * cos(theta1) - b * cos(theta2)) * (a * cos(theta1) - b * cos(theta2));
    ans += (a * sin(theta1) - b * sin(theta2)) * (a * sin(theta1) - b * sin(theta2));
    ans = sqrt(ans);
    cout << fixed << setprecision(11) << ans << endl;

    return 0;
}

Measured memory_bytes: 4092
#include <iostream>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 200001;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    ll an = (1ll * n * m)-(n * 2ll)-((m-2)*2ll);
    if(m == 1)an = n-2;
    if(n == 1)an = m-2;
    if(m == 1 && n == 1)an = 1;
    printf("%lld\n", an);
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	int a[3];
	rep(i,3)cin>>a[i];
	sort(a,a+3);
	int sum = (a[2]-a[0]) + (a[2]-a[1]);
	int ret = sum/2;
	if(sum % 2 == 1)ret += 2;
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 256
function Main(input) {
	var tmp = input.split(" ");
	var ingredients = parseInt((3 * tmp[0])) + parseInt(tmp[1]);
	var pie = Math.floor(ingredients / 2);
  //出力
	console.log('%d',pie);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
d=[0]*9
N=int(input())
a=list(map(int,input().split()))
for i in a:
  if 1<=i<=399 and d[0]==0:
    d[0]=1
  elif 400<=i<=799 and d[1]==0:
    d[1]=1
  elif 800<=i<=1199 and d[2]==0:
    d[2]=1
  elif 1200<=i<=1599 and d[3]==0:
    d[3]=1
  elif 1600<=i<=1999 and d[4]==0:
    d[4]=1
  elif 2000<=i<=2399 and d[5]==0:
    d[5]=1
  elif 2400<=i<=2799 and d[6]==0:
    d[6]=1
  elif 2800<=i<=3199 and d[7]==0:
    d[7]=1
  elif i>=3200:
    d[8]+=1
print(max(sum(d[:8]),1),sum(d[:8])+d[8])

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

void solve(int n,int k,int s,int sum){
  if(sum==s&&k==0){
    cnt++;
    return;
  }
  if(k==0) return; 
  for(int i=n;i>=k;--i){
    solve(i-1,k-1,s,sum+i);
  }
  return ;
}

int main(){
  int n,k,s;
  while(cin>>n>>k>>s&&n){
    int sum=0;
    cnt=0;
    solve(n,k,s,sum);
    cout<<cnt<<endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1156
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const X = parseInt(arg[0].split(" ")[1]);
    
    const A = arg[1].split(" ").map(n=>parseInt(n));
    let cnt = 0;
    
    for(let i=0; i<N-1; i++) {
        let sum = A[i] + A[i + 1];

        if(sum > X) {
            // let temp;
            // if(A[i+1] > A[i]) {
            //     temp = A[i+1]  - X;
            //     A[i+1] -= temp;
            // } else {
            //     temp = A[i] - X;
            //     A[i] -= temp;
            // }
            
            // A[i+1]--;
            
            A[i+1] = Math.max(0, A[i+1] - (sum - X));
            
            cnt += sum - X;
        }
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29696