akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 200010;
const LL INF = 1e16;

int N; int mx[MAXN+1]; LL ans=INF;LL sum=0,ret=0;
struct data{ int x,id; }a[MAXN+1],b[MAXN+1],c[MAXN+1];
bool cmpx(data a,data b){ return a.x<b.x; }

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a1.out","w",stdout);
	N=read();
	for(int i=1;i<=N;i++){
		c[i].x=read();c[i].id=read();
	} sort(c+1,c+N+1,cmpx);
	for(int i=1;i<=N;i++){
		a[i].id=i; a[i].x=c[i].x;
		b[i].id=i; b[i].x=c[i].id;
	} sort(b+1,b+N+1,cmpx);
	reverse(b+1,b+N+1); 
	for(int i=1;i<=N;i++) mx[i]=max(mx[i-1],b[i].id),sum+=min(a[i].x,b[i].x);
	for(int i=2;i<=N;i++){
		if(a[i-1].x<=b[i-1].x&&a[i].x>=b[i].x) if(mx[i-1]>=i){ ans=sum; break; }
	} if(ans!=INF){ printf("%lld\n",ans); return 0; } 
	if(a[N].x<=b[N].x||a[1].x>=b[1].x){printf("%lld\n",sum); return 0;}
	for(int i=1;i<N;i++){
		if(a[i].x<=b[i].x&&a[i+1].x>=b[i+1].x){
			for(int a1=max(1,i-1);a1<=i;a1++){
				for(int b1=max(1,i-1);b1<=i;b1++){
					for(int a2=i+1;a2<=min(N,i+2);a2++){
						for(int b2=i+1;b2<=min(N,i+2);b2++){
							if(a[a1].id==b[b2].id||a[a2].id==b[b1].id) continue;
							if(a[a1].id==b[b1].id&&a[a2].id==b[b2].id) continue;
							if(a[a1].id==b[b1].id&&i!=1) continue;
							if(a[a2].id==b[b2].id&&i+1!=N) continue;
							ans=min(ans,sum-a[a1].x-b[b2].x+min(a[a1].x,b[b2].x)+min(a[a2].x,b[b1].x));
						}
					}
				}
			} 
		}
	} if(ans!=INF)printf("%lld\n",ans); 
	else{
		fgx;
		swap(a[1].x,a[2].x);
		printf("%lld\n",min(a[1].x,b[1].x)+min(a[2].x,b[2].x));
	}
	return 0;
}




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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, N) cin >> p[i];

    sort(p.begin(), p.end());
    int ans = 0;

    rep(i, K) ans+= p[i];

    cout << ans << endl;

    return 0;
}

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

int main(){
	int h;
	int m;
	int s;
	cin >> s;
	h = s/(60*60);
	m = s/60-h*60;
	s = s-(h*60+m)*60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 1168
use std::io::stdin;
use std::time::SystemTime;

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read<T>() -> T
where T: std::str::FromStr
{
    read_line().parse::<T>().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T>() -> Vec<T>
where T: std::str::FromStr
{
    read_line().split(" ").map(|n| n.parse::<T>().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_chars() -> Vec<char>
{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn print_time() -> () {
    println!("{:?}", SystemTime::now());
}

#[allow(unused_variables)]
fn main() {
    let nx: Vec<i64> = read_vec();
    let mut vec: Vec<i64> = read_vec().iter().map(|v| (v-nx[1]).abs()).collect();
    vec.sort();
    if vec.len() == 1 {
        println!("{}", vec[0]);
    } else {
        let mut f = vec[0];
        let mut s = vec[1];
        let mut start = 0;
        
        loop {
            loop {
                let t = s % f;
                if t == 0 {
                    break;
                }
                s = f;
                f = t;
            }
            
            let mut t = 0;
            for i in start..vec.len() {
                if vec[i] % f != 0 {
                    t = vec[i];
                    start = i;
                    break;
                }
            }
            
            if t == 0 {
                println!("{}", f);
                break;
            } else {
                s = t;
            }
        }
        
    }
}


Measured memory_bytes: 8444
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void)
{
    int ans1 = 0, ans2 = 0;

    int n, m;
    scanf("%d%d", &n, &m);

    int ac[n] = {0}, wa[n] = {0};

    rep(i, m)
    {
        int p;
        char s[5];
        scanf("%d%s", &p, s);
        if (s[0] == 'A' && s[1] == 'C')
            ac[p - 1] = 1;
        if (s[0] == 'W' && s[1] == 'A')
            if (ac[p - 1] == 0)
                wa[p - 1]++;
    }
    rep(i, n) if (ac[i] == 1)
    {
        ans1++;
        ans2 += wa[i];
    }

    printf("%d %d\n", ans1, ans2);

    return 0;
}

Measured memory_bytes: 896
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size){
        data=vector<int>(size,-1);
    }
    bool union_set(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];
            data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    GVI(p,N);
    int ans=0;
    int last=0;
    FOR(i,N){
        if(p[i]==i+1){
            if(last==0){
                ans++;
                last=1;
            }else{
                last=0;
            }
        }else{
            last=0;
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    Integer H[] = new Integer[N];
    long count = 0;
    for (int i = 0; i < N; i++) {
      H[i] = scan.nextInt();
    }
    Arrays.sort(H, Collections.reverseOrder());
    if (K - N > 0) {
      for (int i = 0; i < N; i++) {
        H[i] = 0;
      }
    }
    else{
      for (int i = 0; i < K; i++) {
        H[i] = 0;
      }
      for (int i = K; i < N; i++) {
        count += H[i];
      }
    }
    System.out.println(count);
  }
}




Measured memory_bytes: 93864
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
int a[110];
int main()
{
	int i,j,k,n,m,x;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
		if(m<a[i])
		{
			break;
		}
		m-=a[i];
	}
	if(m>0&&i==n)
	{
		i--;
	}
	printf("%d",i);
	return 0;
}

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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int R;
  cin >> R;
  cout << fixed << setprecision(3) << 2 * R * 3.14159265 << endl;
}


Measured memory_bytes: 3796
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

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

int main() {
	int a,b;
	for(;cin>>a>>b;){
		cout<<gcd(a,b)<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;cin>>n;
    int a[n];
    rep(i,n){cin>>a[i];}
    vector<vector<bool>> dp(n+1,vector<bool>(10010,false));
    rep(i,n)    dp[i][0]=true;
    rep(i,n){
        for(int j=10001;j>=0;j--){
            if(dp[i][j]){
                dp[i+1][j]=true;
                if(j+a[i]<10010){
                    dp[i+1][j+a[i]]=true;
                }
            }
        }
    }
    for(int i=10001;i>=0;i--){
        if(dp[n][i]){
            if((i%10)!=0){
            cout<<i<<endl;return 0;}
        }
    }
    cout<<0<<endl;return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int cnt = 0;
    for(int i=0; i<n; i++) {
        cin >> a[i] >> b[i];
        if(a[i]==b[i]) cnt++;
        else cnt = 0;
        if(cnt==3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
K = int(input())

S = set()
cnt,n = 1,7
nothing = False

while True:
    if n % K == 0:
        print(cnt)
        break
    else:
        if n in S:
            print(-1)
            break
        else:
            S.add(n)
            n += (7 * pow(10,cnt,K))
            n %= K
            cnt += 1


Measured memory_bytes: 157160
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int gcd(int a, int b) {
        if (a % b != 0) {
            return gcd(b, a % b);
        } else {
            return b;
        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int k = sc.nextInt();
        double temp = (double) k / 2;
        System.out.println((int) (temp * temp));
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	char a[1005],b[1005];
	int flag = 3;
	long long len1,len2;
	scanf("%s",a);
	scanf("%s",b);
	len1 = strlen(a);
	len2 = strlen(b);
	if(len1 < len2)
		flag = 0;
	else
		if(len1 > len2)
			flag = 1;
	else 
		for(int i = 0; i < len1 ; i++)
		{
			if(a[i]==b[i])
				continue;
			else if(a[i] > b[i])
			{
				flag = 1;
				break;
			}
			else 
			{
				flag = 0;
				break;
			}
	    }
	    if(flag == 0)
	    	printf("LESS\n");
	    else if(flag == 1)
	    	printf("GREATER\n");
	    	else
	    		printf("EQUAL\n");
	    	return 0;
}

Measured memory_bytes: 128
import java.util.*;

// UVa 11504

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		long a = in.nextLong();
		long b = in.nextLong();
		long x = in.nextLong();
		
		long first = a;
		long last = b;
		
		if (first % x != 0) {
			first += (x - a % x);
		}
		if (last % x != 0) {
			last -= b % x;
		}
		
		System.out.println((last - first) / x + 1);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 110
int N;
char S[Max];

int main(int argc, const char * argv[]) {
    N = inputValue();
    inputArray(S, N);
    if (find(S, S+N, 'Y') != S+N){
        output("Four");
    } else {
        output("Three");
    }

    return 0;
}

Measured memory_bytes: 764
n,k = map(int,input().split())
s = list(input())

if s[k-1] == "A" :
    s[k-1] = "a"
elif s[k-1] =="B":
    s[k-1] = "b"
elif s[k-1] == "C" :
    s[k-1] = "c"

s = "".join(s)
print(s)

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
string s[55];
int t[55];
string x;
void solve() {
    cin >> n;
    rep(i, n) cin >> s[i] >> t[i];
    cin >> x;

    bool ok = false;
    int ans = 0;
    rep(i, n) {
        if (ok) ans += t[i];
        if (s[i] == x) ok = true;
    }

    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n: i32,
        s: [String; n],
    }
    let mut h = std::collections::HashMap::new();
    for t in s.iter() {
        let mut chars: Vec<char> = t.chars().collect();
        chars.sort_by(|a, b| b.cmp(a));
        let c = h.entry(chars).or_insert(0 as i64);
        *c += 1
    }
    let r = h.values().fold(0, |acc, v| acc + v * (v - 1) / 2);
    println!("{}", r);
}


Measured memory_bytes: 20508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double L;
    cin >> L;
    printf("%.12lf\n", (L / 3) * (L / 3) * (L / 3));
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace C___Dice_and_Coin
{
    class Program
    {
        static void Main(string[] args)
        {
            var N_K = Console.ReadLine().Split();
            var N = int.Parse(N_K[0]);
            var K = int.Parse(N_K[1]);
            var xi = new double[N];

            for (int i = 1; i <= N; i++)
                xi[i - 1] =  i <= K ? 1.0 / N * Math.Pow(0.5, Math.Ceiling(Math.Log((double)K / i, 2))) : 1.0 / N;

            Console.WriteLine(xi.Sum());

        }
    }
}


Measured memory_bytes: 11872
import bisect as bs
def prime(m):
  N = range(1,m+1, 2)
  N[0] = 2
  for i in range(1, int(m**.5)+1):
    x = N[i]
    if x: N[i+x::x] = [0] * len(N[i+x::x])
  return filter(None, N)

P = prime(10000)
x = [a for a,b in zip(P[1:],P[:-1]) if a-b==2]
while 1:
  n = input()
  if n==0: break
  a = x[bs.bisect_right(x, n)-1]
  print a-2, a

Measured memory_bytes: 4516
#C - Coloring Colorfully
import sys
input = sys.stdin.readline
s = list(input())

cost_0, cost_1 = 0, 0

for i in s[::2]:
	if i == "1":
		cost_0 += 1
for i in s[1::2]:
	if i == "0":
		cost_0 += 1

for i in s[::2]:
	if i == "0":
		cost_1 += 1
for i in s[1::2]:
	if i == "1":
		cost_1 += 1
		 
print(min(cost_0, cost_1))

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

int main(){
    int d;
    cin >> d;
    if(d == 25) cout << "Christmas" << endl;
    else if(d == 24) cout << "Christmas Eve" << endl;
    else if(d == 23) cout << "Christmas Eve Eve" << endl;
    else if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
}


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

typedef long long ll;
const int maxn=2e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int p[maxn],ivp[maxn];

int ppow(int x,int y=mod-2)
{
    if (y==0) return 1;
    int ret=ppow(x,y/2);
    ret=ret*ret%mod;
    if (y&1) ret=ret*x%mod;
    return ret;
}

int C(int n,int m)
{
    return p[n]*ivp[m]%mod*ivp[n-m]%mod;
}

int32_t main()
{
    IOS
    p[0]=ivp[0]=1;
    for (int i=1;i<=2000002;i++)
        p[i]=p[i-1]*i%mod,ivp[i]=ppow(p[i]);

    int r1,r2,c1,c2;
    cin>>r1>>c1>>r2>>c2;

    int ans=0;
    for (int i=r1;i<=r2;i++)
    {
        ans=(ans+C(i+c2+1,i+1))%mod;
        ans=(ans+mod-C(i+c1,i+1))%mod;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 31488
#include <iostream>
#include <cstring>
#include <cctype>
#include <stdio.h>
#include <cstdio>

using namespace std;

int main(){
	char a[1001];
	for(int i=0;;i++){
		scanf("%s",a);
		if(a[0]=='0')break;
		int b=0;
		for(int j=0;j<strlen(a);j++){
			b+=(a[j]-'0');
		}
		printf("%d\n",b);
	}
	return 0;
}

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

int main()
{

        int a, b, c, d;
        cin >> a >> b >> c >> d;

        if (abs(c - b) <= d && abs(b - a) <= d) {
                cout << "Yes" << endl;
        }
        else if (abs(c - a) <= d) {
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>


using namespace std;



int main() {
	while (1) {
		int n;
		double s[1000];
		double sum = 0;
		double ave;
		double dev2 = 0;
		double ans;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			sum += s[i];
		}
		ave = sum / n;
		for (int i = 0; i < n; i++) {
			dev2 += (s[i] - ave) * (s[i] - ave);
		}
		ans = sqrt(dev2 / n);
		cout << fixed << ans << endl;
	}
	
}


Measured memory_bytes: 3248
import java.util.*;
class Main{
	public static void main(String[] args){
    
    	Scanner s = new Scanner(System.in);
        int n = s.nextInt() , d = s.nextInt();
      	long[][] arr = new long[n][d];
      
      	for(int i = 0;i < n;i++){
        	for(int j = 0;j < d;++j){
            	arr[i][j] = s.nextLong();
            } 
        } 
      
      int count = 0;
      long ans = 0;
    
      for(int i = 0;i < n;i++){
      
      	for(int j = i + 1;j < n;j++){
        
          long val = 0;
        	for(int k = 0;k < d;++k){
            	val += Math.pow( (arr[j][k] - arr[i][k]) , 2 ); 
            }
          
          long a = (long)Math.sqrt(val);
          if(a*a == val) count++;
        
        }
      
      }
      
      System.out.println(count);
      
    }
  
}

Measured memory_bytes: 23252
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::VecDeque;

fn main() {
    input! {
        h: usize,
        w: usize,
        board: [chars; h],
    }

    let mut dist: Vec<Vec<i32>> = vec![vec![-1; w]; h];
    let mut black_cells: VecDeque<(i32, i32)> = VecDeque::new();

    for i in 0..h {
        for j in 0..w {
            if board[i][j] == '#' {
                dist[i][j] = 0;
                black_cells.push_front((i as i32, j as i32));
            }
        }
    }

    let mut ans = 0;
    while !black_cells.is_empty() {
        match black_cells.pop_front() {
            Some((y, x)) => {
                ans = dist[y as usize][x as usize];
                for &(dy, dx) in &[(1, 0), (0, 1), (-1, 0), (0, -1)] {
                    let nh = y + dy;
                    let nw = x + dx;
                    if nh < 0 || h as i32 <= nh || nw < 0 || w as i32 <= nw {
                        continue;
                    }
                    if dist[nh as usize][nw as usize] == -1 {
                        dist[nh as usize][nw as usize] = ans + 1;
                        black_cells.push_back((nh, nw));
                    }
                }
            }
            None => break,
        }
    }

    println!("{}", ans);
}


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

using namespace std;

typedef long long ll;

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> left, right;
  right.push_back(0);
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    if (x < 0) left.push_back(x);
    else if (x > 0) right.push_back(x);
    else K--;
  }
  left.push_back(0);
  reverse(left.begin(), left.end());
  int res = INF;
  for (int i = 0; i <= K; ++i) {
    int mi1 = INF;
    int mi2 = INF;
    if (i < left.size() && K - i < right.size()) {
      mi1 = -2 * left[i] + right[K - i];
      mi2 = -left[i] + 2 * right[K - i];
    }
    res = min(res, min(mi1, mi2));
  }
  cout << res << endl;
}

Measured memory_bytes: 1020
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
	int X;
	cin >> X;
	if (X >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3592
import * as fs from 'fs';

namespace AtCoder.abc001 {

    export class Program {

        constructor(private readonly args: string[]) {
        }

        /**
         * in
         *
         * out
         *
         */
        main(this: Program): void {

            const n: number = +this.args[0];
            const s: any = {};

            let ans: number = 0;
            for (let i = 1; i <= n; i++) {

                const keihin = this.args[i];
                if (!s[keihin]) {
                    ans+=1;
                    s[keihin]='find';
                }

            }

            console.log(ans);

        }
    }
}

const args: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg: AtCoder.abc001.Program = new AtCoder.abc001.Program(args);
prg.main();


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

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

  int min_a, min_b, max_a, max_b ;
  min_b = b*10 ;
  max_b = (b+1)*10 - 1 ;
  if ( a % 2 == 1 ){
    min_a = (a*100/8) + 1 ;
    max_a = (a+1)*100/8 -1 ;
  } else {
    min_a = (a*100/8) ;
    max_a = ( (a+1)*100/8 ) ;
  }

  if ( max_a < min_b || max_b < min_a ) {
    cout << "-1" << endl ;
  } else if ( min_b <= min_a ){
    cout << min_a << endl ;
  }else {
    cout << min_b << endl ;
  }

  return 0 ;
}

Measured memory_bytes: 256
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N,X=acinput()

n=[0]*(N+1)
n[0]=1
for i in range(1,N+1):
    n[i]=n[i-1]*2+3
    
    
p = [0]*(N+1)
p[0] = 1
for i in range(1, N+1):
    p[i] = p[i-1]*2+1

def f(N,k):
    
        
    if N == 0 and k>=1:
        return 1
    
    if k <= 1:
        return 0
    
    if k<=n[N-1]+1:
        return f(N-1,k-1)
    else:
        r=k-n[N-1]-2
        return p[N-1]+f(N-1,r)+1


print(f(N,X))

Measured memory_bytes: 12528
N, H = map(int, input().split())
a = []
b = []
for i in range(N):
    tmpa, tmpb = map(int, input().split())
    a.append(tmpa)
    b.append(tmpb)
m = max(a)
b.sort(reverse=True)
cnt = 0
for i in b:
    if i > m and H > 0:
        H -= i
        cnt += 1
    else:
        break
if H > 0:
    cnt += H // m
    if H % m != 0:
        cnt += 1
print(cnt)

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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 main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }

    lli ans = INF;
    REP(i,0,N){
        vector<lli> P,V;
        REP(j,0,N){
            if(A[j]<A[i]){
                if(V.size()>=K){
                    SORT(V);
                    REP(x,0,V.size()-K+1)P.push_back(V[x]);
                }
                V.clear();
            }
            else{
                V.push_back(A[j]);
            }
        }
        if(V.size()>=K){
            SORT(V);
            REP(x,0,V.size()-K+1)P.push_back(V[x]);
        }
        if(P.size()<Q)continue;
        SORT(P);
        chmin(ans,P[Q-1]-P[0]);
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long[] H;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            H = new long[N];
            for(int i=0;i < N ;i++){
                H[i] = sc.nextLong();
            }
        }
        long result = 0;
        long currentMax =0;
        for(int i=0;i < N -1;i++){
            if(H[i] >= H[i+1]){
                currentMax++;
            }else{
                if(currentMax > result){
                    result = currentMax;
                }
                currentMax = 0;
            }
        }
        if(currentMax > result){
            result = currentMax;
        }

        System.out.println( result);
    }

}


Measured memory_bytes: 56016
#B
N = int(input())


AC = 0
WA = 0
TLE = 0
RE = 0
for _ in range(N):
    judge = input()
    if judge == 'AC':
        AC += 1
    elif judge == 'WA':
        WA += 1
    elif judge == 'TLE':
        TLE += 1
    elif judge == 'RE':
        RE += 1

print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')

Measured memory_bytes: 9200
use std::io;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N: i32 = iter.next().unwrap().parse().unwrap();
    for i4 in 0..N {
      for i7 in 0..N {
        if i4 * 4 + i7 * 7 == N {
          println!("{}", "Yes");
          return;
        }
      }
    }
    println!("{}", "No");
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

int64_t solution(int64_t a, int64_t b) {
  int64_t key, target = a * b;
  for (int64_t i = sqrt(static_cast<long double>(target -1)); i < std::max({a, b}); ++i) {
    if (target > i * i)
      key = i;
    else
      break;
  }
  int64_t ans = 2 * key;
  if (a <= key)
    ans -= 1;
  if (b <= key)
    ans -= 1;
  if (key * (key + 1) >= target)
    ans -= 1;
  return ans;
}

int main() {
  int q;
  std::cin >> q;
  for (int i = 0; i < q; ++i) {
    int64_t a, b;
    std::cin >> a >> b;
    std::cout << solution(a, b) << std::endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
 
	int nRemain = N;
	while (nRemain >= 500) {
		nRemain -= 500;
	}
	if (nRemain <= A) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <regex>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    string s,t; cin >> s >> t;
    vector<vector<ll>> alp(26);
    ll ns = s.size(), nt = t.size();
    rep(i,ns){
        ll x = s.at(i) - 'a';
        alp.at(x).push_back(i);
    }
    pair<ll,ll> now(1,0); //1週目の0文字目にいるところからスタート
    rep(i,nt){
        ll x = t.at(i) - 'a';
        if(alp.at(x).size()==0){ //sにそのアルファベットが含まれていない場合は不可
            std::cout << -1 << endl;
            return 0;
        }
        label:;
        auto it = lower_bound(alp.at(x).begin(),alp.at(x).end(),now.second);
        if(it==alp.at(x).end()){
            now.first++;
            now.second = 0;
            goto label;
        }else{
            now.second = *it;
            now.second++;
        }
    }
    std::cout << (now.first - 1)*ns + now.second << endl;
}

Measured memory_bytes: 1724
#include <iostream>


int main() {
  int N = 0;
  int K = 0;
  int X = 0;
  int Y = 0;
  
  std::cin >> N;
  std::cin >> K;
  std::cin >> X;
  std::cin >> Y;
  
  int totalPrice = 0;

  if (N < K) {
    std::cout << N * X << std::endl;
  } else {
    for (int i = 0; i < K; ++i) {
      totalPrice += X;
    }
    for (int j = K + 1; j <= N; ++j) {
      totalPrice += Y;
    }
    std::cout << totalPrice << std::endl;
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,N,i,ren = 0;
    scanf("%d",&N);
    
    for(i = 0;i < N;i ++){
        scanf("%d %d",&a,&b);
        if(a == b){
            ren ++;
        }else{
            ren = 0;
        }
        if(ren == 3){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}



Measured memory_bytes: 1616
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int s;
    cin >> s;
    set <int> a;
    int x = s;
    int count = 1;
    while(a.count(x) == 0) {
        a.insert(x);
        if (x % 2 == 0) {
            x = x/2;
        } else {
            x = 3 * x +1;
        }
        count++;
    }
    cout <<  count << endl;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n){
        cin >> a[i];
        a[i]--;
    }
    int i = 0,cnt = 1;
    bool reached[100000] = {};
    do{
        if(a[i] == 1){
            cout << cnt << endl;
            return 0;
        }
        cnt++;
        reached[a[i]] = true;
        i = a[i];
    }while(reached[a[i]] == false);
    cout << -1 << endl;
}

Measured memory_bytes: 768
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 200001;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    public static void main(String args[]) throws IOException {
        int N = in.nextInt();
        int [] a  = new int [N];
        int INF  = 100000000;
        int MINF = -10000000;
        int min = INF;
        int max = MINF;
        for(int i=0;i<N;i++)
        a[i] = in.nextInt();
        int A = 0;
        int B = 0;
        for(int i=0;i<N;i++){
            min = INF;
            max =MINF;
            int index = 0;
            if(i%2==0){
                for(int j=0;j<N;j++){
                    if(a[j]!=0){
                     if(a[j]>max){
                           max =a[j];
                            index = j;
                     }
                 }
                }
                A+=max;
                a[index] = 0;
            }else{
                for(int j=0;j<N;j++){
                    if(a[j]!=0){
                     if(a[j]>max){
                           max =a[j];
                            index = j;
                     }
                 }
                }
                B+=max;
                a[index] = 0;
            }


        }
        out.println(A-B);

        out.flush();
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
vector<int> G[N];
int C[N], num[N], sum[N];
ll ans[N];
ll cal(int x) {
    return 1LL * x * (x + 1) / 2;
}
void dfs(int u, int fa) {
    int c = C[u], save = sum[c], nodes = 1;
    for(auto v : G[u]) {
        if(v == fa) continue;
        int t = sum[c];
        dfs(v, u);
        int dt = sum[c] - t;
        ans[c] -= cal(num[v] - dt);
        nodes += num[v];
    }
    sum[c] = save + (num[u] = nodes);
}
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &C[i]);
    }
    for(int i = 1, u, v; i < n; i++) {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i = 1; i <= n; i++) {
        ans[i] = cal(n);
    }
    dfs(1, -1);
    for(int i = 1; i <= n; i++) {
        int t = n - sum[i];
        ans[i] -= cal(t);
        printf("%lld\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 37316
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

P ts[10000];

int main(){
	int n;
	int c, m1, s1, m2, s2, m3, s3, m4, s4;
	while(cin >> n && n){
		rep(i, n){
			cin >> c >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			ts[i] = P((m1+m2+m3+m4)*60+s1+s2+s3+s4, c);
		}
		sort(ts, ts + n);
		cout << ts[0].second << endl;
		cout << ts[1].second << endl;
		cout << ts[n-2].second << endl;
	}
	return 0;
}

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

namespace ABC158A
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int A = 0;
            int B = 0;
            for (int i = 0; i < 3; i++)
            {
                if (S[i].ToString() == "A")
                {
                    A += 1;
                }
                else if (S[i].ToString() == "B")
                {
                    B += 1;
                }
            }
            if (A > 0 & B > 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 25860
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> L(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &L[i]);
  }
  int cnt = 0;
  for (int i = 0; i < N; ++i)
  {
    for (int j = i + 1; j < N; ++j)
    {
      for (int k = j + 1; k < N; ++k)
      {
        if ((L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) &&
            (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]))
        {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

int main(void) {
    priority_queue<int> que;
    
    
    int num;
    while(scanf("%d", &num) != EOF) {
        que.push(num);
    }
    cout << que.top() << endl; que.pop();
    cout << que.top() << endl; que.pop();
    cout << que.top() << endl; que.pop();
    
    return(0);
}

Measured memory_bytes: 1228
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Apr  1 18:40:53 2018
//
package main

import (
	"fmt"
)

var N int

func main() {
	fmt.Scan(&N)

	A := make([]int, N)
	B := make([]int, N)

	for i := range A {
		fmt.Scan(&A[i])
		fmt.Scan(&B[i])
	}

	count := 0
	for i := len(A) - 1; i >= 0; i-- {
		var n int
		if A[i]+count == 0 {
			n = 0
		} else {
			n = (A[i]+count-1)/B[i] + 1
		}

		count += n*B[i] - (A[i] + count)
	}
	fmt.Println(count)
}


Measured memory_bytes: 6912
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
#define ll long long
//{{{ read()
inline int read() {
    register int x = 0, f = 1;
    register char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = x * 10 + (ch ^ 48), ch = getchar();
    return x * f;
}
//}}}
int main() {
    // freopen(".in","r",stdin);
    // freopen(".out","w",stdout);
    int n = read(), f1 = 0, f2 = 0, f3 = 0;
    int y = n % 10;
    if (y == 0 || y == 1 || y == 6 || y == 8)
        f2 = 1;
    if (y == 2 || y == 4 || y == 5 || y == 7 || y == 9)
        f1 = 1;
    if (y == 3)
        f3 = 1;
    if (f3)
        puts("bon");
    else if (f2)
        puts("pon");
    else
        puts("hon");
    return 0;
}

Measured memory_bytes: 3600
info=gets.chomp.split(" ").map(&:to_i)
kouho=gets.chomp.split(" ").map(&:to_i)
kouho.shift()
if info[0]!=1
	(info[0]-1).times do|i|
	kouho2=gets.chomp.split(" ").map(&:to_i)
	kouho2.shift()	
	kouho=kouho&kouho2
	end
end
print(kouho.size)

Measured memory_bytes: 3836
n = int(input())

a_list = []
for _ in range(n):
  mini_list = []
  a = int(input())
  for _ in range(a):
    mini_list.append(list(map(int, input().split())))
  a_list.append(mini_list)

ans = 0
for i in range(2**n):
  ans_list = [0]*n
  cnt=0
  while i!=0:
    ans_list[cnt] = i%2
    cnt+=1
    i//=2
  
  flg = True
  for j, syogens in enumerate(a_list):
    if ans_list[j]==0:
      pass
    else:
      for syogen in syogens:
        person = syogen[0]-1
        status = syogen[1]
        if ans_list[person] != status:
          flg=False
  if flg:
    ans = max(ans,sum(ans_list))
print(ans)


Measured memory_bytes: 9136