akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
vector<int> roku,kyuu;
void junbi(){
	for(int i=1;i<=7;i++){
		roku.push_back((int)pow(6,i));
		kyuu.push_back((int)pow(9,i));
	}
}
int kaisu(int N,int maekaisu){
	if(N==6) return maekaisu+1;
	else if(N<=5) return maekaisu+N;
	else if(N%3!=0) return kaisu(N-1,maekaisu+1);
	else{
		return min(kaisu(N-roku[upper_bound(roku.begin(),roku.end(),N)-roku.begin()-1],maekaisu+1),kaisu(N-kyuu[upper_bound(kyuu.begin(),kyuu.end(),N)-kyuu.begin()-1],maekaisu+1));
	}
}
int main(){
	junbi();
	int N;
	scan(N);
	prin(kaisu(N,0));
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = GetInt();
            int[] B = GetInts(N-1);

            int ans = B[0];

            for(int i = 1; i < N-1; i++)
            {
                if(B[i-1] < B[i])
                {
                    ans += B[i - 1];
                }
                else
                {
                    ans += B[i];
                }
            }
            ans += B[N-2];

            Console.WriteLine(ans);
        }
    }
}


public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() => int.Parse(getArg());
    public static long GetLong() => long.Parse(getArg());
    public static double GetDouble() => double.Parse(getArg());
    public static string GetString() => getArg();
    public static char GetChar() => getArg()[0];
    public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
    public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
    public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
    public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int n,a[111111];
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	int res = 0;
	for(int i=1; i<=n; i++)
		if(a[i] == i){
			swap(a[i], a[i+1]);
			res++;
		}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 640
N=int(input())
A = list(map(int,input().split()))
B= list(map(int,input().split()))
C= list(map(int,input().split()))
manzoku=0
for i,a in enumerate(A[:-1]):
    if A[i+1]-a==1:
        manzoku += C[a-1]
manzoku += sum(B)
print(manzoku)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 2000000000

using namespace std;

int main()
{   
    stack<int> S1;
    stack<pair<int, int>> S2;
    string s;
    cin >> s;


    /* 総面積を求める */
    int area = 0;
    for (int i = 1; i < s.size()+1; i++) {
        if (s.at(i-1) == '\\' ) {
            S1.push(i);
        }

        else if (s.at(i-1) == '/' && !S1.empty()) {
            area += i - S1.top();
            int area_sm = i - S1.top();
            while (!S2.empty() && S2.top().first > S1.top()) {
                area_sm += S2.top().second;     S2.pop();
            }
            S2.push(make_pair(S1.top(), area_sm));
            S1.pop();
        }
    }

    vector<int> ans;

    while (!S2.empty()) {
        ans.push_back(S2.top().second);     S2.pop();
    }

    reverse(ans.begin(), ans.end());

    cout << area << endl;
    cout << ans.size();
    REP(i, ans.size()) {
        cout << " " << ans.at(i);
    }
    cout << endl;

}


Measured memory_bytes: 3252
K = int(input())
L = 50
N = K // L + L - 1
res = K - (N - L + 1) * L
assert(res < 50)
ans = [N] * L
for i in range(res):
    ans[i] += L - res + 1
for i in range(res, L):
    ans[i] -= res
print(L)
print(*ans)


Measured memory_bytes: 3064
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
struct UnionFind{
    vector<ll> parent;
    vector<ll> s;
 
    UnionFind(ll n){
        parent.resize(n);
        s.resize(n, 1);
        for(int i = 0; i < n; i++) parent[i] = i;
    }
 
    ll root(ll node){
        if(parent[node] == node){
            return node;
        } else {
            return parent[node] = root(parent[node]);
        }
    }
 
    void unite(ll x, ll y){
        ll rootx = root(x);
        ll rooty = root(y);
        if(rootx == rooty) return;
        if(s[rootx] < s[rooty]) swap(rootx, rooty);
        s[rootx] += s[rooty];
        parent[rooty] = rootx;
    }
 
    bool isSame(ll x, ll y){
        return root(x) == root(y);
    }
 
    ll size(ll x){
        return s[root(x)];
    }
};
int main(void){
    ll n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
    }

    ll ans = 0;
    rep(i, n){
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
}   

Measured memory_bytes: 6424
#include <iostream>

#include <algorithm>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::min;
using std::string;
using std::vector;

static int
count_east(int beg, int end, vector<int> const &cusum_east)
{
  return cusum_east[end] - cusum_east[beg];
}

static int
count_west(int beg, int end, vector<int> const &cusum_east)
{
  return (end - beg) - count_east(beg, end, cusum_east);
}

static int
solve(int N, string const &S)
{
  vector<int> cusum_east(N + 1);
  int east = 0;
  for (int n = 0; n < N; n++)
  {
    if (S[n] == 'E')
    {
      east++;
    }
    cusum_east[n + 1] = east;
  }
  int ret = N;
  for (int n = 0; n < N; n++)
  {
    ret = min(ret, count_west(0, n, cusum_east) + count_east(n + 1, N, cusum_east));
  }
  return ret;
}

int
main()
{
  int N;
  string S;
  cin >> N >> S;
  cout << solve(N, S) << endl;
  return 0;
}


Measured memory_bytes: 1796
#include <stdio.h>
int main (){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if (a==b&&b!=c)
    printf("Yes");
    else if (a==c&&a!=b)
      printf("Yes");
    else if (b==c&&a!=b)
      printf("Yes");
      else printf("No");
 return 0;
  }


Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i, n){
        cin >> a[i+1];
        a[i+1] += a[i];
    }

    vector<vector<int>> dp(n + 1, vector<int>(n + 1, INF));
    rep(i, n){
        dp[i][i+1] = 0;
    }
    for(int l = 2; l <= n; l++){
        rep(i, n){
            if(i + l > n){
                break;
            }
            int k = min(n, i + l);
            for(int j = i; j <= k; j++){
                dp[i][k] = min(dp[i][k], dp[i][j] + dp[j][k] + a[k] - a[i]);
            }
        }
    }
    cout << dp[0][n] << endl;

    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int n;
	cin >> n;
	vl A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	ll sum = 0;
	ll ans1 = 0;
	for (int i = 0; i < n; i++) {
		sum += A[i];
		if (i % 2 == 1) {
			if (sum > 0)continue;
			else {
				ans1 += 1 - sum;
				sum = 1;
			}
		}
		else {
			if (sum < 0)continue;
			else {
				ans1 += sum + 1;
				sum = -1;
			}
		}
	}
	sum = 0;
	ll ans2 = 0;
	for (int i = 0; i < n; i++) {
		sum += A[i];
		if (i % 2 == 0) {
			if (sum > 0)continue;
			else {
				ans2 += 1 - sum;
				sum = 1;
			}
		}
		else {
			if (sum < 0)continue;
			else {
				ans2 += sum + 1;
				sum = -1;
			}
		}
	}
	cout << (ans2>ans1? ans1:ans2)<< endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = (1e-10);
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<int> erat(int n) {
    vector<int> primes(n);
    for (int i = 2; i < n; ++i) primes[i] = i;
    for (int i = 2; i*i < n; ++i)
        if (primes[i])
            for (int j = i*i; j < n; j+=i) primes[j] = 0;
    // 素数のみをvectorに格納する場合は以下の行を追加 (0 である要素を全削除)
    // primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
    return primes;
}

int main(void) {
    vector<int> Erat = erat(1000000);
    int n;
    vector<int> ans;
    while (1) {
        cin >> n;
        if (!n) break; 
        int cnt = 0;
        for (int i = n+1; i <= n*2; i++) {
            if (Erat[i]) cnt++;
        }
        ans.push_back(cnt);
    }
    for (int &i : ans) {
        cout << i << endl;
    }

}




Measured memory_bytes: 6540
unittest
{
	assert( [ "2 2", "4 3", "3 4" ].parse.expand.solve == 2 );
	assert( [ "3 3", "5 9 7", "3 6 9" ].parse.expand.solve == 0 );
	assert( [ "2 2", "4 4", "4 4" ].parse.expand.solve == 0 );
	assert( [ "14 13", "158 167 181 147 178 151 179 182 176 169 180 129 175 168", "181 150 178 179 167 180 176 169 182 177 175 159 173" ].parse.expand.solve == 343772227 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	return tuple( as, bs );
}

auto solve( long[] as, long[] bs )
{
	const M = 10L ^^ 9 + 7;
	
	as.sort!( ( x, y ) => y < x );
	bs.sort!( ( x, y ) => y < x );
	
	// 複数行、複数列に同じ数を書くことはできない
	foreach( i; 1L .. as.length.signed )
	{
		if( as[ i - 1 ] == as[ i ] ) return 0L;
	}
	foreach( i; 1L .. bs.length.signed )
	{
		if( bs[ i - 1 ] == bs[ i ] ) return 0L;
	}
	
	// 大きい数から書き込む
	auto ans = ModWorld!M( 1L );
	auto c = 0L;
	auto h = 0L;
	auto w = 0L;
	foreach_reverse( i; 1L .. as.length.signed * bs.length.signed + 1 )
	{
		// 書き込める範囲を判定
		while( h < as.length && i <= as[ h ] ) h++;
		while( w < bs.length && i <= bs[ w ] ) w++;
		
		// 書き込めるマスの数を計算
		auto t = 0L;
		if( 0 < h && as[ h - 1 ] == i && 0 < w && bs[ w - 1 ] == i )
		{
			// 一か所に決まる場合
			t = 1;
		}
		else if( 0 < h && as[ h - 1 ] == i )
		{
			// 1行に決まる場合
			t = w;
		}
		else if( 0 < w && bs[ w - 1 ] == i )
		{
			// 1列に決まる場合
			t = h;
		}
		else
		{
			// 範囲内ならどこでもいい場合
			t = h * w - c;
			if( t <= 0 ) return 0L;
		}
		c++;
		
		// パターン数を計算
		ans *= t;
	}
	return ans.n;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}


Measured memory_bytes: 2428
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n;
string s;
bool solve(int md){
	if(md*2>n)return false;
	map<string,vector<int>>mp;
	for(int i=0;i<=n-md;i++){
		mp[s.substr(i,md)].pb(i);
	}
	for(pair<string,vector<int>> it:mp){
		sort(all(it.se));
		if(it.se.back()-it.se[0]>=md)return true;
	}
	return false;
}
signed main(){
	cin>>n>>s;
	int ok=0,ng=n;
	while(ng-ok>1){
		int mid=(ng+ok)/2;
		if(solve(mid))ok=mid;
		else ng=mid;
	}
	cout<<ok<<endl;
	return 0;
}


Measured memory_bytes: 6784
A,B = input().split()
A=int(A)
B =int(B)
if A<B:
  for i in range(1,B+1):
    if A*i%B ==0:
      print(A*i)
      break
else:
  for i in range(1,A+1):
    if B*i%A ==0:
      print(B*i)
      break

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

int main(){
    int d;
    cin >> d;
    if(d==25) cout << "Christmas" << endl;
    else if(d==24) cout << "Christmas Eve" << endl;
    else if(d==23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	n, q := readInt(), readInt()
	s := readBytes()

	arr := make([]int, n)
	cnt := 0
	var pre byte
	for i := range s {
		if s[i] == 'C' && pre == 'A' {
			cnt++
		}
		arr[i] = cnt
		pre = s[i]
	}

	for i := 0; i < q; i++ {
		l, r := readInt()-1, readInt()-1
		fmt.Println(arr[r] - arr[l])
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

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

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

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

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

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int d[10];
bool C(int n){
  while(n>0){
    int t=n%10;
    if(d[t] == 1){
      return false;
    }
    n /= 10;
  }
  return true;
}
int main(){
  int N,K;
  cin >> N >> K;
  for(int i=0;i<K;i++){
    int t;
    cin >> t;
    d[t] = 1;
  }
  while(1){
    if(C(N)){
      cout << N << endl;
      return 0;
    }
    N++;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll a,b; cin >> a >> b;
  if(a*b % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

Measured memory_bytes: 256
import sys
from pprint import pprint

mod = 10**9 + 7
def solve(n, a):

    zero_count = [0] * 60
    for a_i in a:
        for j in range(60):
            if a_i >> j & 1:
                zero_count[j] += 1

    ans = 0
    for i, count in enumerate(zero_count):
        # ans += (2**i) * (count * (n - count)) 
        ans += pow(2, i, mod) * (count % mod) * ((n - count) % mod) 
        ans %= mod
    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    a = map(int, sys.stdin.readline().strip().split(" "))
    
    solve(n, a)

Measured memory_bytes: 116552
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var line = lines[0].split(" ").map(x => Number(x))
  var monster_hp = lines[1].split(" ").map(x => Number(x))
  var cnt = line[0]
  var special = line[1]
  var tmp_cnt = 0
  var new_m = monster_hp.sort((a,b) => a-b)
  var m = (cnt - special) > 0 ? cnt - special: 0
  if (m == 0) {
    console.log(0)
  } else if (m == 1){
    var r = new_m.shift()
    console.log(r)
  } else {
    var r = new_m.slice(0, m).reduce((a,x) => a+=x, 0)
    console.log(r)
  }
});

Measured memory_bytes: 36060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String r = br.readLine();
		int n = Integer.valueOf(r);
		while (n > 0 && (r = br.readLine()) != null) {
			String[] s = r.split(" ");
			int[] e = { (int) Math.pow(Integer.valueOf(s[0]), 2),
					(int) Math.pow(Integer.valueOf(s[1]), 2),
					(int) Math.pow(Integer.valueOf(s[2]), 2) };
			Arrays.sort(e);
			System.out.println(((e[0] + e[1]) == e[2]) ? "YES" : "NO");
			n--;
		}
	}
}

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

const ll mod = 998244353;

int dis[100000 + 10];

ll ksm(ll a, ll b)
{
	ll ans = 1;
	while( b )
	{
		if(b & 1) ans = ans * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return ans;
}

int main()
{
	ll n;
	cin>>n;
	ll x;
	ll maxn=0;
	dis[0]=1;
	cin>>x;
	ll flag=0;
	if(x != 0)
	{
		flag = 1;
	}
//	printf("YES");
	for(ll i=1; i<n; i++)
	{
		cin>>x;
		if(x == 0) flag = 1;
		maxn=max(maxn, x);
		dis[x]++;
	}
//	printf("NO");
	
//	cout<<maxn<<endl;
	if(flag)
	{
		printf("0");
		return 0;
	}
		ll ans=1;
		for(ll i=1; i < maxn; i++)
		{
			if(dis[i] == 0)
			{
				printf("0");
				return 0;
			}
			ans=ans*ksm(dis[i], dis[i+1])%mod;
		}
		cout<<ans;	
//	printf("YEs");
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long  n,m,w[100000],v[1000000],kq=-5;
long long f[500][100050];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for (long i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for (long i=0;i<=105;i++)
    {
        for (long j=1;j<=100005;j++)
        {
            f[i][j]=1e17+55;
        }
    }
    for (long i=0;i<=n;i++) f[i][0]=0;
    for (long i=1;i<=n;i++)
    {
        for (long j=1;j<=100005;j++)
        {
            f[i][j]=f[i-1][j];
            if (j>=v[i])
            {
                f[i][j]=min(f[i-1][j],f[i-1][j-v[i]]+w[i]);
            }
        }
    }
    for (long i=1;i<=100005;i++)
    {
        if (f[n][i]<=m)
        {
            kq=i;
        }
    }
    cout<<kq;

}


Measured memory_bytes: 88448
package main

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

func main() {
	r := readF()
	fmt.Println(2 * math.Pi * r)
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 1784
<?php
    /*
        Problem URL : http://agc011.contest.atcoder.jp/tasks/agc011_b

        Score  :
        Result :
        Time   : ms
        Memory : KB
     */

    ini_set('error_reporting', E_ALL & ~E_NOTICE);

    define('DEBUG', false);

    $T = array();

    fscanf(STDIN, "%d\n", $N);
    $A = explode(" ", trim(fgets(STDIN)));
    foreach ($A as $x) {
        $sum[$x]++;
    }
    ksort($sum);
    $arr = array_keys($sum);

    if (DEBUG) var_dump($sum);
    if (DEBUG) var_dump($arr);

    $omit = 0;

    $siz = 0;

    $arrCnt = count($arr);
    for ($i = 0; $i < $arrCnt-1; $i++) {
        $siz += $arr[$i] * $sum[$arr[$i]];
        if (DEBUG) echo "siz:{$siz} ";
        $total += $sum[$arr[$i]];
        if ($siz * 2 < $arr[$i+1]) {
            $omit = $total;
        }
    }

    if (DEBUG) echo "omit:" . $omit . PHP_EOL;

    echo ($N - $omit) . PHP_EOL;
    exit;

    for ($i = 0; $i < $N; $i++) {
        fscanf(STDIN, "%d\n", $T[]);
    }

    sort($T);

    if (DEBUG) var_dump($T);

    if (DEBUG) echo "K:{$K}\n";

    $p = 0;
    $ans = 0;
    foreach ($T as $val) {
        if ($p == 0) {
            $p1 = $val;
            $p = 1;
            $ans++;
        } else {
            if ($val <= $p1 + $K) {
                if (DEBUG) echo "{$val} <= {$p1} + {$K}\n";
                $p++;
            } else {
                $p1 = $val;
                $p = 1;
                $ans++;
            }
        }
        if (DEBUG) printf ("val:%d p1:%d p:%d ans:%d\n", $val, $p1, $p, $ans);
        if ($p >= $C) {
            $p = 0;
        }
    }

    echo $ans . PHP_EOL;

Measured memory_bytes: 21236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	ll tmp=n/k;
	n=n-k*tmp;
	while(abs(n-k)<n){
		n=abs(n-k);
	}
	printf("%lld\n",n);
} 

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

#define INF (int)1e17
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define qq queue
#define w(n) while(n--)
#define for0(i, n) for(i = 0; i < n; i++)
#define for1(i, n) for(i = 1; i <= n; i++)

#define MAXN 100001
ll stone[MAXN], dp[MAXN], n, k;

ll solve(int x) {
    if (x > n) return INF;
    if (x == n) return 0;
    
    if (dp[x] != -1) return dp[x];
    
    int i;
    ll best = INF;
    for1(i, k) {
        int reach = x + i;
        if (reach > n) break;
        ll cost = abs(stone[x] - stone[x+i]);
        best = min(best, solve(x + i) + cost);
    }
    
    dp[x] = best;
    return dp[x];
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    
    int i;
    for1(i, n) {
        cin >> stone[i];
        dp[i] = -1;        
    }
    
    cout << solve(1) << endl;

    return 0;
}


Measured memory_bytes: 12976
H,W = map(int, raw_input().split())
S = [raw_input() for _ in range(H)]
#solve by dycstra
#pad by max value
D = [[H*W]*W for _ in range(H)]
D[0][0] = 0
Q = [(0,0)]
while len(Q) > 0:
	cx,cy = Q.pop(0)
	for dx,dy in [(-1,0),(1,0),(0,-1),(0,1)]:
		x = cx + dx
		y = cy + dy
		if 0 <= x < W and 0 <= y < H and S[y][x] == "." and D[cy][cx] + 1 < D[y][x]: 
			D[y][x] = D[cy][cx] + 1
			Q.append((x, y))

if D[H-1][W-1] < H*W:
	print sum([s.count(".") for s in S]) - D[H-1][W-1] - 1
else:
	print -1

Measured memory_bytes: 2696
#include <stdio.h>
#include <limits.h>
#define MAX 2000000000
typedef struct{
  int x;
  char c;
  }card;
  card M[100000];
int Partition(int, int);
void Quicksort(int, int);
void merge(int, int, int,card[]);
void mergeSort(int, int, card[]);
int main(){
  int i, p, n;
  char c;
  card N[100000];
  scanf("%d%c", &n, &c);
  for(i = 0; i < n; i++){
    scanf("%c%d%c", &N[i].c, &N[i].x, &c);
    M[i] = N[i];
  }
  p = 0;
  mergeSort(0, n, N);
  Quicksort(0, n-1);
  for(i = 0; i < n; i++){
    if(N[i].c != M[i].c){
      printf("Not stable\n");
      break;
    }
    if(i == (n - 1))
    printf("Stable\n");
  }
  for(i = 0; i < n; i++){
    printf("%c %d\n", M[i].c, M[i].x);
  }
  return 0;
  }
int Partition(int e, int s){
  card tmp;
  int i, j, x;
  x = M[s].x;
  i = e - 1;
  for(j = e; j < s; j++){
    if (M[j].x <= x){
      i++;
      tmp = M[i];
      M[i] = M[j];
      M[j] = tmp;
    }
  }
  tmp = M[i + 1];
  M[i + 1] = M[s];
  M[s] = tmp;
  return (i + 1);
}
void Quicksort(int e, int s){
  int w;
  if(e < s){
    w = Partition(e, s);
    Quicksort(e, w-1);
    Quicksort(w+1, s);
  }
}
void merge(int left, int mid, int right, card K[]){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  card L[100001], R[100001];
  for(i = 0; i < n1; i++){
    L[i] = K[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = K[mid+i];
  }
  L[n1].x = MAX;
  R[n2].x = MAX;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i].x <= R[j].x)
    K[k]=L[i++];
    else
    K[k]=R[j++];
  }
}
void mergeSort(int left, int right, card K[]){
  if((left + 1) < right){
    int mid = (left + right) / 2;
    mergeSort(left, mid, K);
    mergeSort(mid, right, K);
    merge(left, mid, right, K);
  }
}



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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

using pii = pair<int, int>;
using ll = long long;

//mt19937 g1(time(0));
//
//int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
//ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a*b / gcd(a, b); }
ll fpow(ll  b, ll exp, ll mod){ if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod; }
ll divmod(ll i, ll j, ll mod){ i%=mod;j%=mod;return i*fpow(j,mod-2,mod)%mod; }

const int MAXN = 1e4 + 5;

vector<int> adj[MAXN];
bool vis[MAXN];
int w[MAXN];

int n;
int c[MAXN];

void solve() {
    cin >> n;
    for(int i=0; i<n-1; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    ll sum = 0LL;
    for(int i=1; i<=n; i++) {
        cin >> c[i];
        sum += c[i];
    }
    sort(c+1, c+n+1);
    sum -= c[n];

    int curpos = n-1;

    queue<int> Q;
    Q.push(1);
    vis[1] = true;
    w[1] = c[n];
    while(sz(Q)) {
        int cur = Q.front();
        Q.pop();
        for(int v : adj[cur]) {
            if(!vis[v]) {
                Q.push(v);
                vis[v] = true;
                w[v] = c[curpos];
//                watch(v);
//                watch(w[v]);
                curpos--;
            }
        }
    }

    cout << sum << '\n';
    for(int i=1; i<=n; i++) {
        cout << w[i] << ' ';
    } cout << '\n';

    return;

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll N, M;

vector<pii> e[100001];
int known[100001];


void dfs( int node, int parent_node ){
	known[node] = 1;
	for ( auto it : e[node] ){
		int next_node = it.first;
		if ( next_node == parent_node || known[next_node] )
			continue;
		dfs( next_node, node );
	}
}

int main(){
	cin >> N >> M;
	
	for ( int i = 0; i < M; i++ ){
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		z = z%2;
		
		e[x].push_back({y,z});
		e[y].push_back({x,z});
	}
	
	ll cost = 0;
	for ( int i = 0; i < N; i++ ){
		if ( !known[i] ){
			dfs( i, -1 );
			cost++;
		}
	}
	
	cout << cost << endl;
	
	return 0;
}



Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
 
void solve()
{
   int n;
   cin >> n;
   vector<int>arr(n);
   for (int c=0;c<n-1;c++)
        cin >> arr[c];

    unordered_map<int,int>maps;
    for (int c=0;c<n-1;c++)
        maps[arr[c]]++;
    for (int c=1;c<=n;c++)
        cout << maps[c] << endl;   
}
 
 
int main()
{
    fast_io;
    int t;
    //cin >> t;
t=1;
    for (int tt=1;tt<=t;tt++)
    {
        solve();
        
 
    }
 
    
    return 0;
}
 


Measured memory_bytes: 12276
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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 MOD = 1000000007;
int main() {
    int N;
    cin >> N;
    string S[110];
    int P[110];
    int T[110];
    rep(i, 0, N) {
        cin >> S[i] >> P[i];
        T[i] = 0;
    }
    int res[110];
    rep(i, 0, N) {
        string min = "zzzzzzzzzzzzzzzzz";
        int p = 0;
        int tmp;
        rep(r, 0, N) {
            if(T[r] == 1) {
                continue;
            }
            if(min > S[r]) {
                min = S[r];
                p = P[r];
                tmp = r;
            } else if(min == S[r]) {
                if(p < P[r]) {
                    min = S[r];
                    p = P[r];
                    tmp = r;
                }
            }
        }
        T[tmp] = 1;
        cout << tmp + 1<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

string sa, sb, sc;
map<char, string> cs;
map<char, int> ci;

char dfs(char c) {
	int &i = ci[c];
	string &s = cs[c];
	if (i < s.size()) {
		char c = s[i];
		i++;
		return dfs(c);
	}
	else {
		return c;
	}
}

int main(void) {
	cin >> sa >> sb >> sc;
	cs['a'] = sa;
	cs['b'] = sb;
	cs['c'] = sc;
	cout << char(toupper(dfs('a'))) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
class weighted_union_find{
    public:
        int n;
        vector<T> p, w, rank;

        weighted_union_find(int n)
            : n(n), p(n+1, -1), w(n+1), rank(n+1) {}

        int find(int v){
            if(p[v] == -1){
                return v;
            }
            int r = find(p[v]);
            w[v] += w[p[v]];
            return p[v] = r;
        }

        int weight(int v){
            find(v);
            return w[v];
        }

        int diff(int u, int v){
            return weight(v) - weight(u);
        }

        void unite(int u, int v, int ww){
            ww = ww + weight(u) - weight(v);
            u = find(u);
            v = find(v);

            if(u == v){
                return;
            }

            if(rank[u] < rank[v]){
                swap(u, v);
                ww = -ww;
            }

            if(rank[u] == rank[v]){
                rank[u]++;
            }

            p[v] = u;
            w[v] = ww;
        }
};

signed main(){
    int n, q;
    cin >> n >> q;

    vector<int> p(n, -1);

    weighted_union_find<int> uf(n);
    rep(i, q){
        int com, x, y;
        cin >> com >> x >> y;

        if(com == 0){
            int w;
            cin >> w;
            uf.unite(x, y, w);
        }

        if(com == 1){
            if(uf.find(x) != uf.find(y)){
                cout << "?" << endl;
                continue;
            }
            cout << uf.diff(x, y) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 5924
N = int(input())
liA = list(map(int, input().split()))
liB = list(map(int, input().split()))
liC = list(map(int, input().split()))

Manzoku = sum(liB)

for i in range(N):
    if i < N - 1:
        if liA[i+1] - liA[i] == 1:
            Manzoku += liC[liA[i] - 1]

print((Manzoku))

Measured memory_bytes: 9104
s=gets.chomp
if s=="SUN"
  puts 7
elsif s=="MON"
  puts 6
elsif s=="TUE"
  puts 5
elsif s=="WED"
  puts 4
elsif s=="THU"
  puts 3
elsif s=="FRI"
  puts 2
elsif s=="SAT"
  puts 1
end


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main() {
	int q;
	int c, a, n;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> c >> a >> n;
		int counter = 0;
		while(c > 0 && a > 0 && n > 0) {
			counter++;
			c--;
			a--;
			n--;
		}
		while (c >= 2 && a > 0) {
			counter++;
			c-=2;
			a--;
		}
		while (c >= 3) {
			counter++;
			c-=3;
		}
		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
    int n,m,a,b;
    scanf("%d %d",&n,&m);
    if(n<10){
        a=100*(10-n);
        b=a+m;
        printf("%d\n",b);
    }
    if(n>=10){
        printf("%d\n",m);
    }
    return 0;
}

Measured memory_bytes: 1684
#if 0


#endif // 0

#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int) 1e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int n,k;
int w[MAXN];

bool is_judge(int x){
    int cnt=0,cur=0;
    int p=1;
    while(p<=n){
        while(p<=n){
            if(cur+w[p]>x) break;
            cur+=w[p++];
        }
        cur=0;
        cnt++;
    }
    return cnt<=k;
}

void work(){
    scanf("%d%d",&n,&k);
    int L=1,R=1000000000;
    for(int i=1;i<=n;i++){
        scanf("%d",&w[i]);
        L=max(L,w[i]);
    }
    int ans=0;
    while(L<=R){
        int mid=(L+R)>>1;
        if(is_judge(mid)){
            R=mid-1;
            ans=mid;
        }
        else{
            L=mid+1;
        }
    }
    printf("%d\n",ans);
}

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





Measured memory_bytes: 3124
n,m=map(int,input().split())
ans_1=[]
ans_2=[]
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        ans_1.append(b)
    if b==n:
        ans_2.append(a)
if set(ans_1)&set(ans_2)!=set():#共通の要素があればpossible
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 21836
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
using namespace std;
ll n, m;
ll grp[9][9];
ll a, b;
ll ans = 0;

ll dfs(int v, ll visited[9]) {
	bool f = true;
	rep(i, n) {
		if (!visited[i]) {
			f = false;
			break;
		}
	}
	if (f) {
		return 1;
	}
	ll ans = 0;
	rep(i, n) {
		if (visited[i]) continue;
		if (!grp[v][i]) continue;
		visited[i] = 1;
		ans+=dfs(i, visited);
		visited[i] = 0;
	}
	return ans;
}
int main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a >> b;
		grp[a-1][b - 1] = grp[b - 1][a - 1] = 1;
	}
	ll visited[9];
	m0(visited);
	visited[0] = 1;
	cout << dfs(0, visited) << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

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

	bool is_positive = false, is_negative = false;
	vector<int> q_positive, q_negative;
	for (int i = 0; i < N; i++)
	{
		if (A[i] >= 0) {
			is_positive = true;
			q_positive.push_back(i);
		}
		else {
			is_negative = true;
			q_negative.push_back(i);
		}
	}

	if (!is_negative) {
		vector<pii> B;
		for (int i = 0; i < N; i++)
			B.push_back(pii(A[i], i));
		sort(B.begin(), B.end());
		const int i_min = B[0].second;
		q_negative.push_back(i_min);
		q_positive.erase(q_positive.begin() + i_min);
	}
	else  if (!is_positive) {
		vector<pii> B;
		for (int i = 0; i < N; i++)
			B.push_back(pii(A[i], i));
		sort(B.rbegin(), B.rend());
		const int i_max = B[0].second;
		q_positive.push_back(i_max);
		q_negative.erase(q_negative.begin() + i_max);
	}

	vector<int> x, y;
	int tx_positive = A[q_positive[0]];
	for (int j = 1; j < q_negative.size(); j++)
	{
		const int i_negative = q_negative[j];
		x.push_back(tx_positive);
		y.push_back(A[i_negative]);
		tx_positive -= A[i_negative];
	}
	int tx_negative = A[q_negative[0]];
	for (int j = 1; j < q_positive.size(); j++)
	{
		const int i_positive = q_positive[j];
		x.push_back(tx_negative);
		y.push_back(A[i_positive]);
		tx_negative -= A[i_positive];
	}
	x.push_back(tx_positive);
	y.push_back(tx_negative);
	const int M = tx_positive - tx_negative;


	cout << M << endl;
	for (int i = 0; i < x.size(); i++)
		cout << x[i] << " " << y[i] << endl;
	return 0;
}


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

int main(){
  int N, M, L;
  
  cin >> N;
  
  M = N % 100;
  L = M % 10;
  
  
  if(L == 2 || L == 4 || L == 5 || L == 7 || L == 9){
    cout << "hon" << endl;
  }else if(L ==0 || L == 1 || L == 6 || L == 8){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3596
from collections import deque
import sys
input = sys.stdin.readline  #文字列入力では注意！

N,M = map(int,input().split())
Graph = [[] for _ in range(N)]
for _ in range(M):
    L,R,D = map(int,input().split())
    L -= 1; R -= 1
    Graph[L].append((R,D))
    Graph[R].append((L,-D))

num = dict()
for i in range(N):
    if i not in num:
        num[i] = 0
        Q = deque(Graph[i])
        x = 0
        while Q:
            now,d = Q.popleft()
            if now in num:
                if num[now] != d:
                    print("No")
                    exit()
            else:
                num[now] = d
                for node,Di in Graph[now]:
                    Q.append((node,d+Di))
print("Yes")


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

using namespace std;

const int N = 1e5 + 5;

vector<int> g[N];
map<pair<int, int>, int> cost;

int bfs(int st, int en) {
  queue<pair<int, int>> q;
  q.push({st, 0});
  int cnt = 0;
  while (!q.empty()) {
    int u = q.front().first;
    int c = q.front().second;
    q.pop();
    //cout << u << " " << c << endl;
    if (u == en && c % 3 == 0) {
      return cost[{u, c % 3}] / 3;
    }
    for (auto v : g[u]) {
      if (!cost[{v, (c + 1) % 3}]) {
        q.push({v, c + 1});
        cost[{v, (c + 1) % 3}] = cost[{u, c % 3}] + 1;
      } else if (cost[{v, (c + 1) % 3}] > cost[{u, c % 3}] + 1) {
        q.push({v, c + 1});
        cost[{v, (c + 1) % 3}] = cost[{u, c % 3}] + 1;
      }
    }
//    cnt++;
//    if (cnt == 1e6) break;
  }
  return -1;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
  }
  int st, en;
  scanf("%d %d", &st, &en);
  cout << bfs(st, en);
  return 0;
}


Measured memory_bytes: 24576
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

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

		int[] A = {nextInt(),nextInt(),nextInt()};
		Arrays.sort(A);
		
		System.out.println(A[0]+A[1]);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

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

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


Measured memory_bytes: 1024
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    x = int(input())

    num_list = []
    i = 0
    while True:
        num_list.append(i)
        if (i+1)**5 - i**5 > x:
            break
        i += 1

    L = len(num_list)
    for i in range(L):
        a = num_list[i]
        for j in range(L):
            b = num_list[j]
            if a ** 5 - b ** 5 == x:
                print(a, b)
                exit()
            if a ** 5 - (-b) ** 5 == x:
                print(a, -b)
                exit()
            if b ** 5 - a ** 5 == x:
                print(b, a)
                exit()
            if b ** 5 - (-a) ** 5 == x:
                print(b, -a)
                exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 67904