akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello
{
    public static void Main()
    {
        int kosu=int.Parse(Console.ReadLine());
        int [] target=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        bool frag=true;
        int kaisu=0;
        
        while(frag)
        {
            frag=false;
        for(int i=kosu-1;i>0;i--)
        {
            if(target[i]<target[i-1])
            {
                int a=target[i];
                target[i]=target[i-1];
                target[i-1]=a;
                frag=true;
                kaisu++;
            }
        }
        }
        Console.WriteLine(string.Join(" ",target));
        Console.WriteLine(kaisu);
    }
}




Measured memory_bytes: 18348
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000000000LL
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n;
string s;
ll r, b, g, rb, rg, bg;

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

    ll ans = 1;

    cin >> n >> s;
    F0R(i, 3*n){
        if(s[i] == 'R'){
            if(bg != 0){
                ans = (ans*bg)%MOD;
                bg--;
            } else if(b != 0){
                ans = (ans*b)%MOD;
                b--;
                rb++;
            } else if(g != 0){
                ans = (ans*g)%MOD;
                g--;
                rg++;
            } else{
                r++;
            }
        } else if(s[i] == 'B'){
            if(rg != 0){
                ans = (ans*rg)%MOD;
                rg--;
            } else if(r != 0){
                ans = (ans*r)%MOD;
                r--;
                rb++;
            } else if(g != 0){
                ans = (ans*g)%MOD;
                g--;
                bg++;
            } else{
                b++;
            }
        } else if(s[i] == 'G'){
            if(rb != 0){
                ans = (ans*rb)%MOD;
                rb--;
            } else if(b != 0){
                ans = (ans*b)%MOD;
                b--;
                bg++;
            } else if(r != 0){
                ans = (ans*r)%MOD;
                r--;
                rg++;
            } else{
                g++;
            }
        }
        //cout << ans << "\n";
        //cout << r << " " << b << " " << g << " " << rb << " " << rg << " " << bg << "\n";
    }
    FOR(i, 1, n){
        ans = (ans*i)%MOD;
    }
    
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 720
n = int(input())
if n == 0:
    print(0)
    exit()

ans = list()
while n != 0:
    ans.append(str((n%-2)*(-1)))
    if n % (-2) < 0:
        n = n // (-2) + 1
    else:
        n = n // (-2)

print(''.join(reversed(ans)))

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

int main() {
    string S; cin >> S;
    string s1 = S.substr(0, S.size() / 2);
    string s2 = S.substr(S.size() / 2 + 2 / 2, S.size() / 2);
    if (s1 == s2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mk make_pair
#define N 100005
using namespace std;
int n,fa[N];
int find(int x)
{
    if(x==fa[x])return x;
    return fa[x]=find(fa[x]);
}
map<pair<int,int>,int>mp;
queue<pair<int,int> >q;
set<int>s[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)fa[i]=i;
    for(int i=1;i<=2*n-2;i++)
    {
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        s[t1].insert(t2);s[t2].insert(t1);
        if(t1<t2)swap(t1,t2);
        mp[mk(t1,t2)]++;
        if(mp[mk(t1,t2)]>1)q.push(mk(t1,t2));
    }
    for(int j=1;j<n;j++)
    {
        if(q.empty())return puts("NO"),0;
        int x=find(q.front().first),y=find(q.front().second);q.pop();
        mp[mk(x,y)]=-1000;
        if(s[x].size()>s[y].size())swap(x,y);fa[x]=y;
        for(auto i=s[x].begin();i!=s[x].end();++i)
        {
            int v=(*i);if(v==y)continue;
            s[v].erase(s[v].find(x));s[v].insert(y);s[y].insert(v);
            int t1=v,t2=y;if(t1<t2)swap(t1,t2);
            mp[mk(t1,t2)]++;if(mp[mk(t1,t2)]>1)q.push(mk(t1,t2));
        }
        s[y].erase(x);s[x].clear();
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 40704
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    loop {
        let (h, w) = read_parameters::<usize>().map(|xs| (xs[0], xs[1])).unwrap();
        if h == 0 && w == 0 {
            break;
        }

        let mut l1 = "#".to_string();
        let mut l2 = ".".to_string();

        for i in 1..w {
            if i % 2 == 1 {
                l1 += ".";
                l2 += "#";
            } else {
                l1 += "#";
                l2 += ".";
            }
        }

        for i in 0..h {
            if i % 2 == 0 {
                println!("{}", l1);
            } else {
                println!("{}", l2);
            }
        }
        println!("");
    }
}



Measured memory_bytes: 5040
var
	ans,m,k,i:Longint;
	c:Char;
	s:String;
begin
	readln(s);
	c:=chr(97);
	ans:=114514;
	while ord(c)<123 do begin
		m:=0;
		k:=0;
		for i:=1 to length(s)do begin
			if s[i]=c then begin
				if m<k then m:=k;
				k:=0;
			end else inc(k);
		end;
		if m<k then m:=k;
		if ans>m then ans:=m;
		c:=chr(ord(c)+1);
	end;
	writeln(ans);
end.


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n; 
    vll used(n,-1);
    ll x1,x2;
    REP(i,n+1){
        ll a;
        cin >> a;
        a--;
        if(used[a]>=0){
            x1 = used[a];
            x2 = i;
        }else{
            used[a] = i;
        }
    }
    ll rm = x1 + (n-x2);
    mint combi = 1;
    mint combi2 = 1;
    for(ll i = 1; i<=n+1;i++){
        mint k = i;
        mint bunsi = n+2-k.x;
        mint bunbo = k;
        mint ans = combi*bunsi;
        ans = ans/bunbo;
        combi = ans;
        if(i-1<=rm&&i-1>0){
            mint bunsi2 = rm-i+2;
            mint bunbo2 = i-1;
            combi2 = combi2*bunsi2;
            combi2 = combi2/bunbo2;
            ans-=combi2;
        }else if(i==1){
            ans-=1;
        }
        cout << ans.x << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int A, B, X;
    cin >> A >> B >> X;
    X -= A;
    if (B >= X && X >= 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}

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;

int main() {
    string L;
    cin >> L;
    int n = L.size();
    vector<ll> dp0(n + 1, 0), dp1(n + 1, 0);
    dp1[0] = 1;
    ll MOD = 1e9 + 7;
    rep(i, n) {
        if (L[i] == '0') {
            dp1[i + 1] = dp1[i]; 
            dp0[i + 1] = (dp0[i] * 3) % MOD;
        } else {
            dp1[i + 1] = (dp1[i] * 2) % MOD;
            dp0[i + 1] = (dp0[i] * 3 + dp1[i]) % MOD;
        }
    }
    cout << (dp0[n] + dp1[n]) % MOD << "\n";
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&k);
        sum+=k%2;
        sum%=2;
    }
    if(sum) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
class TrainTicket():
    def calculate(self, S: list):
        for x in range(2):
            for y in range(2):
                for z in range (2):
                    if x == 1:
                        res = S[0] + S[1]
                    else:
                        res = S[0] - S[1]
                    if y ==1:
                        res += S[2]
                    else:
                        res -= S[2]
                    if z == 1:
                        res += S[3]
                    else:
                        res -= S[3]
                    if res == 7:
                        if x == 1:
                            xr = "+"
                        else:
                            xr = "-"
                        if y == 1:
                            yr = "+"
                        else:
                            yr= "-"
                        if z == 1:
                            zr = "+"
                        else:
                            zr = "-"
                        return(str(S[0]) + xr + str(S[1]) + yr + str(S[2]) + zr + str(S[3]))


if __name__ =="__main__":
    S = list(map(int, input()))
    tt = TrainTicket()
    res = tt.calculate(S)
    print(str(res)+"=7")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  vector<int> a(3);
  REP(i,3) cin >> a[i];
  sort(ALL(a));
  int cnt = 0; 
  while(1){
    if(a[1] == a[2]) break;
    else {
      a[0]++;
      a[1]++;
    }
    cnt++;
  }

  while(1){
    if(a[0] == a[1]) break;
    if(a[0] == a[1]+ 1){
      cnt++;
      break;
    }
    a[0] += 2;
    cnt++;
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3576
import numpy as np
N = input()
N = int(N)
B = np.hstack([int(a) for a in input().split()])

A = np.zeros(N)
A[0] = B[0]
A[-1] = B[-1]
for i in range(N-2):
  A[i+1] = min(B[i], B[i+1])
               
print(int(np.sum(A)))

Measured memory_bytes: 12440
(let* ((n (read))
			 (a (read))
			 (x (make-array n :initial-contents (loop :repeat n :collect (read))))
			 (cache (make-array (expt 51 4) :initial-element nil)))
	(defun s (v k i)
		(cond ((= i n) (if (and (> v 0) (= v (* k a))) 1 0))
					((> v (* a n)) 0)
					(t (let ((key (+ (* v 51 51) (* k 51) i)))
							 (if (aref cache key)
									 (aref cache key)
									 (setf (aref cache key) (+ (s v k (1+ i))
																						 (s (+ v (aref x i)) (1+ k) (1+ i)))))))))
  (format t "~a~%" (s 0 0 0)))


Measured memory_bytes: 71392
//
// Created by Hideaki Imamura on 2020-03-25.
//
# include <bits/stdc++.h>

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

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

void print_vec(vector<int> v) {
    for (auto x : v) cout << x << " ";
    cout << endl;
}

string s, t;
int last[26];
int nxt[26][500000];

int main() {
    cin >> s >> t;
    /* 頭からtを見ていき、各t[i]がs内で登場するかどうか見る
     * 登場しないなら、存在しないことになる
     * 各ch = t[i]とs'の添字jに対して、x = j mod len(s) として、
     * f(ch, x) = sにおいてx文字目以降でchがはじめに登場する位置
     * を計算できればOKっぽい
     * f(ch, x)は、各アルファベットの出現位置のリストを計算しておくと
     * リストからx以上の最小元を取り出すことになるので、lower_boundでいけそう。
     *
     * x が sの長さより長いなら、一周するということ
     * そうでなくでも、ansには次の位置 - 現在の位置を加えれば良さそう。
     * 次の位置はsの長さ未満にしておく
     */

    s += s;
    int n = s.size(), m = t.size();
    vector<ll> l[26];
    for (int i = 0; i < n; ++i) l[s[i] - 'a'].push_back(i);
    for (int i = 0; i < 26; ++i) l[i].push_back(INF);

    auto f = [&](int ch, ll x) {
        return *lower_bound(l[ch].begin(), l[ch].end(), x);
    };

    fill(last, last + 26, n);
    for (int i = n - 1; i >= n / 2; i--)
    {
        last[s[i] - 'a'] = i;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = 0; j < 26; j++) nxt[j][i] = last[j];
        last[s[i] - 'a'] = i;
    }

    ll ans = 0;
    ll x = n / 2 - 1;
    for (int i = 0; i < m; ++i) {
        ll j = f(t[i] - 'a', x + 1);
        //ll j = nxt[t[i] - 'a'][x];
        if (j == INF) {
            cout << -1 << endl;
            return 0;
        }
        //cout << ans << " : " << j + 1 << " : " << x << endl;
        ans += j - x;
        x = j % (n / 2);
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 50944
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N =	sc.nextInt();
	int[] a	= new int[N];
        int max	= 0;
	int maxI = 0;
        for(int i = 0; i<N; i++) {
            int v  = sc.nextInt();
            a[i] = v;
	    if(max < v) {
		max = v;
		maxI = i;
            }
        }
        int result = 0;
	for(int i = 0; i < N; i++) {
            if(i == maxI) {
		result = result + a[i]/2;
            } else{
            	result = result + a[i];
            }
	}
	System.out.println(result);
    }
}


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

int main() {
  
  char s[20], s2[20];
  int n, a;
  scanf("%s", &s);
  
  n = strlen(s);
  
  for (a = 0; a < n; a++) {
    s2[n-a-1] = s[a];
  }
  
  s2[n] = '\0';
  printf("%s\n", s2);
  
  return 0;
}

Measured memory_bytes: 0
//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>
using namespace std;

namespace mine
{
	const int MAX_N=310000;
	typedef long long ll;
	int mymax(int x,int y) {return x>y?x:y;}

	int a[MAX_N],mx[MAX_N];
	int ans[MAX_N];
	void main()
	{
		int n;scanf("%d",&n);
		int m=1<<n;
		for(int i=0;i<m;i++) scanf("%d",&a[i]);

		for(int k=1;k<m;k++)
		{
			ans[k]=mymax(a[0],ans[k-1]);
			mx[k]=a[0];
			for(int u=k;u>0;u=(u-1)&k)
				ans[k]=mymax(ans[k],a[u]+mx[k]),mx[k]=mymax(mx[k],a[u]);
			printf("%d\n",ans[k]);
		}
	}
};

int main()
{
	mine::main();
}


Measured memory_bytes: 6144
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

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

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
bool E[100][100];
vector<bool> seen;
typedef pair<int, int> P;
int D[100];
int F[100];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[100];
int find_time = 0;

void dfs_search(int u) {
    //出発点を訪問済みにする＆行きのタイムスタンプを記録
    int v;
    
    color[u] = 1;
    D[u] = ++find_time;
    //cout << u+1 << " " << color[u] << " " << endl;
    for (v = 0; v < N; v++) {
        //出発点からvへの辺があるか
        if (!E[u][v]) continue;
        //辺がある&&未訪問なら発見した頂点を出発点にして再帰
        if (color[v] == 0) dfs_search(v);
    }
    //今回訪問した頂点より深い未訪問の頂点がない時にその頂点を完了する。
    color[u] = 2;
    F[u] = ++find_time;
}

void dfs() {
    int u;
    find_time = 0;
    for (int i = 0; i < N; i++) color[i] = 0;
    for (u = 0; u < N; u++) {
        //未訪問のuを出発点にしてDFS
        if (color[u] == 0 || color[u] == 1) dfs_search(u);
    }
    //出力
    for (int i = 1; i <= N; i++) {
        cout << i << " " << D[i-1] << " " << F[i-1] << endl;
    }
}

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ok = 0;
    int ans = 0;

    for (int i = 0; i < 1000; i++) {
        string istr = to_string(i);
        if (istr.size() == 1) istr = "00" + istr;
        else if (istr.size() == 2) istr = "0" + istr;
        ok = 0;
        for (int j = 0; j < N; j++) {
            if (istr.at(ok) == S.at(j)) {
                ok++;
                if (ok == 3) {
                    ans++;
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    cout << n/2 * ((n+1)/2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int n; cin >> n;
	cout << "ABC" << n << endl;
	return 0;
}

Measured memory_bytes: 3592
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MOD: u64 = 1_000_000_007;

fn rec(k: usize, p: usize, prev: u32, q: &Vec<u32>, dp: &mut Vec<Vec<Option<u64>>>, is_prime: &Vec<bool>) -> u64 {
    if let Some(res) = dp[k][p] {
        return res;
    }

    let res = if k == q.len() {
        1
    } else {
        if is_prime[q[k] as usize] && prev < q[k] {
            let mut res = 0;
            res += rec(k + 1, 0, q[k], q, dp, is_prime);
            if k + 2 <= q.len() {
                res += rec(k + 2, 1, q[k], q, dp, is_prime);
            }
            res % MOD
        } else {
            0
        }
    };

    // println!("{} {} {} -> {}", k, p, prev, res);
    dp[k][p] = Some(res);
    res
}

fn main() {
    let n = read();
    let q: Vec<u32> = (0..n).map(|_| read()).collect();
    let max = *q.iter().max().unwrap() as usize;
    let mut is_prime = vec![true; max + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..max {
        if i as u64 * i as u64 > max as u64 {
            break;
        }
        if !is_prime[i] {
            continue;
        }
        let mut j = i * i;
        while j <= max {
            is_prime[j] = false;
            j += i;
        }
    }

    let mut dp = vec![vec![None; 2]; n + 1];
    println!("{}", rec(0, 0, 0, &q, &mut dp, &is_prime));
}



Measured memory_bytes: 17364
#include <stdio.h>
#define MOD (1000000007)
/*AGC,GAC,ACG,AG-C,A-GC=>023,203,032,02-3,0-23*/
/*
[2][3][-]は[0][2][3]
[0][3][-]は[2][0][3]
[3][2][-]は[0][3][2]
[2][-][3]は[0][2][-]
[-][2][3]は[0][-][2]からの寄与を受けない*/
int main(){
  int n;
  long dp[98][4][4][4],ans=0;/*dp[i]=>n=i+3までの並べ方*/
  if(scanf("%d",&n)){
    for (int i=0;i<98;i++){
      for (int j=0;j<4;j++){
        for (int k=0;k<4;k++){
          for (int l=0;l<4;l++){/*初期化*/
          dp[i][j][k][l]=1;
          }
        }
      }
    }
    dp[0][0][2][3]=0;
    dp[0][2][0][3]=0;
    dp[0][0][3][2]=0;
    for (int i=0;i<n-3;i++){
      for (int j=0;j<4;j++){
        for (int k=0;k<4;k++){
          for (int l=0;l<4;l++){/*dp[i][j][k][l]の処理*/
            if (j==0 && k==2 && l==3) dp[i+1][j][k][l]=0;
            else if (j==2 && k==0 && l==3) dp[i+1][j][k][l]=0;
            else if (j==0 && k==3 && l==2) dp[i+1][j][k][l]=0;
            else if (j==2 && l==3) 
              dp[i+1][j][k][l]
              =(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
            else if (k==2 && l==3) 
              dp[i+1][j][k][l]
              =(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
            else dp[i+1][j][k][l]
              =(dp[i][0][j][k]+dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
          }
        }
      }
    }
    for (int j=0;j<4;j++){
      for (int k=0;k<4;k++){
        for (int l=0;l<4;l++){
          ans+=dp[n-3][j][k][l];
          ans%=MOD;
        }
      }
    }
    printf("%ld\n",ans);
  }
  else printf("input ERROR!\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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 main()
{
    double a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f){
        double x = (c*e - b*f)/(a*e - b*d);
        double y = (-c*d + a*f)/(a*e - b*d);
        int xi = (int)1000*x;
        int yi = (int)1000*y;
        printf("%.3f %.3f\n", xi/1000.0, yi/1000.0);
    }
    return 0;}


Measured memory_bytes: 3204
def abc085_c():
    n, y = map(int, input().split())
    for i in range(n + 1):
        if 10000 * i + 5000 * (n - i) < y:
            continue
        for j in range(n - i + 1):
            if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
                print(i, j, n - i - j)
                return 0
    print("-1 -1 -1")


abc085_c()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<ll,ll> pint;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    ll n,k;cin>>n>>k;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    ll g=a[0];
    ll ma=a[0];
    REP(i,1,n){
        g=gcd(g,a[i]);
        ma=max(ma,a[i]);
    }
    if(k<=ma&&k%g==0){
        cout<<"POSSIBLE"<<endl;;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    unsigned long long int a,b,d;
    cin >> a >> b >> d;
    b /= d;
    a = (a<1)?(a/d)-1:(a-1)/d;
    unsigned long long int c = (unsigned long long int)b - (unsigned long long int)a;
    cout << c;
    return 0;
}



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>;

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


int main() {
    int k;
    cin >> k;
    int ans = 0;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                int add;
                add = gcd(a,b);
                ans += gcd(add, c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
	int N,p[100000],mn=0;
	cin >> N;
	for (int i = 1; i <= N; i++)
		cin >> p[i];
	for (int i = 1; i <= N; i++)
	{
		if (p[i] != i)
			continue;
		else
		{
			int t;
			t = p[i];
			if(i==N)
				p[i] = p[i - 1];
			else
				p[i] = p[i + 1];
			p[i + 1] = t;
			mn++;

		}
	}
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 640
<?php
while (fscanf(STDIN, '%s', $in)) {
    $ary = preg_split('/,/', $in);
    $l_ary = array_map('intval', array_slice($ary, 0, 10));
    $v_ary = array_map('intval', array_slice($ary, -2, 2));
    $sum = array_sum($l_ary);
    $pass_by_point = $sum * $v_ary[0] / array_sum($v_ary);

    $move_value = 0;
    $division_cnt = 0;
    while ($move_value < $pass_by_point) {
        $move_value += $l_ary[$division_cnt];
        $division_cnt++;
    }
    echo $division_cnt . PHP_EOL;
}



Measured memory_bytes: 9368
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

M = I()
d,c = Line(M,2)

D = sum(c)
S = sum([d[i]*c[i] for i in range(M)])

print(D-1+math.floor((S-1)/9))

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

int main() {
    int n, t;
    vector<int> h;
    cin>>n;
    vector<int> dp(n, INT_MAX);
    for(int i=0; i<n; i++) {
        cin>>t;
        h.push_back(t);
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i<n; i++) {
        dp[i] = min( dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]) );
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1276
#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;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
#define X first
#define Y second
#define int long long int 
const int N = (int)1e6 + 10;
const int MOD = 1000000007;


void solve(){
    int n, k;
    cin >> n >> k;
    int times = n/k;
    n -= times * k;
    int a = n;
    int b = abs(n - k);
    cout << min(a, b) << '\n';

}   

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n; ll d;
ll x,y;

int main(){
    cin >> n >> d;
    int ans = 0;
    while(n--){
        cin >> x >> y;
        x = abs(x); y = abs(y);
        x*=x; y*=y;
        x+=y;
        if(d*d>=x){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3556
#include <algorithm>
#include <iostream>
#include <math.h>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0, before = 1;
    while (before < b) {
        ans++;
        before += a - 1;
    }
    cout << ans << endl;
    return 0;
}


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

namespace ConsoleApp11
{
    class Class81
    {
        static void Main()
        {
            string w = Console.ReadLine();
            Dictionary<char, int> Table = new Dictionary<char, int>();
            for(int i = 0; i < w.Length; i++)
            {
                if (Table.ContainsKey(w[i])) { Table[w[i]]++; }
                else Table[w[i]] = 1;
            }
            Console.WriteLine(Table.Any(x => x.Value % 2 != 0) ? "No" : "Yes");
        }
    }
}


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

int main()
{
  int tennum,rodnum;
  cin >> tennum;
  cin >> rodnum;
  int *high = new int[tennum];
  bool *good = new bool[tennum];
  int road1,road2;
  int scr=0;
  for(int i=0;i<tennum;i++)
  {
    cin >>high[i];
    good[i] = true;
  }
  for(int i=0;i<rodnum;i++)
  {
	cin>>road1;
    cin>>road2;
    road1--;
    road2--;
    if(high[road1]>high[road2])
    {
    good[road2] = false;
    }
    else if(high[road1]<high[road2])
    {
       good[road1] = false;
    }
    else
    {
         good[road1] = false;
         good[road2] = false;
    }
  }
  for(int i=0;i<tennum;i++)
  {
  if(good[i])
  {
  scr++;
  }
  }
  cout<<scr;
}

Measured memory_bytes: 4132
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            out.println(a <= 8 && b <= 8 ? "Yay!" : ":(");
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 21460
#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,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int a,b;
    cin>>a>>b;
    int Btrue=0;
    for(int i=1;i<=b-a;i++){
        Btrue+=i;
    }
    cout<<Btrue-b<<endl;

    return 0;
}




Measured memory_bytes: 256
#include <iostream>

bool isPrime(int x) {
	if (x == 1)
		return false;

	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return false;

	return true;
}

int main() {
	int x;
	std::cin >> x;

	while (true) {
		if (isPrime(x)) {
			std::cout << x << std::endl;
			break;
		}
		++x;
	}
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
template<class T> class Dijkstra {
public:
    int N;
    T inf;
    vector<T> cost;
    vector<vector<pair<T, int>>> edge;
 
    Dijkstra(const int N, T inf) : N(N), inf(inf),cost(N), edge(N) {
    }
 
    void make_edge(int from, int to, T w) {
        edge[from].push_back({ w,to });
    }
 
    void solve(int start) {
        for(int i = 0; i < N; ++i) cost[i] = inf;
 
        priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
        cost[start] = 0;
        pq.push({ 0,start });
 
        while (!pq.empty()) {
            T v = pq.top().first;
            int from = pq.top().second;
            pq.pop();
            for (auto u : edge[from]) {
                T w = v + u.first;
                int to = u.second;
                if (w < cost[to]) {
                    cost[to] = w;
                    pq.push({ w,to });
                }
            }
        }
        return;
    }
};

/*
使い方
1. まずインスタンス生成
重みの型、頂点の数、距離の無限大のINFLL
Dijkstra<ll> d(N, INFLL);

2. 辺を貼る
iからjに重みwの辺を貼る場合
d.make_edge(i,j,w);

3. 頂点sから解く
d.solve(s);

4. sからgの距離
d.cost[g]

GigaCode2019 E - 車の乗り継ぎ
https://atcoder.jp/contests/gigacode-2019/submissions/8651446

*/
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, X, Y;
    cin >> N >> X >> Y;
    X--; Y--;
    Dijkstra<ll> G(N, INFLL);
    G.make_edge(X,Y,1);
    G.make_edge(Y,X,1);
    rep(i,N-1){
        G.make_edge(i, i+1, 1);
        G.make_edge(i+1, i,1);
    }
    vector<ll> ans(N,0);
    rep(i,N){
        G.solve(i);
        //print(G.cost);
        rep(j,N){
            if(i >= j)continue;
            ans[G.cost[j]]++;
        }
    }
    rep1(i,N){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int H, W;
	int h, w=0;

	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (h = 1; h <= H; h++) {
			while (w < W) {
				if (h % 2 == 1) {
					if (w < W) {
						printf("#");
						w++;
					}
					if (w < W) {
						printf(".");
						w++;
					}
				}
				else {
					if (w < W) {
						printf(".");
						w++;
					}
					if (w < W) {
						printf("#");
						w++;
					}
				}
			}
			w = 0;
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  int cnt=0;
  rep(i,s.size()){
    if( s.at(i) == '0' ) cnt++;
  }
  cout << min( cnt, (int)s.size() - cnt )*2 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> p(n),q(n);
    for(int i = 0; i < n; ++i) cin >> p[i];
    for(int j = 0; j < n; ++j) cin >> q[j];
    vector<int> x(n);
    for(int i = 0; i < n; ++i) x[i] = i+1;
    int a,b, cnt = 0;
    do{
        if(p == x) a = cnt;
        if(q == x) b = cnt;
        cnt++;
    }while(next_permutation(x.begin(),x.end()));
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;

int n;
int dp[505];
int chk[505][505];
const ll mod = 1000000007;
int f(int x)
{
    if(x == 1) return 0;
    if(dp[x]) return dp[x];
    dp[x] = 1e9;
    for(int i=1;i<x;i++)
    {
        dp[x] = min(dp[x], 1 + max(f(i), f(x-i)));
    }
    return dp[x];
}
void color(vector<int>& v, int col)
{
    if(v.size() == 1) return;
    int x = v.size();
    for(int i=1;i<x;i++)
    {
        if(dp[x] == 1 + max(dp[i], dp[x-i]))
        {
            //cout << x << ' ' << col << ' ' << i << '\n';
            vector<int> v1, v2;
            for(int j=0;j<x;j++)
            {
                if(j < i) v1.push_back(v[j]);
                else v2.push_back(v[j]);
            }
            for(int x1 : v1)
            {
                for(int x2 : v2)
                {
                    //cout << x1 << ' ' << x2<< '\n';
                    chk[x1][x2] = col;
                    chk[x2][x1] = col;
                }
            }
            color(v1, col+1);
            color(v2, col+1);
            return;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    f(n);
    //cout << f(n) << '\n';
    vector<int> v;
    for(int i=1;i<=n;i++)
         v.push_back(i);
    color(v, 1);
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            cout << chk[i][j] << ' ';
        }
        cout << '\n';
    }
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    cin >> N;
    int ans = (N%2)? N/2 : N/2 - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

const string UNRES = "UNRESTORABLE";

string check(const string& s, const string& t, int i){
    string ret = s;
    for(int j = 0; j < s.size(); ++j){
        if(i <= j && j < i + t.size()){
            if(s.at(j) == '?'){
                ret.at(j) = t.at(j - i);
            }else if(s.at(j) != t.at(j - i)){
                return UNRES;
            }
        }else if(s.at(j) == '?'){
            ret.at(j) = 'a';
        }
    }
    return ret;
}

int main(){
    string s, t;
    cin >> s >> t;
    string ans = UNRES;
    for(int i = 0; i < s.size() - t.size() + 1; ++i){
        const string tmp = check(s, t, i);
        if(tmp == UNRES){ continue; }
        if(ans == UNRES){
            ans = tmp;
        }else{
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a % 2 == 0 and a == b == c:
    print(-1)
    exit()

cnt = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    cnt += 1
    aa = b // 2 + c // 2
    bb = c // 2 + a // 2
    cc = a // 2 + b // 2
    a = aa
    b = bb
    c = cc
print(cnt)


Measured memory_bytes: 3060
N = int(input())
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)

for i in range(1,N+1):
    t[i],x[i],y[i] = map(int, input().split())
    a = t[i] - t[i-1]
    b = abs(x[i] - x[i-1])
    c = abs(y[i] - y[i-1])
    if a % 2 == 0:
        if b + c <= a and (b + c) % 2 == 0:
            continue
        else:
            print('No')
            exit()
    else:
        if b + c <= a and (b + c) % 2 == 1:
            continue
        else:
            print('No')
            exit()

print('Yes')

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

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  vector<vector<int>>banned(n);
  UnionFind fn(n);
  rep(i,0,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    banned[a].push_back(b);
    banned[b].push_back(a);
    fn.merge(a,b);
  }
  rep(i,0,k){
    int a,b;
    cin >> a >> b;
    a--;b--;
    if(!fn.issame(a,b)) continue;
    banned[a].push_back(b);
    banned[b].push_back(a);
  }
  rep(i,0,n){
    int ans = fn.size(i)-1-banned[i].size();
    cout << ans;
    if(i != n-1) cout << " ";
    else cout << "" << endl;
  }
}

Measured memory_bytes: 11208
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		int M=sc.nextInt();
		
		
		
		for(int i=0;i<M;i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			
			if(!map.containsKey(a)) {
				map.put(a, new ArrayList<Integer>());
			}
			if(!map.containsKey(b)) {
				map.put(b, new ArrayList<Integer>());
			}
			map.get(a).add(b);
			map.get(b).add(a);
		}
		
		
		int v[]=new int[N];
		Queue<Integer> qq=new ArrayDeque<>(); 
		
		int sum=0;
		
		qq.add(1);
		while(sum<N&&qq.peek()!=null) {
			int t=qq.poll();
			ArrayList<Integer> cc=map.get(t);
			for(int i:cc) {
				if(v[i-1]==0) {
					v[i-1]=t;
					qq.add(i);
					
				}
			}
		}
		p("Yes");
		for(int i=1;i<N;i++) {
				p(v[i]);
		}
		
		
	}
	public static Map<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>(20001);	
		
	//static int ans=10000009;
	
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 84688