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

int *hanahuda, n, r, p, c;

void initHanahuda(){
	int i;
	hanahuda = (int *)malloc(sizeof(int) * n+1);
	for(i = 1; i <= n; i++){
		hanahuda[i] = n-i+1;
	}
}

void shuffle(int p, int c){
	int i;
	int *tmparray = (int *)malloc(sizeof(int) * c+1);
	//取り出した札をtmparrayに保管
	for(i = 1; i <= c; i++){
		tmparray[i] = hanahuda[p+i-1];
	}
	//上の札を下に下ろす
	for(i = 1; i <= p-1; i++){
		hanahuda[p-i+c] = hanahuda[p-i];
	}
	//一時的に保管した札を山の上に載せる
	for(i = 1; i <= c; i++){
		hanahuda[i] = tmparray[i];
	}
}

int main(void){
	while(1){
		scanf("%d%d", &n, &r);
		if(n==0 && r==0)	break;
		initHanahuda();
		int i;
		for(i = 0; i < r; i++){
			scanf("%d%d", &p, &c);
			shuffle(p, c);
		}
		printf("%d\n", hanahuda[1]);
		free(hanahuda);
	}

	return 0;
}

Measured memory_bytes: 800
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000

const int len[] = {5,7,5,7,7};

int main(){
    int n;

    while(cin>>n , n){
        vector<string> w(n);
        rep(i,n) cin>>w[i];

        int res;
        rep(i,n){
            int idx=0;
            int words=i;
            while(idx<5){
                int sz=0;
                while(sz < len[idx]){
                    sz += w[words++].size();
                }
                if(sz>len[idx]) break;
                idx++;
            }
            if(idx==5){res=i+1;break;}
        }

        cout<<res<<endl;

    }

    return 0;
}

Measured memory_bytes: 1216
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import           Debug.Trace

type Point = (Double, Double)

rotate60 :: Point -> Point
rotate60 (x, y) = (x', y')
  where
    x' = x * cos rad - y * sin rad
    y' = x * sin rad + y * cos rad
    rad = pi / 180 * 60

koch2 :: Point -> Point -> [Point]
koch2 (x1, y1) (x2, y2) =
    [ (x3, y3)
    , (x4, y4)
    , (x5, y5)
    ]
  where
    xu = (x2 - x1) / 3
    yu = (y2 - y1) / 3
    x3 = x1 + xu
    x5 = x1 + xu * 2
    y3 = y1 + yu
    y5 = y1 + yu * 2
    (x4, y4) =
        let (sx, sy) = rotate60 (x5 - x3, y5 - y3)
         in (sx + x3, sy + y3)

koch1 :: [Point] -> [Point]
koch1 []         = []
koch1 [p]        = [p]
koch1 (p1:p2:ps) = p1 : koch2 p1 p2 ++ koch1 (p2:ps)

koch :: Int -> [Point] -> [Point]
koch n ps = go 0 ps
  where
    go !k !qs
        | k == n    = qs
        | otherwise = go (k + 1) (koch1 qs)

printPoint :: Point -> IO ()
printPoint (x, y) = putStrLn $ show x ++ " " ++ show y

main :: IO ()
main = do
    n <- readLn
    let ps = koch n [(0, 0), (100, 0)]
    mapM_ printPoint ps



Measured memory_bytes: 4344
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

table = \
["* = ****",\
 "* =* ***",\
 "* =** **",\
 "* =*** *",\
 "* =**** ",\
 " *= ****",\
 " *=* ***",\
 " *=** **",\
 " *=*** *",\
 " *=**** "]

N = list(get_input())
for l in range(len(N)):

    if l > 0:
        print("")

    num = int(N[l])
    ans = []

    for i in range(5):
        ans.append(table[num // 10**(4-i)])
        num = num % 10**(4-i)

    for i in range(8):
        for j in range(5):
            print(ans[j][i], end="")
        print("")


Measured memory_bytes: 7044
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int N = input[0];
		int K = input[1];
		var mo = new Modulo(0);
		var mo1 = new Modulo(K - 1);
		var mo2 = new Modulo(N - K + 1);
        for(var i = 1; i <= K; i++)
		{
			long ans = mo.Mul(mo1.Ncr(K - 1, i - 1), mo2.Ncr(N - K + 1, i));
			
			Console.WriteLine(ans);
		}
	}
}
class Modulo
{
	private const int M = 1000000007;
	private readonly int[] m_facs;
	public int Mul(int a, int b)
	{
		return (int)(Math.BigMul(a, b) % M);
	}
	public Modulo(int n)
	{
		m_facs = new int[n + 1];
		m_facs[0] = 1;
		for (int i = 1; i <= n; ++i)
		{
			m_facs[i] = Mul(m_facs[i - 1], i);
		}
	}
	public int Fac(int n)
	{
		return m_facs[n];
	}
	public int Pow(int a, int m)
	{
		switch (m)
		{
			case 0:
				return 1;
			case 1:
				return a;
			default:
				int p1 = Pow(a, m / 2);
				int p2 = Mul(p1, p1);
				return ((m % 2) == 0) ? p2 : Mul(p2, a);
		}
	}
	public int Div(int a, int b)
	{
		return Mul(a, Pow(b, M - 2));
	}
	public int Ncr(int n, int r)
	{
		if (n < r) { return 0; }
		if (n == r) { return 1; }
		int res = Fac(n);
		res = Div(res, Fac(r));
		res = Div(res, Fac(n - r));
		return res;
	}
}



Measured memory_bytes: 13396
#include <algorithm>
#include <cstdio>

using namespace std ;

const int N=1e5+10 ;

int a[N] ;
int n , k ;

int main ()
{
	int i , g , mx=0 ;
	scanf("%d%d",&n,&k);
	for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i),mx=max(mx,a[i]);
	for ( g=a[1],i=2 ; i<=n ; i++ ) g=__gcd(g,a[i]);
	puts(k%g==0&&k<=mx?"POSSIBLE":"IMPOSSIBLE");
	return 0 ;
}
/*
在操作过程中，数字只会越来越小
*/

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
vector <bool> prim;
vector <int> vec;
vector <int>::iterator it;
vector <int>::iterator it1;
void prime()
{
    for(int i=0; i<100005; i++)
        prim.push_back(true);
    for(int i=2; i<100005; i++)
    {
        for(int j=2*i; j<100005; j+=i)
            prim[j]=false;
    }
    for(int i=3; i<100005; i+=2)
    {
        int x=(i+1)/2;
        if(prim[i] == true && prim[x] == true)
        {
            vec.push_back(i);
            //cout<<"not"<<endl;
        }

    }
}
int main()
{
    prime();
    //cout<<vec[0]<<endl;
    int q;
    int l,r;
    cin>>q;
    while(q--)
    {
        cin>>l>>r;
        it = lower_bound(vec.begin(),vec.end(),l);
        it1 = upper_bound(vec.begin(),vec.end(),r);
        int pos1=it-vec.begin();
        //cout<<pos1<<endl;
        int pos2 = it1-vec.begin();
        //cout<<pos2<<endl;
        cout<<pos2-pos1<<endl;
    }
    return 0;
}


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

const int MAXN = 300 + 5;

using namespace std;

int dp[100001];


int main()
{
    int n, k;
    vector <int> v;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    for (int i = 0; i <= k; ++i) {
        dp[i] = 2;
        for (int j = 0; j < n; ++j) {
            if (i - v[j] >= 0 and dp[i - v[j]] == 2) {
                dp[i] = 1;
            }
        }
    }
    cout << (dp[k] == 1 ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 640
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n=int(input())
    total=0
    for i in range(1,n+1):
        if i%3!=0 and i%5!=0:
            total+=i
    print(total)



if __name__ == "__main__":

    main()

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

const string YES = "YES";
const string NO = "NO";

typedef long long ll;

void solve(long long N, std::vector<long long> A){
    ll even = 0;
    ll odd = 0;
    for(ll i = 0; i < N; ++i){
        if(A[i] % 2 == 0) even++;
        else odd++;
    }
    if(odd % 2 == 0) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

map<string,int> dict={{"AB",0},{"BC",1},{"AC",2}};
int main(){
    int n;
    int abc[3];
    cin>>n;
    for(int i=0;i<3;i++) cin>>abc[i];

    vector<vector<int>> when(3);
    vector<int> s(n);
    for(int i=0;i<n;i++){
        string tmp;
        cin>>tmp;
        int id = dict[tmp];
        when[id].push_back(i);
        when[(id+1)%3].push_back(i);
        s[i] = id;
    }
    vector<int> res(n);
    for(int i=0;i<n;i++){
        int id = s[i];
        if(abc[id]>1 || abc[(id+1)%3]==0){
            res[i] = (id+1)%3;
        }
        else if(abc[(id+1)%3]>1 || abc[id]==0){
            res[i] = id;
        }
        else{
            auto itid0=upper_bound(when[id].begin(),when[id].end(),i);
            auto itid1=upper_bound(when[(id+1)%3].begin(),when[(id+1)%3].end(),i);
            if(itid0==when[id].end()){
                res[i] = (id+1)%3;
            }
            else if(itid1==when[(id+1)%3].end()){
                res[i] = id;
            }
            else if(*itid0<*itid1){
                res[i] = id;
            }
            else{
                res[i] = (id+1)%3;
            }
        }
        if(res[i]==id){
            abc[id]++;
            abc[(id+1)%3]--;
        }
        else{
            abc[id]--;
            abc[(id+1)%3]++;
        }
        for(int i=0;i<3;i++){
            if(abc[i]<0){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }

    cout<<"Yes"<<endl;
    for(int i=0;i<n;i++){
        cout<<"ABC"[res[i]]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 5068
#include<iostream>
#include<vector>
int main(){
  int n;
  std::cin >> n;
  std::vector<int> cnt(n), sum(n);
  for(int i = 0; i < n; ++i){
    int a;
    std::cin >> a;
    ++sum[cnt[a - 1]++];
  }
  int it = n, acc = n;
  for(int t = 1; t <= n; ++t){
    while(acc < it * t)
      acc -= sum[--it];
    std::cout << it << std::endl;
  }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
ll ans=0;
int st=0;
string s,t;
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	int n1=s.size();
	int n2=t.size();
	int a[n1][26];
	for(int i=0;i<26;i++) a[n1-1][i]=-1;
	a[n1-1][s[n1-1]-'a']=n1-1;
	for(int i=n1-2;i>=0;i--){
		for(int j=0;j<26;j++) a[i][j]=a[i+1][j];
		a[i][s[i]-'a']=i;
	}
	/*
	for(int i=0;i<n1;i++){
		for(int j=0;j<26;j++) cout<<a[i][j]<<",";
			cout<<endl;
	}
	*/
	int z=0;
	for(int i=0;i<n2;i++){
		int pos=t[i]-'a';
		if(st==0){
			if(a[0][pos]==-1){
				z=1; break;
			}
			ans+=(ll)a[0][pos]+1;
			st=(a[0][pos]+1)%n1;
		}
		else{
			if(a[st][pos]==-1){
				i--;
				ans+=(ll)n1-st;
				st=0;
			}
			else{
				ans+=(ll)a[st][pos]-st+1;
				st=(a[st][pos]+1)%n1;
			}
		}
	}
	if(z==1) cout<<"-1";
	else cout<<ans;
}

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

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto f = [&](double x) {
        int cnt = 0;
        for(int i = 0; i < n; i++) {
            cnt += (int)ceil((double)a[i] / x) - 1;
        }
        return (cnt <= k);
    };
    double ng = 0, ok = *max_element(ALL(a));
    for(int _ = 0; _ < 200; _++) {
        auto mid = (ok + ng) / 2.0;
        (f(mid) ? ok : ng) = mid;
    }
    cout << (int)ceil(ok) << endl;
}

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

using namespace std;

int main(){
	long long k,a,b;
	cin>>k>>a>>b;
	if(k<=a) {putchar('1');return 0;}
    else if(a<=b) {puts("-1");return 0;}
    else printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n);

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

    int ans = INT_MAX;

    for(int i=k-1; i<n; i++)
    {
        if(v[i] < 0)
            ans = min(ans,abs(v[i-k+1]));

        else if(v[i-k+1] > 0)
            ans = min(ans, v[i]);
        else
        {
            int x = abs(v[i-k+1]);
            int y = v[i];

            ans = min(ans, x+y+min(x,y));
        }

        //cout<<i<<" "<<ans<<endl;

    }

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


Measured memory_bytes: 640
int main(void) {
    int n, m, en, i, l;
    int H[100], W[100];
    en = 0;
    for ( n = 0 ; en == 0 ; n++ ) {
        scanf("%d %d", &H[n], &W[n]);
        if ( H[n] == 0 && W[n] == 0 )   en = 1;
    }
    for ( m = 0; m < n - 1 ; m++ ) {
        for ( i = 0; i < H[m]; i++ ) {   
            for ( l = 0; l < W[m]; l++ ) {
                printf("#");
            }
            printf("\n");
        }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2048
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

bool score[10010] = {};

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

  int N;
  cin >> N;

  score[0] = true;
  REP(i, N) {
    int s;
    cin >> s;
    REPR(j, 10000) {
      if (score[j]) {
        score[j + s] = true;
      }
    }
  }
  REPR(i, 10000) {
    if (score[i] && i %10 > 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[5005][5005] = {{0}};
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans = INT_MIN;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<i;j++)
        {
            if(s[j-1] == s[i-1])
            {
                if(i - dp[i-1][j-1] != j) dp[i][j] = dp[i-1][j-1] + 1;
                else dp[i][j] = dp[i-1][j-1];
            }
            ans = max(dp[i][j], ans);
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 96384
import collections
n,k=map(int,input().split())
d=[0 for _ in range(k)]
v=[0 for i in range(n)]
for i in range(k):
	d[i] = int(input())
	a = list(map(int,input().split()))
	for j in range(d[i]):
		v[a[j]-1] += 1
unta = collections.Counter(v)
print(unta[0])

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

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

typedef pair<int, int> ii;
typedef vector<ii> vii;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; --i)
#define FORE(x, xs) for (auto x : xs)

const int MAX = 1e5+10;

int N;
vii edges[MAX];
int color[MAX];

int dfs(int n) {
    FORE(e, edges[n]) {
        int m = e.first;
        int l = e.second;
        if (color[m]) continue;
        if (l) color[m] = 3-color[n];
        else color[m] = color[n];
        dfs(m);
    }
}

int main () {
    cin >> N;
    REP (i, N-1) {
        int u, v, w;
        cin >> u >> v >> w; u--; v--; w %= 2;
        edges[u].push_back(make_pair(v, w));
        edges[v].push_back(make_pair(u, w));
    }

    color[0] = 1;
    dfs(0);
    REP (i, N) cout << color[i]-1 << "\n";
}

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

class Union_Find{
private:
  int *par; int *rank;
public:
  Union_Find(int n); ~Union_Find();
  int find(int x); void unite(int x, int y); bool same(int x, int y);
};

Union_Find::Union_Find(int n){
  par = new int[n]; rank = new int[n];
  rep(i, n) par[i] = i, rank[i] = 0;
}

Union_Find::~Union_Find(){
  delete [] par; delete [] rank;
}

int Union_Find::find(int x){
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);
}

void Union_Find::unite(int x, int y){
  x = find(x); y = find(y);
  if (x == y) return;
  if (rank[x] < rank[y]) swap(x, y);
  if (rank[x] == rank[y]) rank[x]++;
  par[y] = x;
}

bool Union_Find::same(int x, int y){
  return find(x) == find(y);
}

int main(){
  int n, k, l;
  cin >> n >> k >> l;
  Union_Find a(n); Union_Find b(n);
  int p, q;
  rep(i,k){
    cin >> p >> q;
    p--; q--;
    a.unite(p,q);
  }
  rep(i,l){
    cin >> p >> q;
    p--; q--;
    b.unite(p,q);
  }
  map<P,int> m;
  rep(i,n) m[P(a.find(i),b.find(i))]++;
  rep(i,n) cout << m[P(a.find(i),b.find(i))] << " ";
  cout << endl;
  return 0;
}


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

#define int long long
#define pb emplace_back
#define f(i,n) for(int i=0 ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int32_t main(){
	fast;
	string s;
	cin >> s;
	for(int i=0; i<3 ; i++)
	{
		if(s[i]==s[i+1])
		{
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
}







Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//可能性のある範囲について、全探索
int main(){
    ll n,k;
    cin >> n >> k;

    //bを固定でぶん回す
    ll res = 0;

    for(ll i = k+1; i <= n; ++i)
    {
        ll tmp = 0;

        //1ループで何回か
        tmp = i - k;


        ll s = n / i;
        ll t = max(n % i - max((k-1), ll(0)),ll(0));
        res += s*tmp;
        res += t;


    }

    cout << res <<  endl;

    return 0;    
}



Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint r;
    cin >> r;
    lint ans = 3 * r * r;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    t_C, t_S, t_F = map(int, input().split())
    C.append(t_C)
    S.append(t_S)
    F.append(t_F)

for k in range(N-1):
    t = 0
    for i in range(k, N-1):
        if t < S[i]:
            t = S[i]
        else:
            if t % F[i] != 0:
                t = t + (F[i] - (t % F[i]))
        t = t + C[i]
    print(t)
print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<lint> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
  V<> id(n);
  iota(begin(id), end(id), 0);
  sort(begin(id), end(id), [&](int i, int j) { return a[i] + b[i] > a[j] + b[j]; });
  lint res = 0;
  for (int i = 0; i < n; ++i) {
    if (i & 1) res -= b[id[i]];
    else res += a[id[i]];
  }
  cout << res << '\n';
}

Measured memory_bytes: 2304
def GCD(x: int, y: int):
    if x < y:
        x, y = y, x

    if x % y == 0:
        return y
    else:
        return GCD(y, x % y)


def LCM(x: int, y: int):
    return x * y // GCD(x, y)


N = int(input())
Tlist = [int(input()) for i in range(N)]
ans = 1
for num in Tlist:
    ans = LCM(ans, num)
print(ans)


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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    int n, k;
    cin >> n >> k;
    unordered_map<int, vector<int>> snuck;
    REP(i, 0, k){
        int d;
        cin >> d;
        REP(j, 0, d){
            int snack;
            cin >> snack;
            snuck[snack].push_back(i + 1);
        }
    }
    int res = 0;
    REP(i, 1, n + 1){
        if(!snuck.count(i)){
            res++;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3672
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
   
      string a,b;
	cin>>a>>b;
	cout<<(b+a);
 
    return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n;
VI ys, ms, ds;

int y_days = 20 * 5 + 19 * 5;
int sy_days = 200;
int bm_days = 20;
int sm_days = 19;

int solve(int now){
	int ans = 0;
	REP(i, ys[now], 1000){
		if(ys[now] != i){
			ans += (i % 3)? y_days : sy_days;
		}else{
			REP(j, ms[now], 11){
				if(ms[now] != j){
					ans += (i % 3 == 0 || j % 2)? bm_days : sm_days;
				}else{
					int dlimit = (i % 3 == 0 || j % 2)? bm_days : sm_days;
					REP(k, ds[now], dlimit + 1){
						ans++;
					}
				}
			}
		}
	}
	return ans;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	cin >> n;
	rep(i, n){
		int y, m, d;
		cin >> y >> m >> d;
		ys.pb(y);
		ms.pb(m);
		ds.pb(d);
	}
	rep(i, n){
		cout << solve(i) << endl;
	}
	return 0;
}

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

void solve() {
    int n;scanf("%d",&n);
    n = (1<<n);
    multiset<int> ms;
    for(int i=0;i<n;++i) {
        int x;
        scanf("%d",&x);
        ms.insert(x);
    }
    priority_queue<int> pq[2];
    int bit = 0;
    pq[bit].push(*prev(ms.end()));
    ms.erase(prev(ms.end()));
    while(!ms.empty()) {
        int nbit = bit^1;
        while(!pq[bit].empty()) {
            int top = pq[bit].top();pq[bit].pop();
            pq[nbit].push(top);
            multiset<int>::iterator it = ms.lower_bound(top);
            if(it== ms.begin()) {
                printf("No\n");
                return;
            }
            it = prev(it);
            pq[nbit].push(*it);
            ms.erase(it);
        }
        bit = nbit;
    }
    printf("Yes\n");
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 15100
A = list(map(int, input().split()))
x = A[0]
y = A[1]
mon = 0
if x < 4:
    if x == 3:
        mon += 100000
    elif x == 2:
        mon += 200000
    elif x == 1:
        mon += 300000
if y < 4:
    if y == 3:
        mon += 100000
    elif y == 2:
        mon += 200000
    elif y == 1:
        mon += 300000
if x == 1:
    if y == 1:
        mon += 400000
print(mon)

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

int main()
{
    int n;
    int NN;
    cin >> n;
    NN = n;
    int n0 = n, n1 = n;
    int m9 = 0, m6 = 0;
    for (; n0 > 0; m9++)
    {
        n0 /= 9;
    }
    for (; n1 > 0; m6++){
        n1 /= 6;
    }
    m9--, m6--;


    int v[33500];
    v[0] = 3;
    v[1] = 1;
    v[2] = 1;
    
    n /= 3;
    for (int i = 3; i < n; i++){
        v[i] = 3 * i;
        
        for (int a6 = 2; a6 <= i + 1; a6 *= 6)
        {
            if (a6-1 == i){
                v[i] = 1;
                break;
            }
            if (i > a6){
                v[i] = min(v[i - a6] + 1, v[i]);
            }
        }
        for (int a9 = 3; a9 <= i + 1; a9 *= 9){
            if (a9-1 == i){
                v[i] = 1;
                break;
            }
            if (i > a9){
                v[i] = min(v[i - a9] + 1, v[i]);
            }
        }
    }
    cout << v[n - 1] + (NN % 3) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define MAX INT_MAX
#define MOD 1000000007
using namespace std;
int main()
{	

	ll n,d;
	cin>>n>>d;
	ll count=0;
	for (int i = 0; i < n; ++i)
	{
		ll x,y;
		cin>>x>>y;
		if((x*x+y*y)<=d*d)
		count++;	
	}
	cout<<count<<endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////

int main() {
ll ans = 0;
	int N; cin >> N;
	int M; cin >> M;
	vector<ll> A;
	vector<ll> P;
	rep(i,M){int a;cin >>a; P.PB(a);}
	sort(ALL(P));
	if(M <= N){ans = 0;}	
	else{
	int a = P.at(0);
	rep(i,M-1)
	{
		int b = P.at(i+1);
		A.PB(b-a);
		a = b;
	}
	sort(ALL(A));
	rep (i,M-N)
	{
		ans += A.at(i);
	}
	
	}
	cout << ans << endl;

}

Measured memory_bytes: 2548
#include<iostream>
#include<string.h>
using namespace std;

int  yoko[1001][1001];

int main() {
	int n, m, a, h, p, q;
	while (cin >> n >> m >> a) {
		if (n == 0 && m == 0 && a == 0)break;
		memset(yoko, 0, sizeof(yoko));
		for (int i = 0; i < m; i++) {
			cin >> h >> p >> q;
			yoko[h][p] = 1;
		}
		for (int i = 1000; i >= 1; i--) {
			if (yoko[i][a] == 1) a++;
			else if (yoko[i][a - 1] == 1) a--;
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 5080
N = int(input())
hs = list(map(int, input().split()))

def dac(hs):
  if not hs:
    return 0
  result = min(hs)
  hs = [h-result for h in hs]
  start = 0
  for i in range(len(hs)):
    if hs[i] == 0:
      result += dac(hs[start:i])
      start = i+1
  if start < len(hs):
    result += dac(hs[start:])
  
  return result
    
print(dac(hs))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)

int main() {
    long long N;
    cin >> N;
    long long ans = 0;
    for (long long i = 1; i <= N; i++) {
        if (i % 2 == 1) {
            long long divcnt = 0;
            for (long long j = 1; j <= i; j++) {
                if (i % j == 0) {
                    divcnt++;
                }
            }
            if (divcnt == 8) {
                ans++;
            }
        }
    }

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


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;




    int main(){
        int x;
        std::cin >> x;
        while (1)
        {
            bool ok = true;
            for (int i = 2; i < x; ++i)
            {
                if (x%i == 0)
                {
                    ok = false;
                    break;
                }
            }
            if (ok) break;
            ++x;
        }
        std::cout << x << "\n";
        return 0;
    }


Measured memory_bytes: 256
void main()
{
    long n = rdElem;
    long[] a = rdRow;

    long q = rdElem;
    foreach (i; 0 .. q)
    {
        long k = rdElem;
        long x = a.binSrch!"a < b"(k) + 1;
        long y = a.binSrch!"a > b"(k);
        writeln(x, " ", y);
    }
}

long binSrch(alias pred = "a < b")(long[] arr, long val)
{
    alias predFun = binaryFun!pred;
    long l = -1, r = arr.length;
    if (!predFun(l, r)) swap(l, r);
    while (abs(r - l) > 1)
    {
        long m = (l + r) / 2;
        if (predFun(arr[m], val)) l = m;
        else r = m;
    }
    return l;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;


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

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


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

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

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<double> A;
  tools::read(A, N);

  std::transform(A.begin(), A.end(), A.begin(), [](const double A_i) { return 1.0 / A_i; });
  std::cout << std::fixed << std::setprecision(14) << 1.0 / std::accumulate(A.begin(), A.end(), 0.0, std::plus<double>()) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;



int main() {
    long long x, y, a, b, c, rr, gg, ww;
    cin >> x >> y >> a >> b >> c;
    multiset<long long> r, g, w;
    for(int i = 0; i < a; ++i){
        cin >> rr;
        r.insert(rr);
    }
    for(int i = 0; i < b; ++i){
        cin >> gg;
        g.insert(gg);
    }
    for(int i = 0; i < c; ++i){
        cin >> ww;
        w.insert(ww);
    }
    multiset<long long> cr;
    unsigned long long ans = 0;
    long long s = 0;
    for(int i = 0; i < x && r.begin() != r.end(); ++i){
        auto now = r.end();
        now--;
        cr.insert(*now);
        r.erase(now);
        s++;
    }
    for(int i = 0; i < y && g.begin() != g.end(); ++i){
        auto now = g.end();
        now--;
        cr.insert(*now);
        g.erase(now);
        s++;
    }
    while(s != x + y){
        auto now = w.end();
        now--;
        cr.insert(*now);
        w.erase(now);
        s++;
    }
    while(w.end() != w.begin() && *cr.begin() < *(--w.end())){
        cr.erase(cr.begin());
        cr.insert(*(--w.end()));
        w.erase(--w.end());
    }
    while(cr.begin() != cr.end()){
        ans += *cr.begin();
        cr.erase(cr.begin());
    }
    cout << ans;
}

Measured memory_bytes: 14336
#include <stdio.h>
#include <algorithm>

using namespace std ;



int main ()

{

    long long int m,n;

    while (scanf ("%lld%lld",&m,&n)!=EOF)
    {

    	if (m==2||n==2)  printf("0\n");
    	else if (n==1||m==1)  
    	{
    		if (max (n,m)==1) printf("1\n");
    		else printf("%d\n", max(n,m)-2);
    	}
    	else
    	{
    		printf("%lld\n", (n-2)*(m-2));
    	}
    }

	return 0;
}

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N, K;
  std::cin >> N >> K;

  int cnt = 0;
  rep(i, N) {
    int h;
    std::cin >> h;
    if(h >= K) ++cnt;
  }
  std::cout << cnt << '\n';
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int M, D;
	cin >> M >> D;

	int cnt = 0;

	for (int i = 1; i <= M; i++) {
		for (int j = 11; j <= D; j++) {
			int d1 = j % 10;
			int d10 = j / 10;
			if (d1 * d10 == i) {
				if (d1 > 1 && d10 > 1) {
					cnt++;
				}
			}
		}
	}
	cout << cnt;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boostup ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
int main()
{
    boostup;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k)
    {
        cout<<(k)<<endl;
    }
    else if(a+b>=k)
    {
        cout<<a<<endl;
    }
    else if(a+b+c>=k)
    {
        ll ans=k-a-b;
        cout<<a-(k-a-b)<<endl;
    }
}   

Measured memory_bytes: 3652
from collections import defaultdict


S = input()
d = defaultdict(list)
for i, s in enumerate(S):
    d[s].append(i + 1)
ret = False
for v in d.values():
    for i in range(len(v) - 1):
        if v[i + 1] - v[i] <= 2:
            ret = True
            print(v[i], v[i + 1])
            break
    if ret:
        break
if not ret:
    print(-1, -1)


Measured memory_bytes: 7796
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define show2(x,y) cout<<#x" = "<<x<<" "<<#y<<" = "<<y<<endl;
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;
typedef vector<vec> grid;

const unsigned LIMIT=3;

grid marked(LIMIT+1,vec(LIMIT+1,0));
grid a(LIMIT+1,vec(LIMIT+1));

void mark(int b)
{
    bool flag;
    for(unsigned i=0;i<LIMIT;++i)
    {
        flag=0;
        for(unsigned j=0;j<LIMIT;++j)
        {
            if(a[i][j] == b)
            {
                marked[i][j]=1;
                // show2(i,j);
                flag=1;
                break;
            }
        }
        if(flag)    break;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    for(unsigned i=0;i<LIMIT;++i)
    {
        for(unsigned j=0;j<LIMIT;++j)
            cin>>a[i][j];
    }
    unsigned n;
    int b;
    cin>>n;
    for(unsigned i=0;i<n;++i)
    {
        cin>>b;
        mark(b);
    }
    for(unsigned i=0;i<LIMIT;++i)
    {
        if(marked[i][0] && marked[i][1] && marked[i][2])
        {
            cout<<"Yes";
            return 0;
        }
    }
    for(unsigned i=0;i<LIMIT;++i)
    {
        if(marked[0][i] && marked[1][i] && marked[2][i])
        {
            cout<<"Yes";
            return 0;
        }
    }
    if((marked[0][0] && marked[1][1] && marked[2][2]) || (marked[0][2] && marked[1][1] && marked[2][0]))
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
}

Measured memory_bytes: 256
/*! if g++ -g alds_1_8_a.cpp -o alds_1_8_a.out; then ./alds_1_8_a.out < alds_1_8_a.test; fi
 */

#include <memory>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

class node;
typedef shared_ptr<node> nodep;

class node{
public:
  int id;
  nodep left, right, parent;
  node(int _id, nodep l, nodep r, nodep p): id(_id), left(l), right(r), parent(p) {}
  node(int i): id(i), left(NULL), right(NULL), parent(NULL) {}
};

nodep root(NULL);

void insert(int i){
  nodep z(new node(i));
  nodep y(NULL);
  nodep x = root;
  while(x.get() != NULL){
    y = x;
    if(z->id < x->id){
      x = x->left;
    } else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y.get() == NULL){
    root = z;
  } else if(z->id < y->id){
    y->left = z;
  } else{
    y->right = z;
  }
}

void mid(nodep nd){
  if(nd.get() == NULL){
    return;
  }
  mid(nd->left);
  cout << " " << nd->id;
  mid(nd->right);
}

void pre(nodep nd){
  if(nd.get() == NULL){
    return;
  }
  cout << " " << nd->id;
  pre(nd->left);
  pre(nd->right);
}

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if(s[0] == 'i'){
      int id;
      cin >> id;
      insert(id);
    } else{
      mid(root); cout << endl;
      pre(root); cout << endl;
    }
  }  
  return 0;
}

Measured memory_bytes: 48100
// K - One Card Poker
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main (){
 int a,b;
   cin>>a>>b;
   if (a==1&&b!=1)
   return cout <<"Alice"<<endl ,0;
   else if (b==1&&a!=1)
    return cout<<"Bob"<<endl,0;
   else{
        if (a>b)
        cout <<"Alice"<<endl;
        else if (a<b)
        cout<<"Bob"<<endl;
        else
    cout <<"Draw"<<endl;


   }

return 0;

}


Measured memory_bytes: 256
n = int(input())
s = input()

for p1,p2 in [(True,True),(True,False),(False,True),(False,False)]:
  ans = []
  ans.extend([p1,p2])  
  for i in range(1,n-1):
    if ans[i] == True:
      if s[i]=='o':
        ans.append(ans[-2])
      else:
        ans.append(not ans[-2])
    else:
      if s[i]=='o':
        ans.append(not ans[-2])
      else:
        ans.append(ans[-2])
  
  f = False
  if ans[-1]==True:
    if s[-1]=='o' and ans[-2]==ans[0]:        
      f = True
    if s[-1]=='x' and ans[-2]!=ans[0]:      
      f = True
  else:
    if s[-1]=='o' and ans[-2]!=ans[0]:
      f = True
    if s[-1]=='x' and ans[-2]==ans[0]:
      f = True
      
  if f:    
    if ans[0] and s[0]=='o' and ans[1] == ans[-1]:
      break
    if ans[0] and s[0]=='x' and ans[1] != ans[-1]:
      break
    if not ans[0] and s[0]=='o' and ans[1] != ans[-1]:
      break
    if not ans[0] and s[0]=='x' and ans[1] == ans[-1]:
      break
  ans = []
  
if len(ans)>0:
  print(''.join(['S' if a else 'W' for a in ans] ))
else:
  print(-1)

Measured memory_bytes: 5044
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   ll n, a, b;
   cin >> n >> a >> b;
   ll r = n % (a + b);
   cout << (n / (a + b)) * a + (a > r ? r : a) << endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Otoshidama {
    double value;
    String currency;
    public Otoshidama(String v, String cur) {
        this.value = Double.parseDouble(v);
        this.currency = cur;
    }

    double toYen() {
        double res = this.value;
        if (currency.equals("BTC")) {
            res = this.value * 380000;
        }
        return res;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Scanner sc2 = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine(); // これよくわからん
        double sum = 0;

        for (int i = 0; i < n; i++) {
            String[] in = sc.nextLine().split(" ");
            sum += (new Otoshidama(in[0], in[1])).toYen();
        }

        System.out.println(sum);

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	string st, sh;
	int countt=0, counth=0;
	for (int i=0; i < n; i++) {
		cin >> st >> sh;
		if (st == sh) {
			countt++;
			counth++;
		} else if (st > sh) {
			countt = countt + 3;
		} else {
			counth = counth + 3;
		}
	}
		cout << countt << " " << counth << "\n";
	return 0;
}


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

Measured memory_bytes: 1732