akhauriyash/Code-Regression huggingface dataset:
#include<atcoder/all>
#include<bits/stdc++.h>
using namespace std;
using namespace atcoder;
const int MOD = 998244353;
void plusle(int &a, int b) {
    a += b;
    while (a >= MOD) a -= MOD;
}
void minun(int &a, int b) {
    a -= b;
    while (a < 0) a += MOD;
}
int add(int a, int b) {
    a += b;
    while (a >= MOD) a -= MOD;
    return a;
}
int sub(int a, int b) {
    a -= b;
    while (a < 0) a += MOD;
    return a;
}
int mul(int a, int b) {
    return int64_t(a) * b % MOD;
}
int power(int a, int64_t b) {
    int res = 1;
    for (; b > 0 ; b >>= 1, a = mul(a, a))
        if (b & 1) res = mul(res, a);
    return res;
}

const int MX = 2e5 + 10;
int fac[MX], invf[MX] ;
void prefact() {
    fac[0] = 1 ;
    for (int i = 1 ; i < MX ; i ++) {
        fac[i] = mul(fac[i - 1], i);
    }
    invf[MX - 1] = power (fac[MX - 1], MOD - 2);
    for (int i = MX - 2 ; i >= 0 ; i --) {
        invf[i] = mul(invf[i + 1], i + 1);
    }
}
int ncr(int N, int R) {
    if (R > N) return 0;
    if (R == 0 || R == N) return 1;
    return mul(fac[N], mul(invf[N - R], invf[R]));
}
const int nax = 2e5 + 10;


int h[nax];
int n;
int cnt[nax];

multiset < pair <int, vector <int>>> setik;

int main() {
    prefact();
    scanf("%d", &n);
    for (int i = 1 ; i <= 2 * n ; ++ i) {
        scanf("%d", h + i);
        cnt[h[i]] += 1;
    }

    for (int i = 1 ; i <= 100000 ; ++ i) {
        if (cnt[i] <= 1) continue;
        vector <int> foo(cnt[i] / 2 + 1);

        int cur = cnt[i];
        int f = 1;

        for (int j = 0 ; j < foo.size() ; ++ j) {
            foo[j] = ncr(cur, 2 * j);
            foo[j] = mul(foo[j], fac[2 * j]);
            foo[j] = mul(foo[j], invf[j]);
            foo[j] = mul(foo[j], power(MOD + 1 >> 1, j));
        }

        setik.emplace(foo.size(), foo);
    }

    while (setik.size() >= 2) {
        vector <int> p1 = setik.begin()->second;
        setik.erase(setik.begin());
        vector <int> p2 = setik.begin()->second;
        setik.erase(setik.begin());
        p1 = convolution(p1, p2);
        setik.emplace(p1.size(), p1);
    }

    vector <int> c = setik.empty() ? vector<int>(1, 1) : setik.begin()->second;

    if (c.size() <= n) c.resize(n + 2);


    const int INV2 = (MOD + 1) / 2;

    int ans = 0;

    for (int bar = 0 ; bar < c.size() ; ++ bar) {
        int v = c[bar];
        v = mul(v, fac[2 * (n - bar)]);
        v = mul(v, invf[n - bar]);
        v = mul(v, power(INV2, n - bar));
        if (bar % 2 == 0) {
            plusle(ans, v);
        } else minun(ans, v);
    }

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

    /**
    f(i) the number of ways to get
    i equal pairs from first v group
    */



}


Measured memory_bytes: 8776
import sys
from collections import deque, defaultdict
import copy
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
sum_a = [0, a[0]]
for i in range(1, N):
    sum_a.append(sum_a[-1]+a[i])

bubunwa = []
for i in range(N):
    for j in range(i + 1, N + 1):
        bubunwa.append(sum_a[j] - sum_a[i])

max_bit = 2
while True:
    if sum_a[-1] < 2**max_bit:
        break
    max_bit += 1

sum = 0
for i in range(max_bit ,-1, -1):
    kouho = []
    for n in bubunwa:
        if n & 2**i == 2**i:
            kouho.append(n)
    if len(kouho) >= K:
        bubunwa = copy.deepcopy(kouho)
        sum += 2**i

print(sum)

Measured memory_bytes: 86632
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合

let x = split[0]

let length = x.count

var ans = ""
for i in 0..<length{
    ans += "x"
}

print(ans)


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

int main() {
  short t, n, left, current;
  cin >> t;
  for (int i; i < t; i++) {
    cin >> n >> left;
    short umax = 0, dmax = 0;
    short *xmax;
    for (int j = 0; j < n - 1; j++) {
      cin >> current;
      xmax = current > left ? &umax : &dmax;
      *xmax = max(*xmax, (short)abs(current - left));
      left = current;
    }
    cout << umax << ' ' << dmax << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long Int;
#define INF (1LL<<30)

Int solve(Int x, Int y){
	if(x < y)swap(x, y);
	Int res = y-1;
	Int bottom = 0, top = x;
	while(top - bottom > 1){
		Int mid = (top + bottom) / 2;
		if(y*x >= (mid+y) * (mid+y+1))bottom = mid;
		else top = mid;
	}
	res += bottom;

	Int a = x*y / (y+bottom+1);
	if(x*y%(y+bottom+1) == 0)a--;
	res += a;
	return res;
}

int main(){
	Int q, x, y;
	cin >> q;
	while(q--){
		cin >> x >> y;
		cout << solve(x, y) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d float64
	fmt.Scan(&a, &b, &c, &d)

	if (math.Abs(b-a) <= d && math.Abs(c-b) <= d) || math.Abs(c-a) <= d {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

bool eq(vector<int>& a, vector<int>& b) {
	if (a.size() != b.size()) {
		return false;
	}
	for (int i = 0; i < a.size(); ++i) {
		if (a[i] != b[i]) {
			return false;
		}
	}
 
	return true;
}
int main() {
	int n;
	cin >> n;
 
	vector<int> s(n);
 
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
		s[i] = i + 1;
	}
 
	int px;
	int x = 1;
	do {
		if (eq(p, s)) {
			px = x;
			break;
		}
		++x;
	} while (next_permutation(s.begin(), s.end()));
 
 
	vector<int> q(n);
	for (int i = 0; i < n; ++i) {
		cin >> q[i];
		s[i] = i + 1;
	}
 
	int qx;
	x = 1;
	do {
		if (eq(q, s)) {
			qx = x;
			break;
		}
		++x;
	} while (next_permutation(s.begin(), s.end()));
 
	cout << abs(px - qx);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> p(m);
	vector<string> s(m);
	map<int, int> wa;
	map<int, string> mp;
	int ac = 0, pena = 0;

	for (int i = 0; i < m; i++)
	{
		cin >> p[i] >> s[i];
		if (mp.find(p[i]) == mp.end())
		{
			mp.insert(make_pair(p[i], s[i]));
			wa.insert(make_pair(p[i], 0));
			if (s[i] == "AC") ac++;
			else wa[p[i]]++;
		}
		else
		{
			if (mp[p[i]] == "WA" && s[i] == "AC")
			{
				ac++;
				mp[p[i]] = s[i];
			}
			else if (mp[p[i]] == "WA" && s[i] == "WA")
			{
				wa[p[i]]++;
			}
		}
		//cout << wa[p[i]] << endl;
	}

	for (int i=0; i<mp.size(); i++)
	{
		if (mp[i] == "AC") pena += wa[i];
	}

	cout << ac << " " << pena << endl;
}

Measured memory_bytes: 17024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	double[] ary = new double[N];
    	String[] strAry = new String[N];
    	double ans = 0;
    	for(int i = 0; i < N; i++){
    		ary[i] = Double.parseDouble(sc.next());
    		strAry[i] = sc.next();
    		if(strAry[i].equals("BTC")) ary[i] = ary[i] * 380000;
    		ans += ary[i];
    	}
    	sc.close();
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,x,len;
	char s[10001];
	scanf("%d",&n);
	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<len;i++)	{
		s[i]=s[i]+n;
		if(s[i]>'Z')	s[i]-=26;
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 128
//A - Kth Term

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int lint[32];
    
    lint[0] = 1;
    lint[1] = 1;
    lint[2] = 1;
    lint[3] = 2;
    lint[4] = 1;
    lint[5] = 2;
    lint[6] = 1;
    lint[7] = 5;
    lint[8] = 2;
    lint[9] = 2;
    lint[10] = 1;
    lint[11] = 5;
    lint[12] = 1;
    lint[13] = 2;
    lint[14] = 1;
    lint[15] = 14;
    lint[16] = 1;
    lint[17] = 5;
    lint[18] = 1;
    lint[19] = 5;
    lint[20] = 2;
    lint[21] = 2;
    lint[22] = 1;
    lint[23] = 15;
    lint[24] = 2;
    lint[25] = 2;
    lint[26] = 5;
    lint[27] = 4;
    lint[28] = 1;
    lint[29] = 4;
    lint[30] = 1;
    lint[31] = 51;

    int k;

    cin >> k;

    cout << lint[k-1] << endl;
    
    return 0;
}


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


int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  int sum_A=0,sum_B=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      sum_A+=a.at(i);
    }
    else{
      sum_B+=a.at(i);
    }
  }
  int ans;
  ans = sum_A - sum_B;
  cout << ans << endl;
}


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

int main(){
    int n, i, tp = 0, hp = 0;
    char hana[101], taro[101];

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %s", taro, hana);
        int cmp = strcmp(taro, hana);

        if(cmp > 0)tp += 3;
        else if(cmp == 0){
            tp++;
            hp++;
        }
        else hp += 3;
    }

    printf("%d %d\n", tp, hp);
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    string s;
    cin >> s;
    int N = 0, E = 0, S = 0, W = 0;
    REP(i, s.size()){
        if(s[i] == 'N'){
            N = 1;
        }else if(s[i] == 'E'){
            E = 1;
        }else if(s[i] == 'S'){
            S = 1;
        }else{
            W = 1;
        }
    }
    if(N == S && E == W){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    ll n;
    cin >> n;
    ves s(n); 
    rep(i,n){
        cin >> s[i];
        sort(all(s[i]));
    }
    map<string,ll> m;
    rep(i,n){
        m[s[i]]++;
    }
    ll ans = 0;
    for(auto it : m){
        ll kari = it.second;
        ans  += (kari*(kari-1))/2;
    }    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16640
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(void){
    double pi=acos(-1),r;
    cin>>r;
    printf("%.10lf\n",2*r*pi);
    return 0;
}


Measured memory_bytes: 3784
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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>

using namespace std;


#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


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


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

	int ans = a*b - a - b + 1;
	ANS(ans);

	return 0;
}



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

int max(int a,int b){
	if(b>a)return b;
	return a;
}

int p[10][10];
int cp[10][10];
int flag[10][10];
int h,w,c;

struct data{
	int x,y;
};

struct data que[5000000];
int f,t;
void push(int xx,int yy){
	que[t].x=xx;
	que[t].y=yy;
	t++;
}

struct data pop(){
	return que[f++];
}

int sx[4]={0,1,0,-1};
int sy[4]={1,0,-1,0};
int col[7],res;

int bfs(int cc){
	memset(flag,0,sizeof(flag));
	f=0,t=0;
	push(1,1);
	flag[1][1]=1;
	while(f!=t){
		struct data q=pop();
		int i;
		for(i=0;i<4;i++){
			int nx=sx[i]+q.x,ny=sy[i]+q.y;
			if(flag[nx][ny]==0){
				if(cp[q.x][q.y]==cp[nx][ny]){
					flag[nx][ny]=1;
					push(nx,ny);
				}
			}
		}
	}
	int cnt=0;
	int i,j;
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			if(flag[j][i]==1)cp[j][i]=cc;
			cnt+=flag[j][i];
		}
	}
	return cnt;
}
int d[6];
void dfs(int x){
	if(x<4){
		for(d[x]=1;d[x]<=6;d[x]++){
			col[x]=d[x];
			dfs(x+1);
		}
	}else{
		col[4]=c;
		int i,j;
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				cp[j][i]=p[j][i];
			}
		}
		for(i=0;i<5;i++){
			bfs(col[i]);
		}
		res=max(res,bfs(7));
	}
}

int main(void){
	while(1){
		scanf("%d %d %d",&h,&w,&c);
		if(h+w+c==0)break;
		res=0;
		memset(p,0,sizeof(p));
		int a,b;
		for(a=1;a<=h;a++){
			for(b=1;b<=w;b++){
				scanf("%d",&p[b][a]);
			}
		}
		dfs(0);
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    int d;
    while(cin>>d)
    {
        long long res = 0;
        for(int c=0;c<600;c+=d)
        {
            res+= d*(c*c);
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); 
    ll N; cin >> N;
    int ans = 0;
    FOR(i, 2, 10000000) {
        int cur = 0;
        while (N % i == 0) {
            cur++;
            N /= i;
        }
        FOR(j, 1, 10000) {
            if (cur < j) break;
            ans++; cur -= j;
        }
    }
    if (N > 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))


double GaussElimination(vector<vector<double> > matrix) {
  const int n = matrix.size();
  double ret = 1.0;
  for (int x = 0; x < n; x++) {
    int pivot = x;
    for (int i = x + 1; i < n; i++) {
      if (fabs(matrix[i][x]) - fabs(matrix[pivot][x]) > EPS) {
        pivot = i;
      }
    }
    swap(matrix[x], matrix[pivot]);
    if (fabs(matrix[x][x]) < EPS) { return 0.0; }
    for (int y = 0; y < n; y++) {
      if (y == x) { continue; }
      double ratio = -matrix[y][x] /  matrix[x][x];
      matrix[y][x] = 0.0;
      for (int i = x + 1; i < n; i++) {
        matrix[y][i] += matrix[x][i] * ratio;
      }
    }
  }
  return ret;
}

typedef int Weight;
struct Edge {
  int src;
  int dest;
  Weight weight;
  Edge(int src, int dest, Weight weight) : src(src), dest(dest), weight(weight) {;}
  bool operator<(const Edge &rhs) const {
    if (weight != rhs.weight) { return weight > rhs.weight; }
    if (src != rhs.src) { return src < rhs.src; }
    return dest < rhs.dest;
  }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<double> Array;
typedef vector<Array> Matrix;

void PrintMatrix(const Matrix &matrix) {
  for (int y = 0; y < (int)matrix.size(); y++) {
    for (int x = 0; x < (int)matrix[y].size(); x++) {
      printf("%f ", matrix[y][x]);
    }
    puts("");
  }
}

const int ITER_CNT = 10;
bool Sunny(const Graph &g) {
  const int n = g.size();
  REP(iter, ITER_CNT) {
    Matrix tutte(n, Array(n, 0));
    REP(from, n) {
      FORIT(it, g[from]) {
        int to = it->dest;
        if (to <= from) { continue; }
        if (from != 0) {
          double r = (double)(rand() + 1) / RAND_MAX * 10;
          tutte[from][to] = r;
          tutte[to][from] = -r;
        } else {
          double r1 = (double)(rand() + 1) / RAND_MAX * 10;
          double r2 = (double)(rand() + 1) / RAND_MAX * 10;
          tutte[from][to] = r1;
          tutte[to][from] = -r2;
        }
      }
    }
    if (GaussElimination(tutte) != 0.0) { return true; }
  }
  return false;
}

int n, m;
int main() {
  while (scanf("%d %d", &n, &m) > 0) {
    Graph g(n);
    REP(i, m) {
      int f, t;
      scanf("%d %d", &f, &t);
      f--; t--;
      g[f].push_back(Edge(f, t, 0));
      g[t].push_back(Edge(t, f, 0));
    }
    if (Sunny(g)) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i, j;
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(H == 0 && W == 0) break;
			
			for(i = 0; i < H; i++){
				for(j = 0; j < W; j++){
					if(i % 2 != 1 && j % 2 != 1 || i % 2 == 1 && j % 2 == 1) System.out.print("#");
					else System.out.print(".");
				}
			System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 36388
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N;
    cin >> N;
    vector<int> spot;
    vector<ll> B(N);
    rep(i, N) {
        int A;
        cin >> A;
        spot.push_back(A);
    }
    //累積和B作る
    rep(i, N) {
        if (i == 0) {
            B[i] = abs(spot[i]);
            continue;
        }
        B[i] = B[i-1] + abs(spot[i] - spot[i-1]);
    }
    rep(i, N) {
        if (i == 0) {
            cout << B[N-1] + abs(spot[N-1]) - abs(spot[0]) - abs(spot[0]-spot[1]) + abs(spot[1])  << endl;
            continue;
        }
        if (i == N-1) {
            cout << B[N-2] + abs(spot[N-2]) << endl;
            continue;
        }
        cout << B[N-1] +abs(spot[N-1]) - (abs(spot[i]-spot[i-1])+abs(spot[i+1]-spot[i])) + abs(spot[i+1]-spot[i-1]) << endl;
    }
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

string s;

bool move(int& i){
	if(s[i + 1] == '#' and s[i + 2] == '#'){
		return false;
	}
	if(s[i + 1] == '#'){
		i++;
	}
	i++;
	return true;
}
bool mover(int& i){
	if(s[i - 1] == '#' and s[i - 2] == '#'){
		return false;
	}
	if(s[i - 1] == '#'){
		i--;
	}
	i--;
	return true;
}

signed main(){
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d >> s;
	n+=2;
	a++; b++; c++; d++;

	s = "##" + s + "##";

	bool ans = true;
	if(
			(a < c and c < b and b < d) or 
			(a < b and b < c and c < d)
	  ){
		while(b < d) if(not move(b)){
			ans = false;
			break;
		}
		while(a < c) if(not move(a)){
			ans = false;
			break;
		}
	}else if(a < b and b < d and d < c){
		int a_ = a;
		while(a_ < c) if(not move(a_)){
			ans = false;
			break;
		}

		bool f = false;
		range(i,b,d + 1){
			if(s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.'){
				f = true;
			}
		}
		ans = f;
	}else{
		assert(false);
	}
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 772
#include <iostream>
#include <fstream>
#include <utility>
#include <queue>
#include <vector>
#include <array>
#include <stack>
#include <list>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define bs(n) (1ul<<(n))

ll n, k, s[200001], r = 0;
map<ll, ll> t;

int main() {
	cin >> n >> k;
	auto g = []() {ll a; cin >> a; return a; };
	rep(i, n)s[i + 1] = (s[i] + g() - 1) % k;
	rep(i, n + 1) {
		if (i >= k) t[s[i - k]]--;
		r += t[s[i]];
		t[s[i]]++;
	}
	cout << r << endl;
}


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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b >> c;
	if (a < b) {
		n = a;
		a = b;
		b = n;
	}
	if (a < c) {
		n = a;
		a = c;
		c = n;
	}
	cout << b + c;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,q;
string s;
vector<pair<char,bool> >a;
main()
{
	cin>>n>>q>>s;
	for(int i=0;i<q;i++)
	{
		char t,d;cin>>t>>d;
		a.push_back(make_pair(t,d=='R'));
	}
	int L=0;
	for(int i=q;L<n&&i--;)
	{
		if(a[i].second)
		{
			if(L>0&&a[i].first==s[L-1])
			{
				L--;
			}
		}
		else
		{
			if(a[i].first==s[L])L++;
		}
	}
	L--;
	int R=n-1;
	for(int i=q;R>=0&&i--;)
	{
		if(a[i].second)
		{
			if(a[i].first==s[R])R--;
		}
		else
		{
			if(R<n-1&&a[i].first==s[R+1])
			{
				R++;
			}
		}
	}
	R++;
	cout<<R-L-1<<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, a[100100];

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    bool flag = true;
    int cnt = 0;
    while(flag){
        flag = false;
        for(int i = N - 1; i >= 1; i--){
            if(a[i] < a[i - 1]){
                swap(a[i], a[i - 1]);
                flag = true;
                cnt++;
            }
        }
    }
    for(int i = 0; i < N; i++){
        cout << a[i] << ((i == N - 1) ? "\n" : " ");
    }
    cout << cnt << endl;


    return 0;
}

/*

*/


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a, b, c[2], res = 1;
vector<pair<int,int> > p;

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> a;
		p.push_back({a,0});
	}
	rep(i,n) {
		cin >> b;
		p.push_back({b,1});
	}
	sort(all(p));
	each(i,p) {
		int x = i.second;
		if (c[x^1]) (res *= c[x^1]--) %= mod;
		else c[x]++;
	}
	cout << res << endl;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll f(ll a, ll b){
    string s=to_string(a),t=to_string(b);
    ll na=s.size(),nb=t.size();
    return max(na,nb);
}

int main(void)
{
    ll a, b, c, x, y, ans=INF;
    cin >> a >> b >> c >> x >> y;
    rep(i,1e5+1){
        ll tmp = max(0LL, x-i)*a + max(0LL, y-i)*b + 2*i*c;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string S, s;
  int N, K;
  cin >> N >> K >> S;
  s = S;
  transform(s.begin(), s.end(), s.begin(), ::tolower);
  S[K-1] = s[K-1];
  cout << S << endl;
}


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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var A = inputLongArray[0];
            var B = inputLongArray[1];

            var ANS = A + B;
            if(ANS >= 24) {
                ANS -= 24;
            }

            Console.WriteLine(ANS.ToString());
        }
    }
}


Measured memory_bytes: 13396
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(lambda x: -int(x), input().split()))

a.sort()
c.sort()

ans = 0
for bi in b:
    na = bisect.bisect_left(a, bi)
    nb = bisect.bisect_left(c, -bi)
    ans += na * nb
print(ans)


Measured memory_bytes: 22720
#include <iostream>
#define MAX_W 20
#define MAX_H 20
using namespace std;

int w, h, ax, ay, cnt;
char t[MAX_H][MAX_W + 1];

void PRINT() {
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      cout << t[i][j];
    }
    cout << endl;
  }
  cout << endl;
}

// 深さ優先探索
// 現在位置(x, y)
void dfs(int x, int y) {
  t[y][x] = 'o';

  for(int dx = -1; dx <= 1; dx++) {
    for(int dy = -1; dy <= 1; dy++) {
      // 4方向に限定
      if(dx * dy == -1 || dx * dy == 1) continue;

      // 現在位置を(nx, ny)に更新
      int nx = x + dx;
      int ny = y + dy;

      // (nx, ny)は部屋の中か？ & t[nx][ny]は黒タイルか？判定
      if(0 <= nx && nx < w && 0 <= ny && ny < h && t[ny][nx] == '.') {
        dfs(nx, ny);
        //PRINT();
        cnt++;
      }
    }
  }
  return;
}

void solve() {
  cnt = 1;
  dfs(ax, ay);
  cout << cnt << endl;
}

int main() {
  while(cin >> w >> h) {
    if(w * h == 0) break;

    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        cin >> t[i][j];
        if(t[i][j] == '@') {
          ax = j;
          ay = i;
        }
      }
    }
    
    solve();
  }
  return 0;
}



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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	string s;
	string ss = "2019/04/30";

	cin >> s;

	if (s <= ss) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
}

Measured memory_bytes: 256
N,K=gets.split.map &:to_i
p=gets.split.map{|i|(i.to_f+1)*0.5}
a=0
t=[0]
N.times do |i|
  t<<t[i]+p[i]
end
(N-K+1).times do |j|
  r=t[j+K]-t[j]
  a=[a,r].max
end
puts a


Measured memory_bytes: 20228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		if(A == B) {
			System.out.println(C);
		}else if(B == C) {
			System.out.println(A);
		}else if(C == A) {
			System.out.println(B);
		}
	}
}

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

using namespace std;

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

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

    int tot = accumulate(a.begin(), a.end(), 0);
    int cnt = 0;
    for (auto x:a) {
        if (x * 4 * M >= tot) cnt++;
    }

    if (cnt >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

const int N=1010;

int x;
int dd[N];

main(){
    #define task "TASK"
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    x=in; forinc(i,1,in) dd[in]=1;

    int best=500,id;
    forinc(i,0,101) if(!dd[i]) if(best>abs(x-i)) best=abs(x-i), id=i;
    cout<<id;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const int MAXN = 300005;
vector<int> tree[MAXN];
int in[MAXN];
int ans = 0;
int dp[MAXN],flag;
int chk[MAXN];
int wa;
int dfs(int here,int dad){
    int ccn = 0;
    for(int i=0;i<tree[here].size();i++){
        int there = tree[here][i];
        if(there == dad) continue;
        dfs(there,here);
        dp[here] += dp[there];
        ccn += (dp[there] > 0);
        
    }
    if(dad == -1){
        if(in[here]-1 > ccn){
            dp[here] += ((in[here]-1)-ccn);
        }
    }
    else{
        if(in[here]-2 > ccn){
            dp[here] += ((in[here]-2)-ccn);
        }
    }
    return 0;
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n;  cin>>n;
    int lim = 0;
    int root = 0;
    for(int i=1;i<=n-1;i++){
        int u,v; cin>>u>>v;
        tree[u].push_back(v);
        tree[v].push_back(u);
        in[u]++; in[v]++;
        lim = max(lim,in[u]);
        lim = max(lim,in[v]);
    }
    for(int i=1;i<=n-1;i++){
        if(in[i] >=3) root = i;
    }
    if(in[root]<=2){
        cout<<1; exit(0);
    }
    dfs(root,-1);
    cout<<max({1,dp[root],lim-1});
    
    return 0;
}


Measured memory_bytes: 16640
import math
from decimal import Decimal
a, b, c, d = list(map(int, input().split()))

cnt = 0
numc = b//c - math.ceil(Decimal(a)/Decimal(c)) + 1
numd = b//d - math.ceil(Decimal(a)/Decimal(d)) + 1

def gcd(a, b):
    if a == 0:
        return b
    elif b == 0:
        return a
    else:
        return gcd(b, a%b)

cd = (c*d) // gcd(c, d)
numcd = b//cd - math.ceil(Decimal(a)/Decimal(cd)) + 1

cnt = b - a + 1 - numc - numd + numcd

print(cnt)

Measured memory_bytes: 10080
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 100005;

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int n;
	cin >> n;
	int te;cin >> te;
	int a;
	rep(i,n-1) {
		cin >> a;
		te = __gcd(a,te);
	}
	cout << te << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

/// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

int main(){
    Sieve s(1000000); // 使う素数の最大　大きすぎると遅い(10^７くらいまで)
    int n;
    cin>>n;
    map<int,int> m;
    int a;
    rep(i,n){
        cin>>a;
        auto fs = s.factor(a);
        for(auto p : fs){
            m[p.F]++;
        }
    }
    int maxv=0; 
    for(auto itr=m.begin();itr!=m.end();itr++){
        maxv=max(maxv,(*itr).S);
    }
    if(maxv<=1) cout<<"pairwise coprime";
    else{
        if(maxv==n) cout<<"not coprime";
        else cout<<"setwise coprime";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 11104
#include <bits/stdc++.h>
using namespace std;
#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(v) v.begin(), v.end()

int main()
{
    int k, s;
    cin >> k >> s;
    vector<int> sum_ij;
    int count = 0;
    rep(i, k+1)
        rep(j, k+1)
            if (0 <= s - (i + j) && s - (i + j) <= k) count++;
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a[6];
    a[0] = 1,a[1] = 2,a[2] = 3,a[3] = 4,a[4] = 5,a[5] = 6;
    int b[6];
    for(int i = 1;i <= 6;i++)cin >> b[i];
    int n;
    cin >> n;
    int x,y;
    for(int i = 0;i < n;i++){
        cin >> x >> y;
        if(x == b[1]){
            if(y == b[2])cout << b[3];
            if(y == b[3])cout << b[5];
            if(y == b[4])cout << b[2];
            if(y == b[5])cout << b[4];
        }
        if(x == b[2]){
            if(y == b[1])cout << b[4];
            if(y == b[3])cout << b[1];
            if(y == b[4])cout << b[6];
            if(y == b[6])cout << b[3];
        }
        if(x == b[3]){
            if(y == b[2])cout << b[6];
            if(y == b[1])cout << b[2];
            if(y == b[6])cout << b[5];
            if(y == b[5])cout << b[1];
        }
        if(x == b[4]){
            if(y == b[1])cout << b[5];
            if(y == b[2])cout << b[1];
            if(y == b[5])cout << b[6];
            if(y == b[6])cout << b[2];
        }
        if(x == b[5]){
            if(y == b[1])cout << b[3];
            if(y == b[3])cout << b[6];
            if(y == b[4])cout << b[1];
            if(y == b[6])cout << b[4];
        }
        if(x == b[6]){
            if(y == b[2])cout << b[4];
            if(y == b[3])cout << b[2];
            if(y == b[4])cout << b[5];
            if(y == b[5])cout << b[3];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(ll &a,ll b){
	a = min(a,b);
}

int main(){
	int m1,d1; cin >> m1 >> d1;
	int m2,d2; cin >> m2 >> d2;

	if(m1+1 == m2) cout<< 1 << endl;
	else cout << 0 << endl;

	return 0;
}

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

a = list(map(int, input().split()))

Flag = True
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            pass
        else:
            Flag = False
            break
if Flag == True:
    print('APPROVED')
else:
    print('DENIED')

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

int main(){
    long long int N;
    vector<long long int> a;
    long long int x;
    long long int ans = 0;

    cin >> N;
    for(int i = 0; i < 3 * N; i++){
        cin >> x;
        a.push_back(x);
    }
    sort(a.begin(), a.end());

    for(int i = N; i <= a.size() - 2; i = i + 2){
        ans += a[i];
    }

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


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int k,s;
    cin >> k >> s;

    if(s==0) {
        cout << 1 << endl;
        return 0;
    }


    int ans=0;

    for(int x=0 ; x<=k ; x++){
        for(int y=0 ; y<=k ; y++){
            int z= s-x-y;
            if(z>=0 && z<=k){
                ans++;
            }
        }
    }


    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/8/ITP1_8_B

#include <iostream>
#include <cstring>
#include <vector>

int main()
{
    std::string num;
    int len = 0;
    int sum = 0;

    while (1)
    {
        std::cin >> num;
        std::vector<char> dig(num.begin(), num.end());

        if (dig[0] == '0')
        {
            return 0;
        }

        for (auto &x : dig)
        {
            sum += x - '0';
        }
        std::cout << sum << std::endl;

        sum = 0;
    }
}



Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <vector>

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

int n, q;
vector<int> graph[500000];
long long ans[500000];
long long inc[500000];
int mark[500000];

void dfs(int v, long long counter)
{
    mark[v] = 1;
    counter += inc[v];
    ans[v] = counter;
    for (int i = 0; i < graph[v].size(); i++)
    {
        int u = graph[v][i];
        if (mark[u] == 0)
        {
            dfs(u, counter);
        }
    }
    counter -= inc[v];
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for (int i = 0; i < q; i++)
    {
        int v, x;
        cin >> v >> x;
        inc[v] += x;
    }
    dfs(1, 0);
    for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}


Measured memory_bytes: 38144
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = input()
v = 0
for c in n:
    v += int(c)
if v%9==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 73680
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
int n,a[N];
LL sum[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),a[i]-=i;
	sort(a+1,a+n+1);
//	for(int i=1;i<=n;i++) cout<<a[i]<<' '; cout<<endl;
	int p=(n+1)/2;
//	cout<<a[p]<<endl;
	LL ans=0;
	for(int i=1;i<=n;i++)
	  ans+=abs(a[p]-a[i]);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    int max = -1;
    int maxidx = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
        if (l[i] > max)
        {
            max = l[i];
            maxidx = i;
        }
    }
    int sum = 0;
    for (int i = 0; i < l.size(); i++)
    {
        if (i != maxidx)
        {
            sum += l[i];
        }
    }
    // cout << sum << "," << max << endl;
    if (sum > max)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import kotlin.math.abs

fun main() {
    val (X, K, D) = readLine()!!.split(" ").map { it.toLong() }
    var x = abs(X)
    var k = K

    while (k > 0) {
        var p = if (k > x / D) {
            x / D
        } else {
            k
        }
        if (p == 0L) {
            break
        }
        x -= p * D
        k -= p
        x = abs(x)
    }
    x = if (k % 2 == 0L) {
        x
    } else {
        abs(x - D)
    }

    println(x)
}

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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<long long> pq;
  
  for(int i = 0; i < n; i++){
  	long long a;
    cin >> a;
    pq.push(a);
  }
  for(int i = 0; i < m; i++){
  	long long a = pq.top();
    a /= 2; pq.pop();
    pq.push(a);
  }
  
  long long ans = 0;
  for(int i = 0; i < n; i++){
  	ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1400