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

template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }

    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }

    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;
constexpr int MAX_FACTORIAL = 2020202;

mint fact[MAX_FACTORIAL];
mint factinv[MAX_FACTORIAL];

void init() {
    fact[0] = 1;
    for (int i = 1; i < MAX_FACTORIAL; i++) {
        fact[i] = fact[i - 1] * i;
    }
    factinv[MAX_FACTORIAL - 1] = fact[MAX_FACTORIAL - 1].inv();
    for (int i = MAX_FACTORIAL - 2; i >= 0; i--) {
        factinv[i] = factinv[i + 1] * (i + 1);
    }
    assert(factinv[0] == 1);
}

mint ncr(int n, int r) { return fact[n] * factinv[r] * factinv[n - r]; }

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

    init();
    int x, y;
    cin >> x >> y;

    int a = 2 * x - y;
    if (a < 0 || a % 3) {
        cout << 0 << endl;
        return 0;
    }
    a /= 3;
    int b = 2 * y - x;
    if (b < 0 || b % 3) {
        cout << 0 << endl;
        return 0;
    }
    b /= 3;
    cout << ncr(a + b, a) << endl;
}


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

int main(){
    string s;
    cin >> s;
    int len = s.length();
    int ans[len];
    memset(ans,0,sizeof(ans));
    int count = 0;
    char save='R';
    vector<int> point;
    rep(i,len){
        if(save=='R' && s[i]=='L'){
            point.push_back(i);
        }
        save=s[i];
    }
    save='R';
    int j=0;
    rep(i,len){
        if(save=='L' && s[i]=='R') j++;
        if(abs(i-point[j])%2==0) ans[point[j]]++;
        else ans[point[j]-1]++;
        save=s[i];
    }

    rep(i,len){
        printf("%d ",ans[i]);
    }
}

Measured memory_bytes: 1280
def divide2(n):
    return int(int(n)%2)

def divideT2(n):
    return int(int(n)/2)
    

N = int(input())
n_list = input().split()

flag = True
counter = 0
while flag == True:
    flag_list = list(map(divide2,n_list))
    if flag_list.count(1) == 0:
        n_list = list(map(divideT2,n_list))
        counter += 1
    else:
        flag = False

print(counter)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  ll ans = 0;

  rep(i, N + 1){
    if((i % 3 != 0) && (i % 5 != 0)) ans += i;
  }

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


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10**6)
K=input()

L=[]

def dfs(n,depth):
    L.append(n)
    if depth==9: return
    ichi_no_kurai=n%10
    for i in range(max(0,ichi_no_kurai-1),min(ichi_no_kurai+2,10)):
        next=n*10+i
        dfs(next,depth+1)

for n in range(1,10):
    dfs(n,0)

L.sort()
print L[K-1]

Measured memory_bytes: 45212
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int N;
void dfs(const string &S = "", char C = 'a') {
    if (SZ(S) == N) {
        cout << S << endl;
        return;
    }
    for (char c = 'a'; c <= C; ++c) {
        if (c == C)
            dfs(S + c, C + 1);
        else
            dfs(S + c, C);
    }
}

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

    cin >> N;
    dfs();

    return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cout << 3 * n * n << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			var p = cin.ArrayInt(n);

			int ans = 0;
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				if (i + 1 == p[i]) {
					++cnt;
				} else {
					if (cnt > 0) {
						ans += (cnt + 1) / 2;
					}

					cnt = 0;
				}
			}

			if (cnt > 0) {
				ans += (cnt + 1) / 2;
			}

			Console.WriteLine(ans);
		}
	}

	public static class Helper
	{
		public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Max(array[index], value);
		public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Max(array[index], value);

		public static T[] Array<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToArray();
		public static List<T> List<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToList();
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 18912
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn dfs(g:&Vec<Vec<(usize, usize)>>, color:&mut Vec<usize>, v:usize, p:usize, c:usize) {
    color[v] = c;
    for tup in &g[v] {
        let (n, l) = (tup.0, tup.1);
        if n == p {continue;}
        dfs(g, color, n, v, (c + l) % 2);
    }
}

fn main() {
    input! {
        N : usize,
        UVW : [(usize1, usize1, usize); N - 1]
    }

    // グラフを生成する
    let mut g = vec!(vec!(); N);
    for uvw in UVW {
        let (u, v, w) = uvw;
        g[u].push((v, w));
        g[v].push((u, w));
    }
    // 塗り分ける(ノード0を根かつ色1とする)
    let mut color = vec!(2usize; N);
    dfs(&g, &mut color, 0, 0, 0);

    for c in color {
        println!("{}", c);
    }
}


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

long int knapsack(long int a[][2],int n,int w,long int dp[][100001])
{if(dp[n][w]==0)
{if(n==0||w==0)
    dp[n][w]=0;
  else if(a[n-1][0]>w)
    dp[n][w]=knapsack(a,n-1,w,dp);
  else
     dp[n][w]=std::max(knapsack(a,n-1,w-a[n-1][0],dp)+a[n-1][1],knapsack(a,n-1,w,dp));}
  return dp[n][w];
}
  
                    
  
int main()
{long int n,w;
 std::cin>>n>>w;
 long int a[n][2];
 for(int i=0;i<n;i++)
 std::cin>>a[i][0]>>a[i][1];
 
 long int dp[n+1][100001]={};
 
 
  std::cout<<knapsack(a,n,w,dp);
 return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { 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; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    ll N;
    cin >> N;

    ll n = 0;
    for(int A = 1; A < N; A++){
        n += N / A;
        if(N % A == 0) n--;
    }

    cout << n << endl; 
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int N,K,Ans=1e9; 
int H[maxn];
int main()
{
	cin>>N>>K;
	for(int i=1;i<=N;i++) cin>>H[i];
	sort(H+1,H+1+N);
	for(int i=1;i+K-1<=N;i++) Ans=min(Ans,H[i+K-1]-H[i]);
	cout<<Ans<<endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    set<string>s;
    for(int i=0;i<n;i++){
        string x,y;
        cin>>x>>y;
        if(x[0]=='i'){
            s.insert(y);
            
        }
        else{
            if(s.find(y)!=s.end())cout<<"yes\n";
            else cout<<"no\n";
        }
    }
    
}


Measured memory_bytes: 32192
s = input()
t = input()
n = len(s)
m = len(t)
ans = []
for i in range(n - m + 1):
    flag = True
    for j in range(m):
        if s[i+j] != '?' and s[i+j] != t[j]:
            flag = False
            break
    if flag:
        ans.append(s[:i].replace('?', 'a') + t + s[i+m:].replace('?', 'a'))
if ans == []:
    print('UNRESTORABLE')
else:
    ans.sort()
    print(ans[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n%2==0)cout<<n<<endl;
    else cout<<n*2<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");

//     String nyu=sc.nextLine();
//int[] num=new int[6];
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu);
//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/


System.out.println(A-B+1) ;

	}
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n;
i64 mod_pow(i64 x, i64 y, i64 mod){
	i64 res = 1;
	while(y > 0){
		if(y & 1) res = res * x % mod;
		x = x*x %mod;
		y >>= 1;
	}
	return res;
}
void solve(){
	cin >> n;
	
	i64 ans = 1;
	for(int i = 2; i < n; i++){
		for(int j = 2; ; j++){
			i64 cnt = mod_pow(i,j, LINF);
			if(cnt > n) break;
			chmax(ans, cnt);
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  vector<long long> h(n);
  for(int i=0;i<n;i++){
  cin>>h[i];
  }
  h[0]--;
  for(int i = 1; i < n; i++){
        if(h[i - 1] < h[i]) h[i]--;
    }
    for(int i = 1; i < n; i++){
        if(h[i - 1] > h[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 4052
#include<iostream>
using namespace std;
int main(){
  int M;
  int D;
  int d1,d2;
  int ans=0;
  cin >> M >> D;
    for(int i=1;i<=M;i++){
      for(int j=1;j<=D;j++){
        d1=j/10;
  		d2=j%10;
        if((d1>=2) && (d2>=2))
         if(i==d1*d2){
           ans++;
         }
      }
    }
  cout << ans << endl;
  return 0;
}

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

int N, M, cnt;
int Map[21][21];

struct Position{
	int x;
	int y;
}robot;

void initMap(void){
	int i, j;
	for(i = 0; i < 21; i++){
		for(j = 0; j < 21; j++){
			Map[i][j] = 0;
		}
	}
}

void setGems(int x, int y){
	Map[x][y] = 1;
}

int main(){
	int x, y, step;
	char dir;
	while(true){
		initMap();
		cnt = 0;
		robot.x = 10; robot.y = 10;
		cin >> N;
		if(N == 0)	break;
		for(int i = 0; i < N; i++){
			cin >> x >> y;
			setGems(x, y);
		}
		cin >> M;
		for(int i = 0; i < M; i++){
			cin >> dir >> step;
			switch(dir){
				case 'N':
					for(int i = 0; i < step; i++){
						robot.y++;
						if(Map[robot.x][robot.y] == 1)	cnt++; Map[robot.x][robot.y] = 0;
					}
					break;
				case 'E':
					for(int i = 0; i < step; i++){
						robot.x++;
						if(Map[robot.x][robot.y] == 1)	cnt++; Map[robot.x][robot.y] = 0;
					}
					break;
				case 'S':
					for(int i = 0; i < step; i++){
						robot.y--;
						if(Map[robot.x][robot.y] == 1)	cnt++; Map[robot.x][robot.y] = 0;
					}
					break;
				case 'W':
					for(int i = 0; i < step; i++){
						robot.x--;
						if(Map[robot.x][robot.y] == 1)	cnt++; Map[robot.x][robot.y] = 0;
					}
					break;
				default:
					break;

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

Measured memory_bytes: 1152
#include<cstdio>
#include<iostream>
#define INF 10000000
using namespace std;
int dp[2][100000][2]={{{0}}};

int main(){

    for(int i = 0;i < 2;i++){
        for(int j = 0;j < 100000;j++){
            dp[i][j][0] = dp[i][j][1] = INF;
        }
    }
    int N;
    cin>>N;
    int v[100000]={0};
    for(int i = 0; i < N - 1;i++){
        cin>>v[i+1];
    }
    v[N-1] = 0;
    for(int i = 0;i < N;i++){

        //dp[i%2][0][1] = 0;
    }
    //i番目の場所までに、一方にj[mm]与えたときの時間 k==0なら右端は与えられている
    for(int i = 0;i < N;i++){
        //cout<<"v = "<<v[i]<<endl;
        for(int j = 0;j < N+1;j++){
            for(int k = 0;k < 2;k++){
                dp[(i+1)%2][j][k] = INF;
            }
        }
        dp[(i+1)%2][0][1] = v[i];

        for(int j = 0;j < N/2;j++){
            if(dp[i%2][j][1]!=INF){
                dp[(i+1)%2][j+1][0] = min(dp[(i+1)%2][j+1][0],dp[i%2][j][1]+v[i]);
                dp[(i+1)%2][j][1] = min(dp[(i+1)%2][j][1],dp[i%2][j][1]-v[i-1]+v[i]);
            }
            if(dp[i%2][j][0]!=INF){
                dp[(i+1)%2][j+1][0] = min(dp[(i+1)%2][j+1][0],dp[i%2][j][0]-v[i-1]+v[i]);
                dp[(i+1)%2][j][1] = min(dp[(i+1)%2][j][1],dp[i%2][j][0]+v[i]);
            }
        }
/*
        for(int k = 0;k < 2;k++){
            cout<<"i = "<<i<<" : ";
            if(k==0)cout<<"k=0 : ";
            else cout<<"k=1 : ";
            for(int j = 0;j < N/2;j++){
                if(j==N/2)cout<<".";

                if(dp[(i+1)%2][j][k]!=INF)
                    printf("%4d ",dp[(i+1)%2][j][k]);
                else cout<<"**** ";
            }
            cout<<endl;
        }
        cout<<endl;
        // */
    }
    /*
    for(int k = 0;k < 2;k++){
        for(int j = 0;j < N-1;j++){
            if(dp[0][j][k]!=INF)printf("%3d ",dp[0][j][k]);
            else cout<<"*** ";
        }
        cout<<endl;
    }
    /*for(int i = 0;i < N-1;i++){
        for(int j = 0;j < N-1;j++){
            if(dp[i][j][0]!=INF)
                printf("%3d ",dp[i][j][0]);
            else cout<<"*** ";
        }
        cout<<endl;
    }
    cout<<"----------"<<endl;
    for(int i = 0;i < N-1;i++){
        for(int j = 0;j < N-1;j++){
            if(dp[i][j][1]!=INF)
                printf("%3d ",dp[i][j][1]);
            else cout<<"*** ";
        }
        cout<<endl;
    }*/
    int ans = INF;
    ans = min(dp[0][N/2-1][0],dp[0][N/2-1][0]);

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

Measured memory_bytes: 3116
N = int(input())
count = 0
A = list(map(int,input().split()))
#print(A)

for i in range(1,N):
    #print(A[i-1],A[i])
    if A[i] < A[i-1]:
        count += A[i-1]-A[i]
        A[i] += A[i-1]-A[i]
print(count)

Measured memory_bytes: 32096
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n, w;
int value[102], weight[102];
long long dp[102][100002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> w;
    for(int i = 1; i <= n; ++i)
        cin >> weight[i] >> value[i];
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= 100000; j++)
            dp[i][j] = (1LL<<30); // a big value assigned
    dp[0][0] = 0; // empty set
    /// 100000 = max value we can get (1e3 * 1e2)
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j <= 100000; ++j)
        {
            dp[i+1][j + value[i+1]] = min(dp[i+1][j + value[i+1]], dp[i][j] + weight[i+1]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    long long ans = 0;
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= 100000; ++j)
            if(dp[i][j] <= w)
                ans = max(ans, 1LL * j);
    cout << ans;
    return 0;
}


Measured memory_bytes: 79232
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;

int main(){
    char a,b;
    cin>>a;
    b='A';
    string s="qwertyuiopasdfghjklzxcvbnm";
    for(int i=0;i<s.size();i++){
        if(s[i]==a){
            b='a';
        }
    }
    cout<<b<<endl;
}


Measured memory_bytes: 3568
A,B,K=map(int,input().strip().split(' '))
while not K==0:
    if A%2==0:
        B+=A/2
        A=A/2
    else:
        A-=1
        B+=A/2
        A=A/2
    K-=1
    if K==0:
        break
    if B%2==0:
        A+=B/2
        B=B/2
    else:
        B-=1
        A+=B/2
        B=B/2
    K-=1
print(int(A),int(B))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        int zero = 0;
        int one = 0;
        for (int i = 0; i < s.length(); i++) {
            if(c[i] == '0') zero++;
            else one++;
        }
        int ans = Math.min(zero, one) * 2;
        System.out.println(ans);
    }
}

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

const MOD: i64 = 1_000_000_007;
pub fn pow_mod(x: i64, n: i64) -> i64 {
    let mut x = x;
    let mut n = n;
    let mut res = 1;
    while n > 0 {
        if n & 1 == 1 {
            res = res * x % MOD
        }
        x = x * x % MOD;
        n >>= 1;
    }
    res
}

#[fastout]
fn main() {
    input! {
        n: i64
    }
    let a = pow_mod(10, n);
    let b = pow_mod(9, n);
    let c = pow_mod(8, n);
    let mut res = (a + c - b - b) % MOD;
    res = (res + MOD) % MOD;
    println!("{}", res);
}


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

int main() {
  int n;
  cin>>n;
  vector<int> mao(n);
  for (int i=0; i<n; i++) {
    cin>> mao.at(i);
  }
  
  vector<int> mao2=mao;
  sort(mao2.begin(),mao2.end());
  
  int z=0;
  for (int i=0; i<n;i++) {
    if (mao.at(i)!=mao2.at(i)) {
      z++;
    }
  }
  
  if (z==0 || z==2) {
    cout<< "YES"<<endl;
  }
  else {
    cout<< "NO"<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int x[10000];
int y[10000];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<c;i++)scanf("%d%d",x+i,y+i);
	int ret=0;
	for(int i=1;i<c;i++){
		int dx=x[i]-x[i-1];
		int dy=y[i]-y[i-1];
		if(dx*dy>0)ret+=max(ABS(dx),ABS(dy));
		else ret+=ABS(dx)+ABS(dy);
	}
	printf("%d\n",ret);
}

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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()
#define allpt_c(v) (v).cbegin(), (v).cend()
#define allpt_r(v) (v).rbegin(), (v).rend()



const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(vector<T> v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

template <typename T>
void show2dvec(vector<vector<T>> v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

vector<string> adding(vector<string> &vs)
{
    int k;
    char c, d;
    string y, w;
    vector<string> ret;
    for (auto z : vs)
    {
        c = 'a';

        w = z;
        d = *max_element(allpt(z));

        k = d - 'a' + 2;


        rep(i, k)
        {
            y = z;
            y += c;
            ret.push_back(y);
            c++;
        }
    }
    sort(allpt(ret));
    return ret;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif


    int n;
    cin >> n;

    vector<string> vs;
    vs.push_back("a");
    

    rep(i, n - 1) vs = adding(vs);

    for (auto z : vs) cout << z << rt;

    return 0;
}


Measured memory_bytes: 10956
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
color = []
for i, v in enumerate(a):
    for _ in range(v):
        color.append(i+1)
ans = [[0] * w for _ in range(h)]
q = 1
x, y = 0, -1
for i in range(h*w):
    if q == 1:
        if y == w-1:
            x += 1
            q = 0
        else:
            y += 1

    elif q == 0:
        if y == 0:
            x += 1
            q = 1
        else:
            y -= 1
    ans[x][y] = color[i]
for w in ans:
    print(*w)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main() {
  int n;
  cin >> n;
  int flag = 0;
  while (n--) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) {
      flag++;
    } else {
      flag = 0;
    }
    if (flag == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

static const int DataMax = 100;

static void input(std::vector<int>& hills)
{
    int val = 0;

    while (std::cin >> val) {
        hills.push_back(val);
    }
}

static int getMax(std::vector<int>& hills)
{
    std::sort(hills.begin(), hills.end());
    int ret = hills.back();
    hills.pop_back();

    return ret;
}

int main()
{
    std::vector<int> vec;

    input(vec);
    for (int i = 0; i < 3; i++) {
        std::cout << getMax(vec) << std::endl;
    }

    return 0;
}

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

typedef long long ll;

ll gcd(ll numA, ll numB){
    return numB ? gcd(numB, numA % numB) : numA;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> nums(N);
    int minusCount = 0;
    for(int i = 0; i < N; i++)
    {
       ll num;
       cin >> num;
       nums.at(i) = num;
    }
    vector<ll> gcds(N + 1);
    vector<ll> revGcds(N + 1);
    gcds.at(0) = nums.at(0);
    for(int i = 1; i < N; i++)
    {
        gcds.at(i) = gcd(nums.at(i), gcds.at(i - 1));
    }
    revGcds.at(N - 1) = nums.at(N - 1);
    for(int i = N - 2; i >= 0; i--)
    {
        revGcds.at(i) = gcd(nums.at(i), revGcds.at(i + 1));
    }
    ll answer = 0;
    for(int i = 0; i < N; i++){
        if (i == 0){
            answer = max(answer, revGcds.at(1));
        } else if(i == N - 1){
            answer = max(answer, gcds.at(N - 2));
        } else {
            answer = max(answer, gcd(gcds.at(i - 1), revGcds.at(i + 1)));
        }
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
  ll n, k;
  cin >> n >> k;
  if ((n % k) == 0) {
    cout << "0";
    exit(0);
  }
  else {
    cout << min(n % k, abs(n % k - k));
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(5e5 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;


int main () {
	ll n, m, v, p;
	cin >> n >> m >> v >> p;
	ll ar[n];
	for (ll i = 0; i < n; i++) {
		cin >> ar[i];
	}
	sort (ar, ar + n, greater<ll> ());
	for (ll i = 0; i < n; i++) {
	}
	ll cc = p, mi = 0;
	for (ll i = p; i < n; i++) {
		if (ar[i] == ar[p - 1]) {
			cc++;
			continue;
		}
		ll x = v - (n - i + p - 1);
		ll xx = max (0LL, (m * x - mi));
		ll ma = ar[p - 1] + xx / (i - p + 1) + (xx % (i - p + 1) > 0);
		if (ma <= ar[i] + m) {
			cc++;
		}
		mi += (ar[p - 1] - ar[i]);
	}
	cout << cc << "\n";
}


Measured memory_bytes: 1152
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()

	a := n / 100
	c := n % 10
	if a == c {
		println("Yes")
	} else {
		println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll yojo[10010];
bool f[10010];
int main(){
	ll n;
	cin>>n;
	vector<vector<ll>>ro(n+1);
	for(int i=0;i<n-1;i++){
		ll a,b;
		cin>>a>>b;
		ro[a].push_back(b);
		ro[b].push_back(a);
	}
	vector<ll>c;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		c.push_back(x);
	}
	sort(c.begin(),c.end(),greater<ll>());
	ll num;
	for(int i=1;i<=n;i++){
		if(ro[i].size()==1){
			num=i;
			break;
		}
	}
	queue<ll>que;
	que.push(num);
	f[num]=1;
	yojo[num]=c[0];
	ll ans=0,now=1;
	while(!que.empty()){
		ll x=que.front();
		que.pop();
		for(ll p:ro[x]){
			if(f[p])continue;
			f[p]=1;
			yojo[p]=c[now];
			ans+=c[now];
			now++;
			que.push(p);
		}
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)cout<<yojo[i]<<' ';
	return 0;
}

Measured memory_bytes: 4132
//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(),(n).end()
#define clr(v,val) memset(v , val , sizeof v)
#define EPS 1e-9
#define OO 1e9
#define PI acos(-1.0)
#define ll long long
#define endl "\n"

void file(){
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}


ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = { -1, 0, 1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//473,700
//7000
const int N = 2e6 + 5, mod = 1e9 + 7;
int num = 1;
void get(vector<vector<char>> a){
	int n = a.size();
	int m = a[0].size();
	vector<vector<int>> v(n, vector<int>(m));
	int x = 0;
	vector<int>c(m);
	for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++){
		if (a[i][j] == '#'){
			c[j] = 1;
			x = max(x, j);
		}
	}
	int str = 0;
	for (int i = 0; i < x; i++)
	if(c[i]){
		while (str <= i)v[0][str++] = num;
		num++;
	}
	while (str < m )v[0][str++] = num;
	num++;

	for (int i = 1; i < n; i++)
	for (int j = 0; j < m; j++)
		v[i][j] = v[i - 1][j];

	for (auto i : v){
		for (int j = 0; j < m; j++){
			if (j)cout << " ";
			cout << i[j];
		}
		cout << endl;
	}
}
int main()
{
	/*** بسم الله الرحمن الرحيم  ***/
	//cout << fixed << setprecision(6);
	//file();
	fast();
	int n, m, k;
	cin >> n >> m >> k;
	vector<vector<char>>a(n, vector<char>(m));
	vector<int>c(n);
	int x = 0;
	for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++){
		cin >> a[i][j];
		if (a[i][j] == '#')
			c[i] = 1, x = i;
	}
	vector<vector<vector<char>>> v;
	int str = 0;
	for (int i = 0; i < x; i++){
		if (c[i]){
			v.push_back(vector<vector<char>>());
			while (str <= i){
				v.back().push_back(a[str++]);
			}
		}
	}
	v.push_back(vector<vector<char>>());
	while (str < n){
		v.back().push_back(a[str++]);
	}
	for (auto i : v)
		get(i);
}

Measured memory_bytes: 1024
//Volume1-0134
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		//declare
		long num = 0,
		     sum = 0;
		
		//input
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			
			//calculate
			sum += sc.nextInt();
			num++;
		}
		
		//output
		System.out.println(sum / num);
	}
}

Measured memory_bytes: 31088
#include<stdio.h>
int main(void)
{
	int n,a,i;
	while(1)
	{
		scanf("%d", &n);
		if(n==0)
		break;
		for(i=0; i<9; i++)
		{
			scanf("%d", &a);
			n-=a;
		}
		printf("%d\n", n);
	}
	
	return 0;
}


Measured memory_bytes: 2032
#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>;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    rep(i,s.size()) {
      if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
        cnt++;
      }
      else {
        ans = max(ans, cnt);
        cnt = 0;
      }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <cstdlib>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

int n,k;
ll h[110000];
ll dp[110000];

int main(void){
    cin>>n>>k;
    rep(i,0,n - 1) cin>>h[i];
    rep(i,0,100010 - 1) dp[i] = INF;
    dp[0] = 0;
    rep(i,0,n-1){
        rep(j,1,k){
            chmin(dp[i+j],dp[i]+abs(h[i+j] - h[i]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
# ABC122B

import numpy as np

def rle(x):
    ''' Run Length Encoding

    rle('001111000000011')
    (array([2, 4, 7, 2]),
     array(['0', '1', '0', '1'], dtype='<U1'))

    rle('aabcccbbbaab')
    (array([2, 1, 3, 3, 2, 1]),
     array(['a', 'b', 'c', 'b', 'a', 'b'], dtype='<U1'))
    '''
    x = np.array(list(x))
    n = len(x)
    if n == 0:
        return (1, '')
    y = list(map(lambda a, b: a != b, x[1:], x[:-1]))
    i = np.hstack((np.where(y)[0]+1, n))
    return (np.diff(np.hstack((0, i))), x[i-1])

s = list(input())
for i in range(len(s)):
    if s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
        s[i] = 'A'
count, value = rle(s)
obj = count[value == 'A']
if len(obj) == 0:
    print(0)
else:
    print(max(obj))


Measured memory_bytes: 12500
# ABC 133: B – Good Distance
from itertools import combinations

n, d = [int(s) for s in input().split()]

x = []
for _ in range(n):
    x.append([int(s) for s in input().split()])

pairs = list(combinations(x, 2))
the_number_of_pairs = 0

#print(pairs)

for i in range(len(pairs)):
    distance = 0

    for j in range(d):
        distance += (abs(pairs[i][0][j] - pairs[i][1][j])) ** 2
    
    distance = distance ** 0.5

    if distance == int(distance):
#        print(pairs[i])
        the_number_of_pairs += 1

print(the_number_of_pairs)

Measured memory_bytes: 3188
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s
}

fn main() {
    let x = read_line().split_whitespace().map(|e|e.parse().unwrap())
        .collect::<Vec<i32>>();
    let a = x[0] * x[1];
    let b = x[2] * x[3];
    if a > b {
        println!("{}",a);
    }else if b > a {
        println!("{}",b);
    }else{
        println!("{}",a);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  int a; cin >>a;
  cout <<3*a*a;
return 0;}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a, b;
vector<vector<ll>> g;
vector<ll> e, o, ans;

void dfs(ll at, ll from, ll mod){

	if(mod == 0){
		e.push_back(at);
	}
	else{
		o.push_back(at);
	}
	
	zep(i, 0, g[at].size()){
		if(g[at][i] != from){
			dfs(g[at][i], at, 1-mod);
		}
	}
	return;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	g.resize(n);
	zep(i, 0, n-1){
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	dfs(0, -1, 0);
	
	ans.resize(n);
	ll a = e.size();
	ll b = o.size();
	ll x = (n+2)/3;
	ll y = (n+1)/3;
	ll z = n/3;
	if(a <= z){
		zep(i, 0, a){
			ans[e[i]] = 3*z;
			z--;
		}
		zep(i, 0, b){
			if(x > 0){
				ans[o[i]] = 3*x-2;
				x--;
			}
			else{
				if(y > 0){
					ans[o[i]] = 3*y-1;
					y--;
				}
				else{
					ans[o[i]] = 3*z;
					z--;
				}
			}
		}
	}
	else{
		if(a <= x+z){
			zep(i, 0, a){
				if(x > 0){
					ans[e[i]] = 3*x-2;
					x--;
				}
				else{
					ans[e[i]] = 3*z;
					z--;
				}
			}
			zep(i, 0, b){
				if(y > 0){
					ans[o[i]] = 3*y-1;
					y--;
				}
				else{
					ans[o[i]] = 3*z;
					z--;
				}
			}
		}
		else{
			zep(i, 0, b){
				ans[o[i]] = 3*z;
				z--;
			}
			zep(i, 0, a){
				if(x > 0){
					ans[e[i]] = 3*x-2;
					x--;
				}
				else{
					if(y > 0){
						ans[e[i]] = 3*y-1;
						y--;
					}
					else{
						ans[e[i]] = 3*z;
						z--;
					}
				}
			}
		}
	}
	zep(i, 0, n){
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 19688
import os

N,K,Q = (int(x) for x in input().split())
A = [input() for i in range(Q)]

B = [K-Q]*N

for i in range(0,Q):
    B[int(A[i])-1] += 1

for j in range(0,N):
    if B[j] > 0:
        print("Yes")
    else:
        print("No")


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

const int N = 1005;
const int W = 20005;

struct Box {
  int w, s, v;

  void read() {
    scanf("%d %d %d", &w, &s, &v);
  }
};

long long dp[N][W];
int n;

Box arr[N];

void read() {
  cin >> n;
  for (int i = 0 ; i < n ; i++) {
    arr[i].read();
  }
}

long long solve(int pos, int sisa) {
  if (sisa < 0) return -4e18;
  if (pos == n) return 0;

  long long &ret = dp[pos][sisa];
  if (ret != -1) return ret;

  ret = solve(pos+1, sisa);
  ret = max(ret, arr[pos].v + solve(pos+1, min(sisa - arr[pos].w, arr[pos].s)));

  return ret;
}

long long work() {
  memset(dp, -1, sizeof dp);
  sort(arr, arr + n, [](Box a, Box b) {
    return a.s - b.w > b.s - a.w;
  });

  // for (int i = 0 ; i < n ; i++) {
  //   printf("%d %d %d\n", arr[i].w, arr[i].s, arr[i].v);
  // }

  return solve(0, W-1);
}

int main() {
  read();
  cout << work() << endl;
  return 0;
}

Measured memory_bytes: 157312
class DoublyLinkedList
    class Ele
        attr_accessor :value, :preview, :next
        def initialize(key)
            @value = key
            @preview = nil
            @next = nil
        end
    end

    def insert(key)
        ele = Ele.new(key)

        unless @first == nil
            @first.preview = ele
            ele.next = @first
        end
        @first = ele
        if @last == nil
            @last = ele
        end
    end

    def delete(key)
        pointer = @first
        pointer = pointer.next until pointer == nil or pointer.value == key

        unless pointer == nil
            if pointer == @first
                deleteFirst
            elsif pointer == @last
                deleteLast
            else
                pointer.next.preview = pointer.preview
                pointer.preview.next = pointer.next
            end
        end
    end

    def deleteFirst
        if @last == @first
            @first = nil
            @last = nil
        else
            @first = @first.next
            @first.preview = nil
        end
    end

    def deleteLast
        if @first == @last
            @first = nil
            @last = nil
        else
            @last = @last.preview
            @last.next = nil
        end
    end

    def showAll
        pointer = @first
        until pointer == nil
            print pointer.value
            print ' ' unless pointer.next == nil
            pointer = pointer.next
        end

        print "\n"
    end
end

dLList = DoublyLinkedList.new
no = gets.to_i
no.times {
    command,key = gets.split
    case command
    when 'insert'
        dLList.insert(key)
    when 'delete'
        dLList.delete(key)
    when 'deleteFirst'
        dLList.deleteFirst
    when 'deleteLast'
        dLList.deleteLast
    end
}
dLList.showAll

Measured memory_bytes: 478988
import java.util.*

fun main(args:Array<String>):Unit {
    val n = readLine()!!.trim().toInt()
    val lamps = readLine()!!.trim().split(' ').map(String::toInt)
    var length = 1
    val stack = Stack<Int>()
    for (i in 1 until n){
        if (lamps[i] == lamps[i - 1]) {
            stack.push(length)
            length = 1
        }else{
            length++
        }
    }
    stack.push(length)
    val len = stack.toIntArray()
    println(if (len.size > 2) (1 until len.size - 1).map{len[it - 1] + len[it] + len[it + 1]}.max()!! else n)
}


Measured memory_bytes: 54508
//
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


int main(){
    int N,D;
    cin >> N >> D;
    int x=0;
    for(int i:range(N)){
        int a;
        cin>>a;
        x^=(a-1)%(D+1);
    }
    if(x==0)cout<<"Second"<<endl;
    else cout<<"First"<<endl;
    return 0;
}


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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int x;
    cin >> x;
    cout << lcm(x, 360) / x << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3644