akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<string>
#include<set>
using namespace std;
string face[6];
int n;
int main(){
  while(cin >> n, n){
    set<string> ans;
    for(int j = 0;j < n;j++){
      cin >> face[0] >> face[1] >> face[2] >> face[3] >> face[4] >> face[5];
      string p;
      for(int i = 0;i < 4;i++){
	if(face[0] == "Blue")break;
	swap(face[0], face[1]);
	swap(face[1], face[5]);
	swap(face[5], face[4]);
      }
      for(int i = 0;i < 4;i++){
	if(face[0] == "Blue")break;
	swap(face[0], face[2]);
	swap(face[2], face[5]);
	swap(face[5], face[3]);
      }
      for(int i = 1;i < 5;i++){
	if(i == 1)p = face[i];
	p = min(p, face[i]);
      }
      while(face[1] != p){
	swap(face[1], face[2]);
	swap(face[2], face[4]);
	swap(face[4], face[3]);
      }
      string res ="";
      for(int i = 0;i < 6;i++){
	res += face[i][0];
      }
      ans.insert(res);
    }
    cout << n - ans.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
c = 0
for i in range(1, n):
    if a * (x[i] - x[i - 1]) <= b:
        c += a * (x[i] - x[i - 1])
    else:
        c += b
print(c)

Measured memory_bytes: 15020
<?php
$que=[];
$head=0;
$tail=0;
$size=100000;
list($N,$Q)=explode(' ',trim(fgets(STDIN)));
for($i=0;$i<$N;$i++) $que[$tail++]=(explode(' ',trim(fgets(STDIN))));
$TIME=0;
while($head!=$tail){
  $task=$que[$head++];
  if($head==$size){$head=0;}
  if($task[1]<=$Q){
    echo $task[0],' ',$TIME+$task[1],PHP_EOL;
    $TIME+=$task[1];
  }
  else{
    $task[1]-=$Q;
    $que[$tail++]=$task;
    if($tail==$size){$tail=0;}
    $TIME+=$Q;
  }
}

Measured memory_bytes: 74544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

vector<vector<int>> g(500*999+4);
vector<int> h(500*999+4,0);


int topological_sort(int v){
    queue<pii> q;
    for(int i = 0; i < v; i++){
        if(h[i] == 0) q.push({i,1});
    }
    vector<int> sorted;
    while(!q.empty()){
        int i = q.front().first;
        int day = q.front().second;
        q.pop();
        sorted.push_back(day);
        for(auto j: g[i]){
            h[j]--;
            if(h[j] == 0){
                q.push({j,day+1});
            }
        }
    }
    if(sorted.size() != v){
        return -1;
    }else{
        return sorted[v-1];
    }
}


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

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

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n-2; j++){
            int from_small = min(i+1,a[i][j]);
            int from_big = max(i+1,a[i][j]);
            int from_v_index = (from_small-1)*(n-1) - (from_small-1)*(from_small-2)/2 + from_big-from_small-1;
            int to_small = min(i+1,a[i][j+1]);
            int to_big = max(i+1,a[i][j+1]);
            int to_v_index = (to_small-1)*(n-1) - (to_small-1)*(to_small-2)/2 + to_big-to_small-1;
            g[from_v_index].push_back(to_v_index);
            h[to_v_index]++;
        }
    }

    int ans = topological_sort(n*(n-1)/2);
    cout << ans << endl;
    return 0;

}


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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> x(n);
  int s = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
    s += x[i];
  }

  int m = static_cast<int>(round(1.0 * s / n));
  int ans = 0;
  for (int i = 0; i < n; i++)
    ans += (x[i] - m) * (x[i] - m);
  printf("%d\n", ans);

  return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    i64 n;
    cin >> n;
    vector<i64> a(n);
    rep(i,0,n) cin >> a[i];
    sort(a.begin(),a.end());
    vector<i64> s(n);
    s[0]=a[0];
    rep(i,1,n) s[i]=s[i-1]+a[i];
    int ans=0;
    for(i64 i=n-1; i>=0; --i){
        i64 x=s[i],idx=i;
        while(idx<n-1){
            i64 tmp=upper_bound(a.begin(),a.end(),2*x)-a.begin()-1;
            if(tmp==idx) break;
            idx=tmp;
            x=s[idx];
        }
        if(idx==n-1) ++ans;
        else break;
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
using namespace std;

#define H 3
#define W 3
#define N 9

class Piece {
public:
    char top, right, bottom, left;
    Piece(string s="    ") :top(s[0]), right(s[1]), bottom(s[2]), left(s[3]) {}
    void rotate() {
        swap(top, right);
        swap(top, bottom);
        swap(top, left);
    }
};

bool match(char c1, char c2) {
    if(c1 == c2) return false;
    return tolower(c1) == tolower(c2);
}

vector<Piece> piece;

int dfs(int y, int x, vector< vector<Piece> > board, bitset<N> used) {
    if(used.count() == N) return 1;
    int result = 0;
    for(int i=0; i<N; i++) {
        if(used[i]) continue;
        Piece p = piece[i];
        for(int j=0; j<4; j++) {
            p.rotate();
            if(0 < x && !match(board[y][x-1].right, p.left)) continue;
            if(0 < y && !match(board[y-1][x].bottom, p.top)) continue;
            int ny = y, nx = x+1;
            bitset<N> u = used;
            if(W <= nx) {
                nx = 0;
                ny++;
            }
            board[y][x] = p;
            u.set(i);
            result += dfs(ny, nx, board, u);
        }
    }
    return result;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++) {
        piece.clear();
        for(int j=0; j<N; j++) {
            string s;
            cin>>s;
            piece.push_back(Piece(s));
        }
        vector< vector<Piece> > board(H, vector<Piece>(W, Piece()));
        bitset<N> used(0);
        cout<<dfs(0, 0, board, used)<<endl;
    }
}

Measured memory_bytes: 1216
function B168(_input) {
    var lines = _input.split("\n");
    var k = parseInt(lines.shift(),10);
    var s = lines.shift();

    if (s.length <= k) {
        console.log(s);
        return;
    }

    var str = s.slice(0, k) + '...';

    console.log(str);
}
B168(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29640
#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;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int gcd(int a,int b){
    while(1){
        if(a<b) swap(a,b);
        if(!b) break;
        a%=b;
    }
    return a;
}
int gcd3(int a,int b,int c){
    int ans1=gcd(a,b);
    return gcd(ans1,c);
}
int main(){
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                ans+=gcd3(i,j,k);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(){
    int A[666];
    int n,i,j,v;
    
//数列の長さと数列を入力
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&A[i]);
    
//挿入ソートアルゴリズム
    for(i=0;i<n;i++){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;

//挿入ソートで整列した数列を出力
        for(j=0;j<n-1;j++){
            printf("%d ",A[j]);
        }
        printf("%d\n",A[j]);
    }
    
    return 0;
}


Measured memory_bytes: 1932
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		String[] d = new String[]{
			"dream",
			"dreamer",
			"erase",
			"eraser"
		};
		
		int N = S.Length;
		bool[] chk = new bool[N + 1];
		chk[0] = true;
		for(int i=0;i<N;i++){
			if(!chk[i]) continue;
			foreach(var s in d){
				bool c = true;
				for(int j=0;j<s.Length;j++){
					if(i + j >= N){
						c = false;
						break;
					}
					c &= s[j] == S[i + j];
				}
				if(c) chk[i + s.Length] = true;
			}
		}
		
		Console.WriteLine(chk[N] ? "YES" : "NO");
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13144
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INA(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) >= 0 ? (a) : -(a))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int n;
multiset<int> bag, tmp;
int a[MAXN], indexx[MAXN];

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n;
	INA(a, n);
	
}

bool cmp(int u, int v) {
	return a[u] > a[v];
}


void preprocess() {
	
	FOR(i, 1, n)
		indexx[i] = i;
	
	sort(indexx+1, indexx+n+1, cmp);
	
	FOR(i, 1, n) {
		int id_l = i;
		while(i+1 <= n && a[indexx[i+1]] == a[indexx[i]]) {
			i++;
		}
		int id_r = i;
		
		vector<int> idx;
		FOR(id, id_l, id_r)
			idx.push_back(indexx[id]);
		sort(idx.begin(), idx.end());
		
		tmp.clear();
		for (int ii = idx.size()-1; ii >= 0; --ii) {
			int id = idx[ii];
			
			auto pt = bag.upper_bound(id);
			if (pt != bag.end()) {
				bag.erase(pt);
			}
			tmp.insert(id);
			
		}
		
		ITE(tmp) {
			bag.insert(*it);
		}
		
	}
	
	cout << bag.size() << "\n";
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 14584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long ,long> ii; 	
typedef complex<long double> com;
 
const ll mod = 998244353;

vector <vector<ll>> graph;

struct node{
	ll w,p;
	bool operator<(const node& rhs) const{
		return w > rhs.w;
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,y;
	cin >> n >> x >> y;
	graph.resize(n+1);
	for (int z=1;z<n;z++){
		graph[z].push_back(z+1);
		graph[z+1].push_back(z);
	}
	graph[x].push_back(y);
	graph[y].push_back(x);
	vector<vector<ll>> dist(n+1,vector<ll>(n+1,LLONG_MAX));
	for (int z=1;z<=n;z++){
		vector <bool> visited(n+1,false);
		visited[z] = true;
		dist[z][z] = 0;
		priority_queue <node> que;
		for (ll v : graph[z]){
			node temp;
			temp.w = 1;
			temp.p = v;
			que.push(temp);
			dist[z][v] = 1;
		}
		while (!que.empty()){
			node temp = que.top();
			ll u = temp.p;
			ll w = temp.w;
			que.pop();
			if (visited[u]) continue;
			for (ll v : graph[u]){
				if (visited[v]) continue;
				if (dist[z][u]+1 < dist[z][v]){
					dist[z][v] = dist[z][u]+1;
					node t;
					t.p = v;
					t.w = dist[z][v];
					que.push(t);
				}
			}
		}
	}
	vector <ll> ans(n);
	for (int z=1;z<=n;z++){
		for (int x=z+1;x<=n;x++){
			ans[dist[z][x]]++;
		}
	}
	for (int z=1;z<n;z++){
		cout << ans[z] << endl;
	}
}

Measured memory_bytes: 31744
import math
import sys
X = int(input())
count = 0
while True:
    for i in range(2,math.ceil(math.sqrt(X))):
        count= 0
        if X%i == 0:
            count += 1
            break

    if count == 0:
        print(X)
        sys.exit()
        break
    X += 1

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


int main() {
	int n, k;
	string a = "a", z = "z";
	string A = "A", Z = "Z";
	string x;
	cin >> x;
	if (x.compare(a) >= 0 && x.compare(z) <= 0) cout << a << endl;
	else if (x.compare(A) >= 0 && x.compare(Z) <= 0) cout << A << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M=1e5+10;
int n,q,len;
char s[M];
int a[M];
int main()
{
    scanf("%d%d%s",&n,&q,s);
    for(int i=1;i<n;i++)
        a[i]=a[i-1]+(s[i-1]=='A' && s[i]=='C');
    while(q--)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",a[r-1]-a[l-1]);
    }
    return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		/*
		 * ケツからたどればよさそう（ケツは情報量が少ないので）
		 * ケツからだと情報が把握できる
		 * いま連結かどうかを何度も判定するので、高速なアルゴリズムが必要
		 * UnionFndで共通祖先を連結か何かに応用できないか？
		 */
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[][] data=new int[M][2];
		long[] res=new long[M+1];
		long fumando=((long)N)*((long)N-1)/2L;
		res[0]=fumando;
		for(int i=M-1; i>=0; i--) {
			data[i][0]=sc.nextInt();
			data[i][1]=sc.nextInt();
		}
		UnionFindTree UFT=new UnionFindTree(N);
		for(int i=0; i<M; i++) {
			int AR=UFT.find(data[i][0]);
			int BR=UFT.find(data[i][1]);
			long a=(long)UFT.size(AR);
			long b=(long)UFT.size(BR);
			//pl(AR+" "+BR+" "+a+" "+b);
			UFT.union(data[i][0], data[i][1]);
			if(AR!=BR) {
				res[i+1]=res[i]-a*b;
			}
			else {
				res[i+1]=res[i];
			}
		}
		for(int i=M-1; i>=0; i--) {
			pl(res[i]);
		}
	}

	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	public static class UnionFindTree {
		int nodeNum;	//頂点数
		int [] parent;	//親の頂点の値
		int [] height;	//高さ（祖先からの距離）
		int [] treeSize;	//共通祖先を持つ頂点集合の数（クラスタ内の頂点の数）

		public UnionFindTree(int nodeNum) {
			this.nodeNum = nodeNum;
			parent = new int[nodeNum+1];
			height = new int[nodeNum+1];
			treeSize = new int[nodeNum+1];
			for (int i = 1; i <= nodeNum; i++) {
				parent[i] = i;
				height[i] = 0;
				treeSize[i] = 1;
			}
		}
		int find(int x) {
			if (parent[x] == x) {
				return x;
			} else {
				return parent[x] = find(parent[x]);
			}
		}
		void union(int x, int y) {
			int rootX = find(x);
			int rootY = find(y);
			if (rootX == rootY) {
				return;
			}
			if (height[rootX] < height[rootY]) {
				parent[rootX] = rootY;
				treeSize[rootY] += treeSize[rootX];
			} else {
				if (height[rootX] == height[rootY]) {
					height[rootX]++;
				}
				parent[rootY] = rootX;
				treeSize[rootX] += treeSize[rootY];
			}
		}
		int size(int vertex) {
			return treeSize[vertex];
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

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

int main() {
  string s; cin >> s;
  if(s[0] == s[1] && s[1] == s[2]){
    cout << "Yes";
  }
  else if(s[1] == s[2] && s[2] == s[3]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (100)

int main()
{
	int N;
	scanf("%d", &N);

	int P[MAX_N], Q[MAX_N];
	for (int i = 0; i < N; i++)
		scanf("%d", &P[i]);
	for (int i = 0; i < N; i++)
		scanf("%d", &Q[i]);

	vector<int> v;
	for (int i = 1; i <= N; i++)
		v.push_back(i);
	int p_index = -1, q_index = -1;
	int _index = 0;
	do {
		bool is_p = true, is_q = true;
		for (int i = 0; i < N; i++) {
			if (v[i] != P[i])
				is_p = false;
			if (v[i] != Q[i])
				is_q = false;
		}
		if (is_p)
			p_index = _index;
		if (is_q)
			q_index = _index;
		_index++;
	} while (next_permutation(v.begin(), v.end()));

	printf("%d\n", abs(p_index - q_index));

	return 0;
}


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

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {  
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost < dist[e.to]) return vector< T >();
  }
  return dist;
}

pair<int, int> calc_bd(string s, int j) {
  int b = 0, d = 0;
  while ( isdigit(s[j]) ) {
    b *= 10;
    b += s[j]-'0';
    j++;
  }
  int sign = (s[j] == '+') ? 1 : -1;
  j++;
  while ( isdigit(s[j]) ) {
    d *= 10;
    d += s[j]-'0';
    j++;
  }
  return {b, sign*d};  
}

using t3 = tuple<int, int, int>;
const int INF = 1e9;

signed main() {  
  int N, C;
  cin >> N >> C;

  Edges<int> es;
  vector<t3> asta;     
  for ( int i = 0; i < C; i++ ) {
    string s;
    cin >> s;
    int j = 0;
    int a = 0, b = 0, d = 0;
    pair<int, int> p;
    
    while ( isdigit(s[j]) ) {
      a *= 10;
      a += s[j]-'0';
      j++;      
    }
    if ( s[j] == '*' ) {
      j++;
      p = calc_bd(s, j);
      b = p.first;
      d = p.second;
      a--; b--;
      asta.emplace_back(t3(a, b, d));      
    } else {
      char c = s[j];      
      j += 2;      
      p = calc_bd(s, j);
      b = p.first;
      d = p.second;
      a--; b--;
      if ( c == '<' ) {
	es.emplace_back(b, a, 0);	
	if ( d > 0 ) es.emplace_back(b, a, -d);	
	else es.emplace_back(a, b, -d);	
      } else {
	es.emplace_back(a, b, 0);	
	if ( d > 0 ) es.emplace_back(a, b, -d);	
	else es.emplace_back(b, a, -d);	
      }
    }
  }

  int sz = asta.size();
  // cout << sz << endl;
  int ans = -1;  
  bool flag2 = false;
  for ( int i = 0; i < (1<<sz); i++ ) {
    Edges<int> tmp = es;
    for ( int j = 0; j < sz; j++ ) {
      int a = get<0>(asta[j]), b = get<1>(asta[j]), d = get<2>(asta[j]);
      // cout << a << " " << b << " " << d << endl;
      if ( i & (1<<j) ) {
	tmp.emplace_back(b, a, 0);	
	if ( d > 0 ) tmp.emplace_back(b, a, -d);	
	else  tmp.emplace_back(a, b, -d);	
      } else {
	tmp.emplace_back(a, b, 0);	
	if ( d > 0 ) tmp.emplace_back(a, b, -d);	
	else tmp.emplace_back(b, a, -d);	
      }
    }

    auto dists = bellman_ford(tmp, N, 0);
    if ( dists.empty() || *min_element(begin(dists), end(dists)) < 0 ) continue;
    flag2 = true;
    // cout << *max_element(begin(dists), end(dists)) << endl;
    ans = max(ans, *max_element(begin(dists), end(dists)));      
  }
  
  if ( ans == numeric_limits<int>::max() ) puts("inf");  
  else cout << ans << endl;  
  
  return 0;
}



Measured memory_bytes: 3216
n=int(input())
dp=[0]*(n+2)
for x in range(1,151):
    for y in range(1,151):
        for z in range(1,151):
            aa=(x*x+y*y+z*z+x*y+y*z+z*x)
            if aa<=n:
                dp[aa]+=1
for i in range(1,n+1):
    print(dp[i])

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

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

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

signed main(){
	int n,k;
	cin>>n>>k;
	rep(i,1,k+1){
		if(i<min(k+1,n-k+2))cout<<COM(k-1,i-1)*COM(n-k+1,i)%MOD<<endl;
		else cout<<0<<endl;

	}
}

Measured memory_bytes: 12160
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<stdio.h>
using namespace std;
int main(){
    int count[4][3][10] ;
    int j,k,l;
    for(j=0;j<4;j++){
        for(k=0;k<3;k++){
            for(l=0;l<10;l++){
                count[j][k][l] = 0;
            }
        }
    }

    int n;
    cin >> n;
    int i;
    for(i = 0;i < n; i++){
        int b,f,r,v;
        cin >> b>>f>>r>>v;
        count[b-1][f-1][r-1] += v;
    }
    j,k,l = 0,0,0;


    for(j=0;j<4;j++){
        for(k=0;k<3;k++){
                for(l=0;l<10;l++){
                        cout << " " << count[j][k][l];
                }
                cout << "\n";
        }
        if (j != 3){
            cout << "####################" << "\n";
        }else{
            
        }
    }
    return 0;
}


Measured memory_bytes: 3096
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

template <class A, class B> inline int Max(const A &a, const B &b){ return (a < b ? b : a); }
template <class A, class B> inline int Min(const A &a, const B &b){ return (a > b ? b : a); }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
 
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int ms1 = h1 * 60 + m1;
    int ms2 = h2 * 60 + m2;

    cout << ms2 - ms1 - k << '\n';
 
    return (0);
}


Measured memory_bytes: 3652
package main

import (
  "fmt"
)

func min(n ...int) int {
  if len(n) == 0 {
    panic("len == 0")
  }
  r := n[0]
  for i := 1; i < len(n); i++ {
    if n[i] <= r {
      r = n[i]
    }
  }
  return r
}

func main() {
  var H, N, A, B int
  fmt.Scan(&H, &N)
  dp := make([]int, H+10001)
  for l := 1; l < H+10001; l++ {
    dp[l] = 2100000000
  }
  amax := 0
  for i := 0; i < N; i++ {
    fmt.Scan(&A, &B)
    if A >= amax {
      amax = A
    }
    dp[A] = min(dp[A], B)
    for j := A+1; j <= H+A+1; j++ {
      dp[j] = min(dp[j], dp[j-A] + B)
    }
  }
  fmt.Println(min(dp[H:H+amax+1]...))
}



Measured memory_bytes: 768
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll x, n;
    cin >> x >> n;
    set<ll> p;
    rep(i, n)
    {
        ll tempP;
        cin >> tempP;
        p.insert(tempP);
    }
    ll dist = 0;
    while (true)
    {
        if (!contains_set(p, x - dist))
        {
            cout << x - dist << endl;
            break;
        }
        else if (!contains_set(p, x + dist))
        {
            cout << x + dist << endl;
            break;
        }
        ++dist;
    }
}

Measured memory_bytes: 3232
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

int main(int argv, char **argc){
   // ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("C:/Users/LAB-605/Desktop/season5/in.txt", "r", stdin);

	int n, m;
	cin >> n >> m;
	cout << (m>=n ? "Yes":"No") << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
N,P = map(int, input().split())
S = list(input()[::-1])
ans = 0
if P == 2:
    for i,s in enumerate(S):    
        if int(s) in [2,4,6,8,0]:
            ans += N - i
elif P == 5:
    for i,s in enumerate(S):    
        if int(s) in [0,5]:
            ans += N - i
else:
    d = defaultdict(int)
    cnt = 0
    d[0] = 1
    for i,s in enumerate(S):
        cnt = (cnt + pow(10,i,P)*int(s))%P
        d[cnt] += 1
    for k in d.keys():
        if d[k] > 1:
            ans += d[k]*(d[k]-1)//2 
print(ans)


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

using namespace std;

bool p[1000001];

int main(void){

  fill(p,p+1000001,true);
  p[0]=p[1]=false;
  
  for(int i=2;i*i<1000001;i++){
    if(p[i]){
      for(int j=i*i;j<1000001;j+=i){
	p[j] = false;
      }
    }
  }

  int a,d,n;
  while(cin >> a >> d >> n,a|d|n){
    int cnt=0,i=a;
    for(;cnt<n;i+=d)cnt+=p[i];
    cout << i-d << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4016
if __name__ == '__main__':
	N = int(input())
	A = [int(a) for a in input().split()]
	c = 0
	for a in A:
		if a % 2 == 0:
			if a % 3 != 0 and a % 5 != 0:
				c = 1

	if c == 1:
		print('DENIED')
	else:
		print('APPROVED')

Measured memory_bytes: 3060
def s(p,q):
    a=p[0]
    b=p[1]
    c=q[0]
    d=q[1]
    return [(2*a+c)/3,(2*b+d)/3]
def t(p,q):
    a=p[0]
    b=p[1]
    c=q[0]
    d=q[1]    
    return [(a+2*c)/3,(b+2*d)/3]
def u(p,q):
    a=p[0]
    b=p[1]
    c=q[0]
    d=q[1]
    return [(a+c)/2+(3**(1/2))*(b-d)/6,(b+d)/2+(3**(1/2))*(c-a)/6]

def koch(p1,p2,n):
    if n==0:
        return [p1]
    else:
        return koch(p1,s(p1,p2),n-1)+koch(s(p1,p2),u(p1,p2),n-1)+koch(u(p1,p2),t(p1,p2),n-1)+koch(t(p1,p2),p2,n-1)

n=int(input())
a=[0,0]
b=[100,0]
for i in koch(a,b,n):
    print(str(i[0])+" "+str(i[1]))

print(str(b[0])+" "+str(b[1]))




Measured memory_bytes: 6236
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 1LL<<60;
/* -- template -- */

int main(){
    ll N;
    ll minv = LLINF;
    ll A[5]; cin >> N;rep(i, 5){cin >> A[i];minv = min(minv, A[i]);}
    cout << 4 + ((N % minv == 0) ? N / minv : N / minv + 1) << endl;
}


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

struct Edge
{
    int to;
    int next;
}a[400009];
int cnt;
int head[400009];
int n;
int vis[400009];
void addedg(int u,int v)
{
    a[cnt].to=v;
    a[cnt].next=head[u];
    head[u]=cnt++;
}
int flag=0;
void dfs(int s,int t)
{
    if(t>2)return;
    else if(t==2)
    {   if(s==n)
         {
             flag=1;
         }
        return;
    }
    else
    {
        for(int e=head[s];e!=-1;e=a[e].next)
        {
            /*if(vis[e]==0)
            {
                vis[e]=1;
                dfs(a[e].to,t+1);
                vis[e]=0;
            }*/
            dfs(a[e].to,t+1);
        }
    }
}
int main()
{
   int m;
   cin>>n>>m;
   memset(vis,0,sizeof(vis));
   memset(head,-1,sizeof(head));
   cnt=0;
   for(int i=1;i<=m;i++)
   {
       int u,v;
       cin>>u>>v;
       addedg(u,v);
       addedg(v,u);
   }
  // vis[1]=0;
  dfs(1,0);
   if(flag==1)
   {
       cout<<"POSSIBLE";
   }
   else
   {
       cout<<"IMPOSSIBLE";
   }
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main(){
string s;
  cin>>s;
  if(s[0]=='A'){
    ll count=0;
  for(ll i=2;i<s.size()-1;i++){
  if(s[i]=='C')
    count++;
  }
    if(count==1){
       if(s[1]=='C'||s[s.size()-1]=='C'){
       cout<<"WA";
       }
            else{
              int flag=0;
      for(ll i=1;i<s.size();i++){
      if(s[i]-'a'<0&&s[i]!='C'){
      cout<<"WA";
        flag=1;
        break;
      }
      }
              if(flag==0){
              cout<<"AC";
              }
              
            }
    }
    else{
        cout<<"WA";
    }
  }
  else{
  cout<<"WA";
  }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, K;
  cin >> N >> K;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  vector<int> S;
  S.push_back(0);
  int b = 0;
  rep(i,N){
    b += v[i];
    b %= K;
    S.push_back(b);
  }
  rep(i,S.size()){
    S[i] = (S[i]-(i%K)+K)%K;
  }
  
  map<int,int> memo;
  rep(i,min(K,(int)S.size())){
    memo[S[i]]++;
  }
  ll ret = 0;
  rep(i,N){
    memo[S[i]]--;
    ret += memo[S[i]];
    //cout << i << " " << S[i] << " " << memo[S[i]] << endl;
    if(i+K<N+1) memo[S[i+K]]++;
  }

  cout << ret << endl;
  
  return 0;
}


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

string solve(int c1,int c2,int canLookCard){
    int count=0;

    for(int i=1; i<11; i++){
        if(i==c1 || i==c2 || i==canLookCard)
            continue;
        if(c1+c2+i>20){
            count++;
        }
    }
    return (count>3) ? "NO" : "YES";
}

int main()
{
    int c1,c2,canLookCard;
    while(cin>>c1>>c2>>canLookCard,!cin.eof()){
        cout<<solve(c1,c2,canLookCard)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1196
mod=1000000007
#mod=1777777777
pi=3.1415926535897932
IS=float('inf')

n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=a*2
ans=chk=0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]>a[j]:
            chk+=1
            chk%=mod

for i in range(n):
    for j in range(n,n*2):
        if b[i]>b[j]:
            ans+=1
            ans%=mod
t=k-1
t=t*(t+1)//2
print((chk*k%mod+ans*t%mod)%mod)


Measured memory_bytes: 41964
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wtr = bufio.NewWriter(os.Stdout)
)

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

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

func main() {
	sc.Split(bufio.ScanWords)

	a,b,c := scanInt(),scanInt(),scanInt()

	if a+b+c >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}


Measured memory_bytes: 640
H, N = map(int, input().split())
hpdown = list()
mpdown = list()
for i in range(N):
  a, b = map(int, input().split())
  hpdown.append(a)
  mpdown.append(b)
  
hmax = H+(max(hpdown)+1)
dp = [10 ** 9] * (hmax)
dp[0] = 0
for h in range(1, hmax):
  for n in range(N):
    if(h-hpdown[n]>=0):
      dp[h] = min(dp[h], dp[h-hpdown[n]] + mpdown[n])
      
ans = 10 ** 9
for i in range(H, hmax):
  if(dp[i] < ans):
    ans = dp[i]
print(ans)

Measured memory_bytes: 41836
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, 10000*50+10)
	ans := make([]int, 10000*50+10)

	for i := 1; i <= n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 1; i <= n; i++ {
		ans[a[i]] = i
	}

	//fmt.Println(ans)
	if n == 1 {
		fmt.Println(ans[1])
	} else {
		fmt.Print(ans[1])
		for i := 2; i <= n; i++ {
			fmt.Print(" " + strconv.Itoa(ans[i]))
		}
		fmt.Println()
	}
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<double> A(5);//全ての都市は1分で移動可能
  double N;
  cin >> N;
  for(int i=0;i<5;i++)
    cin >> A.at(i);
  
  /**
   * N人が都市1にいる状態でスタート
   * 1分後には，A(0)人が都市1から都市2へ移動できる
   * それぞれの交通機関は独立して人を運搬できる
   * 最短では5分で全員移動ができるはず
   * 
   * 解法
   * どんな順序で人を運搬しても，必要な時間は変わらない
   * 運搬できる最小の人数の交通機関について考えていく
   * その人数をm人とすると，
   * 余計にかかる時間は，N / m 分
   * 合わせて，4を加えたら合計の時間になる
  */

  sort(A.begin(), A.end());//昇順にソート
  double min = A.at(0);
  double m = ceil(N / min) + 4;

  cout << std::setprecision(20);
  cout << m << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
 
int main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,k,ans=0,a[N];
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++)ans+=a[i];
    cout<<ans;
    
    
    
    
    
}


Measured memory_bytes: 3628
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try {
		    Scanner sc=new Scanner(System.in);
		    String s=sc.next();
		    char ch=s.charAt(s.length()-1);
		    if(ch=='2'||ch=='4'||ch=='5'||ch=='7'||ch=='9')
		    System.out.println("hon");
		    else if(ch=='0'||ch=='1'||ch=='6'||ch=='8')
		    System.out.println("pon");
		    else
		    System.out.println("bon");
		} catch(Exception e) {
		} finally {
		}
	}
}

Measured memory_bytes: 35724
#include <stdio.h>
#include <stdlib.h>

int cmp(const void* a, const void* b) {
	int maaya = *(const int*)a;
	int sumipe = *(const int*)b;
	if (maaya < sumipe) return -1;
	return maaya > sumipe;
}

int main(void) {
	int N;
	int* d;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	d = malloc(sizeof(*d) * N);
	if (d == NULL) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &d[i]) != 1) return 1;
	}
	qsort(d, N, sizeof(*d), cmp);
	if (N % 2 != 0) {
		puts("0");
	} else {
		printf("%d\n", d[N / 2] - d[N / 2 - 1]);
	}
	free(d);
	return 0;
}


Measured memory_bytes: 892
import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._
  loop()
  @tailrec def loop(): Unit = {
    val str = readLine.trim
    if (str == "#") return
    str match {
      case Expression(e) ⇒ println(e)
      case _ ⇒ ???
    }
    loop()
  }
}
object Expression {
  val mod = 1000000007L

  def unapply(arg: String): Option[Long] = {
    arg.filterNot(_.isWhitespace).toList match {
      case e Expr Nil ⇒ Some(e)
      case _ ⇒ None
    }
  }

  object Number {
    def unapply(arg: List[Char]): Option[(Long, List[Char])] = {
      arg.span(_.isDigit) match {
        case (Nil, _) ⇒ None
        case (n, rest) ⇒ Some(n.foldLeft(0L){case (acc, d) ⇒ acc * 10 + d.asDigit}, rest)
      }
    }
  }
  object Term {
    def unapply(arg: List[Char]): Option[(Long, List[Char])] = {
      arg match {
        case n Number rest ⇒ Some(n, rest)
        case 'S'::'<'::(e Expr '>'::rest) ⇒ Some((e * e) % mod, rest)
        case _ ⇒ None
      }
    }
  }
  object Expr {
    def unapply(arg: List[Char]): Option[(Long, List[Char])] = {
      arg match {
        case t Term rest ⇒ Some(takeAll(rest, t))
        case _ ⇒ None
      }
    }
    @tailrec private[this] def takeAll(arg: List[Char], left: Long): (Long, List[Char]) = {
      arg match {
        case '>'::'>'::(right Term rest) ⇒ takeAll(rest, left >> math.min(63, right))
        case _ ⇒ (left, arg)
      }
    }
  }
}


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

int main(){ 
    int n;
    cin >> n;
    // if(n <= 100){
    if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9 ){
            cout << "hon" << endl;
    }
    else if(n%10 == 3) cout << "bon" << endl;
    else cout << "pon" << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int a,b;
    cin>>a>>b;
    cout<<(b%a?b-a:b+a);
    
    
    return 0;
}

Measured memory_bytes: 256
import sys
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m,x=mp()
l=[lmp() for i in range(n)]
ans=[]
for i in range(2**n):
    b=bin(i)[2:]
    c=b.zfill(n)
    q=[0]*(m+1)
    for k in range(n):
        if c[k]=="0":
            for j in range(0,m+1):
                q[j]+=l[k][j]



    ch=0
    for j in range(1,m+1):
        if q[j]<x:
            ch=1
    if ch==0:
        ans.append(q[0])
if len(ans)==0:
    print(-1)
else:
    print(min(ans))

Measured memory_bytes: 69732
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

const int inf = 1e9;
int pos[100000];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) pos[i] = inf;
    deque<int> q;
    pos[1] = 1;
    q.push_back(1);
    while (!q.empty()) {
        int x = q.front();
        q.pop_front();
        if (pos[x] < pos[(x * 10) % k]) {
            pos[(x * 10) % k] = pos[x];
            q.push_front((x * 10) % k);
        }
        if (pos[x] + 1 < pos[(x + 1) % k]) {
            pos[(x + 1) % k] = pos[x] + 1;
            q.push_back((x + 1) % k);
        }
    }
    printf("%d\n", pos[0]);
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n;vector<int>a;
main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int b;cin>>b;a.push_back(b);
    }
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    cout<<a.size()<<endl;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(),(x).end()

int main() {
	int a, b;
	cin >> a >> b;

	int sum = 0;
	sum += max(a, b);
	sum += max(min(a, b) , sum - 1);

	cout << sum << endl;

    return 0;
}



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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	string S; cin >> S;
	int ans = 0;
	if(S=="SUN") ans = 7; 
	if(S=="MON") ans = 6; 
	if(S=="TUE") ans = 5; 
	if(S=="WED") ans = 4; 
	if(S=="THU") ans = 3; 
	if(S=="FRI") ans = 2; 
	if(S=="SAT") ans = 1;
	cout << ans << endl; 

    return 0;
}

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

int N, temp;
std::vector<int> A;

int main() {
    std::cin >> N;
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        A.push_back(temp);
    }
    std::sort(A.begin(), A.end());

    auto begin = A.begin();
    auto next = std::next(begin);
    
    while (next != A.end() && *begin != 1) {
        *next = *next % *begin;
        
        if (*next < *begin && *next != 0) {
            temp = *next;
            *next = *begin;
            *begin = temp;
        } else if (*next == 0) {
            next++;
        }
        
    }
    std::cout << *begin << std::endl;
}


Measured memory_bytes: 892