akhauriyash/Code-Regression huggingface dataset:
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
puts 2**(log2 gif).to_i


Measured memory_bytes: 3196
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
import itertools

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最小公倍数
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b
 
# 最大公約数 
def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

N = INT()
P = LIST()
Q = LIST()
s = sorted(P)


# for i in range(N):
#   a = P[i] * factorial(N - (i + 1))
  # print(a)
jun = list(itertools.permutations(s))
for i, l in enumerate(jun):
  if tuple(P) == l:
    a = i
  if tuple(Q) == l:
    b = i
print(abs(a-b))




Measured memory_bytes: 9812
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

int main () {
  ll x;
  int p;
  cin >> x >> p;
  if (x%2 == 1) {
    x++;
  }
  double pp = p/(double)100;
  double vec = -1 * pp + (1-pp);
  vec -= 1;
  cout << fixed << setprecision(12) << x/(-1 * vec) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) , _## i = ((y) + 1) ; i < _## i ; i ++)
#define Rep(i , x , y) for(register int i = (x) , _## i = ((y) - 1) ; i > _## i ; i --)
using namespace std ;
#define int long long
using ll = long long ;
using pii = pair < int , int > ;
const static int _ = 1 << 20 ;
char fin[_] , * p1 = fin , * p2 = fin ;
inline char gc() { return (p1 == p2) && (p2 = (p1 = fin) + fread(fin , 1 , _ , stdin) , p1 == p2) ? EOF : * p1 ++ ; }
inline int read() {
	bool sign = 1 ; char c = 0 ; while(c < 48) ((c = gc()) == 45) && (sign = 0) ;
	int x = (c & 15) ; while((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15) ;
	return sign ? x : -x ;
}
template < class T > void print(T x , char c = '\n') {
	(x == 0) && (putchar(48)) , (x < 0) && (putchar(45) , x = -x) ;
	static char _st[100] ; int _stp = 0 ;
	while(x) _st[++ _stp] = x % 10 ^ 48 , x /= 10 ;
	while(_stp) putchar(_st[_stp --]) ; putchar(c) ;
}
template < class T > void cmax(T & x , T y) { (x < y) && (x = y) ; }
template < class T > void cmin(T & x , T y) { (x > y) && (x = y) ; }
int n ;
const int N = 1e5 + 10 ;
vector < int > G[N] ;
int a , b ;
int fa[N] , d[N] , mx[N] ;
void dfs(int u) {
	for(int v : G[u]) {
		if(v == fa[u]) continue ;
		fa[v] = u ;
		d[v] = d[u] + 1 ;
		dfs(v) ;
	}
}
void dfs2(int u) {
	mx[u] = d[u] ;
	for(int v : G[u]) {
		if(v == fa[u]) continue ;
		dfs2(v) ;
		if(mx[v] > mx[u]) mx[u] = mx[v] ;
	}
}
signed main() {
#ifdef _WIN64
	freopen("testdata.in" , "r" , stdin) ;
#endif
	n = read() ; a = read() ; b = read() ;
	rep(i , 1 , n - 1) {
		int a = read() , b = read() ;
		G[a].push_back(b) ;
		G[b].push_back(a) ;
	}
	dfs(b) ; dfs2(b) ;
	int dep = d[a] >> 1 ;
	while(dep --) a = fa[a] ;
	print(mx[a] - 1) ;
	return 0 ;
}

Measured memory_bytes: 13056
H, W = map(int, input().split())
G = [input() for _ in range(H)]

for i in range(1, H-1):
  for j in range(1, W-1):
      if G[i][j] == '#':
        if G[i-1][j] != '#' and G[i+1][j] != '#' and G[i][j-1] != '#' and G[i][j+1] != "#":
          print('No')
          exit()
        
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
#include <map>
#define modulus 1000000007
using namespace std;

int n, m;
vector<vector<int>> arr(100005, vector<int>());
vector<int> res(100005);
vector<bool> visi(100005, false);
vector<long long> dis(100005, 0);
queue<pair<int,long long>> q;
queue<int> q1;

void f(){
    q.push({0,0});
    q1.push(-1);
    visi[0] = true;
    while(!q.empty()){
        pair<int,long long> p = q.front();
        int par = q1.front();
        q.pop();
        q1.pop();
        dis[p.first] = p.second;
        res[p.first] = par+1;
        for(int i = 0; i < arr[p.first].size(); i++){
            if(!visi[arr[p.first][i]]){
                visi[arr[p.first][i]] = true;
                q.push({arr[p.first][i], p.second+1});
                q1.push(p.first);
            }
        }
    }
}

int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        arr[u-1].push_back(v-1);
        arr[v-1].push_back(u-1);
    }
    f();
    bool ok = true;
    for(int i = 0; i < n && ok; i++){
        if(!visi[i]) ok = false;
    }
    if(ok){
        cout << "Yes" << endl;
        for(int i = 1; i < n; i++) cout << res[i] << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 12552
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String x = scan.next();
		String y = scan.next();
		String[] ya = y.split("");
		String a = x + x;
		String[] aa = a.split("");
		int len = aa.length - ya.length;
		int i,m,t;
		t = 0;
		for(i = 0; i < len; i++){
			t = 0;
			for(m = 0; m < y.length(); m++){
				if(aa[i + m].equals(ya[m])){
					++t;
				}
			}
				if(t == y.length()){
					System.out.println("Yes");
					break;
				}
				
			
			}
		if(t != y.length())
			System.out.println("No");
 			}

	}


	

Measured memory_bytes: 26372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ans1 = a[n-1];
    ll ans2 = -1;
    ll ans_max = INF;
    rep(i,n-1){
        if(abs(2*a[i]-a[n-1])<ans_max){
            ans2=a[i];
            ans_max = abs(2*a[i]-a[n-1]);
        }
    }
    cout << ans1 << " " << ans2;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=3e5+5;
int n,a[N],tot,ok;
int xj=1e9+7,yj=1e9+7;
pair<int,int> p[N],jd;

void init()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);reverse(a+1,a+n+1);
	p[++tot]=make_pair(0,n);p[++tot]=make_pair(a[n],n);
	for(i=n;i>1;--i)
		if(a[i]<a[i-1])
		{
			p[++tot]=make_pair(a[i],i-1);
			p[++tot]=make_pair(a[i-1],i-1);
		}
	p[++tot]=make_pair(a[1],0);
}

void calc1(pair<int,int> x,pair<int,int> y)
{
	if(x.second>=x.first&&y.second<=x.first)
	{
		ok=1;
		jd=make_pair(x.first-1,x.first-1);
	}
}
void calc2(pair<int,int> x,pair<int,int> y)
{
	if(x.first<=x.second&&y.first>=x.second)
	{
		ok=1;
		jd=make_pair(x.second-1,x.second-1);
	}
}

void cc1(pair<int,int> x,pair<int,int> y)
{
	if(x.second>=jd.second&&y.second<=jd.second)
		xj=min(xj,x.first-jd.first);
}
void cc2(pair<int,int> x,pair<int,int> y)
{
	if(x.first<=jd.first&&jd.first<=y.first)
		yj=min(yj,y.second-jd.second);
}

void prework()
{
	int i;
	for(i=1;i<tot;++i)
	{
		if(p[i].first==p[i+1].first)
			calc1(p[i],p[i+1]);
		else
			calc2(p[i],p[i+1]);
		if(ok) break;
	}
	
	for(i=1;i<tot;++i)
	{
		if(p[i].first==p[i+1].first)
			cc1(p[i],p[i+1]);
		else
			cc2(p[i],p[i+1]);
	}
	if(xj%2==1&&yj%2==1) printf("Second\n");
	else printf("First\n");
}

int main()
{
	init();prework();
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 100
int d[MAX_V][MAX_V];
int V, M;
void warshall_floyd() {
	rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> V >> M;
    rep(i, 0, V) rep(j, 0, V) {
        if(i == j) d[i][j] = 0;
        else d[i][j] = 1e9;
    }

    int a[M], b[M], c[M];
    rep(i, 0, M) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }

    warshall_floyd();

    int ans = 0;
    rep(i, 0, M) {
        bool flag = false;
        rep(j, 0, V) {
            if(d[j][a[i]] + c[i] == d[j][b[i]]) flag = true;
        }

        if(!flag) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define vvll vector <vll>
#define vvii vector <vii>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll mod = 1000000007;
ll pow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int h[n];
	multiset  <int> ml;
	for(int i = 0; i < n; i++){
		cin >> h[i];
		ml.insert(h[i]);
	}
	for(int i = n-1; i > 0; i--){
		ml.erase(ml.find(h[i]));
		auto it = ml.rbegin();
		if((*it-h[i]) > 1){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 5376
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// head

int t;

int main()
{
	ios::sync_with_stdio(false);
#ifdef RG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, x, y;
	cin >> n >> x >> y;
	vi cnt(n + 1, 0);

	rep(i, 1, n + 1) {
		rep(j, i+1, n + 1) {
			int d1 = j - i;
			d1 = min(d1,abs(x-i) + 1 + abs(y-j));
			cnt[d1]++;
		}
	}

	rep(i, 1, n) cout << cnt[i] << endl;

	return 0;
}

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

using LL = long long;
const LL M = 1e9 + 7;

LL combination(LL n, LL r) {
}

int main() {
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for(auto i=1; i<N; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<LL> fact{1, 1}, inv{1, 1}, finv{1, 1};
  for(LL i = fact.size(); i <= N; ++i) {
    fact.emplace_back(fact.back() * i % M);
    inv.emplace_back(inv.at(M % i) * (M - M / i) % M);
    finv.emplace_back(finv.back() * inv.back() % M);
  }
  auto combination = [&](auto n, auto r) {return (fact[n] * finv[n - r] % M) * finv[r] % M;};

  vector<LL> res(N);
  unordered_map<int, unordered_map<int, LL>> weight, size;
  function<void(int,int)> dfs = [&](auto pre, auto cur) {
    weight[pre][cur] = 1;
    for(auto nex: G[cur]) if(nex != pre) {
      dfs(cur, nex);
      (weight[pre][cur] *= weight[cur][nex]) %= M;
      (weight[pre][cur] *= combination(size[pre][cur] + size[cur][nex], size[cur][nex])) %= M;
      size[pre][cur] += size[cur][nex];
    }
    ++size[pre][cur];
  };
  dfs(-1, 0);

  function<void(int,int)> dp = [&](auto pre, auto cur) {
    vector<int> V;
    for(auto nex: G[cur]) if(nex != pre) V.emplace_back(nex);
    vector<pair<LL,LL>> W;
    W.emplace_back(weight[cur][pre], size[cur][pre]);
    for(auto nex: V) {
      auto w = W.back().first;
      auto s = W.back().second;
      (w *= weight[cur][nex]) %= M;
      (w *= combination(s + size[cur][nex], size[cur][nex])) %= M;
      s += size[cur][nex];
      W.emplace_back(w, s);
    }
    res[cur] = W.back().first;
    LL rw = 1;
    LL rs = 0;
    for(int i=V.size()-1; 0<=i; --i) {
      auto nex = V[i];
      auto w = W[i].first;
      auto s = W[i].second;
      (weight[nex][cur] = w * rw) %= M;
      (weight[nex][cur] *= combination(s + rs, rs)) %= M;
      size[nex][cur] = N - size[cur][nex];
      (rw *= weight[cur][nex]) %= M;
      (rw *= combination(rs + size[cur][nex], size[cur][nex])) %= M;
      rs += size[cur][nex];
// cout<<nex+1<<"to"<<cur+1<<":"<<weight[nex][cur]<<":"<<size[nex][cur]<<endl;
    }
    for(auto nex: V) dp(cur, nex);
  };
  weight[0][-1] = 1;
  size[0][-1] = 0;
  dp(-1, 0);

  for(auto i=0; i<N; ++i) cout << res[i] << endl;

//   for(auto i=-1; i<N; ++i) {
//     cout<<i+1<<":";
//     for(auto p: weight[i]) cout<<"    "<<p.first+1<<":"<<p.second<<":"<<size[i][p.first];
//     cout<<endl;
//   }
}


Measured memory_bytes: 99556
#include <stdio.h>

int main(void){
    int a[3];
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    if (a[0]==7){
        if (a[1]==5&&a[2]==5) {
            printf("YES");
            return 0;
        }
    }
    if (a[1]==7){
        if (a[0]==5&&a[2]==5) {
            printf("YES");
            return 0;
        }
    }
    if (a[2]==7){
        if (a[0]==5&&a[1]==5) {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

Measured memory_bytes: 1696
n, m = map(int, input().split())
h = list(map(int, input().split()))
gon = [1]*n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1]==h[b-1]:
        gon[a-1], gon[b-1] = 0, 0
    else:
        low = a if h[a-1]<h[b-1] else b
        gon[low-1] = 0
        
print(gon.count(1))

Measured memory_bytes: 20140
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool isPrime(int n)
{
	for (int i = 2; i <= sqrt(n) + 1; i++)
	{
		if (n % i == 0)
		{
			return false;
		}
	}
	return true;
}
int32_t main()
{
	Raghav();
	int n, m, sum = 0;
	cin >> n >> m;
	int a[m];
	for (auto i : a)
	{
		cin >> i;
		sum += i;
	}
	if (sum > n)
		cout << -1;
	else
		cout << n - sum;



	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using ll = long long;
using ull = unsigned long long;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ull> vul;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<ll>> vvl;
typedef vector<vector<string>> vvs;
typedef vector<vector<ull>> vvul;
typedef vector<bool> vb;
const ll md = 998244353;

ll add(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod)%mod;
}

ll mul(ll a, ll b, ll mod = md) {
    return ((a%mod) * (b%mod))%mod;
}

ll C(vl &fact, vl &invfact, ll n, ll r, ll mod = md) {
    if(r == 0) return 1;
    return mul(fact[n], mul(invfact[r], invfact[n-r], mod), mod);
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = (n >> 1);
        x = (x*x)%mod;
    }
    res %= mod;
    return res;
}

void cachefact(vector<ll>& fac, vector<ll> &ifac, ll bound, ll mod = md) {
	fac[0] = 1;
	ifac[0] = power(1, mod-2)%mod;
	for(ll i = 1; i <= bound; i++) {
		fac[i] = (fac[i-1] % mod * i % mod)%mod;
		ifac[i] = power(fac[i], mod-2)%mod;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char a;
	cin >> a;
	if(a >= 'A' && a <= 'Z') {
		cout << "A\n";
	} else {
		cout << "a\n";
	}
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

#define Hsec 3600
#define Msec 60
int main()
{
int n=0;
int hour, min, sec;
scanf("%d",&n);
hour=n/Hsec;
min=(n-hour*Hsec)/Msec;
sec=n-hour*Hsec-min*Msec;
printf("%d:%d:%d\n",hour,min,sec);
return 0;
}

Measured memory_bytes: 592
#include <vector>
#include <cassert>

template<class T>
struct potentialized_union_find {
    using value_type = T;
    using size_type = std::size_t;
private :
    size_type _size;
    std::vector<int> node;
    std::vector<value_type> potential;

public :
    potentialized_union_find (size_type n, const value_type &ie) : 
        _size(n), node(n, -1), potential(n, ie) { }

    size_type root (size_type x) {
        if (node[x] < 0) return x;
        int r = root(node[x]);
        potential[x] += potential[node[x]];
        return (node[x] = r);
    }

    value_type weight (size_type x) {
        root(x);
        return (potential[x]);
    }

    bool unite (size_type x, size_type y, value_type p) {
        p += (weight(x) - weight(y));
        if ((x = root(x)) == (y = root(y))) return false;
        if (node[x] > node[y]) {
            std::swap(x, y);
            p = -p;
        }
        node[x] += node[y];
        node[y] = x;
        potential[y] = p;
        _size--;
        return true;
    }

    bool same (size_type x, size_type y) {
        return (root(x) == root(y));
    }

    value_type diff (size_type x, size_type y) {
        assert(same(x, y));
        return (weight(y) - weight(x));
    }

    const size_type& size () const noexcept {
        return (_size);
    }

    size_type size (size_type x) {
        return (size_type(-node[root(x)]));
    }

};


#include <iostream>

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

    std::size_t n;
    int query;
    std::cin >> n >> query;

    potentialized_union_find<int> uf(n, 0);

    while (query--) {
        int type;
        std::cin >> type;
        if (type == 0) {
            std::size_t x, y;
            int p;
            std::cin >> x >> y >> p;
            uf.unite(x, y, p);
        } else {
            std::size_t x, y;
            std::cin >> x >> y;
            if (uf.same(x, y)) {
                std::cout << uf.diff(x,y) << '\n';
            } else {
                std::cout << '?' << '\n';
            }
        }
    }

    return 0;
}


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

int main()
{
	int n; cin >> n; 
	
	vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
	
	sort(a.begin(), a.end(), greater<int>());

	int a_point = 0;
	int b_point = 0;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) a_point += a[i];
		else b_point += a[i];
	}

	cout << a_point - b_point << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
    T,P,R=map(int,raw_input().split())
    if T==P==R==0:break
    CRRCT=dict(zip(range(1,T+1),[0]*T))
    PNLTY=dict(zip(range(1,T+1),[0]*T))
    WRNG=dict(zip(range(1,T+1),[dict(zip(range(1,P+1),[0]*P)) for i in range(T)]))
    for i in range(R):
        tID,pID,time,message=raw_input().split()
        tID,pID,time=int(tID),int(pID),int(time)
        if message=="CORRECT":
            CRRCT[tID]+=1
            PNLTY[tID]+=WRNG[tID][pID]*1200+time
        elif message=="WRONG":
            WRNG[tID][pID]+=1
    L=[(-CRRCT[team],PNLTY[team],team) for team in CRRCT]
    L.sort()
    for c,p,t in L:
        print t,-c,p

Measured memory_bytes: 4420
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	
	
	public static void main(String[] args) {
	int h=sc.nextInt();
	int a=sc.nextInt();
	if(h%a==0) {
	p(h/a);
	}else {
	p(h/a+1);
	}
 }
}


Measured memory_bytes: 22740
function main(input) {
   input = input.trim();
  const a = input.split("\n");
  const b = a[0].split(" ").map(Number);
  const c = a[1].split(" ").map(Number);
	console.log((b[0]-c[0])*(b[1]-c[1]));
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30476
/*
 * FileName:     set_difference
 * CreatedDate:  2020-06-09 16:18:09 +0900
 * LastModified: 2020-06-09 16:27:01 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#define ultra 2e9
int main(void){
    int n;scanf("%d",&n);
    int *a = malloc((n+1)*sizeof(int));
    for(int i=0;i<n;i++)scanf("%d",a+i);
    a[n]=ultra;
    int m;scanf("%d",&m);
    int *b = malloc((m+1)*sizeof(int));
    for(int i=0;i<m;i++)scanf("%d",b+i);
    b[m]=ultra;
    int ia=0,ib=0;
    while(ia<n||ib<m){
        if(a[ia]<b[ib]){
            printf("%d\n",a[ia]);
            ia++;
        }
        else if(a[ia]>b[ib]){
//            printf("%d\n",b[ib]);
            ib++;
        }
        else{
            ia++;
            ib++;
        }
    }
    free(a);
    free(b);
    return 0;
}



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

using namespace std;

int main()
{
  int N; cin >> N;
  int sum;
  for (int i = 0; 4 * i <= N; ++i) {
    sum = 4 * i;
    while (sum <= N) {
      if (sum == N) {
        cout << "Yes";
        return 0;
      }
      sum += 7;
    }
  }

  cout << "No";
}

Measured memory_bytes: 256
#include<stdio.h>

#define INF 999999
#define NIL -1
#define WHITE 0
#define BLACK 2


int n,G[100][100];

int prim(){
  int a,v, i,S=0;
  int d[n],pi[n],color[n];
  int mincost;

 
 for(a=0; a<n; a++){
    d[a] = INF;
    pi[a] = NIL;
    color[a] = WHITE;
  }
  d[0] = 0;
  while(1){
    mincost = INF;

    for(i=0; i<n; i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        //      printf("%d",mincost);
        a = i;
      }
    }

    if(mincost == INF){
     break;
    }

    color[a] = BLACK;

    for(v=0;v<n;v++){
      if(color[v] != BLACK && G[a][v] < d[v] && G[a][v] != -1){
        pi[v] = a;
        d[v] = G[a][v];
      }
    }
  }

  for(i=0;i<n;i++){
    // printf("%d\n",d[i]);
    if(d[i] != INF){
      S += d[i];
      //  printf("%d\n", S);
    }
  }
    return S;

}

int main(){

  int i, j,x;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
    }
  }

  x = prim();

  printf("%d\n",x);

  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    unsigned long long N;
    cin >> N;
    
    int B = (int)(sqrt(N));
    for (int i = B; i >= 1; i--){
        if (N % i == 0){
            cout << i + N/i - 2 << endl;
            return 0;
        }
    }
    return 0;    
}


Measured memory_bytes: 256
n,m=map(int,input().split())
A=[[] for i in range(n+1)]
I=[]
for i in range(m):
    p,y=map(int,input().split())
    A[p].append([i,y])

for i in range(n+1):A[i].sort(key=lambda x: x[1])

for i in range(n+1):
    if A[i] != []:
        for j in range(len(A[i])):
            I.append([A[i][j][0] ,str(i).zfill(6) ,str(j+1).zfill(6)])
I.sort(key=lambda x: x[0])
for i in range(len(I)):print(I[i][1],I[i][2],sep="")

Measured memory_bytes: 53568
#include <iostream>
#include <unordered_map>
#define FOR(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

unordered_map<char, int> term = {{'0', 0}, {'1', 1}, {'2', 2}};
string::iterator it;

int formula() {
  if(*it == '(') {
    it++;
    int f = formula();
    if(*it == '*') ++it, f = min(f, formula());
    if(*it == '+') ++it, f = max(f, formula());
    return ++it, f;
  }
  else if(*it == '-') return ++it, 2 - formula();
  else return term[*(it++)];
  return 0;
}

int main() {
  string s;
  while(cin >> s, s[0] != '.') {
    int cnt = 0;
    REP(i, 3) REP(j, 3) REP(k, 3)
      it = s.begin(),
      term['P'] = i, term['Q'] = j, term['R'] = k,
      cnt += (formula() == 2? 1: 0);
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%n==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
}

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

using namespace std;


int main(){
  int n;
  cin >> n;
  int count = 0, min = 200001;
  for (int i = 0; i < n; i++){
    int k;
    cin >> k;
    if (k < min){
      count++;
      min = k;
    }
  }
  cout << count << "\n";
  

}

Measured memory_bytes: 384
import sys, re
import math
import numpy as np
from decimal import Decimal
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.maxsize = 10 ** 15
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

a,b,c,d = MAP()

a1 = a*c
a2 = a*d
a3 = b*c
a4 = b*d

if a1 >= a2:
    b1 = a1
else:
    b1 = a2

if a3 >= a4:
    b2 = a3
else:
    b2 = a4

if b1 >= b2:
    print(b1)
else:
    print(b2)

Measured memory_bytes: 27296
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

class TrieNode {
public:
	TrieNode *ch[2] = { NULL, };
};

class Trie {
public:
	TrieNode *head;
	Trie() {
		head = new TrieNode();
	}
	void add(char *s) {
		int n = strlen(s);
		TrieNode *cur = head;
		for (int i = 0; i < n; i++) {
			if (cur->ch[s[i] - '0'] == NULL)cur->ch[s[i] - '0'] = new TrieNode;
			cur = cur->ch[s[i] - '0'];
		}
	}
};

char str[100005];
LL f(LL x) {
	LL ret = 1;
	while (!(x & 1)) {
		ret <<= 1;
		x >>= 1;
	}
	return ret;
}

LL dfs(TrieNode *u, LL l, LL depth = 0) {
	if (u == NULL)return 0;
	LL ret = 0;
	int cnt = 0;
	if (u->ch[0] != 0)cnt++;
	if (u->ch[1] != 0)cnt++;
	ret ^= dfs(u->ch[0], l, depth + 1);
	ret ^= dfs(u->ch[1], l , depth +1);
	if (cnt == 1) {
		ret ^= f(l - depth);
	}
	return ret;
}

LL g = 0;

int main() {
	int n;
	LL l;
	scanf("%d%lld", &n, &l);
	Trie trie;
	REP(i, n) {
		scanf("%s", str);
		trie.add(str);
	}
	LL ret = dfs(trie.head, l);
	if (ret == 0)printf("Bob\n");
	else printf("Alice\n");
	return 0;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const int N = 1e5 + 5;
vi g[N];
int dp[N];
bool vis[N];
int ans = 0;
void dfs(int node){
   vis[node] = true;
   for(auto v : g[node]){
      if(!vis[v]){
         dfs(v);
      }
      dp[node] = max(dp[node] , dp[v] + 1);
   }
}
int32_t main(){
   fast;
   int n,m;
   cin >> n >> m;
   f(i,0,m){
      int u,v;
      cin >> u >> v;
      g[u].pb(v);
   }
   f(i,1,n+1) if(!vis[i]){
      dfs(i);
   }
   int ans = 0;
   f(i,1,n+1) ans = max(ans , dp[i]);
   cout << ans << "\n";
}

Measured memory_bytes: 8704
#include <stdio.h>
int main () {
   int N;
   int A[101] = {0};
   int B[101] = {0};
   int i;
   int ans = 0;

   //入力
   scanf ("%d", &N);

   for (i = 0; i < N - 1; i++) {
     scanf ("%d", &B[i]);
   }

   //計算
   A[0] = B[0];
   A[N - 1] = B[N - 2];

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

   for (i = 0;i < N; i++) {
     ans += A[i];
   }

   printf ("%d\n", ans);

   return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();

            int[][] map = new int[10][10];
            int[][] a = new int[h][w];

            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    map[i][j] = in.nextInt();
                }
            }

            //ワーシャルフロイド法
            for (int k = 0; k < 10; k++) {
                for (int i = 0; i < 10; i++) {
                    for (int j = 0; j < 10; j++) {
                        map[i][j] = Math.min(map[i][j], map[i][k] + map[k][j]);
                    }
                }
            }

            int ans = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    int next = in.nextInt();
                    if (next != -1) {
                        ans += map[next][1];
                    }
                }
            }

            out.print(ans);


        }

    }
}



Measured memory_bytes: 49496
import java.util.Scanner;

public class Main {

    /*
     * 行列の積
     * 
     * n×m の行列 A と m×l の行列 B を入力し、それらの積である n×l の行列 C を出力するプログラムを作成してください。行列 C
     * の各要素 cij は次の式で得られます：
     * 
     * cij=?k=1maikbkj ここで、A、B、C の各要素をそれぞれ aij、bij、cij とします。
     * 
     * Input １行目に n、m、l が空白区切りで与えられます。
     * 
     * 続く行に n×m の行列 A と m×l の行列 B が与えられます。
     * 
     * Output n×l の行列 C の要素 cij を出力してください。各行の隣り合う要素を１つの空白で区切ってください。
     * 
     * Constraints 1?n,m,l?100 0?aij,bij?10000
     */
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();

        int[][] array1 = new int[n][m];
        int[][] array2 = new int[m][l];

        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1[i].length; j++) {
                array1[i][j] = sc.nextInt();
            }
        }

        for (int i = 0; i < array2.length; i++) {
            for (int j = 0; j < array2[i].length; j++) {
                array2[i][j] = sc.nextInt();
            }
        }
        
        sc.close();
        long[][] array3 = new long[n][l];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for (int j2 = 0; j2 < m; j2++) {
                    array3[i][j] += array1[i][j2]*array2[j2][j];
                }
            }
        }
        
        for (int i = 0; i < array3.length; i++) {
            for (int j = 0; j < array3[i].length; j++) {
                System.out.print(array3[i][j]);
                if(j != l -1){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }

}

Measured memory_bytes: 45256
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

typedef pair<int,int> pii;
typedef long long int ll;
typedef long double ld;

const int DMAX = 1e5+10;

inline int two(int n) { return 1 << n; }
inline int test(int n, int pos) { return (bool) (n & two(pos)); }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }

vector <int> V[DMAX];

bool uz[10];

char s[DMAX];
char t[DMAX];

int n;

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

    int i,j,lg;

    cin>>lg;
    cin>>s;
    cin>>t;
    for(i=0;i<lg;i++)
        cout<<s[i]<<t[i];
    cout<<'\n';

    return 0;
}


Measured memory_bytes: 2560
import sys
input = sys.stdin.readline
SS = list(input())

if 'N' in SS:
    if not 'S' in SS:
        print('No')
        exit()
if 'S' in SS:
    if not 'N' in SS:
        print('No')
        exit()
if 'W' in SS:
    if not 'E' in SS:
        print('No')
        exit()
if 'E' in SS:
    if not 'W' in SS:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3064
// 166 D

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath> 
using namespace std;

int main(){
    long long int x;
    cin >> x;
    for(int i= -118; i<=119; i++){
        for(int j= -119; j<=118; j++){
            if(pow(i, 5) - pow(j, 5) == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4020
import java.util.Scanner;

class Main {

	int x,n = 0,a,b,c,d,e;
	public void pr() {

		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();

		if(n >= 3 && n <= 10000) {

			for(x = 3; x <= n;x++) {

				a = x % 3;

				b = x % 10;

				c = x / 10;

				d = x / 100;

				e = x / 1000;

				if(a == 0 || b == 3 || c == 3 || c % 10 == 3 || d == 3 || d % 10 == 3 || e == 3 || e % 10 == 3) {

					System.out.print(" " + x);

				}

			}

		}

		System.out.println();

	}

	public static void main(String[] args) {

		new Main().pr();

	}

}

Measured memory_bytes: 28664
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef unsigned long long ull;

struct book{
    int c;
    vector<int> a;
};

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, x, a;
    cin>>n>>m>>x;
    vector<book> books(n);
    vector<int> know(m,0);
    for(int i=0;i<n;i++){
        cin>>books[i].c;
        for(int j=0;j<m;j++){
            cin>>a;
            books[i].a.push_back(a);
            know[j]+=books[i].a[j];
        }
    }

    for(int i=0;i<m;i++){
        if(know[i]<x){
            cout<<-1;
            return 0;
        }
    }

    int ans=INT_MAX;

	int combinations=pow(2,n);
	for(int i=0;i<combinations;i++){
        int cost=0;
		int number=i;
		vector<book> k;
		for(int e=0;e<n;e++){
			if(number&(1<<e)){
				k.push_back(books.at(e));
                cost+=books.at(e).c;
			}
		}

        bool flag=true;
        vector<int> kn(m,0);
        for(auto x:k){
            for(int y=0;y<m;y++){
                kn[y]+=x.a[y];
            }
        }
        for(int y=0;y<m;y++){
            if(kn[y]<x)flag=false;
        }

        if(flag)ans=min(ans,cost);
	}
	cout<<ans;
    return 0;
}

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

using namespace std;

using ll = long long;
const ll INF = 1e18L + 5;

vector<ll> pre; // preprocessing
// pre[mask] - score of group 'mask'
vector<ll> dp;


void rec(int i, const vector<int>& not_taken, ll score_so_far, int mask, int group) {
    //cout<<"i = "<<i<<", score = "<<score_so_far<<", mask = "<<mask<<", group = "<<group<<endl;

    if(i == (int) not_taken.size()) {
        dp[mask] = max(dp[mask], score_so_far + pre[group]);
        //cout<<"i = "<<i<<", mask = "<<mask<<", dp[mask] = "<<dp[mask]<<endl;
        //cout<<endl<<endl;

        return;
    }

    rec(i + 1, not_taken, score_so_far, mask, group);
    rec(i + 1, not_taken, score_so_far, mask ^ (1 << not_taken[i]),
        group ^ (1 << not_taken[i]));
}



// O(2^n * n^2 + 3^n)

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<ll>> in(n, vector<ll>(n));

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            scanf("%lld", &in[i][j]);
        }
    }
    pre.resize(1 << n);

    // O(2^n * n^2)
    for(int mask = 0; mask < (1 << n); ++mask) {
        for(int i = 0; i < n; ++i) {
            if(mask & (1 << i)) {
                for(int j = i + 1; j < n; ++j) {
                    if(mask & (1 << j)) {
                        pre[mask] += in[i][j];
                    }
                }
            }
        }
    }

//    cout<<endl<<endl;
//    for(int mask = 0; mask < (1 << n); ++mask){
//        cout<<pre[mask]<<" ";
//    }
//    cout<<endl;


    // dp[mask] - best total score if we grouped rabbits from 'mask' already
    dp.resize(1 << n, -INF);
    dp[0] = 0;

    // O(2^n * n + 3^n)
    for(int mask = 0; mask < (1 << n); ++mask) {
        vector<int> not_taken;
        for(int i = 0; i < n; ++i) {
            if(!(mask & (1 << i))) {
                not_taken.push_back(i);
            }
        }
        rec(0, not_taken, dp[mask], mask, 0);

    }
    printf("%lld\n", dp[(1<<n)-1]);
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int n, u, v;
vector<Int> G[100001];
Int d[100001];
bool visited[100001];

void dfs(Int x, Int depth) {
    if (visited[x]) return;
    visited[x] = true;
    d[x] = depth;
    for (Int i = 0; i < (Int)G[x].size(); i++) {
        Int to = G[x][i];
        if (not visited[to]) {
            dfs(to, depth + 1);
        }
    }
}

Int deep;

void dfs2(Int x) {
    deep = max(deep, d[x]);
    for (Int i = 0; i < (Int)G[x].size(); i++) {
        if (d[x] < d[G[x][i]]) {
            dfs2(G[x][i]);
        }
    }
}

int main() {
    cin >> n >> u >> v;
    u--, v--;
    for (Int i = 0; i < n - 1; i++) {
        Int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(v, 0);
    Int safe = d[u] - (d[u] - 1) / 2;
    Int cur = u;
    while (safe < d[cur]) {
        for (Int i = 0; i < (Int)G[cur].size(); i++) {
            Int to = G[cur][i];
            if (d[to] < d[cur]) {
                cur = to;
                break;
            }
        }
    }
    //cout << cur << " " << d[cur] << safe << endl;
    dfs2(cur);
    dump(deep - 1);
    return 0;
}

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

int main() {
  long n,sum_a=0,sum_ans=0;
  cin >> n;
  vector<long> a(n);
  vector<long> ans(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
    sum_a+=a[i];
  }

  ans[0]=0;
  for(int i=2;i<n*2;i+=2) {
    ans[i%n]=ans[(i-2)%n]+(a[(i-1)%n]-a[(i-2)%n])*2;
    sum_ans+=ans[i%n];
  }

  for(int i=0;i<n;i++) {
    ans[i]+=(sum_a-sum_ans)/n;
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 2944
/*ex3_2
    takafumi_ueki*/
#include <stdio.h>
int main(void){
    int x;
    scanf("%d",&x);
    //xを10割った余り、つまり1の位が何かによって条件分岐
    //”||”は、またはという意味
    if((x%10 == 2)||(x%10 == 4)||(x%10 == 5)||(x%10 == 7)||(x%10 == 9)){
        printf("hon\n");
    }
    if((x%10 == 0)||(x%10 == 1)||(x%10 == 6)||(x%10 == 8)){
        printf("pon\n");
    }
    if(x%10 == 3){
        printf("bon\n");
    }
    return 0;
}


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

using namespace std;
int main(int argc, char** argv){	
  string S;
  cin >> S;
  int len = S.length();
  if(len%2 != 0){
    cout << "No" << endl;
  }
  else{
    string hitachi;
    for(int i=0; i<len/2; i++){
      hitachi += "hi";
    }
    if(hitachi==S)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


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

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a<c&&b<c){
    cout<< a*b/2 <<endl;
  } else if (a<b&&c<b) {
    cout<< a*c/2 <<endl;
  } else {
    cout<< b*c/2 <<endl;
  }
}

Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    let i:Vec<i32> = read_vec();
    if i[0] > i[1] {
        println!("a > b");
    } else if i[0] == i[1] {
        println!("a == b");
    } else if i[0] < i[1] {
        println!("a < b");
    }
}


Measured memory_bytes: 5028