akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int main(){
  int N;
  double v[50];
  std::cin >> N;
  for (int i = 0; i < N; i++) {
    std::cin >> v[i];
  }
  std::sort(v, v+N);
  for (int i = 0; i < N; i++) {
    v[i+1] = (v[i] + v[i+1])/2;
  }
  std::cout << v[N-1] << std::endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

vector<string> vec;
string tmp;
int n;

void dfs(int x,int t){
	if(x == n){
		cout << tmp << endl;
		return;
	}
	for(int i = 0;i <= t + 1;i++){
		tmp[x] = (char)('a' + i);
		dfs(x + 1,t + (i == t + 1));
	}
}

signed main(){
	cin >> n;
	tmp.resize(n);
	dfs(0,-1);
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s, t;
    cin >> s >> t;
    bool found = false;
    int i;
    for (i = s.size() - 1; i >= 0; --i) {
        if (i + 1 < t.size()) break;
        rep(j, t.size()) {
            if (s[i - j] != '?' && s[i - j] != t[t.size() - 1 - j])
                break;
            if (j == t.size() - 1)
                found = true;
        }
        if (found) break;
    }
    if (!found) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    } else {
        repr(j, t.size() - 1)
            s[i--] = t[j];
        rep(j, s.size()) {
            if (s[j] == '?')
                s[j] = 'a';
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, d, stat, M[N], C[4];
vector < int > Adj[N], Adt[N];
void DFS(int v)
{
    C[M[v]] ++;
    d += (int)Adj[v].size();
    for (int &u : Adj[v])
    {
        if (!M[u])
            M[u] = M[v] % 3 + 1, DFS(u);
        if (M[u] != M[v] % 3 + 1)
            stat = 1;
    }
    for (int &u : Adt[v])
    {
        if (!M[u])
            M[u] = (M[v] + 1) % 3 + 1, DFS(u);
        if (M[u] != (M[v] + 1) % 3 + 1)
            stat = 1;
    }
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        int v, u;
        scanf("%d%d", &v, &u);
        Adj[v].push_back(u);
        Adt[u].push_back(v);
    }
    long long tot = 0;
    for (int i = 1; i <= n; i++)
        if (!M[i])
        {
            C[1] = C[2] = C[3] = d = 0;
            stat = 2; M[i] = 1; DFS(i);
            if (stat == 1) tot += 1LL * (C[1] + C[2] + C[3]) * (C[1] + C[2] + C[3]);
            else if (!C[1] || !C[2] || !C[3]) tot += d;
            else if (stat == 2) tot += 1LL * C[1] * C[2] + 1LL * C[2] * C[3] + 1LL * C[3] * C[1];
        }
    return !printf("%lld\n", tot);
}

Measured memory_bytes: 16384
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace _2_B
//{
class Program
{
    static void Main(string[] args)
    {
        //????????????
        string a = Console.ReadLine();

        string[] b = a.Split(' ');
        int x = int.Parse(b[0]);
        int y = int.Parse(b[1]);
        int z = int.Parse(b[2]);

        if (x < y && y < z)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }


    }
}
//}

Measured memory_bytes: 8836
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,j,N,D,da,db,cnt=0;
  cin>>N>>D;
  for(i=2;i<=D;i++){
    da=i/10;
    db=i%10;
    if(da>1&&db>1&&da*db<=N)cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int H,W;
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			H=scan.nextInt();
			W=scan.nextInt();
			if(H == 0 && W== 0) {
				break;
			}
			for(int i = 0;i < H; i++) {
				for(int j= 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 32396
require 'bigdecimal'
input = STDIN.read.split("\n")
input.shift.to_i.times.map do
  # x1, y1, x2, y2, x3, y3, x4, y4 = input.shift.chomp.split.map { |e| (e.to_f * 100_000).floor.to_f }
  x1, y1, x2, y2, x3, y3, x4, y4 = input.shift.chomp.split.map { |e| BigDecimal.new(e) }
  if y1 == y2 && y3 == y4
    puts 'YES'
    next
  end
  ab = (y2 - y1) / (x2 - x1)
  cd = (y4 - y3) / (x4 - x3)
  puts(ab == cd ? 'YES' : 'NO')
end

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

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());
	for (int i = 0; i < n; i++) {
		if (a[i] == a[i + 1]) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}

Measured memory_bytes: 4032
def counter(arr, d):
  import math
  count = 0
  for item in arr:
    a = int(item[0])
    b = int(item[1])
    lenght = math.sqrt(a**2+b**2)
    #print(lenght)
    if lenght <= d:
      count += 1
  print(count)  
      

if __name__ == '__main__':
  line1 = input().split(" ")
  d = int(line1[1])
  num = int(line1[0])
  #print(d, num)
  arr = []
  for i in range(num):
    line = input().split(" ")
    arr.append(line)
  counter(arr, d)

Measured memory_bytes: 67648
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int INF_INT = 1e9;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    int maxi = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        maxi = max(a[i],maxi);
    }
    vector<int> prime(maxi+1,1);
    vector<int> check(maxi+1,0);
    map<int,int> pprime;
    map<int,int> primecheck;
    for(int i = 2; i <= maxi; i++){
        if(prime[i] == 1){
            check[i] = i;
            pprime[i] = 0;
            primecheck[i] = 0;
            for(int j = 2*i; j <= maxi; j+=i){
                prime[j] = 0;
                if(check[j] == 0) check[j] = i;
            }
        }
    }
    bool pres = true;
    for(int i = 0; i < N; i++){
        int temp = a[i];
        while(temp > 1){
            if(pprime[check[temp]] == 0 || primecheck[check[temp]] == i){
                pprime[check[temp]] = 1;
                primecheck[check[temp]] = i;
            }
            else {
                pres = false;
                break;
            }
            temp /= check[temp];
        }
        if(!pres) break;
    }
    if(pres){
        cout << "pairwise coprime" << endl;
    }
    else{
        int res = a[0];
        for(int i = 1; i < N ; i++){
            int n = a[i];
            if(res < n) swap(res,n);
            while(res % n != 0){
                int temp = res % n;
                res = n;
                n = temp;
            }
            res = n;
        }
        if(res == 1) cout << "setwise coprime" << endl;
        else cout << "not coprime" << endl;
    }
    return 0;
}


Measured memory_bytes: 22160
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int n , m;
    cin >> n >> m ;
    int x ;
    rep(i , m) cin >> x , n -= x ;
    n = max(-1ll , n);
    cout << n; 
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main()
{
    int i,n;
    int p=0,q=0,r=0,s=0;
    char a[10];
    scanf("%d",&n);
    for(i=1;i<=n;i++){
            //int p=0,q=0,r=0,s=0;
        scanf("%s",&a);
        if(strcmp(a,"AC")==0)p++;
    else if(strcmp(a,"WA")==0)q++;
    else if(strcmp(a,"TLE")==0)r++;
    else if(strcmp(a,"RE")==0)s++;
    }
    printf("AC x %d\n",p);
    printf("WA x %d\n",q);
    printf("TLE x %d\n",r);
    printf("RE x %d\n",s);

}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll calc(ll n) {
  return n * (n + 1) / 2;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;

  ll ans = 0;
  FOR(i, 1, n + 1) {
    ans += calc(n / i) * i;
  }
  cout << ans << '\n';

  




  
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <string>
#define INF 99999999
typedef long long ll;
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n<1200)
	cout<<"ABC"<<endl;
	else if(n<2800)
	cout<<"ARC"<<endl;
	else
	cout<<"AGC" <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    int S; cin >> S;
    if(S <= 2) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;

    REP(i,S/3) {
        if(i == 0) ans++;
        else {
            ll hako = i;
            ans += COM(S-3*(hako+1)+hako,hako);
            ans %= MOD;
        }
        //cout << ans << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 15576
import math
S = input()
K = int(input())
M = 5 * 10 ** 15

def main():
    sum = 0
    for s in S:
        n = int(s)
        sum += (M - 1) * math.log(n)
        if sum >= math.log(K):
            print(n)
            return

def main2():
    if K <= len(S):
        for i in range(K):
            if S[i] != '1':
                print(S[i])
                return
        print('1')
        return
    else:
        for s in S:
            if s != '1':
                print(s)
                return

if __name__ == '__main__':
    main2()


Measured memory_bytes: 3064
#coding: utf-8

n,T = map(int,raw_input().split())
c = []
t = []
for i in range(n):
    c_new, t_new = map(int,raw_input().split())
    c.append(c_new)
    t.append(t_new)

a = []
for i in range(n):
    if t[i] <= T: a.append(i)

c_min = 10000
for i in a:
    if c[i] < c_min: c_min = c[i] 

if c_min > 1000:
    print "TLE"
else:
    print c_min


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

inline int read() {
    char c, _c; int x; for (c = _c = getchar(); !isdigit(c); c = getchar()) { _c = c; }
    for (x = 0; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; } return _c == '-' ? -x : x;
}

const int N = 305;

int n, m, k, q;
long long f[N][N], dis[N][N];

int main() {
    n = read(); m = read(); k = read();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dis[i][j] = i == j ? 0 : 1e16;
        }
    }
    for (int i = 0; i < m; i++) {
        int u = read(), v = read(), w = read(); u--; v--;
        dis[u][v] = std::min(dis[u][v], (long long) w);
        dis[v][u] = std::min(dis[v][u], (long long) w);
    }
    for (int u = 0; u < n; u++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dis[i][j] = std::min(dis[i][j], dis[i][u] + dis[u][j]);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (dis[i][j] == 0) {
                f[i][j] = 0;
            } else {
                f[i][j] = dis[i][j] <= k ? 1 : 1e16;
            }
        }
    }
    for (int u = 0; u < n; u++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                f[i][j] = std::min(f[i][j], f[i][u] + f[u][j]);
            }
        }
    }
    q = read();
    for (int i = 0; i < q; i++) {
        int u = read(), v = read(); u--; v--;
        printf("%lld\n", f[u][v] >= 1e15 ? -1 : f[u][v] - 1);
    }
    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  bool can=false;
  cin >> n;
  ll h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  if(n==1){
    cout << "Yes\n";
    return 0;
  }
  for(int i=1;i<n;i++){
    if(h[i-1]<h[i]) h[i]--;
  }
  for(int i=1;i<n;i++){
    if(h[i-1]>h[i]){
      cout <<"No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)

int main()
{
	int wf[20][20];
	int n,m,a,b,c,d;
	
	/*ú»*/
	rep(i,20)
		rep(j,20)
			wf[i][j] = INF;
	rep(i,20)
		wf[i][i] = 0;
		
	/*üÍ*/
	cin >> n >> m;
	rep(i,m){
		scanf("%d,%d,%d,%d\n",&a,&b,&c,&d);
		a--;b--;
		wf[a][b] = c;
		wf[b][a] = d;
	}
	scanf("%d,%d,%d,%d\n",&a,&b,&c,&d);
	a--;b--;
	
	/* [VtCh@ */
	rep(k,n)
		rep(i,n)
			rep(j,n)
				wf[i][j] = min(wf[i][j],wf[i][k]+wf[k][j]);
	
	/* oÍ */
	cout << c - d - wf[a][b] - wf[b][a] << endl;
}

Measured memory_bytes: 0
import java.util.*;

@SuppressWarnings("unchecked")
class Main{

    char[] in;
    boolean[][] checked;
    HashSet[][] memo;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            String s = sc.next();
            if(s.equals("#")) break;

            in = s.toCharArray();
            int n = in.length+1;
            checked = new boolean[n][n];
            memo = new HashSet[n][n];
            System.out.println(expr(0, in.length).size());
        }
    }

    HashSet<Integer> expr(int l, int r){
        if(checked[l][r]) return memo[l][r];

        boolean kakko_num = true;
        int depth = 0;
        HashSet<Integer> res = new HashSet<Integer>();
        for(int i=l; i<r; i++){
            if(in[i]=='(') depth++;
            if(in[i]==')') depth--;
            if((in[i]=='*' || in[i]=='/' || in[i]=='+' || in[i]=='-') && depth==0){
                kakko_num = false;
                HashSet<Integer> left = expr(l, i);
                HashSet<Integer> right = expr(i+1, r);

                for(Iterator j=left.iterator(); j.hasNext();){
                    int a = (int)(Integer)j.next();
                    for(Iterator k=right.iterator(); k.hasNext();){
                        int b = (int)(Integer)k.next();
                        if(in[i]=='*') res.add(new Integer(a * b));
                        if(in[i]=='/' && b!=0) res.add(new Integer(a / b));
                        if(in[i]=='+') res.add(new Integer(a + b));
                        if(in[i]=='-') res.add(new Integer(a - b));
                    }
                }
            }
        }

        if(kakko_num){
            //digit?
            boolean num = true;
            for(int i=l; i<r; i++) if(!Character.isDigit(in[i])) num = false;
            if(num) res.add(new Integer(digit(l, r)));
            //(gonyo)?
            int depth2 = 0;
            for(int i=l+1; i<r-1; i++){
                if(in[i]=='(') depth2++;
                if(in[i]==')') depth2--;
            }
            if(depth2==0 && in[l]=='(' && in[r-1]==')') res = expr(l+1, r-1);
        }

        checked[l][r] = true;
        return memo[l][r] = res;
    }

    int digit(int l, int r){
        int res = 0;
        int ten = r-l-1;
        for(int i=l; i<r; i++){
            res += (in[i]-'0') * (int)Math.pow(10, ten--);
        }
        return res;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 25784
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *

import numpy as np

import math

import collections
import itertools
import bisect

def check(maiz):
    for i in range(h):
        for j in range(w):
            count = 0
            if i > 0 and maiz[i-1][j] =="#":
                count+=1
            if i <h-1 and maiz[i+1][j] =="#":
                count+=1
            if j > 0 and maiz[i][j-1] =="#":
                count+=1
            if j <w-1 and maiz[i][j+1] =="#":
                count+=1
            if count > 2 and  maiz[i][j] == "#":
                return False
    return True

if __name__ == '__main__':
    h, w = map(int, input().split())
    count =0
    flag =False
    maiz=[]
    for i in range(h):
        s = input()
        count+=s.count("#")
        maiz.append(list(s))

    if count == h+w-1 and check(maiz):
        print("Possible")
    else:
        print("Impossible")

Measured memory_bytes: 27068
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const int N=100010;

int ans,a[N],nxt[N],head[N];

int dfs(int k,int d)
{
    int p=head[k],t=0;
    while (p)
    {
        t=max(t,dfs(p,d)+1);
        p=nxt[p];
    }
    if (t==d-1&&a[k]!=1) {ans++;return -1;}
    return t;
}

int main()
{
	#ifdef waltz
		freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,k;scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	ans=0;
	if (a[1]!=1) {ans++;a[1]=1;}
    for (int i=2;i<=n;i++)
        if (a[i]!=1)
        {
            nxt[i]=head[a[i]];head[a[i]]=i;
        }
    for (int i=2;i<=n;i++) if (a[i]==1) dfs(i,k);
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {

	int n; cin >> n;
	vector<Int>h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	Int temp=h[0];
	bool ok = 0;
	if (n == 1) ok = 1;
	else {
		for (int i = 1; i < n; i++) {
			if (h[i] < temp) {
				//cout << i;
				if (abs(h[i] - temp) == 1) {
					ok = 1;
					temp = max(h[i] - 1, temp);
				}
				else {
					ok = 0;
					break;
				}
			}
			else {
				ok = 1;
				temp = max(h[i], temp);
			}

		}
	}
	if (ok) cout << "Yes";
	else cout << "No";
	
		



	//cout<<

	cout << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    int[][] dp1 = new int[n][t + 1];
    int[][] dp2 = new int[n][t + 1];

    for(int j = a[0]; j <= t; j++) {
      dp1[0][j] = b[0];
    }

    for(int j = a[n - 1]; j <= t; j++) {
      dp2[n - 1][j] = b[n - 1];
    }

    for(int i = 1; i < n; i++) {
      for(int j = 1; j <= t; j++) {
        if(j >= a[i]) {
          dp1[i][j] = Math.max(dp1[i - 1][j], b[i] + dp1[i - 1][j - a[i]]);
        } else {
          dp1[i][j] = dp1[i - 1][j];
        }
      }
    }

    for(int i = n - 2; i >= 0; i--) {
      for(int j = 1; j <= t; j++) {
        if(j >= a[i]) {
          dp2[i][j] = Math.max(dp2[i + 1][j], b[i] + dp2[i + 1][j - a[i]]);
        } else {
          dp2[i][j] = dp2[i + 1][j];
        }        
      }      
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
      int s = 0;
      for(int j = 0; j <= t - 1; j++) {
        if(i == 0) s = Math.max(s, dp2[1][t - 1]);
        if((i > 0) && (i < (n - 1))) s = Math.max(s, dp1[i - 1][j] + dp2[i + 1][t - 1 - j]);
        if(i == (n - 1)) s = Math.max(s, dp1[n - 2][t - 1]);
      }
      ans = Math.max(ans, b[i] + s);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 123540
using System;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Array.ConvertAll(System.Console.ReadLine().Split(' '), int.Parse);
            int tsuru = (4 * n[0] - n[1]) / 2;
            int kame = n[0] - tsuru;
            if(kame >=0 && tsuru >=0 && (4*n[0]-n[1])%2==0 )
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
                  
        }
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
constexpr int MAX = 2000200;
constexpr double EPS = 1E-11;

using namespace std;

int main() {
	vector<int>a(3);
	rep(i, 3)cin >> a[i];
	vector<int>b(3);
	rep(i, 3)cin >> b[i];

	vector<int>res(4);
	for (int i = 0; i < 3; i++) {
		res[a[i] - 1]++;
		res[b[i] - 1]++;
	}
	rep(i, 4) {
		if (res[i] >= 3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	//rep(i, 4)cout << res[i] << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      while (true) {
        int n = sc.nextInt();
        if ( n == 0) { break; }
        int[] scores = new int[n];
        double average = 0, variance = 0;
        for (int i = 0; i < scores.length; i++) {
          scores[i] = sc.nextInt();
          average += scores[i];
        }
        average /= n;
        for (int i = 0; i < scores.length; i++) {
          variance += Math.pow(scores[i] - average, 2);
        }
        variance /= n;
        System.out.println(Math.sqrt(variance));
      }
    }
  }
}



Measured memory_bytes: 31100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


ll gcd(ll a, ll b){  if(b==0){  return a; }   return gcd(b , a%b); }

ll cube (ll a){
  return a*a*a ;  
}
int main() {

int n;
cin>>n;
unordered_map<string,int> umap;
int flag = 1;
string first ;
cin>>first;
umap[first]++;
REP(i,n-1){
  string s,curr;
  cin>>s;
  curr = s;
  umap[s]++;
  if(first[first.length()-1] != curr[0]){
    flag = 0;
  }
  first = curr;
}

for(auto i: umap){
  if(i.second > 1){
    flag = 0;
    break;
  }
} 

if(!flag){
  cout<<"No\n";
}
else{
  cout<<"Yes\n";
}
  
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

#define pi 3.141592653589


void call(int n){
	int i = 1;
CHECK_NUM:
	int x = i;
	if (x % 3 == 0){
		cout << " " << i;
		goto END_CHECK_NUM;
	}
INCLUDE3:
	if (x % 10 == 3){
		cout << " " << i;
		goto END_CHECK_NUM;
	}
	x /= 10;
	if (x) goto INCLUDE3;
END_CHECK_NUM:
	if (++i <= n) goto CHECK_NUM;

	cout << endl;
}
int main(){
	int n;
	
	cin >> n;

	call(n);
	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
int main(void){
int long long N, i, j, A, B, ans, rem;

    scanf("%lld %lld %lld",&N,&A,&B); 

    ans=N/(A+B)*A;
    rem=N%(A+B);

    if(A>rem)
      ans=ans+rem;
    else
      ans=ans+A;
    
    printf("%lld",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int d,t,s;
    
    cin >> d >> t >> s;
    
    if (d <= t*s){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3644
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string S;

  cin >> S;

  int A[3];
  rep(i, 3) { A[i] = 0; }

  rep(i, S.size()) {
    if (S[i] == 'a')
      A[0] += 1;
    else if (S[i] == 'b')
      A[1] += 1;
    else
      A[2] += 1;
  }
  bool ans = true;
  rep(i, S.size()) {
    if (A[i] != 1) ans = false;
  }

  if (ans == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c[100],i=0,sum=0,count=0;
  cin>>a>>b;
  while(i<=a){
  cin>>c[i];
  i++;
  }
  i=0;
  while(1){
    count++;
    sum+=c[i];
    if(sum>b){break;}
    i++;
  }
  cout<<count;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void){
  char w[11],t[1001];
  int l,i,c=0;
  scanf("%s",w);
  for(i=0;w[i]!='\0';i++){
    w[i]=tolower(w[i]);
  }
  while(1){
    scanf("%s",t);
    if(strcmp(t,"END_OF_TEXT")==0)
      break;
    for(i=0;t[i]!='\0';i++){
      t[i]=tolower(t[i]);
    }
    if(strcmp(t,w)==0)
	c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 552
#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.at(i);
  }
  
  int max=0, maxnum=0, k=0, A=0, B=0; 
  
  for(int i=0;i<N;i++) { 
    for(int i=0;i<N;i++) {
      if(a.at(i)>max) {
        max=a.at(i);
        maxnum=i;
      }
    }
    
    if(k%2==0) A+=max;
    else B+=max;
    
    a.at(maxnum)=0;
    max=0;
    maxnum=0;
    k++;
    }
  
  cout << A-B << endl;
}

Measured memory_bytes: 3632
N = int(input())
A = [int(x) for x in input().split()]
ans_plusstart = 0
sum_plusstart = 0
ans_minusstart = 0
sum_minusstart = 0
if A[0] < 0:
    ans_plusstart += 1 - A[0]
    sum_minusstart = A[0]
    sum_plusstart = 1
else:
    ans_minusstart += 1 + A[0]
    sum_minusstart = -1
    sum_plusstart = max(1, A[0])
    if A[0] == 0:
        ans_plusstart = 1
for i in range(1, N):
    #print(sum_plusstart, ans_plusstart, sum_minusstart, ans_minusstart)
    if i % 2 == 0:  # スタートと同じ記号にしたい
        if A[i] + sum_plusstart > 0:
            sum_plusstart = A[i] + sum_plusstart
        if A[i] + sum_plusstart <= 0:
            ans_plusstart += 1-(A[i] + sum_plusstart)
            sum_plusstart = 1

        if A[i] + sum_minusstart < 0:
            sum_minusstart = A[i] + sum_minusstart
        if A[i] + sum_minusstart >= 0:
            ans_minusstart += 1 + A[i] + sum_minusstart
            sum_minusstart = -1

    else:  # スタートと違う記号にしたい
        if A[i] + sum_plusstart < 0:
            sum_plusstart = A[i] + sum_plusstart
        if A[i] + sum_plusstart >= 0:
            ans_plusstart += 1+A[i] + sum_plusstart
            sum_plusstart = -1

        if A[i] + sum_minusstart > 0:
            sum_minusstart = A[i] + sum_minusstart
        if A[i] + sum_minusstart <= 0:
            ans_minusstart += 1 - (A[i] + sum_minusstart)
            sum_minusstart = 1
print(min(ans_minusstart, ans_plusstart))


Measured memory_bytes: 14332
s = input()
x, y = list(map(int, input().split()))
Ans = ["No", "Yes"]
UD = []
RL = []
ud = 0
rl = 0
f = -1
cnt = 0
for i in s:
  if i == "F":
    cnt += 1
  else:
    if f == 0:
      UD.append(cnt)
      ud += cnt
      f = 1
    elif f == 1:
      RL.append(cnt)
      rl += cnt
      f = 0
    else:
      f = 0
      x -= cnt
    cnt = 0

if f == 0:
  UD.append(cnt)
  ud += cnt
elif f == 1:
  RL.append(cnt)
  rl += cnt
else:
  x -= cnt

if abs(y) > ud or abs(x) > rl:
  print(Ans[0])
  exit()

d = ud - abs(y)
l = rl - abs(x)

if d % 2 == 1 or l % 2 == 1:
  print(Ans[0])
  exit()

if d != 0:
  memo = [0]
  k = d // 2
  for i in UD:
    t = [0]
    for j in memo:
      if i + j == k:
        break
      if i + j < k:
        t.append(i + j)
    else:
      memo = t
      continue
    break
  else:
    print(Ans[0])
    exit()

if l != 0:
  memo = [0]
  k = l // 2
  for i in RL:
    t = [0]
    for j in memo:
      if i + j == k:
        break
      if i + j < k:
        t.append(i + j)
    else:
      memo = t
      continue
    break
  else:
    print(Ans[0])
    exit()

print(Ans[1])

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int res;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		if( !sc.hasNext() )return false;
		for(int i = 0; i < 10; i++){
			res += sc.nextInt();
		}
		return true;
	}
	
	static void solve(){
		System.out.println(res);
	}

}

Measured memory_bytes: 17368
object Main {
  def main(args: Array[String]): Unit = {
    val n = readInt
    val list = (for(i <- 1 to n) yield {
      val Array(a,b,_*) = readLine.split(" ")
      (a, b.toInt)
    }).toList
    val res = ((List.fill(13)("S") zip (1 to 13)) ++
    (List.fill(13)("H") zip (1 to 13)) ++
    (List.fill(13)("C") zip (1 to 13)) ++
    (List.fill(13)("D") zip (1 to 13))).filterNot(list.contains)
    for(e <- res)println(e._1+" "+e._2)
  }
}

Measured memory_bytes: 43976
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> a,v; //mainで入力

long long knap(long n,long W){
    vector<vector<long long>> dp(n+1,vector<long long>(W+1,0));
    for(int i=1;i<=n;++i){    
        for(int j=1;j<=W;++j){ 
            if(j-a[i-1]<0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j],dp[i-1][j-a[i-1]]+v[i-1]);
        }
    }
    return dp[n][W];
}

int main(void){
    // Your code here!
    long long n,w;cin>>n>>w;
    v.assign(n,0);
    a.assign(n,0);
    for(int i=0;i<n;i++){
        cin>>a[i]>>v[i];
    }
    cout<<knap(n,w)<<endl;
    
    
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vll A(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    if (A[0] != 0)
    {
        cout << -1 << endl;
        return 0;
    }
    for (size_t i = 1; i < N; i++)
    {
        if (A[i] - A[i - 1] > 1)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans=0;
    for (size_t i = 1; i < N; i++)
    {
        if(A[i] == A[i-1]+1)
        {
            ans++;
        }else
        {
            ans += A[i];
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class BStringPalindrome {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            char[] c = s.next().toCharArray();
            w.println(palin(0, c.length - 1, c) && palin(0, c.length / 2 - 1, c) && palin((c.length + 3) / 2 - 1, c.length - 1, c) ? "Yes" : "No");
        }

        boolean palin(int l, int r, char[] c) {
            while (l <= r) {
                if (c[l] != c[r]) return false;
                l++;
                r--;
            }
            return true;
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21332
/*
 * 2536.cc: Median Tree
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_M = 10000;

/* typedef */

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];

  void clear(int n) {
    for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1;
  }

  UFT() {}
  UFT(int n) { clear(n); }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }

  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1), mr;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

struct Edge {
  int u, v, c;
  Edge() {}
  Edge(int _u, int _v, int _c): u(_u), v(_v), c(_c) {}
  bool operator<(const Edge &e) const { return c < e.c; }
};

/* global variables */

UFT uft;
Edge es[MAX_M];

/* subroutines */

/* main */

int main() {
  for (;;) {
    int n, m;
    cin >> n >> m;
    if (n == 0) break;

    for (int i = 0; i < m; i++) {
      cin >> es[i].u >> es[i].v >> es[i].c;
      es[i].u--, es[i].v--;
    }
    sort(es, es + m);

    uft.clear(n);
    int en = 0, me = (n - 1) / 2, ans = -1;

    for (int i = 0; i < m; i++) {
      Edge &ei = es[i];
      int ru = uft.root(ei.u);
      int rv = uft.root(ei.v);
      if (ru != rv) {
	uft.merge(ei.u, ei.v);
	if (en == me) {
	  ans = ei.c;
	  break;
	}
	en++;
      }
    }

    printf("%d\n", ans);
  }
  return 0;
}

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

 main() {
int n;
cin >>n;
vector<pair<pair<string,int>,int>>a(n);
for(int i=0;i<n;i++){
    string z;int zz;
    cin >> z >>zz;
    a.at(i)=make_pair(make_pair(z,-1*zz),i+1);
}
sort(a.begin(),a.end());
for(int i=0;i<n;i++){
    cout << a.at(i).second<<endl;
}
 }




Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
for i in range(n):
  s = 0
  a = list(map(int,input().split()))
  for k in range(m):
    s += a[k]*b[k]
  s += c
  if s > 0:
    count += 1
print(count)

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

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

    int target_number = N % 10;

    if (target_number == 3) {
        cout << "bon" << endl;
        return 0;
    }
    if (target_number == 0 || target_number == 1 || target_number == 6 ||
        target_number == 8) {
        cout << "pon" << endl;
        return 0;
    }
    cout << "hon" << endl;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;

inline int read(){
	char ch = getchar(); int x = 0, op = 1;
	while (ch < '0' || '9' < ch) { if (ch == '-') op = -1; ch = getchar(); }
	while ('0' <= ch && ch <= '9') { x = x*10 + ch-'0'; ch = getchar(); }
	return op * x;
}
const int maxn = 100009;
LL n, s[maxn], t, res1, res2, op;

int main(){
	n = read();
	for (LL i=1; i<=n; i++) s[i] = s[i-1] + read();
	op = 1; t = 0;
	for (LL i=1; i<=n; i++){
		if (op == 1 && (s[i]+t) <= 0){
			res1 += 1 - (s[i]+t);
			t = 1 - s[i];
		}
		if (op == -1 && (s[i]+t) >= 0){
			res1 += (s[i]+t) + 1;
			t = -s[i] - 1;
		}
		op = -op;
	}
	op = -1; t = 0;
	for (LL i=1; i<=n; i++){
		if (op == 1 && (s[i]+t) <= 0){
			res2 += 1 - (s[i]+t);
			t = 1 - s[i];
		}
		if (op == -1 && (s[i]+t) >= 0){
			res2 += (s[i]+t) + 1;
			t = -s[i] - 1;
		}
		op = -op;
	}
	printf("%lld\n", min(res1, res2));
	return 0;
}

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

int main(){
    std::string S, T, U;
    int A, B;
    std::cin >> S >> T >> A >> B >> U;
    
    if(S == U){ A--; }
    else if(T == U){ B--; }
    std::cout << A << " " << B << std::endl;
    
    return 0;
}


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



int main(){
    string S;
    cin >> S;
    if(S[0] == S[1]) cout << "Bad" << endl;
    else if(S[1] == S[2])cout << "Bad" << endl;
    else if(S[2] == S[3]) cout << "Bad" << endl;
    else cout << "Good " << endl;
    return 0;
}

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

using namespace std;

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

int dp[1001][1001];

int main() {
  int n;
  cin >> n;
  pair<int, int> a[n];
  rep (i, n) cin >> a[i].second >> a[i].first;
  sort(a, a + n);
  rep (i, n + 1) rep (j, n + 1) dp[i][j] = 1e9;
  dp[0][0] = 0;
  rep (i, n) rep (j, i + 2) {
    if (j > 0 && dp[i][j - 1] + a[i].second <= a[i].first) {
      dp[i + 1][j] = min(dp[i][j], dp[i][j - 1] + a[i].second);
    } else {
      dp[i + 1][j] = dp[i][j];
    }
  }
  rep (i, n) if (dp[n][i + 1] == 1e9) {
    cout << i << endl;
    return 0;
  }
  cout << n << endl;
}

Measured memory_bytes: 1232
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,6);
  var len = input.length;
  var alist = [];
  var blist = [];
  for(var i = 0; i < len /2; i++){
    alist.push(input[i]);
    blist.push(input[len - (i+1)]);
  }
  var output = 0;
  for(var i = 0; i < alist.length; i++){
    if(alist[i] != blist[i]){
       output++;
       }
  }
  myout(output);
}

Main(myin());


Measured memory_bytes: 21064
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        if(n-k<0)
            printf("0\n");
        else printf("%d\n",n-k);
    }
return 0;}


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

int main(int argc, char* argv[]) {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i ++)
		cin >> a[i];

	int sum = 0;
	for (int i = 0; i < n; i ++) {
		for (int j = i; j < n; j ++) {
			if (i == j)
				continue;

			sum += a[i] * a[j];
		}
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 256