akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 1000000007

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vector<vector<int>> data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
int n, p;
vector<int> a;
ll odd, even;

int main() {
    cin >> n >> p;
    a.resize(n);
    odd = 0;
    even = 1;
    for (int i = 0; i < n; ++i) {
        ll new_odd, new_even;
        cin >> a[i];
        if (a[i] % 2) {
            new_odd = odd + even;
            new_even = even + odd;
        } else {
            new_odd = 2 * odd;
            new_even = 2 * even;
        }
        odd = new_odd, even = new_even;
    }
    cout << (p ? odd : even);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  set<string> se;
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    se.insert(S);
  }
  cout << se.size() << endl;

}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
    cin >> a[i];
    int g = 0;
    int pref[n], suff[n];
    pref[0] = a[0];
    for(int i = 1; i < n; i++)
    pref[i] = __gcd(pref[i-1], a[i]);
    suff[n-1] = a[n-1];
    for(int i = n - 2; i >= 0; i--)
    suff[i] = __gcd(suff[i+1], a[i]);
    for(int i = 0; i < n; i++){
        int temp = 0;
        if(i - 1 < 0)
        temp = suff[i+1];
        else if(i + 1 >= n)
        temp = pref[i-1];
        else
        temp = __gcd(pref[i-1], suff[i+1]);
        g = max(temp, g);
    }
    cout << g;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

int n,a,b,c;
int ans = inf;
vector<int> l(8);

void solve(vector<int> v){
    if(v.size()==n){
        int now = 0;
        int cnt = 0;
        set<int> sc;
        rep(i,n){
            if(v[i]!=3 && sc.find(v[i])!=sc.end()) cnt++;
            sc.insert(v[i]);
        }
        vector<int> s(3,0);
        rep(i,n){
            if(v[i]!=3)s[v[i]] += l[i];
        }
        bool ok = 1;
        rep(i,3) if(s[i]==0) ok = 0;
        if(ok){
            now += abs(a - s[0]) ;
            now += abs(b - s[1]) ;
            now += abs(c - s[2]) ;
            now += cnt*10;
            ans = min(ans,now);
        }
    }else{
        rep(i,4){
            vector<int> copy = v;
            copy.push_back(i);
            solve(copy);
        }
    }
}

int main(){
    cout << fixed << setprecision(10);

    cin >> n >> a >> b >> c;
    rep(i,n) cin >> l[i];
    vector<int> init;
    solve(init);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const L = int.max / 2;

void dump(int[][][] x) {
    foreach (i; 0 .. 2) {
        foreach (j; 0 .. x[0].length) {
            x[i][j].map!((a) => (a == L ? -1 : a)).writeln;
        }
        writeln;
    }
    writeln;
}

void main() {
    int N;
    readf("%d\n", &N);
    int[] t = new int[N + 1];
    foreach (i; 0 .. N) {
        readf("%d\n", &t[i + 1]);
    }
    auto dp = new int[][][](2, 2, N + 1);
    foreach (i; 0 .. 2) foreach (j; 0 .. 2) dp[i][j][] = L;
    dp[0][1][1] = dp[1][1][0] = 0;
    static int s(int x) { return x % 2; }
    foreach (i; 1 .. N) {
        foreach (j; 0 .. N) {
            dp[0][s(i + 1)][j + 1] = min(dp[0][s(i)][j], dp[1][s(i)][j] + t[i]);
            dp[1][s(i + 1)][j] = min(dp[0][s(i)][j] + t[i], dp[1][s(i)][j]);
        }
    }
    int ans = L;
    foreach (i; 0 .. 2) {
        ans = min(ans, dp[i][s(N)][N / 2]);
    }
    ans.writeln;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a , b;
  cin >> a >> b;
  int x = (a * b) % 2;
  if (x == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, K; cin >> N >> K;
    vector<int> A(N); for (auto &a : A) cin >> a, a--;
    int ans = 0;
    if (A[0] != 0) ans++, A[0] = 0;
    vector<vector<int>> G(N);
    for (int i = 1; i < N; i++) {
        G[A[i]].push_back(i);
    }
    function<int(int)> recur = [&](int i) {
        int t = 0;
        for (auto child : G[i]) {
            t = max(t, recur(child));
        }
        if (A[i] != 0 && t == K - 1) ans++, t = -1;
        return t + 1;
    };
    recur(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    string S;
    cin >> S;
    ll ans = 0;
    for(int s = 0; s < (1 << (S.size()-1)); s++){
	string now = "";
	now += S[0];
	for(int i = 0; i < S.size()-1; i++){
	    if(s & (1 << i))	now += "+"; 
	    now += S[i+1];
	}
	ll sum = 0;
	int pos = 0;
	while(now.find("+", pos) != string::npos){
	    int nextpos = now.find("+", pos);
	    sum += stoll(now.substr(pos, nextpos - pos));
	    pos = nextpos + 1;
	}
	sum += stoll(now.substr(pos));
	ans += sum;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
n,m = map(int,input().split())

l = list(map(int,input().split()))
s = sum(l)
ans = 0
t = s/(4*m)

for i in l:
  if i>=math.ceil(t):
    ans+=1
  
if ans>=m:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9176
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> a(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &a[i]);
		int ans = INF;
		rer(x, -100, 100) {
			int cost = 0;
			rep(i, N)
				cost += (a[i] - x) * (a[i] - x);
			amin(ans, cost);
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

struct edge{
	ll to, cap, cost, rev;
	edge(ll to, ll cap, ll cost, ll rev): to(to), cap(cap), cost(cost), rev(rev) {}
};

typedef vector<edge> edges;
typedef vector<edges> graph;
ll INF= LLONG_MAX/3;

void add_edge(graph &G, ll from, ll to, ll cap, ll cost){
	G[from].push_back(edge(to, cap, cost, G[to].size()));
	G[to].push_back(edge(from, 0, -cost, G[from].size()-1));
}

ll SSC(graph &G, vector<ll> &excess){
	ll V = G.size();
	map<ll, ll>  E, D;
	REP(i, V){
		if(excess[i]>0) E[i] = excess[i];
		if(excess[i]<0) D[i] = excess[i];
	}

	ll total_cost = 0;
	vector<ll> pot(V, 0);
	vector<ll> prevv(V);
	vector<ll> preve(V);
	while(!E.empty()){
		ll s, t;
		s = E.begin()->first;

		// dijkstra
		priority_queue< pll, vector<pll>, greater<pll> > pq;
		bool feasibility_flag = false;
		vector<ll> dist(V, INF);
		vector<bool> visited(V, false);
		dist[s] = 0;
		pq.push(pll(0, s));
		while(!pq.empty()){
			pll p = pq.top();
			pq.pop();
			ll v = p.second;
			visited[v] = true;
			if(excess[v]<0){
				t = v;
				feasibility_flag = true;
				break;
			}
			if(dist[v]<p.first) continue;
			for(int i=0;i<G[v].size();i++){
				edge &e = G[v][i];
				if(e.cap>0 && dist[e.to]>dist[v]+e.cost+pot[v]-pot[e.to]){
					dist[e.to] = dist[v] + e.cost + pot[v] - pot[e.to];
					prevv[e.to] = v;
					preve[e.to] = i;
					pq.push(pll(dist[e.to], e.to));
				}
			}
		}

		// check fesibility
		if(!feasibility_flag) return -1;

		for(auto itr=D.begin();itr!=D.end();itr++)

		// update potential
		for(int i=0;i<V;i++) pot[i] += (visited[i] ? dist[i] : dist[t]);

		// get flow amount
		ll f = min(E[s], -D[t]);
		ll d = f;
		for(int v=t;v!=s;v=prevv[v]){
			d = min(d, G[prevv[v]][preve[v]].cap);
		}

		// update excess and deficit
		E[s] -= d;
		if(E[s]==0) E.erase(s);
		D[t] += d;
		if(D[t]==0) D.erase(t);

		// update total cost
		total_cost += pot[t]*d;

		// update residual graph
		for(int v=t;v!=s;v=prevv[v]){
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return total_cost;
}

int main(){
	ll V, E, F;
	cin >> V >> E >> F;
	graph G(V);
	REP(i, E){
		ll u, v, c, d;
		cin >> u >> v >> c >> d;
		add_edge(G, u, v, c, d);
	}
	vector<ll> excess(V, 0);
	excess[0] = F;
	excess[V-1] = -F;
	ll res = SSC(G, excess);
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 3208
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    H,W=MI()
    if (H*W)%3==0:
        print(0)
    else:
        def tw(h,w):
            #2つに分ける
            if (h*w)%2==0:
                return h*w//2,h*w//2
            else:
                a=h//2*w
                b=h*w - a
                c=w//2*h
                d=h*w - c
                if abs(a-b)<=abs(c-d):
                    return a,b
                else:
                    return c,d
                
            
        ans=10**10
        s=[0,0,0]
        #一個目を，長さW高さiにする，iを探索
        for i in range(1,H):
            s[0]=i*W
            s[1],s[2]=tw(H-i,W)
            temp=max(s)-min(s)
            ans=min(ans,temp)
            
        for j in range(1,W):
            s[0]=j*H
            s[1],s[2]=tw(H,W-j)
            temp=max(s)-min(s)
            ans=min(ans,temp)
        print(ans)
            
    
            

main()


Measured memory_bytes: 43740
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#define min(x, y) (x < y ? x : y)
#define ll long long int 

int main()
{

ll test = 0;
char s[101]={'\0'};
scanf("%s",s);
ll K ;
scanf("%lld",&K);
int copy = K ;
for (int i = 0 ;i<strlen(s);i++)
{
ll digit = s[i] -'0';
for (int j = 0; j<=64;j++)
 {
   test = pow(digit,j);
   if (test>=K)
   {
     
    printf("%lld",digit);
    return 0;
   }
 }
 K=K-test;
} 
 K = copy;
 printf("%c",s[K-1]);

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

long long gcd(long long a, long long b)
{
	long long tmp, r;
	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	vector<pair<ll,ll>> a(n);
	rep(i, n)
	{
		cin >> a[i].first >> a[i].second;
	}

	sort(a.begin(), a.end());

	ll ans = 0;
	ll honsu = 0;
	for(int i=0;i<n;i++)
	{
		ans += a[i].first * min(m - honsu, a[i].second);
		honsu += a[i].second;
		if (honsu >= m)
		{
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    vector<int>ans;
    rep(i,n-1) {
        if(a[i] == a[i+1]) {
            ans.push_back(a[i]);
            i++;
        }
    }
    if(ans.size()<2) {
        cout << 0 << endl;
        return 0;
    }
    ll square = (ll)(ans[0]) * (ll)(ans[1]);
    cout << square << endl;
}

Measured memory_bytes: 3944
package main

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

func main() {
	nextReader = newScanner()

	W := nextInt()
	H := nextInt()
	x := nextInt()
	y := nextInt()
	r := nextInt()
	if x-r < 0 || x+r > W || y-r < 0 || y+r > H {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

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



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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  long long sum = 0;
  int before = 0;
  rep(i, N)
  {
    if (A[i] < before)
    {
      sum += before - A[i];
    }
    else
    {
      before = A[i];
    }
  }

  cout << sum << endl;

  return 0;
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector< vector<char> > mp(h + 2, vector<char>(w + 2, '#'));
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> mp[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			cout << mp[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);

  auto g = GraphW!int(n); alias Edge = g.Edge;
  foreach (_; 0..n-1) {
    int u, v, w; readV(u, v, w); --u; --v;
    g.addEdgeB(u, v, w);
  }

  auto d = new long[](n);
  auto bfs = bfsw(g);
  bfs.findEdge ~= (Edge e) { d[e.dst] = d[e.src] + e.wt; };
  bfs.run(0);

  foreach (di; d)
    writeln(di%2 ? 1 : 0);
}

struct GraphW(W = int, W i = 10^^9)
{
  alias Node = int, Wt = W, inf = i;
  struct Edge { Node src, dst; Wt wt; alias cap = wt; }
  Node n;
  Edge[][] g;
  alias g this;
  this(Node n) { this.n = n; g = new Edge[][](n); }
  void addEdge(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); }
  void addEdgeB(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); g[v] ~= Edge(v, u, w); }
}

struct BFSW(Graph)
{
  import std.algorithm, std.container;
  Graph g;
  alias Node = g.Node, Edge = g.Edge;
  void delegate(Node)[] findNode;
  void delegate(Edge)[] findEdge;

  this(ref Graph g) { this.g = g; }
  auto run(Node s)
  {
    auto visited = new bool[](g.n);
    auto q = DList!(Node)(s);
    visited[s] = true;
    findNode.each!(f => f(s));

    while (!q.empty) {
      auto u = q.front; q.removeFront();
      foreach (e; g[u])
        if (!visited[e.dst]) {
          visited[e.dst] = true;
          findNode.each!(f => f(e.dst));
          findEdge.each!(f => f(e));
          q.insertBack(e.dst);
        }
    }
  }
}
auto bfsw(G)(ref G g) { return BFSW!G(g); }


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

int main()
{
	std::vector<std::string> s;
	std::string l;
	for (int i = 0; i < 3; i++)
	{
		std::cin >> l;
		s.push_back(l);
		std::sort(s[i].begin(), s[i].end());
	}
	int player = 0;
	while (true)
	{
		if (s[player].size() == 0)
		{
			break;
		}

		if (s[player][s[player].size()-1] == 'a')
		{
			s[player].pop_back();
			player = 0;
		}
		else if (s[player][s[player].size() - 1] == 'b')
		{
			s[player].pop_back();
			player = 1;
		}
		else if (s[player][s[player].size() - 1] == 'c')
		{
			s[player].pop_back();
			player = 2;
		}
	}

	switch (player)
	{
	case 0:
		std::cout << "A\n";
		break;
	case 1:
		std::cout << "B\n";
		break;
	case 2:
		std::cout << "C\n";
		break;
	}
    return 0;
}



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

string s,t;
int dp[3001][3001];


int main()
{
    cin>>s>>t;
    for(int i=1;i<=s.size();i++){
        for(int j=1;j<=t.size();j++){
            if(s[i-1]==t[j-1])
                dp[j][i]=dp[j-1][i-1]+1;
            else{
                dp[j][i]=max(dp[j-1][i],dp[j][i-1]);
            }
        }
    }

    string sol="";
    int i=t.size();
    int j=s.size();

    while(i>0&& j>0){
            if(s[j-1]==t[i-1]){
               sol+=s[j-1];
               i--;
               j--;
            }
            else if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;

        }

        for(int i=sol.size()-1;i>=0;i--)
            cout<<sol[i];
       if(sol.size()==0) cout<<" ";


    return 0;
}


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

int main() {
	char s[2][3];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> s[i][j];
		}
	}
	bool flag = true;
	for (int i = 0; i < 3; i++) {
		if (s[0][i] != s[1][2 - i]) {
			flag = false;
		}
	}
	if (flag == true) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int Sound(int A, int B, int C){
  if(B / A >= C) return C;
  else return B / A;
}

int main(void){
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  printf("%d\n", Sound(A, B, C));
  return 0;
}


Measured memory_bytes: 128
from collections import deque, defaultdict

N, M = map(int, input().split())
ab = []
for _ in range(N + M - 1):
    a, b = map(int, input().split())
    ab.append((a, b))

out = defaultdict(list)
in_cnt = defaultdict(int)
rev = defaultdict(list)
for a, b in ab:
    out[a].append(b)
    in_cnt[b] += 1
    rev[b].append(a)

queue = deque(i for i in range(1, N + 1) if in_cnt[i] == 0)
sorted_ans = []

while len(queue) != 0:
    v = queue.popleft()
    sorted_ans.append(v)
    for v2 in out[v]:
        in_cnt[v2] -= 1
        if in_cnt[v2] == 0:
            queue.append(v2)

order = [i + 1 for i, v in sorted(enumerate(sorted_ans), key=lambda x: x[1])]
order = [0] + order
ans = [0] * (N + 1)
ans[sorted_ans[0] + 1] = 0

for v in sorted_ans[:0:-1]:
    ans[v] = max((order[v2], v2) for v2 in rev[v])[1]
ans.pop(0)
for a in ans:
    print(a)


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

int main(){    
  int N;
  cin >> N;
  string S;
  cin >> S;
  int t = 0;
  if(N%2 == 1) cout << "No" << endl;
  else{
    for(int i = 0; i < N/2; i++){
      if(S.at(i) == S.at(N/2+i)) t++;
    }
    if(t == N/2) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

struct edge{
  int u,v,s,t;
  edge(int a=0, int b=0, int x=0, int y=0):u(a), v(b), s(x), t(y) {}
  bool operator<(const edge &e) const {
    return t < e.t;
  }
};

int main(){
  int n,m,s,g;
  cin >> n >> m >> s >> g; s--; g--;

  vector<vi> event(n);
  vector<edge> edges;
  rep(i,m){
    int u,v,t,c;
    cin >> u >> v >> t >> c; u--; v--;
    edges.eb( edge(u,v,t,t+c) );
    event[v].eb(t+c);
  }
  event[s].eb(0);
  sort(all(edges));
  rep(i,n){
    sort(all(event[i]));
    event[i].erase( unique(all(event[i])), event[i].end() );
    //rep(j,event[i].size()) cerr << event[i][j] << " ";
    //cerr << endl;
  }

  vector<vi> ans(n);
  rep(i,n){
    if(i==g) ans[i] = vi(event[i].size(), 0);
    else ans[i] = vi(event[i].size(), INF);
  }

  rrep(i, m){
    edge &e = edges[i];
    int u_p = upper_bound(all(event[e.u]), e.s) - event[e.u].begin();
    int v_p = lower_bound(all(event[e.v]), e.t) - event[e.v].begin();

    if(u_p != 0) chmin(ans[e.u][u_p-1], ans[e.v][v_p] + (e.s - event[e.u][u_p-1]));
    if(v_p != 0) chmin(ans[e.v][v_p-1], ans[e.v][v_p] + event[e.v][v_p] - event[e.v][v_p-1]);
  }
  cout << ans[s][0] << endl;
}

Measured memory_bytes: 16260
# -*- coding: utf-8 -*-

import os
import sys
import math
import numpy as np


N = int(input())
A = np.array([int(input()) for i in range(N)])

counter = {}

for a in A:
    if a in counter.keys():
        counter[a] = abs(counter[a] - 1)
    else:
        counter[a] = 1

print(sum(counter.values()))

Measured memory_bytes: 25124
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
int x[]={1,0,-1,0},y[]={0,1,0,-1};
int ans[25][25][25][25];
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	vector<string> s(h);
	rep(i,h)cin>>s[i];
	rep(i,h){
	    rep(j,w){
	        queue<pair<P,int>> que;
	        que.push({{i,j},0});
	        while(!que.empty()){
	            auto it=que.front();que.pop();
	            int px=it.first.first,py=it.first.second,point=it.second;
	            if((i==px&&j==py&&point!=0)||ans[i][j][px][py]!=0)continue;
	            if(s[px][py]=='#'){
	                ans[i][j][px][py]=-1;
	                continue;
	            }
	            ans[i][j][px][py]=point;
	            rep(k,4){
	                if(0<=px+x[k]&&px+x[k]<h&&0<=py+y[k]&&py+y[k]<w){
	                    que.push({{px+x[k],py+y[k]},point+1});
	                }
	            }
	        }
	    }
	}
	int an=0;
	rep(i,h){
	    rep(j,w){
	        rep(k,h){
	            rep(l,w){
	              an=max(an,ans[i][j][k][l]);
	            }
	        }
	    }
	}
	cout<<an<<endl;
}

Measured memory_bytes: 2304
#include<cstdio>
#include<algorithm>
using namespace std;
int n, res;
long long gcd(long long a, long long b) {
	return b?gcd(b, a%b) :a;
}
int main() {
	long long a, b, c, d;
	int TC;
	scanf("%d", &TC);
	while (TC--) {
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
		long long g = gcd(b, d);
		long long t = a % g;
		if (t <= c) t += (c - t) / g*g;
		while (t <= c)t += g;
		if (t >= b && a>=b && b<=d)puts("Yes");
		else puts("No");
	}
}

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

int main(){
	int x,y;
	while (1){
		cin >> x >> y;
		if (x == 0 && y == 0)break;

		if (x > y){
			int a;
			a = x;
			x = y;
			y = a;
		}
		cout << x <<" "<< y << endl;
	}

	return 0;
}

Measured memory_bytes: 3092
#include <cstdio>
#include <cstring>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
inline char nc()
{
	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++; \
}
template<class T> void read(T &x)
{
	x=0; int f=1,ch=nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x*=f;
} 
typedef long long ll;
const int mod=1e9+7;
const int maxn=600+5;
int n;
int a[maxn];
int mark[maxn];
int g[2][maxn][maxn];
inline void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int main()
{
	read(n),n<<=1;
	for(int i=1;i<=n;++i) read(a[i]);
	int k=0;
	for(int i=1;i<=n;i+=2)
	{
		if(a[i]!=-1&&a[i+1]!=-1) 
		{
			mark[a[i]]=mark[a[i+1]]=-1;
		}
		else 
		{
			if(a[i]!=-1) mark[a[i]]=1;
			if(a[i+1]!=-1) mark[a[i+1]]=1;
			if(a[i]==-1&&a[i+1]==-1) ++k;
		}
	}
	int cur=0;
	g[cur][0][0]=1;
	for(int i=n;i>=1;--i) if(mark[i]!=-1)
	{
		cur^=1;
		memset(g[cur],0,sizeof(g[cur]));
		for(int x=0;x<=n;++x) for(int s=0;s<=n;++s) if(g[cur^1][x][s])
		{
			if(mark[i]==1)
			{
				upd(g[cur][x][s+1],g[cur^1][x][s]);
				if(x) upd(g[cur][x-1][s],g[cur^1][x][s]); 
			}
			else
			{
				upd(g[cur][x+1][s],g[cur^1][x][s]);
				if(x) upd(g[cur][x-1][s],g[cur^1][x][s]);
				if(s) upd(g[cur][x][s-1],(ll)g[cur^1][x][s]*s%mod);
			}
		}
	}
	int an=g[cur][0][0];
	for(int i=1;i<=k;++i) an=(ll)an*i%mod;
	printf("%d\n",an);
	return 0;
} 

Measured memory_bytes: 3072
N, K = map(int, input().split())
S = input()

c0 = S.count('0')
if c0 == 0 or c0 == N:
  ans = N
else:
  A = [[0, 0, 0]]
  c = 0
  now = '1' if S[0]=='0' else '0'
  for s in S:
    if s == '0':
      if now == '1':
        A[-1][2] = c
        A.append([c, 1, 0])
        c = 1
        now = '0'
      else:
        c += 1
    else:
      if now == '1':
        c += 1
      else:
        A[-1][1] = c
        c = 1
        now = '1'
  
  A = A[1:]  
  if s == '0':
    if S[-2] == '0':
      A[-1][1] = c
  else:
    if S[-2] == '0':
      A[-1][2] = 1
    else:
      A[-1][2] = c
  m = len(A)
  if m <= K:
    ans = N
  else:
    ans = 0
    for i, a in enumerate(A):
      ans += a[0]+a[1]
      if i == K-1:
        ans += a[2]
        break

    l = ans
    for i in range(1, m-K+1):
      a1 = A[i-1]
      a2 = A[i+K-1]
      l = l-(a1[0]+a1[1])+(a2[1]+a2[2])
      ans = max(ans, l)


print(ans)

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

int main() { 
  
  int A,B;
  cin >> A >> B ;
  
  if (A+B == 3) {
    cout << 3 << endl;
  }
  
  if (A+B == 4) {
    cout << 2 << endl;
  }
  if (A+B == 5) {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
class SegmentTreeMax():
  def __init__(self,n,init):
    self.offset=2**((n-1).bit_length())
    self.tree=[init]*(2*self.offset)
    self.init=init
  def update(self,pos,val):
    pos+=self.offset
    self.tree[pos]=val
    while pos>1:
      pos=pos//2
      self.tree[pos]=max(self.tree[2*pos],self.tree[2*pos+1])
  def query(self,l,r):
    l+=self.offset
    r+=self.offset
    ret=self.init
    while l<=r:
      ret=max(ret,self.tree[r])
      r=(r-1)//2
      ret=max(ret,self.tree[l])
      l=(l+1)//2
    return ret

n,k=map(int,input().split())
arr=[int(input()) for _ in range(n)]
lim=max(arr)
st=SegmentTreeMax(lim,0)
for val in arr:
  l=max(0,val-k)
  r=min(lim,val+k)
  tmp=st.query(l,r)
  st.update(val,tmp+1)
print(st.query(0,lim))

Measured memory_bytes: 134388
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long[] a = new long[3];
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		for (int i = 0; i < 3; i++) {
			if (a[i] % 2 == 0) {
				System.out.println(0);
				return;
			}
		}
		Arrays.parallelSort(a);
		System.out.println(a[0] * a[1]);
	}
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vec b(n);
    int sum=0;
    int cnt=0;
    while(true){
        sum=0;
        rep(i,n){
            b[i]=ceil(max(a[i]-(n-1),0LL),n);
            sum+=b[i];
        }
        cnt+=sum;
        int ok=0;
        rep(i,n){
            a[i]=a[i]-b[i]*n+(sum-b[i])*1;
            if(a[i]<=n-1) ok++;
        }
        if(ok==n) break;
    }
    cout<<cnt<<endl;
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,b) for (int i = 0; i < (b); i++ )

typedef pair<int,int> P;
typedef long long ll;

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    ll R, L;
    cin >> L >> R;

    ll ans = 2018;

    ll r,l; 

    if (R-L>3000) {
      cout << 0 << endl;
    }
    else{
    for (ll l = L; l<R; l++) {
      for (ll r = l+1; r<=R; r++)
        ans = min(ans, (r*l)%2019);
    }

    cout << ans << endl;

    }
}


Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy

s = input()

dic = {}
for i in range(len(s)):
    current = dic.get(s[i],0)
    dic[s[i]] = current + 1

for key in dic:
    if dic[key] != 2:
        print("No")
        quit()

print("Yes")

Measured memory_bytes: 63980
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    if(x<a)
      System.out.println(0);
    else
      System.out.println(10);
  }
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

int main()
{
  ios::sync_with_stdio(0);
  string s;

  cin >> s;
  for(int i = 0; i < s.size(); i++)
    cout << 'x';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
S = []
for _ in range(N):
    S += [int(input())] 

if sum(S) % 10 != 0:
    print(sum(S))
    sys.exit()

count = 0
for i in S:
    if i % 10 == 0:
        count = count + 1
    else:
        break
    
if count == N:
    print(0)
    sys.exit()

S_sorted = sorted(S)

while True:
    for i in range(N):
        if S_sorted[i] % 10 != 0:
            S_sorted.pop(i)

            if sum(S_sorted) % 10 != 0:
                print(sum(S_sorted))
                sys.exit()
    

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

double f(double K, double i, int n) {
    if(K <= i) {
        return n;
    }
    n++;
    f(K, i * 2, n);
}

int main() {
    double N;
    double K;
    cin >> N >> K;
    double ans;
    for(double i = N; i >= 1; i--) {
        // double tmp;
        double cl = f(K, i, 0);
        ans += (1.0 / N) * pow(1.0 / 2.0, cl);
        // ans += tmp;
    }

    printf("%.12f\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <functional>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
const ll InF = 1e13;

int main() {
  ll A,B,Q;
  cin>>A>>B>>Q;
  vector<ll> s(A+2),t(B+2),X(Q);
  s[0] = t[0] = -InF;
  s[A+1] = t[B+1] = InF;
  for (int i = 1; i <= A; i++) cin>>s[i];
  for (int i = 1; i <= B; i++) cin>>t[i];
  for (int i = 0; i < Q; i++) cin>>X[i];
  for (int i = 0; i < Q; i++) {
    ll x;
    x = X[i];
    int sa,sb,ta,tb;
    sa = distance(s.begin(),upper_bound(s.begin(),s.end(),x));
    if (sa == A + 2) sa = A + 1;
    sb = sa - 1;
    ta = distance(t.begin(),upper_bound(t.begin(),t.end(),x));
    if (ta == B + 2) ta = B + 1;
    tb = ta - 1;
    ll ans,ret0,ret1,ret2,ret3;
    ret0 = max(s[sa],t[ta]) - x;
    ret1 = x - min(s[sb],t[tb]);
    ret2 = s[sa] - t[tb] + min(s[sa]-x,x-t[tb]);
    ret3 = t[ta] - s[sb] + min(t[ta]-x,x-s[sb]);
    ans = min(ret0,min(ret1,min(ret2,ret3)));
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

  int A, B, C;
  cin >> A >> B >> C;
  if (A == B) cout << C << endl;
  else if (A == C) cout << B << endl;
  else cout << A << endl;
    
  return 0;
}

Measured memory_bytes: 3572
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace AtCoder {
    public class Program {
        static int[] getKeys() {
            var Keys = Console.ReadLine().Split(' ');
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(delimiter);
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }

        public static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(T[,] map, string delimiter) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + delimiter);
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(IEnumerable<T> ts) {
            foreach (var item in ts) {
                Console.Write(item + " ");
            }
            Console.WriteLine();
        }
        public static void Show<T>(IEnumerable<T> ts, string delimiter) {
            foreach (var item in ts) {
                Console.Write(item + delimiter);
            }
            Console.WriteLine();
        }

        static void Main() {
            var Key = getKeys();
            if (Key[0] / 2 + Key[0] % 2 >= Key[1]) {
                Console.WriteLine("YES");
            } else {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int n;
  cin >> n;

  long long c;
  int i = 1;

  while (1) {

    if (i*i > n) {
      break;
    }
    c = i*i;
    i++;
  }

  cout << c << endl;
  return 0;
}



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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

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

  ll ans = 0;
  for(int i=0;i<n;++i) {
    for(int j=i+1;j<n;++j) {
      ans += min(a[i][j], a[j][i]);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
using namespace std;
struct data
{
	int id,p;
}a[100100];
int coo(struct data x,struct data y)
{
	if(x.p<y.p)  return 1;
	return 0;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)   cin>>a[i].p,a[i].id=i;
	sort(a+1,a+n+1,coo);
	for(int i=1;i<=n;i++)
	{
		cout<<a[i].id<<" ";
	}
	return 0;
}

Measured memory_bytes: 4392
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N, M, *a = map(int, read().split())
    A = {i for i in a}
    P = (10**9)+7

    dp = [0]*(N+1)
    dp[0] = 1

    if not (1 in A):
        dp[1] = 1
        

    for i in range(2, N+1):
        if i in A:
            continue
        else:
            dp[i] = (dp[i-1] + dp[i-2])%P
    print(dp[N])
if __name__ == '__main__':
    main()


Measured memory_bytes: 14164
m,n,l=map(int,input().split(" ")) #m=3,n=2,l=3
matA=[list(map(int,input().split(" "))) for i in range(m)] #matA[3][2]
matB=[list(map(int,input().split(" "))) for i in range(n)] #matB[2][3]
matAB=[[0 for i in range(l)] for k in range(m)] #matAB[3][3]

ele=0
for k in range(l):
    for i in range(m):
        for j in range(n):
            matAB[i][k]+=matA[i][j]*matB[j][k]

#print(matAB)
for i in range(m):
    for j in range(l):
        if j!=l-1:
            print(matAB[i][j],end=" ")
        else:
            print(matAB[i][j])


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

vector <pair<int, int>> A[16];

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

	int n, a, b, m;

	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> m;
		for (int j = 1; j <= m; j++)
		{
			cin >> a >> b;
			A[i].push_back(make_pair(a, b));
		}
	}

	int res = 0;

	for (int i = 0; i < (1 << n); i++)
	{
		int cnt = 0;
		int check[16];
		memset(check, -1, sizeof(check));

		for (int j = 0; j < n; j++)
		{
			if (i&(1 << j))
			{
				cnt++;
				check[j + 1] = 1;
			}
			else
			{
				check[j + 1] = 0;
			}
		}
		bool ok = true;
		for (int j = 1; j <= n; j++)
		{
			for (int k = 0; k < A[j].size(); k++)
			{
				int a = A[j][k].first;
				int b = A[j][k].second;
				if (check[j] == 1)
				{
					if(check[a]!=b)
					{
						ok = false;
						break;
					}
				}
			}
			if (ok == false)
			{
				break;
			}
		}

		if (ok)
		{
			res = max(res, cnt);
		}
	}

	cout << res << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
ll a[100010][3];
ll dp[100010][3];


int main() {
    int n;
    cin>>n;
    
    rep(i,n){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(j==k) continue;
                 chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    
    ll ans = 0;
    rep(j,3) chmax(ans, dp[n][j]);
                      
    cout << ans << endl;
    return 0;
}


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

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

fn main() {
    let mut a = [0; 3];

    for i in 0..3 {
        a[i] = read::<i32>();
    }

    a.sort();
    print!("{}", a[2]*10 + a[1] + a[0]);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int n; cin>>n;
	ll a[n];
	for(int i = 0 ; i < n ;i++)
		cin>>a[i];
	bool cant_sorry = false;
	int max_till_here = a[0]-1;
	for(int i = 1 ; i < n ; i++)
	{
		if(a[i]<max_till_here)
		{
			cant_sorry = true;
			break;
		}
		if(a[i]>max_till_here)
			max_till_here = a[i] -1;	
	}
	cout<<((cant_sorry)?"No":"Yes")<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            bool[] e = new bool[10];
            for (int i = 0; i < 10; i++)
            {
                e[i] = true;
            }

            s = Console.ReadLine().Split(' ');
            for (int i = 0; i < K; i++)
            {
                int j = int.Parse(s[i]);
                e[j] = false;
            }

            bool valid = false;
            do
            {
                int tmp = N;

                valid = true;

                while (tmp > 0)
                {
                    if (!e[tmp % 10])
                    {
                        valid = false;
                        break;
                    }

                    tmp /= 10;
                }

                if (!valid)
                {
                    N++;
                }
            }
            while (!valid);

            Console.WriteLine(N);
        }
    }
}


Measured memory_bytes: 13140