akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

int x[700];
int d[700][700];
int c[701][1401];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, n)c[i][i] = 1;
	REP(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--, b--;
		c[b][a] = c[a][b] = 1;
	}
	VI v;
	memset(x, -1, sizeof(x));
	REP(i, n){
		if (x[i] != -1) continue;
		x[i] = 0;
		deque<int> q;
		q.push_back(i);
		int cnt = 0;
		while (!q.empty()) {
			auto t = q.front();
			q.pop_front();
			if (x[t] == 0)cnt++;
			else cnt--;
			REP(j, n) {
				if (c[t][j] == 0) {
					if (x[j] != -1) {
						if (x[t] == x[j]) {
							cout << -1 << endl;
							return 0;
						}
						continue;
					}
					x[j] = 1 - x[t];
					q.push_back(j);
				}
			}
		}
		v.PB(cnt);
	}
	d[0][0] = 1;
	REP(i, v.size()) {
		REP(j, n) {
			d[i + 1][abs(j - v[i])] |= d[i][j];
			d[i + 1][j + v[i]] |= d[i][j];
		}
	}
	REP(i, n) {
		if (d[v.size()][i]) {
			int r1 = (n + i) / 2;
			int r2 = (n - i) / 2;
			cout << (r1*(r1 - 1)) / 2 + (r2*(r2 - 1)) / 2 << endl;
			return 0;
		}
	}
	return 0;
}

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

int main () {
	int n;
	cin>>n;
	int a[n];
	for (int i = 1; i <= n; i++) {
		cin>>a[i];
	}
	int ans=1e9;
	for (int i=1;i<=100;i++){
		int s=0;
		for (int j=1;j<=n;j++){
			s+=pow(abs(i-a[j]),2);
		}
		//cout<<i<<" "<<ans<<endl;
		ans=min(ans,s);
		//cout<<ans<<endl;
	}
	cout<<ans;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
float a,b,c,d,e,f,g,h,k,l,m,n,o,p; //(a,b),(c,d),(e,f),(g,h) are coordinates. Others are variables.
while(scanf("%f%f%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f,&g,&h)==8){; //Take input.

k = e*(b-d) + f*(c-a) + a*d - b*c;
l = g*(b-d) + h*(c-a) + a*d - b*c;

m = a*(f-d) + b*(c-e) + e*d - f*c;
n = g*(f-d) + h*(c-e) + e*d - f*c;

o = c*(b-f) + d*(e-a) + a*f - b*e;
p = g*(b-f) + h*(e-a) + a*f - b*e;

// If the point lies on side of triangle. I think this needs some modification.
if ((k/l>=0) && (m/n>=0) && (o/p>=0)) printf("YES\n");
else printf("NO\n");
}
return 0;
}

Measured memory_bytes: 608
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, a, b, c = LI()
A = [a, b, c]
K = [II() for _ in range(n)]


def DFS(cur, x, y, z):
    if cur == n:
        return abs(x - a) + abs(y - b) + abs(z - c) - 30 if min(x, y, z) > 0 else INF
    ret0 = DFS(cur + 1, x, y, z)
    ret1 = DFS(cur + 1, x + K[cur], y, z) + 10
    ret2 = DFS(cur + 1, x, y + K[cur], z) + 10
    ret3 = DFS(cur + 1, x, y, z + K[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(DFS(0, 0, 0, 0))


Measured memory_bytes: 3064
<?php
$case = 0;
while(true){
    $input_line = fgets(STDIN);
    $W = str_replace(array("\r\n","\r","\n"), '', $input_line);
    $input_line = fgets(STDIN);
    $N = str_replace(array("\r\n","\r","\n"), '', $input_line);    
    if($W == 0) {
        break;
    }
    $case++;
    $array_v = array(-1);
    $array_w = array(-1);
    for($i = 0; $i < $N; $i++){
        $input_line = fgets(STDIN);
        $input_line = str_replace(array("\r\n","\r","\n"), '', $input_line);
        $array = explode(",", $input_line);
        array_push($array_v, $array[0]);
        array_push($array_w, $array[1]);
    }
    $dp = array();
    $dp_w = array();
    for($i = 0; $i <= $N; $i++){
        for($j = 0; $j <= $W; $j++){
            $x = 0;
            $y = 0;
            $x_w = 0;
            $y_w = 0;
            if($i == 0){
                $dp[$i][$j] = 0;
                $dp_w[$i][$j] = 0;
            } else{
                $x = $dp[$i - 1][$j];
                $x_w = $dp_w[$i - 1][$j];
                if($array_w[$i] <= $j) {
                    $y = $dp[$i - 1][$j - $array_w[$i]] + $array_v[$i];
                    $y_w = $dp_w[$i - 1][$j - $array_w[$i]] + $array_w[$i];
                }
                $dp[$i][$j] = ($x > $y) ? $x : $y;
                $dp_w[$i][$j] = ($x > $y) ? $x_w : $y_w;
            }

        }
        //不要なメモリ解放
        if ($i >= 2) {
            unset($dp[$i-2]);
        }

    }
    /*
     * デバッグ用出力
    for($i = 0; $i <= $N; $i++){
        echo $i."| ";
        for($j = 0; $j <= $W; $j++){
            echo $dp[$i][$j]." ";
        }
        echo "\n";
    }
    echo "weight;\n";
    for($i = 0; $i <= $N; $i++){
        echo $i."| ";
        for($j = 0; $j <= $W; $j++){
            echo $dp_w[$i][$j]." ";
        }
        echo "\n";
    }
    */
    $array_ans_w = array();
    for($j = 0; $j <= $W; $j++){
        if($dp[$N][$j] == $dp[$N][$W]){
            array_push($array_ans_w, $dp_w[$N][$j]);
        }
    }
    echo "Case {$case}:\n";
    echo $dp[$N][$W] . "\n";
    echo min($array_ans_w) . "\n";
}
?>


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

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

  bool hasYellow = false;

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;

    if (S == "Y") {
      hasYellow = true;
      break;
    }
  }

  cout << ((hasYellow == true) ? "Four" : "Three") << endl;
  return 0;
}

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

typedef long long LL;

int sum;

int main()
{
    for(int i=0;i<3;i++)
    {
        int a;
        cin>>a;
        sum+=a;
    }
    if(sum>=22)
        puts("bust");
    else
        puts("win");
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

void rotate(vector<PII>& pos){
  if(pos[0].first > 0) return;
  if(pos[0].first < 0)
	REP(i,SZ(pos)){
	  pos[i].first *= -1;
	  pos[i].second *= -1;
	}
  else{
	if(pos[0].second > 0){
	  REP(i,SZ(pos)){
		swap(pos[i].first, pos[i].second);
		pos[i].second *= -1;
	  }
	}
	else{
	  REP(i,SZ(pos)){
		swap(pos[i].first, pos[i].second);
		pos[i].first *= -1;
	  }
	}
  }
}

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

  while(true){
	int N; cin >> N; if(!N) break;
	vector< vector<PII> > lines(N+1);
	REP(i,N+1){
	  int m; cin >> m;
	  int x, y; cin >> x >> y;
	  for(int j=1;j<m;++j){
		int ax, ay;	cin >> ax >> ay;
		lines[i].PB(MP(ax-x, ay-y));
		x = ax, y = ay;
	  }
	}

	rotate(lines[0]);
	for(int i=1;i<=N;++i){
	  if(SZ(lines[0]) != SZ(lines[i])) continue;
	  rotate(lines[i]);
	  int j;
	  for(j=0;j<SZ(lines[0]);++j)
		if(lines[0][j] != lines[i][j])
		  break;
	  if(j == SZ(lines[0])){
		 cout << i << endl;
		 continue;
	  }
	  reverse(ALL(lines[i]));
	  rotate(lines[i]);
	  for(j=0;j<SZ(lines[0]);++j)
		if(lines[0][j] != lines[i][j])
		  break;
	  if(j == SZ(lines[0])){
		 cout << i << endl;
	  }
	}
	cout << "+++++" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1208
import java.io.BufferedReader
import kotlin.system.exitProcess

fun main() {
    fun modPow(n: Long, k: Int, m: Long): Long {
        if (k == 0) {
            return 1L
        }
        var half = modPow(n, k shr 1, m)
        half *= half
        if (k and 1 == 1) {
            half %= m
            half *= n
        }
        return half % m
    }

    fun gcd(p: Int, q: Int): Int {
        return if (p == 0) q
        else if (q == 0) p
        else if (p and 1 == 0 && q and 1 == 0) gcd(p shr 1, q shr 1) shl 1
        else if (p and 1 == 0) gcd(p shr 1, q)
        else if (q and 1 == 0) gcd(p, q shr 1)
        else if (p > q) gcd((p - q) shr 1, q)
        else gcd(p, (q - p) shr 1)
    }

    val br = System.`in`.bufferedReader()
    var k = br.readInt()
    if (k % 7 == 0) {
        k /= 7
    }
    k *= 9

    if (k % 2 == 0 || k % 5 == 0) {
        print(-1)
        exitProcess(0)
    }

    var x = 1
    while (true) {
        if (modPow(10L, x, k.toLong()) == 1L) {
            print(x)
            exitProcess(0)
        }
        x++
    }
//    var lcm = 1
//    var i = 2
//    while (i * i <= k) {
//        var factor = 1
//        while (k % i == 0) {
//            factor *= i
//            k /= i
//        }
//        if (i == 3) {
//            factor /= 9
//            lcm = lcm * factor / gcd(lcm, factor)
//        } else if (factor != 1) {
//            var totient = (factor / i) * (i - 1)
//            while (totient and 1 == 0 && modPow(10L, totient shr 1, factor.toLong()) == 1L) {
//                totient /= 2
//            }
//
//            var temp = totient
//            while (temp and 1 == 0) {
//                temp /= 2
//            }
//            if (modPow(10L, totient / temp, factor.toLong()) == 1L) {
//                totient /= temp
//            }
//
//            lcm = lcm * totient / gcd(lcm, totient)
//        }
//        i++
//    }
//    if (k != 1) {
//        var totient = k - 1
//        while (totient and 1 == 0 && modPow(10L, totient shr 1, k.toLong()) == 1L) {
//            totient /= 2
//        }
//        var temp = totient
//        while (temp and 1 == 0) {
//            temp /= 2
//        }
//        if (modPow(10L, totient / temp, k.toLong()) == 1L) {
//            totient /= temp
//        }
//        lcm = lcm * totient / gcd(lcm, totient)
//    }
//    print(lcm)
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

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

int main() {
	
	int a, b;
	
	cin >> a >> b;
	
	if(a != b)
	{
		if(a > b) cout << "a > b" << endl;
		
		else cout << "a < b" << endl;
		
	}else
	{
		cout << "a == b" << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3076
#include<stdio.h>

int search1(int S[],int n,int T);
int search2(int S[],int n,int T);

int main(void)
{
  int n,q,S[10000],T;
  int i,j;

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

  j = 0;
  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&T);
    
    if(search1(S,n,T) != search2(S,n,T)){
      j++;
    }
    
  }
  printf("%d\n",j);

  return 0;
}


int search1(int S[],int n,int T){
  int i = 0;
  
  S[n] = T;
  while(S[i] != T){
    i++;
  }
  return i;
}

int search2(int S[],int n,int T){
  int i = 0;
  
  S[n] = T;
  while(S[i] != T){
    i++;
  }
  return n;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main()  {
  int N;
  cin >> N;
  vector<int> a(N);
  int ans = 0;
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++)  {
    bool is_candidate = true;
    for (int j = 0; j < i; j++)  {
      if (a[j]>a[i])  {
      is_candidate = false;
      break;
    }
  }
  if(is_candidate) ++ans;
}
cout << ans <<endl;
}

Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, i = (int(_) for _ in input().split())  
    print(N-i+1)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
open System

let N,K = 
    let t = Console.ReadLine().Split() 
            |> Array.map(int)
    t.[0],t.[1]
                
let f b =
    //e [0,1,2,..,b-1]
    //r [0,1,2,..,r]
    //pb + r (0 <= t < b)
    let e = N % b
    let p = N / b
    let r =  
        if   K = 0  then e
        elif e >= K then e - K + 1
        else             0   
    (b - K) * p + r                 
    
[K+1..N]
|> List.map(fun x -> (int64 <| f x))
|> List.sum
|> printfn "%i" 
    

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

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

int main() {
  int H, W, h, w;
  scanf("%d%d%d%d", &H, &W, &h, &w);
  if (H % h == 0 && W % w == 0) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  REP(i,H)REP(j,W) {
    int n = 10000;
    if (H % h != 0 && i % h == h - 1) n = -(h-1)*10000 - 1;
    else if (H % h == 0 && j % w == w - 1) n = -(w-1)*10000 - 1;
    printf("%d ", n);
    if (j == W-1) printf("\n");
  }
}


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

typedef long double ld;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;

void print()
{
  std::cout << std::endl;
}

template<class T>
void print(T param)
{
  std::cout << param << std::endl;
  return;
}

template<class T, class... S>
void print(T param1, S... param2)
{
  std::cout << param1 << " "; print(std::forward<S>(param2)...);
}

void fail()
{
  return;
}

void solve()
{
  ll N, K;
  std::cin >> N >> K;

  ll ans = 0LL;

  // 0からNまで並んでいるとする
  // i 個選ぶ
  for (ll i = K; i <= N + 1; i++) {
    ll min_val = (0 + (i-1))   * i / 2;  // 0 〜 i-1
    ll max_val = (N + (N-i+1)) * i / 2;  // N-i+1 〜 N
    ans = (ans + (max_val - min_val + 1)) % MOD;
  }

  print(ans);
  return;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3600
import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

n,w = map(int,input().split())
l=[list(map(int,input().split())) for i in range(w)]
ans=0
#edge[i] : iから出る道の[重み,行先]の配列
for j in range(w):
    edge = [[] for i in range(n)]
    b=l[:j]+l[j+1:]
    for i in range(w-1):
        x,y = b[i][0],b[i][1]
        x-=1;y-=1
        z=1
        edge[x].append([z,y]) #有向辺
        edge[y].append([z,x]) #有向辺
    if float("inf") in dijkstra_heap(0):
            ans+=1
print(ans)

Measured memory_bytes: 45276
import itertools
n = int(input())
s = []
march = [0] * 5
for i in range(n):
    s = input()
    if s[0] == 'M':
        march[0] += 1
    if s[0] == 'A':
        march[1] += 1
    if s[0] == 'R':
        march[2] += 1
    if s[0] == 'C':
        march[3] += 1
    if s[0] == 'H':
        march[4] += 1

comb = itertools.combinations(list(range(5)), 3)
ans = 0
for i in comb:
    ans += march[i[0]] * march[i[1]] * march[i[2]]
print(ans)


Measured memory_bytes: 3064
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

type Data struct {
	a int
	b int
}

// Datas :
type Datas []Data

func (p Datas) Len() int {
	return len(p)
}

func (p Datas) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Datas) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

func main() {
	sc.Split(bufio.ScanWords)
	h := getInt()
	w := getInt()
	n := getInt()
	P := make(Datas, n*9)
	for i := 0; i < n; i++ {
		P[i].b = getInt() - 1
		P[i].a = getInt() - 1
	}

	x := [8]int{-1, 0, 1, -1, 1, -1, 0, 1}
	y := [8]int{-1, -1, -1, 0, 0, 1, 1, 1}
	idx := n
	for i := 0; i < n; i++ {
		for j := 0; j < 8; j++ {
			px := P[i].a + x[j]
			py := P[i].b + y[j]
			if (px < w) && (px >= 0) && (py < h) && (py >= 0) {
				P[idx].a = px
				P[idx].b = py
				idx++
			}
		}
	}
	P = P[:idx]

	sort.Sort(P)
	//out(P)
	ans := make([]int, 10)

	xx := -1
	yy := -1
	cnt := 0
	for i := 0; i < len(P); {
		if (P[i].a == 0) || (P[i].a == w-1) || (P[i].b == 0) || (P[i].b == h-1) {
			i++
			continue
		}
		xx = P[i].a
		yy = P[i].b
		cnt = 0
		for ; ; i++ {
			if i >= len(P) {
				break
			}
			if (xx == P[i].a) && (yy == P[i].b) {
				cnt++
			} else {
				break
			}
		}
		ans[cnt]++
	}

	sum := 0
	for i := 1; i < 10; i++ {
		sum += ans[i]
	}
	ans[0] = (w-2)*(h-2) - sum

	for i := 0; i < 10; i++ {
		out(ans[i])
	}
}


Measured memory_bytes: 17280
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>

using namespace std;
int main()
{
    int n;
    cin >> n;
    char s[300000];
    int e = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        if (i >= 1) {
            if (s[i] == 'E') {
                e++;
            }
        }
    }
    int ans = e;
    int mobu = 300000;
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == 'W') {
            ans++;
        }
        if (s[i] == 'E') {
            ans--;
        }
        if (mobu > ans) {
            mobu = ans;
        }
    }
    if (e < mobu) {
        cout << e << endl;
    }
    else {
        cout << mobu << endl;
    }

    return 0;
}

Measured memory_bytes: 512
from collections import deque

n, k = map(int, input().split())
v = list(map(int, input().split()))

w = deque(v)
ans = 0
for i in range(k+1):
    if i > n:
        break
    s = v[:i]
    for j in range(k+1-i):
        if j > n-i:
            break
        t = sorted(v[n-j:] + s, reverse=True)
        u = sum(t)
        for l in range(k+1-i-j):
            ans = max(ans, u)
            if not t:
                break
            u -= t.pop()
print(ans)

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

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

    if(a <= b){
        for(int i = 0; i < b; i++){
            cout << a;
        }
    }else{
        for(int i = 0; i < a; i++){
            cout << b;
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
int solve(int src, vector<vector<int>> &v, int* dp){
    if(dp[src]!=-1){
        return dp[src];    
    }
    if(v[src].size() == 0){
        dp[src] = 0;
        return dp[src];
    }
    int best = 0;
    // for(auto x:v[src]){
    //     best = max(best,solve(x,v,dp));
    // }
    
    for(auto x:v[src]){
        if(dp[x] == -1)solve(x,v,dp);
    }
    for(auto x:v[src]){
        best = max(best,dp[x]);
    }
    dp[src] = 1 + best;
    return dp[src];
}
 
 
int32_t main() {
	int n,e;
	cin>>n>>e;
	vector<vector<int>> v(n+1);
	int i;
	for(i=0;i<e;i++){
	    int a,b;
	    cin>>a>>b;
	    v[a].push_back(b);
	}
	
	int dp[n+1];
	fill(dp,dp+n+1,-1);
	
    // for(i=1;i<=n;i++){
    //     cout<<i<<" -> ";
    //     for(auto x:v[i]){
    //         cout<<x<<" , ";
    //     }
    //     cout<<endl;
    // }
	
	for(i=1;i<=n;i++){
	    solve(i,v,dp);
	}
	
// 	for(i=1;i<=n;i++){
// 	    cout<<dp[i]<<" ";
// 	}
// 	cout<<endl;
	
	int mx = 0;
	for(i=1;i<=n;i++)mx = max(mx,dp[i]);
	cout<<mx<<endl;
	
	return 0;
}

Measured memory_bytes: 9856
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var N = int.Parse(Console.ReadLine());
    var zen = Console.ReadLine().Split();
    var x = new List<int>();
    foreach(var a in zen){
      x.Add(int.Parse(a));
    }
    int ave =(int)Math.Round(x.Average(), 0,MidpointRounding.AwayFromZero);
    var k = 0;
    for(var i = 0;i<x.Count;i++){
      k+= (x[i]-ave)*(x[i]-ave);
    }
    Console.WriteLine(k);
  }
}

Measured memory_bytes: 11348
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]
            var line = ReadLine();
            int A = line[0];
            int B = line[1];
            int K = line[2];

            var numbers = new List<int>();

            for(int i = 0; i < K; i++)
            {
                //小さいほう
                if (A + i <= B)
                {
                    numbers.Add(A + i);
                }

                //大きいほう
                if (B - i >= A)
                {
                    numbers.Add(B - i);
                }
            }

            var ans = numbers.Distinct().OrderBy(x => x);

            foreach (var a in ans)
            {
                Console.WriteLine(a);
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13524
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << min(A, B) + min(C, D) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
     
        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int n = o[0];
            int m = o[1];
            var graph = new int[n];
            for(int i=0;i<m;++i)
            {
                o = ReadAndParseIntArr();
                int a = o[0];
                int b = o[1];
                graph[a-1]++;
                graph[b-1]++;
            }
            for(int i=0;i<graph.Length;++i)
            {
                Console.WriteLine(graph[i]);
            }
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int res = 0 , ans = 0;
	for(int i=0;i<n;i++){
		res += (a[i]-1);
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var W = cin.ReadInt;
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            if(a + W < b){
                WriteLine(b - (a + W));
                return;
            }else if (b + W < a){
                WriteLine(a - (b + W));
                return;
            }else{
                WriteLine("0");
                return;
            }

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

int main() {
  int n, t;
  vector<int> h;
  cin >> n;
  rep(i,n){
    cin >> t;
    h.push_back(t);
  }
  string ans = "Yes";
  int cut=0;
  for (auto& l: h){
    if (l > cut) cut = l-1;   
    else if (l < cut) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
import sys
from itertools import accumulate

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  A = list(map(int, input().split()))
  A = [0] + [a % M for a in accumulate(A)]
  
  ans = 0
  appeared = {}
  for i in range(len(A)):
    if A[i] in appeared:
      ans += appeared[A[i]]
      appeared[A[i]] += 1
    else:
      appeared[A[i]] = 1

  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 14044
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        r: usize,
        g: usize,
	b: usize,
    }
    let kazu = r * 100 + g * 10 + b;
    if kazu % 4 == 0 {
	println!("YES");
    } else {
	println!("NO");
    }
}


Measured memory_bytes: 2092
#include <cstdint>
#include <cstdio>
#include <array>
#include <string>
#include <utility>
#include <vector>

#include <atcoder/mincostflow>

constexpr std::array<std::pair<int, int>, 4> dij{{{-1, 0}, {0, -1}, {1, 0}, {0, 1}}};

int main() {
  int n, k;
  scanf("%d %d", &n, &k);

  std::vector<std::vector<intmax_t>> a(n, std::vector<intmax_t>(n));
  for (auto& ai: a)
    for (auto& aij: ai)
      scanf("%jd", &aij);

  int rows = 0;
  int cols = rows + n;
  int source = cols + n;
  int sink = source + 1;
  atcoder::mcf_graph<int, intmax_t> g(sink+1);

  for (int i = 0; i < n; ++i) {
    g.add_edge(source, rows+i, k, 0);
  }
  for (int j = 0; j < n; ++j) {
    g.add_edge(cols+j, sink, k, 0);
  }

  intmax_t ofs = 1e10;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      g.add_edge(rows+i, cols+j, 1, ofs-a[i][j]);
    }
  }

  g.add_edge(source, sink, n*k, ofs-0);

  auto [cap, cost] = g.flow(source, sink, n*k);

  std::vector<std::string> res(n, std::string(n, '.'));
  for (auto const& e: g.edges()) {
    if (e.flow == 0) continue;
    if (e.from < cols) {
      int i = e.from - rows;
      int j = e.to - cols;
      res[i][j] = 'X';
    }
  }

  printf("%jd\n", cap*ofs - cost);
  for (auto const& si: res) printf("%s\n", si.data());
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    return gcd(b%a,a);
}

int main()
{
    unsigned ll a,b,c,d;

    cin>>a>>b>>c>>d;

    unsigned ll lcm = (c*d)/gcd(c,d);

    unsigned ll flcm = (a-1)/lcm;

    unsigned ll slcm = b/lcm;

    unsigned ll c1 = (a-1)/c;

    unsigned ll c2 = b/c;

    unsigned ll d1 = (a-1)/d;

    unsigned ll d2 = b/d;

    cout<<(b-a+1)-((c2-c1) + (d2-d1) - (slcm-flcm))<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int h,m,s,ss;
	scanf("%d",&ss);
	h=ss/3600;
	ss=ss%3600;
	m=ss/60;
	s=ss%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
	}


Measured memory_bytes: 2696
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##################################
# University of Wisconsin-Madison
# Author: Yaqi Zhang
##################################
# This module contains ...
##################################

# standard library
import sys
sys.setrecursionlimit(10**9)

MOD = int(1e9 + 7)


def main():
    """1~K"""
    n, k = map(int, input().split())
    dp = [-1] * (k + 1)
    # gcd == i
    for x in range(k, 0, -1):
        cnt = k // x
        if cnt == 1:
            dp[x] = 1
        else:
            dp[x] = pow(cnt, n, MOD)
            for i in range(2, cnt + 1):
                dp[x] = (dp[x] - dp[x * i]) % MOD
    ans = 0
    for i in range(1, k + 1):
        ans = (ans + i * dp[i]) % MOD
    print(ans)



if __name__ == "__main__":
    main()


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

int main() {
  string S;
  cin >> S;
  
  if (S=="RRR") {
    cout << "3" << endl;
  }
  
  else if (S=="RRS" || S=="SRR") {
    cout << "2" << endl;
  }
  
  else if (S=="RSS" || S=="SRS" || S=="SSR" || S=="RSR") {
    cout << "1" << endl;
  }
  
  else {
    cout << "0" << endl;
  }
  
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <algorithm> //next_permutation

using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

int main(){
  ll n;
  cin>>n;
  if (n%2==1) {cout<<0;}
  else{
    ll ans=0;
    n/=2;
    ll i=0;
    while (n>0){
      ll temp=n/5;
      ans+=temp;
      n/=5;
    }
    cout<<ans;

  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a, int b){
  if(a%b==0) return b;
  return gcd(b, a%b);
}
int main(){
  int n;
  cin >> n;
  int s=0;
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      for(int k=1; k<=n; k++){
        s+=gcd(gcd(i,j),k);
      }
    }
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
vector<ll> dijkstra(vector<vector<P>> graph, ll s) {
    vector<ll> ans(graph.size(), -1);
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (ll i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].first, graph[cur2][i].second});
            }
        }
    }
    return ans;
}
vector<string> maze;
ll h, w;
bool check(ll y, ll x) {
    if (x < 0 || x >= w || y < 0 || y >= h || maze[y][x] == '#') {
        return false;
    }
    return true;
}
string idmaker(ll x) {
    string s = to_string(x);
    ll length = s.size();
    REP(i, 6 - length) { s = "0" + s; }
    return s;
}
int main() {
    ll n, m;
    cin >> n >> m;
    vector<vector<P>> id(n);
    REP(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;
        id[a].push_back({b, i});
    }
    vector<string> ans(m);
    REP(i, n) {
        sort(id[i].begin(), id[i].end());
        REP(j, id[i].size()) { ans[id[i][j].second] = idmaker(i + 1) + idmaker(j + 1); }
    }
    REP(i, m) { cout << ans[i] << endl; }
}

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

int main()
{

   double N,D;
   int coun=0;
   cin>>N>>D;

   while(N--)
   {
     double x,y;
     cin>>x>>y;
     if(sqrt(x*x+y*y)<=D)
     {
         coun++;
     }
   }
    cout<<coun<<endl;

  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];

  int ans = 0;
  for (int i=0; i<n-2; i++) {
    for (int j=i+1; j<n-1; j++) {
      for (int k=j+1; k<n; k++) {
	if (l[i] == l[j] || l[i] == l[k] || l[k] == l[j]) {
	  continue;
	}
	if (abs(l[i]-l[j]) < l[k] && l[k] < l[i]+l[j]) {
	  ans++;
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n, x;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  mllll m;
  fi(0, n) {
    cin >> x;
    m[x]++;
  }

  if(m.size() > 3) {
    cout << "No\n";
  } else if(m.size() == 1) {
    if(m[0])
      cout << "Yes\n";
    else
      cout << "No\n";
  } else {
    vllll v;
    for(auto y: m) {
      v.push_back(y);
    }
    if(m.size() == 2) {
      if(v[0].first == 0 && v[0].second * 2 == v[1].second)
        cout << "Yes\n";
      else
        cout << "No\n";
    }
    else {
      if(v[0].second == v[1].second && v[0].second == v[2].second && (v[0].first ^ v[1].first) == v[2].first) 
        cout << "Yes\n";
      else
        cout << "No\n";
    }
  }
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll k;
    cin >> k;
    k++;

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

    int p[40];
    for (int l = 0; l < 40; l += 2) {
        ll m0 = 1LL << l;
        ll m1 = m0 << 1;
        ll c = 0;
        for (int i = 0; i < n; i++) {
            c += ((a[i] & m0) > 0) + ((ll)((a[i] & m1) > 0) << 32);
        }
        *(ll *)(p + l) = c;
    }

    function<ll(ll, int, int)> f = [&](ll t, int h, int b) {
        ll s = 0, s1 = 0;
        for (int l = h - 1; l >= 0; l--) {
            ll m = 1LL << l;
            ll c = p[l];
            if (c < n - c && (t ^ m) < k) {
                if (b) s1 = max(s1, f(t, l, 0) + s + (c << l));
                t ^= m;
                s += (n - c) << l;
            } else {
                s += c << l;
            }
        }
        return max(s, s1);
    };

    cout << f(0, 40, 1) << endl;

    return 0;
}

Measured memory_bytes: 1024
Scanf.scanf "%d %d" (fun n k ->
    let rec gcd a b = if b = 0 then a else gcd b (a mod b) in
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let rec loop i mx gc =
        if i = n then mx >= k && (mx - k) mod gc = 0 else
            loop (i + 1) (max mx a.(i)) (gcd gc a.(i))
    in
    loop 1 a.(0) a.(0) |> (fun b -> print_endline @@ if b then "POSSIBLE" else "IMPOSSIBLE")
)

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
#define fi first
#define se second
int n,m,l;
vector<pii>g[303];
int mind[303],lst[303],vis[303];
int adds[303][303];
int main(){
	cin>>n>>m>>l;
	for (int i=0;i<m;i++){
		int a,b,c;cin>>a>>b>>c;
		if (c<=l)g[a].push_back(pii(b,c)),g[b].push_back(pii(a,c));
	}
	int q;cin>>q;
	for (int s=1;s<=n;s++){
		memset (vis,0,sizeof(vis));
		for (int i=1;i<=n;i++) mind[i]=1e9,lst[i]=-1;
		priority_queue <piii,vector<piii>,greater<piii> > pq;
		mind[s]=0,lst[s]=l;
		pq.push(piii(pii(0,-l),s));
		while (!pq.empty()){
			piii x=pq.top();pq.pop();
			if (vis[x.se]) continue;
			vis[x.se]=1;
			for (int i=0;i<g[x.se].size();i++){
				int wants=x.fi.fi,lss=lst[x.se]-g[x.se][i].se;
				if (lst[x.se]<g[x.se][i].se) wants++,lss=l-g[x.se][i].se;
				if (mind[g[x.se][i].fi]>wants || (mind[g[x.se][i].fi]==wants&&lss>lst[g[x.se][i].fi])){
					mind[g[x.se][i].fi]=wants;
					lst[g[x.se][i].fi]=lss;
					pq.push(piii(pii(mind[g[x.se][i].fi],-lss),g[x.se][i].fi));
				}
			}
		}
		for (int i=1;i<=n;i++) adds[s][i]=mind[i];
	}
	while (q--){
		int s,t;cin>>s>>t;
		if (adds[s][t]==1e9) puts("-1");
		else cout<<adds[s][t]<<"\n";
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

void out(bool f)
{
	cout << (f ? "YES" : "NO") << endl;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s, t; cin >> s >> t;
	int n = s.size(), m = t.size();
	vi cntsa(n + 1), cntsb(n + 1);
	REP(i, n)
	{
		cntsa[i + 1] = cntsa[i] + (s[i] == 'A');
		cntsb[i + 1] = cntsb[i] + (s[i] == 'B');
	}
	vi cntta(m + 1), cnttb(m + 1);
	REP(i, m)
	{
		cntta[i + 1] = cntta[i] + (t[i] == 'A');
		cnttb[i + 1] = cnttb[i] + (t[i] == 'B');
	}
	int q; cin >> q;
	while (q--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int sa = cntsa[b] - cntsa[a - 1];
		int sb = cntsb[b] - cntsb[a - 1];
		int ta = cntta[d] - cntta[c - 1];
		int tb = cnttb[d] - cnttb[c - 1];
		out((tb - sb + 2 * ta - 2 * sa) % 3 == 0);
	}
	return 0;
}

Measured memory_bytes: 2512
// E - Rotation Matching

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	vector<pair<int, int>> ans;

	int i=1;
	for (int j=M; j>=1; j-=2) {
		ans.push_back(make_pair(i, i+j));
		i++;
	}

	i = 1+M+1;
	for (int j=M-1; j>=1; j-=2) {
		ans.push_back(make_pair(i, i+j));
		i++;
	}

	for (auto a : ans) {
		cout << a.first << " " << a.second << endl;
	}

	return 0;
}

Measured memory_bytes: 4316
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws java.lang.NumberFormatException{
    Scanner scan=new Scanner(System.in);

    while(true){
      String num=scan.next();
      if(num.equals("0"))break;

      long sum=0;

      for(int i=0;i<num.length();i++){
        sum+=Character.getNumericValue(num.charAt(i));
      }
      System.out.println(sum);
    }
  }
}


Measured memory_bytes: 26596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        while(N>0){
            N-=1000;
        }
        System.out.println(N*-1);
    }
}

Measured memory_bytes: 35612