akhauriyash/Code-Regression huggingface dataset:
/* 
 */
#include<bits/stdc++.h>
using namespace std;

#define double long double
#define int long long //define macro: certain strings in the code will be changed before the compilation
#define double long double
#define normalInt int
#define vec vector
typedef vector<int> vi; //  give a shorter name to a datatype
#define PB push_back
#define MP make_pair
#define unset unordered_set
typedef pair<int,int> ii;
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)

#define SQ(a) (a)*(a) // chu y 2 dau ngoac (macro = text replacement!)
const double EPS=1e-9;
inline int GCD(int a, int b) { while (b != 0) {int c = a % b; a = b; b = c;} return a;};

int count_one(int a, int k) {// number of '1' in position k (=0, 1, ... from right) in binary rep of 0,1, ...a
	int period = pow(2, k+1);
	int m = (a+1)/period, n = (a+1)%period;
	int maxV, po = pow(2,k); 
	if(n-po>0) maxV = n-po;
	else maxV = 0;
	return m*po + maxV;
}

#undef int
int main() {
#define int long long
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0); 	cin.tie(0);

	int a, b; cin >> a >> b;
	
//	for(int i=0; i<10; ++i) cout << count_one(b, i) << " ";
//	cout << endl;
	
	string res="";
	for(int i=0; i<45; ++i) {
		int dif1;
		if(a>=1) dif1 = count_one(b, i) - count_one(a-1, i); // if a>=1
		else dif1 = count_one(b, i);
		
//		cout << i << ", dif1 = " << dif1 << endl;
		
		if(dif1%2==0) res = '0' + res;
		else res = '1' + res;
		
//		cout << i << ". res = " << res << endl;
		
	}
	
//	cout << res << endl;
	
	cout << stoll(res, 0, 2) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  ll a, b, x;cin>>a>>b>>x;
  if(a+b==0){
    cout << 1 << endl;
  }else if(a==0){
    cout << b/x+1 << endl;
  }else{
    cout << b/x-(a-1)/x << endl;;
  }
}


Measured memory_bytes: 256
// Colorful Transceivers

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A < B) {
        if (C < A || B < C) {
            printf("No");
        }
        else {
            printf("Yes");
        }
    }
    else {
        if (C < B || A < C) {
            printf("No");
        }
        else {
            printf("Yes");
        }
    }
    return 0;
}

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

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)3e5 + 1;
const int INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n, e[N], w[N];
pii t[N * 4];
string s;

void build (int v, int tl, int tr){
  if (tl == tr) t[v].first = e[tl], t[v].second = w[tl];
  else {
    int tm = tl + tr >> 1;
    build (v * 2, tl, tm);
    build (v * 2 + 1, tm + 1, tr);
    t[v].first = t[v * 2].first + t[v * 2 + 1].first;
    t[v].second = t[v * 2].second + t[v * 2 + 1].second;
  }
}

int get1 (int v, int tl, int tr, int l, int r){
  if (l <= tl && tr <= r) return t[v].first;
  if (l > tr || tl > r) return 0;
  int tm = tl + tr >> 1;
  return get1 (v + v, tl, tm, l, r) + get1 (v + v + 1, tm + 1, tr, l, r);
}

int get2 (int v, int tl, int tr, int l, int r){
  if (l <= tl && tr <= r) return t[v].second;
  if (l > tr || tl > r) return 0;
  int tm = tl + tr >> 1;
  return get2 (v + v, tl, tm, l, r) + get2 (v + v + 1, tm + 1, tr, l, r);
}

int main (){
  cin >> n >> s;
  forn (i, 0, s.size() - 1){
    if (s[i] == 'E') e[i + 1] = 1;
    if (s[i] == 'W') w[i + 1] = 1;
  }
  build (1, 1, n);
  int ans = INF;
  //cout << get2 (1, 1, n, 1, 7) + get1(1, 1, n, 9, n) << "\n";
  forn (i, 0, s.size() - 1){
    if (i == 0){
      ans = min (ans, get1(1, 1, n, 1, n));
    }
    else if (i == s.size() - 1){
      ans = min(ans, get2 (1, 1, n, 1, n));
    }
    else {
      ans = min(ans, get2(1, 1, n, 1, i) + get1 (1, 1, n, i + 2, n));
    }
   //a cout << ans << "\n";
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 12420
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------




int main(){
    

	int n,a,b;
	cin>>n>>a>>b;
	
	int ans=a*n;
	ans=min(ans,b);
	cout<<ans;






    return 0;
}

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

bool used[200005]={};
vector<int> ans(200005,0);

void bfs(int s,vector<int> g[]){
    queue<int> que;
    used[s]=true;
    que.push(s);
    while(!que.empty()){
        int p=que.front(); que.pop();
        //cout << p << endl;
        for(auto it=g[p].begin();it!=g[p].end();it++){
            if(used[*it]==false){
                ans[*it]+=ans[p];
                que.push(*it);
                used[*it]=true;
            }
        }
    }
}

int main(){
    int N,Q;
    cin >> N >> Q;
    vector<int> g[N]; //隣接リスト
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<Q;i++){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p]+=x;
    }
    bfs(0,g);
    for(int i=0;i<N;i++){
        cout << ans[i] << " ";
    }
}


Measured memory_bytes: 15732
using System;
using System.Text;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
       var s  = sc.Next();
       string ans="";
       if (s == "Sunny")
       {
           ans = "Cloudy";
       }
       if (s == "Cloudy")
       {
           ans = "Rainy";
       }
       if (s == "Rainy")
       {
           ans = "Sunny";
       }
       Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cctype>
#include <cstring>
#include <vector>
using namespace std;

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
class Dice
{
public:
	Dice()
	{}
	
	Dice(char m[7])
	{
		f[TOP]=0; f[FRONT]=1; f[LEFT]=2;
		f[RIGHT]=3; f[BACK]=4; f[BOTTOM]=5;
		
		memcpy(val, m , sizeof(val));
	}
	void rotate(FACE a, FACE b, FACE c, FACE d)
	{
		int tmp = f[a];
		f[a]=f[b];
		f[b]=f[c];
		f[c]=f[d];
		f[d]=tmp;
	}
	
	vector<Dice> all_rotate()
	{
		vector<Dice> t;
		for(int i=0; i<6; (i&1?rotateY():rotateX()), i++)
		for(int j=0; j<4; rotateZ(), j++)
			t.push_back(*this);
			
		return t;
	}
	
	void rotateX() { rotate(TOP, BACK, BOTTOM, FRONT); }
	void rotateY() { rotate(TOP, LEFT, BOTTOM, RIGHT); }
	void rotateZ() { rotate(FRONT, RIGHT, BACK, LEFT); }
	char GetVal(FACE fe) { return val[f[fe]]; }
	
	int f[6];
	char val[7];
};

Dice pz[2][2][2];
bool fl[2][2][2];
int num[2][2][2];

bool eq[8][8];
bool used[8];
vector<vector<Dice> > all_face;

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

int nx[]={0,0,1,1,0,0,1,1};
int ny[]={0,1,0,1,0,1,0,1};
int nz[]={0,0,0,0,1,1,1,1};

FACE chk1[]={LEFT, BACK, RIGHT, FRONT, TOP, BOTTOM};
FACE chk2[]={RIGHT, FRONT, LEFT, BACK, BOTTOM, TOP};

bool isequal(char l, char r)
{
	if(isupper(l)&&isupper(r)) return false;
	if(islower(l)&&islower(r)) return false;
	
	if(isupper(l))	return tolower(l)==r;
	
	return toupper(l)==r;
}

bool dfs(int x, int y, int z, int p)
{
	if(p==8) return true;
	int l=(p==0?1:8);
	for(int i=0; i<l; i++)
	{
		int fcnt=0;
		if(used[i]) continue;
		for(int j=0; j<24; j++)
		{
			int cnt=0;
			bool g=true, ct=false;
			pz[x][y][z]=all_face[i][j];
			for(int k=0; k<6; k++)
			{
				
				int tx=x+dx[k], ty=y+dy[k], tz=z+dz[k];
				if(tx<0||ty<0||tz<0||tx>=2||ty>=2||tz>=2) continue;
				if(!fl[tx][ty][tz]) continue;
				
				cnt++;
				int dn=num[tx][ty][tz];
				if(!eq[i][dn])
				{
					ct=true;
					break;
				}
				if(!isequal(pz[x][y][z].GetVal(chk1[k]), pz[tx][ty][tz].GetVal(chk2[k])))
				{
					g=false;
					break;
				}
			}
			
			if(ct) break;
			if(!g) continue;
			fcnt++;
			
			num[x][y][z]=i;
			fl[x][y][z]=1;
			used[i]=1;
			
			if(dfs(nx[p+1], ny[p+1], nz[p+1], p+1)) return true;
			
			num[x][y][z]=-1;
			fl[x][y][z]=0;
			used[i]=0;
			
			if(cnt>=2) break;
			if(cnt==1&&fcnt>=4) break;
		}
	}
	
	return false;
}

int main()
{
	char b[7];
	while(scanf("%s", b), b[0]!='0')
	{
		memset(fl,0,sizeof(fl));
		memset(eq,0,sizeof(eq));
		memset(used, 0, sizeof(used));
		all_face.clear();
		for(int i=0; i<8; i++)
		{
			Dice d(b);
			all_face.push_back(d.all_rotate());
			if(i==7) break;
			scanf("%s", b);
		}
		
		for(int i=0; i<8; i++)
		for(int j=i+1; j<8; j++)
		{
			if(i==j) continue;
			for(int k=0; k<6; k++)
			for(int l=0; l<6; l++)
			{
				if(isequal(all_face[i][0].val[k], all_face[j][0].val[l]))
				{
					eq[i][j]=1;
					eq[j][i]=1;
				}
			}
		}
		
		if(dfs(nx[0], ny[0], nz[0], 0)) puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 796
import sys
from collections import defaultdict
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
d = defaultdict(int)

for i in range(N):
    s = tuple(sorted(input()))
    d[s] += 1
ans = 0
for key, value in d.items():
    while value != 0:
        ans += value - 1
        value -= 1
print(ans)

Measured memory_bytes: 23908
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = stdin.ReadInt()
	}

	d := map[int]bool{}
	for i := 0; i < n; i++ {
		d[a[i]] = true
	}

	if len(d) == n {
		stdout.Println("YES")
	} else {
		stdout.Println("NO")
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(10) << x << endl
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

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

  ll x;
  cin >> x;
  bool f = false;
  for(ll a = -120; a < 120; ++a) for(ll b = -120; b < 120; ++b) {
    if(pow(a, 5) - pow(b, 5) == x) {
      out(a << ' ' << b);
      f = true;
      break;
    }
    if(f) break;
  }
  return 0;
}


Measured memory_bytes: 4024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int r; cin >> r;
    cout << r * r << endl;
}


Measured memory_bytes: 888
lim = int(1e5 + 1)
x = int(input())
d = {}
for i in range(-lim, lim):
    d[pow(i, 5)] = i
for i in range(-lim, lim):
    res = pow(i, 5) + x
    if res in d:
        print(d[res], i)
        break

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

int main() {
    int N, M; cin >> N >> M;
    multiset<ll> things;
    for (int i = 0; i < N; i++) 
    {
        ll thing; cin >> thing;
        things.insert(thing);
    }
    for (int i = 0; i < M; i++)
    {
        auto x = things.end();
        x--;
        ll x_ = *x / 2;
        things.erase(x);
        things.insert(x_);
    }
    ll ans = 0;
    for (auto itr = things.begin(); itr != things.end(); itr++) ans += *itr;
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define For(i, j, k) for(int i = j; i <= k; ++i)
#define Forr(i, j, k) for(int i = j; i >= k; --i)
using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') p = -1; c = getchar(); }
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return x *= p;
}

template<typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

inline void File() {
	freopen("ARC080C.in", "r", stdin);
	freopen("ARC080C.out", "w", stdout);
}

const int N = 1e5 + 10, M = 30 + 10;
int n, A[N], F[M], tmp[N];

int main() {
//	For(i, 0, 29) F[i] = 1 << i;
	n = read();
	For(i, 1, n) {
		int x = read();
//		Forr(j, 29, 1) if(!(x % F[j])) x /= F[j], A[i] += j;
		while(x % 2 == 0) x /= 2, ++ A[i];
	}
	sort(A + 1, A + 1 + n);

	int cnt = 0;
	For(i, 1, n + 1 >> 1) {
		tmp[++cnt] = A[i], tmp[++cnt] = A[n + 1 - i];
		if(i == n + 1 - i) -- cnt;
	}
	
	int res = 0;
	For(i, 1, n - 1) if(tmp[i] + tmp[i + 1] < 2) ++ res;
	printf("%s\n", res ? "No" : "Yes");
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


#define N 200007
ll fac[N], inv[N], finv[N];

void cominit(int n) {
    int i;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (i = 2; i < n + 2; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
    return;
}

ll com(int n, int r) {
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    if (r == 0 || r == n) return 1;
    return (fac[n] * finv[r]) % mod * finv[n - r] % mod;
}

int main(void) {
    int n, m, k;
    ll fdi, fdj, cdi, cdj, ans;

    scanf("%d%d%d", &n, &m, &k);

    cominit(n * m);

    fdi = 0;
    for (cdi = 1; cdi <= n - 1; cdi++) {
        fdi += cdi * (n - cdi) % mod * m % mod * m % mod;
    }
    fdj = 0;
    for (cdj = 1; cdj <= m - 1; cdj++) {
        fdj += cdj * (m - cdj) % mod * n % mod * n % mod;
    }

    ans = (fdi + fdj) % mod;

    ans = ans * com(n * m - 2, k - 2) % mod;

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 4992
use proconio::input;

fn main() {
    input! {n: u32, d: f64, xy: [(f64, f64); n]};

    let mut res = 0;
    for i in xy {
        if (i.0 * i.0 + i.1 * i.1).sqrt() <= d {
            res = res + 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll unsigned long long
#define maxn 500005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    cout << (n / 500) * 1000 + ((n % 500)/5*5)<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    
    int a=0,b=0,x=-1,ans=0;
    
    for (int i = 0;i<N;i++){
        cin >> b;
        
        if (a >= b && x == -1){
            x = i - 1;
        }
        else if (a >= b && i == N - 1 && x != -1){
            if (ans < i - x){
                
                ans = i - x;
            }
        }
        
        else if (a < b && x != -1){
            if (ans < (i - 1) - x){
                ans = (i - 1) - x;
            }
            
            x = -1;
        }
        
        
        a = b;
    }
    
    cout << ans << endl;
    
}

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

using namespace std;

int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    int flag=0;
    for (int i=a;i<=b;i++){
        if(i%k==0){
            flag=1;
            break;
        }
    }
    if(flag){
        cout<<"OK";
    }
    else{
        cout<<"NG";
    }
    cout<<endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;

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

    int ans = 2000000001;

    for(int i = 0; i < n; i++) {
        int y = a[i];

        vector<vector<int>> b(n);
        int idx = 0;
        for(int j = 0; j < n; j++) {
            if(a[j] < y) {
                idx++;
            } else {
                b[idx].push_back(a[j]);
            }
        }

        vector<int> c;

        for(int j = 0; j < n; j++) {
            sort(b[j].begin(), b[j].end());

            for(int l = 0; l < (int)b[j].size() - k + 1; l++) {
                c.push_back(b[j][l]);
            }
        }

        sort(c.begin(), c.end());

        if(c.size() >= q) {
            int x = c[q - 1];
        
            ans = min(ans, x - y);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  map<ll,ll>mp;
  vector<ll>a(n);
  ll sum = 0;
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
    sum += a[i];
  }
  
  int q;
  cin >> q;
  while(q--){
    ll b,c;
    cin >> b >> c;
    ll cnt = mp[b];
    sum -= b*cnt;
    sum += c*cnt;
    mp[b]=0;
    mp[c]+=cnt;
    cout << sum << endl;
  }
    
  return 0;
}


Measured memory_bytes: 10024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<double> t(N);
    vector<double> v(N);
    rep(i, N)
    {
        cin >> t[i];
    }
    rep(i, N)
    {
        cin >> v[i];
    }

    // 全体のT秒を求める
    int T = 0;
    rep(i, N)
    {
        T += t[i];
    }

    vector<double> maxV(2 * T + 1, (double)INF); // 0.5秒刻みで最大の速度

    // maxのスピードをv[i]で初期化
    int nowT = 0; // 現在の時間
    rep(i, N)
    {
        rep(ti, t[i])
        {
            int t1 = nowT + ti * 2;
            int t2 = nowT + ti * 2 + 1;
            maxV[t1] = min(maxV[t1], v[i]);
            maxV[t2] = min(maxV[t2], v[i]);
        }
        nowT += t[i] * 2;
        maxV[nowT] = min(maxV[nowT], v[i]);
    }

    // 0秒とT秒は0(静止)
    maxV[0] = maxV[T * 2] = 0.0;


    // 1秒間に1m/sしか速度が変わらない
    // 前から比較
    rep(ti, 2 * T + 1)
    {
        maxV[ti + 1] = min(maxV[ti + 1], maxV[ti] + 0.5);
    }
    // 後ろから比較
    for (int ti = 2 * T; ti >= 0; --ti) {
        maxV[ti] = min(maxV[ti], maxV[ti + 1] + 0.5);
    }

    double ans = 0.0;
    // 図形をにv軸に平行な辺を底として見て,x軸に平行な辺を縦として見ている
    rep(i, 2 * T + 1)
    {
        // (上底 + 下底) * 高さ / 2
        ans += (maxV[i] + maxV[i + 1]) * 0.5 / 2.0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int main() {
	int N;
	cin >> N;
	vector<ll>A(N);
	for (int i = 0; i < N;++i) {
		cin >> A[i];
	}
	sort(A.begin(),A.end());
	string ans = "YES";
	ll before = A[0];
	for (int i = 1; i < N;++i) {
		if (before == A[i]) {
			ans = "NO";
			break;
		}
		before = A[i];
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n,x,t;

    cin >> n >> x >> t;

    if(n%x==0)
    {
        cout << (n/x)*t << endl;
    }
    else
    {
        cout << ((n/x)+1)*t << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		string in[n];
		for(int i=0;i<n;i++){
			cin>>in[i];
		}
		int mojisu=0,ct=0;
		while(ct<(n*(n-1))/2){
			int kazu1[n];
			for(int i=0;i<n;i++){
				kazu1[i]=0;
			}
			mojisu++;
			ct=0;
			string s[n][mojisu];
			for(int i=0;i<n;i++){
				int flg=1,len=in[i].size(),nanmoji=0;
				for(int j=0;j<len;j++){
					if(flg==1){
						s[i][nanmoji]=in[i][j];
						nanmoji++;
					}
					if(in[i][j]=='a'||in[i][j]=='i'||in[i][j]=='u'||in[i][j]=='e'||in[i][j]=='o'){
						flg=1;
					}
					else{
						flg=0;
					}
					if(nanmoji==mojisu){
						break;
					}
				}
				for(int j=nanmoji;j<mojisu;j++){
					s[i][j]='1';
					kazu1[i]=1;
				}
			}
			for(int i=0;i<n-1;i++){
				for(int j=i+1;j<n;j++){
					for(int k=0;k<mojisu;k++){
						if(s[i][k]!=s[j][k]){
							ct++;
							break;
						}
					}
				}
			}
			int b=0;
			for(int i=0;i<n;i++){
				b=b+kazu1[i];
			}
			if(b==n){
				mojisu=-1;
				break;
			}
		}
		cout<<mojisu<<endl;
	}
    return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int a, b ,c, d;
  a = n % 10;
  b = n % 100 / 10;
  c = n % 1000 / 100;
  d = n / 1000;
  
  if((a == b && b == c) || (b == c && c == d)){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
}

Measured memory_bytes: 3620
if __name__ == '__main__':
    n = int(input())
    points = []
    for i in range(n):
        points.append(list(map(int, input().split())))

    for c_x in range(101):
        for c_y in range(101):
            is_correct = True
            estimated_height = 0
            for point in points:
                x = point[0]
                y = point[1]
                h = point[2]
                if h != 0:
                    estimated_height = abs(c_x - x) + abs(c_y - y) + h
                    break

            for point in points:
                x = point[0]
                y = point[1]
                h = point[2]
                if h != 0:
                    if estimated_height != abs(c_x - x) + abs(c_y - y) + h:
                        is_correct = False
                        break
                else:
                    if estimated_height - abs(c_x - x) - abs(c_y - y) > 0:
                        is_correct = False
                        break

            if is_correct:
                # outputの形式を確認する
                print(c_x, c_y, estimated_height)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>



int main(){
int n,i;
int x[1001],y[1001];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %s",x,y);
printf("%d\n",lcs(x,y));
}
return 0;
}
int lcs(char x[] ,char y[]){

int i,j;
int u=strlen(x);
int v=strlen(y);
int a[u+1][v+1];
for(i=0;i<=u;i++)
a[i][0] = 0;
for(i=0;i<=v;i++)
a[0][i] = 0;
for(i=1;i<=u;i++){
for(j=1;j<=v;j++){
if(x[i-1]==y[j-1])
a[i][j]=a[i-1][j-1]+1;
else if(a[i-1][j]>=a[i][j-1])
a[i][j]=a[i-1][j];
else
a[i][j]=a[i][j-1];}

}
return a[u][v];
}

Measured memory_bytes: 5716
from collections import Counter
from operator import mul
from functools import reduce
def combinations_count2(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

#
N=int(input())
A=list(map(int,input().split()))
#
hoge=Counter(A)
ans=0
for i in hoge.values():
    if i>=2:
        ans += combinations_count2(i, 2)
for i in range(N):
    print(ans-hoge[A[i]]+1)



Measured memory_bytes: 27016
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

int main() {
    int h, w;
    std::cin >> h >> w;
    char s[100][100];
    int grid[100][100];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++) {
            grid[i][j] = 0;
     
            std::cin >> s[i][j];
        
        }
       
    }
  

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#')
            {
                for (int dx = -1; dx <= 1; dx++) {
                    for (int dy = -1; dy <= 1; dy++) {
                        int x = dx + j;
                        int y = dy + i;
                        if(x >= 0 && x < w && y >= 0 && y < h) {
                            grid[y][x]++;
                        }
                    }
                }
            }
        } 
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(s[i][j] != '#') {
                std::cout << grid[i][j];
            } else {
                std::cout << '#';
            }
        }

        std::cout << "\n";
    }
}

Measured memory_bytes: 3620
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_da].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

void MAIN() {

    ll n;
    string a, b;
    cin >> n >> a >> b;
    fori (i, n) {
        cout << a[i] << b[i]; 
    }
    cout << '\n';

}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string s,t;
	cin >> s >> t;

	string st = t.substr(0, s.length());
	if(s == st && s.length() == t.length()-1){
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3672
a,b,c,x,y = gets.split.map(&:to_i)
ans = 10**9
for i in 0..x
    ret = a*i+c*2*(x-i)
    ret += (b < c*2 ? b : c*2)*(y-x+i > 0 ? y-x+i : 0)
    ans = ret if ans > ret
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define nxt "\n"
#define intpair pair<int,int>
using namespace std;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int pow(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline bool sortinrev(const pair<int,int> &a,const pair<int,int> &b){return (a.first > b.first);} //sort pair in descending order
inline ll gcd(ll a, ll b){if (b == 0) return a;return gcd(b, a%b);}
inline ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}  
int main(){
		ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
			if(i%k == 0){
				cout<<"OK\n";
				return 0;
			}
		}
		cout<<"NG\n";
}
 


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define REP(i,start,end) for (int (i) = (start); (i) < (end); (i)++)

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

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

    int A, B, C; cin >> A >> B >> C;
    if ((A == 5 && B == 5 && C == 7) ||
        (A == 5 && B == 7 && C == 5) ||
        (A == 7 && B == 5 && C == 5))
    {
        cout << "YES";
    } else {
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 256
def SuminCluster(num,C):
    if num>=15:
        return 60
    sum = 0
    for i in range(1,num+1):
        if i%3==0 or i%5==0:
            pass
        else:
            sum+=i
            sum+=C*15
    return sum

N = int(input())
C = N//15
A = N%15
FBSum = C*C*60+SuminCluster(A,C)
# for i in range(15):
#     print("FBSum: ",SuminCluster(i,C))
print(FBSum)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
//#include <iostream>
using namespace std;
int main() {
  long long int N, Y;
  long long int i,j,k;
  char S[100050] = {0};
  scanf("%s", S);
  //cout << S << endl;

  for (i = strlen(S)-1; i >= 0;i--) {
    int flag = 0;
    //cout << i << " " << endl;
    if (i >= 4) {
      if (S[i] == 'm' &&
          S[i-1] == 'a' &&
          S[i-2] == 'e' &&
          S[i-3] == 'r' &&
          S[i-4] == 'd') {
        i -= 4;
        //puts("dream");
        flag = 1;
        goto end;

      }
    }
    if (i >= 6) {
      if (S[i] == 'r' &&
          S[i-1] == 'e' &&
          S[i-2] == 'm' &&
          S[i-3] == 'a' &&
          S[i-4] == 'e' &&
          S[i-5] == 'r' &&
          S[i-6] == 'd') {
        i -= 6;
        //puts("dreamer");
        flag = 1;
        goto end;

      }
    }
    if (i >= 5) {
      if (S[i] == 'r' &&
          S[i-1] == 'e' &&
          S[i-2] == 's' &&
          S[i-3] == 'a' &&
          S[i-4] == 'r' &&
          S[i-5] == 'e' ) {
        i -= 5;
        //puts("eraser");
        flag= 1;
        goto end;
      }
    }
    if (i >= 4) {
      if (S[i] == 'e' &&
          S[i-1] == 's' &&
          S[i-2] == 'a' &&
          S[i-3] == 'r' &&
          S[i-4] == 'e' ) {
        i -= 4;
        //puts("erase");
        flag = 1;
        goto end;
      }
    }
    
    else {
      printf("NO\n");
      return 0;
    }
    if (flag == 0) {
      printf("NO\n");
      return 0;
    }    
  end:;
  }
  printf("YES\n");
  return 0;
  // scanf("%lld%lld", &N, &Y);

  // for (i = 0; i <= N; i++) {
  //   for (j = 0; j <= N-i; j++) {
  //     k = N - i - j;
  //     //cout << i << " " << j << " " << k << endl;
  //     if ((i*10000) + (j * 5000) + (k*1000) == Y) {
  //       cout << i << " " << j << " " << k << endl;
  //       return 0;
  //     }
  //   }
  // }
  // printf("-1 -1 -1\n");

}


Measured memory_bytes: 384
fun main(args: Array<String>) {
  val day: String = readLine()!!
    when(day) {
    Weekday.SUN.toString() -> println(Weekday.SUN.restDay)
    Weekday.MON.toString() -> println(Weekday.MON.restDay)
    Weekday.TUE.toString() -> println(Weekday.TUE.restDay)
    Weekday.WED.toString() -> println(Weekday.WED.restDay)
    Weekday.THU.toString() -> println(Weekday.THU.restDay)
    Weekday.FRI.toString() -> println(Weekday.FRI.restDay)
    Weekday.SAT.toString() -> println(Weekday.SAT.restDay)
  }
}

enum class Weekday(val restDay: Int){
  SUN(7),
  MON(6),
  TUE(5),
  WED(4),
  THU(3),
  FRI(2),
  SAT(1)
}

Measured memory_bytes: 29724
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
typedef int64_t i64;

int main() {
	int n;
	scanf("%d", &n);
	auto m = n * 3;
	auto a = new int[m];
	for(int i = 0; i < m; i++) scanf("%d", a + i);
	sort(a, a + m);
	reverse(a, a + m);
	i64 s = 0;
	for(int i = 0; i < n; i++) s += a[2 * i + 1];
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define _GLIBCXX_DEBUG
     
int main() {
  ll n, ans=0;
  cin >> n;
  int a[n+1];
  int b[n];
  rep (i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  
  rep(i, n) {
    if (a[i] + a[i+1] >= b[i]) {
      a[i+1] -= b[i] - a[i] > 0 ? b[i] - a[i] : 0;
      ans += b[i];
    }
    else {
      ans += (a[i] + a[i+1]);
      a[i+1] = 0;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
using namespace std;
 
 
int main(){
  int e;
  while(cin>>e,e){
		int ans = 1 << 20;
        for(int i = 0;i*i*i<=e;i++){
					int yyx  = e - i*i*i;
					int y = (int)sqrt(yyx);
					ans = min(yyx-y*y+y+i,ans);
				}
				cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2960
import sys
alphabet = 'abcdefghijklmnopqrstuvwxyz'
result = {}


def check(judge):
    global result
    for i in judge:
            x = i.lower()
            if x in alphabet:
                result[x] += 1

for i in alphabet:
    result[i] = 0

judge = sys.stdin.read()
check(judge)
   
for k, v in result.items():
    print('{} : {}'.format(k, v))


Measured memory_bytes: 5564
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll INF=1LL<<60;


int main(){
  int n,m;
  cin >> n >> m;
  cout << m*(m-1)/2+n*(n-1)/2;
}



Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abl/abl_c
import sys
from collections import deque

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

class node:
    def __init__(self, i):
        self.i = i
        self.adj = {self}
        self.visited = False
    
    def join(self, B):
        self.adj.add(B)
        B.adj.add(self)

def bfs(tar):
    q = deque()
    q.append(tar)
    cnt = 0
    while (q):
        tar = q.popleft()
        if not tar.visited:
            cnt += 1
        tar.visited = True
        q.extend(adj for adj in tar.adj if not adj.visited)
    return cnt

def main():
    N, M = i2nn()
    G = [node(i) for i in range(N + 1)]
    for _ in range(M):
        A, B = i2nn()
        G[A].join(G[B])
    ans = 0
    for tar in G[1:]:
        if not tar.visited:
            bfs(tar)
            ans += 1
    print(ans - 1)
    return

main()

Measured memory_bytes: 100860
N, K = gets.chomp.split(' ').map(&:to_i)
A = gets.chomp.split(' ').map(&:to_i)

count = {}
A.each do |ai|
  count[ai] ||= 0
  count[ai] += 1
end

ans = 0
count.values.sort.reverse.each.with_index do |c, i|
  next if i < K
  ans += c
end

print ans

Measured memory_bytes: 34160
#include "bits/stdc++.h"
using namespace std;
#define maxn 301
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair

const int mod = 1000000000 + 7;
int cnt[26];

int run(string s, char c){
    s = s + c;
    int ans = 0;
    rep(i, s.size()){
        for(int j=i; j<s.size(); ++j){
            if(s[j] == c){
                ans = max(ans, j - i);
                break;
            }
        }
    }
    return ans;
}

void solve(){
    string s;
    cin >> s;
    int ans = s.size();
    for(int i=0; i<26; ++i)
        ans = min(ans, run(s, 'a' + i));
    cout << ans;
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10,p=924844033;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int mul(int x,int y){return (ll)x*y%p;}
int power(int x,int y){
    int ans=1;
    for (;y;y>>=1,x=mul(x,x))
        if (y&1) ans=mul(ans,x);
    return ans;
}
int w[N],iw[N];
void init(int n){
    w[0]=1;w[1]=power(5,(p-1)/n);
    for (int i=2;i<=n;i++) w[i]=mul(w[i-1],w[1]);
    for (int i=0;i<=n;i++) iw[i]=w[n-i];
}
void fft(int n,int *a,int *w){
    for (int i=0,j=0;i<n;i++){
        if (i<j) swap(a[i],a[j]);
        for (int k=n>>1;(j^=k)<k;k>>=1);
    }
    for (int i=2;i<=n;i<<=1){
        int m=i>>1,step=n/i;
        for (int j=0;j<n;j+=i)
        for (int k=0,pos=0;k<m;k++,pos+=step){
            int t=mul(a[j+k+m],w[pos]);
            a[j+k+m]=dec(a[j+k],t);
            a[j+k]=inc(a[j+k],t);
        }
    }
    if (w==iw){
        int del=power(n,p-2);
        for (int i=0;i<n;i++) a[i]=mul(a[i],del);
    }
}
int n,e[N],head[N],nxt[N];
void add(int f,int t){
    static int cnt=0;
    e[++cnt]=t;
    nxt[cnt]=head[f];
    head[f]=cnt;
}
int size[N];
void dfs(int x,int fa){
    size[x]=1;
    for (int i=head[x];i;i=nxt[i]){
        int v=e[i];
        if (v==fa) continue;
        dfs(v,x);
        size[x]+=size[v];
    }
}
int cnt[N],fac[N],ifac[N],f[N],g[N];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);add(v,u);
    }
    dfs(1,0);
    cnt[n]=n;
    for (int i=2;i<=n;i++)
        cnt[size[i]]--,cnt[n-size[i]]--;
    for (int i=1;i<=n;i++)
        if (cnt[i]<0) cnt[i]+=p;
    fac[0]=1;
    for (int i=1;i<=n;i++) fac[i]=mul(fac[i-1],i);
    ifac[n]=power(fac[n],p-2);
    for (int i=n;i;i--) ifac[i-1]=mul(ifac[i],i);
    for (int i=0;i<=n;i++) g[i]=mul(cnt[i],fac[i]),f[i]=ifac[n-i];
    int size=1;
    while (size<=n+n) size<<=1;
    init(size);
    fft(size,f,w);fft(size,g,w);
    for (int i=0;i<size;i++) f[i]=mul(f[i],g[i]);
    fft(size,f,iw);
    for (int i=1;i<=n;i++) printf("%d\n",mul(f[i+n],ifac[i]));
    return 0;
}

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

int main() {

  long long int n, m;
  cin >> n >> m;

  vector< long long int > a, b, c, d;

  for ( long long int i = 0; i < n; i++ ) {

    long long int ina, inb;
    cin >> ina >> inb;
    a.push_back( ina );
    b.push_back( inb );

  }

  for ( long long int i = 0; i < m; i++ ) {

    long long int inc, ind;
    cin >> inc >> ind;
    c.push_back( inc );
    d.push_back( ind );

  }

  for ( long long int i = 0; i < n; i++ ) {

    long long int cnt = abs( a[i] - c[0] ) + abs( b[i] - d[0] );
    long long int ans = 0;

    for ( long long int j = 1; j < m; j++ ) {

      long long int k = abs( a[i] - c[j] ) + abs( b[i] - d[j] );
      if ( k < cnt ) {
	cnt = k;
	ans = j;
      }

    }

    cout << ans + 1 << endl;

  }

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(i) ((i)&(-(i)))
#define lson(i) ((i)<<1)
#define rson(i) ((i)<<1|1)
#define sqr(x) ((x)*(x))
#define fi first
#define se second
#define mp(x,y) make_pair((x),(y))
#define pb push_back
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef pair<int,int> pii;
typedef vector<int> vii;
typedef vector<pii> vpi;
typedef queue<int> qii;

const int inf=0x3f3f3f3f;
const int maxn=2e6+5;
const long long MOD=1e9+7;

char s[maxn],t[maxn];
int fail[maxn],refail[maxn];

void getfail(int *fail,char *s){
	fail[0]=-1;
	int i=0,j=-1;
	while(s[i]){
		if(j==-1 || s[i]==s[j]){
			fail[i+1]=j+1;
			i++;
			j++;
		}
		else{
			j=fail[j];
		}
	}
}

int main(){
	scanf("%s",&s);
	ll ans=0;
	int len=strlen(s);
	for(int i=0;s[i];i++){
		t[i]=s[len-i-1];
	}
	t[len]='\0';
	getfail(fail,s);
	getfail(refail,t);
	int m;
	if(fail[len]==0 || len%(len-fail[len])){
		m=1;
	}
	else{
		m=2;
	}
	bool flag=1;
	for(int i=1;s[i];i++){
		if(s[i]!=s[i-1]){
			flag=0;
		}
	}
	if(flag){
		m=len;
	}
	if(m==1 || flag){
		ans=1;
	}
	else{
		for(int i=0;i<len-1;i++){
			int k=len-i-1;
			if((fail[i+1]==0 || (i+1)%(i+1-fail[i+1])) && (refail[k]==0 || k%(k-refail[k]))){
				ans++;
				ans%=MOD;
			}
		}
	}
	cout<<m<<endl<<ans%MOD<<endl;
	return 0;
}

Measured memory_bytes: 10368