akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 205
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//------------------------------------
ll n,m,r;
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>m>>r;
	ll cst[n+1][n+1];
	vector<ll> v;
	for(i=1;i<=r;i++){
		cin>>k;
		v.ps(k);
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cst[i][j]=2e18;
		}
	}
	ll a,b,c;
	for(i=1;i<=m;i++){
		cin>>a>>b>>c;
		cst[a][b]=c;
		cst[b][a]=c;
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			for(k=1;k<=n;k++){
				cst[j][k]=min(cst[j][k],cst[j][i]+cst[i][k]);
			}
		}
	}
	ll mn=2e18; sort(all(v));
	do{
		ll c=0;
		for(i=1;i<r;i++){
			c+=cst[v[i-1]][v[i]];
		}
		mn=min(mn,c);
	}while(next_permutation(all(v)));
	cout<<mn;
	return 0;
}

Measured memory_bytes: 640
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		String[] line =n.split(" ");


		Deque<Integer> stack = new ArrayDeque<Integer>();
		for(int i=0; i<line.length; i++) {
			int a=0,b=0;
			switch(line[i]) {
			case "+":
				a = stack.pop();
				b = stack.pop();
				stack.push(b+a);
				break;
			case "-":
				a = stack.pop();
				b = stack.pop();
				stack.push(b-a);
				break;
			case "/":
				a = stack.pop();
				b = stack.pop();
				stack.push(b/a);
				break;
			case "*":
				a = stack.pop();
				b = stack.pop();
				stack.push(b*a);
				break;
			default:
				a = Integer.parseInt(line[i]);
				stack.push(a);
				break; 
			}
		}
        int ans = stack.pop();
		System.out.println(ans);
	}
}




Measured memory_bytes: 26360
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=200005;

int main()
{
    IO;
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n=s.size();
    set<string> st;
    for(int i=0;i<n;++i){
        string tmp;int cnt=0;
        for(int j=i;j<n&&cnt<5;++j,++cnt){
            tmp.push_back(s[j]);
            st.insert(tmp);
        }
    }
    for(auto i:st){
        --k;
        if(!k)re cout<<i,0;
    }
    re 0;
}

Measured memory_bytes: 1664
o = input()
e = input()
for i in range(max(len(o), len(e))):
    # print(len(o), len(e), i)
    if len(o) > i:
         print(o[i], end="", sep="")
    if len(e) > i:
         print(e[i], end="", sep="")
print()

Measured memory_bytes: 62252
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() }
    val mx = t.max()!!
    val rem = t.sum() - mx
    println(if (mx < rem) "Yes" else "No")
}

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

void solve(long long X){
	if (X == 3 || X == 5 || X == 7) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

}

int main(){
	long long X;
	scanf("%lld",&X);
	solve(X);
	return 0;
}


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

int main(int argc, const char * argv[]) {
    char str[5];
    
    scanf("%s", str);
    str[4] = '\0';
    if (str[0] == str[1] || str[1] == str[2] || str[2] == str[3]){
        printf("Bad\n");
        return 0;
    }
    printf("Good\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	int n,k,s;
	cin>>n>>k>>s;
	for(int i=1;i<=n;i++){
		if(k>0){
			cout<<s<<" ";
			k--;
		}else{
			cout<<max(100000,s-1)<<" ";
		}
	}
}

Measured memory_bytes: 1280
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	vector<int>a(100), b, c;
	int n;
	cin >> n;
	int sum;
	map<int, int>mp;
	iota(all(a), 1);
	b = c = a;
	for (auto aa : a)for (auto bb : b)for (auto cc : c) {
		sum = aa * aa + bb * bb + cc * cc + aa * bb + aa * cc + bb * cc;
		mp[sum]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << mp[i] << endl;
	}
	//for (auto m : mp)cout << m.first << ":" << m.second << endl;
}


Measured memory_bytes: 5348
#include <iostream>

using namespace std;

int main(){

  int a,b,c,x,count;

  cin >> a >> b >> c >>x;

  for(int i =0; i<= a; i++){
    for(int j = 0; j<= b; j++){
      for(int k = 0; k <= c; k++){
      if( 500*i + 100*j + 50*k == x) count ++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


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

int main(){
    double a,b,c,deg,S;
    scanf("%lf%lf%lf",&a,&b,&deg);
    S = (0.5) * a * b * sin(M_PI * deg / 180);
    c = sqrt(a * a + b * b - 2 * a * b * cos(M_PI * deg / 180));
    printf("%.8lf\n%.8lf\n%.8lf\n",S,a + b + c,2 * S / a);

    return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
using P = std::pair<int, ll>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

P ve[262145];
ll dp[257][100001],ans;
int s[2],m;

void solve(int i, int w, ll v){
	if(w<0){
		return;
	}
	if(i<=m){
		ans = std::max(ans,v+dp[i][w]);
		// std::cout << "*" << ans << std::endl;
		return;
	}
	solve(i/2,w,v);
	solve(i/2,w-ve[i].first,v+ve[i].second);
}

int main(void){
	int n,i,j,k,v,q,l;
	std::cin >> n;
	m = std::min(n,255);
	for(i=1; i<=n; ++i){
		std::cin >> ve[i].second >> ve[i].first;
	}
	for(i=1; i<=m; ++i){
		for(j=0; j<=100000; ++j){
			dp[i][j] = std::max(dp[i][j],dp[i/2][j]);
			if(j+ve[i].first<=100000){
				dp[i][j+ve[i].first] = std::max(dp[i][j+ve[i].first],dp[i/2][j]+ve[i].second);
			}
		}
	}
	std::cin >> q;
	while(q--){
		std::cin >> v >> l;
		ans = 0ll;
		solve(v,l,0ll);
		std::cout << ans << std::endl;
	}
	return 0;
}


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

int main(){
    int n, a = 0, b = 0;
    string t, h;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> t >> h;
        if(t > h)a += 3;
        else if(t < h)b += 3;
        else if(t == h){
            a++; b++;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3220
#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;
int binarySearch(int A[],int key,int n){
  int left=0;
  int right=n;
  while(left<right){
    int mid=(left+right)/2;
    if(key==A[mid])return 1;
    if(key<A[mid])right=mid;
    else if(key>A[mid])
      left=mid+1;
  }
  return 0;
}
  

int main(void){
  int n,q;
  cin>>n;
  int S[n];
  for(int i=0;i<n;++i){
    cin>>S[i];
  }

  cin>>q;
  
  int count=0;
  int key;
  for(int i=0;i<q;i++){
    cin>>key;
    if(binarySearch(S,key,n))count++;
  }

  cout<<count<<endl;

  return 0;
}



Measured memory_bytes: 3424
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;
#include <bits/stdc++.h>

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

    int N, K;
    string S;

    cin >> N >> S >> K;

    char S_K;
    S_K = S[K-1];

    for(int i = 0; i < S.length(); i++){
        if(S[i] != S_K){
            S[i] = '*';
        }
    }

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(range(n))
for i in range(n):
  x[i] = input()
c_0 = x.count("AC")
c_1 = x.count("WA")
c_2 = x.count("TLE")
c_3 = x.count("RE")
print("AC x {}".format(c_0))
print("WA x {}".format(c_1))
print("TLE x {}".format(c_2))
print("RE x {}".format(c_3))

Measured memory_bytes: 16036
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto BS = readln.split.to!(int[]);

    int r;
    foreach (i; 0..N) {
        if (i == 0) {
            r += BS[i];
        } else if (i == N-1) {
            r += BS[i-1];
        } else {
            r += min(BS[i], BS[i-1]);
        }
    }
    writeln(r);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
ll h,n;
cin>>h>>n;
cout<<Ceil(h,n);

}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////

int main(){
    string s,t;cin>>s>>t;
    int len=s.size();
    
    char ss[2*len+1];
    rep(i,0,len-1)ss[i]=s[i];
    rep(i,len,2*len-1)ss[i]=s[i-len];
    
    rep(i,0,len-1){
        bool flag=true;
        rep(j,0,len-1){
            if(ss[i+j]!=t[j])flag=false;
        }
        if(flag){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

public class Main {

	static void solve (Scanner in, PrintWriter out, Methods ms) {

		while (true) {

			int h = in.nextInt(), w = in.nextInt();
			if (h == 0 && w == 0) return;

			//Input
			char[][] map = new char[h + 2][w + 2];
			for (int i = 0; i < h + 2; i++) {
				Arrays.fill(map[i], '-');
			}
			for (int i = 0; i < h; i++) {
				String temp = in.next();
				for (int j = 0; j < w; j++) {
					map[i + 1][j + 1] = temp.charAt(j);
				}
			}

			//Breadth First Search
			boolean[][] memo = new boolean[h + 2][w + 2];
			for (int i = 0; i < h + 2; i++) {
				Arrays.fill(memo[i], true);
			}
			for (int i = 1; i < h + 1; i++) {
				for (int j = 1; j < w + 1; j++) {
					memo[i][j] = false;
				}
			}
			
			
			int ans = 0;
			
			for (int i = 1; i < h + 1; i++) {
				for (int j = 1; j < w + 1; j++) {
					
					//探索開始
					if (memo[i][j] == false) {
						
						char fruit = map[i][j];
						ArrayDeque<Point> dq = new ArrayDeque<>();
						dq.addLast(new Point(j, i));
						memo[i][j] = true;
						while (dq.isEmpty() == false) {
							
							Point p = dq.removeFirst();
							for (int k = 0; k < 4; k++) {
								int x = p.x + dx[k];
								int y = p.y + dy[k];
								if (map[y][x] == fruit && memo[y][x] == false) {
									dq.addLast(new Point(x, y));
									memo[y][x] = true;
								}
							}
							
						}
						
						
						
						ans++;
						
					}
					
				}
			}
			
			out.println(ans);
			
		}

	}

	static class Point {
		int x, y;
		Point (int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

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



	public static void printMap (char[][] a) {
		System.out.println();
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[0].length; j++) {
				System.out.print(a[i][j]);
			}
			System.out.println();
		}
	}

	public static void main (String[] args) {

		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		Methods ms = new Methods();
		solve(in, out, ms);
		in.close();
		out.close();

	}

	static class Methods {

		public void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}

		public int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}

		public int min (int... ar) {Arrays.sort(ar); return ar[0];}

		public long gcd (long a, long b) {return b > 0 ? gcd(b,a%b) : a;}

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

		public long factorial (int i) {
			if (i == 1) return 1;
			else return i * factorial(i-1);
		}

		public int manhat (int x1, int y1, int x2, int y2) {
			return Math.abs(x1 - x2) + Math.abs(y1 - y2);
		}

		public double euclid (double x1, double y1, double x2, double y2) {
			return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
		}

		public boolean isPrime (int n) {
			if (n == 2) return true;
			if (n < 2 || n % 2 == 0) return false;
			for (int i = 3; i <= Math.sqrt(n); i += 2) if(n % i == 0) return false;
			return true;
		}

	}

}


Measured memory_bytes: 30512
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [W, a_left, b_left] = string_to_int(inputs[0])
    a_right = a_left + W
    b_right = b_left + W

    if a_right < b_left:
        return b_left - a_right
    elif a_left > b_right:
        return a_left - b_right
    return 0


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    long long ans = 0;
    
    if (a >= k) {
        cout << k << endl;
        return 0;
    }
    else {
        if (a + b >= k) {
            cout << a << endl;
            return 0;
        }
        else {
            cout << a-(k-a-b) << endl;
            return 0;
        }
    }
}



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

#define int long long

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

int x;

signed main() {
    cin >> x;
    if (x % 11 == 0) {
        cout << x / 11 * 2 << endl;
    } else if (x % 11 <= 6) {
        cout << x / 11 * 2 + 1 << endl;
    } else {
        cout << x / 11 * 2 + 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int, input().split())

A_ang = 30*H+30*M/60
B_ang = M*360/60

#print(A_ang, B_ang)
ang = A_ang - B_ang
out = float(A**2+B**2)-float(2*A*B*math.cos(math.radians(ang)))
print(math.sqrt(out))

Measured memory_bytes: 9504
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int tage = 10;

int main(){
	int n; cin >> n;
	cin.ignore();
	vector<bitset<tage>> f;
	for( int i = 0; i < n; ++i ){
		string s; getline(cin, s);
		s.erase( remove( s.begin(), s.end(), ' ' ), s.end() );
		f.emplace_back(s);
	}
	int p[n][tage+1];
	for( int i = 0; i < n; ++i ){
		for( int t = 0; t <= tage; ++t ){
			cin >> p[i][t];
		}
	}
	int ans = -inf;
	for( int cond = 1; cond < (1<<10); ++cond ){
		int sum = 0;
		for( int i = 0; i < n; ++i ){
			auto tmp = f[i];
			tmp &= cond;
			sum += p[i][tmp.count()];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3


def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def main():
    n, t = get_ints()
    p = []
    for _ in range(n):
        p.append(get_ints())
    p = [_ for _ in p if _[1] <= t]
    p = [_[0] for _ in p]
    ans = min(p) if len(p) else 'TLE'
    print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 38288
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto nq = readints();
    int n = nq[0], q = nq[1];

    auto uf = new UnionFind(n);
    for (int i = 0; i < q; i++) {
        auto xs = readints();
        int com = xs[0], x = xs[1], y = xs[2];
        switch (com) {
        case 0:
            uf.unite(x, y);
            break;

        case 1:
            writeln(uf.isSame(x, y) ? 1 : 0);
            break;
        default:
        }
    }
}

class UnionFind {
    private int[] _data;

    this(int n) {
        _data = new int[](n + 1);
        _data[] = -1;
    }

    int root(int a) {
        if (_data[a] < 0)
            return a;
        return _data[a] = root(_data[a]);
    }

    bool unite(int a, int b) {
        int rootA = root(a);
        int rootB = root(b);
        if (rootA == rootB)
            return false;
        _data[rootA] += _data[rootB];
        _data[rootB] = rootA;
        return true;
    }

    bool isSame(int a, int b) {
        return root(a) == root(b);
    }

    int size(int a) {
        return -_data[root(a)];
    }
}

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

int main(){
	int a;
	string s;
	cin>>a>>s;

	int ans=0;
	for (int i = 1; i < a; i++){
		int cut=0;
		
		for (char c = 'a'; c <= 'z' ; c++){
			bool left=false,right=false;
			
			for (int j = 0; j < i; j++){
				if(s[j]==c)
					left=true;
			}

			for (int j = i; j < a; j++){
				if(s[j]==c)
					right=true;
			}	

			if(left&&right)
				cut++;
		}
		if(ans<cut)
			ans=cut;
	}

	cout<<ans<<endl;

}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    A, B, C = map(int,input().split())
    K = int(input())
    count = 0
    while A >= B:
        B = B * 2
        count += 1
    while B >= C:
        C = C * 2
        count += 1
    if count <= K:
        print("Yes")
    else:
        print("No")
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9132
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  string ans = "No";
  while(n){
    if (n % 10 == 7) ans = "Yes";
    n /= 10; 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  bool flag=false;
  for(int i=0;i<9;i++){
    if(N%(i+1)==0){
      if(N/(i+1)<=9){
        cout<<"Yes"<<endl;
        flag=true;
        break;
      }
    }
  }
  if(flag==false){
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    string S;
    cin >> S;
    int N = S.size();
    REP(int,i,0,N){
        if ( S.at(i) != S.at(N - i - 1) ){
            cout << "No" << endl;
            return 0;
        }
        else continue;
    }
    REP(int,i,0,(N-1)/2){
        if ( S.at(i) != S.at((N-1)/2-i-1)){
            cout << "No" << endl;
            return 0;
        }
        else continue;
    }
    REP(int,i,(N+2)/2-1,N){
        if ( S.at(i) != S.at(N-i-1)){
            cout << "No" << endl;
            return 0;
        }
        else continue;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll bit[200001]; int n;
ll mx[200001];
ll max(int i){
	ll s=0;
	while(i>0){
		s=max(s, bit[i]);
		i-=(i&(-i));
	}
	return s;
}
void update(int i, ll x){
	while(i<=n){
		bit[i]=max(bit[i], x);
		i+=(i&(-i));
	}
}
int main()
{
	cin>>n;
	int h[200000];
	for(int i=0; i<n; i++) cin>>h[i];
	for(int i=0; i<n; i++){
		ll a;
		cin>>a;
		ll m=max(h[i]-1);
		if(mx[h[i]]<a+m){
			mx[h[i]]=a+m;
			update(h[i], mx[h[i]]);
		}
	}
	cout<<max(n)<<endl;
	return 0;
}

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

string N; int K;

int dp[1000][2][10];

signed main(){
	cin>>N>>K;
	dp[0][0][0]=1;
	int l=N.size();
	for(int i=0;i<l;i++){
		for(int smaller=0;smaller<2;smaller++){
			//smallerが1ならi桁目まではNと一緒
			//0ならNよりも小さいことが確定している
			for(int j=0;j<=K;j++){
				for(int k=0; k<=(smaller ? 9 : N[i]-'0'); k++){
					dp[i+1][smaller or (k<(N[i]-'0'))][k==0 ? j : j+1]+=dp[i][smaller][j];
				}
			}
		}
	}

	cout<<dp[l][0][K]+dp[l][1][K]<<endl;
}

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

typedef long long ll;

int main () {
	int X, Y;
	cin >> X >> Y;
	if (Y%2) {
		cout << "No" << endl;
		return 0;
	}
	Y /= 2;
	if (Y-X>=0 && 2*X-Y>=0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RREP(i,n) for (int i=n-1;i>=0;i--)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (ll)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    string s,t;
    int a,b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s) a--;
    else b--;
    cout << a << ' ' << b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

class UnionFind{
private:
    using uint = std::uint_fast64_t;
    std::vector<uint> par;
    std::vector<uint> sizes;
public:
    UnionFind() = delete;
    UnionFind(uint size) : par(size), sizes(size, 1){
        for(uint i = 0; i < size; ++i) par[i] = i;
    }
    uint find(uint x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    bool unite(uint x, uint y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        
        if(sizes[x] < sizes[y]) std::swap(x, y);
        if(sizes[x] == sizes[y] && x > y) std::swap(x, y);
        sizes[x] += sizes[y];
        sizes[y] = 0;
        par[y] = x;
        return true;
    }
    bool isSame(uint x, uint y ){ return find(par[x]) == find(par[y]);}
    uint getSize(uint x){return sizes[x];}
}; 

int main(){
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);

    int x, y, z;
    rep(i, M){
        cin >> x >> y >> z; x--, y--;
        uf.unite(x, y);
    }

    int ans = 0;
    rep(i ,N){
        if(uf.getSize(i))  ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=5005,mod=1e9+7,inv2=(mod+1)/2;
int f[N][N],s2[N][N],pw[N],ipw[N],n,m,ans;

int power(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mod)
		if(p&1) res=(ll)res*x%mod;
	return res;
}
int mul(int x,int y){
	return (ll)x*y%mod;
}
void add(int &x,int y){
	x=(x+y>=mod?x+y-mod:x+y);
}
int pw2(int x){
	return x>=0?pw[x]:ipw[-x];
}

int main(){
	read(n),read(m);
	swap(n,m);
	pw[0]=ipw[0]=1;
	rep(i,1,5000){
		pw[i]=mul(pw[i-1],2);
		ipw[i]=mul(ipw[i-1],inv2);
	}
	rep(i,1,n){
		f[0][i]=1;
		s2[0][i]=mul(i,pw2(-i));
		add(s2[0][i],s2[0][i-1]);
	}
	rep(i,1,m){
		rep(j,1,n){
			f[i][j]=mul(j+1,f[i-1][j]);
			if(j>=2) add(f[i][j],mul(s2[i-1][j-1],pw2(j-1)));
			s2[i][j]=mul(f[i][j],mul(j,pw2(-j)));
			add(s2[i][j],s2[i][j-1]);
		}
	}
	cout<<f[m][n]<<endl;
	return 0;
}

Measured memory_bytes: 199224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
struct edge{ll to, cost;};
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define INF 1000000000000

using graph = vector<vector<ll>>;
vector<bool> seen;
vector<ll> ans;
int main(){
    ll n;
    cin >> n;
  bool ok = true;
  
    if(n % 2 == 1){
        //cout << 0 << endl;
        //return 0;
      ok = false;
    }
    ll ans = 0;
  if(n % 2 == 0){
    for(ll i = 10; i <= n; i *= 5){
        ans += floorl(n / i);
    }
  }
  if(ok){
    cout << ans << endl;
  }
  else{
    cout << 0 << endl;
  }
}

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

int main()
{
    int numa, numb;
    cin >> numa >> numb;

    if(numa == numb){
        cout << numa *2 << endl;
    }else{
        if(numb > numa){
        numa = numb;
        }

        cout << numa*2 - 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>

using namespace std;

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

    long long c[500],s[500],f[500],n,i;
    cin >> n;
    for (i = 0; i < n-1 ; i++)
    {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (i = 0; i < n ; i++)
    {
        if (i == n-1)
        {
            cout << '0' << endl;
            return 0;
        }
        long long flag = i;
        long long answ = 0;
        while (flag < n-1)
        {
            if (answ < s[flag])
            {
                answ = s[flag];
            }
            else if ( (answ-s[flag]) % f[flag] != 0)
            {
                answ = s[flag] + ((answ - s[flag]) / f[flag] + 1) * f[flag];
            }
            answ = answ + c[flag];
            flag = flag + 1;
        }
        cout << answ << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*If the frog is currently on Stone 
i
, jump to one of the following: Stone 
i
+
1
,
i
+
2
,
…
,
i
+
K
. Here, a cost of 
|
h
i
−
h
j
|
 is incurred, where 
j
 is the stone to land on
 */
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
# define PI  3.14159265358979323846
ll maxi=LLONG_MIN;
ll mini=LLONG_MAX;
int main() 
{

 	ll n,k;cin>>n>>k;
 	ll a[n];
 	for (int i = 1; i <= n ; ++i)
 	{
 	  cin>>a[i];
 	}
 	ll dp[n+1];
    for (int i = 1; i <= n ; ++i)
    {
    	dp[i]=LLONG_MAX;
    }
    dp[1]=0;
 	for (int i = 1; i <= n; ++i)
 	{
 	  for (int j = i+1; j <=min(n,i+k) ; ++j)
 	  	{
 	  	   dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j])); 
 	  	}	
 	}
    cout<<dp[n];
 	return 0;
 }

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        vector<double> a(10);
        if(!(cin >> a[0]))
            return 0;

        for(int i=1; i<10; ++i){
            if(i % 2 == 1)
                a[i] = a[i-1] * 2;
            else
                a[i] = a[i-1] / 3;
        }

        printf("%.10f\n", accumulate(a.begin(), a.end(), 0.0));
    }
}

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

public class Main {

    static int A;
    static int B;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();

        System.out.println( solve() );
    }

    static String solve() {
        if ( A+B == 15 ) return "+";
        if ( A*B == 15 ) return "*";
        return "x";
    }

    @SuppressWarnings("unused")
    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



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

int main() {
  int N;
  scanf("%d", &N);
  int x[N],y[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &x[i]);
    y[i] = x[i];
  }

  sort(y,y+N);

  int ansleft = y[N/2-1];
  int ansright = y[N/2];

  for (int i = 0; i < N; ++i){
    if(x[i]<ansright){
      cout << ansright << endl;
    }
    else cout << ansleft << endl;
  }

  

}



Measured memory_bytes: 3712
package main

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

var sc = bufio.NewScanner(os.Stdin)

func swap(a int64, b int64) (int64, int64) {
	return b, a
}

func gcd(a int64, b int64) int64 {
	if b > a {
		a, b = swap(a, b)
	}
	if b == 0 {
		return a
	} else {
		return gcd(a%b, b)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func nextLong() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func nextByte() byte {
	sc.Scan()
	s := sc.Bytes()
	return s[0]
}

func main() {
	sc.Split(bufio.ScanWords)
	//ans := 1
	N := nextInt()
	K := nextLong()
	ans := 0
	Looplength := int64(0)
	var A [200005]int
	var Teleportnum [500005]int64
	var Visited [200005]bool
	for i := 1; i <= N; i++ {
		A[i] = nextInt()
	}
	Nowtown := 1
	Teleport := int64(0)
	for {
		if Visited[Nowtown] || K == 0 {
			break
		}
		Teleportnum[Nowtown] = Teleport
		Visited[Nowtown] = true
		Teleport++
		Nowtown = A[Nowtown]
		K--
	}
	for i := 1; i <= N; i++ {
		Visited[i] = false
	}
	Teleport = int64(0)
	if K == 0 {
		fmt.Printf("%d\n", Nowtown)
		return
	}
	//fmt.Printf("%d\n", K)
	for {
		if Visited[Nowtown] || K == 0 {
			break
		}
		//fmt.Printf("%d\n", Nowtown)
		Teleportnum[Nowtown] = Teleport
		Visited[Nowtown] = true
		Teleport++
		Nowtown = A[Nowtown]
		K--
		Looplength++
	}
	if K == 0 {
		fmt.Printf("%d\n", Nowtown)
		return
	}
	K = (K % Looplength)
	for i := 1; i <= N; i++ {
		if Visited[i] == true && K == Teleportnum[i] {
			ans = i
			break
		}
	}
	//fmt.Printf("%d\n", Alllength)
	//fmt.Printf("%d\n", Looplength)
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 8900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int n;
const int NN = 305;
int a[NN][NN], d[NN][NN];

int32_t main() {
    cin >> n;
    rep (i,n) rep (j,n) cin >> a[i][j];

    rep (k,n) rep (i,n) rep (j,n) if (a[i][j] > a[i][k] + a[k][j]) quit(-1);
    rep (i,n) rep (j,n) d[i][j] = a[i][j];
    rep (k,n) rep (i,n) rep (j,n) if (k != i && k != j && a[i][j] == a[i][k] + a[k][j]) d[i][j] = -1;

    int sum = 0;
    rep (i,n) rep (j,n) if (i < j && d[i][j] != -1) sum += d[i][j];
    cout << sum << endl;
    
}


Measured memory_bytes: 1664
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          fozubaoyou    no BUGs alive
*/
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define RFOR(i, a, b) for(int i = b; i >= a; i--)
#define REP(i, n) FOR(i, 0, n)
#define SZ(x) ((int)(x).size())
using namespace std;
typedef vector<int> vi;

int bubSort(vi &A) {
    bool flg = true;
    int n = 0;
    while (flg) {
        flg = false;
        RFOR(i, 1, SZ(A)-1) {
            if (A[i] < A[i-1]) {
                int tmp = A[i];
                A[i] = A[i-1];
                A[i-1] = tmp;
                flg = true;
                n++;}}}
    return n;
}

int main(){
    int n; cin >> n;
    vi A(n); REP(i,n) cin >> A[i];
    int nu = bubSort(A);
    REP(i,n) {
        cout << A[i];
        i == n-1 ? cout << endl : cout << " ";}
    cout << nu << endl;
}

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


pair<ll, ll> digit_sum(ll d) {
  ll dd = d;
  ll res = 0;
  ll count = 0;
  while(dd > 0) {
    res += dd % 10;
    dd /= 10;
    count++;
  }
  return make_pair(count, res);
}


ll sunuke(ll n) {
  //cout << "sunuke " << n << endl;
  pair<ll, ll> count_sum = digit_sum(n);
  double a =  (double) n / (double) count_sum.second;
  ll b = n;
  //cout << " count_sum " << count_sum.first << endl;
  for(int i=1;i<=count_sum.first;i++) {
    //cout << "n " <<  n << " ((ll) (n%pow(10, i))) " << ((ll) (n%pow(10, i))) << " pow(10, i) " << pow(10, i);
    ll cand = n - ((ll) (n % (ll) pow(10, i))) + pow(10, i) - 1;
    pair<ll, ll> p = digit_sum(cand);
    //cout << " cand " << cand << " sum " << p.second << " div " << (double) cand / (double) p.second<< endl;
    if(a > ((double) cand / (double) p.second)) {
      a = (double) cand / (double) p.second;
      b = cand;
    }
  }
  return b;
}

vector<ll> d(ll k) {
  vector<ll> res;
  res.push_back(1);
  ll i = 2;
  while((ll) res.size()<k) {
    i = sunuke(i);
    res.push_back(i);
    i++;
  }
  return res;
}

int main() {
  ll k;
  cin >> k;
  vector<ll> res = d(k);
  for(auto i: res) {
    cout << i << endl;
  }
}

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

int main(){
  int a,b,sum;
  while(1){
    cin>> a;
    if(a==0)break;
    sum=0;
    for(int i=0;i<a*(a-1)/2;i++){
      cin>>b;
      sum+=b;
    }
    cout << sum/(a-1) <<endl;
  }
  return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second

typedef long long int ll;

const ll INF = 1e10;

main(){
	IOS;
	ll a,b;
	cin>>a>>b;
	cout<<a*b-(a+b-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll par[N],sz[N];
void init(){
    for(ll i=0;i<N;i++)par[i]=i,sz[i]=1;
}
ll dsu_parent(ll node){
    if(node==par[node])return node;
    return par[node]=dsu_parent(par[node]);
}
void dsu_union(ll a,ll b){
    a=dsu_parent(a),b=dsu_parent(b);
    if(a==b)return;
    if(sz[a]<sz[b])swap(a,b);
    sz[a]+=sz[b];
    par[b]=a;
}
ll c1[N],c2[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    init();
    ll n,k,l;cin>>n>>k>>l;
    for(ll i=0,u,v;i<k;i++){
        cin>>u>>v;
        dsu_union(u,v);
    }
    ll cnt=0;
    for(ll i=1;i<=n;i++)if(i==dsu_parent(i))c1[i]=cnt++;
    for(ll i=1;i<=n;i++)c1[i]=c1[dsu_parent(i)];

    init();
    for(ll i=0,u,v;i<l;i++){
        cin>>u>>v;
        dsu_union(u,v);
    }
    cnt=0;
    for(ll i=1;i<=n;i++)if(i==dsu_parent(i))c2[i]=cnt++;
    for(ll i=1;i<=n;i++)c2[i]=c2[dsu_parent(i)];

    map< pair<ll,ll> , ll > mp;
    for(ll i=1;i<=n;i++)mp[{c1[i],c2[i]}]++;
    for(ll i=1;i<=n;i++)cout<<mp[{c1[i],c2[i]}]<<" ";
}


Measured memory_bytes: 18304
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    for (int i = 0; i < sz(s); ++ i) {
    	if (k - 1 == i) {
    		cout << char(tolower(s[i]));
    	}
    	else
    		cout << s[i];
    }
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256