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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int ans = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                int sum = i * 500 + j * 100 + k * 50;
                if(sum == X){
                    ans++;
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a;
	int b;
	int c;
	int d;
	int x;
	int y;
	int z;
	scanf("%d\n%d\n%d\n%d\n%d\n",&a,&b,&c,&d,&z);
	if(a<40){
		a=40;
	} if(b<40){
		b=40;
	} if(c<40){
		c=40;
	} if(d<40){
		d=40;
	} if(z<40){
		z=40;
	}
	y=a+b+c+d+z;
	x=y/5;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstdlib>
#include<string>
#include<typeinfo>
using namespace std;

int main()
{
  string a, b;
  cin >> a >> b;
  a = a + b;

  int x;
  x = atoi(a.c_str());

  for(int i = 1; i <= 10000; i++){
    if(x == i*i){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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 int mod = 1000000007;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int sum = a+b+c;
    if(sum >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 3636
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    string s;
    cin >> s;
    int n = s.size();
    int left[n], right[n];
    int l = n - 1, r = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        left[i] = l;
        if (s[i] == 'L')
        {
            l = i;
        }
    }
    for (int i = 0; i < n; i++)
    {
        right[i] = r;
        if (s[i] == 'R')
        {
            r = i;
        }
    }
    vector<int> count(n, 0);
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'L')
        {
            if ((i - right[i]) % 2 == 0)
            {
                count[right[i]]++;
            }
            else
            {
                count[right[i] + 1]++;
            }
        }
        else
        {
            if ((left[i] - i) % 2 == 0)
            {
                count[left[i]]++;
            }
            else
            {
                count[left[i] - 1]++;
            }
        }
    }
    for (auto i : count)
    {
        cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 1872
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
    int n,ans=0;
    string a,b,c;
    cin>>n>>a>>b>>c;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]&&b[i]==c[i]) ans+=0;
        else if(a[i]==b[i]||b[i]==c[i]||c[i]==a[i]) ans++;
        else ans+=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  cout<<a[n-1]-a[0]<<endl;
}

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

base = [2,3,4,8,9,10]
ans = []

if(n==3):
    ans = [2,5,63]
elif(n == 4):
    ans = [2,3,4,9]
elif(n==5):
    ans = [2,3,4,9,6]
elif(n > 15000):
    for i in range(2500):
        for j in base:
            ans.append(j + i*12)
    for i in range(n - 15000):
        ans.append((i+1)*6)

else:
    for i in range(n//6):
        for j in base:
            ans.append(j + i*12)
    for i in range(n%6):
        ans.append((i+1)*6)
    

print(' '.join(map(str,ans)))
    

Measured memory_bytes: 5208
#include <stdio.h>
    #include <string.h>
    #include <math.h>

    int main(void)
    {
        int i,maxv = 0,minv = 0;
        int n;

        scanf("%d",&n);

        int a[n];

        for(i=0;i<n;i++){scanf("%d",&a[i]);}

        maxv = a[1] - a[0];
        minv = a[0];
        for(i=1;i<n;i++){
            if(maxv < (a[i] - minv)){maxv = a[i] - minv;}
            if(minv > (a[i])){minv = a[i];}
        }
        printf("%d\n",maxv);
        return 0;
    }



Measured memory_bytes: 2624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std; 
string a,b;
int main()
{
	getline(cin,a);
	getline(cin,b);
	int d=a.size();
	int l=b.size();
	int minn=999999;
	int sum=0;
	int x=d-l;
	for(int i=0;i<=x;i++)
	{
		sum=0;
		int k=-1;
		int y=i+l-1;
		for(int j=i;j<=y;j++)
		{
			k++;
			if(a[j]!=b[k])
			{
				sum++;
			}
		}
		if(sum<minn)
		{
			minn=sum;
		}
	}
	cout<<minn<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
int n, m, q;
int v[100000][100];
int c[100000];
int g[100000];
int id = 1;
 
void dfs (int s) {
    int i;
    g[s]=id;
    for (i = 0; i < c[s]; i++) {
        if (g[v[s][i]] == 0)
        dfs(v[s][i]);
    }
}
 
int main() {
    int i, j, x, y;
    scanf("%d%d", &n, &m);
    for (i = 0; i < m; i++) {
        scanf("%d%d", &x, &y);
        v[x][c[x]++] = y;
        v[y][c[y]++] = x;
    }
    for (i = 0; i < n; i++) {
        if (g[i] == 0) {
            dfs(i);
            id++;
        }
    }
    scanf("%d",&q);
    for (i = 0; i < q; i++) {
        scanf("%d%d", &x, &y);
        if (g[x] == g[y])
        printf("yes\n");
        else printf("no\n");
    }
 
return 0;
}



Measured memory_bytes: 44660
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    ll m=a[0];
    for(int i=1;i<n;i++){
        if(a[i]>=m){
            m=a[i];
        }
        else{
            ans+=m-a[i];
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 4776
s = input()
t = input()

import bisect
from collections import defaultdict
d = defaultdict(list)
for i in range(len(s)):
    d[s[i]].append(i)

#print(d)
now=-1
cnt=0
for i in range(len(t)):
    if len(d[t[i]])==0:
        print(-1)
        exit()

    ind = bisect.bisect_right(d[t[i]],now)
#    print(now,ind)
    if ind==len(d[t[i]]):
        ind = bisect.bisect_right(d[t],0)
        cnt+=1
#    print(t[i],cnt)
    now=d[t[i]][ind]

print(cnt*len(s) +now +1)

#print(cnt,len(s), d[t[-1]])

Measured memory_bytes: 45680
use std::io::*;

// 持ってる票数が固定 →　貪欲
// 全員投票しなくて良い →　平均値最大化っぽい
// しかし、全員持ってる票数が違う＋全員投票しなくてはいけないので、難しい。

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    if k <= a {
        println!("1");
    } else if a <= b {
        println!("-1");
    } else {
        println!("{}", (k - a + (a - b - 1)) / (a - b) * 2 + 1);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mod 1000000007
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inp_vecN for(int i=0;i<n;i++)cin>>v[i]; 
vector<int> get_Factors(ll n)
{
      vector <int> v;
      for(ll i=2; i<=sqrt(n)+1; i++)
      {
            if(n%i==0)
            {
                  v.push_back(i);
                  v.push_back(n/i);
            }
      }

      v.push_back(1);

      return v;
}
string get_bin(ll n)
{
    string s = "";
    while(n > 0)
    {
        s += ('0' + n%2);
        n /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}

ll bin_to_dec(string s)
{
    ll ans = 0;
    for(auto ch: s)
    {
        ans *= 2;
        ans += (ch - '0');
    }
    return ans;
}
void PrintVector(vector<ll> v,int n)
{

    for(int i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
int no_of_primeFactors(int n)  
{ 
    int count=0;
    while (n % 2 == 0)  
    {  
        count++;
        n = n/2;  
    }  
   
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
           count++;
            n = n/i;  
        }  
        
    }  
    if (n > 2)  
        count++;
    return count;
} 
 ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
} 
   
  ll lcm(int a, int b)  
{  
    return (a/gcd(a, b)*b);  
}  



ll pwr(ll base,ll expo,ll m)
{
    if(base==0) return 0LL;
    if(expo==0) return (1LL%m);
    if((expo&1)==0) {ll temp=pwr(base,expo>>1,m); return (temp*temp)%m;}
    return ((base%m)*pwr(base,expo-1,m))%m;
}

int main(int argc, char const *argv[])
{
    ios;

   int n,k;
   cin>>k;
   string s;
   cin>>s;

   n=s.length();
   if(n<=k)
   {
      cout<<s;
   }
   else
   {
      string s2=s.substr(0,k);
      s2+="...";
      cout<<s2;
   }



      return 0;
}

Measured memory_bytes: 3532
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


n, m = map(int, input().split())

edges = []

for i in range(m):
    a, b = map(int, input().split())
    edges.append([a - 1, b - 1])

ans = 0
for ban in range(m):
    uf = UnionFind(n)
    for i in range(m):
        if ban == i:
            continue

        frm, to = edges[i]
        uf.union(frm, to)

    if len(uf.roots()) > 1:
        ans += 1

print(ans)


Measured memory_bytes: 3064
def count_lunlun(num):
    num = list(map(int, str(num)))
    d = len(num)
    dp = [[[[0] * 10 for _ in range(2)] for _ in range(2)] for _ in range(d + 1)]
    dp[0][0][0][0] = 1
    for i in range(d):
        for j in range(2):
            for k in range(10):
                for z in range(2):
                    for x in range(10 if j else (num[i] + 1)):
                        if abs(x - k) <= 1:
                            dp[i + 1][j or x < num[i]][x != 0 or z][x] += dp[i][j][z][k]
                        elif z == 0:
                            dp[i + 1][j or x < num[i]][x != 0 or z][x] += dp[i][j][z][k]
    return sum(dp[d][0][0]) + sum(dp[d][0][1]) + sum(dp[d][1][0]) + sum(dp[d][1][1]) - 1


K = int(input())
left = 0
right = 10 ** 12
while right - left > 1:
    mid = (left + right) // 2
    count = count_lunlun(mid)
    if count >= K:
        right = mid
    else:
        left = mid
print(right)

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

int a[60],b[60],c[60],d[60];

int A[60];

int n,m,q;

int ans;

void dfs(int depth, int val){ 
  //depth個目を今埋めていて、今使える値はval以上である
  if( depth == n ){ 
    
    if(false){ 
    for(int i = 0; i < n; i++){ 
      cout << A[i] << " ";
    }
    cout << endl;
    }
    
    int sum = 0;
    
    for(int i = 0; i < q; i++){ 
      
      if( A[b[i]] - A[a[i]] == c[i] ){ sum += d[i];}
      
    }

    ans = max(ans,sum);
    
    
    return;
  }
  
  for(int next = val; next <= m; next++){ 
    
    A[depth] = next;
    dfs(depth+1,next);

  }
  
  return;
} 

signed main(void){ 
  
  cin >> n >> m >> q;
  for(int i = 0; i< q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  
  dfs(0,1);
  
  cout << ans << endl;
  
  return 0;
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
void dfs(int node, vector<bool> &vis, vector<vint> &adj)
{
    vis[node] = true;
    for (auto u : adj[node])
    {
        if (!vis[u])
            dfs(u, vis, adj);
    }
}
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, ans = 0;
    cin >> n >> m;
    vector<vint> adj(n);
    fr(i, 0, m)
    {
        int u, v, x;
        cin >> u >> v >> x;
        --u, --v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    vector<bool> vis(n, false);
    fr(i, 0, n)
    {
        if (!vis[i])
        {
            ans++;
            dfs(i, vis, adj);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

long long M;
int N, V, P, ans;
long long A[100010];
long long summemo=0;
void judge(int x){
  summemo+=A[x-1];
  if(summemo-A[x]*(x-P+1)<=(N-V)*M&&A[P-1]-A[x]<=M){
    ans++;
    if(x<N-1) judge(x+1);
  }
}

int main(){
  cin >> N >> M >> V >> P;
  ans=P;
  for(int i=0; i<N; i++) cin >> A[i];
  sort(A, A+N, greater<>());
  judge(P);
  cout << ans << endl;
  
  return 0;
}

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

int main(){
	int n;

	while(cin>>n){
		int cc = 0;
		for(int a = 0; a <= 9; a ++){
			for(int b = 0; b <= 9; b ++){
				for(int c = 0; c <= 9; c ++){
					for(int d = 0; d <= 9; d ++){

						if(a + b + c + d == n){
							cc ++;
						}
					}
				}
			}
		}
		cout<<cc<<endl;
	}
}

Measured memory_bytes: 1160
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

	int ans;

	ans = (b >= a*n) ? a*n : b;

	cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

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

	array := make([]int, 0)
	var a int
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		array = append(array, a)
	}

	sort.Sort(sort.IntSlice(array))

	res := 0
	i := 0
	for i < N {
		cur := array[i]
		count := 0
		for i < N && array[i] == cur {
			i++
			count++
		}
		res += count % 2
	}

	fmt.Println(res)
}


Measured memory_bytes: 5504
use whiteread::parse_line;

fn main() {
    let (n, k): (usize, usize) = parse_line().unwrap();
    let s: Vec<f64> = parse_line().unwrap();
    let mut a: Vec<f64> = vec![0.0];
    let mut ans: f64 = 0.0;

    for i in 0..n {
        a.push(a[i] + (1.0 + s[i]) / 2.0);
    }

    for i in 0..n - k + 1 {
        ans = ans.max(a[i + k] - a[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 5776
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m;
	while(cin >> n){
		cin >> m;
		cout << GCD(n,m) << endl;
	}
}


Measured memory_bytes: 3068
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>

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

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
const int inf = 1<<29;

int n;
int t[16][17];
int dp[1 << 16];

int rec(int s){
    if(dp[s] >= 0) return dp[s];
    if(s == (1 << n)-1) return dp[s] = 0;
    int res = inf;
    REP(next,n){
        if(!(s & (1 << next))){
            int cost = t[next][0]; //?£??????????
            REP(j, n){
                if((s & (1 << j))) cost = min(cost, t[next][j+1]);
            }
            res = min(res, rec(s|1<<next) + cost);
        }
    }
    return dp[s] = res;
}

int main(){
    while(cin >> n && n!=0){
        memset(dp, -1, sizeof(dp));
        REP(i,n){
            REP(j,n+1){
                cin >> t[i][j];
            }
        }
        cout << rec(0) << endl;
    }
    return 0;
}

Measured memory_bytes: 1424
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<map>

using namespace std;

int main(){
	int H,R;
	scanf("%d %d",&H,&R);
	if(R==(-1)*H)
	printf("0\n");
	else{
		if(H<(-1)*R)
		printf("-1\n");
		else
		printf("1\n");
	}
}


Measured memory_bytes: 3168
#define _USE_MATH_DEFINES 
#include<math.h>
#include<stdio.h>

double r,L,S;


int main(void){
scanf("%lf",&r);
L = 2*r*M_PI;
S = r*r*M_PI;

printf("%lf %lf\n",S,L);

return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[200005], t[200005];
int main(){
    int n, ans = 0;
    scanf("%s", s+1);
    scanf("%s", t+1);
    int m = strlen(s+1);
    for(int i=1;i<=m;i++){
        if(s[i] != t[i]) ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 4212
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())
A = make_divisors(N)
ans = float("inf")
#print(A)
if len(A)%2 == 0:
  mid = len(A)//2
else:
  mid = len(A)//2 + 1
for i in range(mid):
  temp = max(len(str(A[i])),len(str(A[-1-i])))
  ans = min(ans,temp)
print(ans)
  


Measured memory_bytes: 66084
s=input()
n=len(s)
if n==1:
    print(int(s))
else:
    n-=1
    ans=0
    for i in range(1<<n):
        l=[]
  #      print(i)
        for j in range(n-1,-1,-1):
            if (i>>j)&1:
                l.append(n-1-j)
   #     print(l)
        j=0
        k=0
        while j<len(l):
            num=''
            while k<=l[j]:
                num+=s[k]
                k+=1
    #        print(num,end=' , ')
            ans+=int(num)
            j+=1
        num=''
        while k<n+1:
            num+=s[k]
            k+=1
     #   print(num)
        ans+=int(num)
    print(ans)




Measured memory_bytes: 3064
//  Created by Vignesh Manoharan

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cassert>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vi> vvi;

const int INF = 1000000000;
const ll LINF = 1e17;
const double PI =3.141592653589793238;
#pragma unused(INF,PI,LINF)
#define F(i,a,n) for(int i=(a);i<(n);i++)

template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){
    for(int i=0;i<(t).size();i++)s<<t[i]<<((i<(t).size()-1)?" ":"");return s; }
template<typename T> ostream& operator<<(ostream &s,set<T> t){for(T x:t) s<<x<<" ";return s; }
template<typename T> istream& operator>>(istream &s,vector<T> &t){
    for(int _i=0;_i<t.size();_i++) s>>t[_i];return s; }

#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<int> low,idx,visited,parent;
int counter=0;
vector<vector<int>> graph;
vector<ii> bridges;
void find_bridges(int u){
    low[u]=idx[u]=counter++;
    for(int v:graph[u]){
        if(!visited[v]){
            parent[v]=u;
            visited[v]=1;
            find_bridges(v);
            if(low[v]>idx[u])
                bridges.pb(mp(u,v));
            low[u]=min(low[u],low[v]);
        } else if(v!=parent[u])
            low[u]=min(low[u],idx[v]);
    }
}
int main(int argc, const char * argv[]) {
#ifdef local_test
    //    input
    //    freopen("input","w",stdout);
    //    cout<<"1 \n 100 10 \n";
     freopen("input","r",stdin);
     freopen("output","w",stdout);
#endif
    int n,m;
    cin>>n>>m;
    graph = vvi(n,vi());
    low=vi(n);
    idx=vi(n);
    visited=vi(n,0);
    parent=vi(n,-1);
    F(i,0,m){
        int u,v;
        cin>>u>>v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    for(int i=0;i<n;i++) if(!visited[i]) find_bridges(i);
//    cout<<bridges<<"\n";
    for(int i=0;i<bridges.size();i++){
        ii e=bridges[i];
        bridges[i]=mp(min(e.first,e.second),max(e.first,e.second));
    }
    sort(all(bridges));
    for(ii e:bridges){
        cout<<e.first<<" "<<e.second<<"\n";
    }
}

Measured memory_bytes: 4628
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  long long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  long long low = 0, high = 1e9 + 10;
  while (high - low > 1) {
    long long mid = (low + high) / 2;
    long long cnt = 0;
    for (int i = 0; i < N; i++) {
      cnt += (A[i] - 1) / mid;
      if (cnt > K) break;
    }
    if (cnt > K)
      low = mid;
    else
      high = mid;
  }
  cout << high << endl;
  return 0;
}


Measured memory_bytes: 5208
def Binit(B,siz):
  while len(B)<siz+1:
    B.append(0)
  while len(B)>siz+1:
    del B[-1]
  for i in range(siz+1):
    B[i]=0
  B.append(siz)

def Badd(B,a,x):
  z=a
  while z<=B[-1]:
    B[z]+=x
    z+=(z&(-z))

def Bsum(B,a):
  r=0
  z=a
  while z>0:
    r+=B[z]
    z-=(z&(-z))
  return r

def Bssum(B,a,b):
  return Bsum(B,max(a,b))-Bsum(B,min(a,b)-1)

BIT=[]
N,Q=map(int,input().split())
Binit(BIT,N+1)
A=list(map(int,input().split()))
for i in range(N):
  Badd(BIT,i+1,A[i])
a,b,c=0,0,0
for i in range(Q):
  a,b,c=map(int,input().split())
  if a:
    print(Bssum(BIT,b+1,c))
  else:
    Badd(BIT,b+1,c)

Measured memory_bytes: 133752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
vector<int> G[100010];

int dfs(int v, int p){
    int res = 0;
    int son = 0;
    for(auto u : G[v]){
        if(u != p) res ^= dfs(u, v) + 1; 
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    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);
 
    }
    cout << (dfs(1, 0) == 0 ? "Bob" : "Alice") << endl;
    return 0;
}

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

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x = x - 1;
    y = y - 1;
    
    int res[n];
    rep(i, n-1){
        res[i] = n - 1 - i;
    }
    
    for(int j = 0; j < n - 1; ++j){
        for(int k = j + 1; k < n; ++k){
            int nd = abs(x - j) + 1 + abs(k - y);
            // cout << k - j << " " << nd << endl;
            if((k - j) > nd){
                res[nd - 1] += 1;
                res[k - j - 1] -= 1;
            }
        }
    }
    
    rep(i, n-1){
        cout << res[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int X = scanner.nextInt();
        int Y = scanner.nextInt();
        int to = Math.max(X, Y);
        long min = Long.MAX_VALUE;
        for (int i = 0; i <= to;i++) {
            long a = A * (X - i);
            long b = B * (Y - i);
            long c = C * i * 2;
            if (a < 0) a = 0;
            if (b < 0) b = 0;
            min = Math.min(min, a + b + c);
        }
        System.out.println(min);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () {
            s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


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

#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=800005;

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

  ll n;
  cin>>n;
  ll a[n];
  forn(i,n) cin>>a[i];
  ll dp[n];
  dp[0]=0;
  for(ll i=1;i<n;i++)
  {
    ll min=1e12;
    if(i-1>=0)
    {
      min=std::min(min,dp[i-1]+abs(a[i]-a[i-1]));
    }
    if(i-2>=0)
    {
      min=std::min(min,dp[i-2]+abs(a[i]-a[i-2]));
    }
    dp[i]=min;
  }
  cout<<dp[n-1];
}
//nothing is impossible

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}


ll n,ans;
char s[99];
char mae[1<<18][40],usiro[1<<18][40];
ll maenum[1<<18],usironum[1<<18];
int cc(const void*a,const void*b){return memcmp(a,b,40);}



int main(){
	scanf("%lld\n%s",&n,s);
	{
		//初期チェック
		ll a[999]={};
		rep(i,0,2*n)a[s[i]]^=1;
		rep(i,0,256)if(a[i]){puts("0");return 0;}
	}
	rep(i,0,1<<n){
		ll akacnt=0,aocnt=0;
		rep(k,0,n){
			if(bit(i,k))mae[i][akacnt++]=s[k];
			else mae[i][20+aocnt++]=s[k];
		}
		
		akacnt=0,aocnt=0;
		for(ll k=2*n-1;k>=n;k--){
			if(bit(i,2*n-1-k))usiro[i][akacnt++]=s[k];
			else usiro[i][20+aocnt++]=s[k];
		}
	}

	qsort(mae,1<<n,40,cc);
	qsort(usiro,1<<n,40,cc);
//	rep(i,0,16){rep(j,0,40)putchar(mae[i][j]?:32);puts("");}puts("");
//	rep(i,0,16){rep(j,0,40)putchar(usiro[i][j]?:32);puts("");}
	
//	rep(i,0,1<<n)rep(j,0,1<<n)if(!memcmp(mae[i],usiro[j],40))ans++;

	
	ll maecnt=0;maenum[0]=1;
	rep(i,1,1<<n){
		if(memcmp(mae[maecnt],mae[i],40))memmove(mae[++maecnt],mae[i],40);
		maenum[maecnt]++;
	}
	ll usirocnt=0;usironum[0]=1;
	rep(i,1,1<<n){
		if(memcmp(usiro[usirocnt],usiro[i],40))memmove(usiro[++usirocnt],usiro[i],40);	
		usironum[usirocnt]++;
	}
	
	ll usirotemp=0;
	rep(i,0,maecnt+1){
		while(usirotemp<=usirocnt&&memcmp(usiro[usirotemp],mae[i],40)<0)usirotemp++;
		if(!memcmp(usiro[usirotemp],mae[i],40))ans+=usironum[usirotemp]*maenum[i];
	}
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 28920
use std::collections::*;
use std::io::*;
use std::*;
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>();
            ret
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    // iterator(splitted input-string) => iterator(output-type)
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:ty),+) => {
        ($(_get!($it; $t)),*)
    };
}

fn main() {
    let (n, k) = get!(i32, i32);
    let mut h = get!([i64]);
    h.sort_unstable();
    let mut ans: i64 = 0;
    for i in 0..n - k {
        ans += h[i as usize];
    }
    println!("{}", ans);
}


Measured memory_bytes: 5832
N, K = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

wk = Array.new(N+1, -1)
A.unshift(0)
tmp, c = [1, 0]
while wk[tmp] == -1 do
  wk[tmp] = c
  tmp = A[tmp]
  c += 1
end
a = (K - wk[tmp]) % (c-wk[tmp])

if K - wk[tmp] > 0 then
  puts wk.index(a+wk[tmp])
else
  puts wk.index(K)
end


Measured memory_bytes: 31004
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
template<class T>
T gcd(T x, T y) {
	return y ? gcd(y, x % y) : x;
}

template<class T>
vector<T> enum_div(T n) {
	vector<T> ret;
	for (T i = 1; i * i < n; ++i) {

		if (n % i == 0) {
			ret.push_back(i);

			if (i != 1 && i * i != n) {
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}

template<class T>
map<T, int> prime_factorization(T n) {
	map<T, int> ret;

	for (long long i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}

	if (n != 1)ret[n] = 1;
	return ret;
}

template<class T>
long long C(T n, T r) {
	static map<pair<T, T>, long long> _map;
	if (n < r) return 0;

	if (n == r || r == 0) {
		_map[make_pair(n, r)] = 1ll;
	}
	else if (_map[make_pair(n, r)] == 0) {
		_map[make_pair(n, r)] = (C(n - 1, r) + C(n - 1, r - 1));
	}

	_map[make_pair(n, r)] %= MOD;
	return _map[make_pair(n, r)];
}

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

	for (int i = 0; i < s.length(); ++i) {
		s[i] += n;
		while(0x5a < (int)s[i])
		{
			s[i] -= 26;
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

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

using namespace std;
typedef long long ll;

const int MAX = 100100;
int S[MAX];

int search(int x, int n) {
   int head = 0;
   int tail = n;
   int mid;

   while (head != tail) {
      mid = (tail + head) / 2;
      if (S[mid] == x)
         return(1);
      else if (S[mid] < x)
         head = mid + 1;
      else
         tail = mid;
   }
   return(0);
}

int main() {
   int n, q, x;
   int cnt = 0;

   cin >> n;
   rep(i, n) scanf("%d", &S[i]);
   cin >> q;
   rep(i, q) {
      scanf("%d", &x);
      cnt += search(x, n);
   }
   cout << cnt << endl;
   return(0);
}



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

int zalgo(string s, int x){
  s = s.substr(x);
  int n = s.size();
  vector<int> a(n, 0);
  int l = -1, r = -1;
  for(int i=1; i<n; ++i){
    int &cnt = a[i];
    if(l != -1){
      cnt = min(a[i-l], r-i);
      cnt = max(0, cnt);
    }
    while(i + cnt < n && s[cnt] == s[i+cnt]) ++cnt;
    if(r < i+cnt){
      l = i;
      r = i+cnt;
    }
  }
  a[0] = n;
  int ans = 0;
  for(int i=0; i<n; ++i){
    if(a[i] <= i) ans = max(ans, a[i]);
  }
  return ans;
}

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i=0; i<n; ++i){
    ans = max(ans, zalgo(s,i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
Imports System

Module Program
    Sub Main(args As String())
        Dim tmpA As String() = Split(Console.ReadLine(), " ")

        Dim N As Long = CLng(tmpA(0))
        Dim A As Long = CLng(tmpA(1))
        Dim B As Long = CLng(tmpA(2))

        Dim i As Long = 0
        Dim j As Long = 0

        i = N \ (A + B)
        j = N Mod (A + B)

        If j < A Then
            Console.WriteLine(i * A + j)
        Else
            Console.WriteLine(i * A + A)
        End If
    End Sub
End Module


Measured memory_bytes: 13536
L = [1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049]

N = int(input())

dp = [float("inf") for i in range(200000)]
dp[0] = 0
for i in range(N + 1):
	for j in L:
		if dp[i] + 1 <= dp[i + j]:
			dp[i + j] = dp[i] + 1
print(dp[N])

Measured memory_bytes: 9368
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <vector>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 512
#define M 32
#define K (1048576*20)
#define T (256*5)

int c[M];
int s[N][M];
int t[N], max_t[N];
std::vector<int> poi[M];

constexpr int n = 365, m = 26;

int count()
{
    for(int i=0;i<m;++i) poi[i] = {-1};
    int res = 0;
    for(int i=0;i<n;++i)
    {
        int l = poi[t[i]].back(), d = i-l;
        poi[t[i]].push_back(i);
        res += s[i][t[i]];
        res -= c[t[i]]*d*(d-1)/2;
    }
    for(int i=0;i<m;++i)
    {
        int l = poi[i].back(), d = n-l;
        poi[i].push_back(n);
        res -= c[i]*d*(d-1)/2;
    }
    return res;
}

int pos, ot, nt;
std::vector<int>::iterator oil, oit, oir, nil, nir;

int update_dryrun(int x, int k)
{
    int res;
    pos = x, ot = t[x], nt = k;
    res = s[x][nt] - s[x][ot];
    oit = std::find(poi[ot].begin(), poi[ot].end(), x), oil = std::prev(oit), oir = std::next(oit);
    res -= c[ot] * (x-*oil) * (*oir-x);
    nir = std::upper_bound(poi[nt].begin(), poi[nt].end(), x), nil = std::prev(nir);
    res += c[nt] * (x-*nil) * (*nir-x);
    return res;
}

void patch()
{
    const int &x = pos;
    poi[ot].erase(oit);
    poi[nt].insert(nir, x);
    t[x] = nt;
}

int main()
{
    int d;
    scanf("%d", &d);
    assert(d == n);
    for(int i=0;i<m;++i) scanf("%d", &c[i]);
    for(int i=0;i<n;++i)for(int j=0;j<m;++j) scanf("%d", &s[i][j]);
    for(int i=0;i<n;++i) t[i] = rand() % m;
    memcpy(max_t,t,sizeof(max_t));
    int val = count(), max_val = val;
#ifdef DBG
    int init_val = val;
    int ca=0, cb=0;
#endif //DBG
    for(int i=0;i<K;++i)
    {
        int x = rand()%n, k = rand()%(m-1);
        if(k>=t[x]) ++k;
        int nxt_v = val + update_dryrun(x,k);
        if(nxt_v >= val || rand() <= (int)(exp((double)(nxt_v-val)/T)*((lli)RAND_MAX+1)))
        {
#ifdef DBG
            (nxt_v < val ? ca : cb) ++;
#endif //DBG
            val = nxt_v;
            patch();
            if(max_val < val) 
            {
                max_val = val;
                memcpy(max_t,t,sizeof(max_t));
            }
        }
    }
    for(int i=0;i<n;++i) printf("%d\n", max_t[i]+1);
    dbg_pri("poi 3: init=%d max=%d val=%d %d %d\n", init_val, max_val, val, ca, cb);
    return 0;
}


Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
int read(){int x;scanf("%d",&x);return x;}
int main(){
	int N=read();
	int *A=new int[N];
	long long S=0;
	for(int i=0;i<N;i++)A[i]=read(),S+=i?abs(A[i]-A[i-1]):abs(A[i]);
	S+=abs(A[N-1]);
	for(int i=0;i<N;i++){
		if(i==0)printf("%lld\n",S-abs(A[i])-abs(A[i]-A[i+1])+abs(A[i+1]));
		else if(i==N-1)printf("%lld\n",S-abs(A[i-1]-A[i])-abs(A[i])+abs(A[i-1]));
		else printf("%lld\n",S-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]));
	}
}

Measured memory_bytes: 1664
def solv
  n = gets.to_i
  a = gets.split.map(&:to_i).reverse
  s = gets.chomp.split("").map(&:to_i).reverse

  x = [0]
  n.times do |i|
    p = s[i]
    b = a[i]
    x.each do |v|
      b = [b, b^v].min
    end
    if p == 0
      x << b
    else
      return 1 if b != 0
    end
  end
  return 0
end

t = gets.to_i
t.times do |i|
  puts solv
end


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

using namespace std;

using int64 = long long;

int main() {
  int M, N;
  while(cin >> M >> N, M) {
    bool v[1000] = {};
    int cur = 0, rest = M;

    for(int i = 1; i <= N; i++) {
      string x;
      cin >> x;

      if(rest > 1) {
        string ans;
        if(i % 15 == 0) ans = "FizzBuzz";
        else if(i % 3 == 0) ans = "Fizz";
        else if(i % 5 == 0) ans = "Buzz";
        else ans = to_string(i);

        if(x != ans) {
          v[cur] = true;
          --rest;
          while(v[cur]) cur = (cur + 1) % M;
        } else {
          cur = (cur + 1) % M;
          while(v[cur]) cur = (cur + 1) % M;
        }
      }
    }
    bool f = false;
    for(int i = 0; i < M; i++) {
      if(!v[i]) {
        if(f++) cout << " ";
        cout << i + 1;
      }
    }
    cout << endl;
  }
}



Measured memory_bytes: 3188
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int[] monsters = new int[n];
		for (int i = 0; i < n; i++) {
			monsters[i] = sc.nextInt();
		}
		Arrays.sort(monsters);
		int left = 0;
		int right = 1000000000;
		while (right - left > 1) {
			int m = left + (right - left) / 2;
			if (check(monsters, a, b, m)) {
				right = m;
			} else {
				left = m;
			}
		}
		System.out.println(right);
	}
	
	static boolean check(int[] arr, long max, long avg, long value) {
		long minus = avg * value;
		long bonus = max - avg;
		for (int i = arr.length - 1; i >= 0 && value >= 0; i--) {
			if (arr[i] - minus > 0) {
				value -= (arr[i] - minus + bonus - 1) / bonus;
			} else {
				break;
			}
		}
		return value >= 0;
	}
}


Measured memory_bytes: 49608
#include<iostream>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;
const int N=1e5+2;
int a[N],b[N];
pair<int,int> c[N];
signed main(){
	int n,i,j,sum1=0,sum2=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		c[i].first=a[i]+b[i];
		c[i].second=i;
	}
	sort(c+1,c+1+n);
	for(i=n,j=0;i>=1;j++,i--){
		if(j%2==0){
			sum1+=a[c[i].second];
		}
		else{
			sum2+=b[c[i].second];
		}
	}
	cout<<sum1-sum2;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  long long A, B, K, tmp, zero;
  zero = 0;
  
  cin >> A >> B >> K;
  
  tmp = A;
  A = max(zero,A-K);
  B = max(zero, B-max(zero,K-tmp));

  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max:Integer;
  //a:array of Integer;
  s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    sum:=a;
    max:=a;
    Read(a);
    sum:=sum+a;
    max:=(max+a+abs(max-a))div 2;
    Readln(a);
    sum:=sum+a;
    max:=(max+a+abs(max-a))div 2;

    Writeln(sum-max);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll ans=0;
  if(a>b){
    cout<<0<<endl;
    return 0;
  }
  if(a==b){
    cout<<1<<endl;
    return 0;
  }
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  ans=(n-2)*(b-a)+1;
  cout<<ans<<endl;
}

Measured memory_bytes: 3544
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	xm := make(map[int]bool, n)
	for i := 0; i < n; i++ {
		a := scanInt()
		xm[a] = true
	}

	if v := len(xm); v%2 == 1 {
		fmt.Println(v)
	} else {
		fmt.Println(v - 1)
	}
}


Measured memory_bytes: 2944
N, M = map(int, input().split())
ans = 0
for i in range(1,int(M ** 0.5) + 2):
    if M % i == 0:
        if M//i <= M//N:
            ans = max(ans, M//i)
        if i <= M//N:
            ans = max(ans, i)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

int main() {
	int num;
	char blood[2];
	char row[1000];
	map<string, int> type;
	while(cin>>row){
		if(cin.eof()) break;
		sscanf(row,"%d,%s", &num, &blood);
		type[blood]++;
	}
	cout<<type["A"]<<endl;
	cout<<type["B"]<<endl;
	cout<<type["AB"]<<endl;
	cout<<type["O"]<<endl;
	return 0;
}

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

using namespace std;

#define ll long long
int n;
vector<int> h(2*100000+5),a(2*100000+5);

ll tree[4*100000+5];

void modify(int index,ll value){
	int p=n+index;
	tree[p]=value;
	p/=2;
	while(p>0){
		tree[p]=max(tree[2*p],tree[2*p+1]);
		p/=2;
	}
}

ll query(int l,int r){
	ll res=0;
	l+=n,r+=n;
	while(l<=r){
		if(l%2==1)res=max(res,tree[l++]);
		if(r%2==0)res=max(tree[r--],res);
		l/=2;
		r/=2;
	}
	return res;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&h[i]),--h[i];
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	vector<ll> dp(n+1);
	ll res=0;
	for(int i=0;i<n;i++){
		dp[i]=a[i];
		dp[i]=query(0,h[i]-1)+a[i];
		modify(h[i],dp[i]);
		res=max(res,dp[i]);
	}
	
	printf("%lld",res);
}


Measured memory_bytes: 6528