akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func main() {
	N := scanInt()
	MOD := 1000000007
	letters := []string{"A", "C", "G", "T"}
	dp := make([]map[string]int, 101, 101)
	dp[3] = map[string]int{
		"AAA": 1,
		"AAC": 1,
		"AAG": 1,
		"AAT": 1,
		"ACA": 1,
		"ACC": 1,
		"ACG": 0, // ACG
		"ACT": 1,
		"AGA": 1,
		"AGC": 0, // AGC
		"AGG": 1,
		"AGT": 1,
		"ATA": 1,
		"ATC": 1,
		"ATG": 1,
		"ATT": 1,
		"CAA": 1,
		"CAC": 1,
		"CAG": 1,
		"CAT": 1,
		"CCA": 1,
		"CCC": 1,
		"CCG": 1,
		"CCT": 1,
		"CGA": 1,
		"CGC": 1,
		"CGG": 1,
		"CGT": 1,
		"CTA": 1,
		"CTC": 1,
		"CTG": 1,
		"CTT": 1,
		"GAA": 1,
		"GAC": 0, // GAC
		"GAG": 1,
		"GAT": 1,
		"GCA": 1,
		"GCC": 1,
		"GCG": 1,
		"GCT": 1,
		"GGA": 1,
		"GGC": 1,
		"GGG": 1,
		"GGT": 1,
		"GTA": 1,
		"GTC": 1,
		"GTG": 1,
		"GTT": 1,
		"TAA": 1,
		"TAC": 1,
		"TAG": 1,
		"TAT": 1,
		"TCA": 1,
		"TCC": 1,
		"TCG": 1,
		"TCT": 1,
		"TGA": 1,
		"TGC": 1,
		"TGG": 1,
		"TGT": 1,
		"TTA": 1,
		"TTC": 1,
		"TTG": 1,
		"TTT": 1,
	}
	for i := 4; i <= N; i++ {
		prev := dp[i - 1]
		dp[i] = map[string]int{
			"AAA": (prev["AAA"] + prev["CAA"] + prev["GAA"] + prev["TAA"]) % MOD,
			//"AAC": 1,
			//"AAG": 1,
			//"AAT": 1,
			//"ACA": 1,
			//"ACC": 1,
			"ACG": 0, // ACG
			//"ACT": 1,
			//"AGA": 1,
			"AGC": 0, // AGC
			//"AGG": 1,
			//"AGT": 1,
			//"ATA": 1,
			//"ATC": 1,
			//"ATG": 1,
			//"ATT": 1,
			//"CAA": 1,
			//"CAC": 1,
			//"CAG": 1,
			//"CAT": 1,
			//"CCA": 1,
			//"CCC": 1,
			//"CCG": 1,
			//"CCT": 1,
			//"CGA": 1,
			"CGC": (/*prev["ACG"] + */prev["CCG"] + prev["GCG"] + prev["TCG"]) % MOD,
			//"CGG": 1,
			//"CGT": 1,
			//"CTA": 1,
			//"CTC": 1,
			//"CTG": 1,
			//"CTT": 1,
			//"GAA": 1,
			"GAC": 0, // GAC
			//"GAG": 1,
			//"GAT": 1,
			//"GCA": 1,
			//"GCC": 1,
			//"GCG": 1,
			//"GCT": 1,
			//"GGA": 1,
			"GGC": (/*prev["AGG"] + */prev["CGG"] + prev["GGG"] + prev["TGG"]) % MOD,
			//"GGG": 1,
			//"GGT": 1,
			//"GTA": 1,
			"GTC": (/*prev["AGT"] + */prev["CGT"] + prev["GGT"] + prev["TGT"]) % MOD,
			//"GTG": 1,
			//"GTT": 1,
			//"TAA": 1,
			//"TAC": 1,
			//"TAG": 1,
			//"TAT": 1,
			//"TCA": 1,
			//"TCC": 1,
			//"TCG": 1,
			//"TCT": 1,
			//"TGA": 1,
			"TGC": (/*prev["ATG"] + */prev["CTG"] + prev["GTG"] + prev["TTG"]) % MOD,
			//"TGG": 1,
			//"TGT": 1,
			//"TTA": 1,
			//"TTC": 1,
			//"TTG": 1,
			//"TTT": 1,
		}
		for _, l1 := range letters {
			for _, l2 := range letters {
				for _, l3 := range letters {
					if _, ok := dp[i][l1 + l2 + l3]; !ok {
						v := 0
						for _, l0 := range letters {
							v += prev[l0 + l1 + l2]
						}
						dp[i][l1 + l2 + l3] = v % MOD
					}
				}
			}
		}
	}
	sum := 0
	for _, v := range dp[N] {
		sum += v
		sum %= MOD
	}
	fmt.Println(sum)
}

func scanInt() (num int) {
	fmt.Scan(&num)
	return
}

func scanInts(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func scanString() (str string) {
	fmt.Scan(&str)
	return
}

func scanStrings(len int) (strs []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scan(&str)
		strs = append(strs, str)
	}
	return
}

Measured memory_bytes: 1280
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/7/ITP1_7_C

#include <iostream>

int main()
{
    int r, c;
    std::cin >> r >> c;
    int matrix[r + 1][c + 1] = {};

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            std::cin >> matrix[i][j];
            matrix[i][c] += matrix[i][j];
            matrix[r][j] += matrix[i][j];
            matrix[r][c] += matrix[i][j];
        }
    }

    for (int i = 0; i <= r; i++)
    {
        for (int j = 0; j <= c; j++)
        {
            std::cout << matrix[i][j];
            if(j<c)
            {
                std::cout << " " ;
            }
        }
        std::cout << std::endl;
    }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, fa[N], fb[N], ca[N], cb[N], head[N], to[N * 4], nxt[N * 4], eid;
int vis[N * 4];
inline void init_edge() {
	memset(head, -1, sizeof(head));
	eid = 0;
}
inline void add_edge(int u, int v) {
	to[eid] = v;
	nxt[eid] = head[u];
	head[u] = eid++;
}
int f[N], ans[N];
void euler(int u) {
	for (int &i = head[u]; ~i; i = nxt[i]) if (!vis[i]) {
		vis[i] = vis[i ^ 1] = 1;
		int v = to[i];
		if (i < 2 * n) {
			if (fa[u] == v) f[u] = 1;
			else f[v] = -1;
		}
		euler(v);
	}
}
int main() {
	init_edge();
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &fa[i]);
		if (fa[i] == -1) fa[i] = 0;
		ca[fa[i]]++;
		add_edge(i, fa[i]);
		add_edge(fa[i], i);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &fb[i]);
		if (fb[i] == -1) fb[i] = 0;
		cb[fb[i]]++;
		add_edge(i, fb[i]);
		add_edge(fb[i], i);
	}
	for (int i = 1; i <= n; i++)
		if ((ca[i] ^ cb[i]) & 1) {
			puts("IMPOSSIBLE");
			return 0;
		}
	puts("POSSIBLE");
	euler(0);
	memcpy(ans, f, sizeof(f));
	for (int i = 1; i <= n; i++)
		ans[fa[i]] -= f[i];
	for (int i = 1; i <= n; i++)
		printf("%d%c", ans[i], " \n"[i == n]);
	return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
int n;
string s[50];
map<char,int> mp,mp1;
int main()
{
	cin>>n;
	for(char i='a';i<='z';i++)
	  mp1[i]=100,mp[i]=0;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		for(int j=0;j<s[i].size();j++)
		{
			mp[s[i][j]]++;
		}
		for(char j='a';j<='z';j++)
		{
			mp1[j]=min(mp1[j],mp[j]);
			mp[j]=0;
	    }
	}
	for(char i='a';i<='z';i++)
	{
		if(mp1[i] && mp1[i]!=100)
		  for(int j=0;j<mp1[i];j++)
		    cout<<i;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
import fractions
a,b=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
s=abs(x[-1]-b)
d=set()
for i in range(a-1):
    s=min(s,abs(x[i]-b))
    d.add(x[i+1]-x[i])
if a==1:
    print(abs(b-x[0]))
    exit()
ans=s
while d:
    ans=fractions.gcd(ans,d.pop())
print(ans)


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

#define int long long
#define INF 9223372036854775807

int v[100009][3];

int memo[3][100009];

int n;

int dp(int last, int index){
    if(index == n) return 0;
    else if(memo[last][index] != -1){
        return memo[last][index];
    }else{
        memo[last][index] = -INF;
        for(int i = 0; i< 3; i++){
            if(i == last) continue;
            memo[last][index] = max(memo[last][index], dp(i,index+1)+v[index][i]);
        }
    }
    return memo[last][index];
}

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

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 100009; j++){
            memo[i][j] = -1;
        }
    }
    int tot = -INF;
    for(int i = 0; i < 3; i++){
        tot = max(tot, dp(i,0));
    }
    cout << tot << endl;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(string s;cin>>s;){
		ll res=0;
		int r=s.size()-1;
		per(i,s.size())
			if(s[i]=='B'){
				res+=r-i;
				r--;
			}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 720
#include<stdio.h>
#include<string.h>
int main()
{
	int k;
	char s[101];
	scanf("%d",&k);
	scanf("%s",s);
	int store=strlen(s);
	if(store<=k)
		printf("%s\n",s);
	else
	{
		char str[105];
		int i;
		for(i=0;i<k;i++)
		{
			str[i]=s[i];
		}
		int j=0;
		while(j<3)
		{
			str[i]='.';
			i++;j++;
		}
		printf("%s\n",str);
	}
}


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

using namespace std;

int main() {
	string s;
	ios::sync_with_stdio(0);
	cin >> s;
	if(s[s.length() - 1] == 's') {
		s += "es";
	}
	else s += "s";
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>

using namespace std;

void retMinimumDiff(auto& min, auto y, auto z){
    auto sub = y*z;
    if( min == -1 || sub < min ){
        min = sub;
    }
}
    
int main()
{
    long x,y,z;
    cin >> x;
    cin >> y;
    cin >> z;
    
    long min = -1;
    if( x%2 == 0 || y%2 == 0 || z%2 == 0){
        min = 0;
    } else{
        retMinimumDiff(min, y, z);
        retMinimumDiff(min, z, x);
        retMinimumDiff(min, x, y);
    }
    
    cout << min << endl;
    
    return 0;
}


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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int f[50][50];

int dfs(vector<vector<int>> &m, int h, int w, vector<vector<char>> as, int t) {
    if (h < 0 || w < 0 || h >= m.size() || w >= m[h].size()) {
        return 0;
    }
    if (as[h][w] == 'B') return 1;
    if (as[h][w] == 'W') return 2;
    if (f[h][w]) return t;
    f[h][w] = 1;
    t |= m[h][w];
    t |= dfs(m, h-1, w, as, t);
    t |= dfs(m, h+1, w, as, t);
    t |= dfs(m, h, w+1, as, t);
    t |= dfs(m, h, w-1, as, t);
    m[h][w] = t;
    return t;
}

int main()
{
    int w, h;
    while (cin >> w >> h, w) {
        loop(50,i) loop(50,j) f[i][j] = 0;
        vector<vector<char>> as;
        as.resize(h);
        loop(h,i) {
            string s;
            cin >> s;
            for (char c:s) as[i].push_back(c);
        }

        vector<vector<int>> mat(h, vector<int>(w,0));
        loop(h,i){
            loop(w,j){
                if (as[i][j] == '.') {
                    dfs(mat, i, j, as, 0);
                }
            }
        }
        // 菴墓腐縺倶コ悟屓繧?ｋ縺ィ騾壹ｋ
        loop(50,i) loop(50,j) f[i][j] = 0;
        loop(h,i){
            loop(w,j){
                if (as[i][j] == '.') {
                    dfs(mat, i, j, as, 0);
                }
            }
        }

        int ans_w = 0, ans_b = 0;
        for(auto mm:mat) {
            for (auto m:mm) {
                if (m == 1) ans_b++;
                if (m == 2) ans_w++;
            }
        }
        cout << ans_b << ' ' << ans_w << endl;

    }
}

Measured memory_bytes: 14204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
	return 0;
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t a,b,m;
  cin >> a >> b >> m;
  vector<int64_t> av(a),bv(b);
  rep(i,a){
    cin >> av[i];
  }
  rep(i,b){
    cin >> bv[i];
  }
  int64_t minp = 100000000000000;
  minp = *(min_element(av.begin(),av.end()))+*(min_element(bv.begin(),bv.end()));
  rep(i,m){
    int64_t q,w,e;
    cin >> q >> w >> e;
    minp = min(minp,av[q-1]+bv[w-1]-e);
  }
  cout << minp << endl;
               
      
    
}
    
    
  

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

using namespace std;

/*

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


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


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

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

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



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

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


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

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


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


    int n,a,b;
    cin >> n >> a >> b;

    cout << min(n*a,b) << endl;
    return 0;
}



Measured memory_bytes: 256
N,M = list(map(int,input().split()))
X = list(map(int,input().split()))
X.sort()
Y = []
for i in range(M-1):
  Y.append(abs(X[i]-X[i+1]))
Y.sort()
res = 0
for i in range(M-N):
  res = res + Y[i]
print(res)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(0, min(B, D) - max(A, C));

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll pp[100010];
vector<pair<int, ll> > g[100010];

void dfs(int u, int p ){
	for( auto pv:g[u] ) if( pv.first != p ){
		pp[pv.first] = pp[u] + pv.second;
		dfs(pv.first, u);
	}
}

int main() {
	int n;scanf("%d", &n);
	for( int i = 0, u, v, w ;  i< n -1 ; ++i ) scanf("%d%d%d", &u, &v, &w), g[u].push_back( {v,w}), g[v].push_back({u,w});
	int u = -1;
	for( int i = 1 ;  i<= n ; ++i ) if( g[i].size() == 1 ) {u = i; break;}
	dfs(u, -1);
	for( int i = 1 ; i <= n ; ++i ) {
		printf("%lld\n",pp[i]%2);
	}
	return 0;
}


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

namespace ABC098
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int c = a + b;

            if((a - b) > c)
            {
                c = a - b;
            }

            if((a * b) > c)
            {
                c = a * b;
            }

            Console.WriteLine(c);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13140
n = gets.to_i
nt = 0;
nh = 0;
n.times do
  t, h = gets.split(" ")
  if(t > h) then
    nt += 3
  elsif ( t < h) then
    nh += 3
  else
    nt += 1
    nh += 1
  end
end
printf "%d %d\n", nt, nh

Measured memory_bytes: 8716
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

class City {
public:
	int citynumber;
	int prefecture;
	int year;
	string identification;

	City(int num, int p, int y) {
		citynumber = num;
		prefecture = p;
		year = y;
	}
};

bool cmpNum(const City &a, const City &b) {
	return a.citynumber < b.citynumber;
}

bool cmpPrefYear(const City &a, const City &b) {
	if(a.prefecture != b.prefecture) return a.prefecture < b.prefecture;
	else return a.year < b.year;
}

bool cmpYear(const City &a, const City &b) {
	return a.year < b.year;
}

int n, m;
vector<City> vc;

void input() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int p, y;
		cin >> p >> y;
		vc.push_back(City(i, p, y));
	}
	sort(vc.begin(), vc.end(), cmpPrefYear);
}

string addZero(string str) {
	int div_len = 6 - str.length();
	string added = str;
	for (int i = 0; i < div_len; i++) {
		added = "0" + added;
	}
	return added;
}

void identify() {
	int pref = 0;
	int serial_year = 1;
	string identification_a;
	string identification_b;
	for (int i = 0; i < m; i++) {
		if (vc.at(i).prefecture != pref) {
			pref = vc.at(i).prefecture;
			identification_a = addZero(to_string(pref));
			serial_year = 1;
		}
		identification_b = addZero(to_string(serial_year));
		vc.at(i).identification = identification_a + identification_b;

		serial_year++;
	}
}

void output() {
	sort(vc.begin(), vc.end(), cmpNum);
	for (int i = 0; i < m; i++) {
		cout << vc.at(i).identification << "\n";
	}
}

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

	input();

	identify();
	
	output();

	return 0;
}

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a, b;
  vector<int> tmp;
  map<int, int> tmp3;
  vector<vector<int>> list(n + 1, tmp);
  vector<map<int, int>> color(n + 1, tmp3);
  rep(i, n - 1) {
    int x, y;
    cin >> x >> y;
    a.push_back(x);
    b.push_back(y);
    list[a[i]].push_back(b[i]);
    list[b[i]].push_back(a[i]);
  }
  int maximcolor = 0;
  rep2(i, 1, n + 1) {
    int size = list[i].size();
    maximcolor = max(maximcolor, size);
  }
  cout << maximcolor << endl;
  queue<int> tyoten;
  int nowcolor = 0;
  int now = 1;
  while (1) {
    int len = list[now].size();
    int dis = 0;
    rep(i, len) {
      if (now < list[now][i]) {
        tyoten.push(list[now][i]);
        if (i + 1 + dis == nowcolor) {
          dis++;
        }
        color[now][list[now][i]] = i + 1 + dis;
        color[list[now][i]][list[now][i]] = i + 1 + dis;
      } else
        --dis;
    }
    if (tyoten.empty()) {
      break;
    }
    now = tyoten.front();
    tyoten.pop();
    nowcolor = color[now][now];
  }
  rep(i, n - 1) { cout << color[a[i]][b[i]] << endl; }
  return 0;
}


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


int main() {
    long long int n,i,j,sum=0;
    cin>>n;
    long long int d[n];
    for(i=0;i<n;i++)
    cin>>d[i];
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        sum+=d[i]*d[j];
    }
    cout<<sum;

     

  return 0;
    
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sol(int n,int k,vector<int>v){
    vector<vector<int>>dp(n,vector<int>(k+1,-1000000000));
    dp[0][0]=v[0];
    if(n>1)dp[0][1]=0;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<k-1;j++){
            dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+v[i+1]);
            dp[i+1][j+2]=max(dp[i+1][j+2],dp[i][j]);
        }
    }
    int m=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<k;j++){
            m=max(m,dp[i][j]);
        }
    }
    return m;
}
int main(){
    int n,k;
    cin>>n>>k;
    int v[n];
    vector<int>vl(n);
    vector<int>vr;
    for(int i=0;i<n;i++){
        cin>>v[i];
        vl[i]=v[i];
    }
    if(n==1){
        cout<<max(v[0],0)<<endl;
        return 0;
    }
    int m=0;
    for(int i=n-1;i>0;i--){
        vl.pop_back();
        vr.push_back(v[i]);
        for(int j=0;j<=k;j++){
            m=max(m,sol(i,j,vl)+sol(n-i,k-j,vr));
        }
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT

using namespace std;

signed main() {
  ll H, W, N, ans = 0;
  cin >> H >> W >> N;
  while (N > 0) {
    if (H > W) {
      N -= H;
      W--;
    } else {
      N -= W;
      H--;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = 
                    new BufferedReader( new InputStreamReader(System.in));
            String seedStr = stdReader.readLine();

            Integer seed = Integer.valueOf(seedStr);
            Integer cubicSeed = seed * seed * seed; 
            System.out.println(cubicSeed);
            System.exit(0);

        } catch (Exception e) {
            System.exit(-1);
        }
    }
}

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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type
{int o = 0; p << "{"; for (auto c : y) {if (o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if (p > y) p = y;}
sim, class s> void maxi(n &p, s y) {if (p < y) p = y;}

#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "

int n, ba, a, b, ins;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n;

	for(int i = 1; i <= n; ++i)
	{
		string s;
		cin >> s;

		if(s[0] == 'B' && s.back() == 'A')
			++ba;
		else if(s[0] == 'B')
			++b;
		else if(s.back() == 'A')
			++a;

		for(int j = 0; j + 1 < siz(s); ++j)
		{
			if(s[j] == 'A' && s[j + 1] == 'B')
				++ins;
		}
	}

	int ans = min(a, b);

	if(a || b)
		ans += ba;
	else
		ans += ba - 1;

	ans = max(ans, 0);

	ans += ins;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>;
using namespace std;

int n;
struct AA
{
	int x1,x2,y1,y2,id;
}a[110];
bool cmp(AA a,AA b)
{
	if (a.x1==b.x1) return a.y1<b.y1;
	return a.x1<b.x1;
}
int shef[20];
int ans[20];
int maxx;
void dfs(int p,int num)
{
	if (p==0) return;
	for (int i=0;i<n;i++)
	if (shef[i]&p)
	{
		ans[a[i].id]=num;
		num++;
		p-=shef[i];
		int tmp_p=0,tmp_num=0,x2;
		for (x2=a[i].x2;x2<=maxx;x2++)
		{
			bool fail=false;
			for (int j=0;j<n;j++)
				if (a[j].x1==x2 && a[j].y1<a[i].y2 && a[j].y2>a[i].y2) {fail=true;break;}
			if (fail) break;
		}
		for (int j=0;j<n;j++)
		{
			if ((shef[j]&p) && (a[j].x2<=x2 && a[j].y2<=a[i].y2))
			{
				p-=shef[j];
				tmp_p+=shef[j];
				tmp_num++;
			}
		}
		dfs(tmp_p,num);
		num+=tmp_num;
	}
}
int main()
{
	scanf("%d",&n);
	shef[0]=1;
	for (int i=1;i<=10;i++)
		shef[i]=shef[i-1]*2;
	while (n!=0)
	{
		maxx=0;
		for (int i=0;i<n;i++)
		{
			scanf("%d%d%d%d",&a[i].x1,&a[i].y1,&a[i].x2,&a[i].y2);
			a[i].id=i;
			maxx=max(maxx,a[i].x2);
		}
		sort(a,a+n,cmp);
		int p=(1<<n)-1;
		dfs(p,1);
		for (int i=0;i<n;i++)
			printf("%d\n",ans[i]);
		scanf("%d",&n);
		if (n!=0) printf("\n");
	}
}

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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	get(a);

	if(a < 600)
		cout << 8 << endl;
	else if(a < 800)
		cout << 7 << endl;
	else if(a < 1000)
		cout << 6 << endl;
	else if(a < 1200)
		cout << 5 << endl;
	else if(a < 1400)
		cout << 4 << endl;
	else if(a < 1600)
		cout << 3 << endl;
	else if(a < 1800)
		cout << 2 << endl;
	else
		cout << 1 << endl;

	return 0;
}						

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

using namespace std;

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

	string s;
	cin >> s;

	int n = s.length();
	int ans = 0;

	for(int i = 0; i < n/2; i++) {
		if(s[i] != s[n-i-1]) ans++;
	}
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int k,n;
string s;

int main(){
	Init();
	cin>>k>>s;
	n=s.size();
	ll res=0;
	for(int i=n;i<=n+k;i++){
		(res+=nCk(i-1,n-1)*Pow(25,i-n)%mod*Pow(26,n+k-i))%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 20876
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    lint k;
    if(a == b){
        k = 0;
    }
    else {
        if((a + b) % 2 == 0){
            k = (a + b) / 2;
        }
        else {
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j;
  int data[10];
  for(i=0;i<10;i++){ 
    scanf("%d",&data[i]);
  }
  for(i=0;i<9;i++){
    for(j=0;j<9-i;j++){
      if(data[j]<data[j+1]){
	int temp;
	temp=data[j];
	data[j]=data[j+1];
	data[j+1]=temp;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",data[i]);
  }
  return(0);
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int md=1000000007;
int n,m,i,j,k,p[605],a[605],b[605],id[605],f[605][305][305];
bool v[605];
int main()
{
	scanf("%d",&m);
	for(i=1;i<=2*m;++i)
		scanf("%d",b+i);
	for(i=1;i<=m;++i)
		if(b[2*i-1]!=-1&&b[2*i]!=-1)
			v[b[2*i-1]]=v[b[2*i]]=true;
	for(i=1,j=0;i<=2*m;++i)
		if(!v[i])
			id[i]=++j;
	n=0;
	for(i=1;i<=m;++i)
		if(b[2*i-1]==-1||b[2*i]==-1)
		{
			a[++n]=(b[2*i-1]!=-1?id[b[2*i-1]]:-1);
			a[++n]=(b[2*i]!=-1?id[b[2*i]]:-1);
		}
	n/=2;
	for(i=1;i<=2*n;++i)
		if(a[i]!=-1)
			p[a[i]]=i;
	m=0;
	for(i=1;i<=n;++i)
		if(a[2*i-1]==-1&&a[2*i]==-1)
			++m;
	f[0][0][0]=1;
	for(i=0;i<2*n;++i)
	{
		if(p[i])
			++m;
		for(j=0;j<=i&&j<=n;++j)
			for(k=0;k<=i&&i+k<=2*n;++k)
				if(f[i][j][k])
				{
					//printf("%d %d %d %d\n",i,j,k,f[i][j][k]);
					if(!p[i+1])
					{
						if(m-j-(i-j-k)/2>0)
							f[i+1][j+1][k]=(f[i+1][j+1][k]+1ll*f[i][j][k]*(m-j-(i-j-k)/2)%md)%md;
						if(j)
							f[i+1][j-1][k]=(f[i+1][j-1][k]+f[i][j][k])%md;
						f[i+1][j][k+1]=(f[i+1][j][k+1]+f[i][j][k])%md;
					}
					else
					{
						if(k)
							f[i+1][j][k-1]=(f[i+1][j][k-1]+1ll*f[i][j][k]*k)%md;
						f[i+1][j+1][k]=(f[i+1][j+1][k]+f[i][j][k])%md;
					}
				}
	}
	printf("%d",f[2*n][0][0]);
	return 0;
}


Measured memory_bytes: 217472
from fractions import gcd


def memo(fnc):

    cache = {}

    def inner(*args):

        if args in cache:
            return cache[args]
        cache[args] = fnc(*args)
        return cache[args]

    return inner


@memo
def my_gcd(m, n):

    return gcd(m, n)


k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(i, k+1):
        g1 = my_gcd(i, j)
        for l in range(j, k+1):
            if i == j == l:
                w = 1
            elif i == j or j == l:
                w = 3
            else:
                w = 6
            ans += w * my_gcd(g1, l)


print(ans)


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using W = V<V<T>>;

struct UnionFind {
	V<int> p, r;
	int gn;
	UnionFind(int n = 0) : p(n, -1), r(n, 1), gn(n) {}
	void merge(int a, int b) {
		int x = group(a), y = group(b);
		if (x == y) return; // same
		gn--;
		if (r[x] < r[y]) {
			p[x] = y;
		}
		else {
			p[y] = x;
			if (r[x] == r[y]) r[x]++;
		}
	}
	int group(int a) {
		if (p[a] == -1) return a;
		return p[a] = group(p[a]);
	}
	bool same(int a, int b) {
		return group(a) == group(b);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	
	UnionFind uf(n);
	
	for (int i = 0; i < q; ++i) {
		int ty, a, b;
		cin >> ty >> a >> b;
		if (ty == 0) uf.merge(a, b);
		else cout << int(uf.same(a, b)) << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 4620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
vector<ll> P(100, -1);

ll pow(ll x){
    if(x==0) return 1;
    if(P[x]>-1) return P[x];
    ll res=1;
    rep(i,x) res*=10;
    P[x]=res;
    return res;
}

ll maxdigit(ll x, ll digit){
    ll y=x;
    while(y/10>0) y/=10;
    if(y>1 && x/pow(digit-1)==0) return -1;
    else return x/(pow(digit-1));
}


int main(){
    ll k; cin>>k;
    if(k<=10){
        cout<<k<<endl;
        return 0;
    }
    vector<ll> v={0,1,2,3,4,5,6,7,8,9};
    ll digit=1;
    while(v.size()<=1e5+10){
        vector<ll> _v={};
        rep(i,v.size()) _v.push_back(v[i]);
        for(ll x:_v){
            ll left=maxdigit(x, digit);
            if(left==-1) continue;
            if(left>1) v.push_back((left-1)*pow(digit)+x);
            if(left>0) v.push_back(left*pow(digit)+x);
            if(left<9) v.push_back((left+1)*pow(digit)+x);
        }
        digit++;
        sort(v.begin(), v.end());
    }
    sort(v.begin(), v.end());
    cout<<v[k]<<endl;
    return 0;
}

Measured memory_bytes: 5064
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const int MAXN = -1;

struct UnionFind
{
    vector<int> d;//その要素のルートの番号が入る。もしそれがルートの場合は-1*(そのグループのサイズ)
    UnionFind(int n=0):d(n,-1){}//最初は全部が親でサイズは1
    int find(int x)//その要素がどの親をルートをもつか
    {
        if(d[x]<0)return x;
        return d[x]=find(d[x]);//通常return find(d[x]);だがメモ化してトップのルート番号を入れておくことで高速化
    }

    bool unite(int x,int y)
    {
        x=find(x),y=find(y);
        if(x==y) return false;
        if(d[x] > d[y])swap(x,y);//ｘにyをつなげたい
        d[x]+=d[y];//合体によりサイズ変更
        d[y]=x;//ルート書き変え
        return true;
    }
    bool same(int x,int y){return find(x)==find(y);}
    int size(int x){return -d[find(x)];}
};


int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind u(n+1);
    vector<int> block[n+1],friends[n+1];
    rep(i,m)
    {
        int a,b;
        cin>>a>>b;
        u.unite(a,b);
        friends[a].push_back(b);
        friends[b].push_back(a);
    }
    rep(i,k)
    {
        int a,b;
        cin>>a>>b;
        block[a].push_back(b);
        block[b].push_back(a);
    }
    for(int i=1;i<=n;i++)
    {
        int ans=u.size(i)-1-friends[i].size();
        for(ll j=0;j<block[i].size();j++)
        {
            if(u.find(block[i][j])==u.find(i))ans--;
        }
        cout<<ans<<" ";
    }

    
}

Measured memory_bytes: 12152
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 900000000000000
signed main(){
    int n,k;cin>>n>>k;
    if(n<2*k-1){
        cout<<-1<<endl;
        return 0;
    }
    int Ans[n][3];
    if(n%2==1){
        //ギリギリのときの構成
        int V[n][3];
        int k0=(n+1)/2;
        rep(i,(n+1)/2){
            V[i][0]=i+k0;
            V[i][1]=(k0+2*n)+2*i-V[i][0];
            V[i][2]=(k0+2*n)+2*i;
        }
        for(int i=(n+1)/2;i<n;i++){
            V[i][0]=k0+i;
            V[i][2]=(k0+2*n)+2*(i-(n-1)/2)-1;
            V[i][1]=V[i][2]-V[i][0];
        }
        
        rep(i,n){
            rep(j,3)Ans[i][j]=V[i][j]+k-k0;
        }
//        rep(i,n){
 //           cout<<Ans[i][0]<<' '<<Ans[i][1]<<' '<<Ans[i][2]<<endl;
//        }
        //奇数完了
    }
    else{
        int m=n/2;
        rep(i,m){
            Ans[i][0]=k+i;
            Ans[i][1]=k+i+3*m;
            Ans[i][2]=k+4*m+i*2;
        }
        for(int i=m;i<2*m;i++){
            Ans[i][0]=k+i;
            Ans[i][1]=k+i+m;
            Ans[i][2]=k+4*m+1+2*(i-m);
        }
        
    }
    rep(i,n){
        cout<<Ans[i][0]<<' '<<Ans[i][1]<<' '<<Ans[i][2]<<endl;
    }
}
        

Measured memory_bytes: 6912
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	if strings.HasPrefix(s, "YAKI") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
class BITmax:
    def __init__(self, N, init=0):
        self.init = init
        self.length = N + 1
        self.tree = [self.init] * (N+1)
    
    def set(self, x, value):
        while x < self.length:
            old = self.tree[x]
            if value <= old:
                break
            self.tree[x] = value
            x += x & -x
    
    def find_max_to(self, x):
        result = self.init
        while x > 0:
            result = max(result, self.tree[x])
            x -= x & -x
        return result

def main():
    N = int(input())
    dpt = BITmax(N)

    h_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))

    for h, b in zip(h_list, b_list):
        dpt.set(h, dpt.find_max_to(h-1) + b)

    print(max(dpt.tree))

if __name__ == '__main__':
    main()


Measured memory_bytes: 42668
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    REP(i,n)IN(v[i]);
    int ans=0;
    for(int i=0;i<=min(n,k);i++){
        for(int j=0;i+j<=min(n,k);j++){
            int tmp=0;
            priority_queue<int>q;
            for(int p=0;p<j;p++){
                tmp+=v[n-1-p];
                if(v[n-1-p]<0)q.push(-v[n-1-p]);
            }
            for(int p=0;p<i;p++){
            tmp+=v[p];
            if(v[p]<0)q.push(-v[p]);
            }
            for(int p=0;SZ(q)>0&&p<k-(i+j);p++){
                tmp+=q.top();
                q.pop();
            }
            ans=max(ans,tmp);
        }
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){

  double a, b, c;
  double angle;
  double sin1;
  double cos1;
  double s, l ,h;

  cin>>a>>b>>angle;
  angle = angle*M_PI/180.0;
  sin1 = sin(angle);
  cos1 = cos(angle);

  s = 0.5 * a * b * sin1;
  c = a*a + b*b -2.0*a*b*cos1;
  c = sqrt(c);
  l = a + b + c;
  h = 2.0*s/a;

  // cout<<sin1<<" "<<cos1<<endl;
  printf("%.16lf\n%.15lf\n%.15lf\n", s, l ,h);

}

Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;

#define ll long long

int main() {
	ll n;
	ll i,j;
	ll x;
	ll ans;
	cin >> n;
	vector<ll>a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0)x = a[i];
		else x ^= a[i];
	}
	for (i = 0; i < n; i++) {
		ans=x^a[i];
		cout << ans << ' ';
	}
	return 0;
}

Measured memory_bytes: 4768
using System;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var K = int.Parse(Console.ReadLine());

            var result = 0L;
            for (int i = 1; i <= K; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    for (int k = 1; k <= K; k++)
                    {
                        result += Gcd(Gcd(i, j), k);
                    }
                }
            }
            Console.WriteLine(result);
        }

        private static long Gcd(long a, long b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var r = a % b;
                a = b;
                b = r;
            }
            return a;
        }
    }
}


Measured memory_bytes: 27544
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int i,j,n;cin>>n;
	//スタートに2 があれば答えは1か0 なければ2か0 これをn=13全探索で試した
	int ans=0;
	int aaa=(1<<24)-1;
	int bbb=(n-1)^aaa;
	string s;cin>>s;
	bool aru=false;
	for(i=0;i<n;i++){if(s[i]=='2'){aru=true;}}
	for(i=0;i<n;i++){
		if(((!aru)&&s[i]=='3')||s[i]=='2'){
			if((bbb&i)==0){ans++;}
		}
	}
	ans%=2;
	if(!aru){ans*=2;}
	cout<<ans<<endl;
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

ll n,m;
int main() {
    scanf("%lld%lld",&n,&m);
    n -= 2;
    m -= 2;
    if(n == -1) n = 1;
    if(m == -1) m = 1;
    
    printf ("%lld\n",n*m);
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,X = inpl()
xx = inpl()

def gcd(a,b):
    while b:
        a,b = b, a%b
    return a

xx.append(X)
xx.sort()
li = []
for i in range(1,N+1):
    li.append(xx[i]-xx[i-1])

ans = li[0]
for d in li:
    ans = gcd(ans,d)

print(ans)


Measured memory_bytes: 15448
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(void) {
	int n; cin >> n;
	vector<ll> v(n);
	rep(i, n)cin >> v[i];
	ll sum = accumulate(v.begin(), v.end(), 0);
	sum -= (*max_element(v.begin(), v.end()))/2;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

if S == 'MON':
    print('6')
elif S == 'TUE':
    print('5')
elif S == 'WED':
    print('4')
elif S == 'THU':
    print('3')
elif S == 'FRI':
    print('2')
elif S == 'SAT':
    print('1')
else:
    print('7')


Measured memory_bytes: 9004
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		long[] tori=new long[K];
		long tmp1=0,tmp2=0;
		for(int i=1; i<=K; i++) {
			tmp1=(N+(i%K))/K;
			if(i%K==0) {
				tmp2=(N-(i%K))/K;
			}
			else {
				tmp2=(N-(i%K))/K+1;
			}

			if(2*i%K==0) {
				tori[i%K]=tmp1*tmp2;
			}
			else {
				tori[i%K]=0;
			}
			//System.out.println(tori[i%K]);
		}
		long sousuu=0;

		for(int i=1; i<=N; i++) {
			sousuu+=tori[i%K];
		}
		System.out.println(sousuu);
	}
}

Measured memory_bytes: 23636
//#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};
ll gcdll(ll a, ll b ){
    ll r, tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
ll lcmll(ll a, ll b ){
    if(a==0||b==0) return 0;
    return ((a/gcdll(a,b))*b);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    swap(a,b);
    ll cd = lcmll(c,d);
    ll ans = a-b+1 - ((a/c)-(b-1)/c) - ((a/d)-(b-1)/d) + ((a/cd)-(b-1)/cd);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
int main(void){
	int a = 0;
	int b = 0;
	int i = 0;
	int j = 0;

	while (1){
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0){
			break;
		}else{
			for (i = 0; i < a; i++){
				for (j = 0; j < b; j++)
				{
					printf("%c", '#');
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 572
#include<stdio.h>

int main()
{
  int n;
  int i,j;
  scanf("%d",&n);
  int A[n+1];

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

  int heal=0;

  for(i=1;i<n;i++)
  {
    for(j=i+1;j<=n;j++)
    {
        heal=heal+(A[i]*A[j]);
    }
  }

  printf("%d",heal);

  return 0;
}


Measured memory_bytes: 128