akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

typedef int		BOOL;
#define TRUE	1;
#define FALSE	0;

typedef struct Word{
	char	word[31];
	int		page;
}	WORD;

WORD wordArray[100];

void input();
	BOOL is_smaller(WORD, int);
void output();

int main()
{
    input();
    output();
	
	return 0;
}

void input()
{
	int 	cnt1, cnt2;
	WORD	tempWORD;
	
	while(scanf("%s %d", tempWORD.word, &tempWORD.page) != EOF)
		for(cnt1 = 0; cnt1 < 100; cnt1++){
			if(wordArray[cnt1].page == 0){
				strcpy(wordArray[cnt1].word, tempWORD.word);
				wordArray[cnt1].page = tempWORD.page;
				break;
			}
			else if(is_smaller(tempWORD, cnt1)){
				for(cnt2 = 98; cnt2 >= cnt1; cnt2--){
					strcpy(wordArray[cnt2 + 1].word, wordArray[cnt2].word);
					wordArray[cnt2 + 1].page = wordArray[cnt2].page;
				}
				strcpy(wordArray[cnt1].word, tempWORD.word);
				wordArray[cnt1].page = tempWORD.page;
				break;
			}
		}
}

BOOL is_smaller(WORD tempWORD, int cnt)
{
	if(strcmp(tempWORD.word, wordArray[cnt].word) < 0)
	{
		return TRUE;
	}
	else if(strcmp(tempWORD.word, wordArray[cnt].word) == 0)
	{
		if(tempWORD.page < wordArray[cnt].page)
		{
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
	else
	{
		return FALSE;
	}
}

void output()
{
	int		output_cnt = 0;
	char	last_print_word[31] = "";

	while(wordArray[output_cnt].page != 0)
	{
		if(strcmp(last_print_word, "") == 0)
		{
			printf("%s\n", wordArray[output_cnt].word);
			strcpy(last_print_word, wordArray[output_cnt].word);
		}
		else if(strcmp(wordArray[output_cnt].word, last_print_word) != 0)
		{
			printf("\n%s\n", wordArray[output_cnt].word);
			strcpy(last_print_word, wordArray[output_cnt].word);
		}
		else
		{
			printf(" ");
		}
		printf("%d", wordArray[output_cnt].page);
		output_cnt++;
	}
	printf("\n");
}

Measured memory_bytes: 640
n=int(input())
ans = {}
printed = 0
for i in range(n):
  a = int(input())
  if not a in ans:
    ans[a] = 1
    printed += 1
  else:
    ans[a] += 1
    if ans[a] % 2 == 0:
      printed -= 1
    else:
      printed += 1
print(printed)

Measured memory_bytes: 82504
import Control.Applicative
import qualified Data.HashMap.Strict as Map

main = do
  [_,capa] <- map (read :: String -> Int) . words <$> getLine
  goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
  print $ maximum $ map snd $ Map.toList (resolve capa (Map.fromList (zip [0..capa] [0,0..])) goods)

resolve capa capaMap ([v,w]:xs)
  | xs == []  = koushin'
  | otherwise = resolve capa koushin' xs
  where
    koushin' =  koushin capaMap [v,w] (capa-w)
    koushin capaMap [v,w] n
      | n == 0 && capaMap Map.! w <= v        = Map.insert w v capaMap
      | n == 0                                = capaMap
      | oldValue == 0                         = next
      | capaMap Map.! (n+w) >= v + oldValue   = next
      | otherwise = koushin (Map.insert (n+w) (v + oldValue) capaMap) [v,w] (n-1)
      where
        oldValue = capaMap Map.! n
        next     = koushin capaMap [v,w] (n-1)

Measured memory_bytes: 8060
#include<stdio.h>
int main(void)
{
	int a = 0;
	int b = 0;
	int c;
	int d;

	scanf("%d %d", &a,&b);

	c = a * b;
	d = (a + b) * 2;

	printf("%d %d\n",c,d);

	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#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;}

int main() {
    double t, x;
    cin >> t >> x;
    cout << t/x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i=1; ;i++){
            int h = sc.nextInt();
            int w = sc.nextInt();
            int pin =  1;

            if(h==0&&w==0) break;

            for(int n = 0; n < h ; n++){
                for(int m = 0; m < w; m++){
                    if (pin%2 == 1)System.out.print("#");
                    if (pin%2 == 0)System.out.print(".");
                    pin ++;
                    if(m == w-1)System.out.println();
                }
                if(w%2==0) pin ++;
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 37284
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

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

int main(){
  int N;
  cin >> N;
  ll ans;
  cin >> ans;

  rep(i, N - 1){
    ll t;
    cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 998244353
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
#define int ll


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

string s;
int k;

int dp[305][305][305];
int pre[305][305][305];
int pre1[305][305][305];
vector<int> v;

// int solve(int index, int out, int total) {
// 	if(out<0 || out>3) return 0;

// 	if(index==v.size()) {
// 		if(out==0) return 1;
// 		else return 0;
// 	}

// 	if(dp[index][out]!=-1) return dp[index][out];
// 	int ans = 0;

// 	// Consumer
// 	for(int i=0;i<=300;i++) {
// 		ans += solve(index+1,out+i, total);
// 		ans %= MOD;
// 	}

// 	// Producer
// 	for(int i=1;i<=v[index];i++) {
// 		ans += solve(index+1,out-i, total+i);
// 		ans %= MOD;
// 	}

// 	cout<<index<<" "<<out<<" -- "<<ans<<endl;
// 	return dp[index][out] = ans;
// }

signed main() {
	fast;

	cin>>s;
	cin>>k;

	int cur = 0;
	int n = s.size();
	k = min(k, n);

	for(int i=0;i<n;i++) {
		if(s[i]=='0') {v.pb(cur);cur=0;}
		else cur++;
	}
	v.pb(cur);

	for(int i=0;i<=300;i++) pre[v.size()][0][i] = 1, pre1[v.size()][0][0] = 1;

	int ff = 0;

	for(int i=(int)v.size()-1;i>=0;i--) {
		for(int tot=k;tot>=0;tot--) {

			for(int out=0;out<=300;out++) {
				int ans = 0;

				int sum = pre[i+1][tot][300] - ((out==0)?0:pre[i+1][tot][out-1]);
				// if(i==2 && tot==0 && out==0) cout<<"$$"<<sum<<endl;

				ans += sum;
				ans %= MOD;

				if(tot>=out) sum = ((out-(v[i]) < 0) ? pre1[i+1][tot-out][0]: pre1[i+1][tot-v[i]][out-v[i]]) - pre1[i+1][tot][out];
				else sum = ((tot-(v[i]) < 0) ? pre1[i+1][0][out-tot]: pre1[i+1][tot-v[i]][out-v[i]]) - pre1[i+1][tot][out];
				// if(i==2 && tot==0 && out==0) cout<<"$$"<<sum<<" "<<v[i]<<endl;

				ans += sum;
				ans %= MOD;

				if(out!=0) {
					pre[i][tot][out] = (ans + pre[i][tot][out-1])%MOD;
				}
				else {
					pre[i][tot][out] = ans;
				}

				if(out!=300) {
					pre1[i][tot][out] = (ans + pre1[i][tot+1][out+1])%MOD;
				}
				else {
					pre1[i][tot][out] = ans;
				}

				// cout<<"#"<<i<<" "<<tot<<" "<<out<<" -- "<<ans<<endl;

				if(i==0&&tot<=k&&out==0) ff += ans;
				ff %= MOD;
			}
		}
	}

	ff += MOD;
	ff %= MOD;
	cout<<ff;

}

Measured memory_bytes: 220612
import sys

n, a, b = map(int, input().split())
ans = 0
allcnt = 0
if a > n:
    print(n)
    sys.exit()
elif a+b >= n:
    print(a)
    sys.exit()
else:
    allcnt = n//(a+b)
    amari = n%(a+b)
    if amari > a:
        amari = a 
    print(allcnt*a+amari)
    

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int H, W, K;
ll dp[110][20];

int main()
{
    cin >> H >> W >> K;
    dp[0][0] = 1;
    for (int i = 0; i <= H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            for (int bit = 0; bit < (1 << (W - 1)); bit++)
            {
                bool ok = true;
                for (int k = 0; k < W - 2; k++)
                {
                    if ((bit & (1 << k)) && (bit & (1 << (k + 1))))
                    {
                        ok = false;
                    }
                }
                if (ok)
                {
                    int nj = j;
                    if (bit & (1 << j))
                    {
                        nj = j + 1;
                    }
                    else if (j > 0 && bit & (1 << (j - 1)))
                    {
                        nj = j - 1;
                    }
                    dp[i + 1][nj] += dp[i][j];
                    dp[i + 1][nj] %= MOD;
                }
            }
        }
    }
    cout << dp[H][K - 1] << endl;
}


Measured memory_bytes: 256
function Main(input) {
  var array = input.trim().split("\n");
  array = array.map(val => parseInt(val, 10));
  var waitTimeAry = [];
  var amount = 0;
  var ceilArray = [];

  for (var i = 0; i < array.length; i++) {
    var ceil = Math.ceil(array[i] / 10) * 10;
    waitTimeAry.push(ceil - array[i]);
    ceilArray.push(ceil);
  }

  var maxWait = Math.max(...waitTimeAry);
  var index = waitTimeAry.indexOf(maxWait);
  ceilArray.splice(index, 1);
  ceilArray.splice(ceilArray.length, 0, array[index]);
  for (var j = 0; j < ceilArray.length; j++) {
    amount += ceilArray[j];
  }
  console.log(amount);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;
map <string,int> cost;
multimap <string,string>  rule;
set <string> his;
int mk_rule(string a,int mae){
  if(his.count(a) == 0||cost[a]>mae){
    his.insert(a);    
    multimap<string,string>::iterator it=rule.find(a);
    while(it != rule.end() && it->first == a) cost[a]= min(cost[a],mk_rule(it->second,cost[a])),it++;
    it=rule.find(a);
    while(it != rule.end() && it->first == a) cost[a]= min(cost[a],mk_rule(it->second,cost[a])),it++;
  }
  return cost[a];
}
int main(){
  int n,m,b;
  cin >> n;
  string a,c,ls[5002];
  for(int i=0;i<n;i++) cin >> ls[i] >> b, cost[ls[i]] = b;

  cin >> m;
  for(int i=0;i<m;i++){
    cin >> a >> c;
    rule.insert(pair<string,string>(a,c));
    rule.insert(pair<string,string>(c,a));
  }
  int ans=0;
  for(int i=0;i<n;i++) ans += mk_rule(ls[i],cost[ls[i]]);
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 2244
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


vector<int> c;
vector<vector<int>> s;
vector<int> last_d(27, 0);

int calc_score(vector<int> &schedule) {
	int score = 0;
	for (int i = 1; i < schedule.size(); i++) {
		score += s[i][schedule[i]];
		last_d[schedule[i]] = i;
		for (int j = 1; j < 27; j++) {
			score -= c[j] * (i - last_d[j]);
		}
		cout << score << endl;
	}
	return score;
}

int cal_totdays_score_change(const int &type, const int &date) {
	int score = 0;
	score += s[date][type];
	for (int j = 1; j < 27; j++) {
		if (j == type) continue;
		score -= c[j] * (date - last_d[j]);
	}
	return score;
}


int main() {

	int D;
	cin >> D;

	c.resize(27);
	for (int i = 0; i < 26; i++) {
		cin >> c[i+1];
	}

	s.resize(D+1);
	for (int i = 0; i < D; i++) {
		s[i + 1].resize(27);
	}

	for (int i = 0; i < D; i++) {
		for (int j = 1; j < 27; j++) {
			cin >> s[i+1][j];
		}
	}

	vector<int> schedule(D+1);
	for (int i = 0; i < D; i++) {
		cin >> schedule[i+1];
	}

	int total_score = 0;
	for (int i = 0; i < D; i++) {
		total_score += cal_totdays_score_change(schedule[i + 1], i + 1);
		last_d[schedule[i + 1]] = i + 1;
		cout << total_score << endl;
	}


	return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n , x[105] , dek=0 , ans , m;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
    dek=max(x[i] , dek);
  }

  for(int i=1;i<=dek;i++){
    m = 0;
    for(int j=0;j<n;j++){
      m+=(x[j]-i)*(x[j]-i);
    }
    if(i == 1){
      ans = m;
    } else {
      ans = min(ans,m);
    }
  }
  cout<<ans<<endl;
  
  return(0);
}
  

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
ll d[210][210];
 
int main(){
	ll n;
	cin>>n;
	clr(d,-1);
	rep(i,0,40){
		string s;
		rep(j,0,200){
			s += "0";
		}
		rep(j,0,5){
			s[i+j*40] = '1';
		}
		cout << "?" << " " << s << endl;
		ll ans1;
		cin>>ans1;
		if(ans1==0){
			rep(j,0,5){
				rep(k,j+1,5){
					d[i+j*40][i+k*40] = 0;
				}
			}
		}
	}
	rep(i,0,n){
		rep(j,i+1,n){
			if(d[i][j]!=-1)continue;
			string s1;
			rep(l,0,n){
				if(l==i||l==j)s1+="1";
				else s1+="0";
			}
			cout << "?" << " " << s1 << endl;
			ll ans1;
			cin>>ans1;
			if(ans1==1){
				d[i][j] = 1;
			}
			else{
				d[i][j] = 0;
			}
		}
	}
	cout << "! ";
	vector<pair<ll,ll> > v;
	rep(i,0,200){
		rep(j,i+1,200){
			if(d[i][j] == 1){
				v.pb(mp(i,j));
			}
		}
	}
	rep(i,0,v.sz){
		cout << "(" << v[i].fi << "," << v[i].se << ")";
		if(i!=v.sz-1)cout << " ";
	}
	cout << endl;
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n + 1);
  map<int, int> p;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    p[i]++;
  }

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (h[a] < h[b])
      p.erase(a);
    else if (h[a] > h[b])
      p.erase(b);
    else if (h[a] == h[b]) {
      p.erase(a);
      p.erase(b);
    }
  }

  cout << p.size() << endl;
}

Measured memory_bytes: 8300
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        for(int i=1; i<=1000; i++){
            if((int)(i*0.08)==A && (int)(i*0.1)==B){
                System.out.println(i);
                break;
            }
            if(i==1000){
                System.out.println(-1);
            }
        }
    }
}

Measured memory_bytes: 23764
#include<stdio.h>

int main(){
  int i, j, k, v, N;
  int A[100];

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

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

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



Measured memory_bytes: 2128
package main

import (
	"fmt"
	"sort"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	ms := make(map[byte][]int, 26)
	ts := make(map[byte][]int, 26)
	for i := 0; i < len(s); i++ {
		ms[s[i]] = append(ms[s[i]], i)
		ts[t[i]] = append(ts[t[i]], i)
	}
	if len(ms) != len(ts) {
		fmt.Println("No")
		return
	}
	//要素の多い順にソート、要素数にずれがあったとき、NG。要素１までOKならOK
	//ソートで構造体必要なら最初から構造体で良かったかも、、
	a := SortBy{}
	for k, v := range ms {
		e := rn{k, v}
		a = append(a, e)
	}
	b := SortBy{}
	for k, v := range ts {
		e := rn{k, v}
		b = append(b, e)
	}

	sort.Sort(a)
	sort.Sort(b)
	for i := 0; i < len(a); i++ {
		if len(a[i].vlist) == len(b[i].vlist) {
			continue
		} else {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

type rn struct {
	key   byte
	vlist []int
}

type SortBy []rn

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return len(a[i].vlist) > len(a[j].vlist) }

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int N=1;
    int c[n],a[n][m];
    for(int i=0;i<n;i++){
        N*=2;
        cin>>c[i];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int mi=10000000;
    for(int i=0;i<N;i++){
        bool b=true;
        int I=i,cost=0;
        int exp[m]={};
        for(int j=0;j<n;j++){
            if(I%2){
                cost+=c[j];
                for(int k=0;k<m;k++){
                    exp[k]+=a[j][k];
                }
            }
            I/=2;
        }
        for(int j=0;j<m;j++){
            if(exp[j]<x)b=false;
        }
        if(b)mi=min(mi,cost);
    }
    if(mi==10000000)cout<<"-1"<<endl;
    else cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 3648
def resolve():
    N, A, B = map(int, input().split())
    ca = cb = 0
    for s in input():
        if s == "c":
            print("No")
        elif s == "a" and ca < A + B:
            print("Yes")
            ca += 1
        elif s == "b" and ca < A + B and cb < B:
            print("Yes")
            ca += 1
            cb += 1
        else:
            print("No")


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 49880
N = int(input())
A = list(map(int, input().split()))
# ex. 24 11 8 3 16
A.sort()
# ex. 3 8 11 16 24
cnt = 0
# Aの最大値が24なら25個用意する感じ
# indexと考える値を一致させて分かりやすくしている
# Trueで初期化
# 最後のインデックスはA[-1]
dp = [True] * (A[-1] + 1)

# エラトステネスの篩っぽいやつ
for i in range(N):
    if dp[A[i]] == True:
        # dp[A[i]], dp[2*A[i]], dp[3*A[i]],...をFalseにする
        for j in range(A[i], A[-1] + 1, A[i]):
            dp[j] = False

        if i < N - 1:
            # 次も同じ数字が存在するなら数えない、なぜならお互いに割れてしまって題意を満たさないから
            # 次以降に出てくる同じ数字は既にFalseになっているのでもう走査する事はない
            if A[i] != A[i + 1]:
                cnt += 1
        # i=N-1の時は次がないので無条件でcntを増やす
        # elseの方が良さそうだが明示的にするためにelifを使った
        elif i == N - 1:
            cnt += 1

print(cnt)


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

int main(){
	int n;
	cin >> n;
	int a[100];
	for (int i=0;i<n;i++){
		cin >> a[i];
	}
	
	for (int i=0; i<n ; i++){
		if (i!=0){cout << " ";}
		cout << a[n-i-1];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        if (N == M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define fast       ios_base::sync_with_stdio(false); cin.tie(NULL);
 
int main() {
    fast
    ll n; cin>>n; ll a[n-1]; 
    ll b[n];
    for(ll i=0;i<n;i++){
        b[i]=0;
    }
    for(ll i=0;i<n-1;i++){
        cin>>a[i];
        b[a[i]-1]++;
    }
    for(ll i=0;i<n;i++){
        cout<<b[i]<<endl;
    }
    
    
}

Measured memory_bytes: 6736
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=100000;
int n;
int a[MAXN+10];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	int res=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]==i)
		{
			++res;
			if(a[i+1]==i+1)swap(a[i],a[i+1]);
		}
	}
	printf("%d",res);
	return 0;
}


Measured memory_bytes: 640
N = int(input())
K = int(input())

cmb = [[0]*(101) for _ in range(101)]
cmb[0][0] = 1
for i in range(1, 101):
    for j in range(i+1):
        if j == 0:
            cmb[i][j] = 1
            continue
        cmb[i][j] = cmb[i-1][j-1]+cmb[i-1][j]

S = str(N)
ans = 0
if K == len(S):
    for i in range(K):
        ans += (int(S[i])-1)*9**(K-i-1)
    ans += 1
else:
    for i in range(K, len(S)):
        ans += 9*cmb[i-1][K-1]*9**(K-1)
    if K == 1:
        ans += int(S[0])
    if K == 2:
        ans += (int(S[0])-1)*(len(S)-1)*9
        i = 1
        while i < len(S) and S[i] == "0":
            i += 1
        if i < len(S):
            ans += (len(S)-1-i)*9
            ans += int(S[i])
    if K == 3:
        ans += (int(S[0])-1)*cmb[len(S)-1][K-1]*9**(K-1)
        i = 1
        while i < len(S)-1 and S[i] == "0":
            i += 1
        flag = True
        if i < len(S)-1:
            ans += cmb[len(S)-i-1][2]*9**2
            ans += (int(S[i])-1)*(len(S)-i-1)*9
        else:
            flag = False
        i += 1
        while i < len(S) and S[i] == "0":
            i += 1
        if i < len(S) and flag:
            ans += (len(S)-i-1)*9
            ans += int(S[i])
print(ans)

Measured memory_bytes: 3192
a,b,m=map(int,input().split())
a_prices=[int(i) for i in input().split()]
b_prices=[int(i) for i in input().split()]
a_min=min(a_prices)
b_min=min(b_prices)
a_add_b=a_min+b_min
for i in range(m):
    x,y,c=map(int,input().split())
    if a_prices[x-1]+b_prices[y-1]-c<a_add_b:
        a_add_b=a_prices[x-1]+b_prices[y-1]-c
print(a_add_b)

Measured memory_bytes: 69868
function Main(input) {
	var a = Number(input);
	var b = Math.ceil(a/1.08);
	if(Math.floor(b*1.08) == a){
		console.log(b);
	}else{
      	console.log(':(');
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
queue<int> q[1000];
int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N - 1; j++) {
            int tmp;
            cin >> tmp;
            tmp--;
            q[i].push(tmp);
        }
    }
    int n_emp = 0, ans = 0;
    set<int> target;
    set<int> used;
    for(int i = 0; i < N; i++) {
        target.insert(i);
    }
    for(ans = 0; n_emp < N; ans++) {
        for(auto i : target) {
            if(used.count(i) || q[i].empty()) continue;
            int j = q[i].front();
            if(used.count(j) || q[j].empty()) continue;
            // 動く
            if(q[j].front() == i) {
                used.insert(i);
                used.insert(j);
                q[i].pop(); q[j].pop();
                if(q[i].empty()) n_emp++;
                if(q[j].empty()) n_emp++;
            }
        }
        if (n_emp < N && used.empty()) {
            cout << -1 << endl;
            return 0;
        }
        target = used;
        used.clear();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#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 smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
 
const ll M=2e5+5,LG=19,SM=2000+5,inf=1e9+1;
ll mod=1e9+7;
 
ll n;
ll a[M]; 
str z[2]={"Yes","No"};
void ret(ll x)
{
    cout << z[x];
    exit(0);
}

bool n1,n2,e1,e2;

int main()
{
	ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    ll s=0,t=0;
    For(i,0,n)
    {
        ll x;
        cin >> x;
        if (x==0)
            s+=t/2,t=0;
        else
            t+=x; 
    }
    s+=t/2;
    cout << s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s,t;
    int c=0;
    cin>>s>>t;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i]){c++;}
    }
    cout<<c;
    return 0;

}


Measured memory_bytes: 3560
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 1

for i in range(1,n):
    cnt += 1
    if T[i] - f <= k and cnt <= c:
        continue
    else:
        f = T[i]
        ans += 1
        cnt = 1

print(ans)

Measured memory_bytes: 13328
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func main() {
	sc := NewScanner()
	S, T := sc.nextRuneSlice(), sc.nextRuneSlice()
	length := len(S)
	count := 0
	for count <= length {
		if string(S) == string(T) {
			fmt.Println("Yes")
			return
		}
		first := S[0]
		S = S[1:]
		S = append(S, first)
		count++
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main(){
	int A, B, C, X; cin >> A >> B >> C >> X;
	int cnt = 0;
	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			for (int c = 0; c <= C; c++) {
				if (500*a + 100*b + 50*c == X)cnt++;
			}
		
		}
	}
	print(cnt);





	return 0;
}

Measured memory_bytes: 256
r=".IVXLCDM",require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(i){i?(n=s=p=0,i.split('').map(function(c){n=Math.pow(10,~~((n=r.indexOf(c))/2))/(2-(n%2)),n>p?s-=p*2:0,s+=n,p=n}),console.log(s)):0})

Measured memory_bytes: 8696
#include<iostream>
using namespace std;
int main() {
    int a,b,s;
    cin>>a>>b;
    if(a>=b){
        s=a;
        for(int i=0;i<s;i++)
            cout<<b;
    } else{
        for(int i=0;i<b;i++)
            cout<<a;

    }

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        long num = 26;
        String ans = "";
        while (N > 0)
        {
            N = N - 1;
            long x = (long)(N % num);
            char temp = (char)('a'+x);
            ans = temp+ans;
            N = N/num;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27524
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let mut h = std::collections::BinaryHeap::new();
    for _ in 0..n {
        let a: u32 = it.next().unwrap().parse().unwrap();
        h.push(a);
    }
    for _ in 0..m {
        let v = h.pop().unwrap();
        h.push(v / 2);
    }
    let mut ans = 0u64;
    while let Some(v) = h.pop() {
        ans += v as u64;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, i;
	long long s=0LL, a[10], M=0, A=0, R=0, C=0, H=0;
	char L[100009][20];
	cin >> n;
	for (i=0; i<n; i++)
	{
		cin >> L[i];
	}
	for (i=0; i<n; i++)
	{
		//cin >> L;
		switch(L[i][0])
		{
			case'M': M++;
					 break;
			case'A': A++;
					 break;
			case'R': R++;
					 break;
			case'C': C++;
					 break;
			case'H': H++;
					 break;
			default: break;
		}
	}
	a[0] = M*A*R;
	a[1] = M*A*C;
	a[2] = M*A*H;
	a[3] = M*R*C;
	a[4] = M*R*H;
	a[5] = M*C*H;
	a[6] = A*R*C;
	a[7] = A*R*H;
	a[8] = A*C*H;
	a[9] = R*C*H;
	for(i=0; i<10; i++)
	{
		s+=a[i];
	}
	cout << s << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 2176
using System;

namespace TestSpace
{
    class Test
    {
        static void Main(string[] args)
        {
            int d, i;
            int[] arrInt = new int[10000];
            d = int.Parse(Console.ReadLine());
            for (i=1; d!= 0;i++)
            {
                Console.WriteLine("Case {0}: {1}", i, d);
                d = int.Parse(Console.ReadLine());
            }
        }
    }
}



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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 200005

int n , k;
int a[MAXX];

int main()
{
    _FastIO;

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

    int l = 0;
    int r = k;
    while(r < n){
        if(a[r] > a[l])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        l++;
        r++;
    }
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 3005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL dp[SIZE][SIZE][4];
LL item[SIZE][SIZE];

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

    int H, W, K;
    cin >> H >> W >> K;

    while(K--) {
        int r, c, v;
        cin >> r >> c >> v;
        item[r][c] = v;
    }

    for(int i = 1; i <= H; ++i) {
        for(int j = 1; j <= W; ++j) {
            if(i + 1 <= H) {
                for(int k = 0; k <= 3; ++k) {
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                }

                if(item[i][j] != 0) {
                    for(int k = 0; k <= 2; ++k) {
                        dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k] + item[i][j]);
                    }
                }
            }
            if(j + 1 <= W) {
                for(int k = 0; k <= 3; ++k){
                    dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                }

                if(item[i][j] != 0) {
                    for(int k = 0; k <= 2; ++k) {
                        dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + item[i][j]);
                    }
                }
            }
        }
    }

    LL res = 0;
    for(int i = 0; i <= 3; ++i) {
        res = max(res, dp[H][W][i]);
    }

    if(item[H][W] != 0) {
        for(int i = 0; i <= 2; ++i) {
            res = max(res, dp[H][W][i] + item[H][W]);
        }
    }
    cout << res << endl;
    return 0;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
    li now = 100;
    li x;
    cin >> x;
    rep(i, 10000) {
        now += now / 100;
        if (now >= x) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);    
#define f(i,j,k)  for(int i=j;i<k;i++)
#define fr(i,j,k) for(int i<=k-1;i>=j;i--)
#define ll long long
#define ld long double

using namespace std;

int main()
{
	fio
	int TC;
	TC=1;
	//cin>>TC;
	while(TC--)
	{
		ll n,m;
		cin>>n>>m;
		ll sum=0;
		std::vector<ll> v(n);
		for (int i = 0; i < n; ++i)
		{
			cin>>v[i];
			sum+=v[i];
		}
		
		int  cutoff  = ceil(((float)sum/(4.0*m)));

		int count = 0;
		for(int i=0;i<n;i++)
			if(v[i]>=cutoff)
				count++;
		if(count>=m)
			cout<<"Yes\n";
		else
			cout<<"No\n";
		
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  if(abs(b-a)<=d && abs(c-b)<=d || abs(c-a)<=d){
    cout<<"Yes";
  }else{ cout<<"No";
       }
  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $x, $y);
$x = (int)$x;
$y = (int)$y;

$a = [1,3,5,7,8,10,12];
$b = [4,6,9,11];
$c = [2];


if (in_array($x, $a)) {
    if (in_array($y, $a)) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
} else if (in_array($x, $b)) {
    if (in_array($y, $b)) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
} else {
    if (in_array($y, $c)) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
}

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

int main() {
  int n, a;
  cin >> n >> a;
  if (a >= 500) {
    cout << "Yes" << endl;
  }
  else {
    if (n%500 <= a) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int x,y;
    cin>>x>>y;
    if((y-2*x)%2!=0 || y-2*x<0){
        cout<<"No"<<endl;
    }  
    else if((4*x-y)%2!=0 || 4*x-y<0){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()){
        if(s.at(i) + n > 'Z') s.at(i) += (n - 'Z' + 'A' - 1);
        else s.at(i) += n;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
X=list(map(int,input().split()))

X.sort()
#print(X)
d = [X[i]-X[i-1] for i in range(1,M)]
d.sort()
#print(d)
#print(sum(d[:-(N-1)]) if M-N>0 else 0)
print(sum(d[0:(M-N)]) if (M-N)>0 else 0)

Measured memory_bytes: 13968
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <tuple>
#include <vector>

// lib/quo.hpp
#ifndef QUO_H
#define QUO_H

/*
a == tools:quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

namespace tools {
  template <typename T>
  constexpr T quo(const T lhs, const T rhs) {
    return lhs > 0 ? lhs / rhs : rhs > 0 ? -((-lhs - 1 + rhs) / rhs) : (-lhs - 1 + -rhs) / -rhs;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/extgcd.hpp
#ifndef EXTGCD_HPP
#define EXTGCD_HPP


/*
usage:

std::tuple<int, int, int> result = tools::extgcd(4, 5);
int gcd = std::get<0>(result);
int x0 = std::get<1>(result);
int y0 = std::get<2>(result);
*/

namespace tools {
  template <typename T>
  std::tuple<T, T, T> extgcd(T prev_r, T r) {
    T prev_s = 1;
    T prev_t = 0;
    T s = 0;
    T t = 1;
    while (r != 0) {
      const T q = quo(prev_r, r);
      const T next_r = prev_r - q * r;
      prev_r = r;
      r = next_r;
      const T next_s = prev_s - q * s;
      prev_s = s;
      s = next_s;
      const T next_t = prev_t - q * t;
      prev_t = t;
      t = next_t;
    }
    return std::make_tuple(prev_r, prev_s, prev_t);
  }
}

#endif

// main.cpp

int main() {
  i64 A, B, C, D;
  std::cin >> A >> B >> C >> D;

  const i64 lcm = C * D / std::get<0>(tools::extgcd(C, D));
  std::cout << (B - B / C - B / D + B / lcm) - ((A - 1) - (A - 1) / C - (A - 1) / D + (A - 1) / lcm) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    for(int i = 0; i < 1e8; i++){
        int t = i * 0.08;
        int x = i * 0.1;
        if(t == a && x == b){
            cout << i;
            return 0;
        }
    }
    cout << -1;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

main(){
  long long dp[31];
  for(int i=0;i<31;i++){
    dp[i]=0;
  }
  dp[0]=1;
  for(int i=0;i<31;i++){
    int t=i+1;
    if(t<31) dp[t]+=dp[i];
    t++;
    if(t<31) dp[t]+=dp[i];
    t++;
    if(t<31) dp[t]+=dp[i];
  }

  int n;
  while(1){
    cin >> n;
    if(n==0) break;

    if(dp[n]%3650==0){
      cout << dp[n]/3650 << endl;
    }else{
      cout << dp[n]/3650+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
<?php
$s = trim(fgets(STDIN));
$cnt = [];

for ($i=0; $i < 4; $i++) { 
	$tmp = $s[$i];
	if (isset($cnt[$tmp])) {
		$cnt[$tmp] += 1;
	}else{
		$cnt[$tmp] = 1;
	}
}
if (count($cnt) === 2) {
	$flg = true;
	foreach ($cnt as $v) {
		$flg = ($flg && $v === 2);
	}
	if ($flg) {
		echo 'Yes';
		exit();
	}
}
echo 'No';

Measured memory_bytes: 4728
import java.util.*
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val sc = Scanner(System.`in`)
    val N=sc.nextInt()
    val a=Array(N) {sc.nextInt()}
    var num=0

    for (j in 1..N)
    {
      val i=a[j-1]
      if (i>=j) continue
      num+=if(a[i-1]==j&&a[j-1]==i) 1 else 0
    }

    println(num)
  }
}


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}



int main() {
  int N,K;
  cin >> N >> K;
  int tmp=N*(N-1)/2;
  if (K>(N-1)*(N-2)/2) {
    cout << -1 << endl;
    return 0;
  }

  cout << tmp-K << endl;
  rep(i,N-1) {
    rep2(j,i+1,N) {
      // cout << "##" << tmp << endl;
      if (tmp>=K) {
        cout << i+1 << ' ' << j+1 << endl;
        tmp--;
      }
      if (tmp==K) return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N,ans = 0;
    cin >> N;
    vector< P > A(N),B(N);
    rep(i,N){
        int a,b;
        cin >> a >> b;
        A[i] = P(b,a);
        B[i] = P(a,b);
    }
    sort(A.begin(), A.end());
    sort(B.rbegin(), B.rend());
    vector<ll> X(N+1),Y(N+1);
    rep(i,N){
        X[i+1] = X[i] + (A[i].first * -2);
        Y[i+1] = Y[i] + (B[i].first * 2);
    }
    rep(i,N){
        for(int j = -1;j <= 1;j++){
            if(i + j + 1 < 0 || i + j + 1 >= N)continue;
            ll num = X[i+1] + Y[i + j + 1];
            ans = max(ans, num);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]
c = gets.chomp[-1]
drf = ["hon","pon","bon"]
drf.each do |arr_name|
  eval("if(#{arr_name}.include?(c.to_i))
         puts '#{arr_name}';exit;
        end")
end


Measured memory_bytes: 14364
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1369",problemID = "A",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    s,t = invr()
    print(t + s)
        
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("b3.in","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        #print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(str,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1],1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
  }
  
  // AとBを関連付ける
  vector<pair<int, int>> AB(N);
  for (int i = 0; i < N; ++i) {
    AB[i] = make_pair(A[i], B[i]);
  }
  
  // ソートする
  sort(AB.begin(), AB.end());
  
  // 順にとっていく
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    int buy = min(M, AB[i].second);		// 買う個数
    ans += (long long)buy * AB[i].first;
    M -= buy;
  }
  
  cout << ans << endl;
  
}
    

Measured memory_bytes: 1792
def solve():
    H,W,K=[int(x) for x in input().split()]
    cake=[]

    for h in range(H):
        output_string=""
        raw=[1 if x=="#" else 0 for x in input()]
        cake.append(raw)

    output_lst=[]
    num=0
    non_count=0
    for h,raw in enumerate(cake):
        if any(raw):
            if raw[0]==0:
                num+=1
                flag=True
            else:
                flag=False
            output_string=""
            for i,a in enumerate(raw):
                
                if a:
                    if flag:
                        flag=False
                    else:
                        num+=1
                
                output_string+=str(num)+" "
      
                    
            output_lst.append(output_string.strip())
            for i in range(non_count):
                output_lst.append(output_string.strip())
                non_count=0
                

        else:
            if len(output_lst):
                output_lst.append(output_lst[h-1])
            else:
                non_count+=1
            
    for out in output_lst:
        print(out)
            

solve()


Measured memory_bytes: 4852
N = int(input())
S = input()

W = [0 for k in range(N)]
E = [0 for k in range(N)]

for k in range(1,N):
    if S[k-1] == "W":
        W[k] = W[k-1] + 1
    else:
        W[k] = W[k-1]

for k in range(1,N):
    if S[N-k] == "E":
        E[N-k-1] = E[N-k] + 1
    else:
        E[N-k-1] = E[N-k]

ans = 10**9
for k in range(N):
    ans = min(W[k]+E[k],ans)

print(ans)


Measured memory_bytes: 17984