akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func main() {
	matrix := make([]string, 3)
	for i := 0; i < 3; i++ {
		fmt.Scan(&matrix[i])
	}
	// fmt.Println(matrix)
	for i := 0; i < 3; i++ {
		fmt.Print(string(matrix[i][i]))
	}
	fmt.Println()
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define LEN 1000000
  
typedef struct pp{
  char name[100];
  int t;
}P;
 
P Q[LEN+1];
  
int main(){
  int n, i, q, sum =0, last, cnt=0;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  i = 1;
  last = n;
  while(1){
    if(Q[i].t > q){
      sum += q;
      strcpy(Q[last+1].name, Q[i].name);
      Q[last+1].t = Q[i].t - q;
      last++;
    } else {
      sum += Q[i].t;
      printf("%s %d\n", Q[i].name, sum);
      cnt++;
    }
    i++;
    if(cnt == n) break;
  }   
  return 0;
}


Measured memory_bytes: 20948
#include <stdio.h>

int main(){
	double a,b,c,d,e,f;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)>0){
			f=(f-c/a*d)/(e-b/a*d);
			c=c/a-f*b/a;
			printf("%.3f %.3f\n",c,f);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	int n;
	int mx = 0, mn = 1e9;
	cin >> n;
	rep(i, n){
		int a;
		cin >> a;
		ckmax(mx, a);
		ckmin(mn, a);
	}
	cout << mx - mn;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

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

int main() {

	int r;
	cin >> r;

	if( r < 1200 )
	{
		cout << "ABC" << endl;
		return 0;
	}

	if( r < 2800 )
	{
		cout << "ARC" << endl;
		return 0;
	}

	cout << "AGC" << endl;

	return 0;
}


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

using namespace std;

#define ll long long

int main(void){
    ll n;
    cin >> n;
    ll ans;

    for(ll i = 1;i < sqrt((double)n)+1;++i){
        if(n%i == 0){
            ans = i-1 + n/i -1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int W, H, N;
void func()
{
    cin>>W>>H>>N;
    int x[N], y[N], a[N];
    rep(i, 0, N) {
        cin>>x[i]>>y[i]>>a[i];
    }
    int ans=W*H;
    int p1=0, p2=W, p3=0, p4=H;
    rep(i, 0, N) {
        if (a[i]==1) {
            p1=(x[i]>p1)?x[i]:p1;
        }
        else if (a[i]==2) {
            p2=(x[i]<p2)?x[i]:p2;
        }
        else if (a[i]==3) {
            p3=(y[i]>p3)?y[i]:p3;
        }
        else if (a[i]==4) {
            p4=(y[i]<p4)?y[i]:p4;
        }
        if (p2<p1 || p4<p3) {
            ans=0;
        }
        else {
            ans=(p2-p1)*(p4-p3);
        }
    }
    cout<<ans<<endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    ll res1, res2;
    res1 = res2 = 0;
    vector<ll> a;
    bool f = true; // 次は正
    for (int i = 0; i < n; i++) {
        ll ai;
        cin >> ai;
        a.push_back(ai);
    }

    // 足して正
    f = false;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (f) {
            if (sum > 0) {
                f = false;
            } else {
                res1 += abs(sum - 1);
                sum = 1;
                f = false;
            }
        } else {
            if (sum < 0) {
                f = true;
            } else {
                res1 += sum + 1;
                sum = -1;
                f = true;
            }
        }
    }

    sum = 0;
    f = true;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (f) {
            if (sum > 0) {
                f = false;
            } else {
                res2 += abs(sum - 1);
                sum = 1;
                f = false;
            }
        } else {
            if (sum < 0) {
                f = true;
            } else {
                res2 += sum + 1;
                sum = -1;
                f = true;
            }
        }
    }
    cout << min(res1, res2) << endl;
	return 0;
}

Measured memory_bytes: 1400
x , a , b = gets.split()
x = x.to_i
a = a.to_i
b = b.to_i

distanceA = "#{a - x}".to_i.abs
distanceB = "#{b - x}".to_i.abs

if distanceA < distanceB
  puts "A"
elsif distanceA > distanceB
  puts "B"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
     int D,N;
     cin >> D >> N;
     if(D == 0 && N < 100) cout << N << endl;
     else if(D == 1 && N < 100) cout << N*100 << endl;
     else if((D == 2 && N < 100)) cout << N*10000 << endl;
     else if(D == 0 && N == 100) cout << N + 1 << endl;
     else if(D == 1 && N == 100) cout << (N + 1)*100 << endl;
     else cout << (N + 1)*10000 << endl;
}

Measured memory_bytes: 256
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
 use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;

procedure main is
   N: Integer;
   M: Integer;
begin
   get(N);
   get(M);
   if (N = M) then put_line("Yes");
   else put_line("No");
   end if;
end main;

Measured memory_bytes: 3688
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()

    if N % 2 == 0:
        ans = A[N // 2] - A[N // 2 - 1]
        for i in range(N // 2 - 1):
            ans -= 2 * A[i]
        for i in range(N // 2 + 1, N):
            ans += 2 * A[i]
    else:
        ans1 = -A[N // 2] - A[N // 2 - 1]
        for i in range(N // 2 - 1):
            ans1 -= 2 * A[i]
        for i in range(N // 2 + 1, N):
            ans1 += 2 * A[i]

        ans2 = A[N // 2] + A[N // 2 + 1]
        for i in range(N // 2):
            ans2 -= 2 * A[i]
        for i in range(N // 2 + 2, N):
            ans2 += 2 * A[i]

        ans = max(ans1, ans2)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 7524
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        
        int last = str.length();
        
        if(str.charAt(last - 1) == 's'){
            System.out.println(str.substring(0,last) + "es");
        }else{
            System.out.println(str + "s");
        }
    }
}


Measured memory_bytes: 38488
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100001;
int n,m;
vector<vector<int>> vec(N);
int dp[N];
int solve(int i)
{
   if(dp[i]!=-1)return dp[i];
   else
   {
       if(vec[i].size()==0)dp[i]=0;
       else
       {
           for(int j=0;j<vec[i].size();j++)
           {
               dp[i]=max(dp[i],1+solve(vec[i][j]));
           }
       }
       return dp[i];
   }
}
int main()
{
    for(int i=0;i<N;i++)dp[i]=-1;
cin>>n>>m;
for(int i=0;i<m;i++)
{
    int x,y;cin>>x>>y;
    vec[x].push_back(y);
}
int ans=0;
for(int i=1;i<=n;i++)
{
    ans=max(ans,solve(i));
    
}
cout<<ans<<endl;
}
  


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

int main() {
  int N;
  cin >> N;
  string ans = "No";

  for (int i = 1; i <= 9; i++) {
    if (!(N % i) && N / i <= 9) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector <int> adj[200009];
queue <int> q;
vector <bool> used(200005);
vector <int> d(200005), p(200005);

void bfs(void){
	q.push(1);
	used[1] = true;
	p[1] = -1;
	d[1] = 0;
	int i, v;
	while(!q.empty()){
		v = q.front();
		q.pop();
		for(i=0; i<adj[v].size(); i++){
			if(!used[adj[v][i]]){
				used[adj[v][i]] = true;
				d[adj[v][i]] = d[v] + 1;
				p[adj[v][i]] = v;
				q.push(adj[v][i]);
			}
		}
	}

}

int main()
{
	int n, m, i, j, x, y, fl = 0;
	cin >> n >> m;
	for(i=0; i<m; i++){
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for(i=1; i<=n; i++){
		used[i] = false;
		p[i] = -1;
	}
	bfs();
	for(i=2; i<=n; i++)
		if (p[i] == -1)
			fl = 1;
	if (fl == 1)
		cout << "No" << endl;
	else{
		cout << "Yes" << endl;
		for(i = 2; i <= n; i++)
			cout << p[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 13816
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll N;
    cin >> N;
    ll out = (1000 - N%1000)%1000;
    cout << out << endl;
    return 0;
}



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

const double inf = 1e10;

int main() {
  for(int r, n; cin >> r >> n && (r|n); ) {
    vector<int> hs(2 * r);
    for(int i = 0; i < n; ++i) {
      int a, b, h;
      cin >> a >> b >> h;
      a += r; b += r;
      for(int j = a; j < b; ++j) {
        if(0 <= j && j < hs.size()) {
          hs[j] = max(hs[j], h);
        }
      }
    }
    double t = inf;
    for(int j = 1; j < hs.size(); ++j) {
      double x = j - r;
      t = min(t, (double)min(hs[j-1], hs[j]) + r - sqrt(r*r - x*x));
    }
    printf("%.10f\n", t);
  }
  return 0;
}

Measured memory_bytes: 1228
// -*- coding:utf-8-unix -*-

use proconio::input;

// v[i] > k を満たす最小の i を返す (or k より小さい v の要素数)
// 見つからなければ `v.len()` を返す
// `v` はソートされていること
fn lower_bound_ne(v: &[usize], k: usize) -> usize {
    let mut low: isize = -1;
    let mut high = v.len() as isize;

    while high - low > 1 {
        let mid = (low + high) / 2;
        if v[mid as usize] > k {
            high = mid;
        } else {
            low = mid;
        }
    }
    high as usize
}

// v[i] >= k を満たす最小の i を返す (or k より小さい v の要素数)
// 見つからなければ `v.len()` を返す
// `v` はソートされていること
fn lower_bound_eq(v: &[usize], k: usize) -> usize {
    let mut low: isize = -1;
    let mut high = v.len() as isize;

    while high - low > 1 {
        let mid = (low + high) / 2;
        if v[mid as usize] >= k {
            high = mid;
        } else {
            low = mid;
        }
    }
    high as usize
}

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
        b: [usize; n],
        mut c: [usize; n],
    }

    a.sort();
    c.sort();
    let mut ans = 0;
    for i in 0..n {
        let a_idx = lower_bound_eq(&a[..], b[i]);
        if a_idx == n && a[n - 1] >= b[i] {
            continue;
        }

        let c_idx = lower_bound_ne(&c[..], b[i]);
        if c_idx == n {
            continue;
        }

        // println!("a_idx: {}, b: {}, c_idx: {}", a_idx, b[i], c_idx);
        // println!("{}", a_idx * (n - c_idx));
        ans += a_idx * (n - c_idx);
    }
    println!("{}", ans);
}


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

using namespace std;

using ll = long long;

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

bool compare(ll x, ll y) {
    if (x * sum(y) <= y * sum(x)) return false;
    return true;
}

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

    ll K;
    cin >> K;

    ll cur = 0, add = 1;
    for (int i = 0; i < K; ++i) {
        if (compare(cur + add, cur + 10 * add)) add *= 10;
        cur += add;
        cout << cur << '\n';
    }

    return 0;
}


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

signed main() {
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; ++i)cin >> d[i];
	sort(d.begin(), d.end());
	int l = d[n / 2 - 1];
	int u = d[n / 2];
	cout << u - l << endl;
}


Measured memory_bytes: 1024
h, n = map(int, input().split())
ab = []
for _ in range(n):
    ab.append(map(int, input().split()))

m = 20010
dp = [1000000000] * m
dp[0] = 0
for a, b in ab:
    for i in range(m):
        if i - a >= 0:
            dp[i] = min(dp[i], dp[i - a] + b)
print(min(dp[h:]))


Measured memory_bytes: 68468
H, W = map(int, input().split())
s = 0
for _ in range(H):
    S = input().rstrip() + "."
    a0 = "."
    A = []
    for i, a in enumerate(S):
        if a==a0:
            continue
        else:
            A.append(i)
        a0 = a
    if len(A) > 2:
        print("Impossible")
        exit()
    if s != A[0]:
        print("Impossible")
        exit()
    s = A[1]-1
print("Possible")

Measured memory_bytes: 61932
import sys
sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    N,K=MI()
    ans=0
    for b in range(K+1,N+1):
        ans+=((N+1)//b)*(b-K)
        ans+=max((N+1)%b-K,0)
        #print(b,((N+1)//b)*(b-K),max((N+1)%b-K,0))
    if K==0:
        ans=N*N
        
        
    print(ans)
    
            
    


main()

Measured memory_bytes: 39024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;


class Networkflow {
private:
	struct edgedata {
		int to, weight, capacity;
		edgedata* dual_p;
	};
	struct node {
		int id;
		bool done;
		list<edgedata> edge;
	};
	vector<node> nodes;
	int n;
	int source, sink;
public:
	int result;
	Networkflow(vector<vector<pair<int, P>>> data, int s, int t) {
		n = data.size();
		source = s;
		sink = t;
		nodes.resize(n);
		Loop(i, n) {
			nodes[i] = { i, false, {} };
		}
		edgedata* dummy = new edgedata;
		Loop(i, n) {
			Loop(j, data[i].size()) {
				nodes[i].edge.push_back({
					data[i][j].first,
					data[i][j].second.first,
					data[i][j].second.second,
					dummy
				});
				nodes[data[i][j].first].edge.push_back({
					i,
					data[i][j].second.first,
					0,
					&(nodes[i].edge.back())
				});
				nodes[i].edge.back().dual_p = &(nodes[data[i][j].first].edge.back());
			}
		}
		delete dummy;
	}
	void maxflow() {
		result = 0;
		stack<pair<int, edgedata*>> stk;
		int a; // the node which is focused on
		while (1) {
			a = source;
			Loop(i, n) nodes[i].done = false;
			nodes[source].done = true;
			while (a != sink) {
				int b = -1;
				edgedata* p;
				for (auto itr = nodes[a].edge.begin(); itr != nodes[a].edge.end(); ++itr) {
					if ((*itr).capacity > 0) {
						b = (*itr).to;
						if (nodes[b].done) b = -1;
						else {
							p = &(*itr);
							stk.push(make_pair(a, p));
							nodes[b].done = true;
							a = b;
							break;
						}
					}
				}
				if (b == -1) {
					if (stk.empty()) break;
					a = stk.top().first;
					stk.pop();
				}
			}
			if (stk.empty()) break;
			while (stk.size()) {
				(*(stk.top().second)).capacity--;
				(*((*(stk.top().second)).dual_p)).capacity++;
				stk.pop();
			}
			result++;
		}
		return;
	}
};

int main() {
	int v, e;
	cin >> v >> e;
	vector<vector<pair<int, P>>> data(v);
	Loop(i, e) {
		int u, v, c; cin >> u >> v >> c;
		data[u].push_back(make_pair(v, make_pair(1, c)));
	}
	Networkflow networkflow(data, 0, v - 1);
	networkflow.maxflow();
	cout << networkflow.result << endl;
	return 0;
}

Measured memory_bytes: 3232
#include <stdio.h>

int main(void)
{
    int n, i;
    int x;
    int a, b;
    int j;
    int f;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        a = b = 0;
        f = 1;
        for (j = 0; j < 10; j++) {
            scanf("%d", &x);
            if (x > a && x > b) {
                if (a > b) {
                    a = x;
                } else {
                    b = x;
                }
            } else if (x > a) {
                a = x;
            } else if (x > b) {
                b = x;
            } else {
                f = 0;
            }
        }
        printf("%s\n", f ? "YES" : "NO");
    }

    return 0;
}

Measured memory_bytes: 580
#import<bits/stdc++.h>
#define LL long long
using namespace std;
LL a,b,c,i,j,k,m,n,s,t,x,y,z[2040][2040];
int dgs(int x){int s=0;for(;x;x/=10)s+=x%10;return s;}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int max2(int x,int y){return x>y?x:y;}
int max3(int x,int y,int z){return x>y?x>z?x:z:y>z?y:z;}
int min2(int x,int y){return x<y?x:y;}
int min3(int x,int y,int z){return x<y?x<z?x:z:y<z?y:z;}
int prime(int x){if(x<2||x%6^1&&x%6^5)return x==2|x==3;for(int i=5;i*i<=x;i+=6)if(x%i<1||x%(i+2)<1)return 0;return 1;}
main()
{
scanf("%lld%lld",&n,&k);
for(z[0][0]=1;i++<=n;)for(j=0;j<=i;j++)z[i][j]=j?(z[i-1][j-1]+z[i-1][j])%1000000007:1;
for(i=0;i++<k;)printf("%lld\n",z[k-1][k-i]*z[n-k+1][n-k-i+1]%1000000007);
//printf("%lld",z[4][2]);
}

Measured memory_bytes: 30720
n, a, b = map(int, input().split())
s = list(input())
b_count = 1
t = 0
for i in range(n):
    if s[i] == "a":
        if t < a+b:
            print("Yes")
            t += 1
        else:
            print("No")
    elif s[i] == "b":
        if t < a+b:
            if b_count <= b:
                print("Yes")
                b_count += 1
                t += 1
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4712
n,m = gets.chomp.split(" ").map(&:to_i)
k = []
s = Array.new{Array.new}
m.times do |i|
  s[i] = gets.chomp.split(" ").map(&:to_i)
end
p = gets.chomp.split(" ").map(&:to_i)
ans = 0
[0,1].repeated_permutation(n).each do |x|
  on = true
  m.times do |i|
    cnt = 0
    s[i][0].times do |j|
      cnt += 1 if x[s[i][j+1]-1] == 1
    end
    if cnt % 2 != p[i]
      on = false
    end
  end
  if on
    ans += 1
  end
end
puts ans


Measured memory_bytes: 14364
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] cin = Console.ReadLine().Split();
        int t = int.Parse(cin[0]);
        int x = int.Parse(cin[1]);

        Console.WriteLine((double)t / x);
    }
}

Measured memory_bytes: 11092
N = gets.to_i
h = gets.split(" ").map(&:to_i)
count = 0

while h != [] do
    while h[0] == 0 do
    h.shift 
    end
    h.size.times do |i|
        count += 1 if i == 0
        h[i] -= 1 if h[i] > 0
        break if h[i + 1] == 0
    end
end

puts count 

Measured memory_bytes: 1788
s=input()
x,y=map(int,input().split())
lx=[]
ly=[]
t=0
k=0
for i in s:
    if i=="F":
        t+=1
    else:
        if k:
            ly.append(t)
            k=0
        else:
            lx.append(t)
            k=1
        t=0
if k:
    ly.append(t)
else:
    lx.append(t)
x-=lx.pop(0)
sx,sy=sum(lx),sum(ly)
dx=[0]*(sx*2+1)
dy=[0]*(sy*2+1)
dx[0],dy[0]=1,1
for i in lx:
    t=[0]*(sx*2+1)
    for j in range(-sx,sx+1):
        if dx[j]:
            t[i+j]=1
            t[j-i]=1
    dx=t
for i in ly:
    t=[0]*(sy*2+1)
    for j in range(-sy,sy+1):
        if dy[j]:
            t[i+j]=1
            t[j-i]=1
    dy=t
if sx>=abs(x) and sy>=abs(y) and dx[x] and dy[y]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 47068
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    vint idx[10];
    rep(i, n) idx[s[i]-'0'].push_back(i);

    int ans = 0;
    rep(i, 1000) {
        string p = to_string(i);
        while(p.length() < 3) p = '0'+p;
        int id = -1;
        bool c1 = true;
        rep(j, 3) {
            bool c2 = false;
            for (int x : idx[p[j]-'0']) {
                if (x > id) {
                    id = x;
                    c2 = true;
                    break;
                }
            }
            if (!c2) c1 = false;
        }
        if (c1) ans++;
    }

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

Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

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

int main() {
	
	int n;
    string s,t,u;
    cin>>n>>s>>t>>u;
    int ans=0;
    REP(i,n){
        int cnt=0;
        if(s[i]==t[i]){
            cnt++;
        }
        if(t[i]==u[i]){
            cnt++;
        }
        if(u[i]==s[i]){
            cnt++;
        }
        if(cnt==0){
            ans+=2;
        }
        else if(cnt==1){
            ans++;
        }
    }
	
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define SOBA_MAX    51  /* ?????°?????\???????????§(????????????????????§50(?????§?????\???)?????§??¨?????????????´???°???51) */
#define PATTERN_MAX 6   /* ????????????????????°????????????????????¨?????¨???????????????????????????????????????????????? */

#define MAX_VAL 10000000 /* ??£?????????????????????????????§???????????§????????????DP????????????????????¨??? */

/* ?????\????????¨???????????????????????? */
const int pattern[PATTERN_MAX][2] = {
    {   200  /100,  380             }
    ,{  200*5/100,  380*5*80/100    }
    ,{  300  /100,  550             }
    ,{  300*4/100,  550*4*85/100    }
    ,{  500  /100,  850             }
    ,{  500*3/100,  850*3*88/100    }
};

int memo[SOBA_MAX];

int dfs(int soba){
    int pat;
    int min;
    int val;

    if(memo[soba]<MAX_VAL) return memo[soba];

    min = MAX_VAL;

    /* ????????\??????????????\?????????????????????????????????????¨????????????????????¨????????°???????????????? */
    for(pat=0;pat<PATTERN_MAX;pat++){
        if( soba-pattern[pat][0] >= 0 ){
            val = pattern[pat][1] + dfs(soba-pattern[pat][0]);
            if( min > val ){
                min = val;
            }
        }
    }

    return memo[soba]=min;
}

int main(){
    int input;
    int i;

    for(i=0;i<SOBA_MAX;i++){
        memo[i] = MAX_VAL;
    }

    memo[0] = 0; /* 0g?????\????????????0??????????????? */

    while((scanf("%d",&input)>0) && (input>0)){
        printf("%d\n",dfs(input/100));
    }

    return 0;
}

Measured memory_bytes: 1852
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[3000];
vector<int> G[3000];
int dp[3000];
void dfs(int x, int p) {
  if (dp[x] != -1) return;
  dp[x] = 0;
  for (int t : G[x]) if (t != p && A[x] > A[t]) {
    dfs(t, x);
    dp[x] |= dp[t]==0;
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  rep(i, N) dp[i] = -1;
  rep(i, N) {
    dfs(i, -1);
  }
  rep(i, N) if (dp[i]) cout<<i+1<<" ";
  cout<<"\n";
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  char s[N];
  int a = 0;
  char Y;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
}
    

  for (int i = 0; i < N; i++) {
    if (s[i] == 'Y') ++a;   
}
if (a == 0) {
  cout << "Three" << endl;
}
else {
  cout << "Four" << endl;
}
}     

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明

// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) {
		a_powered *= a;
	}
	return a_powered;
}


int main(int argc, char *argv[]){
    string S;
    cin >> S;
    int N = (int)S.length();

    int distance = 0;
    for(int i=0; i<N; i++){
        if(S[i]-'0' != i%2){
            distance++;
        }
    }

    int ans = min(distance, N-distance);
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long ll;

const int INF = 1e9;

int main() {
    double R;
    cin >> R;

    cout << fixed << setprecision(6) << 2.0*R*M_PI << "\n";
}


Measured memory_bytes: 3764
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static int MOD = 1000000007;
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer N = Integer.parseInt(scanner.next());
        Integer M = Integer.parseInt(scanner.next());

        boolean[] isSafe = new boolean[N];
        Arrays.fill(isSafe, true);
        for(int i = 0; i < M; i++) {
            int a = Integer.parseInt(scanner.next());
            isSafe[a] = false;
        }

        Long[] dp = new Long[N+1];
        Arrays.fill(dp, 0L);
        dp[0] = 1L;
        if(M == 0 || isSafe[1]) dp[1] = 1L;

        for(int i = 2; i <= N; i++) {
            if (isSafe[i-1]) dp[i] += dp[i-1];
            if (isSafe[i-2]) dp[i] += dp[i-2];
            dp[i] %= MOD; // 1000000007 で割る
        }
        System.out.println(dp[N]);
    }
}

Measured memory_bytes: 47184
#!/usr/bin/env python3
import sys
import numpy as np


def solve(A: int, B: int, K: int):
    if A<K:
        B-=(K-A)
        B=0 if B<0 else B
        A=0
    else:
        A-=K
    print(A,B)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20656
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long X, long long A, long long B){
    lint res = - A + B;
    if (B <= A) {cout << "delicious" << endl;}
    else if(B <= A+X) { cout << "safe" << endl ;}
    else {cout << "dangerous"  << endl;}
}

int main(){

    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(X, A, B);
    return 0;
}



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

#define ff first
#define ss second
#define endl '\n'

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

	int a, b;
	cin >> a >> b;

	int ans[3] = {1, 2, 3};
	for (int i = 0; i < 3; ++i) {
		if (ans[i] != a && ans[i] != b) {
			cout << ans[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
isChenge = False
cnt = 0
for i in range(n-1):
  if a[i] == a[i+1] and isChenge == False:
    cnt += 1
    isChenge = True
  else:
    isChenge = False
print(cnt)
    

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

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    const int md = 1000000007;
    int used[26] = {};
    for(auto u : s){
        used[u-'a']++;
    }
    int an = 1;
    for(int i = 0; i < 26; i++){
        an = (1ll * an * (1 + used[i])) % md;
    }
    an -= 1;
    if(an < 0) an += md;
    cout << an;
}


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

int arr[3];
int main(){
int n,m,k;

cin>>n>>m>>k;
long long int res=(n*k)-m;
cout<<res<<endl;
for(int i=1;i<10;i++){
    res=(n*res)-m;
    cout<<res<<endl;



}


return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int N, M;
char ChairsPerson[101];
int Offset[101];


void solveA() {

	for (int i = 1; i <= N; ++i) {
		if (ChairsPerson[i]=='#') {
			ChairsPerson[i] = 'A';
			return;
		}
	}
}

void solveB() {

	for (int i = N; i >= 1; --i) {
		if (ChairsPerson[i] != '#') {
			continue;
		}
		if (i > 1 && ChairsPerson[i - 1] == 'A') {
			i -= 2;
			continue;
		}
		if (i < N  && ChairsPerson[i + 1] == 'A') {
			continue;
		}
		ChairsPerson[i] = 'B';
		return;
	}

	for (int i = 1; i <= N; ++i) {
		if (ChairsPerson[i] == '#') {
			ChairsPerson[i] = 'B';
			return;
		}
	}
}

void solveC(int id) {

	if (id == 0) {
		//firstperson
		ChairsPerson[N / 2 + 1] = 'C';
		return;
	}

	for (int i = 1; i <= N; ++i) {
		if (ChairsPerson[i] == '#') {
			continue;
		}
		if (i < N && ChairsPerson[i + 1] == '#') {
			ChairsPerson[i + 1] = 'C';
			return;
		}
		if (i > 1 && ChairsPerson[i - 1] == '#') {
			ChairsPerson[i - 1] = 'C';
			return;
		}
	}	
}

void solveD() {
	int pos, pos1, pos2, at;

	for (pos1 = 1; pos1 <= N; ++pos1) {
		if (ChairsPerson[pos1] == '#') {
			continue;
		}
		for (pos2 = 1; pos2 <= N; ++pos2) {
			Offset[pos2] = min(Offset[pos2], abs(pos1 - pos2));
		}
	}

	pos = 0;
	at = 1;
	for (pos1 = 1; pos1 <= N; ++pos1) {
		//cout << "pos1:" << pos1 << "  " << Offset[pos1] << endl;
		if (Offset[pos1] > pos) {
			pos = Offset[pos1];
			at = pos1;
		}
	}
	ChairsPerson[at] = 'D';
}

int main() {
	char person;

	while (cin >> N >> M, N) {
		fill(ChairsPerson + 1, ChairsPerson + N + 1, '#');
		fill(Offset + 1, Offset + N + 1, 1000);

		for (int i = 0; i < M; ++i) {
			cin >> person;
			switch (person)
			{
			case 'A':solveA(); break;
			case 'B':solveB(); break;
			case 'C':solveC(i); break;
			case 'D':solveD(); break;
			default:break;
			}
		}
		for (int i = 1; i <= N; ++i) {
			cout << ChairsPerson[i];
		}
		cout << endl;
	}

	return 0;
}




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

int main() {
	string s,ans;
	cin >> s;
	for (char c : s) {
		if (c == '1') {
			ans += '1';
		}
		else if (c == '0') {
			ans += '0';
		}
		else {
			if (!ans.empty()) {
				ans.pop_back();
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

typedef pair<int, int> point;

vector<point> r;
vector<point> b;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	for (int i = 0; i < N; i++) {
		int ai, bi;
		cin >> ai >> bi;
		r.push_back(point(ai, bi));
	}

	for (int i = 0; i < N; i++) {
		int ci, di;
		cin >> ci >> di;
		b.push_back(point(ci, di));
	}

	sort(begin(r), end(r));
	sort(begin(b), end(b));

	int cnt = 0;
	for (int i = 0; i < b.size(); i++) {
		int max = -1, max_idx = -1;
		for (int j = 0; j < r.size(); j++) {
			if (r[j].first < b[i].first && r[j].second < b[i].second && max < r[j].second) {
				max = r[j].second;
				max_idx = j;
			}
		}

		if (max_idx == -1) continue;
		r[max_idx].second = 13869948;
		r[max_idx].first = 13869948;
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, L; cin >> N >> L;
    vector<string> S(N, "");
    for (int i = 0; i < N; i++) cin >> S[i];
    sort(S.begin(), S.end());
    for (int i = 0; i < N; i++) cout << S[i];
    printf("\n");
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0; i < n; i++)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> a(n+1), b(n+1);
	rep(i,n)a[i+1]=s[i]=='#';
	rep(i,n)b[i+1]=s[i]=='.';
	rep(i,n)a[i+1]+=a[i];
	rep(i,n)b[i+1]+=b[i];
	int ans = n;
	rep(i,n+1)ans = min(ans, a[i] + b[n]-b[i]);
	cout<<ans<<endl;
}


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

int main()
{
    int H, W, M;
    cin >> H >> W >> M;
    vector<int> rows(H, 0);
    vector<int> cols(W, 0);
    //vector<vector<bool> > exist(H, vector<bool>(W, false));
    set<pair<int, int> > st;
    for (int i=0; i<M; i++)
    {
        int h, w;
        cin >> h >> w;
        h--;
        w--;
        rows[h]++;
        cols[w]++;
        st.insert({h, w});
    }
    int max_row = *max_element(rows.begin(), rows.end());
    int max_col = *max_element(cols.begin(), cols.end());
    vector<int> hr(0);
    vector<int> hc(0);
    for (int i=0; i<H; i++)
    {
        if (rows[i]==max_row) hr.push_back(i);
    }
    for (int i=0; i<W; i++)
    {
        if (cols[i]==max_col) hc.push_back(i);
    }
    int ans = max_row + max_col -1;
    for (int i=0; i<hr.size(); i++)
    {
        for (int j=0; j<hc.size(); j++)
        {
            if (st.find({hr[i], hc[j]}) == st.end())
            {
                ans++;
                break;
            }
        }
        if (ans == max_row + max_col) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 23800
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
  string s ;cin>> s ;
  ll n= s.size() ;
  ll ans=0 ;
  rep(i,n){
    if(s[i]=='p')
    ans++ ;
      }
  cout<< -ans+(n/2)<<endl ;
  return 0;
  }

Measured memory_bytes: 3760
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
int n,m,a[maxn],pre[maxn],tree[maxn*2];
int lowbit(int x){
	return x&(-x);
}
void add(int x){
	x+=(n+1);
	for(;x<=2*n+2;x+=lowbit(x)) tree[x]++;
}
int query(int x){
	x+=(n+1);
	int ret=0;
	for(;x;x-=lowbit(x)) ret+=tree[x];
	return ret; 
}
bool check(int x){
	int i;
	for(i=1;i<=n;i++){
		pre[i]=pre[i-1];
		if(a[i]<=x) pre[i]++;
		else pre[i]--;
	}
	for(i=0;i<=2*n+2;i++) tree[i]=0;
	add(0);
	ll tot=0;
	for(i=1;i<=n;i++){
		tot+=query(pre[i]-1);
		add(pre[i]);
	}
	ll al=1LL*(n+1)*n/2;
	al=al/2+1;
	return tot>=al;
}
int main(){
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int l=0,r=1e9,mid,ans=0;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define max(a,b) (((a)>(b))?a:b)
#define min(a,b) (((a)<(b))?a:b)
using namespace std;
template<typename T>void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-48;
	x*=f;
}
int n;
int hs[200010],a[200010];
int main(){
	read(n); 
	for(int i=1;i<=n;++i)
		read(a[i]);
	for(int i=1;i<=n;i+=2)
		hs[a[i]]++;
	int mx=0,mxi,nx=0;
	for(int i=1;i<=200000;++i)
		if(hs[i]>mx) nx=mx,mxi=i,mx=hs[i];
			else if(hs[i]>nx) nx=hs[i];
	memset(hs,0,sizeof(hs));
	for(int i=2;i<=n;i+=2)
		hs[a[i]]++;
	int mx2=0,mxi2,nx2=0;	
	for(int i=1;i<=200000;++i)
		if(hs[i]>mx2) nx2=mx2,mxi2=i,mx2=hs[i];
			else if(hs[i]>nx2) nx2=hs[i];
	mx=(n+1)/2-mx;
	nx=(n+1)/2-nx;
	mx2=n/2-mx2;
	nx2=n/2-nx2;
	int ans;
	if(mxi==mxi2) ans=min(mx+nx2,nx+mx2);
		else ans=mx+mx2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 100010
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int n,l,r;
int main(){
	n=read(),l=read(),r=read();
	FUP(i,1,n-1)
	{
		int ans=0;
		ans+=max(0,l-i);
		ans+=max(0,n-r+1-i);
		int mid=(r-l+1)/2+(r-l+1)%2;
		if(i<=mid-(r-l+1)%2) ans+=r-l+1;
		if(i==mid&&(r-l+1)%2==0) ans-=mid;
		int tmp=ans;
		ans+=2*max(mid+l-1+(r-l)%2-i,0)-2*max(l-i,0)-2*max(0,mid+(r-l)%2-i);
		if((r-l+1)%2==0&&ans>tmp&&i>mid) ans--;
		tmp=l,l=n-r+1;
		int ttmp=ans;
		ans+=2*max(mid+l-1+(r-tmp)%2-i,0)-2*max(l-i,0)-2*max(0,mid+(r-tmp)%2-i);
		//printf("#%d,%d\n",ans,2*max(mid+tmp-1+(r-tmp)%2-i,0)-2*max(tmp-i,0)-2*max(0,mid+(r-tmp)%2-i));
		l=tmp;
		if((r-l+1)%2==0&&ans>ttmp&&i>mid) ans--;
		//printf("#%d\n",ans);
		if(i>2&&l!=1&&r!=n) ans+=max(0,n-(r-l)+1-i)-max(0,l+1-i)-max(0,n-r+2-i);
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

	vector<int> d;
	for(int i = 0; i+1 < N; i++){
		d.pb(vec[i+1]-vec[i]);
	}

	int tmp = (K-vec[N-1])+vec[0];
	d.pb(tmp);

	// rep(i,d.size()) cout << d[i] << " ";
	// cout << endl;

	sort(d.begin(), d.end());
	int total = 0;
	rep(i,d.size()-1){
		total += d[i];
	}

	cout << total << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    double d; cin >> d;
    double ans=d*sqrt(2);
    double e=floor(d);
    ans=max(ans,e+1.0);
    cout << ans << '\n';
}


Measured memory_bytes: 3292
package main

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

// AtCoder Functions
var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()

	A := map[int]int{}
	for i := 0; i < N; i++ {
		A[i+1] = nextInt()
	}

	sr := map[int]int{}
	for i := 0; i < N; i++ {
		sr[A[i+1]] = i + 1
	}
	for i := 0; i < N-1; i++ {
		fmt.Printf("%d ", sr[i+1])
	}
	fmt.Println(sr[N])
}


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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v, T b=0){ return accumulate(v.begin(), v.end(), b); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Field {
  Field(int w, int h) : w(w), h(h) {}
  bool invalid(int x, int y){ return x < 0 || w <= x || y < 0 || h <= y; }
  const int w, h;
};

struct Solver {
  Solver(){}
  int solve(){
  }
};

int main()
{
  vector<int> vs = inpt<int>(5);
  sort(vs);
  revs(vs);
  show(vs);
  return (0);
}

Measured memory_bytes: 1212
#include<cstdio>
const static int MAX_N = 200000;

int par[MAX_N], rank[MAX_N], group_size[MAX_N];
unsigned answer = 1;

void init_union_find(unsigned n){
	for (unsigned i = 0; i < n; ++i){
		par[i] = i;
		rank[i] = 0;
		group_size[i] = 1;
	}
}

unsigned find(unsigned x){
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void unite(unsigned x, unsigned y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rank[x] < rank[y]){
		par[x] = y;
		group_size[y] += group_size[x];
        if(answer < group_size[y]) answer = group_size[y];
	}else{
		par[y] = x;
		group_size[x] += group_size[y];
		if(rank[x] == rank[y]) rank[x]++;
        if(answer < group_size[x]) answer = group_size[x];
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

int main(){
    unsigned N, M;
    scanf("%u %u", &N, &M);
    init_union_find(N);
    for (unsigned i = 0; i < M; i++){
        unsigned A, B;
        scanf("%u %u", &A, &B);
        unite(A-1, B-1);
    }
    printf("%u\n", answer);
	return 0;
}

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

int main() {
  
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s<t){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[1000000+5];
ll arr[1000000+5];
/*arr[0]=1;
dp[0]=1;*/
int main()
{
    /*ll n,x=1,i;
    cin>>n;
    ll mod=1000000007;
    ll dp[n+2]
    for(i=1;i<=n-1;i++)
    {
        x=x*2;
        x=x%mod;
    }
    x=x+n-1;
    x=x%mod;
    cout<<x;*/
    /*ll n;
    cin>>n;
    ll a[n],i;
    for(i=0;i<n;i++)
    {
        cin>>n;
    }*/
    ll n,i;
    cin>>n;
    ll mod=1000000007;
    if(n<2)
        cout<<"0";
    else
    {
        arr[0]=1;
        dp[0]=1;
        ll x=1;
        ll y=1;
        ll z=1;
        for(i=1;i<=n;i++)
        {
            x=x*10;
            y=y*9;
            z=z*8;
            x%=mod;
            y%=mod;
            z%=mod;  
        }

        ll ans=(x-2*y+z+mod+mod)%mod;
        cout<<ans;
        

    }
}


Measured memory_bytes: 3644