akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

using P = pair<i64,i64>;

int N;
int M;

vector<int> L,R,D;

vector<vector<P>> edges;

vector<bool> visited;
vector<i64> dist;

bool dfs(int v){
    visited[v] = true;

    for(P edge : edges[v]){
        //edge = 頂点vから伸びている辺
        //edge.first ... 伸びた先
        //edge.second .. 差
        if(!visited[edge.first]){
            dist[edge.first] = dist[v] + edge.second;
            bool ok = dfs(edge.first);
            if(!ok){
                return false;
            }
        }
        else{
            //edge.firstの距離がすでに定まっている
            //矛盾していないかどうか調べる
            if(!(dist[edge.first] == dist[v] + edge.second)){
                return false;
            }
        }
    }
    return true;
}

int main(){
    cin >> N >> M;

    L.resize(M);
    R.resize(M);
    D.resize(M);

    edges.resize(N);
    visited.resize(N,false);
    dist.resize(N);
    rep(i,0,M - 1){
        cin >> L[i] >> R[i] >> D[i];
        L[i]--;
        R[i]--;
        edges[L[i]].push_back({R[i],D[i]});
        edges[R[i]].push_back({L[i],-D[i]});
    }

    rep(i,0,N - 1){
        if(!visited[i]){
            dist[i] = 0;
            bool ok = dfs(i);
            if(!ok){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 18816
#include <iostream>
#include <cstring>

using namespace std;

int main() {

	char str[20];

	cin >> str;

	//cout << strlen(str) << endl;

	for (int i = strlen(str) - 1; i >= 0; i--) {
		cout << str[i];
	}

	cout << endl;

	return 0;

}

Measured memory_bytes: 3016
n = int(input())
a,b = map(int,input().split())
p = list(map(int, input().split()))
p.sort()
ans = [0 for _ in range(3)]
for pp in p:
    if pp <= a:
        ans[0] += 1
    elif (a < pp and pp <= b):
        ans[1] += 1
    else:
        ans[2] += 1
print(min(ans))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    static final int[] DIGITS = { 0, 3, 5, 7 };

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        System.out.println(solve(N));

        sc.close();
    }

    static int solve(int N) {
        return search(N, 0, 9);
    }

    static int search(int N, int number, int rest) {
        if (rest == 0) {
            String s = String.valueOf(number);

            return (number <= N && s.indexOf('0') == -1 && s.chars().distinct().count() == 3) ? 1 : 0;
        }

        int result = 0;
        for (int digit : DIGITS) {
            result += search(N, number * 10 + digit, rest - 1);
        }

        return result;
    }
}

Measured memory_bytes: 62104
N=int(input())
A=[list(map(int,input().split())) for i in range(2)]
import pprint
#print(A)
dp=[[0 for _ in range(N)] for _ in range(2)]
dp[0][0]=A[0][0]
dp[1][0]=A[1][0]+A[0][0]
for i in range(1,N):
    #print(dp)
    dp[0][i]=dp[0][i-1]+A[0][i]
    dp[1][i]=max(dp[1][i-1]+A[1][i],dp[0][i]+A[1][i])
print(dp[1][N-1])

Measured memory_bytes: 38512
package main

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

type node struct {
	a, b int
}

type nodes []node

func (n nodes) Len() int {
	return len(n)
}

func (n nodes) Swap(i, j int) {
	n[i], n[j] = n[j], n[i]
}

func (n nodes) Less(i, j int) bool {
	return n[i].b < n[j].b
}

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	v := make(nodes, n)
	for i := range v {
		sc.Scan()
		v[i].a, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		v[i].b, _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(v)
	t := 0
	ok := true
	for _, e := range v {
		t += e.a
		if t > e.b {
			ok = false
			break
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

g = [[] for _ in range(n)]
edge = {}


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

m = int(input())


def dfs(u,v):
    visited = [False]*n
    visited[u] = True
    stack = [u]
    prev = [-1]*n
    while stack:
        uu = stack.pop()
        for vv in g[uu]:
            if not visited[vv]:
                visited[vv] = True
                prev[vv] = uu
                stack.append(vv)
        if prev[v] != -1:
            break
    bin_edge = 0
    head = v
    while head != u:
        bin_edge += 1 << edge[(head, prev[head])]
        head = prev[head]
    return bin_edge

intv = [0]*m

for i in range(m):
    u, v = map(int, input().split())
    intv[i] = dfs(u-1,v-1)


mm = 1 <<m

ans = 0

for i in range(mm):
    a = 0
    cnt = 0
    for j in range(m):
        if (i >> j) & 1:
            cnt += 1
            a = a | intv[j]
    white = str(bin(a)).count('1')
    ans += ((-1)**(cnt))*2**(n-1-white)

print(abs(ans))


Measured memory_bytes: 43280
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()

edges = [0] * (m-1)
for i in range(m-1):
    edges[i] = abs(x[i+1] - x[i])

edges.sort(reverse=True)
ans = sum(edges[n-1:])
print(ans)


Measured memory_bytes: 13960
fn getline() -> String{
  let mut __ret=String::new();
  std::io::stdin().read_line(&mut __ret).ok();
  return __ret;
}

fn main() {
  let line1 = getline();
  let _n:i32 = line1.trim().parse().unwrap();
  let line2 = getline();
  let mut vs:Vec<i64> = line2.trim().split(' ').map(|v| v.parse().unwrap()).collect();
  vs.sort();
  vs.reverse();

  let mut candidate = Vec::new();
  let mut prev = -1;
  for v in vs {
    if v == prev {
      candidate.push(v);
      prev = -1;
    } else {
      prev = v;
    }
  }
  candidate.push(0);
  candidate.push(0);
  let ans = candidate[0] * candidate[1];
  println!("{}", ans);
}

Measured memory_bytes: 6396
import java.util.Scanner;
import java.math.BigDecimal;

public class Main{
	Main(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] st = new String[3];
			for(int i = 0; i < 3; i++){
				st[i] = "";
			}
			String str = sc.next();
			char ch[] = str.toCharArray();
			int p = 0;
			for(int i = 0; i < str.length(); i++){
				if(ch[i] == '+' || ch[i] == '='){
					p++;
					continue;
				}
				st[p] += String.valueOf(ch[i]);
			}
			int s = 0;
			for(int i = 0; i < 3; i++){
				if(st[i].charAt(0) == 'X' && st[i].length() > 1){
					s = 1;
					break;
				}
			}
			int t = -1;
			for(int i = s; i <= 9; i++){
				BigDecimal bd1 = new BigDecimal(st[0].replaceAll("X", Integer.toString(i)));
				BigDecimal bd2 = new BigDecimal(st[1].replaceAll("X", Integer.toString(i)));
				BigDecimal bd3 = new BigDecimal(st[2].replaceAll("X", Integer.toString(i)));
				
				bd1 = bd1.add(bd2);
				if(bd1.compareTo(bd3) == 0){
					t = i;
					break;
				}
			}
			
			if(t == -1){
				System.out.println("NA");
			} else {
				System.out.println(Integer.toString(t));
			}
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<ll, ll>;
const int INF = 1001001001;

struct UnionFind{
  vector<int> par;
  UnionFind(int n) : par(n, -1){}
  int root(int x){ return (par[x] < 0) ? x : par[x] = root(par[x]); }
  int size(int x){ return -par[root(x)]; }
  bool issame(int x, int y){ return root(x) == root(y); }
  void marge(int x, int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(x > y) swap(x, y);
    par[x] += par[y];
    par[y] = x;
  }
};

int main(void){
  ll n;
  cin >> n;
  map<P, ll> xmp, ymp;
  set<P> st;
  vector<tuple<ll, ll, ll>> c;
  UnionFind uf(n);
  REP(i, n){
    ll x, y;
    cin >> x >> y;
    st.insert(P(x, y));
  }
  n = st.size();
  vector<P> xp(n), yp(n);
  ll i = 0;
  for(P p : st){
    xp[i] = p;
    xmp[p] = i;
    yp[i] = P(p.second, p.first);
    ymp[yp[i]] = i;
    i++;
  }
  sort(ALL(xp));
  sort(ALL(yp));
  auto cost = [](P a, P b){
    ll c = abs(a.first - b.first);
    ll d = abs(a.second - b.second);
    return min(c, d);
  };
  REP(i, n-1){
    ll p = xmp[xp[i]];
    ll q = xmp[xp[i+1]];
    c.emplace_back(cost(xp[i], xp[i+1]), p, q);
    p = ymp[yp[i]];
    q = ymp[yp[i+1]];
    c.emplace_back(cost(yp[i], yp[i+1]), p, q);
  }
  sort(ALL(c));
  ll ans = 0;
  ll m = c.size();
  for(ll i = 0; i < m && uf.size(0) != n; i++){
    ll d, p, q;
    tie(d, p, q) = c[i];
    if(uf.issame(p, q)) continue;
    uf.marge(p, q);
    ans += d;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 30832
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    vl b(n);rep(i,n)cin>>b[i];

    ll cap=0,need=0;
    rep(i,n){
        if(a[i]<b[i])cap+=(b[i]-a[i])/2;
        else need+=a[i]-b[i];
    }
    
    cerr<<need<<' '<<cap<<endl;
    cout<<(need<=cap?"Yes":"No")<<endl;
}

Measured memory_bytes: 384
a = [[0 for i in range(100)] for j in range(100)]
b = [0 for i in range(100)]
n, m = map(int, input().split())
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(m):
    b[i] = int(input())
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)

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

const int ComputeChangedNum(const std::string &S, const char frontColor);

int main(){
  
  std::string S;
  std::cin >> S;
  const int changedNum0 = ComputeChangedNum(S, '0');
  const int changedNum1 = ComputeChangedNum(S, '1');
  std::cout << std::min(changedNum0, changedNum1);
  
  return 0;
}

const int ComputeChangedNum(const std::string &S, const char frontColor){
  int count = 0;
  char expected = frontColor;
  for(const char ch : S){
    if(ch == expected) ++count;
    expected = expected == '0' ? '1' : '0';
  }
  return count;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }else {
                for (int i=0;i < H; i++){
                    for(int j=0;j < W; j++){
                        System.out.print("#");
                        }
                    System.out.println( );
                    }
                }
            System.out.println( );
            }
        }
    }


Measured memory_bytes: 35216
#include <bits/stdc++.h>
using namespace std;
struct point{
	int v;
	point *l,*r,*pa;
	point(){l=r=pa=NULL;}
	point(int vv):v(vv){l=r=pa=NULL;}
};
point *root;
void insert(int v){
	point *p,*pa=NULL;
	p=root;
	while(p){
		pa=p;
		if(v>=p->v)p=p->r;
		else p=p->l;
	}
	if(!pa){root=new point(v);return;}
	if(v>=pa->v)pa->r=new point(v);
	else pa->l=new point(v);
}
bool find(int v){
	point *p=root;
	while(p){
		if(v>p->v)p=p->r;
		else if(v<p->v)p=p->l;
		else return 1;
	}return 0;
}
void dfs1(point *p){
	if(!p)return;
	dfs1(p->l);
	printf(" %d",p->v);
	dfs1(p->r);
}
void dfs2(point *p){
	if(!p)return;
	printf(" %d",p->v);
	dfs2(p->l);
	dfs2(p->r);
}
void print(){
	dfs1(root);printf("\n");
	dfs2(root);printf("\n");
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int T;cin>>T;
	string s;int vv;
	bool first=0;
	while(T--){
		cin>>s;
		if(s=="insert")cin>>vv,insert(vv);
		else if(s=="find")cin>>vv,(printf("%s\n",find(vv)?"yes":"no"));
		else print();
	}
	return 0;
}


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

using namespace std;

const int N = 310;

long long dp[N][N], tmp[N][N];
long long h[N];
int n, K;

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

  set<long long> s;
  vector<long long> v;
  map<long long, int> pos;

  cin >> n >> K;
  s.insert(0);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
    s.insert(h[i]);
  }

  for (int val : s) {
    v.push_back(val);
    pos[val] = v.size() - 1;
  }

  for (int i = 0; i < n; ++i) {
    for (int k = 0; k <= K; ++k) {
      if (i == 0) {
        for (int j = 0; j < v.size(); ++j) {
          if (k == 0) {
            dp[k][j] = (v[j] == h[i] ? h[i] : (1LL << 60));
          } else {
            dp[k][j] = v[j];
          }
        }
      } else {
        long long val = (1LL << 60);
        long long val2 = (1LL << 60);
        for (int j = 0; j < v.size(); ++j) {
          if (k > 0) {
            val = min(val, tmp[k-1][j] - v[j]);
          }
          dp[k][j] = v[j] + val;
        }
        if (i > 0 && k > 0) {
          val = 1LL << 60;
          for (int j = v.size()-1; j >= 0; --j) {
            val = min(val, tmp[k-1][j]);
            dp[k][j] = min(dp[k][j], val);
          }
        }
        const int p = pos[h[i]];
        for (int j = 0; j < v.size(); ++j) {
          dp[k][p] = min(dp[k][p], tmp[k][j] + max(0LL, h[i] - v[j]));
        }
      }
    }

    swap(dp, tmp);
  }

  long long ans = 1LL << 60;
  for (int k = 0; k <= K; ++k) {
    for (int j = 0; j < v.size(); ++j) {
      ans = min(ans, tmp[k][j]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
x,y,a,b,c=map(int,input().split())
red=sorted(list(map(int,input().split())),reverse=True)
green=sorted(list(map(int,input().split())),reverse=True)
white=sorted(list(map(int,input().split())),reverse=True)
eat_list=sorted(red[:x]+green[:y])
for i in range(min(len(eat_list),len(white))):
  if eat_list[i]<white[i]:
    eat_list[i]=white[i]
  else:
    break
print(sum(eat_list))


Measured memory_bytes: 23200
Module Program
  Sub Main
    Dim s = GetInts()
    Dim a=s(0)
    Dim ans=a\3
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int mod=1e9+7;
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
LL p[100010];
int main(){
//    freopen("B-small-attempt1.in","r",stdin);
//    freopen("output.txt","w",stdout);
    int n,m;
    p[0]=1;
    for(int i=1;i<=100000;i++){
        p[i]=p[i-1]*i%mod;
    }
    cin>>n>>m;
    if(n>m) swap(n,m);
    if(n==m){
        cout<<p[n]*p[n]%mod*2%mod<<endl;;
    }
    else if(n+1==m){
        cout<<p[n]*p[m]%mod<<endl;
    }
    else puts("0");
	return 0;
}
/*
*/


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;
  ll a[n],b[n];rep(i,0,n)cin>>a[i]>>b[i];
  ll ans=0;
  for(ll i=n-1;i>=0;i--){
    if(b[i]!=1&&(a[i]+ans)%b[i]!=0)ans+=b[i]-(a[i]+ans)%b[i];
  }

  out(ans);



  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  ll ar[4];
//  rep(i,0,4) {cin>>ar[i];k=max(k,ar[i]);l=min(l,ar[i]);}
  cin>>n;
  cin>>s>>r;
  rep(i,0,n)
  {
    cout<<s[i]<<r[i];
  }
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(26));

    for(int i=0;i<n;i++){
        string s;
        cin>> s;
        for(int j=0;j<s.size();j++){
            int tmp = s[j] - 'a';
            v[i][tmp]++;
        }
    }

    string str(" ");

    for(int j=0;j<26;j++){
        int mi=1e8;
        bool ok=true;
        for(int i=0;i<n;i++){
            if(v[i][j]==0){ok=false;break;}

            mi = min(mi,v[i][j]);
        }
        if(ok)
            for(int i=0;i<mi;i++){
                if(str==" ")
                    str = j + 'a';
                else
                    str += j + 'a';
            }
    }

    sort(str.begin(),str.end());

    cout<<str;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
 
	// ??????????????\????????????2????????°?????\???????????°
	int line, column;
	scanf("%d %d", &line, &column);
	
	// ???????????????????????????
	int grid[line+1][column+1];
	
	for(int cnt1 = 0; cnt1 <= line; cnt1++) {
	  
	  for(int cnt2 = 0; cnt2 <= column; cnt2++) {
	    
	    grid[cnt1][cnt2] = 0;
	  }
	}
	
	// ????????????????????\??????
	for(int cnt1 = 0; cnt1 <= line; cnt1++) {
		
		if(cnt1 < line) {
			
			for(int cnt2 = 0; cnt2 <= column; cnt2++) {
				
				if(cnt2 < column) {
				
					scanf("%d", &grid[cnt1][cnt2]);
					printf("%d ", grid[cnt1][cnt2]);
					
					// ??????????????????????????????????¨??????\??????
					grid[cnt1][column] += grid[cnt1][cnt2];
					
					// ??????????????????????????????????¨??????\??????
					grid[line][cnt2] += grid[cnt1][cnt2];
					
				// ??????????¨??????????	
				} else {
					
					printf("%d\n", grid[cnt1][cnt2]);
					grid[line][column] += grid[cnt1][cnt2];
				}
			}
			
		} else {
			
			for(int cnt2 = 0; cnt2 <= column; cnt2++) {
				
				if(cnt2 != column) {
					
					printf("%d ", grid[cnt1][cnt2]);
					
				} else {
					
					printf("%d\n", grid[cnt1][cnt2]);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1820
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 998244353;
const int INF = 1LL << 55;

signed main() {
    int N;
    string str;
    cin >> N >> str;

    vector<int> black_sm(N + 1, 0);
    vector<int> white_sm(N + 1, 0);

    for (int i = 0; i < N; i++) {
        black_sm[i+1] = black_sm[i];
        white_sm[i+1] = white_sm[i];
        if (str[i] == '.') { // white
            white_sm[i+1] += 1;
        } else {
            black_sm[i+1] += 1;
        }
    }

    int ret = INF;
    for (int i = -1; i < N; i++) {
        if (i < 0) {
            ret = min(ret, white_sm[N]);
            continue;
        }

        int cnt = black_sm[i+1] + white_sm[N] - white_sm[i+1];
        ret = min(ret, cnt);
    }

    cout << ret << endl;

    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  string s; cin >> s;
  vector<int> v(3);
  for(auto e:s)v[e-'a']++;
  sort(v.begin(), v.end());
  cout << (v.back()-v.front() >= 2 ? "NO" : "YES") << endl;
}



Measured memory_bytes: 3716
#include <cstring>
#include <cstdio>
#include <algorithm>
const int MAXN = 200010;
using namespace std;

int N, A[MAXN], val[MAXN], Ans = 0;

int main() {
	int i;
	scanf("%d", &N);
	for(i = 1; i <= N; i++) scanf("%d", &A[i]);
	for(i = N; i >= 1; i--) {
		val[ A[i] ] = val[ A[i] + 1 ] + 1;
		Ans = max(Ans, val[ A[i] ]);
	}
	printf("%d", N - Ans);
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

double dp[101][101];
double tmp[101][101];
int h,n,p,m,k;

int a[501];

int main() {
    for(int i=0; i<101; ++i)
        for(int j=0; j<101; ++j)
            dp[i][j] = 0.0;

    cin>>h>>n>>p>>m>>k;
    p--;

    for(int i=0; i<=h; ++i) a[i] = -1;
    int at,bt;
    for(int i=0; i<m; ++i) {
        cin>>at>>bt;
        at--,bt--;
        a[at] = bt;
    }

    dp[0][p] = 1;
    int rem = h-m;

    for(int i=h-1; i>=0; --i) {
        for(int j=0; j<n; ++j) for(int l=0; l<=k; ++l) tmp[l][j] = 0;

        // cout<<endl<<i<<endl;
        // for(int j=0; j<n; ++j) {
        //     for(int l=0; l<=k; ++l) {
        //         cout<<dp[l][j]<<" ";
        //     }
        //     cout<<endl;
        // }


        if(a[i] != -1) {
            for(int j=0; j<n; ++j) {
                for(int l=0; l<=k; ++l) {
                    if(a[i] == j) {
                        tmp[l][j] = dp[l][j+1];
                    }else if(a[i] == j-1) {
                        tmp[l][j] = dp[l][j-1];
                    }else tmp[l][j] = dp[l][j];
                }
            }
        }else{
            for(int l=0; l<=k; ++l) {
                double p = (double)(k-l)/rem;
                if(p > 1) continue;
//                cout<<p<<" : "<<(1-p)<<" -> "<<rem<<endl;
                for(int j=0; j<n; ++j) {
                    double pp = p/(n-1);
                    if(j == 0) {
                        tmp[l+1][j+1] += dp[l][j] * p / (n-1);
                        tmp[l+1][j] += dp[l][j] * p * (n-2) / (n-1);
                    }else if(j == n-1) {
                        tmp[l+1][j-1] += dp[l][j] * p / (n-1);
                        tmp[l+1][j] += dp[l][j] * p * (n-2) / (n-1);
                    }else{
                        tmp[l+1][j-1] += dp[l][j] * p / (n-1);
                        tmp[l+1][j+1] += dp[l][j] * p / (n-1);
                        tmp[l+1][j] += dp[l][j] * p * (n-3) / (n-1);
                    }
                    tmp[l][j] += dp[l][j] * (1-p);
                }
            }
            rem--;
        }

        for(int j=0; j<n; ++j) {
            for(int l=0; l<=k; ++l) {
                dp[l][j] = tmp[l][j];
            }
        }
    }

    double ans = 0;
    for(int j=0; j<n; ++j) {
        ans = max(ans, dp[k][j]);
    }
    printf("%.12f\n", ans);
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer tree[] = new Integer[n];
		for (int i = 0; i < n; i++) {
            tree[i] = sc.nextInt();
		}		
		Arrays.sort(tree);
		int r = 0;
		for (int j = 0; j < k; j++) {
			r = r + tree[j];
		}
	  System.out.println(r);
	  sc.close();
	}
}

Measured memory_bytes: 39092
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    
    int ans = -1;
    for (int i = 1; i <= 1250; i++) {
        if ((int)(i*0.08) == a && (int)(i*0.1) == b) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
from bisect import bisect_left
a, b, c, d, e, f = map(int, input().split())
mw = []
for i in range(31):
    for j in range(31):
        mw.append(a * i + b * j)
mw.sort()

ms = []
for i in range(3001):
    for j in range(3001):
        ms.append(- (c * i + d * j))

ms.sort()

ans = 0
ans_mw = mw[1]
ans_ms = 0

for mwi in mw[1:]:
    if mwi * 100 > f:
        break
    target = min(f - mwi * 100, mwi * e)
    msi = -ms[bisect_left(ms, - target)]
    cand = msi / mwi
    if mwi * 100 + msi <= f and cand > ans:
        ans = cand
        ans_mw = mwi
        ans_ms = msi

print(ans_mw * 100 + ans_ms, ans_ms)


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

int main(){
  int i, A[100];

  cin >> i;
  for (int j=0; j<i; j++)
    cin >> A[j];

  int j;
  for (j=0; j<i-1; j++)
    cout << A[j] << ' ' ;
  cout << A[j] << endl;

  for (int j=1; j<i; j++){
    int key = A[j];
    for (int k=0; k<j; k++)
      if (A[k] > A[j])
        swap(A[k], A[j]);
    int k;
    for (k=0; k<i-1; k++)
      cout << A[k] << ' ' ;
    cout << A[k] << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
def insertionSort(a, n, g):
    global cnt
    for i in range(g, n):
        tmp = a[i]
        j = i - g
        while j >= 0 and a[j] > tmp:
            a[j+g] = a[j]
            j = j - g
            cnt += 1
        a[j+g] = tmp

cnt = 0
n = int(input())
a = [int(input()) for _ in range(n)]

i = 0
g = [1]
while 3*g[i]+1 < n:
    g.append(3*g[i]+1)
    i += 1
g.reverse()
m = len(g)

for i in range(m):
    insertionSort(a, n, g[i])

print(m)
print(*g)
print(cnt)
print(*a, sep="\n")




Measured memory_bytes: 53292
#include <stdio.h>

typedef struct{
  char egara;
  int value;
} card;

int main()
{
  int i,j,N,minj,judge=0;
  card C[36],C2[36],c;


  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c%d",&C[i].egara,&C[i].value);
  }
  for(i=0;i<N;i++){
    C2[i]=C[i];
  }


  /* BubbleSort */
  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(C[j].value < C[j-1].value){
	c = C[j];
	C[j] = C[j-1];
	C[j-1]=c;
      }
    }
  }


  /* SelectionSort */
  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(C2[j].value < C2[minj].value){
	minj = j;
      }
    }
    if(minj!=i){
      c = C2[i];
      C2[i] = C2[minj];
      C2[minj]=c;
    }
  }

  for(i=0;i<N-1;i++){
    printf("%c%d ",C[i].egara,C[i].value);
  }
  printf("%c%d\n",C[i].egara,C[i].value);

  printf("Stable\n");

  for(i=0;i<N-1;i++){
    printf("%c%d ",C2[i].egara,C2[i].value);
  }
  printf("%c%d\n",C2[i].egara,C2[i].value);

  /* 比較 */
  for(i=0;i<N;i++){
    if(C2[i].egara!=C[i].egara){
      judge=1;
      break; 
    }
  }
  if(judge==1) printf("Not stable\n");
  else printf("Stable\n");
  return 0;
}

Measured memory_bytes: 608
#include <cstdio>
using namespace std;

bool check(double p1[3], double p2[3], double v1[3], double v2[3], double v3[3]) {
  int i, p, q;
  double  a[3], b[3], c[3], d[3], n[3], m[3], x, y, z;

  for (i=0; i<3; i++) a[i] = v2[i] - v1[i];
  for (i=0; i<3; i++) b[i] = v3[i] - v1[i];
  n[0] = a[1]*b[2] - a[2]*b[1];
  n[1] = a[2]*b[0] - a[0]*b[2];
  n[2] = a[0]*b[1] - a[1]*b[0];

  for (i=0; i<3; i++) c[i] = p1[i] - v1[i];
  for (i=0, x=0.0; i<3; i++) x += c[i] * n[i];
  for (i=0; i<3; i++) d[i] = p2[i] - v1[i];
  for (i=0, y=0.0; i<3; i++) y += d[i] * n[i];
  if ((x>0.0&&y>0.0) || (x<0.0&&y<0.0)) return true;

  z = x/(x-y);
  for (i=0; i<3; i++) m[i] = (1.0-z)*c[i] + z*d[i];

  for (i=0; i<3; i++) if (n[i]<0.0) n[i] = -n[i];
  if (n[0]>n[1] && n[0]>n[2]) p=1, q=2;
  else if (n[1]>n[2]) p=2, q=0;
  else p=0, q=1;
  z = 1.0/(a[p]*b[q]-a[q]*b[p]);
  x = (b[q]*m[p]-b[p]*m[q])*z;
  y = (a[p]*m[q]-a[q]*m[p])*z;
  return (x<0.0 || y<0.0 || x+y>1.0);
}

int main() {
  int i;
  double p1[3], p2[3], v1[3], v2[3], v3[3];
  for (i=0; i<3; i++) scanf("%lf", &p1[i]);
  for (i=0; i<3; i++) scanf("%lf", &p2[i]);
  for (i=0; i<3; i++) scanf("%lf", &v1[i]);
  for (i=0; i<3; i++) scanf("%lf", &v2[i]);
  for (i=0; i<3; i++) scanf("%lf", &v3[i]);
  if (check(p1, p2, v1, v2, v3)) {
    printf("HIT\n");
  } else {
    printf("MISS\n");
  }
  return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    Int x;
    cin >> x;
    Int money = 100;
    int ans = 0;
    while (money < x) {
        money += money / 100;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
// abc117d
ll dp[51][2];
int main() {
  ll n,k; cin >> n >> k;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  int bits = 45;
  memset(dp, -1, sizeof(dp));
  dp[bits][1] = 0;
  for (int i=bits-1; i>=0; --i) {
   // num of 1's of a[j][i] for j <- 0..n-1
    ll cnt = 0;
    rep(l, n) if ((a[l] >> i) & 1) cnt++;
    // If you make a 0, it increses by # of 1's * keta; if you make a 1 # of 0's
    // 0->0
    ll digit = 1ll << i;
    if (dp[i+1][0] >= 0) {
      chmax(dp[i][0], dp[i+1][0] + (ll) (cnt)*digit); // x[i] = 0
      chmax(dp[i][0], dp[i+1][0] + (ll) (n-cnt)*digit); // x[i] = 1
    } 
    // 1->0
    if (dp[i+1][1] >= 0) {
      if ((k >> i)&1) {
        chmax(dp[i][0], dp[i+1][1] + (ll)(cnt) * digit); // x[i] = 0
      }
      // 1->1
      if ((k>>i) & 1) chmax(dp[i][1], dp[i+1][1] + (ll)(n - cnt) * digit);
      else chmax(dp[i][1], dp[i+1][1] + (ll)(cnt) * digit);
    }
  }
  ll ans = max(dp[0][0], dp[0][1]);
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 4108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef long long ll;
const int MOD = (int)1e9 + 7;
int add(int x, int y)
{
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y)
{
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y)
{
	return ((ll)x * y) % MOD;
}

const int N = 3030;
int n;
char s[N];
int a[N];
int b[N];
int dp[N][N];
int C[N][N];

void read()
{
	int m;
	scanf("%d%d", &n, &m);
	scanf(" %s ", s);
	for (int i = 0; i < n; i++)
		a[i] = (int)(s[i] - '0');
	for (int i = 0; i < n; i++)
		b[i] = i + 1;
	while(m--)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		l--;
		b[l] = max(b[l], r);
	}
	for (int i = 1; i < n; i++)
		b[i] = max(b[i], b[i - 1]);
}

int main()
{
	read();

	for (int i = 0; i < N; i++)
		C[i][0] = C[i][i] = 1;
	for (int i = 1; i < N; i++)
		for (int j = 1; j < i; j++)
			C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
	
	dp[0][0] = 1;
	int cur = 0;
	for (int i = 0; i < n; i++)
	{
		int willAdd = 0;
		while(cur < b[i])
		{
			willAdd += a[cur];
			cur++;
		}
		for (int x = 0; x <= n; x++)
		{
			if (dp[i][x] == 0) continue;
			int y = x + willAdd;
			if (y != 0)
				dp[i + 1][y - 1] = add(dp[i + 1][y - 1], dp[i][x]);
			if (y != cur - i)
				dp[i + 1][y] = add(dp[i + 1][y], dp[i][x]);
		}
	}
	printf("%d\n", dp[n][0]);

	return 0;
}

Measured memory_bytes: 40448
import java.util.Scanner;

public class Main {
	void run() {
		Scanner  scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++) {
			a[i] = new int[m];
		}
		int[] b = new int[m];
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a[i][j] = scan.nextInt();
			}
		}
		for (int i = 0; i < m; i++) {
			b[i] = scan.nextInt();
		}
		for (int i = 0; i < n; i++) {
			int sum = 0;
			for (int j = 0; j < m; j++) {
				sum += a[i][j] * b[j];
			}
			System.out.println(sum);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 40392
//In the name of God!
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e6 + 12;

string s;
set<char> se;
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> s;
    for(int i = 0; i < s.size(); i++)
        se.insert(s[i]);
    if(se.size() == 2)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(K: int, A: int, B: int):
    for s in range(A, B+1):
        if s % K == 0:
            print("OK")
            return
    print("NG")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 5;
int L[N] = {}, R[N] = {};
int gd[N] = {};
string str, pre;
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, c, k;
    cin >> n >> c >> k;
    cin >> str;
    if (k == 0) {
        int cnto = 0;
        for (const char &c : str)
            cnto += c == 'o';
        if (cnto == c)
            for (int i = 1; i <= n; i++)
                 if (str[i - 1] == 'o')
                    cout << i << '\n';
        return 0;
    }
    k++;
    for (int i = 0; i < k; i++)
        pre.push_back('x');
    str = pre + str + pre;
    for (int i = k; i < n + k + k; i++)
        L[i] = (str[i] == 'o' ? L[i - k] + 1 : L[i - 1]);
    for (int i = n + k - 1; i >= 0; i--)
        R[i] = (str[i] == 'o' ? R[i + k] + 1 : R[i + 1]);
    for (int i = 1; i < n + k; i++)
        gd[i] = L[i] + R[i + k];
    deque<int> deq;
    for (int i = 1; i < n + k; i++) {
        while (!deq.empty() && gd[deq.back()] <= gd[i - 1])
            deq.pop_back();
        deq.emplace_back(i - 1);
        if (deq.front() <= i - k)
            deq.pop_front();
        if (str[i] == 'o' && !deq.empty() && gd[deq.front()] < c)
            cout << i - k + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 5456
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::*;
use proconio::{input, fastout, marker::*};

fn powmod(x:i64 , y:i64) -> i64 {
  let MOD = 10i64.pow(9)+7;
  let mut ans:i64 = 1;
  for _i in 0..y {
      ans = ans*x%MOD;
  }
  ans
}

fn better_mod(x:i64 , y:i64) -> i64 {
  let mut res = x%y;
  if (res < 0){ res += y;}
  res
}

#[fastout]
fn main() {
  input!{
    n:i64
  }
  let MOD = 10i64.pow(9)+7;
  println!("{}",(better_mod(better_mod(powmod(10,n)-powmod(9,n),MOD)-powmod(9,n),MOD)+powmod(8,n))%MOD);
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
using namespace std;
const long MOD=1e9+7;
template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}

int main(){
    long n;cin >> n;
    vector<long> a(n);
    long ans=-1;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans=max(ans,abs(a[i]-a[j]));
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
  //printf("総フレーム数：");
  int N;
  scanf("%d",&N);
  int Array[N];
  int a;
  for(int i=0;i<N;i++){
    scanf("%d",&a);
    Array[i] = a;
  }
  int sum = 0;
  for(int j=0;j<N;j++){
    sum += Array[j];
  }
  double ave = (double)sum/(double)N;
  double sa;
  double min = 0;
  double MIN = 0;
  int A=0;
  sa = Array[0] - ave;
  min = fabs(sa);
  for(int k=1;k<N;k++){
    sa = Array[k] - ave;
    MIN = fabs(sa);
    if(min>MIN){
      min = MIN;
      A = k;
    }
  }
  printf("%d\n",A);
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) {
        cin >> A[i];
    }
    sort(A, A + N);
    int L = A[0];
    vector<P> v;
    rep(i, N - 2) {
        if (A[i + 1] >= 0) {
            v.push_back({A[0], A[i + 1]});
            A[0] -= A[i + 1];
        }
        else  {
            v.push_back({A[N - 1], A[i + 1]});
            A[N - 1] -= A[i + 1];
        }
    }
    int M = A[N - 1] - A[0];
    v.push_back({A[N - 1], A[0]});
    cout << M << endl;
    rep(i, v.size()) {
        cout << v[i].first << " " << v[i].second << endl;
    }

    return 0;
}


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

a = []
b = []

for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a.sort()
b.sort()

x, y = 0, 0

if n % 2 == 1:
    x = b[n//2]
    y = a[n//2]
else:
    x = b[n//2] + b[n//2-1]
    y = a[n//2] + a[n//2-1]

print(x-y+1)


Measured memory_bytes: 25504
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        for(int i = 0; i < N; i++){
            int x = sc.nextInt();
            if(x > X) X = x;
        }
        for(int j = 0; j < M; j++){
            int y = sc.nextInt();
            if(y < Y) Y = y;
        }
        sc.close();
        if(X < Y) System.out.println("No War");
        else System.out.println("War");

    }

}


Measured memory_bytes: 21716
int main(void){
    
  int n,b,f,r,v,i,j,k;
  int count[4][3][10]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    count[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        printf(" %d",count[i][j][k]);
      }
      printf("\n");
    }
    if(!(i==3)){
      for(k=0;k<20;k++){
        printf("#");
      }
      printf("\n");
    }
  }
  return 0;
}




Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,d;
    cin>>n>>d;
    ll cnt=0;
    for(ll i=0;i<n;++i){
        ll x,y;
        cin>>x>>y;
        if(x<0) x*=-1;
        if(y<0) y*=-1;
        long double dist = sqrt((x*x)+(y*y));
        //cout<<x<<" "<<y<<" "<<dist<<endl;
        if(dist<=d) {
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    char c;
    cin >> c;
    cout << char(c+1) << endl;
    

    
    // system("pause");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin =new Scanner(System.in);
		int a=0,b=0;
		for(int i = 0;i<4;i++){
			a+=cin.nextInt();
		}
		for(int i = 0;i<4;i++){
			b+=cin.nextInt();
		}
		System.out.println(Math.max(a, b));
	}

}

Measured memory_bytes: 11000
#include<stdio.h>
#include<string.h>
#define LEN 100005
int min(int a,int b){
  return a < b ? a : b;
}

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  if ( tail == LEN )
    tail = 1;
  else tail++;
}

P dequeue(){
  P x = Q[head];
  if ( head == LEN )
    head = 1;
  else head++;
  return x;
}

int main(){
  int elaps = 0, c, i, q;
  P u;
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++)
    scanf("%s %d", Q[i].name, &Q[i].t);

  head = 1; tail = n+1;

  while( head != tail ){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 )
      enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}



Measured memory_bytes: 12020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  
  int coin = N % 500;
  
  if (A >= coin) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> V(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    V[i] = make_pair(a,b);
  }
  sort(V.begin(),V.end());
  
  priority_queue<int> Q;
  int now=0,ans=0;
  for(int i=1;i<=M;i++){
    while(true){
      if(V[now].first==i){
        Q.push(V[now].second);
        now++;
      }
      else break;
    }
    if(Q.empty()) continue;
    ans += Q.top();
    Q.pop();
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main(){
  int ans;
  vector<int> x(5);
  for(int i = 0; i < 5; i++){
    cin >> x[i];
    if(x[i] == 0){
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
}

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

ll frog2(ll N, ll a[], ll k)
{
    ll dp[N+1];
    dp[0] = 0;
    dp[1] = a[0];
    dp[2] = abs(a[1] - a[0]);
    for( ll i = 3; i <= N; i++)
    {
        dp[i] = INT_MAX;
        for(ll j = 1 ; j <= k; j++)
        if(i-j-1>=0)
        {
            if(i-j-1 == 0)
                dp[i] = min(dp[i], abs(a[i-1] - a[i-j-1]));
            else
                dp[i] = min(dp[i], dp[i-j] + abs(a[i-1]-a[i-j-1]));
        }  
    }

    return dp[N];
}


int main()
{
    ll N, k;
    cin>>N>>k;
    ll a[N];
    for(ll i = 0; i < N; i++) cin>>a[i];
    cout << frog2(N,a,k);
}

Measured memory_bytes: 5148
S = input()
init_count = len(S)

tmp_i = 0
while len(S) > 1:
    no_01 = True
    before_s = None
    for i, s in enumerate(S[tmp_i:]):
        if i == 0:
            before_s = s
            continue
        if before_s != s:
            no_01 = False
            # print(S[:tmp_i + i-1], '(', S[tmp_i + i - 1], ' | ', S[tmp_i + i],  ')', S[tmp_i + i+1:])
            newS = S[:tmp_i + i-1] + S[tmp_i + i+1:]
            S = newS
            # print('newS: ', newS)
            tmp_i = tmp_i + i - 2
            if tmp_i < 0:
                tmp_i = 0
            # print(tmp_i)
            break
    if no_01:
        break
print(init_count - len(S))

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

int main() {
  int N, A;
  string op;
  cin >> N >> A;

  if (N % 500 == 0) {
    cout << "Yes" << endl;
  }
  else {
    if (N % 500 <= A) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    static String getEra(int ymd) {
        if (ymd < 18680908) {
            return "pre-meiji";
        } else if (ymd < 19120730) {
            return "meiji";
        } else if (ymd < 19261225) {
            return "taisho";
        } else if (ymd < 19890108) {
            return "showa";
        } else {
            return "heisei";
        }
    }

    static int getYear(String s, int y) {
        int base = 0;
        if (s.equals("meiji")) {
            base = 1868;
        } else if (s.equals("taisho")) {
            base = 1912;
        } else if (s.equals("showa")) {
            base = 1926;
        } else if (s.equals("heisei")) {
            base = 1989;
        }
        return y - base + 1;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        while ((line = br.readLine()) != null) {
            String[] input = line.split(" ");
            int year = Integer.parseInt(input[0]);
            int month = Integer.parseInt(input[1]);
            int day = Integer.parseInt(input[2]);

            StringBuilder value = new StringBuilder();
            value.append(year);
            if (month < 10)
                value.append(0);
            value.append(month);
            if (day < 10)
                value.append(0);
            value.append(day);

            String eraName = getEra(Integer.parseInt(value.toString()));

            if (eraName.equals("pre-meiji")) {
                System.out.println(eraName);
            } else {
                int yearX = getYear(eraName, year);
                System.out.printf("%s %d %d %d%n", eraName, yearX, month, day);
            }
        }
    }
}


Measured memory_bytes: 24536
'use strict'

const main = input => {
	const args = input.trim().split(' ').map(Number)
	let sum = 0

	if (args[0] > args[1]) {
		sum += args[0]
		args[0]--
	} else {
		sum += args[1]
		args[1]--
	}

	if (args[0] > args[1]) {
		sum += args[0]
	} else {
		sum += args[1]
	}

	console.log(sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int check(string x)
{
    int len=x.length();
    int i=0,j=len-1;
    while(i<=j)
    {
        if(x[i]!=x[j])
        return 0;
        i++;
        j--;
    }
    return 1;
}
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    if(check(s.substr(0,(n-1)/2))&&check(s.substr((n+1)/2))&&check(s))
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 256