akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

ll a[4001];
ll b[4001];
ll c[4001];
int main() {
	ll n, k; cin >> n >> k;
	rep(i, 0, n) {
		ll A; cin >> A;
		a[i] = A;
		a[i + n] = A;
	}
	rep(i, 0, n) {
		rep(j, i + 1, n) {
			if (a[i] > a[j]) {
				b[i]++;
			}
		}
	}
	rep(i, 0, n) {
		rep(j, 0, n) {
			if (a[i] > a[j]) {
				c[i]++;
			}
		}
	}

	//rep(i, 0, n) {
	//	rep(j, i + 1, 2 * n) {
	//		if (j < n) {
	//			if (a[i] > a[j]) {
	//				b[i]++;
	//			}
	//		}
	//		else {
	//			if (a[i] > a[j]) {
	//				c[i]++;
	//			}
	//		}
	//	}
	//}

	ll ans = 0;
	rep(i, 0, n) {
		b[i] %= MOD;
		c[i] %= MOD;
		ll K = (k * (k - 1) / 2) % MOD;
		ll B = (b[i] * k) % MOD;
		ll C = (c[i] * K) % MOD;
		ll A = (B + C) % MOD;
		ans = (ans + A) % MOD;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
class A:

    def solve(self):
        [a, b, c] = sorted([int(x) for x in input().split(" ")])
        if a == 5 and b == 5 and c == 7:
            print("YES")
        else:
            print("NO")

class B:

    def solve(self):
        [n, l] = [int(x) for x in input().split(" ")]

        strings = []
        for r in range(n):
            strings.append(input())

        sorted_strings = sorted(strings)

        print("".join(sorted_strings))

B().solve()


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

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

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

    long long n;
    int x, m;
    cin >> n >> x >> m;
    long long ans = x;
    vector<int> rep(m + 1, -1);
    rep[x] = 0;
    vector<long long> ac(m + 1, 0);
    ac[0] = x;
    int prev = x;
    int i, cur;
    for (i = 1; i < n; i++) {
        cur = (prev * 1ll * prev) % m;
        if (rep[cur] != -1) break;
        rep[cur] = i;
        prev = cur;
        ans += cur;
        ac[i] = ans;
    }
    if (i != n && cur != 0) {
        long long loop = ac[i - 1];
        if (rep[cur] != 0)
            loop -= ac[rep[cur] - 1];
        ans += loop * ((n - i) / (i - rep[cur]));
        long long resto;
        if (rep[cur] - 1 + (n - i) % (i - rep[cur]) >= 0)
            resto = ac[rep[cur] - 1 + (n - i) % (i - rep[cur])];
        if (rep[cur] != 0)
            resto -= ac[rep[cur] - 1];
        ans += resto;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4508
import itertools
import copy
h,w,k=map(int,input().split())
c=[list(input()) for _ in range(h)] 
num=0
for i in range(h):
    for j in range(w):
        if c[i][j]=='#':
            num+=1
ans=0
for a in range(1,h+1):
    for b in range(1,w+1):
        l=range(1,h+1)
        m=range(1,w+1)
        for p in itertools.combinations(l, a):
            for q in itertools.combinations(m, b):
                sum=0
                d=copy.deepcopy(c)
                for i in p:
                    for j in q:
                        for s in range(w):
                            if d[i-1][s]=='#':
                                sum+=1
                                d[i-1][s]='.'
                        for t in range(h):
                            if d[t][j-1]=='#':
                                sum+=1
                                d[t][j-1]='.'
                if num-sum==k:
                    ans+=1
for a in range(1,h+1):
        l=range(1,h+1)
        for p in itertools.combinations(l, a):
            sum=0
            d=copy.deepcopy(c)
            for i in p:
                for s in range(w):
                    if d[i-1][s]=='#':
                        sum+=1
                        d[i-1][s]='.'
            if num-sum==k:
                ans+=1
for b in range(1,w+1):
        m=range(1,w+1)
        for q in itertools.combinations(m, b):
            sum=0
            d=copy.deepcopy(c)
            for j in q:
                for t in range(h):
                    if d[t][j-1]=='#':
                        sum+=1
                        d[t][j-1]='.'
            if num-sum==k:
                ans+=1
if num==k:
    ans+=1
print(ans)

Measured memory_bytes: 74880
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ll a,b,c;
  cin >> a>>b>>c;
  
  cout << (a-c)/(b+c) << endl;
}


Measured memory_bytes: 764
import sys
s = str(input())
a = 0
if len(s) == 1:
    print('No')
    sys.exit()
for i in range(len(s) - 1):
    if s[i] == 'h' and s[i + 1] == 'i':
        a += 1
if len(s) % 2 == 0:
    if a == len(s) // 2:
        print('Yes')
        sys.exit()
    else:
        print('No')
        sys.exit()
else:
     print('No')


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

int main() {
  long long h;
  cin >> h;
  int n = 0;
  
  for (int i = 0;h > 1;i++){
    h /= 2;
    n++;
  }
  
  long long ans = pow(2,n+1) - 1;

  cout << ans << endl;
}

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

using namespace std;

int BubSort(int *x, int n)
{
    int i, j, temp;

    for (i = 0; i < n - 1; i++)
    {
        for (j = n - 1; j > i; j--)
        {
            if (x[j - 1] > x[j])
            {                /* 前の要素の方が大きかったら */
                temp = x[j]; /* 交換する */
                x[j] = x[j - 1];
                x[j - 1] = temp;
            }
        }
    }
}

int main()
{
    int N,i;
    int X[101];
    cin >> N;
    for(i = 0; i < N;i++)
    {
        cin >> X[i];
    }
    BubSort(X,N-1);
    int min = X[0];
    int max = X[N-1];
    int ans_1;
    int ans_2 = 2100000000;
    for(i = 0; i <= 100; i++){
        ans_1 = 0;
        for(int j = 0;j < N;j++){
            ans_1 += (X[j]-i) * (X[j]-i);
            //cout << ans_1 << endl;
        }
        if (ans_1 < ans_2)
        {
            ans_2 = ans_1;
        }
    }
    cout << ans_2;
    return 0;
}

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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define N 3005
double dp[N][N];
vector<double> arr(N);
int n;

void solve(){

    int head=(n+1)/2;
    
    for(int x=1;x<=head;x++)  dp[0][x]=0;
    for(int i=0;i<=n;i++) dp[i][0]=1;

    for(int i=1;i<=n;i++){
        for(int x=1;x<=head;x++){
            //if(i<x) dp[i][x]=0;
            //else{
                dp[i][x]=arr[i]*dp[i-1][x-1]+(1-arr[i])*dp[i-1][x];
            //}        
        }
    }
    cout<<fixed<<setprecision(10)<<dp[n][head];




    
    
}
int32_t main(){
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++) cin>>arr[i];
    solve();

}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 5 * 10000 + 1
#define INF 10000000000
int n;

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

    cout << fixed << setprecision(12) << endl;
    cin >> n;
    vector<double> prob(n + 1); // prob[i], i heads so far. 
    prob[0] = 1;
    for (int c = 0; c < n; ++c)
    {
        double currP;
        cin >> currP;
        for (int i = c + 1; i >= 0; --i)
        {
            prob[i] *= (1 - currP);
            if (i > 0)
                prob[i] += prob[i-1] * currP;
        }
    }
    double ans = 0.0;
    for(int i = n/2 + 1; i <= n; ++i)
        ans += prob[i];
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if (N == i*j){
                cout << "Yes" << endl;
                return 0;                
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
	  int i,n,k,a[55],ans=0;
	  cin >>n >>k;
      for(i=0;i<n;i++){
      		cin >>a[i];
      		}
  	  sort(a,a+n,greater<int>());
  	for(i=0;i<k;i++){
    ans=ans+a[i];
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define pi 3.14159265358979323846264338327950L
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a+b+c==k)
        cout<<(a*1)+(c*-1)<<endl;
    else
    {
        ll sum=0;
        if(a>=k && k>0)
        {
            sum+=(1*k);
            k=0;
        }
        else if(k>0)
        {
            sum+=(1*a);
            k-=a;
        }
        if(b>=k && k>0)
        {
            k=0;
        }
        else if(k>0)
            k-=b;
        if(c>=k && k>0)
        {
            sum-=(1*k);
            k=0;
        }
        else if(k>0)
        {
            sum-=(1*c);
            k-=c;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
int main(){
	int a,b,c,d;
	double g;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d))
	{
		g=(double)a*(double)b/2.0;
		printf("%lf ",g);
		if(a=c*2&&b==d*2)
		printf("1\n");
		else
		printf("0\n");
	}
}//

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

ll mod_pow(ll x, ll n, const ll mod){
    ll ans = 1;
    while(n){
        if(n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

int main(){
    const ll mod = 1e9+7;
    int n, k; cin >> n >> k;

    ll d[k+1];
    loop(i, 1, k+1) d[i] = mod_pow(k/i, n, mod);
    for(int i = k; i > 0; i--){
        for(int j = 2*i; j < k+1; j += i){
            d[i] -= d[j];
            d[i] %= mod;
        }
    }
    ll ans = 0;
    loop(i, 1, k+1){
        ans += d[i]*i;
        ans %= mod;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	int N , A;
    cin >> N;
    int Max = 10000;
    for(int i = 0; i < N; i++){
        int count = 0;
    	cin >> A;
        while(A % 2 == 0){
        	count++;
            A /= 2;
        }
        if(Max > count){
        	Max = count;
        }
    }
    cout << Max << endl;
}


Measured memory_bytes: 3560
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize, k: usize,
      mut pa: [usize; n]
    };
    pa.sort();

    let mut ans = 0;

    for p in &pa[..k] {
        ans += p;
    }

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


Measured memory_bytes: 2204
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a;
multiset<int> st;
vector<int> vec, memo;
signed main() {
	cin >> n;
	int m = (ll)1 << n;
	rep(i, m) {
		cin >> a;
		st.insert(a);
	}
	vec.push_back(*st.rbegin());
	rep(i, n) {
		memo = vec;
		for (int j : vec) {
			if (st.lower_bound(j) == st.begin()) {
				puts("No");
				return 0;
			}
			memo.push_back(*--st.lower_bound(j));
			st.erase(--st.lower_bound(j));
		}
		vec = memo;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 15852
#include <stdio.h>

void del(int,int,int,int);

int map[50][50];

int main(){
  int i,j,w,h,cnt;
  while(1){
    for(i=0;i<50;i++){
      for(j=0;j<50;j++)map[i][j]=0;
    }
    cnt=0;
    scanf("%d%d",&w,&h);
    if(w==0&&h==0)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	scanf("%d",&map[i][j]);
      }
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(map[i][j]==1){
	  cnt++;
	  del(i,j,h,w);
	}
      }
    }
    printf("%d\n",cnt);
  }
  return 0;
}


void del(int h,int w,int height,int width){
  int i,j;
  map[h][w]=0;
  for(i=-1;i<=1;i++){
    for(j=-1;j<=1;j++){
      if((i==0 && j==0)|| h+i<0 || w+j<0 || h+i>=height || w+j>=width)continue;
      if(map[i+h][j+w]==1)del(i+h,w+j,height,width);
    }
  }
}

Measured memory_bytes: 1880
#include <iostream>
#include <map>
using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, n;
	cin >> n;


		if (n / 100 == 1)
			cout << 9;
		else cout << 1;
		n %= 100;
		if (n / 10 == 1)
			cout << 9;
		else cout << 1;
		n %= 10;
		if (n == 1)
			cout << 9;
		else cout << 1;
		
	cout <<endl;
	return 0;
}

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

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

	int n = s.size();

	// char ⇒ int の変換
	vector<int> c(n); for (int i = 0; i < n; i++) c[i] = (int)(s.at(i) - '0');
	
	int cnt_x = 0;
	int cnt_y = 0;
	
	for (int i = 0; i < n; i++) {
		
		if (i % 2 == 0) {			
			if (c[i] == 0) cnt_x++;
		}
		else {
			if (c[i] != 0) cnt_x++;
		}

		if (i % 2 == 0) {
			if (c[i] != 0) cnt_y++;
		}
		else {
			if (c[i] == 0) cnt_y++;
		}

	}
	
	cout << min(cnt_x, cnt_y) << endl;
	
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	string S;
	cin >> S;

	string str(S);
	reverse(str.begin(), str.end());
	string operation[4] = {"dreamer", "dream", "eraser", "erase"};
	for(int i=0; i<4; i++)
		reverse(operation[i].begin(), operation[i].end());

	auto it = str.begin();
	while(it != str.end())
	{
		bool ok = false;
		for(int i=0; i<4; i++)
		{
			if(str.substr(it-str.begin(), operation[i].size()) == operation[i])
			{
				it += operation[i].size();
				ok = true;
				break;
			}
		}

		if(ok != true)
			break;
	}
			
	string ret;
	if(it == str.end())
		ret = "YES";
	else
		ret = "NO";

	cout << ret << endl;

	return 0;
}


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

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnInts();
        var A = _[0];
        var B = _[1];
        for (int i = 0; i < 1050; i++)
        {
            if ((int)(0.0800001f * i) == A)
            {
                for (int n = i; n < 1050; n++)
                {
                    if ((int)(0.100001f * n) == B)
                    {
                        if (i == n)
                        {
                            print(i); return;
                        }
                    }
                }
            }
        }
        print(-1);
    }



    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin >> n;
    ll mx=0,mn=INF;
    for (ll i=0;i<n;i++){
        ll a,b;
        cin >> a >> b;
        mx=max(a,mx);
        mn=min(mn,b);
    }
    cout << mx+mn << endl;
    return 0;
}


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

#define lli long long int
#define REP(i, s, l) for (lli i = s; i < l; i++)
#define DEBUG 0
#define INF (1LL << 50)
#define MOD 1000000007

int main()
{
    int n, m; cin >> n >> m;
    vector<int> a(900);
    int l = 0;

    for(int i=0; i<n; i++){
        int k; cin >> k;
        for(int j=0; j<k; j++){
            cin >> a[l];
            l++;
        }
    }
    int cnt = 0;
    int ans = 0;
    for(int i=1; i<=m; i++){
        for(auto it=a.begin(); it!=a.end(); it++){
            if (*it == 0) break;
            if(*it==i){ 
                cnt++;
                if(cnt==n) ans++;
            }
        }
        cnt = 0;
    }
    cout << ans << endl;
    



    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<math.h>
#include<algorithm>
#include<string>
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> >
#define vb vector<bool> 
#define vvb vector<vector<bool> >
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b:i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define INF 1123456789012345
using namespace std;

int main(){
	ll a,b; cin>>a>>b;
	if(a+b>=10) cout<<"error"<<endl;
	else cout<<(a+b)<<endl;
	return 0;
}

Measured memory_bytes: 256
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;
using namespace std;

int main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if(a == 0) cout << 1 << endl;
    if(b == 0) cout << 2 << endl;
    if(c == 0) cout << 3 << endl;
    if(d == 0) cout << 4 << endl;
    if(e == 0) cout << 5 << endl;
}


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

long long x,y,z,n,m,k,sum;
priority_queue<long long> pq1,pq2,pq3;

int main() {
	cin >> x >> y >> z >> n >> m;
	for (int a = 0; a < z; a++) {
		scanf("%lld",&k);
		pq1.push(k);
	}
	for (int a = 0; a < n; a++) {
		scanf("%lld",&k);
		pq2.push(k);
	}
	for (int a = 0; a < m; a++) {
		scanf("%lld",&k);
		pq3.push(k);
	}
	for (int a = 0; a < x; a++) {
		pq3.push(pq1.top());
		pq1.pop();
	}
	for (int a = 0; a < y; a++) {
		pq3.push(pq2.top());
		pq2.pop();
	}
	for (int a = 0; a < x+y; a++) {
		sum += pq3.top();
		pq3.pop();
	}
	cout << sum << "\n";
}

Measured memory_bytes: 8048
#include<bits/stdc++.h>
using namespace std;
int n;
long long dp[100005][2];
vector<int> g[100005];
void dfs(int x,int pre)
{
	dp[x][0]=1;
	dp[x][1]=1;
	for(int i=0;i<g[x].size();i++)
		if(g[x][i]!=pre)
		{
			dfs(g[x][i],x);
			dp[x][0]*=(dp[g[x][i]][0]+dp[g[x][i]][1]);
			dp[x][0]%=1000000007;
			dp[x][1]*=dp[g[x][i]][0];
			dp[x][1]%=1000000007;
		}
}
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%1000000007<<endl;
	return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int a, b;

int main()
{
  while (scanf("%d %d", &a, &b) != EOF)
  {
    int ans;
    for (ans; ans < 1e7; ans ++)
    {
      DEBUG printf("%d - %d %d\n", ans, (int)(ans * 8 / 100.0), (int)(ans / 10.0));
      if ((int)(ans * 8 / 100.0) == a && (int)(ans / 10.0) == b)
        break;
    }
    if (ans == 1e7) ans = -1;
    printf("%d\n", ans);
  }
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

int dp[4000][4000];
int li[4000][4000];
int lj[4000][4000];

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
                li[i][j] = i - 1;
                lj[i][j] = j - 1;
            } else {
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    dp[i][j] = dp[i - 1][j];
                    li[i][j] = i - 1;
                    lj[i][j] = j;
                } else {
                    dp[i][j] = dp[i][j - 1];
                    li[i][j] = i;
                    lj[i][j] = j - 1;
                }
            }
        }
    }
    int x = n, y = m;
    vector<char> ans;
    while (x != 0 && y != 0) {
        int i = li[x][y];
        int j = lj[x][y];
        if (i != x && j != y) {
            ans.push_back(s[i]);
        }
        x = i;
        y = j;
    }
    reverse(ans.begin(), ans.end());
    for (char &i : ans) {
        cout << i;
    }
}


Measured memory_bytes: 143616
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] chars = S.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            char ch = chars[i];
            if ((i + 1) % 2 == 0) {
                //if (!(ch == 'L' || ch == 'U' || ch == 'D')) {
                if (ch == 'R') {
                    System.out.print("No");
                    return;
                }
            }
            else {
                // if (!(ch == 'R' || ch == 'U' || ch == 'D')) {
                if (ch == 'L') {
                    System.out.print("No");
                    return;
                }
            }
        }
        System.out.print("Yes");
    }

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

Measured memory_bytes: 23892
n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

visited = [-1 for i in range(n+1)] # 訪れていたら訪れたときの添字を格納する。
points = []
p = 1
while visited[p] == -1:
  visited[p] = len(points)
  points.append(p)
  p = a[p-1] #添字に直す

T = len(points) - visited[p]
s = visited[p]

if k < s:
  print(points[k])
else:
  mod = (k - s) % T
  print(points[s+mod])
  


Measured memory_bytes: 32324
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

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

    static class CForbiddenList {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt(), n = in.nextInt();
            int[] p = in.readIntArray(n);

            TreeSet<Integer> allowed = new TreeSet<>();
            for (int i = 0; i <= 101; i++)
                allowed.add(i);
            for (int i : p)
                allowed.remove(i);

            int answer = allowed.floor(x);
            if (allowed.ceiling(x) - x < x - answer)
                answer = allowed.ceiling(x);

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }
}



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

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

    // a = h - x, b = h + t - x so a + b = 2h - 2x + t
    // b - a = t
    int t = b - a;
    int height = t * (t - 1) * 0.5;

    // a = t * (t-1) *0.5 - x;
    // x = h - a;
    int snow = height - a;
    cout << snow;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _;
    cin >> _;
    while(_--){
        string S;
        cin >> S;
        int N = S.size();
        set<string> str;
        for(int i=1; i<N; i++){
            string A = S.substr(0,i);
            string B = S.substr(i);
            string A_r = A;
            string B_r = B;
            reverse(A_r.begin(),A_r.end());
            reverse(B_r.begin(),B_r.end());
            str.insert(A+B);
            str.insert(A_r+B);
            str.insert(A+B_r);
            str.insert(A_r+B_r);
            str.insert(B+A);
            str.insert(B_r+A);
            str.insert(B+A_r);
            str.insert(B_r+A_r);
        }
        // for(auto s: str){
        //     cout << s << endl;
        // }
        cout << str.size() << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    string S; cin>>S;
    int cnt0=0,cnt1=0;
    rep(i,S.size()){
        if(S[i]=='0')cnt0++;
        else cnt1++;
    }
    int mn =min(cnt1,cnt0);
    cout<<mn*2<<endl;
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
int i;
#define rep2(i, a, b) for(i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
using namespace std;
// _________コーディングはここから！！___________
template <const int sz = 5 * 10000000, typename T = long long> struct IO {
    char reader[sz], writer[sz];
    char *now, *now2 = writer;
    IO() {
        reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
        now = reader;
    }
    inline T read() {
        while(*now && *now <= 32) now++;
        if(*now == '-') {
            now++;
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return -res;
        } else {
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return res;
        }
    }
    inline string read_str() {
        string res;
        while(*now and *now != '\n' and *now != ' ') res += *now++;
        now++;
        return res;
    }
    inline void write(T x, char margin = ' ') {
        if(x == 0) {
            putchar('0');
            putchar(margin);
            return;
        }
        if(x < 0) {
            putchar('-');
            x = -x;
        }
        while(x) {
            *now2 = '0' + x % 10;
            now2++;
            x /= 10;
        }
        do {
            now2--;
            putchar(*now2);
        } while(now2 != writer);
        putchar(margin);
    }
    inline void write_str(string s, char margin = ' ') {
        for(auto c : s) putchar(c);
        putchar(margin);
    }
};
IO io;
inline int read() { return io.read(); }
inline void write(int x) { io.write(x); }
inline void write(int x, char c) { io.write(x, c); }
constexpr int N = 500003;
int c[N];
struct T {
    int l, r, idx;
    constexpr bool operator<(const T &rhs) const noexcept { return r < rhs.r; }
} q[N];
int ans[N], last[N], dat[N];

inline void dec(int k) {
    for(++k; k < N; k += k & -k) --dat[k];
}
inline int sum(int k) {
    int res = 0;
    for(++k; k > 0; k -= k & -k) res += dat[k];
    return res;
}
int n, Q, now = 1;

// 頑張れ！！
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
// 頑張れ！！

main() {
    n = read(), Q = read();
    rep2(i, 1, n) c[i] = read();
    rep(i, Q) q[i].l = read(), q[i].r = read() + 1, q[i].idx = i;
    sort(q, q + Q);
    rep(i, Q) {
        for(; now < q[i].r; ++now) {
            if(last[c[now]]) dec(last[c[now]]);
            last[c[now]] = now;
        }
        ans[q[i].idx] = sum(q[i].r - 1) - sum(q[i].l - 1) + q[i].r - q[i].l;
    }
    rep(i, Q) write(ans[i], '\n');
}


Measured memory_bytes: 26772
<?php

while (true) {
    list($h, $w) = getStdinExplodedBy();
    if ($h == 0 && $w == 0) {
        break;
    }
    while ($h--) {
        echo str_repeat('#', $w), PHP_EOL;
    }
    echo PHP_EOL;
}

function getStdinExplodedBy($delimiter = ' ')
{
    return explode($delimiter, trim(fgets(STDIN)));
}

Measured memory_bytes: 15396
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
 
bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

signed main(){
	int a[3];cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]==a[2]){
		cout<<1<<endl;
	}else if(a[0]!=a[1]&&a[1]!=a[2]){
		cout<<3<<endl;
	}else {
		cout<<2<<endl;
	}
}


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

int main(){
	int a;
	char ca;
	cin>>ca;
	a=int(ca);
	if(int('a')<=ca && int('z')>=ca) cout<<'a'<<endl;
	else if(int('A')<=ca && int('Z')>=ca) cout<<'A'<<endl;
}

Measured memory_bytes: 3644
# cook your dish here
a,b,c = map(int, input().split())
k = int(input())
c1, c2 = 0, 0
while b<=a:
    b=b*2
    c1 = c1 + 1
while c <= b:
    c=c*2
    c2 = c2 +1
if c1 + c2 <= k:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define repm(i,a,b) for(ll i=(ll)(a);i>(ll)(b);i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb =vector<bool>;
using vvb=vector<vb>;
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; }
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    ll n;
    cin >> n;
    vll a(n);
    vll d(1100001,0);
    rep(i, n){
        cin >> a[i];
        d[a[i]]+=1;
    }
    ll count=0;
    rep(i,n){
        vll ret;
        ret=divisor(a[i]);
        bool flag=false;
        rep(j,ret.size()){
            if(d[ret[j]]!=0&&(j!=(ll)(ret.size()-1)||d[ret[j]]>1)){
                flag=true;
                break;
            }
        }
        if(flag) continue;
        count++;
    }
    cout << count << endl;
}

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

int main() {
    string s, t;
    cin >> s >> t;

    // longest ending at pos i 
    vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));
    vector<vector<pair<int, int>>> prev(s.size() + 1, vector<pair<int, int>>(t.size() + 1));

    for (int i = 1; i <= s.size(); i++) {
        int s_idx = i - 1;
        for (int j = 1; j <= t.size(); j++) {
            int t_idx = j - 1;
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (dp[i - 1][j] > dp[i][j - 1])
                prev[i][j] = {i - 1, j};
            else
                prev[i][j] = {i, j - 1};

            if (s[s_idx] == t[t_idx]) {
                if (dp[i - 1][j - 1] + 1 > dp[i][j])
                    prev[i][j] = {i - 1, j - 1};

                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            }
        }
    }

    string ans = "";
    int x = s.size();
    int y = t.size();

    // want to go to curr - 1, and if not possible, curr
    while (dp[x][y] > 0) {
        pair<int, int> & p = prev[x][y];
        if (dp[x][y] != dp[p.first][p.second]) {
            ans += s[x - 1];
        }

        x = p.first;
        y = p.second;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}



Measured memory_bytes: 105984
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define EPS (1e-10)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1 
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;

//

class Point
{
  public:
  double x,y;

  Point(double x = -1,double y = -1): x(x),y(y){}

  Point operator + (Point p ){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}//※イケメンに限る

  bool operator < (const Point& p) const
  { return x != p.x?x<p.x:y<p.y; }

  bool operator == (const Point& p)const
  { return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS; }

};

struct Segment
{
  Point p1,p2;
  Segment(Point p1 = Point(-1,-1),Point p2 = Point(-1,-1)):p1(p1),p2(p2){}
};

typedef Point Vector;
typedef Segment Line;
typedef vector<Point> Polygon;

ostream& operator << (ostream& os,const Point& a)
{
  os << "(" << a.x << "," << a.y << ")";
}

double dot(Point a,Point b){ return a.x*b.x + a.y*b.y; }

double cross(Point a,Point b){ return a.x*b.y - a.y*b.x; }

double norm(Point a){ return a.x*a.x+a.y*a.y; }

double abs(Point a){ return sqrt(norm(a)); }

Point rotate(Point a,double rad){ return Point(cos(rad)*a.x - sin(rad)*a.y,sin(rad)*a.x + cos(rad)*a.y); }

double toRad(double agl){ return agl*M_PI/180.0; }

//

struct Node
{
  Point p;
  double v;
  Node(Point p=Point(),double v=inf):p(p),v(v){}
};

int N;

void compute(vector<Node> &vec)
{
  Point cur = vec[0].p;
  //cout << "(" << cur.x << "," << cur.y << ")\n";
  double eps = 0.98,d = 10000;
  double mdist;
  while(d > EPS)
    {
      int index = -inf;
      mdist = -inf;
      rep(j,vec.size())
	{
	  double dist = abs(vec[j].p-cur) / vec[j].v;
	  if(!equals(mdist,dist) && mdist < dist)
	    {
	      mdist = dist;
	      index = j;
	    }
	}
      
      Vector dept = vec[index].p - cur;
      dept = (dept/abs(dept)) * d;
      cur = cur + dept;
      d *= eps;
    }

  cout << setiosflags(ios::fixed) << setprecision(10) << mdist << endl;

}

int main()
{
  while(cin >> N,N)
    {
      vector<Node> vec(N);
      rep(i,N)cin >> vec[i].p.x >> vec[i].p.y >> vec[i].v;
      compute(vec);
    }
  return 0;
}

Measured memory_bytes: 1292
def main():
    n = int(input())
    rs = [int(input()) for _ in range(n)]
    result = -2000000000000
    history_min = rs[0]
    for r in rs[1:]:
        result = max(result, r - history_min)
        history_min = min(history_min, r)
    print(result)
        


if __name__ == '__main__':
    main()


Measured memory_bytes: 14944
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}
constexpr int mxN = 1e5+4;
bool prime_bool[mxN+1];
vi prime_list;
void complete_prime(){
    for(int i = 0 ; i < mxN ; i++){
        prime_bool[i] = ( i % 2 == 0) ? false : true; 
    }
    prime_bool[2] = true;
    prime_list.push_back(2);
    int current_index = 0;
    for(int i = 3; i < mxN ; i++){
        if(prime_bool[i] == false){
            continue;
        }else{
            //found new prime
            prime_list.push_back(i);
            for(int j = 2 ; j <= mxN / i ; j++){
               prime_bool[i * j] = false; 
            }
        }
    }
}
void solve(){
    complete_prime();
    int x;
    cin >> x;
    auto it = lower_bound(prime_list.begin(), prime_list.end(), x);
    cout << *it;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

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

static const int maxsize = 100;

void showSeq(int a[],int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0)cout << " ";
		cout << a[i];
	}
	cout << endl;
}


int main()
{
	int N, a[maxsize];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int num=0;
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				int temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
				num++;
			}
		}
	}
	showSeq(a, N);
	cout << num << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N;
    cin >> N;
    int a[N+1];
    vector<int> edge[N+1];
    rep2(i, 2, N+1){
        cin >> a[i];
        edge[a[i]].push_back(i);
    }
    queue<int> que;
    int dep[N+1];
  	int cnt[N+1];
  	fill_n(cnt, N+1, 0);
    rep2(i, 1, N+1){
        if(edge[i].size() == 0){
            dep[i] = 0;
            que.push(i);
        }
    }
    while(!que.empty()){
        int i = que.front();
        que.pop();
        if(i == 1) break;
        int j = a[i];
        int n = edge[j].size();
      	cnt[j]++;
        if(cnt[j] < n) continue;
        int d[n];
        rep(k, n) d[k] = dep[edge[j][k]];
        sort(d, d+n, greater<int>());
        dep[j] = 0;
        rep(k, n){
            dep[j] = max(dep[j], d[k]+k+1);
        }
        que.push(j);
    }
    cout << dep[1] << endl;
}

Measured memory_bytes: 6912
#include "bits/stdc++.h"
using namespace std;
#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 MOD 1000000007
const long long mod = 1e9+7;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main(){
    VI c(9);
    VI a(3);
    VI b(3);
    REP(i,9){
        cin >> c[i];
    }
    a[0] = 0;
    REP(j,3){
        b[j] = c[j] - a[0];
    }
    for(int i = 1; i < 3; i++)
    {
        a[i] = c[i*3] - b[0];
    }
    int k=0;
    REP(i,3){
        REP(j,3){
            if ( c[k] != a[i] + b[j]){
                cout << "No" <<endl;
                return 0;
            }
            k++;
        }
    }
    cout << "Yes" <<endl;
    return 0;
}
   


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,sum=0; cin>>n;
    for(int i=0;i<n;++i){
	cin>>a;
	int cnt=0;
	while(a%2==0){
	    a/=2;
	    ++cnt;
	}
	sum+=cnt;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define endc printf("\n")

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

//const int maxn = 2e5 + 7; 
const int md = 1e9 + 7;

int main() {
	IOS;	
	int n; cin>>n;
	string s,t; cin>>s>>t; s = " "  + s; t = " " + t; s += "$"; t += "$";
	int i = 1; ll ans = 1; int last = 0;
	while (i <= n) {
		if (s[i] == t[i]) {
			ans = (ans * (last == 0 ? 3 : ((last == 1) ? 2 : 1)))%md;
			last = 1; i++;
		} else {
			ans = (ans * (last == 0 ? 6 : ((last == 1) ? 2 : 3)))%md;
			last = 2; i+=2;
		}
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 256