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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<P> ba(n);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    ba[i] = make_pair(b, a);
  }
  sort(ba.begin(), ba.end());

  bool ok = true;
  int cur = 0;
  rep(i, n) {
    cur += ba[i].second;
    if (cur > ba[i].first) {
      ok = false;
      break;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 1792
n = gets.to_i
a = gets.split.map(&:to_i)
r0 = 0
for i in 0...n do
  r0 += a[i] * (i % 2 == 0 ? 1 : -1)
end
r = [r0]
for i in 1...n do
  r[i] = a[i-1] * 2 - r[i-1]
end
puts r.join(" ")


Measured memory_bytes: 14156
#include <stdio.h>

int main(void)
{
  int n[5],i,k,t,j;

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

  for(i=4;i>=1;i--){
    for(j=i-1;j>=0;j--){
      t=n[i]-n[j];
      if(t>k){
        printf(":(");

        return 0;
      }
    }
  }

  printf("Yay!");

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <vector>
#include <iostream>
// #include <bits/stdc++.h>

using namespace std;
#define _GLIBCXX_DEBUG

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

    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a <= k)
    {
        printf("Yay!");
    }
    else
    {
        printf(":(");
    }

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::collections::*;

fn prime_factorization(x: i64) -> std::collections::BTreeMap<i64, i64> {
    (std::iter::once(2).chain((3..).step_by(2)))
        .scan(x, |state, i| match *state {
            1 => None,
            _ => {
                let divisor = if i * i <= *state { i } else { *state };
                let mut index = 0;
                while *state % divisor == 0 {
                    *state /= divisor;
                    index += 1;
                }
                Some((divisor, index))
            }
        })
        .filter(|&(_, index)| index > 0)
        .collect()
}

fn main() {
    input! {
        n:i64
    }
    let ans: i64 = prime_factorization(n)
        .iter()
        .map(|(_, &index)| {
            (1..)
                .take_while(|&i| index >= i * (i + 1) / 2)
                .last()
                .unwrap()
        })
        .sum();
    println!("{}", ans);
}

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

int main() {
  string n;
  cin >> n;
  int ans = 0;
  int moveUp = 0;
  for(int i = n.length()-1; i >= 0; i--){
    int num = (int)n.at(i) -'0' + moveUp;
    if(num < 5){
      ans += num;
      moveUp = 0;
    }else if(num == 5){
      ans += num;
      moveUp = (((int)n[i-1] - '0' > 4) ? 1 : 0);
    }else{
      ans += 10 - num;
      moveUp = 1;
    }
  }
  cout << ans + moveUp << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;

int main()
{
	ll k; string s;
	cin >> s >> k;
	ll n = s.size();
	if(n == 1)
	{
		cout << k / 2 << endl;
		return 0;
	}
	
	bool flag = true;
	for(int i = 0; i < n; i++)
	{
		if(s[i] != s[0]) flag = false;
	}
	if(flag)
	{
		cout << n * k / 2 << endl;
		return 0;
	}
	
	vi ciclos(1, 1);
	
	for(ll i = 1; i < n; i++)
	{
		if(s[i] == s[i - 1])
		{
			ciclos[ciclos.size() - 1]++;
		}
		else
		{
			ciclos.push_back(1);
		}
	}
	
	ll total = 0;
	ll m = ciclos.size();
	
	for(ll i = 1; i < m - 1; i++)
	{
		total += (ciclos[i] / 2) * k;
	}
	
	if(s[0] == s[n - 1])
	{
		total += (ciclos[0] / 2) + (ciclos[m - 1] / 2) + ((ciclos[0] + ciclos[m - 1]) / 2) * (k - 1);
	}
	else
	{
		total += (ciclos[0] / 2) * k + (ciclos[m - 1] / 2) * k;
	}
	
	cout << total << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        var NK = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, K) = (NK[0], NK[1]);
        var RSP = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (R, S, P) = (RSP[0], RSP[1], RSP[2]);
        var T = ReadLine();

        var Hand2Point = new Dictionary<char, int>() { { 'r', R }, { 's', S }, { 'p', P } };
        var WinHand = new Dictionary<char, char>() { { 'r', 'p' }, { 's', 'r' }, { 'p', 's' } };

        IEnumerable<char> GetSkipT(int n)
        {
            for (int i = n; i < T.Length; i += K)
                yield return T[i];
        }

        var skipT = Enumerable.Range(0, K).Select(x => GetSkipT(x).ToArray()).ToArray();

        var ans = 0;

        for (int i = 0; i < K; i++)
        {
            var point = 0;
            var prevNotWinPoint = 0;
            var prevWinHand = ' ';

            for (int j = 0; j < skipT[i].Length; j++)
            {
                var enemyHand = skipT[i][j];
                var winHand = WinHand[enemyHand];

                var tempPoint = point;

                if (winHand == prevWinHand)
                    point = prevNotWinPoint + Hand2Point[winHand];
                else
                    point += Hand2Point[winHand];

                prevNotWinPoint = tempPoint;
                prevWinHand = winHand;
            }

            ans += point;
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 38748
package main

import "fmt"

func main() {

	var (
		n int
		q int
		s string
		l int
		r int
	)

	fmt.Scan(&n, &q)
	acCnt := make([]int, n)

	fmt.Scan(&s)

	for i := 1; i < n; i++ {
		acCnt[i] = acCnt[i-1]
		if s[i-1] == 'A' && s[i] == 'C' {
			acCnt[i]++
		}
	}

	for i := 0; i < q; i++ {
		fmt.Scan(&l, &r)
		fmt.Println(acCnt[r-1] - acCnt[l-1])
	}
}


Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

struct p {
	int a;
	int b;
	int c;
	int d;
};

void make(int n, int m, int q, int t, int pre, p* x, int* nums, int &ans) {
	REP(i, pre, m+1) {
		nums[t] = i;

		if (t == n - 1) {
			int sum = 0;
			rep(j, q) {
				if (nums[x[j].b - 1] - nums[x[j].a - 1] == x[j].c) sum += x[j].d;
			}
			ans = max(ans, sum);
		}
		else {
			make(n, m, q, t + 1, i, x, nums, ans);
		}
	}
}

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

	int n, m, q;
	cin >> n >> m >> q;
	p* x = new p[q];
	rep(i, q) {
		cin >> x[i].a >> x[i].b >> x[i].c >> x[i].d;
	}

	int* nums = new int[n];
	
	int ans = 0;
	make(n, m, q, 0, 1, x, nums, ans);
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3616
import math
n=int(input())
a=list(map(int,input().split()))
cnt=0
ans=0
for i in range(n-1):
    if a[i]==a[i+1]:
        cnt+=1
    else:
        cnt+=1
        if 1<cnt:
            ans+=math.floor(cnt/2)
            cnt=0
        else:
            cnt=0
if a[-2]==a[-1]:
    cnt+=1
    ans+=math.floor(cnt/2)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,x,y,z;
cin>>a>>b;  
x=a+b;  
y=a-b;
z=a*b;
if(x>=y&&x>=z){cout<<x;}
else if(y>=x&&y>=z){cout<<y;}  
else{cout<<z;}  
return 0;
}

Measured memory_bytes: 3580
N = int(input())
A = list(map(int, input().split()))
M = 1000
S = 0
for i in range(N-1):
    if A[i] < A[i+1]:
        S = M // A[i]
        M = M % A[i] + S*A[i+1]
        S = 0
    else:
        pass
print(M)

Measured memory_bytes: 9080
// Aizu Vol0 0003: Is it a Right Triangle?
// 2017.7.28

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a, b, c, k;
	int i, n;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &c, &k);

		if (k > c) a = c, c = k;
		else a = k;

		scanf("%d", &k);

		if (k > c) b = a, a = c, c = k;
		else if (k < c) b = a, a = k;
		else goto NO;

		if (a*a + b*b == c*c) puts("YES");
		else {
		NO:	puts("NO");
		}
	}
	return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    repA(i,1,n) cin>>a[i];
    for(ll i=k+1;i<=n;i++)
    {
      ll num=a[i];
      ll den=a[i-k];
      ll u=ceil(1.0*num/den);
      if(u>1ll) cout<<"Yes\n";
      else cout<<"No\n";
    }
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 4792
def D():
    n,x,y = list(map(int, input().split()))
    d_num = [0]*(n-1)
    for i in range(1,n):
        for j in range(i+1,n+1):
            d = []
            d.append(j-i)
            if x < j and i < y:
                d.append(abs(x-i)+1+abs(y-j))
            d_num[min(d)-1] += 1
    print("\n".join(map(str,d_num)))
D()

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

int main(){
	int n, a[20], b[20], c[20];
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)	cin >> a[i];
	for (int i = 0; i < n; i++)	cin >> b[i];
	for (int i = 1; i < n; i++) cin >> c[i];
	for (int i = 0; i < n; i++){
		ans += b[i];
		if (a[i] == a[i + 1] - 1){
			ans += c[a[i]];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> h(n+1,0);
    rep(i,n) cin>>h.at(i+1);
    bool flag=1;
    rep(i,n){
        if(h[i]==h[i+1]) continue;
        if(h[i]<h[i+1]) h[i+1] --;
        else{flag=0;break;}
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}

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

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

  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  cout << a[n - 1] - a[0] << endl;

  return 0;
}


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

struct Node {
	int x, y, id;
	long long sum;
	bool operator < (const Node &A) const {
		return 1ll * y * A.x < 1ll * A.y * x || 1ll * y * A.x == 1ll * A.y * x && id < A.id;
	}
	Node operator += (const Node &A) {
		sum += 1ll * y * A.x + A.sum, x += A.x, y += A.y;
		return *this;
	}
};

set <Node> S;
int fa[200010];
Node a[200010];
int par[200010];

int find(int x) {
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int main () {
	int n; scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		scanf("%d", &par[i]);
	}
	for (int i = 1; i <= n; i++) {
		fa[i] = i;
		int x; scanf("%d", &x);
		if (x) a[i].x = 0, a[i].y = 1, a[i].id = i, a[i].sum = 0;
		else a[i].x = 1, a[i].y = 0, a[i].id = i, a[i].sum = 0;
		if (i != 1) S.insert(a[i]);
	}
	while (S.size()) {
		int x = S.begin()->id; S.erase(S.begin());
		int p = find(par[x]);
		if (p != 1) S.erase(a[p]);
		a[p] += a[x], fa[x] = p;
		if (p != 1) S.insert(a[p]);
	}
	printf("%lld\n", a[1].sum);
	return 0;
}


Measured memory_bytes: 22564
#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, k, x[maxn];

int main(void) {
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; ++i) scanf("%d", x + i);
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        int t = min(x[i], abs(k - x[i]));
        ans += t << 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, m = ril()
ls = rsls(m)

ac = set()
wa = collections.defaultdict(int)
done = set()
for p, s in ls:
    if p not in ac:
        if s == 'AC':
            ac.add(p)
        else:
            wa[p] += 1
print(len(ac), sum(wa[p] for p in ac))

Measured memory_bytes: 48904
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

const int ih[5] = { 0,1,0,-1,0 };
const int iw[5] = { 0,0,1,0,-1 };
int h, w, cnt = 0;
void dfs(int nh, int nw, vector<string> grid, vector<vector<bool>>& painted) {
	rep(i, 5) {
		int dh = ih[i], dw = iw[i];
		if (nh + dh < 0 || nh + dh >= h || nw + dw < 0 || nw + dw >= w)continue;
		if (grid[nh + dh][nw + dw] == '.')continue;
		if (painted[nh + dh][nw + dw])continue;
		painted[nh + dh][nw + dw] = true;;
		cnt++;
		dfs(nh + dh, nw + dw, grid, painted);
	}
}

int main() {
	string ans = "Yes";
	cin >> h >> w;
	vector<string>grid(h);
	vector<vector<bool>>painted(h, vector<bool>(w, false));
	rep(i, h)cin >> grid[i];
	rep(i, h) {
		rep(j, w) {
			if (painted[i][j])continue;
			if (grid[i][j] == '.')continue;
			cnt = 0;
			dfs(i, j, grid, painted);
			if (cnt == 1) {
				ans = "No";
				break;
			}
		}
		if (cnt == 1)break;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}


long long dp[100010][2];
bool ok[100010][2];
vector<ll> A;

long long dfs(int p, int c) {
    if (p == A.size()) return c == 1 ? -1e18 : 0;

    if (ok[p][c]) {
        return dp[p][c];
    }

    long long v = c ? -A[p] : A[p];

    long long ans = dfs(p + 1, 0) + v;
    ans = max(ans, dfs(p + 1, 1) - v);


    ok[p][c] = true;
    return dp[p][c] = ans;
}


void solve(long long N, std::vector<long long> A) {
    ::A = A;
    cout << dfs(0, 0) << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 8192
def mium():
  a, b = map(int, input().split())
  if a > 0:
    print("Positive")
  elif a == 0:
    print("Zero")
  elif b >= 0:
    print("Zero")
  else:
    if ( b - a ) % 2 == 1:
      print("Positive")
    else:
      print("Negative")
if __name__ == "__main__":
  mium()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  string s; cin>>s;
  if(s[0]==s[1] && s[2]==s[3] &&s[1]==s[2]) cout<<"No";
  else if(s[0]==s[1] && s[2]==s[3]) cout<<"Yes";
  else if(s[0]==s[2] && s[1]==s[3]) cout<<"Yes";
  else if(s[0]==s[3] && s[1]==s[2]) cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

pii p[N];

int main() {
	int n,m;cin>>n>>m;
	rep(i,m){cin>>p[i].second>>p[i].first;}
	sort(p,p+m);
	int ans=1,b=p[0].first;
	for(int i=1;i<m;i++){
		if(b!=p[i].first&&b<=p[i].second){
			b=p[i].first;
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((v[i - 1] < v[i] && v[i] < v[i + 1]) || (v[i - 1] > v[i] && v[i] > v[i + 1])) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;cin >> n;
    vector<queue<int> > a(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            int tmp;cin  >> tmp;
            tmp --;
            a[i].push(tmp);
        }
    }
    queue<pair<int,int> > q;
    for(int i=0;i<n;i++){
        if(a[a[i].front()].front() == i){
            q.push(make_pair(i,a[i].front()));
        }
    }
    int count = 0;
    int day = 0;
    while(count < (n*(n-1))/2){
        if(q.empty()){
            cout << "-1" << endl;
            return 0;
        }
        int daygame = q.size();
        int daycount = 0;
        while(daycount < daygame){
            pair<int ,int> game;
            game = q.front();
            q.pop();
            if(a[game.first].front() != game.second || a[game.second].front() != game.first){
                daycount++;
                continue;
            }
            else{
                a[game.first].pop();
                a[game.second].pop();
                daycount ++;
                count ++;
                if(!a[game.first].empty()){
                    if(game.first == a[a[game.first].front()].front()){
                        q.push(make_pair(game.first,a[game.first].front()));
                    }
                }
                if(!a[game.second].empty()){
                    if(game.second == a[a[game.second].front()].front()){
                        q.push(make_pair(game.second,a[game.second].front()));
                    }
                }

            }
        }
        day ++;
    }
    cout << day << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {
  ll n, k; cin >> n >> k;
  vector<ll> h(n);
  rep(i, 0, n) cin >> h[i];
  sort(ALL(h));
  ll ans = INF;
  Rep(i, 0, n-k){
    ans = min(ans, abs(h[i] - h[i+k-1]));
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int L, R, d; cin >> L >> R >> d;
  int c = 0;
  rep(i,R-L+1) {
    if ((i+L)%d==0) c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// cout << fixed << setprecision(10);
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int main(){
    int x,y,z,k; cin >> x >> y >> z >> k;
    long long a[1001],b[1001],c[1001];
    vector<long long> ab(0),abc(0);
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];

    sort(a,a+x); reverse(a,a+x);
    sort(b,b+y); reverse(b,b+y);
    sort(c,c+z); reverse(c,c+z);

    for (int i = 0; i < x; i++){
        for (int j = 0; j < y; j++){
            ab.push_back(a[i] + b[j]);
        }
    }

    sort(ab.begin(),ab.end()); 
    reverse(ab.begin(),ab.end());

    for (int i = 0; i < min(k,x*y); i++){
        for (int j = 0; j < z; j++){
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(abc.begin(),abc.end());
    reverse(abc.begin(),abc.end());
    for (int i = 0; i < k; i++){
        cout << abc[i] << endl;
    }

} 


Measured memory_bytes: 43364
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] array = new int[N];
			for(int i = 0; i < N; i++) {
				array[i] = sc.nextInt();
			}
			
			boolean ok = true;
			
			int left_min = array[N - 1];
			for(int i = N - 2; i >= 0; i--) {
				if(left_min < array[i] - 1) {
					ok = false; break;
				} else if(left_min == array[i] - 1){
					array[i] -= 1;
				} 
				
				left_min = Math.min(array[i], left_min);
			}
			
			System.out.println(ok ? "Yes" : "No");
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

int main(void){
	int a,b,c,d,e,f;

	while(cin>>a>>b>>c>>d>>e>>f, (a || b || c || d || e || f)){
		int sum = 100;

		sum += -3 * a + 15 * a + a * 5 * 13;
		f -= a + 5 * a;

		sum += -3 * b + 15 * b + b * 3 * 13;
		f -= b + 3 * b;

		sum += -3 * c + 7 * c;
		f -= c;

		sum -= d;
		f -= d;

		sum -= e * 3;
		f -= e * 2;

		sum -= 3 * f;

		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                count+=1
print(count)



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int ans = 0;
        while (n > 0) {
            ans++;
            n /= k;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;


	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			ll n;
			cin>>n;
			ll sum=100;

			ll year=1;
			ll ans=0;
			while(sum<n)
			{
				ll x=(sum)/100;
				sum+=x;
				ans+=1;
			}
			cout<<ans;

			
			 
			return 0;
		 }	


Measured memory_bytes: 3652
#include<stdio.h>

main(void)
{
	int H , W , a ,b;
	
	while(1){
		scanf("%d %d",&H,&W);
		
		if(H==0 && W==0){
			break;
		}
		
		for(a=0;a<H;a++){
			for(b=0;b<W;b++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
		
	}
	return 0;
}

Measured memory_bytes: 572
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

typedef long long int ll;

struct union_find{
	int n;
	vector<int> par,rnk;
	union_find(int _n){
		n = _n;
		for(int i=0;i<n;i++) par.push_back(i);
		for(int i=0;i<n;i++) rnk.push_back(0);
	}
	int find(int x){
		if(par[x]==x) return x;
		else return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(rnk[x]<rnk[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rnk[x]==rnk[y]) rnk[x]++;
		}
	}
};
typedef pair<ll,pair<int,int> > edge;

int main(){
	int n;
	pair<ll,int> x[100000];
	pair<ll,int> y[100000];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&x[i].first,&y[i].first);
		x[i].second = y[i].second = i;
	}
	sort(x,x+n);
	sort(y,y+n);
	vector<edge> E;
	for(int i=0;i<n-1;i++){
		edge e;
		e.second.first = x[i].second;
		e.second.second = x[i+1].second;
		e.first = x[i+1].first - x[i].first;
		E.push_back(e);
	}
	for(int i=0;i<n-1;i++){
		edge e;
		e.second.first = y[i].second;
		e.second.second = y[i+1].second;
		e.first = y[i+1].first - y[i].first;
		E.push_back(e);
	}
	sort(E.begin(),E.end());
	ll ans = 0;
	union_find uf(n);
	for(int i=0;i<E.size();i++){
		if(!uf.same(E[i].second.first,E[i].second.second)){
			ans += E[i].first;
			uf.unite(E[i].second.first,E[i].second.second);
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 9328
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if(B>=A*C)
			System.out.println(C);
		else
			System.out.println(B/A);
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
	std::cin >> a[i] >> b[i];
    }
    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());

    double am, bm;
    long long ans;
    if(n % 2 == 1){
	am = a[(n+1)/2 - 1];
	bm = b[(n+1)/2 - 1];
	ans = bm - am + 1;
    }else{
	am = (a[n/2 - 1] + a[n/2]);
	bm = (b[n/2 - 1] + b[n/2]);
	ans = (bm - am)+ 1;
    }
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 4820
#include <stdio.h>

#define MAX 100

int main(void)
{
	int i, j, n, u, k, v, a[MAX+1][MAX+1]={0};
	
	scanf("%d",&n);
	
	for (i=0; i<n; i++) {
		scanf("%d %d", &u, &k);
		for (j=0; j<k; j++) {
			scanf("%d",&v);
			a[u][v] = 1;
		}
	}
	
	for (i=1; i<=n; i++) {
		for (j=1; j<=n-1; j++) {
			printf("%d ", a[i][j]);
			
		}
		printf("%d\n", a[i][n]);
	}
	
	return 0;
}

Measured memory_bytes: 648
# include <bits/stdc++.h>
using namespace std;
int n, m, a[308][308], vis[308], go[308];
bool check(int x)
{
    memset(go, 0, sizeof(go));
    for(int i=1; i<=n; ++i) a[i][0] = 1;
    while(1)
    {
        memset(vis, 0, sizeof(vis));
        bool flag = true;
        for(int i=1; i<=n; ++i)
        {
            while(a[i][0] <= m && go[a[i][a[i][0]]]) ++a[i][0];
            if(++vis[a[i][a[i][0]]] > x) {go[a[i][a[i][0]]]=1; flag =false;}
            if(a[i][0] > m) return false;
        }
        if(flag) return true;
    }
    return false;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; ++i)
    {
        a[i][0] = 1;
        for(int j=1; j<=m; ++j)
        scanf("%d",&a[i][j]);
    }
    int l=1, r=n;
    while(l<r)
    {
        int m = l+r>>1;
        if(check(m)) r = m;
        else l=m+1;
    }
    printf("%d\n",r);
    return 0;
}


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


void dfs(vector<long>* edge,bool visited[],int n,long start){
	visited[start] = true;

	for(int i=0;i<edge[start].size();i++){
		long next = edge[start][i];
		if(!visited[next]){
			dfs(edge,visited,n,next);
		}
	}
}

int find(vector<long>* edge, int n){
	bool visited[n];
	memset(visited,0,sizeof(visited));
	long count = 0;
	for(int i=0;i<n;i++){
		if(!visited[i]){
			count++;
			dfs(edge,visited,n,i);
		}
	}
	return count;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<long>* edge = new vector<long>[n];
	for(int i=0;i<m;i++){
		long a,b;
		cin >> a>> b;
		edge[a-1].push_back(b-1);
		edge[b-1].push_back(a-1);
	}

	long res = find(edge,n);

	cout << res-1;


}

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

string s;
long long allsum = 0;
void dfs(int i, long long be, long long sum);

int main(){
    cin >> s;
    dfs(0, 0, 0);
    cout << allsum << endl;

    return 0;
}

void dfs(int i, long long be, long long sum){
    if(i == s.size()-1){
        allsum += (sum + be * 10 + (s[i] - '0'));
        return;
    }
    //加える
    dfs(i+1,0,sum+be*10 + (s[i] - '0'));
    //待つ
    dfs(i+1,be*10+(s[i] - '0'), sum);

    
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

ll dp[2005][2005];

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long Y;
  scanf("%lld", &Y);

  Fill(dp, -1LL);
  dp[0][0] = 0;

  rep(i, 0, N + 1) rep(j, 0, N + 1) {
    ll m = Y - (10000 * i + 5000 * j);
    if (m < 0) continue;
    ll a = m / 1000;
    if (i + j + a == N) {
      cout << i << " " << j << " " << a << endl;
      return 0;
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[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 <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 31744
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<bool> > x(2,vector<bool>(n,false));
  int a, b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    if(a==1)x[0][b-1]=true;
    if(b==n)x[1][a-1]=true;
  }
  for(int i=0;i<n;i++){
    if(x[0][i]*x[1][i]){
      puts("POSSIBLE");
      return 0;
    }
  }
  puts("IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 384
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 2000005;

char s[mxn], t[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    cin >> s >> t;
    int n = sl(s);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += s[i] != t[i];
    }
    cout << ans << '\n';
}

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

#define ios ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define FOR(i, a, b) for(int i=(int)a; i<(int)b; i++)
#define len(a) a.length()
#define ndl "\n";
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define inrep int t; cin >> t; for(int tc=1; tc<=t; tc++)
#define debug cout << "DEBUG" << ndl;
#define in(a) cin >> a
#define out(a) cout << a << ndl
const int N = 1e5+7;
const int LOGN = log(N) + 2;
const int MOD = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	ios;
	int a, b, c, d; cin >> a >> b >> c >> d;
	int ans = 0;
	for(int i=a; i<=b; i++) {
		if (i >= c && i <=d) {
			ans++;
		}
	}
	if (ans == 0) {cout << 0 << ndl;}
	else cout << ans-1 << ndl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	string S,T;
	cin>>S;
	rep(i,0,S.size()){
		T.pb('x');
	}
	cout<<T<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
class Program
    {
        static int n;
        static int m;
        static int[] c;
        static int[] t;
        static void Main(string[] args){
            String[] str_1 = Console.ReadLine().Split(' ');
            String[] str_2 = Console.ReadLine().Split(' ');
            n = int.Parse(str_1[0]);
            m = int.Parse(str_1[1]);
            c = new int[m];
            t = new int[n+1];
            for (int i=0; i < m; i++){
                c[i] = int.Parse(str_2[i]);
            }
            Console.WriteLine(coin());
        }
        static int coin()
        {
            for (int j = 0; j < n+1; j++)
            {
                t[j] = 10000000;
            }
            t[0] = 0;
            for (int i = 0; i < m; i++) {
                for (int j = c[i]; j < n + 1; j++) {
                    t[j] = Math.Min(t[j],t[j-c[i]]+1);
                }
            }
            return t[n];
        }
    }

Measured memory_bytes: 9360
n = int(input())
A = list(map(int,input().split()))
A.sort()
from collections import deque
q = deque(A)
s = (A[0] + A[1])/2
q.popleft()
q.popleft()
while q:
    t = q.popleft()
    s +=t
    s/=2
print(s)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	string s;
	cin >> s;
	vector<ll>arr(s.size() + 1);
	rep(i, s.size()) {
		if (s[i] == '<')arr[i+1] = arr[i] + 1LL;
	}

	for (ll i = s.size()-1; i >=0;i--) {
		if (s[i] == '>')arr[i] = max(arr[i + 1] + 1LL,arr[i]);
	}
	ll sum = accumulate(all(arr),0LL);
	cout << sum << endl;
}


Measured memory_bytes: 7716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    if (N%2!=0){
        cout << "No" << endl;
        return 0;
    }
    N/=2;
    rep(i,N){
        if (S[i]!=S[i+N]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll lcm(ll a, ll b){
  if(a > b){
    return (a / __gcd(a, b)) * b;
  }else{
    return (b / __gcd(a, b)) * a;
  }
}

int
main(void){  
  int n;
  cin >> n;
  ll a[n];
  ll max_a = 0LL;
  REP(i, n) {
    cin >> a[i];
    //if(max_a < a[i]) max_a = a[i];
  }

  /*
  ll ans = a[0];
  FOR(i, 1, n){
    ans = lcm(a[i], ans);
  }
  
  ll hoge = 0LL;
  REP(i, n) hoge += (ans-1) % a[i];
  cout << hoge << endl;
  */

  ll ans = 0LL;
  REP(i, n) ans += a[i]-1;
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long int;

int main() {
	ll n, m;
	cin >> n >> m;
	map<ll, ll> mp;

	bool ok = false;
	vector<ll> B;
	for (ll i = 0; i < m; i++)
	{
		ll ai, bi;
		cin >> ai >> bi;
		if (ai == 1) {
			mp[bi]++;
		}
		if (bi == n) {
			B.push_back(ai);
		}
	}

	for (auto&& e : B)
	{
		if (mp[e] > 0) {
			ok = true;
		}
	}

	if (ok) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE " << endl;
	}
}

Measured memory_bytes: 13556
import math

#x = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
n,x = list(map(int,input().split(" ")))
#a,b,c = list(input().split())
#string = input()
ls = [int(input()) for i in range(n)]

remain = x - sum(ls)
num = remain // min(ls)
ans = num + n

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int h, w;
char grid[25][25];
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

int main(){
	cin>>h>>w;
	for(int i = 0; i<h; i++){
		for(int j = 0; j<w; j++){
			cin>>grid[i][j];
		}
	}
	int ans = 0;
	auto is_good = [&](int row, int col){
		return row >= 0 && col >= 0 && row < h && col < w && grid[row][col] == '.';
	};
	for(int s_row = 0; s_row < h; s_row++){
		for(int s_col = 0; s_col < w; s_col++){
			if(is_good(s_row, s_col)){
				vector<pair<int, int>> q;
				q.emplace_back(s_row, s_col);
				vector<vector<bool>> vis(h, vector<bool>(w));
				vector<vector<int>> dist(h, vector<int>(w));
				vis[s_row][s_col] = true;
				for(int i = 0; i < (int)q.size(); i++){
					pair<int, int> me = q[i];
					for(int dir = 0; dir < 4; dir++){
						int row2 = me.first + dx[dir];
						int col2 = me.second + dy[dir];
						if(is_good(row2, col2) && !vis[row2][col2]){
							dist[row2][col2] = dist[me.first][me.second] + 1;
							vis[row2][col2] = true;
							ans = max(ans, dist[row2][col2]);
							q.emplace_back(row2, col2);							
						}
					}
				}
			}
		}
	}
	cout<<ans<<endl;	
}


Measured memory_bytes: 256