akhauriyash/Code-Regression huggingface dataset:
N = int(input())
H = list(map(int, input().split()))
c = 0
for i in range(N-1):
  if H[i] > H[i+1]:
    H[i+1] = H[i+1] + 1
  if H[i] <= H[i+1]:
    c += 1
if c == N-1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 14228
# import sys
# input = sys.stdin.readline
import collections

def main():
    n = int(input())
    h = input_list()
    count = 0
    while True:
        if list(set(h)) == [0]:
            break
        count += 1
        f = False
        for i, v in enumerate(h):
            if v == 0:
                if f:
                    break
            if v > 0:
                h[i] -= 1
                f = True
    print(count)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 67980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,K;
ll T[100000];
vector<ll> t;

int main(){
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>T[i];
    if(i){
      t.push_back(T[i]-T[i-1]-1);
    }
  }
  sort(t.begin(),t.end());

  ll ans=N;
  
  for(int i=0;i<N-K;i++){
    ans+=t[i];
  }

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



Measured memory_bytes: 4672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,x;
	cin>>n>>x;
	int ans=1;
	int now=0;
	rep(i,n){
		int l;
		cin>>l;
		now+=l;
		if(now<=x) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
bool judge(int x,int y)
{
	if(x==0||y==0) return true;
	if(x==n||y==m) return true;
	return false;
}
struct node
{
	int x,y,id;
	node(){}
	node(int a,int b,int e)
	{
		x=a;
		y=b;
		id=e;
	}
};
node edge[200100];
int cnt = 0;
bool cmp(node a,node b)
{
	if(a.x==b.x)
	{
		if(a.x==0)
		return a.y<b.y;
		else return a.y>b.y;
	}
	else if(a.y==b.y)
	{
		if(a.y==0)
		{
			if(a.x!=0&&b.x!=0)
			return a.x>b.x;
			else if(a.x==0) return true;
			else if(b.x==0) return false;
		}
		else return a.x<b.x;
	}
	else if(a.x==0) return true;
	else if(a.x==n)
	{
		if(b.x==0||b.y==m) return false;
		return true;
	}
	else if(a.y==0) return false;
	else if(a.y==m)
	{
		if(b.x==0) return false;
		return true;
	}
}
stack<int>st;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=k;i++)
	{
		int x1,x2,y1,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(judge(x1,y1)&&judge(x2,y2)) edge[++cnt] = node(x1,y1,i),edge[++cnt] = node(x2,y2,i);
	}
	sort(edge+1,edge+1+cnt,cmp);
	for(int i=1;i<=cnt;i++)
	if(st.size()==0) st.push(edge[i].id);
	else if(st.top()!=edge[i].id) st.push(edge[i].id);
	else st.pop();
	if(st.size()) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 2944
a,b,c,d=map(int,input().split())
if abs(b-a)+abs(c-b)<=d  :
    print('Yes')
elif abs(b-a)<=d and abs(c-b)<=d:
    print('Yes')
elif abs(c-a)<=d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
k = list(map(int, input().split()))[0]
a, b = list(map(int, input().split()))
for i in range(1, 10000):
    n = k * i
    #     print(n)
    if n >= a and n <= b:
        print("OK")
        break
    elif n > b:
        print("NG")
        break

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

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

    long long int r = 0, g = 0, b = 0;

    for (int i = 0; i < n; i++)
    {
        if (str[i] == 'R')
            r++;
        else if (str[i] == 'G')
            g++;
        else
            b++;
    }

    long long int ans = r * g * b;

    long long int wcnt = 0;

    for (int i = 0; i < n - 2; i++)
    {
        for (int j = i + 1; j < n - 1 && 2 * j - i < n; j++)
        {
            int k = 2 * j - i;
            if (str[i] != str[j] && str[j] != str[k] && str[k] != str[i])
                wcnt++;
        }
    }

    cout << ans - wcnt << endl;
}

Measured memory_bytes: 3564
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(N-1)]
mod=10**9+7


E=[[] for i in range(N+1)]
for x,y in EDGE:
    E[x].append(y)
    E[y].append(x)

from collections import deque
QUE=deque([1])
ANS=[-1]*(N+1)
ANS[1]=K
count=K

while QUE:
    NQUE=deque()
    while QUE:
        x=QUE.pop()
        if x!=1:
            count=K-1

        for to in E[x]:
            if ANS[to]!=-1:
                continue

            count-=1
            ANS[to]=count
            NQUE.append(to)

    QUE=NQUE

A=1
for a in ANS[1:]:
    A=a*A%mod

print(A)
            
            
        


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;


template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int digit(int n) {
  int ans = 0;
  while(n > 0) {
    n /= 10;
    ans++;
  }
  return ans;
}

int solve(int n, ll k, bool b3, bool b5, bool b7) {
  if(n < k) {
    return 0;
  } else {
    int ans = (b3 && b5 && b7) ? 1 : 0;
    ans += solve(n, 10*k+3, true, b5, b7);
    ans += solve(n, 10*k+5, b3, true, b7);
    ans += solve(n, 10*k+7, b3, b5, true);
    return ans;
  }
}



int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  int ans = solve(n, 0, false, false, false);
  cout << ans << endl;
}


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

INF = 10 ** 9


def base(x, y):
    ret = 0
    while x >= y:
        ret += x % y
        x //= y
    ret += x
    return ret
        

def main():
    ans = INF
    for i in range(N + 1):
        v = base(i, 6) + base(N - i, 9)
        ans = min(ans, v)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9132
n = gets.to_i
a = []
n.times{ a << gets.to_i }
dp =  Array.new
dp << -1
n.times do |i|
  if dp.last < a[i]
    dp << a[i]
  else
    left = 0
    right = dp.size - 1
    mid = 0
    while left <= right
      mid = (left + right)/2
      if a[i] >= dp[mid]
        left = mid + 1
      else
        right = mid - 1
      end
    end
    if dp[right] < a[i] && dp[left] > a[i]
      dp[right+1] = a[i]
    end
  end
end
p dp.size - 1

Measured memory_bytes: 10452
n,m = gets.chomp.split.map(&:to_i)
as = m.times.map{gets.to_i}
MOD = 10**9+7

dp = Array.new(n+1,-1)
as.each do |a|
	dp[a] = 0
end
(n+1).times do |i|
	next if dp[i] == 0
	if i == 0 || i == 1
		dp[i] = 1
	else
		dp[i] = (dp[i-1] + dp[i-2]) % MOD
	end
end

puts dp[n]

Measured memory_bytes: 4860
import sys

lines = sys.stdin.readlines()
parts = lines[0].split(' ')
n = int(parts[0])
k = int(parts[1])
arr = [int(s) for s in lines[1].strip().split()]

ans = 0
mod = 1000000007

for i in range(n):
    in_arr = 0
    all_arr = 0
    for j in range(n):
        if arr[i] > arr[j]:
            all_arr += 1
            if j > i:
                in_arr += 1

    ans += in_arr * k + all_arr * (k - 1) * (k) // 2
    ans %= mod

print(ans)


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

int main() {
    double D, T, S;
    cin >> D >> T >> S;
    double x = D / S;
    if (x <= T) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3680
#include<stdio.h>

int main(){
   int m,d,i,j,count=0;
   scanf("%d %d", &m, &d);
   for(i=2;i<=m;i++){
      for(j=10;j<=d;j++){
         if(i == (j/10)*(j%10) && (j/10)>=2 && (j%10)>=2){
            //printf("%d %d\n", i,j);
            count++;
         }
      }
   }
   printf("%d", count);
   return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var N = line[0];
        var K = line[1];
        var list = new List<long[]>();
        for (var i=0;i<N;++i)
        {
            var ab = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            list.Add(new long[] { ab[0],ab[1]});
        }
        var orderList=list.OrderBy(x => x[0]);
        var ans = 0L;
        foreach (var l in orderList)
        {
            K -= l[1];
            if (K <= 0)
            {
                ans = l[0];
                break;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 26032
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < k; i++) {
			int d = sc.nextInt();
			for (int j = 0; j < d; j++) {
				set.add(sc.nextInt());
			}
		}
		sc.close();

		System.out.println(n - set.size());
	}
}


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

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  vector<vector<int>> c(h,vector<int>(w));
  int t=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[t]==0)t++;
      if(i%2) c[i][w-1-j]=t+1;
      else c[i][j]=t+1;
      a[t]--;
    }
    for(int j=0;j<w;j++){
      cout << c[i][j] << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
S = input()

Lindex = S.index("L")
Rindex = 0

num = [0]*len(S)

for i in range(len(S)):
  if S[i] == "R":
    Rindex = i
    if Lindex < i: Lindex = i+ S[i:].index("L")
    if (Lindex-i)%2==1:
      num[Lindex-1] += 1
    else:
      num[Lindex] += 1
  else:
    if (Rindex-i)%2==1:
      num[Rindex+1] += 1
    else:
      num[Rindex] += 1
print(*num)

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  sort(a,a+n);
  ll ans=0;
  rep(i,n) {
    REP(j,i+1,n) {
      REP(k,j+1,n) {
        if(a[i]==a[j]||a[j]==a[k]) continue;
        if(a[i]+a[j]>a[k]) ans++;
      }
    }
  }
  pr(ans);

}

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


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
typedef pair<int, int> P;

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int n = x + y + z;
    vector<int64> a(n), b(n), c(n);
    vector<P> d;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
        d.push_back({a[i] - b[i], i});
    }
    sort(d.rbegin(), d.rend());
    vector<int64> suma(n), sumb(n);
    priority_queue<int64> qa, qb;
    int64 now = 0;
    for(int i = 0; i < x; i++){
        qa.push(c[d[i].second] - a[d[i].second]);
        now += a[d[i].second];
    }
    suma[x - 1] = now;
    for(int i = x; i < x + z; i++){
        qa.push(c[d[i].second] - a[d[i].second]);
        int64 tmp = qa.top(); qa.pop();
        now += tmp + a[d[i].second];
        suma[i] = now;
    }
    now = 0;
    for(int i = n - 1; i > n - 1 - y; i--){
        qb.push(c[d[i].second] - b[d[i].second]);
        now += b[d[i].second];
    }
    sumb[n - y] = now;
    for(int i = n - 1 - y; i >= x; i--){
        qb.push(c[d[i].second] - b[d[i].second]); 
        int64 tmp = qb.top(); qb.pop();
        now += tmp + b[d[i].second];
        sumb[i] = now;
    }
    int64 ans = 0;
    for(int i = x - 1; i < x + z; i++){
        ans = max(ans, suma[i] + sumb[i + 1]);
        // cout << i << ' ' << suma[i] << ' ' << sumb[i + 1] << endl;
    }
    cout << ans << endl;
}

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

public class Main {
	
	static int[] x = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		while (true) {
			char[] steps = sc.next().toCharArray();
			if (steps[0] == '#') break;
			
			if (steps.length <= 2) {
				out.println(0);
			} else {
				int step = 0, left = -1, right = 1, foot = 0;
				for (int i = 0; i < steps.length; i++) {
					int next = x[steps[i] - '1'];
					if (foot % 2 == 0) {
						if (next > right) {
							step++;
							right = next;
						} else {
							left = next;
							foot++;
						}
					} else {
						if (next < left) {
							step++;
							left = next;
						} else {
							right = next;
							foot++;
						}
					}
				}
				
				int min = step;
				
				step = 0;
				left = -1;
				right = 1;
				foot = 1;
				for (int i = 0; i < steps.length; i++) {
					int next = x[steps[i] - '1'];
					if (foot % 2 == 0) {
						if (next > right) {
							step++;
							right = next;
						} else {
							left = next;
							foot++;
						}
					} else {
						if (next < left) {
							step++;
							left = next;
						} else {
							right = next;
							foot++;
						}
					}
				}
				
				min = Math.min(min, step);
				
				out.println(min);
			}
		}
		
		out.flush();
	}
}

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 byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
}

Measured memory_bytes: 32408
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        double B = sc.nextDouble();
        System.out.println((A * (long)(B*100 + 0.5))/100);
//        System.out.println(A * B);
    }
}

Measured memory_bytes: 36584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	/*
	for(int i = k + 1; i <= n; ++i)
	{
		for(int j = k; j < i; ++j)
		{
			ans += (n - j) / i + (j > 0);
		}
	}
	*/
	for(int i = k + 1; i <= n; ++i)
	{
		for(int j = 0; j + k <= n; j += i)
		{
			int l = max(1, j + k);
			int r = min(n, j + i - 1);
			ans += r - l + 1;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long int A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K<=A) {
        cout << K << endl;
    } else if(K<=A+B) {
        cout << A << endl;
    } else {
        cout << A-(K-A-B) << endl;
    }


    return 0;
    
}

Measured memory_bytes: 3636
INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2

def dijkstra(n, m):
    d = [INFTY] * n
    color = [WHITE] * n

    d[0] = 0
    color[0] == GRAY

    while True:
        minv = INFTY
        u = -1
        for i in range(n):
            if minv > d[i] and color[i] != BLACK:
                u = i
                minv = d[i]
        if u == -1:
            break
        color[u] = BLACK
        for v in range(n):
            if color[v] != BLACK and m[u][v] != INFTY:
                if d[v] > d[u] + m[u][v]:
                    d[v] = d[u] + m[u][v]
                    color[v] = GRAY

    for i in range(n):
        out = d[i]
        if out == INFTY:
            out = -1
        print('{0} {1}'.format(i, out))


n = int(input())
m = [[INFTY] * n for i in range(n)]
for i in range(n):
    line = [int(v) for v in input().split()]
    u = line[0]
    k = line[1]
    for j in range(k):
        v = line[2*j + 2]
        c = line[2*j + 3]
        m[u][v] = c

dijkstra(n, m)


Measured memory_bytes: 5712
char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*z-50,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;}

Measured memory_bytes: 0
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

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

	public static void solve() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Map<Integer, List<Integer>> graph = new HashMap<>();

		for (int i = 0; i < m; i++) {
			Integer from = sc.nextInt();
			Integer to = sc.nextInt();
			if (graph.containsKey(from)) {
				List<Integer> before = graph.get(from);
				before.add(to);
			} else {
				List<Integer> bridges = new ArrayList<>();
				bridges.add(to);
				graph.put(from, bridges);
			}
			if (graph.containsKey(to)) {
				List<Integer> before = graph.get(to);
				before.add(from);
			} else {
				List<Integer> bridges = new ArrayList<>();
				bridges.add(from);
				graph.put(to, bridges);
			}
		}
		sc.close();

		int count = 0;
		for (int i = 0; i < m; i++) {
			for (Integer key : graph.keySet()) {
				if (graph.get(key).size() == 1) {
					Integer deleteKey = graph.get(key).get(0);
					graph.get(key).remove(0);
					graph.get(deleteKey).remove(key);
					count++;
				}
			}
		}
        out.println(count);
        out.flush();
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  const int MAX = 1e5;
  for(int n,m;cin>>n>>m,n;){
    int cost[m][m];
    int time[m][m];
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
	cost[i][j] = MAX;
	time[i][j] = MAX;
      }
    }
    int a,b,c,t;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c>>t;
      cost[max(a-1,b-1)][min(a-1,b-1)] = c;
      time[max(a-1,b-1)][min(a-1,b-1)] = t;
    }
    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
	for(int j=0;j<=i;j++){
	  if(cost[i][j]>cost[max(i,k)][min(i,k)]+cost[max(k,j)][min(j,k)])
	    cost[i][j] = cost[max(i,k)][min(i,k)]+cost[max(k,j)][min(j,k)];
	  if(time[i][j]>time[max(i,k)][min(i,k)]+time[max(k,j)][min(j,k)])
	    time[i][j] = time[max(i,k)][min(i,k)]+time[max(k,j)][min(j,k)];
	}
      }
    }
    int l,r;
    cin>>l;
    for(int i=0;i<l;i++){
      cin>>a>>b>>r;
      if(r)
	cout<<time[max(a-1,b-1)][min(a-1,b-1)]<<endl;
      else
	cout<<cost[max(a-1,b-1)][min(a-1,b-1)]<<endl;      
    }
  }
  return 0;
}

Measured memory_bytes: 944
n,x= list(map(int, input().strip().split()))
a= list(map(int, input().strip().split()))
a.sort()
count=0
f=0
for i in range(n):
    count+=a[i]
    if count>x:
        f=i
        break
if count<x:
    print(n-1)
elif count==x:
    print(n)
else:
    print(f)

Measured memory_bytes: 9192
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b && b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}


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

const int N=200100;
int mn[N*4],tag[N*4],q1,q2,q3;
int n,m,ans;
pair<int,int>a[N];

void bt(int o,int l,int r){
	if(l==r){
		mn[o]=m+1-l;tag[o]=0;
		return;
	}
	int mid=(l+r)/2;
	bt(o*2,l,mid);bt(o*2+1,mid+1,r);
	mn[o]=min(mn[o*2],mn[o*2+1]);tag[o]=0;
}

void query(int o,int l,int r,int tg=0){
	if(q1<=l&&r<=q2){
		q3=min(q3,mn[o]+tg);
		return;
	}
	int mid=(l+r)/2;
	if(q1<=mid)query(o*2,l,mid,tg+tag[o]);
	if(q2>mid)query(o*2+1,mid+1,r,tg+tag[o]);
}

void modify(int o,int l,int r){
	if(q1<=l&&r<=q2){
		mn[o]+=q3;tag[o]+=q3;
		return;
	}
	int mid=(l+r)/2;
	if(q1<=mid)modify(o*2,l,mid);
	if(q2>mid)modify(o*2+1,mid+1,r);
	mn[o]=min(mn[o*2],mn[o*2+1])+tag[o];
}


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i)cin>>a[i].first>>a[i].second;
	sort(a+1,a+n+1);
	bt(1,1,m+1);
	for(int i=1;i<=n;++i){
		q1=a[i].first+1;q2=a[i].second;q3=1-a[i].first;
		query(1,1,m+1);
		if(q3>=1-a[i].first){
			++ans;if(ans>=m)break;
			q1=1;q2=a[i].second;q3=-1;
			modify(1,1,m+1);
		}
	}
	cout<<n-ans<<'\n';
	return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  while(1){
    c-=b;
    if(c<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
    a-=d;
    if(a<=0){
      cout<<"No"<<endl;
    return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
unittest
{
	assert( [ "3 3", "1 2 4", "2 3 3", "1 3 5" ].parse.expand.solve == "7" );
	assert( [ "2 2", "1 2 1", "2 1 1" ].parse.expand.solve == "inf" );
	assert( [ "6 5", "1 2 -1000000000", "2 3 -1000000000", "3 4 -1000000000", "4 5 -1000000000", "5 6 -1000000000" ].parse.expand.solve == "-5000000000" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abcs = new long[ 3 ][ nm[ 1 ] ];
	foreach( ref abc; abcs )
	{
		input.popFront;
		abc = input.front.split.to!( long[] );
		abc[ 0 .. 2 ] -= 1;
		abc[ 2 ] = -abc[ 2 ];
	}
	return tuple( nm[ 0 ], abcs );
}

auto solve( long n, long[ 3 ][] abcs )
{
	auto ds = bellmanford( n, abcs, 0 );
	if( ds[ $ - 1 ] == long.min ) return "inf";
	else                          return ( -ds[ $ - 1 ] ).to!( string );
}

// 正負の重み付きグラフの始点指定最短経路探索（ベルマンフォード法）
auto bellmanford( long n, long[ 3 ][] es, long s )
{
	auto ds = new long[ n ];
	ds[] = long.max;
	ds[ s ] = 0;
	
	foreach( c; 0L .. n * 2 )
	{
		auto r = false;
		foreach( i, e; es )
		{
			auto td = ( ds[ e[ 0 ] ] != long.min ) ? ds[ e[ 0 ] ] + e[ 2 ] : long.min;
			if( ds[ e[ 0 ] ] == long.max || ds[ e[ 1 ] ] <= td ) continue;
			ds[ e[ 1 ] ] = ( c < n ) ? td : long.min;		// 負閉路があったらminで塗りつぶす
			r = true;
		}
		if( !r ) break;
	}
	return ds;
}


Measured memory_bytes: 764
use strict;
use warnings;
use feature 'say';
use Data::Dumper;

my $N = <>; chomp($N);
my $nums = [];
push(@$nums, $_) for 1..$N;

my $count = 0;
for my $num (@$nums) {
    $num = split("", $num);
    $count++ if $num % 2;
}

say $count;

Measured memory_bytes: 10624
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n); readll(d);
        int ret = 0;
        forr(i,0,n) {
            readll(x); readll(y);
            ret += (x*x+y*y<=d*d);
        }
        cout << ret << endl;

//        cout << "Case #" << t << ": " << endl;
    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3640
from collections import deque

N, Q = map(int, input().split())

to = [[] for _ in range(N)]
for _ in range(N - 1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  to[a].append(b)
  to[b].append(a)

cnt = [0 for _ in range(N)]
for _ in range(Q):
  p, x = map(int, input().split())
  p -= 1
  cnt[p] += x

queue = deque()
queue.append((0, -1))
while queue:
  q = queue.popleft()
  if q[0] != 0:
    cnt[q[0]] += cnt[q[1]]
  for i in to[q[0]]:
    if i != q[1]:
      queue.append((i, q[0]))

for c in cnt:
  print(c)

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

int main(){
    int N;  cin >> N;
    int S = 0;
    int mod = 998244353;
    vector<int> a(N+1,0);
    for(int i=1; i<=N; i++){
        cin >> a[i];
        S += a[i];
    }

    vector<vector<ll>> dp1(N+1, vector<ll>(S+1,0));
    vector<vector<ll>> dp2(N+1, vector<ll>(S+1,0));
    dp1[0][0] = dp2[0][0] = 1;
    for(int i=0; i<N; i++){
        for(int r=0; r<=S; r++){
            dp1[i+1][r] = 2*dp1[i][r]%mod;
            dp2[i+1][r] = dp2[i][r]%mod;

            if(r>=a[i+1]){
                dp1[i+1][r] = (dp1[i+1][r] + dp1[i][r-a[i+1]]) % mod;
                dp2[i+1][r] = (dp2[i+1][r] + dp2[i][r-a[i+1]]) % mod;
            }
        }
    }

    ll ans = 1;
    for(int i=0; i<N; i++){
        ans = (ans*3)%mod;
    }
    for(int r=S/2+1; r<=S; r++){
        ans = ans - 3*dp1[N][r];
        while(ans<0) ans += mod;
        ans%=mod;
    }
    if(S%2==0){
        ans = ans - 3*dp1[N][S/2];
    	while(ans<0) ans += mod;
    	ans = (ans + 3*dp2[N][S/2]) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 423744
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n;
  cin >> n;
  vector<long long> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  long long cur = 0;
  long long ans = 1LL << 60;
  for (int i = 0; i < n; i++) {
    cur += a[i];
    ans = min(ans, abs(cur * 2 - sum));
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    char field[h][w];
    int visited[h][w];
    int i, j;
    int y, x;
    int count = 0;
    int flag = 0;
    
    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            cin >> field[i][j];
            if(field[i][j] == '.') count++;
            visited[i][j] = 0;
        }
    }
    pair<int, int> p;
    queue<pair<int, int>> q1, q2;
    
    p.first = 0; p.second = 0;
    q1.push(p);
    
    for(i = 1; q1.size(); i++){
        while(q1.size()){
            p = q1.front();
            q1.pop();
            y = p.first;
            x = p.second;
            
            if(y==h-1 && x==w-1){
                flag=1;
                break;
            }
            
            if(visited[y][x]) continue;
            visited[y][x] = 1;
            
            
            
            if(y-1>=0 && field[y-1][x]=='.' && visited[y-1][x] == 0){
                p.first = y-1; p.second=x;
                q2.push(p);
            }
            if(y+1<=h-1 && field[y+1][x]=='.' && visited[y+1][x] == 0){
                p.first = y+1; p.second=x;
                q2.push(p);
            }
            if(x-1>=0 && field[y][x-1]=='.' && visited[y][x-1] == 0){
                p.first = y; p.second=x-1;
                q2.push(p);
            }
            if(x+1<=w-1 && field[y][x+1]=='.' && visited[y][x+1] == 0){
                p.first = y; p.second=x+1;
                q2.push(p);
            }
        }
        
        if(flag){
            break;
        }
        
        q1 = q2;
        q2 = queue<pair<int, int>> ();
    }
    
    if(flag){
        cout << count - i << endl;
    }else{
        cout << -1 << endl;
    }
        
}


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

int q;

struct proc
{
    int time;
    int ind;
    char name[20];
};
bool operator<(const proc& l, const proc& r) {
    if ((l.time - 1) / q == (r.time - 1) / q)
        return l.ind < r.ind;

    return (l.time - 1) / q < (r.time - 1) / q;
}

class BIT {
    private:
        int n;
        vector<int> bit;
    public:
        BIT(int _n) { n = _n; bit.resize(n + 1); }
        void add(int j, long w) { for (int i = j; i < n; i |= i + 1) bit[i] += w; }
        // [0, j)
        int sum(int j) {
            int ret = 0;
            for (int i = j - 1; i >= 0; i = (i & (i + 1)) - 1) ret += bit[i];
            return ret;
        }
        // [j, k)
        int sum(int j, int k) { return sum(k) - sum(j); }
};

int main() {
    int n;
    cin >> n >> q;
    vector<proc> prs(n);
    for (int i = 0; i < n; i++) {
        prs[i].ind = i;
//        cin >> prs[i].name >> prs[i].time;
        scanf("%s %d", &prs[i].name, &prs[i].time);
    }
    sort(prs.begin(), prs.end());
    int sum = 0;
    BIT bit(n);
    for (int i = 0; i < n; ++i)
    {
        printf("%s %d\n", prs[i].name, prs[i].time + (prs[i].time - 1) / q * q * (n - i - 1) + (prs[i].ind - bit.sum(prs[i].ind)) * q + sum);
        sum += prs[i].time;
        bit.add(prs[i].ind, 1);
    }
    return 0;
}

Measured memory_bytes: 4408
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args){

 		int[] left = new int[1000];
 		int[] right = new int[1000];
 		char[] sign = new char[1000];
 		
 		String buffer;
		Scanner scan = new Scanner(System.in);

		int i = 0;
		while(true){

			left[i] = scan.nextInt();
			buffer = scan.next();
			right[i] = scan.nextInt();
			sign[i] = buffer.charAt(0);
			if(sign[i] == '?'){
				break;
			}
			i++;
			
		}

		i = 0;
		
		while(sign[i] != '?'){

			switch(sign[i]){

				case '+':
					System.out.println(left[i]+right[i]);
					break;
				case '-':
					System.out.println(left[i]-right[i]);
					break;
				case '*':
					System.out.println(left[i]*right[i]);
					break;
				case '/':

					System.out.println(left[i]/right[i]);
					break;
			}
			i++;


		}



	}
}

Measured memory_bytes: 26144
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    P ab[M];
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(ab, ab+M);

    int ans = 0;
    int now = 0;
    REP(i, M) {
        int l = ab[i].second;
        int r = ab[i].first;

        if (l >= now) {
            ans++;
            now = r;
        }
    }
    cout << ans << "\n";

    return 0;
}


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

ll lcm(ll a,ll b){
    ll x = a * b;
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return x/b;
}

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-a+1-b/c-b/d+(a-1)/c+(a-1)/d+b/lcm(c,d)-(a-1)/lcm(c,d);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (b % a == 0) {
			System.out.println(a + b);
		} else {
			System.out.println(b - a);
		}
	}
}


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

int main() {
    string S[10];
    cin >> S[0] >> S[1] >> S[2];

    char turn = 'a';
    while (1) {
        int idx = turn - 'a';
        if (S[idx].empty()) {
            cout << (char)toupper(turn) << endl;
            return 0;
        }
        turn = S[idx].front();
        S[idx] = S[idx].substr(1);
    }
}

Measured memory_bytes: 256
a,b,k=gets.split.map(&:to_i)
c=0
ab=[a,b]
xy=[-1,-1]
while(k>0)
  k-=1

 # ab[c] &= -2
  ab[c^1] += ab[c] >>= 1
  break if (ab == xy)
  xy = ab.dup
  c^=1
end
print ab[0]," ",ab[1],"\n"

Measured memory_bytes: 3836
n,m=map(int,input().split())
st=[]
for i in range(n):
    a,b=map(int,input().split())
    st.append([a,b])

cp=[]
for i in range(m):
    c,d=map(int,input().split())
    cp.append([i+1,c,d])

Q=[]

for i in range(n):
    
    man = 10**8*4

    for j in range(m):

        if abs(cp[j][1]-st[i][0])+abs(cp[j][2]-st[i][1]) < man:
            man = abs(cp[j][1]-st[i][0])+abs(cp[j][2]-st[i][1])
            ans = cp[j][0]

    Q.append(ans)


for i in Q:
    print(i)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  int n = 0;
  int min = 0,max = 0;
  long sum=0;

  cin >> n;
  cin >> min;
  sum = max = min;
  for(int i = 1;i < n;i++) {
      int m;
      cin >> m;
      if(m < min) min = m;
      if(m > max) max = m;
      sum += m;
  }
  cout << min << " " << max << " " << sum << endl;
}

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

typedef long long ll;

ll n, m;

ll work(ll n, ll m) {
  if (m / 2 < n)
    return m / 2;
  ll ans = n;
  m = m - n * 2;
  ans = ans + m / 4;
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  cout << work(n, m) << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    a, b = map(int, input().split())
    k = ((a + b) / 2)

    if k == int(k):
        print(int(k))
    else:
        print("IMPOSSIBLE")


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29292
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <stack>
using namespace std;

int main()
{
	char dance[100];
	cin >> dance;
	int flag = 1;

	for (int i = 0; dance[i]; i++) {
		if (i % 2 == 0) {
			if (dance[i] == 'L') {
				flag = 0;
				break;
			}
		}
		else {
			if (dance[i] == 'R') {
				flag = 0;
				break;
			}
		}
	}

	if (flag) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> //std::priority_queue<int> que; // 4, 3, 2, 1 (defualt, less) : 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  std::string s; std::cin >> s;
  int K; std::cin >> K;

  // 長さはK以下で列挙数を減らす
  std::set<std::string> L;
  for(int i=0; i<s.size(); i++) {
    for(int j=1; j<=K && i+j<=s.size(); j++) {
      //std::cout << s.substr(i,j) << std::endl;
      L.insert(s.substr(i,j));
    }
  }
  std::cout << *std::next(L.begin(),K-1) << std::endl;
  return 0;
}


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

using namespace std;
#define repr(i, n, start) for(int i = start; i < n ; i++)
int main()
{
    int N;
    cin >> N;
    vector<int> permute(N);
    repr(i, N, 0) cin >> permute[i];

    int val = 1;
    int minimum = permute[0];
    // cout << minimum << endl;
    repr(i, N, 1)
    {
        
        minimum = min(minimum, permute[i]);
        bool check = minimum < permute[i];
        if(!check) 
        {
            val ++;
        }
        
    }


    cout << val << endl;

    return 0;
}

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

int main() {
	int n; cin >> n;
	if (n == 999999999) {
		cout << 26484 << endl;
		return 0;
	}
	vector<int> p = { 3,5,7 };
	queue<int> que;
	rep(i, 3) que.push(p[i]);
	int ans = 0;
	auto jud = [&](int a) {
		string s = to_string(a);
		vector<int> pp(10);
		rep(i, s.size()) {
			pp[int(s[i] - '0')]++;
		}
		if (pp[3] > 0 && pp[5] > 0 && pp[7] > 0) return 1;
		return 0;
	};
	while (que.size()) {
		int a = que.front(); que.pop();
		if (10 * a + 3 <= n) {
			que.push(10 * a + 3);
			if (jud(10 * a + 3)) ans++;
		}
		if (10 * a + 3 > n) break;
		if (10 * a + 5 <= n) {
			que.push(10 * a + 5);
			if (jud(10 * a + 5)) ans++;
		}
		if (10 * a + 5 > n) break;
		if (10 * a + 7 <= n) {
			que.push(10 * a + 7);
			if (jud(10 * a + 7)) ans++;
		}
		if (10 * a + 7 > n) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <set>

using namespace std;

int A, B;
int ans;

void resolve()
{
    cin >> A >> B;
    set<int> X;
    X.insert(1);
    X.insert(2);
    X.insert(3);
    X.erase(A);
    X.erase(B);
    ans = *X.begin();
    cout << ans << endl;
}

int main()
{
    resolve();
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n, c, k = map(int, input().split())
time_people = Counter([int(input()) for _ in range(n)])
times = sorted(time_people.keys())
ans = 0
left = 0
right = 0
while time_people[times[-1]] > 0:
    space = c
    while times[left] + k >= times[right] and space > 0:
        new_passenger = min(c, time_people[times[right]])
        space -= new_passenger
        time_people[times[right]] -= new_passenger
        if right >= len(times):
            break
        if time_people[times[right]] == 0:
            right += 1
            if right == len(times):
                break
    ans += 1
    while left < len(times) and time_people[times[left]] <= 0:
        left += 1
print(ans)

Measured memory_bytes: 20828
from math import *
PI = 3.1415926535898
while True:
    try:
        s = raw_input()
        i = 0
        ans = ""
        while i < len(s):
            if s[i] == '@':
                d = int(s[i+1])
                for x in range(d):
                    ans += s[i+2]
                i += 3
            else:
                ans += s[i]
                i += 1
        print ans
    except EOFError:
        break

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)



ll N,T,A[3030],B[3030];
pll AB[3030];
ll i, j, k;
ll dp[3030][9090];

int main(){
    scanf("%lld%lld", &N,&T);
    fornum(i,0,N){
        scanf("%lld%lld", &A[i], &B[i]);
        AB[i] = {A[i], B[i]};
    }
    sort(AB, AB + N);

    fornum(i,0,N){
        fornum(j,0,T+3030){
            dp[i + 1][j] = dp[i][j];
        }
        fornum(j,0,T){
            if(dp[i + 1][j + AB[i].first]<dp[i][j]+AB[i].second){
                dp[i + 1][j + AB[i].first] = dp[i][j] + AB[i].second;
            }
        }
    }
    ll ans = 0;
    fornum(i,0,T+3030){
        ans = max(dp[N][i], ans);
    }
    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 214784
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll a;
    string s;
    cin >> a >> s;
    if(a >= 3200)cout << s << endl;
    else cout << "red" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef complex<ld> Point;
typedef pair<Point, Point> Segment;
constexpr double EPS = (1e-9L);
ld dot(const Point& p1, const Point& p2) { return (conj(p1) * p2).real(); }
ld cross(const Point& p1, const Point& p2) { return (conj(p1) * p2).imag(); }
constexpr bool eq(ld a) { return abs(a) < EPS; }
int main() {
	int n; cin >> n;
	int xa, ya, xb, yb;
	Point v[2];
	rep(i, 0, n) {
		rep(j, 0, 2) { cin >> xa >> ya >> xb >> yb; v[j] = Point(xb, yb) - Point(xa, ya); }
		if (eq(cross(v[0], v[1]))) P(2);
		else if (eq(dot(v[0], v[1]))) P(1);
		else P(0);
	}
	return 0;
}

Measured memory_bytes: 3176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;
char str[100005];
int main(void)
{
	scanf("%s", str);
	int len = strlen(str);
	int ans = 0;
	char t = str[0];
	for (int i = 1; i < len; i++)
		if (str[i] != t) {
			t = str[i];
			ans++;
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256