akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
    #include <bits/stdc++.h>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <list>

    #include <stack>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define INFINI (1000 * 1000 * 1000)

    using namespace std;
    //#define s(T) scanf("%d", &T)
    #define sl(T) scanf("%lld", &T)
    #define fill(a, val) memset(a, val, sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define DREP(x) sort(all(x)); x.erase(unique(all(x)), x.end())
    #define INDEX(a, val) (lower_bound(all(a), val) - a.begin())
    #define mod ll(1e9+7)
    typedef long long ll;


    bool compare_first(pair<ll,ll >a,pair<ll,ll >b)
    {
        return a.first<b.first;
    }

     bool compare_second(pair<int,pair<int , int> > a,pair<int,pair<int , int> > b)
    {
        return a.second.first<b.second.first;
    }


    ll min(ll a,ll b)
    {
        if(a>b)return b;
        return a;
    }
     ll max(ll a,ll b)
    {
        if(a>b)return a;
        return b;
    }

    ll toINT(string s)
    {
        ll a=0;
        for(ll index=0;index<s.size();index++)
            a=a*10+(s[index]-'0');
        return a;
    }



    int main() {
      ios::sync_with_stdio(false);

      ll n;
      cin>>n;
      ll first=1,second=1;
      for(ll index=0;index<n;index++)
      {
          ll t,a;
          cin>>t>>a;

         if(t>=first&&a>=second)
         {
             first=t;
             second=a;
         }
         else if(t<first&&a>=second)
         {
             ll k=first/t;
             if(first%t)k++;
             first=t*k;
             second=a*k;
         }
         else if(t>=first&&a<second)
         {
             ll k=second/a;
             if(second%a)k++;
             first=t*k;
             second=a*k;
         }
         else if(t<first&&a<second)
         {
             ll k1=first/t,k2=second/a;
             if(first%t)k1++;
             if(second%a)k2++;
             k1=max(k1,k2);
             first=t*k1;
             second=a*k1;
         }



      }
      cout<<first+second<<endl;

return 0;
    }

/*

 }
 */


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

int n;
vector<int> a, b;

void agc009a() {
  ll ans = 0;
  for (int i = n; i >= 1; i--) {
    a[i] = (a[i] + ans) % b[i];
    ans += (b[i] - a[i]) % b[i];
  }
  cout << ans << '\n';
  return;
}

int main() {
  cin >> n;
  a.resize(n + 1);
  b.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }
  agc009a();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int main(){
	ll N,K;
	cin >> N >> K;
	vector<ll> h(N+7),dp(N+7,INF);

	for(int i=1;i<=N;i++){
		cin >> h[i];
	}

	dp[1] = 0;
	// 貰うDP
	for(int i=2;i<=N;i++){
		// dp[i]を決める
		for(int j=1;j<=K;j++){
			// j個前からジャンプしてきた時のコストと比較
			// 配列の範囲外へのアクセスに注意
			if(i-j>=1)dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}

	cout << dp[N] << endl;
}

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

using namespace std;

#define f first
#define s second

int main(){
	
	long n,w;
	scanf("%ld%ld",&n,&w);
	vector<pair<long,long> > arr(n);
	for(int i=0;i<n;i++)
		scanf("%ld%ld",&arr[i].f,&arr[i].s);
	vector<vector<long> > dp(n+1,vector<long>(w+1));
	for(int i=1;i<=n;i++)
	{	
		long we=arr[i-1].f,val=arr[i-1].s;
		for(int j=0;j<=w;j++)
		{
			long a=((j-we>=0&&i-1>=0)?dp[i-1][j-we]+val:0);
			long b=(i-1>=0?dp[i-1][j]:0);
			dp[i][j]=max(a,b);
			//cout<<dp[i][j]<<" ";
			}
			//cout<<"\n";
		}
		printf("%ld",dp[n][w]);
		
	}




Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;

signed main() {
	int a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <cmath>
# include <functional>
# include <utility>
#include<iomanip>
# define MOD 1000000007
# define INF 2000000000
#define rep(i, a, n) for (ll(i) = (a); (i) < (n); (i)++)
#define repq(i,a,n) for(ll (i)=(a); (i)<=(n); (i)++)
typedef long long ll;
using namespace std;

long long inv(long long n) {
	long long t = 1;
	while (n > 1) {
		t = t * (MOD - MOD / n) % MOD;
		n = MOD % n;
	}

	return t;
}

long long comb(long long n, long long k) {
	if (k > n - k) k = n - k;
	long long numerator = 1, denominator = 1;
	for (int i = 1; i < k + 1; i++) {
		numerator = numerator * (n + 1 - i) % MOD;
		denominator = denominator * i % MOD;
	}

	return numerator * inv(denominator) % MOD;
}
signed main() {
//new
	ll x, y,A=0,B=0;
	cin >> x >> y;
	if (y > x)swap(x, y);

	if (x < (x - y) * 2) {
		cout << 0 << endl;
		return 0;
	}
	if (x > y&&(x-(x-y)*2)%3==0) {
		A += ((x - (x - y) * 2) / 3) + (x - y);
		B += (x - (x - y) * 2) / 3;
	}
	else if (x == y&&x%3==0) {
		A += x / 3;
		B += y / 3;
	}
	
	if (A == 0 && B == 0) {
		cout << 0 << endl;
		return 0;
	}
	else if (A == 0 || B == 0) {
		cout << 1 << endl;
		return 0;
	}
	else {
		ll zero = 0;
		cout << comb(A + B, A) << endl;
	}
}



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

vector<int> tree[101010];
void dfs(int u, int p){
    for(int i=0;i<tree[u].size();i++){
        int v = tree[u][i];
        if(v != p){
            cout<<u<<" "<<v<<endl;
            dfs(v, u);
        }
    }
}
int main(){
    string s;
    cin>>s;
    int n = s.length();
    s = " " + s;
    if(s[1] == '0' || s[n - 1] == '0' || s[n] == '1')return cout<<-1<<endl, 0;

    int root;
    for(int i=2;i<=n;i++){
        if(i < n && s[i] != s[n - i])return cout<<-1<<endl, 0;
        if(s[i] == '1'){
            root = i;
            for(int j=i-1;j>=1;j--){
                tree[i].push_back(j);
                tree[j].push_back(i);
                if(s[j] == '1')break;
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(tree[i].size() == 0){
            tree[i].push_back(root);
            tree[root].push_back(i);
        }
    }
    dfs(n, -1);
}


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

ll dp[11][2][2];
char s[20];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	f(i, 0, n)s[i] -= '0';
	reverse(s, s + n);
	ll an = 0;
	int t = n;
	f(tmp, 0, t + 1){
		f(i, 0, 11)f(j, 0, 2)f(k, 0, 2)dp[i][j][k] = 0;
		dp[0][0][0] = 1;
		f(i, 0, n + 1 >> 1)f(a, 0, 2)f(b, 0, 2)f(k, 0, 10)f(w, 0, 2){
			ll &r = dp[i][a][b];
			int j = n - i - 1;
			if (j == i){
				if (w)continue;
				int z = k + s[i] + a;
				bool c = z >= 10;
				if (c)z -= 10;
				if (z == k && c == b)dp[i + 1][c][c] += r;
			}else {
				int z = k + s[i] + a;
				bool c = z >= 10;
				if (c)z -= 10;
				if (i == 0 && z == 0)continue;
				z += s[j] + w;
				bool d = z >= 10;
				if (d)z -= 10;
				if (z == k && d == b)dp[i + 1][c][w] += r;
			}
		}
		f(i, 0, 2)an += dp[n + 1 >> 1][i][i];
		++n;
	}
	printf("%lld\n", an);
}

Measured memory_bytes: 256
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int u=0,l=0,m=0;
		for(int i=0;i<s[0];i++){
			a[i]-=s[1];
			if(a[i]>0){u+=a[i];}
			else{l+=a[i];}
		}
		m=-l+u+1;
		l=-l;
		long[,] dp=new long[s[0],m];
		dp[0,l+a[0]]=1;
		for(int i=1;i<s[0];i++){
			dp[i,l+a[i]]++;
			for(int j=0;j<m;j++){
				dp[i,j]+=dp[i-1,j];
				if(j-a[i]>=0&&j-a[i]<m){
					dp[i,j]+=dp[i-1,j-a[i]];
				}
			}
		}
		Console.WriteLine("{0}",dp[s[0]-1,l]);
	}
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin>>N>>X;
  vector<int> m(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>m.at(i);
    sum+=m.at(i);
  }
  
  sort(m.begin(),m.end());
  
  int ans=N;
  
  while(true){
    if(X>=sum+m.at(0)){
      ans++;
      sum+=m.at(0);
    }
    else{
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long int r,d,x;
    scanf("%lld %lld %lld",&r,&d,&x);

    for (int i = 1; i <= 10; i++)
    {
        x = r * x - d;
        printf("%lld\n",x);
    }
    
}

Measured memory_bytes: 128
//https://atcoder.jp/contests/abc165/tasks/abc165_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll X; cin>>X;
  ll v=100;
  ll ans=0;
  while(v<X){
    v = (v * 1.01);
    ++ans;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
# Union Find
# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # x < y にする
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# 根の個数を返す
def group_count():
    return sum(x < 0 for x in par)


n, m = map(int, input().split())
l = []
for _ in range(m):
    l.append(tuple(map(int, input().split())))

ans = 0
for j in range(m):
    par = [-1] * n
    for i, ab in enumerate(l):
        if i != j:
            unite(ab[0] - 1, ab[1] - 1)
    if group_count() == 2:
        ans += 1

print(ans)

Measured memory_bytes: 9196
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    static class Node {

        int num;

        int dist;

        public Node(int num, int dist) {

            this.num = num;

            this.dist = dist;

        }
    }

    static class Vertex {

        int num;

        List<Integer> edges = new LinkedList<>();

        public Vertex(int num) {

            this.num = num;
        }
    }

    static Vertex[] nodes;

    static int N;

    static int M;

    static int S;

    static int T;
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        N = s.nextInt();

        M = s.nextInt();

        nodes = new Vertex[N+1];

        for (int i = 1; i <= N; i++) {

            nodes[i] = new Vertex(i);
        }

        for (int i = 0; i < M; i++) {

            int from = s.nextInt();

            int to = s.nextInt();


            nodes[from].edges.add(to);
        }

        S = s.nextInt();

        T = s.nextInt();

        bfs();

    }

    public static void bfs() {


        boolean[][] flag = new boolean[N+1][3];


        Queue<Node> q = new LinkedList<>();

        flag[S][0] = true;

        Node n = new Node(S, 0);

        q.add(n);

            while (q.isEmpty() == false) {

                Node k = q.poll();

                int dist = k.dist;

            if (dist % 3 ==0 && k.num == T) {

                System.out.println(dist/3);

                return;
            }

            int newDist = dist + 1;


            List<Integer> list = nodes[k.num].edges;

            for (int i : list) {

                if (flag[i][newDist %3] == true) continue;

                flag[i][newDist%3] = true;

                q.add(new Node(i, newDist));

            }

        }

        System.out.println(-1);
    }


}


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

using namespace std;
typedef long long ll;

// #define DEBUG

const int INTMAX = 2 * 1e9 + 10;
const int NMAX = 2 * 1e3;

bool check[NMAX];

int dfs(int s, int t, int f, vector<pair<int, int>> edge[], vector<int> *used)
{
    int d = 0;
    check[s] = true;
    if (s == t)
    {
        used->push_back(t);
        return f;
    }

    for (auto next : edge[s])
    {
        if (check[next.first] == false && next.second > 0)
            d = dfs(next.first, t, min(next.second, f), edge, used);
        if (d > 0)
        {
            used->push_back(s);
            return d;
        }
        // DFSが終点まで行くと正の値dが帰ってくるので、辺の容量の調整をして終了
    }
    return 0; //そうでなければ何もしない
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m, s, t, c, a, b, f, ans;
    cin >> n >> m;

    vector<pair<int, int>> edge[n];
    vector<int> used;

    f = 1, ans = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> s >> t >> c;
        edge[s].push_back(make_pair(t, c));
        edge[t].push_back(make_pair(s, 0));
    }
    while (f > 0)
    {
        for (int i = 0; i < n; i++)
            check[i] = false;

        f = dfs(0, n - 1, INTMAX, edge, &used);
        a = -1, b = -1;
        for (auto i : used)
        {
            a = b;
            b = i;

            if (a >= 0 && b >= 0)
            {
                for (auto j = edge[a].begin(); j != edge[a].end(); j++)
                {
                    if (j->first == b)
                    {
                        j->second += f;
                        break;
                    }
                }
                for (auto j = edge[b].begin(); j != edge[b].end(); j++)
                {
                    if (j->first == a)
                    {
                        j->second -= f;
                        break;
                    }
                }
            }
        }
        ans += f;
        used.clear();
    }
    cout << ans << endl;

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3180
N,X=map(int, input().split())
m=0
sum_m =0
min_m =100000
num_donut =0

for i in range(N):
	m = int(input())
	sum_m += m
	if m< min_m:
		min_m = m

num_donut=N+(X-sum_m)//min_m
print(num_donut)

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

int i,j,k,m;
main()
{
   int n;
   cin>>n;
   map<int,int> m;
   for(i=0;i<n;i++)
   {
       int x;cin>>x;
       m[x]++;
   }
   map<int,int>::iterator it;

   int s=0;
   for(it=m.begin();it!=m.end();it++)
   {
      if((*it).first==(*it).second) continue;
       if((*it).first>(*it).second) s+=(*it).second;
       if((*it).first<(*it).second)  s+=((*it).second-(*it).first);

   }
cout<<s<<endl;
}


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
int n,x[1234565],y[123456];
int main(){
    cin>>n;
    cin>>x[n];
    for(int i=0;i<n;i++)cin>>x[i];
    int a=n+1;
    sort(x,x+a);
    for(int i=0;i<n;i++)y[i]=x[i+1]-x[i];
    sort(y,y+n);
    for(int i=0;i<(n-1);i++){
        int a,b,r;
        b=y[i];
        a=y[(i+1)];
        r=a%b;
        while(r!=0){
            a=b;
            b=r;
            r=a%b;
        }
        y[(i+1)]=b;
    }
    cout<<y[(n-1)]<<endl;
}


Measured memory_bytes: 1024
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    string s; cin >> s;
    if (s=="AAA" || s=="BBB") cout << "No";
    else cout << "Yes";
    cout << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

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

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
ll n;
ll recurse(ll idx) {
	if(idx <= 0) return 0;
	ll ans = 0;
	ans = 1 + 2 * recurse((idx/2));
	return ans;
}

int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> n;
  cout << recurse(n) << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b; scanf("%d%d",&a,&b);
	int ary[3] = {a+b, a-b, a*b};
	int max = ary[0];
	for (int i=0; i<3; i++) {
		if (max<ary[i]) max = ary[i];
	}
	printf("%d",max);
	return 0;
}


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

struct AVL{
 struct Node{
  int l,r,p; int d,z; pair<LL,int> v;
  void merge(const Node& l, const Node& r){
   d = max(l.d,r.d)+1;
   z = l.z+r.z+1;
  }
 };
 Node Zero = Node{-1,-1,-1,0,0,{0,0}};
 vector<Node> V;
 int R=-1;
 Node& get(int v){ if(v==-1) return Zero; else return V[v]; }
 void upd(int v){ V[v].merge(get(V[v].l),get(V[v].r)); }
 int& parentchild(int v){
  if(v==R) return R;
  if(V[V[v].p].l==v) return V[V[v].p].l;
  return V[V[v].p].r;
 }
 void swapidx(int a,int b){
  swap(parentchild(a),parentchild(b));
  swap(V[a],V[b]);
  if(V[a].l!=-1) V[V[a].l].p = a;
  if(V[a].r!=-1) V[V[a].r].p = a;
  if(V[b].l!=-1) V[V[b].l].p = b;
  if(V[b].r!=-1) V[V[b].r].p = b;
 }
 void rotL(int v){
  int w=V[v].r;
  parentchild(v)=w; V[w].p=V[v].p;
  V[v].r=V[w].l; if(V[w].l!=-1) V[V[w].l].p=v;
  V[v].p=w; V[w].l=v;
  upd(v); upd(w);
 }
 void rotR(int v){
  int w=V[v].l;
  parentchild(v)=w; V[w].p=V[v].p;
  V[v].l=V[w].r; if(V[w].r!=-1) V[V[w].r].p=v;
  V[v].p=w; V[w].r=v;
  upd(v); upd(w);
 }
 int fix(int v){
  if(get(V[v].l).d+1 < get(V[v].r).d){ rotL(v); return V[v].p; }
  if(get(V[v].l).d > get(V[v].r).d+1){ rotR(v); return V[v].p; }
  upd(v);
  return v;
 }
 void fixall(int v){
  while(v!=-1) v=V[fix(v)].p;
 }

 void insert(pair<LL,int> v){
  int p=-1, *pp=&R;
  while(*pp!=-1){
   p=*pp;
   if(V[p].v > v){ pp=&V[p].l; }
   else pp=&V[p].r;
  }
  *pp=V.size();
  V.push_back({-1,-1,p,1,1,v});
  fixall(V.size()-1);
 }
 int find(pair<LL,int> v){
  int p=R;
  while(p!=-1){
   if(V[p].v > v) p=V[p].l;
   else if(V[p].v < v) p=V[p].r;
   else return p;
  }
  return -1;
 }
 void erase(int v){
  while(true){
   if(V[v].l==-1 && V[v].r==-1) break;
   else if(get(V[v].l).d < get(V[v].r).d) rotL(v);
   else rotR(v);
  }
  int p=V[v].p;
  swapidx(v,V.size()-1);
  parentchild(V.size()-1)=-1;
  V.pop_back();
  fixall(p);
 }
 pair<LL,int> nth_element(int n){
  n--;
  int p=R;
  while(true){
   if(get(V[p].l).z == n) return V[p].v;
   if(get(V[p].l).z > n) p=V[p].l;
   else{ n-=get(V[p].l).z+1; p=V[p].r; }
  }
 }
 void printInorder(int v=-2){
  if(v==-2) v=R;
  if(v==-1) return;
  printInorder(V[v].l);
  printf("(%lld,%d) ",-V[v].v.first,V[v].v.second+1);
  printInorder(V[v].r);
  if(v==R) cout<<endl;
 }
 void printPreorder(int v=-2){
  if(v==-2) v=R;
  if(v==-1) return;
  printf("(%lld,%d,%d) ",-V[v].v.first,V[v].v.second+1,V[v].z);
  printPreorder(V[v].l);
  printPreorder(V[v].r);
  if(v==R) cout<<endl;
 }
};

int N,Q;
LL Score[100000]={};
AVL T;

int main(){

 scanf("%d%d",&N,&Q);
 rep(i,N){
  T.insert({-Score[i],i});
 }

 rep(i,Q){
  int c; scanf("%d",&c);
  if(c==0){
   int t,p; scanf("%d%d",&t,&p); t--;
   T.erase(T.find({-Score[t],t}));
   Score[t]+=p;
   T.insert({-Score[t],t});
  }
  if(c==1){
   int p; scanf("%d",&p);
   auto t=T.nth_element(p);
   printf("%d %lld\n",t.second+1,-t.first);
  }
 }

 return 0;
}



Measured memory_bytes: 8060
#include <iostream>

int main()
{
	float A, B, T;
	A = B = T = 0.0f;
	std::cin >> A >> B >> T;

	int Num = 0;
	for (float t = A; t < T+0.5f; t += A)
	{
		Num += B;
	}

	std::cout << Num;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double x;
    double t = h + m/60.0;
    x = t*(11.0/6.0)*M_PI;
    double c_2 = a*a + b*b -2*a*b*cos(x);
    cout << fixed << setprecision(17) << pow(c_2,0.5) << endl;
}

Measured memory_bytes: 4356
N = str(input())

if N[-1]=="2" or N[-1]=="4" or N[-1]=="5" or N[-1]=="7" or N[-1]=="9":
    print('hon')

elif N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8":
    print('pon')

elif N[-1]=="3":
    print('bon')


Measured memory_bytes: 9064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e5+10;
int n, a[N], b[N], d[N];
char s[N];

int main() {
	scanf("%d", &n);
	int c[2]{};
	REP(i,1,n) {
		scanf("%d%d",a+i,b+i);
		++c[a[i]+b[i]&1];
	}
	if (c[0]!=n&&c[1]!=n) return puts("-1"),0;
	printf("%d\n",31+!!c[0]);
	REP(i,0,30) printf("%d ", 1<<i);
	if (c[0]) printf("%d ", 1);
	hr;
	REP(i,1,n) {
		int x = a[i], y = b[i];
		if (c[0]) --x, s[31] = 'R';
		int f = 0;
		PER(i,0,30) {
			if (abs(x)<abs(y)) swap(x,y), f^=1;
			if (x>0) x-=1<<i,s[i]="RU"[f];
			else x+=1<<i,s[i]="LD"[f];
		}
		puts(s);
	}
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

char nxt[256];


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int H, W, N, sr, sc;
  cin >> H >> W >> N >> sr >> sc;

  string S, T;
  cin >> S >> T;
  
  nxt[(int)'L'] = 'U';
  nxt[(int)'U'] = 'R';
  nxt[(int)'R'] = 'D';
  nxt[(int)'D'] = 'L';

  auto CanLeaveRight = [&]() {
    int cur_c = sc;
    debug(sc, S, T);
    for (int i = 0; i < N; ++i) {
      if (S[i] == 'R') {
        ++cur_c;
        if (cur_c > W) { return true; }
      }

      if (T[i] == 'L' && cur_c > 1) {
        --cur_c;
      }
    }
    return false;
  };

  for (int i = 0; i < 4; ++i) {
    if (CanLeaveRight()) {
      cout << "NO\n";
      return 0;
    }

    for (char &ch : S) { ch = nxt[ch]; }
    for (char &ch : T) { ch = nxt[ch]; }

    tie(sr, sc) = make_pair(sc, H - sr + 1);
    swap(H, W);
  }

  cout << "YES\n";
}



Measured memory_bytes: 920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	InputStream input = System.in;
      	OutputStream output = System.out;
      	Scanner sc = new Scanner(input);
      	PrintWriter out = new PrintWriter(output);
      	String A = sc.next();
      	String B = sc.next();
      	String C = sc.next();
      	out.println(A.charAt(0) + "" + B.charAt(0) + "" + C.charAt(0));
      	out.close();
    }
}

Measured memory_bytes: 21844
import itertools
n = int(input())
statements = [[]for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        statements[i].append((x-1, y))

can_be = []
for i in itertools.product('01', repeat=n):
    people = tuple(map(int, i))
    contradiction = 0
    for j in range(n):
        if people[j] == 0:
            continue
        for k, x in statements[j]:
            if people[k] == x:
                continue
            contradiction = 1
            break
        if contradiction:
            break
    else:
        can_be.append(people)

ans = 0
for p in can_be:
    ans = max(ans, p.count(1))

print(ans)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    double t, x;
    cin >> t >> x;
    cout << fixed << setprecision(10) << t / x << endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  vector<int> length(11, 0);
  
  length[A]++;
  length[B]++;
  length[C]++;
  
  if (length[5] == 2 && length[7] == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by ??\??? on 2016/12/7.
 */
public class Main {
    static int si(String s){
        return Integer.parseInt(s);
    }
    static void run(String[] args) throws Exception{
        BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
        int T = si(scan.readLine());
        Map<String,String> m = new HashMap<>();
        for(int t =0;t<T;t++){
            String[] lines = scan.readLine().split(" ");
            if(lines[0].equals("insert")){
                m.put(lines[1],"i");
            }
            else{
                if(m.containsKey(lines[1])){
                    System.out.println("yes");
                }else {
                    System.out.println("no");
                }
            }
        }
    }
    public static void main(String[] args) throws Exception{
        run(args);
    }
}

Measured memory_bytes: 189944
<?php

fscanf(STDIN, '%d', $n);
$line = trim(fgets(STDIN));
$S = explode(' ', $line);
fscanf(STDIN, '%d', $q);
$line = trim(fgets(STDIN));
$T = explode(' ', $line);

$result = 0;
foreach ($T as $t) {
    $left = 0;
    $right = $n;
    $t = (int)$t;
    $test = 0;

    while ($left < $right) {
        $i = (int)(($left + $right) / 2);
        $s = (int)$S[$i];
        if ($s === $t) {
            $result++;
            break;
        } elseif ($s < $t) {
            $left = $i + 1;
        } else {
            $right = $i;
        }
    }
}

echo $result, PHP_EOL;

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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < 100000; i++) {
    if ((i + 1) * (i + 1) > N) {
      cout << i * i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	vector<ll>arr(n+3);
	priority_queue< pair<ll,ll> >pq;
	for(ll i=1;i<=n;i++)
	{
		cin>>arr[i];
		pair<ll,ll>pp=mp(arr[i],i);
		pq.push(pp);
	}
	for(ll i=32;i>=0;i--)
	{
		while(m>0)
		{
			ll val=pq.top().fi;
			ll pos=pq.top().se;
			ll curr=((val>>i)&1);
			if(curr==0)
			{
				break;
			}
			pq.pop();
			arr[pos]/=2LL;
          	m--;
			pq.push(mp(val/2LL,pos));
		}
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		ans+=arr[i];
	}
  cout<<ans;
    return 0;
}


//252908XL

Measured memory_bytes: 3188
package main

import (
	"bytes"
	"fmt"
	"math"
)

const theta = math.Pi * 60.0 / 180.0

var memo bytes.Buffer

type point struct {
	x float64
	y float64
}

func solve() string {
	var depth int
	fmt.Scan(&depth)
	var left, right point
	left.x, left.y = 0, 0
	right.x, right.y = 100, 0
	memo.WriteString(fmt.Sprintf("%.8f %.8f\n", left.x, left.y))
	koch(depth, left, right)
	memo.WriteString(fmt.Sprintf("%.8f %.8f\n", right.x, right.y))
	return memo.String()
}

func koch(depth int, left, right point) {
	if depth == 0 {
		return
	}
	var s, t, u point

	s.x = (2.0*left.x + 1.0*right.x) / 3
	s.y = (2.0*left.y + 1.0*right.y) / 3
	t.x = (1.0*left.x + 2.0*right.x) / 3
	t.y = (1.0*left.y + 2.0*right.y) / 3
	u.x = s.x + (t.x-s.x)*math.Cos(theta) - (t.y-s.y)*math.Sin(theta)
	u.y = s.y + (t.x-s.x)*math.Sin(theta) + (t.y-s.y)*math.Cos(theta)
	koch(depth-1, left, s)
	memo.WriteString(fmt.Sprintf("%.8f %.8f\n", s.x, s.y))
	koch(depth-1, s, u)
	memo.WriteString(fmt.Sprintf("%.8f %.8f\n", u.x, u.y))
	koch(depth-1, u, t)
	memo.WriteString(fmt.Sprintf("%.8f %.8f\n", t.x, t.y))
	koch(depth-1, t, right)
}

func main() {
	fmt.Print(solve())
}



Measured memory_bytes: 1908
import re
S = input()
'''
メタ文字：
^ = 文字列の先頭、
| = OR
+ = 直前のパターンを1回以上繰り返し、
$ = 文字列の末尾
'''
if re.match("^(dream|dreamer|erase|eraser)+$", S):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 12880
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n,p;
	int a[52];
	scanf("%d%d",&n,&p);
	rep1(i,n)scanf("%d",&a[i]);
	
	ll dp[52][2] = {};
	dp[0][0] = 1;
	rep1(i,n){
		if(a[i]%2 == 0){
			dp[i][0] = dp[i-1][0]*2;
			dp[i][1] = dp[i-1][1]*2;
		}
		else {
			dp[i][0] = dp[i][1] = dp[i-1][0]+dp[i-1][1];
		}
	}
	cout << dp[n][p] << endl;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	var total int
	for i := 1; i <= n; i++ {
		s := sumDigits(i)
		if a <= s && s <= b {
			total += i
		}
	}

	fmt.Println(total)
}

func sumDigits(n int) int {
	var sum int
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
	int K; int S; cin >> K >> S;
	int cnt = 0;

	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			int num = S - i - j;
			if (num >= 0 && num <= K) cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	string s,t;
	string ans="";
	ll dp[3030][3030];
	memset(dp,0,sizeof(dp));
	cin>>s>>t;
	REP(i,s.size())
		REP(j,t.size())
		{
			if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
		}
	int i=s.size();
	int j=t.size();
	while(i>0&&j>0)
		{
			if(dp[i][j]==dp[i-1][j])i--;
			else if(dp[i][j]==dp[i][j-1])j--;
			else {
				ans+=s[i-1];
				i--;
				j--;
			}
		}
	for(int i=ans.size()-1;i>=0;i--)
		cout<<ans[i];
	cout<<endl;
	return 0;
}



Measured memory_bytes: 71936
#include <iostream>
#include <vector>
using namespace std;
void output(vector<int> A)
{
    for(int i = 0; i < A.size(); ++i){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}
vector<int> insertionSort(vector<int> A)
{
    for(int i = 1; i < A.size(); ++i){
        output(A);
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
    }
    output(A);
    return A;
}
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    insertionSort(A);
    return 0;
}

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

int dn(int a,int b,int c,int d){
  return abs(c-a)+abs(d-b);
}

int main(){
  int n,m,i,j;
  cin>>n>>m;
  int a[n],b[n],c[m],d[m];
  for(i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  for(i=0;i<m;i++){
    cin>>c[i]>>d[i];
  }
  int min[n];
  for(i=0;i<n;i++){
    min[i]=0;
    for(j=0;j<m;j++){
      if(dn(a[i],b[i],c[j],d[j])<dn(a[i],b[i],c[min[i]],d[min[i]]))min[i]=j;
    }
  }
  for(i=0;i<n;i++){
    cout<<min[i]+1<<endl;
  }
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
nums = list(map(int, input()))

for n in range(3**2):
    ans = nums[0]
    ops = []
    for i in range(3):
        if 1 & (n >> i):
            ans += nums[i+1]
            ops.append('+')
        else:
            ans -= nums[i+1]
            ops.append('-')

    if ans == 7:
        b = ['%d%s' % (nums[i], ops[i]) for i in range(3)]
        b += ['%d' % nums[3]]
        print(''.join(b) + '=7')
        exit()



Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    cin>>n;
    double p[n];
    for (int i = 0; i < n; ++i)
    {
        /* code */
        cin>>p[i];
    }
    double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;

    for(int  i =1;i<=n;i++)
        for(int  j =0;j<=i;j++)
        {
           dp[i][j]+= ((j)?(dp[i-1][j-1]*p[i-1]):0.0)+dp[i-1][j]*(1-p[i-1]);
        }
    double sum = 0;
    for(int i =1;i<=n;i++)
    {
         if(i>n-i)
         {
            sum+= dp[n][i];
         }
    }
    cout<<fixed<<setprecision(10)<<sum<<endl;
}

Measured memory_bytes: 70528
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int a = INF;
    int cnt = 0;
    rep(i,N) {
        chmin(a,A[i]);
        if (a >= A[i]) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<ll> A(200010, 0);
vector<ll> v;

bool Solve1(int m, int mid){ return v[mid] - v[0] < v[m] - v[mid]; }
bool Solve2(int m, int mid){ return v[mid] - v[m] < v[N] - v[mid]; } 

int main(void){
    
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
    
    v = A;
    for(int i = 1; i < N; ++i) v[i + 1] += v[i]; 
    
    ll ans = LLONG_MAX;
    for(int m = 2; m <= N - 2; ++m){
        
        int ok = 0, ng = m;
	    while(abs(ok - ng) > 1){
		    int mid = (ok + ng) / 2;
		    if(Solve1(m, mid)) ok = mid;
		    else ng = mid;
	    }
        int Lmid = ( abs((v[m] - v[ok]) - v[ok]) < abs((v[m] - v[ng]) - v[ng]) ) ? ok : ng;
        
        ok = m, ng = N;
        while(abs(ok - ng) > 1){
		    int mid = (ok + ng) / 2;
		    if(Solve2(m, mid)) ok = mid;
		    else ng = mid;
	    }
        int Rmid = ( abs((v[N] - v[ok]) - (v[ok] - v[m])) < abs((v[N] - v[ng]) - (v[ng] - v[m])) ) ? ok : ng;
        
        ll b = v[Lmid], c = v[m] - v[Lmid], d = v[Rmid] - v[m], e = v[N] - v[Rmid];
        ll mx = max({b, c, d, e}), mn = min({b, c, d, e});
        ans = min(ans, abs(mx - mn));
        
    }
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>

using namespace std;

int main(){
    int H,W,D;
    int PanelX[90000];
    int PanelY[90000];
    cin>>H>>W>>D;
    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            int i;
            cin>>i;
            i--;
            PanelX[i]=h;
            PanelY[i]=w;
        }
    }
    
    int accum[90001]={};
    for(int i=0;i<H*W;i++){
        if(i<D){
            accum[i]=0;
        }else{
            int maryoku = abs(PanelX[i]-PanelX[i-D])+abs(PanelY[i]-PanelY[i-D]);
            accum[i]=accum[i-D]+maryoku;
        }
    }
    
    int Q;
    cin>>Q;
    for(int i=1;i<=Q;i++){
        int L,R;
        cin>>L>>R;
        L--; R--;
        int ans;
        if(L==R){
            ans=0;
        }else{
            ans=accum[R]-accum[L];
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>

int main(void){

    int  a, b, c, d;

    scanf("%d%d%d%d", &a, &b, &c, &d);

    while(1){
        c -= b;
        if(c <= 0){
            printf("Yes\n");
            break;
        }
        a -= d;
        if(a <= 0){
            printf("No\n");
            break;
        }

    }
    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<int> d;

    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }

    // ソート
    sort(d.begin(), d.end());

    int ans = d[N / 2] - d[N / 2 - 1];

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    string w;
    cin >> w;
    int n = w.size();
    map<char, int> m;
    rep(i, n)
    {
        m[w[i]]++;
    }
    string ans = "Yes";
    rep(i, n)
    {
        if (m[w[i]] % 2 != 0)
        {
            ans = "No";
            break;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int n;
vector<vector<int>> g;

int dfs(int pre,int now){
    int ret=0;
    for(auto to:g[now])if(to!=pre) ret^=1+dfs(now,to);
    return ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    cin>>n;
    g.resize(n);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int res=dfs(-1,0);
    if(res==0) cout<<"Bob\n";
    else cout<<"Alice\n";
    return 0;
}


Measured memory_bytes: 10368
#include <stdio.h>
#include <stdlib.h>

int change(char *a){
	for(;*a;++a){
		if(*a>='a'&&*a<='z'){
			*a-='a'-'A';
		}
		else if(*a>='A'&&*a<='Z'){
			*a+='a'-'A';
		}
	}
}

int main(){
	int n=1500;
	char* const a=(char*)malloc(n);
	if(a){
		if(fgets(a,n,stdin)){
			change(a);
			fputs(a,stdout);
		}
	}
	free(a);
	return 0;
}

Measured memory_bytes: 1748
n, *a = map(int, open(0).read().split())

# hantei
ok = True
for i in range(n - 1):
    if a[i + 1] - a[i] > 1:
        ok = False
if not ok or a[0] != 0:
    print(-1)
    exit()


ans = 0
a = list(reversed(a))
i = 0
while i < n:
    ans += a[i]
    while i < n - 1 and a[i] - 1 == a[i + 1]:
        i += 1
    i += 1
print(ans)


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

int main() {
  int score[6];
  for (int i = 0; i < 6; i++) {
    cin >> score[i];
  }

  int sum = 0;
  for (int i = 0; i < 6; i++) {
    sum += score[i];
  }
  
  int mini;
  mini = score[0];
  for (int i = 0; i <= 3; i++) {
    if (score[i] < mini) mini = score[i];
  }
  sum -= mini;

  if (score[4] < score[5]) mini = score[4];
  else mini = score[5];
  sum -= mini;

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
//#define Local
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 5005, MOD = 1e9 + 7;

int n;
struct Edge{
    int v, next;
}e[N << 1];
int head[N], tot;
void adde(int u, int v) {
    e[tot].v = v; e[tot].next = head[u]; head[u] = tot++;
}

ll g[N];
void init() {
    g[0] = 1;
    for(int i = 2; i < N; i += 2) g[i] = g[i - 2] * (i - 1) % MOD;
}

ll f[N][N], sz[N], tmp[N];
void dfs(int u, int fa) {
    f[u][sz[u] = 1] = 1;
    for(int i = head[u]; ~i; i = e[i].next) {
        int v = e[i].v;
        if(v == fa) continue;
        dfs(v, u);
        for(int j = 0; j <= sz[u] + sz[v]; j++) tmp[j] = f[u][j], f[u][j] = 0;
        for(int j = 1; j <= sz[u]; j++) {
            for(int k = 0; k <= sz[v]; k++) {
                (f[u][j + k] += (tmp[j] * f[v][k]) % MOD) %= MOD;
            }
        }
        sz[u] += sz[v];
    }
    for(int i = 2; i <= sz[u]; i += 2) {
        f[u][0] -= (f[u][i] * g[i] % MOD);
        f[u][0] %= MOD;
    }
    if(f[u][0] < 0) f[u][0] += MOD;
}

void run() {
    for(int i = 1; i <= n; i++) head[i] = -1; tot = 0;
    for(int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        adde(u, v); adde(v, u);
    }
    dfs(1, 0);
    cout << (MOD - f[1][0]) % MOD << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
#ifdef Local
    freopen("../input.in", "r", stdin);
    freopen("../output.out", "w", stdout);
#endif
    init();
    while(cin >> n) run();
    return 0;
}


Measured memory_bytes: 194944
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
	cin>>n>>a>>b;
	if((b-a)%2LL==0LL)
		cout<<(b-a)/2LL<<endl;
	else
	{
		long long ans=0LL;
		if(a-1LL<n-b)
		{
			ans+=a;
			b=b-a;
			a=1LL;
			ans+=(b-a)/2LL;
		}
		else
		{
			ans+=(n-b+1LL);
			a=a+(n-b+1LL);
			b=n;
			ans+=(b-a)/2LL;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    int odd_flag = 0;
    int count = 0;
    int tmp_A, tmp_B, tmp_C;
    while(odd_flag == 0)
    {
        if( A%2 == 1 || B%2 == 1 || C%2 == 1)
        {
            odd_flag = 1;
            break;
        }
        tmp_A = A;
        tmp_B = B;
        tmp_C = C;
        A = tmp_B/2 + tmp_C/2;
        B = tmp_C/2 + tmp_A/2;
        C = tmp_A/2 + tmp_B/2;
        
        if( A == B && B == C)
        {
            count = -1;
            break;
        }
        
        //cout << A << " "<< B << " "<< C << endl;
        count++;
        
    }
    cout << count << endl;

    
}


Measured memory_bytes: 256