akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a,b,c;cin>>a>>b>>c;
  cout<<max((int)0,b+c-a)<<endl;
  return 0;
}

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

namespace VS_atcoder
{

    class Program
    {
        static void Main(string[] args)
        {


            String str = Console.ReadLine();

            int X = Int32.Parse(str.Split(' ')[0]);
            int Y = Int32.Parse(str.Split(' ')[1]);

            long minXY = X > Y ? X : Y;
            long max = (long)Math.Pow(10, 18);
            int min = Y > X ? Y / X : 2;

            for (int i = min > 1? min : 2; i < max; i++)
            {
                if (Y == 1 || X == Y || X % Y == 0) break;
                if ((X * i) % Y != 0)
                {
                    Console.WriteLine(X * i);
                    return;
                }



                if ((X * i) > max) break;
            }




            Console.WriteLine(-1);
            return;

        }


    }
}


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

typedef long long ll;
#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    string S;
    cin >> S;

    string a = S.substr(0,2);
    string b = S.substr(2,2);

    int n1 = stoi(a);
    int n2 = stoi(b);

    if( 0 < n1 && n1 <13 && 0 < n2 && n2 < 13){
        cout << "AMBIGUOUS" << endl;
    }else if( 0 < n1 && n1 <13 ){
        cout << "MMYY" << endl;
    }else if(0 < n2 && n2 < 13){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[101][4][2];
int main (){
    string N;
    int k;
    cin >> N >> k;
    vector<int> n(100,0);
    int l=N.size();
    for(int i=0;i<l;i++)
    n[i]=N[i]-'0';

    dp[0][0][0]=1;
    for(int i=0; i<l; i++){
        for(int j=0; j<4; j++){
            for(int smaller=0; smaller<2; smaller++){
                
                for(int x=0; x <= (smaller ? 9 : n[i]);x++){
                    //cout << x<< endl;
                   if(x==0) dp[i+1][j][smaller || (x<n[i])] += dp[i][j][smaller];
                   else if(j==3) continue;
                   else dp[i+1][j+1][smaller || (x<n[i])] += dp[i][j][smaller];
                }
            }
        }
    }
    
    cout << dp[l][k][0] + dp[l][k][1]  <<endl;

    return 0;

}

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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<Vec2> Red;
	vector<Vec2> Blue;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		Red.pb(Vec2(b, a));
	}
	rep(i, N) {
		int c, d;
		cin >> c >> d;
		Blue.pb(Vec2(c, d));
	}
	sort(ALL(Red),greater<Vec2>());
	sort(ALL(Blue));
	vector<bool> usedR(N,false);
	int ans = 0;
	rep(i, N) {
		auto blue = Blue[i];
		rep(j, N) {
			auto red = Red[j];
			if (red.second < blue.first and red.first < blue.second and !usedR[j]) {
				usedR[j] = true;
				ans++;
				break;
			}
			else {
				continue;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    R,S,P=MI()
    T=input()
    L=[]
    
    ans=0
    for i in range(N):
        pre="z"
        if i-K>=0:
            pre=L[i-K]
            
        if T[i]=="r":
            if pre!="p":
                ans+=P
                L.append("p")
            else:
                L.append("z")
                
        if T[i]=="s":
            if pre!="r":
                ans+=R
                L.append("r")
            else:
                L.append("z")

        if T[i]=="p":
            if pre!="s":
                ans+=S
                L.append("s")
            else:
                L.append("z")
                
    print(ans)
                
    

main()


Measured memory_bytes: 79876
<?php
$n = intval(fgets(STDIN));
echo getMap($n);
function getMap($n){
if($n <= 2){
    return -1;
}elseif($n == 3){
    return <<<HOGE
.aa
a..
a..
HOGE;
}elseif($n == 4){
    return <<<HOGE
abcc
abdd
eegh
ffgh
HOGE;
}elseif($n == 5){
    return <<<HOGE
aabbc
hii.c
h..jd
g..jd
gffee
HOGE;
}elseif($n == 6){
    return <<<HOGE
aabc..
ddbc..
..aabc
..ddbc
bc..aa
bc..dd
HOGE;
}elseif($n == 7){
    return <<<HOGE
..a..ax
..a..ax
aa.aa.y
..a..ay
..a..az
aa.aa.z
xxyyzz.
HOGE;
}else{
    for($i = 0; $i < $n; $i++){
        $str[] = str_repeat(".", $n);
    }
    $m = $n;
    while($m > 7){
        $four = explode("\n", getMap(4));
        $m-=4;
        for($j = 0; $j < 4; $j++){
            for($k = 0; $k < 4; $k++){
                $str[$m+$j][$m+$k] = $four[$j][$k];
            }
        }
    }
    $top = explode("\n", getMap($m));
    for($j = 0; $j < $m; $j++){
        for($k = 0; $k < $m; $k++){
            $str[$j][$k] = $top[$j][$k];
        }
    }
    return implode("\n", $str);
}
}


Measured memory_bytes: 7672
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
class Player
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');

        int CookieCount = int.Parse(s[0]);
        int HumanCount = int.Parse(s[1]);         

        Console.WriteLine(CookieCount % HumanCount == 0 ? 0 : 1);
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
int compa(const void *a,const void *b)
{
 return *(int*)a - *(int*)b;
}


int main(void)
{
 int A[200001];
 int N,N1,i;

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


 qsort(A,N,sizeof(int),compa);

 for(i=0;i<N-1;i++) 
 {
  if(A[i]==A[i+1]) 
   {
     printf("NO\n");
     return 0;
   }
 }

  printf("YES\n");

/*
 printf("%d\n",N);
*/


 return 0;
}

Measured memory_bytes: 1788
#include <stdio.h>
#include <algorithm>
#include <iostream>
 
using namespace std;
 
class Heap{
public:
    Heap(){
        array = new int[2000000];
        n = 0;
    }
    void insert(int data){
        array[n] = data;
        int tmp = n;
        while(tmp != 0 && array[tmp] > array[(tmp-1)/2]){
            std::swap(array[tmp], array[(tmp-1)/2]);
            tmp = (tmp-1)/2;
        }
        n++;
    }
void max_heapify(int* array, int start, int end)
{
	int dad = start;
	int son = dad * 2 + 1;

	while (son <= end)
	{
		if (array[son] < array[son+1] && son+1 <= end)
			son++;
		if (array[dad] > array[son])
			return;
		else
		{
			swap(array[son], array[dad]);
			dad = son;
			son = dad * 2 + 1;
		}
		
	}
}

int heap_sort(int* array, int len)
{
	int i;
        swap(array[0],array[len-1]);
        max_heapify(array,0,len-2);
        return array[len-1];
}
    int extract(){
    int ret = heap_sort(array,n);
    n--;
    return ret;
    }
 
private:
    int* array;
    int n;
};
 
int main(){
 
    int insert_data;
    char buf[22];
    Heap heap;
 
    while(true){
        fgets(buf,22,stdin);
        if(buf[2] == 'd') break;
        if(buf[0] == 'i'){
            insert_data = 0;
            for(int i = 0; buf[i] != '\0';i++){
                if(buf[i] >= '0' && buf[i] <= '9'){
                    insert_data = 10*insert_data + (buf[i] - '0');
                }
            }
            heap.insert(insert_data);
        }else{
            printf("%d\n",heap.extract());
        }
    }
}


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

int array[251];

int main(){
    int H, i;
    
    scanf("%d", &H);
    
    for(i=0; i < H; i++){
        scanf("%d", &array[i]);
    }
    
    for(i = 0; i < H; i++){
        printf("node %d:", i+1);
        printf(" key = %d,", array[i]);
        if((i-1) >= 0) printf(" parent key = %d,", array[(i-1)/2]);
        if(2*i + 1 < H) printf(" left key = %d,", array[2*i + 1]);
        if(2*i + 2 < H) printf(" right key = %d,", array[2*i + 2]);
        printf(" \n");
    }
    return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int x[105];
  for(int i = 0; i< N; i++){
    cin >> x[i];
  }
  int ans = 10000001;
  for(int i = 1; i < 101; i++){
    int sum = 0;
    for(int j = 0; j < N;j++){
      sum+= (x[j]-i)*(x[j]-i);
    }
    ans=min(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++)
            //A[i] = (int)(Math.random()*200);
            A[i] = sc.nextInt();
        boolean[] up = new boolean[N];
        boolean allup = true;
        for (int i = 1; i < N; i++) {
            up[i - 1] = A[i - 1] < A[i];
            allup &= up[i-1];
        }
        /*
        if(allup){
            System.out.println("1000");
            return;
        }*/

        //System.err.println(Arrays.toString(A));
        //System.err.println(Arrays.toString(up));
        long sum = 1000;
        long buy = 0;
        for (int i = 0; i < N; i++) {
            if (up[i]) {
                long p = sum/A[i];
                buy += p;
                sum -= A[i]*p;
               // System.err.println("buy "+A[i]+"   "+sum);
            } else {
                sum += A[i] * buy;
                buy = 0;
                //System.err.println("sell "+A[i]+"   "+sum);
            }
        }
        System.out.println(sum);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35848
v=[[3*M=998244353,s=1]]
`sort -nr`.lines{|e|x,d=e.split.map &:to_i
d&&(r=1
r*=v.pop[1]while v[-1][0]<x+d
v<<[x,r%M+1])}
v.map{|_,y|s=s*y%M}
p s

Measured memory_bytes: 25076
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    if (a+b>9) {
        cout << "error" << endl;
    }
    else {
        cout << a+b << endl;
    }
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

vector<vector<int>> Edge(10005);
vector<bool> seen(10005);

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    long long N,K;cin >> N >> K;
    long long ans = 0;
    //bを固定して考える
    for(long long i = K+1;i<=N;i++){
        //余りは0,1,2…i-1の繰り返し
        long long group = (N+1)/i;
        long long aboveK = group*(i-K);
        //cout << aboveK << " ";
        //余りの部分
        aboveK += max((N-group*i)-K+1,(long long)0);
        ans += aboveK;
        if(K == 0) ans--;
        //cout << ans << endl;
    }
    cout << ans << endl;

}


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

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

void solve() {
  int n;
  cin >> n;
  cout << (n < 1200 ? "ABC" : "ARC") << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
from collections import deque
def solve():
    solved = set()

    N,M = map(int, input().split())
    wa = [0]*(N+1)
    pn = 0
    for i in range(M):
        p,s = input().split()

        if s == "AC":
            if not (p in solved):
                solved.add(p)
                pn += wa[int(p)]
        else:
            if not (p in solved):
                wa[int(p)] += 1
    print(len(solved), pn)



if __name__ == '__main__':
    solve()

Measured memory_bytes: 15200
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def make_adj_list(n, E):
    l = [[] for _ in range(n)] # 隣接リスト. 各要素は(コスト、to_node)
    for i in range(E):
        s, t, d = map(int, input().strip().split())
        l[s].append([d, t])
    return l

def bellman_ford(n, s, l):
    # s: start node, n: num of node
    # return True: negative cycle
    dist = [INF] * n
    dist[s] = 0
    for i in range(n):
        for v in range(n):
            for k in range(len(l[v])):
                cost, to = l[v][k]
                if dist[v] != INF and dist[to] > dist[v] + cost:
                    dist[to] = dist[v] + cost
                    if i == n-1:
                        return (True, dist)
    return (False, dist)

def main():
    v, e, r = map(int, input().strip().split())
    l = make_adj_list(v, e)
    is_negative_cycle, dist = bellman_ford(v, r, l)
    if is_negative_cycle:
        print("NEGATIVE CYCLE")
        return
    for d in dist:
        if d == INF:
            print('INF')
        else:
            print(d)

if __name__ == '__main__':
    main()



Measured memory_bytes: 6156
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
		long c = long.Parse(input[2]);
		Console.WriteLine(a*b/2);
	}
}

Measured memory_bytes: 11092
/**
*    created: 12.07.2020 12:43:45
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b) * (h/2) << endl;
    return 0;
}

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

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

    double aver = (double)sum / n;
    double mn = fabs(aver - a[0]);
    int index = 0;
    for(int i = 1; i < n; i++)
    {
        if(fabs(aver - a[i]) < mn)
        {
            mn = fabs(aver - a[i]);
            index = i;
        }
    }

    cout << index << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int comp(const void *p,const void *q){
	return *(int *)q - *(int *)p;
}
int main(){
	int a[1005],n,m,i,ans;
	while(scanf("%d%d",&n,&m)!=EOF){
		if(n==0 && m==0)break;ans=0;
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		qsort(a,n,sizeof(int),comp);
		for(i=0;i<n;i++){
			if((i+1)%m!=0)ans+=a[i];
		}
		printf("%d\n",ans);
	}
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define REP(i,n) for(int i=0; i < (n); ++i)
#define SIZE(c) (int) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
#define FWD(i,a,b) for (int i=(a); i<(b); ++i)
#define BCK(i,a,b) for (int i=(a); i>(b); --i)
#define PI 3.14159265358979311600
#define pb push_back
#define mp make_pair
#define st first
#define nd second

using namespace std;

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

typedef vector < int > VI;
typedef vector<ll> VL;

typedef long double K;

const int N = 200005;
const int mod = 1000*1000*1000+7;

int n, x, y, fact[N], ifact[N];
vector<int> g[N];

int power(int a, int n) {
	int result = 1;
	while (n > 0) {
		if (n & 1) {
			result = (1LL * result * a) % mod;
		}
		a = (1LL * a * a) % mod;
		n /= 2;
	}
	return result;
}

int inv(int a) {
	return power(a, mod - 2);
}

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

	cin >> n >> x >> y;
	REP(i, n) {
		int c, w;
		cin >> c >> w;
		g[c - 1].push_back(w);
	}

	multiset<int> s;
	vector<int> sizes;
	int all = 0;

	REP(i, n) if (!g[i].empty()) {
		sort(g[i].begin(), g[i].end());
		s.insert(g[i][0]);
	}
	REP(i, n) if (!g[i].empty()) {
		int val = x - g[i][0];
		int can = 0;
		s.erase(s.find(g[i][0]));
		if (!s.empty()) {
			val = max(val, y - (*s.begin()));
			if ((*s.begin()) + g[i][0] <= y) {
				can = 1;
			}
		}
		s.insert(g[i][0]);
		int cnt = upper_bound(g[i].begin(), g[i].end(), val) - g[i].begin();
		cnt = max(cnt, 1);
		if (can) {
			sizes.push_back(cnt);
			all += cnt;
		}
	}

	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fact[i] = (1LL * fact[i - 1] * i) % mod;
		ifact[i] = inv(fact[i]);
	}

	int result = fact[all];
	for(auto& item : sizes) {
		result = (1LL * result * ifact[item]) % mod;
	}

	cout << result << '\n';

	return 0;
}

Measured memory_bytes: 18044
#include<bits/stdc++.h>
using namespace std;
#define end(n) (s.substr(s.length()-n,n))
int main(){
  string s;
  int l;
  cin>>s;
  while(l=s.length()){
    if(end(5)=="dream"||end(5)=="erase")s=s.substr(0,l-5);
    else if(end(6)=="eraser")s=s.substr(0,l-6);
    else if(end(7)=="dreamer")s=s.substr(0,l-7);
    else {cout<<"NO";return 0;}
  }
  cout<<"YES";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=10000;
const int Max = 1e6+10;
const double pi = acos(-1);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
    int n;
    cin>>n;
    VI a(n+1,0);
    rep(i,2,n+1){
        int t;
        cin>>t;
        a[t]++;
    }
    rep(i,1,n+1)cout<<a[i]<<endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






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

int main()
{
	string o, e;
	char s[100];
	cin >> o >> e;
	for (int i = 0; i < o.size(); i++) {
		s[2 * i] = o[i];
	}
	for (int i = 0; i < e.size(); i++) {
		s[2 * i + 1] = e[i];
	}
	for (int i = 0; i < o.size() + e.size(); i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define alll(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define endl '\n'

int nxt[200005][25];
int a[200005], vis[25];
int main()
{
    int n;
    cin >> n;
    ii cin >> a[i];
    for(int i=0;i<20;++i) vis[i]=n+1;
    for(int i=n;i>=1;--i) {
        for(int j=0;j<20;++j) {
            nxt[i][j] = vis[j];
            if(a[i] & (1<<j)) vis[j] = i;
        }
    }
    ll ans = 0;
    int R = n+1;
    for(int i=n;i>=1;--i) {
        int r = n+1;
        for(int j=0;j<20;++j) {
            if(a[i] & (1<<j)) r = min(r, nxt[i][j]);
        }
        R = min(R, r);
        ans += R - i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 20608
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
int main(){
    cout << fixed << setprecision(10);
    ll a,b,c;
    cin >> a >> b >> c;
    if(4ll*a*b < (c-a-b)*(c-a-b) && c-a-b >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e3 + 10; 

int n,x,y;
int ans[maxn];

int main()
{
	fastIO;
	cin >> n >> x >> y;
	int mid = (x + y) / 2;
	rep(i,1,n) {
		ans[i] = n - i;
	}
	rep(i,1,x + mid) {
		rep(j,mid + 1,n + 1){
			int l1 = j - i, l2 = abs(x - i) + abs(j - y) + 1;
			if(l1 > l2){
				ans[j - i]--;
				ans[abs(x - i) + abs(j - y) + 1]++;
			}
		}
	}

	/*
	rep(i,x + 1, mid){
		rep(j,y, n + 1) {
			ans[i - x + j - y]++;
			ans[j - i]--;
		}
	}
	rep(i,mid + 1,y){
		rep(j,1,x + 1){
			ans[y - i + x - j]++;
			ans[i - j]--;
		}
	}
	*/
	rep(i,1,n) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	vector<int>vec(N);
	rep(i, N) {
		cin >> vec[i];
	}

	sort(vec.begin(), vec.end());
	int A = vec[N / 2] - vec[N / 2 - 1];

	cout << A << endl;
}

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

#define int long long int

int32_t main()
{
    int n;
    cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++)
  {
      int x,y;
      cin>>x>>y;
      ans+=abs(x-y)+1;
  }
    cout<<ans<<endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

template<typename T>
void trace(T *a, int s, int n) {
    for (int i=s; i<n; i++) {
	cout<<a[i]<<" ";
    }
    cout<<endl;
}



typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6+10;

const int M = 2000;
const int off = 50000;

string a,b,c;

bool ab[maxn], bc[maxn], ac[maxn]; //true: if this shift is good

bool same(char x, char y) {
    return x=='?'||y=='?'||x==y;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>a>>b>>c;

    for (int i=0; i<(int)a.length(); i++) {
	for (int j=0; j<(int)b.length(); j++) {
	    if (!same(a[i],b[j])) ab[i-j+off]=true;
	}
    }

    for (int i=0; i<(int)a.length(); i++) {
	for (int j=0; j<(int)c.length(); j++) {
	    if (!same(a[i],c[j])) ac[i-j+off]=true;
	}
    }

    for (int i=0; i<(int)b.length(); i++) {
	for (int j=0; j<(int)c.length(); j++) {
	    if (!same(b[i],c[j])) bc[i-j+off]=true;
	}
    }


    int ans = 3*M;

    for (int i=-2*M; i<=2*M; i++) {//b's shift
	for (int j=-2*M; j<=2*M; j++) {//c's shift
	    if (!ab[i+off] && !bc[j-i+off] && !ac[j+off]) {
		int L = min({0, i, j});
		int R = max({(int)a.length(), (int)b.length()+i, (int)c.length()+j});
		ans = min(ans, R-L);
	    }
	}
    }

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


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
  int n,i,l,j,k,p[N+1],m[N+1][N+1];
  scanf("%d",&n);
  for(i =1;i <= n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i =1;i <= n;i++) m[i][i] = 0;
  for(l =2;l <= n;l++){
    for(i =1; i<= n - l + 1; i++){
      j = i + l - 1;
      m[i][j] = (1<<21);
      for(k = i;k <= j - 1;k++){
        if(m[i][j] > m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]){
          m[i][j] = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
        }
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 8;
string s;
int a[MAXN];
int main()
{
    #ifdef LOCAL
    int T = 1;
    while(T--){
    #endif
    LL n, i, l, r, mid;
    bool f;
    cin >> n;
    l = 0, r = n - 1;
    cout << l << "\n"; fflush(stdout);
    cin >> s;
    if(s[0] == 'M'){
        a[l] = 1;
    }
    else if(s[0] == 'F'){
        a[l] = 2;
    }
    else{
        a[l] = -1;
        return 0;
    }
    cout << r << "\n"; fflush(stdout);
    cin >> s;
    if(s[0] == 'M'){
        a[r] = 1;
    }
    else if(s[0] == 'F'){
        a[r] = 2;
    }
    else{
        a[r] = -1;
        return 0;
    }
    while(l + 1 < r){
        mid = (l+r)>>1;
        cout << mid << "\n"; fflush(stdout);
        cin >> s;
        if(s[0] == 'M'){
            a[mid] = 1;
        }
        else if(s[0] == 'F'){
            a[mid] = 2;
        }
        else{
            a[mid] = -1;
            return 0;
        }
 
        if((r - mid - 1)&1){
            if(a[mid] == a[r]){
                r = mid;
            }
            else{
                l = mid;
            }
        }
        else{
            if(a[r] != a[mid]){
                r = mid;
            }
            else{
                l = mid;
            }
        }
    }
    #ifdef LOCAL
    cout << endl;
    }
    #endif // LOCAL
    return 0;
}

Measured memory_bytes: 852
import java.io.*;
class Main{
    public static void main(String[] args)throws IOException{

	BufferedReader br = null;
	String buf;
	boolean line = true;
	try{
	    br = new BufferedReader(new InputStreamReader(System.in));
	    while((buf = br.readLine()) !=null){
		int[] year = new int[2];
		for(int i=0;i<year.length;i++){
		    year[i]= Integer.parseInt(buf.split(" ")[i]);
		}
		if(year[0] == year[1] && year[0] ==0)break;
		if(line){
		    line = false;
		}else{
		    System.out.println();}
		boolean check = false;
		for(int i = year[0];i<=year[1];i++){
		    if(i%4==0 && (i%100 != 0 || i%400 == 0)){
			check = true;
			System.out.printf("%d\n",i);
		    }
		}
		if(!check){
		    System.out.println("NA");
		}
	    }
	}finally{
	    if(br !=null){
		br.close();
	    }    
	}
    }   
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
const int INF = INT_MAX / 2;

class C{
    public:
        string str;
        int step;
        C(string _str, int _step);
};

C::C(string _str, int _step){
    str = _str;
    step = _step;
}

int main(){
    queue<C> open;
    open.push( C("01234567", 0) );
    map<string, int> ans;

    while(!open.empty()){
        C now = open.front();
        open.pop();

        if(ans.find(now.str) != ans.end() && ans[now.str] <= now.step){
            continue;
        }

        ans[now.str] = now.step;

        int zero;
        REP(i, now.str.size()) if(now.str[i] == '0') zero = i;
        int mv[] = {1, -1, 4, -4};

        REP(i, 4){
            if(zero + mv[i] >= now.str.size()) continue;
            if(zero + mv[i] < 0) continue;
            if(zero == 3 && zero + mv[i] == 4) continue;
            if(zero == 4 && zero + mv[i] == 3) continue;
            string tmp = now.str;
            swap(tmp[zero], tmp[zero + mv[i]]);
            open.push( C(tmp, now.step + 1) );
        }
    }
    while(true){
        string fir_inp, inp = "";
        if(!getline(cin, fir_inp)) break;
        stringstream ss(fir_inp);
        while(ss >>fir_inp) inp += fir_inp;
        cout <<ans[inp] <<endl;
    }
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int a[n];
  int sum = 0;
  for(int i = 0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  double b = (double)sum /(4*m);
  int count = 0;
  for(int i = 0;i<n;i++){
    if(a[i]>=b)count++;
  }
  if(count >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    a=0
    for i in range(N-2):
        a+=1 if S[i:i+3]=="ABC" else 0
    print(a)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    scanf("%d", &i);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    scanf("%lld", &i);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';

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

ll sn(int n)
{
    return (ll)n * (n+1) / 2;
}

int main()
{
    int N;
    io >> N;

    ll ans = 0;
    for (int k = 1; k <= N; k++)
    {
        ans += sn(N/k) * k;
    }
    io << ans << BR;
}

Measured memory_bytes: 3780
#include <iostream>
#include <string>
#define SIZE 100

using namespace std;

string shuffle(string, int);

int main(void){

	while (1) {
		string str;
		int m;
		int h[SIZE];

		cin >> str;
		if (str == "-") break;

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

		for (int i = 0; i < m; i++) {
			str = shuffle(str, h[i]);
		}

		cout << str << "\n";
	}
	
	return 0;
}

string shuffle(string str, int h) {
	string buf;
	buf = str.substr(0, h);
	str.erase(str.begin(), str.begin() + h);
	str += buf;
	return str;
}

Measured memory_bytes: 3192
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

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

  a = (a == 1 ? 14 : a);
  b = (b == 1 ? 14 : b);

  if(a > b) cout << "Alice" << endl;
  else if(a < b) cout << "Bob" << endl;
  else cout << "Draw" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i, n)
  {
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
A=[]
answer=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=[int(input()) for i in range(N)]
for j in range(N):
    for k in range(3):
        for l in range(3):
            if B[j]==A[k][l]:
                answer[k][l]=1
i=0
J=0
for i in range(3):
    if answer[i][0]==answer[i][1]==answer[i][2]==1:
        print("Yes")
        J=J+1
        break
    elif answer[0][i]==answer[1][i]==answer[2][i]==1:
        J=J+1
        print("Yes")
        break
if J==0 and answer[0][0] == answer[1][1] == answer[2][2] == 1:
    J=J+1
    print("Yes")
if J == 0 and answer[0][2] == answer[1][1] == answer[2][0]== 1:
    J=J+1
    print("Yes")
if J == 0:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> count(n, 0);
    for(int i = 0; i < q; ++i){
        ll ai;
        cin >> ai;
        ai--;
        count.at(ai)++;
    }
    for(int i = 0; i < n; ++i){
        if(k - q + count.at(i) > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
n, m = STDIN.gets.chomp.split(" ").map{|x| x.to_i}
data = Array.new(m, 0)

for i in 1..n do
  d = STDIN.gets.chomp.split(" ").map{|x| x.to_i}
  d = d[1..-1]
  d.each{|y| data[y-1] += 1}
end

cnt = 0
data.each{|x|
  if x==n
    cnt +=1
  end
  }

puts cnt

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

using namespace std;

const int inf = 1 << 29;

int main(){
  int N; cin >> N;
  if( N%10 == 9 || N >= 90){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using std::min;
using std::max;
using std::swap;
using std::vector;
typedef double db;
typedef long long ll;
#define pb(A) push_back(A)
#define pii std::pair<int,int>
#define all(A) A.begin(),A.end()
#define mp(A,B) std::make_pair(A,B)
#define inv(X) ksm(X,mod-2)
const int N=2e6+5;
const int mod=1e9+7;

int x[8],y[8];
int fac[N],ifac[N];

struct Node{
    int x,y,type;
    Node(){}
    Node(int a,int b,int c=0){x=a,y=b,type=c;}
}node[10];

int ksm(int x,int y,int ans=1){
    while(y){
        if(y&1) ans=1ll*ans*x%mod;
        x=1ll*x*x%mod;y>>=1;
    } return ans;
}

int getint(){
    int X=0,w=0;char ch=getchar();
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while( isdigit(ch))X=X*10+ch-48,ch=getchar();
    if(w) return -X;return X;
}

int C(int n,int m){
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int G(int x1,int x2,int y1,int y2){
    return C(abs(x2-x1)+abs(y2-y1),abs(x2-x1));
}

int G(Node a,Node b){
    return C(abs(a.x-b.x)+abs(a.y-b.y),abs(a.x-b.x));
}

int cal(Node a,Node b){
    int ans=0;
    for(int i=x[3];i<=x[4];i++){
        ans=(1ll*ans-1ll*G(a,Node(i,y[3]-1))*G(Node(i,y[3]),b)%mod*(i+y[3])%mod+mod)%mod;
        ans=(1ll*ans+1ll*G(a,Node(i,y[4]))*G(Node(i,y[4]+1),b)%mod*(i+y[4]+1)%mod)%mod;
    }
    for(int i=y[3];i<=y[4];i++){
        ans=(1ll*ans-1ll*G(a,Node(x[3]-1,i))*G(Node(x[3],i),b)%mod*(i+x[3])%mod+mod)%mod;
        ans=(1ll*ans+1ll*G(a,Node(x[4],i))*G(Node(x[4]+1,i),b)%mod*(i+x[4]+1)%mod)%mod;
    } return (1ll*ans*a.type*b.type+mod)%mod;
}

signed main(){
    fac[0]=ifac[0]=1;
    for(int i=1;i<=N-5;i++) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[N-5]=inv(fac[N-5]);
    for(int i=N-6;i;i--) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
    for(int i=1;i<=6;i++) x[i]=getint();
    for(int i=1;i<=6;i++) y[i]=getint();
    node[1]=Node(x[1]-1,y[1]-1,1);node[2]=Node(x[2],y[1]-1,-1);
    node[3]=Node(x[1]-1,y[2],-1); node[4]=Node(x[2],y[2],1);
    node[5]=Node(x[5],y[5],1);    node[6]=Node(x[6]+1,y[5],-1);
    node[7]=Node(x[5],y[6]+1,-1); node[8]=Node(x[6]+1,y[6]+1,1);
    ll ans=0;
    for(int i=1;i<=4;i++)
        for(int j=5;j<=8;j++)
            ans=((ans+cal(node[i],node[j]))%mod+mod)%mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,k;
    int arr[1000]={0};
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int inp;
        cin>>arr[i];
    }
    int tmp;
    for(int i=n-1;i>0;i--){
        for(int j=0;j<=i-1;j++){
            if(arr[j]>arr[j+1]){
                tmp = arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=tmp;    
            }
        }
    }
    int ans=0;
    for(int i=0;i<k;i++){
        ans = ans + arr[i];
    }
    cout<<ans;


}  

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

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n;
    cin >> n;
    string s = "";
    int k;

    while (n)
    {
        k = n % 26;
        if (k == 0)
        {
            s += 'z';
        }
        else
        {
            s += k + 'a' - 1;
        }
        n--;
        n = n / 26;
    }
    reverse(s.begin(), s.end());
    cout << s;

    return 0;
}


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

int main (void) {
    int n, q, t;
    string name;

    queue<pair<string,int> > Q;

    cin >> n >> q;

    for ( int i = 0 ; i < n ; i++ ) {
        cin  >> name >> t;
        Q.push( make_pair(name , t));
    }

    int sum = 0, a;
    pair<string,int> u;
    while (!Q.empty()) {
        u = Q.front();
        Q.pop();

        a = min(u.second, q);
        u.second -= a;
        sum += a;

        if(u.second > 0) {
            Q.push(u);
        } else {
            cout << u.first << " " << sum << "\n";
        }

    }

    return 0;
}

Measured memory_bytes: 6172
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
A, B, C = ri_()
print('Yes' if A == B and B == C else 'No')

Measured memory_bytes: 63340
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define ci(n) cin >> n
#define ci2(n, o) cin >> n >> o
#define ci3(n, o, p) cin >> n >> o >> p
#define co(n) cout << n << endl
#define mp(n, o) map<n, o>
#define so(n) sort(n.begin(), n.end())
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗

int main() {
  int N, L, a = 0, b = 1000;
  ci2(N, L);
  ve(int) A(N);
  rep(i, N) {
    A.at(i) = L + i;
  }
  rep(i, N) {
    if(abs(b) > abs(A.at(i))) {
      b = A.at(i);
    }
    a += A.at(i);
  }
  co(a - b);
} 

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

int cmp(const void* x, const void* y) {
	int a = *(const int*)x;
	int b = *(const int*)y;
	if (a < b) return -1;
	return a > b;
}

int N, M;
int next_num[1024];
int next[1024][1024];

int inv_num[1024];
int inv[1024][1024];
int group[1024];

int count_count;
int count[1024][2];

int ayaneru(int node, int g) {
	int i, ng = (g == 1 ? 2 : 1);
	if (group[node] != 0) {
		/* 同じノードが別の州でなければならない → 矛盾 */
		return group[node] == g;
	}
	group[node] = g;
	count[count_count][g - 1]++;
	for (i = 0; i < inv_num[node]; i++) {
		if (!ayaneru(inv[node][i], ng)) return 0;
	}
	return 1;
}

int memo[1024][1024];

int kitaeri(int cpos, int acc) {
	int c1, c2;

	if (cpos >= count_count) return acc;
	if (memo[cpos][acc]) return ~memo[cpos][acc];

	c1 = kitaeri(cpos + 1, acc + count[cpos][0]);
	c2 = kitaeri(cpos + 1, acc + count[cpos][1]);

	return ~(memo[cpos][acc] = ~((abs(c1 - (N / 2)) <= abs(c2 - (N / 2))) ? c1 : c2));
}

int main(void) {
	int i;
	int hayamin;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		int A, B;
		if (scanf("%d%d", &A, &B) != 2) return 1;
		A--;
		B--;
		next[A][next_num[A]++] = B;
		next[B][next_num[B]++] = A;
	}
	for (i = 0; i < N; i++) {
		qsort(next[i], next_num[i], sizeof(next[i][0]), cmp);
	}
	/* 結ばれていない = 「絶対別の州」関係 */
	for (i = 0; i < N; i++) {
		int j, ptr = 0;
		for (j = 0; j < N; j++) {
			if (i == j) continue;
			else if (ptr < next_num[i] && j == next[i][ptr]) {
				ptr++;
			} else {
				inv[i][inv_num[i]++] = j;
			}
		}
	}
	for (i = 0; i < N; i++) {
		if (group[i] == 0) {
			if (!ayaneru(i, 1)) {
				puts("-1");
				return 0;
			}
			count_count++;
		}
	}
#if 0
	/* test */
	for (i = 0; i < count_count; i++) {
		printf("%10d %10d\n", count[i][0], count[i][1]);
	}
#endif
	hayamin = kitaeri(0, 0);
	printf("%d\n", hayamin * (hayamin - 1) / 2 + (N - hayamin) * (N - hayamin - 1) / 2);
	return 0;
}


Measured memory_bytes: 10364
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[2010];
    rep(i, N) cin >> A[i];
    int ans = 0;
    rep(i, N) {
        int cntL = 0, cntR = 0;
        rep(j, N) {
            if (i < j && A[i] > A[j]) cntR++;
            else if (j < i && A[i] > A[j]) cntL++;
        }
        int tmpL = (cntL * (((K) * (K - 1)/2) % mod)) % mod;
        int tmpR = (cntR * (((K * (K + 1)) / 2) % mod)) % mod;
        ans = (ans + tmpL + tmpR) % mod;
        //cout << i << " " << cntL << " " << cntR << " "  << ans << endl;
    }
    cout << ans << endl;
    return 0;
}
// 2 1 2 1 2 1


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

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	int a,b,c;
	while(cin>>a>>b>>c){
		bool num[11]={};
		num[a]=num[b]=num[c]=true;

		int now=a+b;
		int sum=0;
		for(int i=1;i<=10;i++){
			if(num[i]==false && now+i<=20)sum++;
		}
		if(sum>=4)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1148