akhauriyash/Code-Regression huggingface dataset:
import math
n, m = map(int, input().split())

ab = []
ans = 0
sum = 0

for _ in range(n):
    ab.append(list(map(int, input().split())))

ab.sort()

for i in range(n):
    if m - ans < ab[i][1]:
        sum += (m-ans) * ab[i][0]
        ans = m
        break
    else:
        ans += ab[i][1]
        sum += ab[i][0] * ab[i][1]

    if ans == m:
        break


print(sum)


Measured memory_bytes: 27864
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;
typedef vector<vi> mat;

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<Kanna;I_Love++)cout<<Hashimoto[I_Love]<<(I_Love==Kanna-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<Kanna;I_Love++)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n;
int color[4444];
int blackpos[2222];
int whitepos[2222];
int num[4444];
int wsuf[4444][2222],bsuf[4444][2222];
//wsuf[i][j] represents the number of white balls with number < j behind the ball i
int dp[2222][2222];

int I_Love_Hashimoto_Kanna() {
	fastio;
	FOR(i,0,2222)FOR(j,0,2222) {
		dp[i][j]=inf;
	}
	cin>>n;
	FOR(i,0,n+n) {
		char c;
		cin>>c>>num[i];
		num[i]--;
		if(c=='W') {
			color[i]=1;
			whitepos[num[i]]=i;
		} else {
			color[i]=-1;
			blackpos[num[i]]=i;
		}
	}
	//calculate suffix
	for(int i=n+n-1; i>=0; i--) {
		FOR(j,0,n+1)wsuf[i][j]=wsuf[i+1][j],bsuf[i][j]=bsuf[i+1][j];
		if(color[i+1]==1) {
			FOR(j,num[i+1]+1,n+1)wsuf[i][j]++;
		} else if(color[i+1]==-1) {
			FOR(j,num[i+1]+1,n+1)bsuf[i][j]++;
		}
	}
	dp[0][0]=0;
	//dp
	FOR(i,0,n+1) {
		FOR(j,0,n+1) {
			int pos1,pos2;
			//white ball
			pos1=i+j;
			pos2=whitepos[i]+wsuf[whitepos[i]][i]+bsuf[whitepos[i]][j];
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+pos2-pos1);
			//black ball
			pos1=i+j;
			pos2=blackpos[j]+wsuf[blackpos[j]][i]+bsuf[blackpos[j]][j];
			dp[i][j+1]=min(dp[i][j+1],dp[i][j]+pos2-pos1);
		}
	}

	cout<<dp[n][n]<<endl;
	return 0;
}


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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    ll ans = 1e18;
    rep(i, N - K + 1) {
        ans = min(ans, 0LL + abs(x[i]) + abs(x[i] - x[i + K - 1]));
        ans = min(ans, 0LL + abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1]));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <bitset>
#define LL long long
#define NUM 1000000007

using namespace std;

int main() {
    int n, m;
    cin >> n;
    vector<int> t(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    cin >> m;
    vector<pair<int, int>> px(m);
    for (size_t i = 0; i < m; i++)
    {
        cin >> px[i].first >> px[i].second;
    }
    for (size_t i = 0; i < m; i++)
    {
        long long sum = 0;
        for (size_t j = 0; j < n; j++)
        {
            if (px[i].first - 1 == j)
            {
                sum += px[i].second;
            }
            else
            {
                sum += t[j];
            }
        }
        cout << sum << endl;
    }

}

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

int main(){
  int n;
  ll k;
  cin>>n>>k;
  ll sum=0;
  ll vec[n];
  ll vecb[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
    sum+=vec[i];
  }
  if(sum<=k){
    cout<<0<<endl;
    return 0;
  }
  for(int i=0;i<n;i++){
    cin>>vecb[i];
  }
  sort(vec,vec+n);
  sort(vecb,vecb+n);
  reverse(vecb,vecb+n);
  ll ng=0,ok=1e12+1e5;
  ll check;
  ll zero=0;
  for(int t=0;t<40;t++){
    check=(ng+ok)/2;
    sum=0;
    for(int i=0;i<n;i++){
      sum+=max(zero,vec[i]-check/vecb[i]);
    }
    if(sum<=k){
      ok=check;
    }
    else{
      ng=check;
    }
  }
  cout<<ok<<endl;
}

Measured memory_bytes: 3328
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
from queue import Queue
INF = float("inf")
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    numer = reduce(mul, range(n, n - r, -1))
    denom = reduce(mul, range(1, r + 1))
    return numer // denom


def solve(N: int, M: int, A: "List[int]"):
    B = itertools.accumulate(A)
    c = collections.Counter()
    for b in B:
        c[b % M] += 1
    print(c[0]+sum([cmb(c[k], 2)for k in c if c[k] > 1]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21032
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;



int main() {
  ll n,k;
  cin >> n >> k;
  ll h[n];
  rep (i,n) cin >> h[i];
  ll cnt = 0;
  rep(i,n){
      if (k<=h[i]) cnt++;
  }
  cout << cnt << endl;

}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,ans=1,minv,b;
	cin>>a;
	cin>>b; 
	minv=b;
	for(int i=1;i<a;i++){
		cin>>b;
		if(b<=minv){
			minv=b;
			ans++;
		}
	}
	cout<<ans; 
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;

#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

void rw()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

int main()
{
    speed;
    //rw();

    ll q;
    cin>>q;
  	
  	cout<<(!q?1:0);
   
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

main(){

	int b,f,r,v,n,i;
	int a[4][3][10]={};

	while(b<4){
		f=0;
		while(f<3){
			r=0;
			while(r<10){
				a[b][f][r]=0;
				r++;
			}
			f++;
		}
		b++;
	}

	scanf("%d", &n);
	i=0;
	while(i<n){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		b=b-1;
		f=f-1;
		r=r-1;
		a[b][f][r] = a[b][f][r] + v;
		i++;
	}

	b=0;
	while(b<4){
		f=0;
		while(f<3){
			r=0;
			while(r<10){
				printf(" %d",a[b][f][r]);
				r++;
			}
			printf("\n");
			f++;
		}
		if(b<3)printf("####################\n");
		b++;
	}
;	return 0;
}

Measured memory_bytes: 612
class PriorityQueue
  attr_accessor(:node)
  
  def initialize(src = [])
    @node = []
    src.each do |e|
      push(e)
    end
  end

  def push(x)
    @node << x
    bottom_up
  end

  def pop
    res = @node.first
    top_down
    return res
  end
  
  def bottom_up
    i = @node.size - 1
    v = @node[i]
    while i > 0
      parent = (i - 1) >> 1
      break if @node[parent] >= v
      
      swap(parent, i)
      i = parent
    end
    
    @node[i] = v
  end

  def top_down
    i = 0
    tmp = @node.pop
    while (i << 1) + 1 < @node.size
      lhs = (i << 1) + 1
      rhs = (i << 1) + 2
      m = lhs
      
      if rhs < @node.size && @node[lhs] < @node[rhs]
        m = rhs
      end
      
      break if @node[m] <= tmp
      @node[i] = @node[m]
      i = m
    end
    
    @node[i] = tmp unless @node.empty?
  end

  def swap(i, j)
    @node[i], @node[j] = @node[j], @node[i]
  end
end

_, m = $stdin.readline.chomp.split.map(&:to_i)
a = $stdin.readline.chomp.split.map(&:to_i)
pq = PriorityQueue.new(a)

m.times do
  break if pq.node.empty?
  
  x = pq.pop
  pq.push(x / 2)
end
puts pq.node.sum

Measured memory_bytes: 23856
#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    scanf("%d", &n);
    char s[102], t[102];
    scanf("%s%s", s, t);
    int i, j;
    int x;
    for (i = 0; i < n; i++)
    {
        x = 0;
        for (j = i; j < n; j++)
        {
            if (s[j] != t[j - i])
            {
                x++;
                break;
            }
        }
        if (x == 0)
            break;
    }
    printf("%d\n", n + i);
    return 0;
}

Measured memory_bytes: 128
object Main{

def main(args: Array[String]): Unit = {
  val arr1 = io.StdIn.readLine().split(' ')
  val a = arr1(0).toInt
  val b = arr1(1).toInt
  val c = arr1(2).toInt
  
  if (a - b >= c) println(0) else println(c - (a - b) )
}
}


Measured memory_bytes: 25376
S = input() + "R"
ans = [0]*len(S)
R = 0
L = 0
D = 0

for i in range(len(S) -1):
  if D == 0:
    if S[i] == S[i + 1]:
      R += 1
    else:
      ans[i] = 1
      ans[i+1] = 1
      ans[i] += R//2
      ans[i+1] += R - (R//2)
      temp = i
      D = 1
      R = 0
  else: 
    if S[i] == S[i + 1]:
      L += 1
    else:
      ans[temp+1] += L//2
      ans[temp] += L - (L//2)
      D = 0
      L = 0
[ print(_) for _ in ans[:-1]]

    
  

Measured memory_bytes: 6528
n=int(input())
h=list(map(int,input().split()))
h[0]=h[0]-1
for i in range(1,n):
    try:
        if h[i-1]<=h[i]-1:
            h[i]=h[i]-1
    except IndexError:
        pass
for i in range(n):
    try:
        if h[i]>h[i+1]:
                print("No")
                exit()
    except IndexError:
        pass
print("Yes")

Measured memory_bytes: 14396
#include <stdio.h>
int main(void){
	int n,m,i;
	scanf("%d%d",&n,&m);
	int a,b,b1[n],b2[n];
	for(i=0;i<n;i++){b1[i]=0;b2[i]=0;}
	for(i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		if(a==1)	b1[b] = 1;
		if(b==n)	b2[a] = 1;
	}
	for(i=0;i<n;i++){
		if(b1[i]==1 && b2[i]==1){
			printf("POSSIBLE");
			return 0;
		}
	}
	
	printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)

map<string, ll> mp;
int main() {
	ll n; cin >> n;
	rep(i, 0, n) {
		string s; cin >> s;
		mp[s]++;
	}
	ll maxV = 0;
	for (auto M : mp) maxV = max((ll)maxV, M.second);

	for (auto M : mp) {
		if (M.second == maxV) {
			cout << M.first << endl;
		}
	}
	


}


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

int		main(void)
{
	int N, M, sum, result;

	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; i++)
		cin >> s[i];	
	cin >> M;
	vector<string> t(M);
	for (int i = 0; i < M; i++)
		cin >> t[i];	
	for (int i = 0; i < N; i++)
	{
		sum = 0;
		for (int j = i + 1; j < N; j++)
		{
			if (s[i] == s[j])
				sum++;
		}
		for (int k = 0; k < M; k++)
		{
			if (s[i] == t[k])
				sum--;
		}
		if (result < sum || i == 0)
			result = sum;
	}
	result < 0 ? result = 0 : result ++;
	cout << result << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	var S string
	var K int
	fmt.Scan(&N, &S, &K)
	s := S[K - 1]
	ans := ""
	for  i := 0; i < N; i++ {
		if s == S[i] {
          ans += string(S[i])
		} else {
          ans += "*"
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
/* 
 * Author: aps
 * Time: 2019-10-19 19:48:45
**/
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll inf = 1e18;
const ll mod = 1e9+7;
 
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll gcd(ll x, ll y) { return x == 0 ? y : gcd(y % x, x); }
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n, ans = 1; cin >> n;
    string s; cin >> s;

    for(int i=1;i<n;i++) {
        if(s[i] != s[i-1]) ans++;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aman Kumar Singh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACurtain solver = new ACurtain();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACurtain {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int a = ni();
            int b = ni();
            pn(a - Math.min(a, 2 * b));

        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21588
n,m = map(int,input().split())
l = []
for _ in range(m):
    a = list(map(int,input().split()))
    l.append(a)

memo = [0]*n

for i in range(m):
    memo[l[i][0]-1] += 1
    memo[l[i][1]-1] += 1

for j in range(n):
    print(memo[j])

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

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

  if (a > 0)
	cout << "Positive" << endl;
  else if (b >= 0)
	cout << "Zero" << endl;
  else{
	if ((b - a + 1) % 2 == 0)
	  cout << "Positive" << endl;
	else
	  cout << "Negative" << endl;
  }
}

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

int main(){
  int m,t,p,r,i,j,k;
  while(1){
    cin >> m >> t >> p >> r;
    if(m==0)break;
    int ac[t]={},wa[t][p+1],actime[t]={};
    for(i=0;i<t;i++){
      for(j=0;j<p+1;j++)wa[i][j]=0;
    }
    for(i=0;i<r;i++){
      int M,T,P,R;
      cin >> M >> T >> P >> R;
      if(R!=0)wa[T-1][P]++;
      else{
        ac[T-1]++;
        actime[T-1]+=wa[T-1][P]*20+M;
      }
    }

    //cout << actime[0] << actime[1] << endl;

    bool flag[t]={};
    int bscore=-1,bfinaltime=-1;
    for(j=0;j<t;j++){
      int team=-1,score=-1,finaltime=300*20;
      for(i=0;i<t;i++){
        if(flag[i]==true)continue;
        if(score<ac[i]){
          team=i;
          score = ac[i];
          finaltime= actime[i];
        }else if(score == ac[i] && finaltime>=actime[i]){
          team=i;
          finaltime=actime[i];
        }
      }
      if(j!=0){
        if(bscore==score && bfinaltime==finaltime)cout << "=";
        else cout << ",";
      }
      cout << team+1;
      flag[team]=true;
      bscore = score;
      bfinaltime=finaltime;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#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(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll a[7];
  rep(i,7) R a[i];
  ll ans=a[1];
  if(a[0]&&a[3]%2&&a[4]%2||a[0]%2&&a[3]&&a[4]%2||a[0]%2&&a[3]%2&&a[4]) {
    a[3]--;
    a[4]--;
    a[0]--;
    ans+=3;
  }
  ans+=a[0]/2*2;
  ans+=a[3]/2*2;
  ans+=a[4]/2*2;
  pr(ans);
}

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


Measured memory_bytes: 256
# 16:20
s = input()
for i in range(len(s)):
    if s[i] != 'U' and s[i] != 'D':
        if (i+1)%2 == 0 and s[i] == 'R':
            print("No")
            exit(0)
        if (i+1)%2 != 0 and s[i] == 'L':
            print("No")
            exit(0)
print("Yes")

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

int main(){
    ll n,x;
    cin>>n>>x;
    vector<ll>a(n);
    ll ans=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]>x){
            ans+=a[i]-x;
            a[i]=x;
        }
    }
    for(int i=0; i<n-1; ++i){
        if(a[i]+a[i+1]>x){
            ans+=a[i]+a[i+1]-x;
            a[i+1]-=a[i]+a[i+1]-x;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import deque
import sys
sys.setrecursionlimit(202020)

n, q = map(int, input().split())
to = [deque() for _ in range(n)]
score = [0 for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b)
    to[b].append(a)
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    score[p] += x

visited = [False for _ in range(n)]
def dfs(v):
    visited[v] = True
    stack = deque([v])
    while len(stack) > 0:
        u = stack[-1]
        if len(to[u]) > 0:
            w = to[u].popleft()
            if visited[w]:
                continue
            score[w] += score[u]
            visited[w] = True
            stack.append(w)
        else:
            stack.pop()

dfs(0)
print(*score)

Measured memory_bytes: 157240
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, h;

int main(){
	cin >> n;
	ll maxh = 0;
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		cin >> h;
		if(h >= maxh){ans++;}
		maxh = max(h, maxh);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,h[100010],a,b,f[100010],ans;
vector<int> v[100010];
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>h[i];
	for (int i=0;i<m;i++){
		cin>>a>>b;
		if (h[a]>=h[b]) f[b]=1;
		if (h[a]<=h[b]) f[a]=1;
	}
	for (int i=1;i<=n;i++) if (f[i]==0) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6760
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;



int main()
{
    ll n;
    ll t;
    cin >> n >> t;
    ll p[n];
    ll max[n]; //iよりも先で、価格が最大のpを格納
    for(ll i=0 ; i<n ; i++)
    {
        cin >> p[i];
    }

    for(ll i = n - 1 ; i >= 0 ; i-- )
    {
        if(i == n - 1)
        {
            max[i] = 0;
        }
        else if(i == n - 2)
        {
            max[i] = p[n-1];
        }
        else
        {
            if(max[i+1] < p[i+1])
            {
                max[i] = p[i+1];
            }
            else
            {
                max[i] = max[i+1];
            }
        }
    }

    ll gap[n];
    ll maxgap = 0;
    for(ll i = 0 ; i < n - 1 ; i++)
    {
        gap[i] = max[i] - p[i];
        if(maxgap < gap[i])
        {
            maxgap = gap[i];
        }
    }

    ll ans = 0;
    for(ll i = 0 ; i < n-1 ; i++)
    {
        if(gap[i] == maxgap)
        {
            ans ++;
        }
    }

   cout << ans << endl;

   return 0 ;

}


Measured memory_bytes: 2560
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>
#include <sstream>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class EThisMessageWillSelfDestructIn5s {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int64_t n;
    cin >> n;
    vector<int> a_vec(n);
    vector<int> a_vec_plus(n);
    vector<int> a_vec_minus(n);

    int64_t res = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a_vec[i];
      a_vec_minus[i] = i - a_vec[i];
      a_vec_plus[i] = i + a_vec[i];
    }
    sort(a_vec_plus.begin(), a_vec_plus.end());
    for (int j = 0; j < n; ++j) {
      auto liter = lower_bound(a_vec_plus.begin(), a_vec_plus.end(), a_vec_minus[j]);
      auto uiter = upper_bound(a_vec_plus.begin(), a_vec_plus.end(), a_vec_minus[j]);
      res += (distance(a_vec_plus.begin(), uiter) - distance(a_vec_plus.begin(), liter));
    }
    cout << res << endl;
  }
};


int main() {
    EThisMessageWillSelfDestructIn5s solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n[4];
    rep(i, 4) cin >> n[i];
    sort(n, n + 4);
    if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9)
        cout << "YES\n";
    else
        cout << "NO\n";
}

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

void solve() {
    int A, B, C, S;
    scanf("%d %d %d", &A, &B, &C);
    S = A + B + C;
    puts(S == 17 ? "YES" : "NO");
}

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

    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll n;
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    //COMinit();
    ll ans = 1,tmp1 = 1,tmp2 = 1;
    for(ll i = 1; i <= n; ++i) {
        ans *= 10;
        tmp1 *= 8;
        tmp2 *= 9;
        ans %= mod;
        tmp1 %= mod;
        tmp2 %= mod;
    }
    ll ans_tmp = ans+tmp1-2*tmp2;
    ans_tmp %= mod;
    if(ans_tmp < 0) cout << ans_tmp+mod << endl;
    else cout << ans_tmp << endl;
    //cout << COM(n,2) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long N) {
  int ans=0;
  for(int i=1; i<=N; i++){
    string n =to_string(i);
    if(n.length()%2!=0){
      ans++;
    }
  }
  cout<<ans<<endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  vector<FiniteField> factorials(4001);
  factorials[0] = 1;
  for (int i = 1; i <= 4000; i++) {
    factorials[i] = factorials[i - 1] * i;
  }
  vector<FiniteField> inv_factorials(4001);
  for (int i = 0; i <= 4000; i++) {
    inv_factorials[i] = FiniteField(1) / factorials[i];
  }
  auto c_fn = [&](int n, int k) {
    return factorials[n] * inv_factorials[k] * inv_factorials[n - k];
  };

  vector<FiniteField> two_powers(4001);
  two_powers[0] = 1;
  for (int i = 1; i <= 4000; i++) {
    two_powers[i] = two_powers[i - 1] * 2;
  }

  int k, n;
  cin >> k >> n;
  for (int i = 2; i <= 2 * k; i++) {
    int a = (i % 2 == 0) ? 1 : 0;
    int b = 0;
    for (int f1 = 1; f1 <= k; f1++) {
      int f2 = i - f1;
      if (1 <= f2 && f2 <= k && f1 < f2) {
        b++;
      }
    }
    int c = k - a - 2 * b;
    if (DEBUG) cout << "a: " << a << " b: " << b << " c: " << c << endl;

    FiniteField v = 0;
    for (int x = 0; x <= a; x++) {
      for (int y = 0; y <= b; y++) {
        if (x + y > n) continue;
        int r = n - x - y;
        if (r > 0 && y + c == 0) continue;

        FiniteField w = 1;
        w *= c_fn(b, y);
        w *= two_powers[y];
        w *= c_fn(n - x + c - 1, n - x - y);
        if (DEBUG) cout << "x: " << x << " y: " << y << " w: " << w.Value() << endl;
        v += w;
      }
    }
    cout << v.Value() << endl;
  }
}

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(100000)
ans = 0

def dfs(s, n):
    global ans
    if s == "":
        pass
    elif int(s) > n:
        return
    elif "3" in s and "5" in s and "7" in s:
        # print(s)
        ans += 1

    for i in "753":
        dfs(s+i, n)


def main():
    global ans
    n = int(input())
    dfs("", n)
    print(ans)

main()


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

int N, M, R;
vector<vector<int>> d(300, vector<int>(300, 1e9));

void warshall_floyd() {
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    cin >> N >> M >> R;
    vector<int> r(R);
    string order = "";
    for (int i = 0; i < R; i++) {
        int x;
        cin >> x;
        r[i] = x - 1;
        order += char(r[i] + '0');
    }
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshall_floyd();
    int ans = 1e9;
    sort(r.begin(), r.end());
    do {
        int sum = 0;
        for (int i = 1; i < R; i++) {
            sum += d[r[i - 1]][r[i]];
        }
        ans = min(ans, sum);
    } while (next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007


#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

vector<string> ans; 

ll n;
void f(string &s, ll h){
  if(s.sz==n){
    ans.pb(s);
    return;
  }
  rep(i,0,h+2){
    string s1 = s + ctos('a'+i);
    f(s1,max(h,i));
  }
}

int main(){
  /*
  ll n;
  cin>>n;
  rep(i,0,pow(n,n)){
    ll a = i;
    string s;
    rep(j,0,n){
      s += ctos('a'+(a%n));
      a /= n;
    }
    ll flag = 1;
    vector<ll> v;
    rep(i,0,n){
      v.pb(i);
    }
    ll flag1 = 1;
    do{
      string s1;
      ll flag = 1;
      rep(j,0,n){
        s1 += ctos('a'+v[(s[j]-'a')]);
      }
      if(s1<s)flag1 = 0;
    }while(next_permutation(all(v)));
    if(flag1 == 1){
      cout << s << endl;
    }
  }
  */
  cin>>n;
  string s = "a";
  f(s,0);
  sort(all(ans));
  rep(i,0,ans.sz){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 7796
from math import pi, sin, cos


def read_int():
    return int(input())


deg = read_int()
x = 0.0
y = 0.0
theta = 90.0
rad = 180.0 / pi
cnt = 0
while True:
    cnt += 1
    x += cos(theta / rad)
    y += sin(theta / rad)
    theta += deg
    if x * x + y * y <= 1e-6:
        break

print(cnt)


Measured memory_bytes: 9560
num_of_games=int(input())
t_point=0
h_point=0
for i in range(num_of_games):
    t,h=input().split()
    if t < h:h_point+=3;
    elif t>h:
        t_point+=3;
    else:
        t_point+=1; h_point+=1
print(t_point, h_point)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int a, b;
  cin >> a >> b;
  int d = a / b;
  int r = a % b;
  double f = a / (double) b;
  cout << d << " " << r << " " << fixed << setprecision(7) << f << endl;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	vs query, yaml;
	string buf;
	getline(cin, buf);
	int t = 1;
	FOR(i, 1, buf.size())
	{
		if (buf[i] == '.')
		{
			query.push_back(buf.substr(t, i - t));
			t = i + 1;
		}
	}
	query.push_back(buf.substr(t));
	while (getline(cin, buf)) yaml.push_back(buf);
	int n = yaml.size();
	vi cntsp(n);
	REP(i, n)
	{
		REP(j, yaml[i].size())
		{
			if (yaml[i][j] != ' ')
			{
				cntsp[i] = j;
				break;
			}
		}
		yaml[i].erase(0, cntsp[i]);
	}


	int top = -1, sp = 0;
	bool f = true;
	REP(i, query.size())
	{
		string tar = query[i];
		FOR(j, top+1, yaml.size())
		{
			if (cntsp[j] < sp)
			{
				puts("no such property");
				return 0;
			}
			if (cntsp[j] > sp) continue;
			if (yaml[j].substr(0, tar.size()) == tar)
			{
				if (i == query.size() - 1)
				{
					if (yaml[j].size() == tar.size() + 1)
					{
						puts("object");
						return 0;
					}
					else
					{
						cout << "string \"" << yaml[j].substr(tar.size() + 2) << "\"" << endl;
						return 0;
					}
				}
				else
				{
					if (j == yaml.size() - 1 || cntsp[j+1] <= cntsp[j])
					{
						puts("no such property");
						return 0;
					}
					top = j;
					sp = cntsp[j + 1];
					f = false;
					break;
				}
			}
		}
		if (f)
		{
			puts("no such property");
			return 0;
		}
		f = true;
	}
	
	return 0;
}

Measured memory_bytes: 3296
#define _GLIBCXX_DEBUG
#include <cstdio>
#include <vector>
#include <string>

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  char buf[131072];
  scanf("%s", buf);
  std::string S = buf;

  std::vector<int> B(N);
  for (size_t i = 0; i < N; ++i)
    B[i] = S[i]-'0';

  std::vector<int> D[2];
  D[1].push_back(0);

  int k = 1;
  for (size_t i = 0; i < N; ++i) {
    if (k != B[i]) {
      k ^= 1;
      D[k].push_back(1);
    } else {
      ++D[k].back();
    }
  }

  if (D[0].size() == D[1].size())
    D[1].push_back(0);

  int cur = D[1][0];
  for (size_t i = 0; i < K; ++i) {
    if (i >= D[0].size()) break;
    cur += D[0][i];
    cur += D[1][i+1];
  }

  int res = cur;
  for (size_t i = K; i < D[0].size(); ++i) {
    cur -= D[1][i-K];
    cur -= D[0][i-K];
    cur += D[0][i];
    cur += D[1][i+1];
    res = std::max(res, cur);
  }

  printf("%d\n", res);
}

Measured memory_bytes: 1320
#include <stdio.h>
#define N 300001
int c[N], p[N], pc;
int main(void)
{
    int i, j, n;
    for(i=6;i<N;i+=(i%7==1)?5:2) if (!c[i]) {
        p[pc++]=i;
        for(j=i+i;j<N;j+=i) c[j]=1;
    }

    while (scanf("%d", &n), n-1) {
        printf("%d:", n);
        for(i=0;i<pc;++i) if (n%p[i]==0) printf(" %d", p[i]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1924
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

signed main(){
  int N;
  cin >> N;
  FOR(i,N,114514){
    if(i%10 == i/100 && i%10 == (i%100)/10){
      cout << i << endl;
      return 0;
    }
  }
}

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

using ll=long long;

ll check(vector<pair<ll,ll>> vt){
  ll n = vt.size();
  for(int i=0;i<n;i++) vt[i].first=min(vt[i].first,n);
  vector<vector<ll>> vs(n+1);
  for(int i=0;i<n;i++) vs[vt[i].first].emplace_back(vt[i].second);
  priority_queue<ll> que;
  ll ans=0;
  for(int i=n;i>0;i--){
    for(auto u:vs[i]){
      que.push(u);
    }
    if(!que.empty()){
      ans+=que.top();
      que.pop();
    }
  }
  return ans;
}

void solve(){

  int n;
  cin >> n;

  ll k,l,r;
  ll ans = 0;
  vector<pair<ll,ll>> right,left;
  ll m;
  for(int i=0;i<n;i++){
    cin >> k >> l >> r;

    if(l>r){
      ans+=r;
      left.emplace_back(k,l-r);
    }else{
      ans+=l;
      right.emplace_back(n-k,r-l);
    }
  }
  ans+=check(left);
  ans+=check(right);
  cout << ans << endl;
}

int main(){

  ll t;
  cin >> t;
  for(ll i=0;i<t;i++){
    solve();
  }
}

Measured memory_bytes: 14236
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int c=0;
    char a[3],abc[3]={'a','b','c'};
    cin>>a;
    for(int i=0;i<=2;i++)
    {
        if (a[0]==abc[i])
        {
            c++;
            continue;
        }
        else if (a[1]==abc[i])
        {
            c++;
            continue;
        }
        else if (a[2]==abc[i])
        {
            c++;
            continue;
        }
    }
        if (c!=3) cout << "No";
        if (c==3) cout << "Yes";
}


Measured memory_bytes: 3548
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll n ; 
	for(int i=0;i<5;i++){
		cin >> n ;
		if(n==0){
			cout << i+1 << endl ;
			return 0 ;
		}
	}
}

Measured memory_bytes: 3552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;

namespace ABC161D
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());

            long max = 3234566667;
            //long max = 500;
            int count = 0;
            for (long i = 1; i <= max; i++)
            {
                if (Check(i, out i))
                {
                    count++;
                    //Console.WriteLine(count);
                }

                if (count == K) { Console.WriteLine(i); break; }
            }
            Console.ReadKey();
        }

        static bool Check(long num, out long next)
        {
            bool ans = true;

            int digit = Digit(num);
            string s = num.ToString();
            for (int j = 0; j < digit - 1; j++)
            {
                if (Math.Abs(int.Parse(s[j].ToString()) - int.Parse(s[j + 1].ToString())) <= 1) continue;
                ans = false;
                long p = (long)Math.Pow(10, digit - j - 2);
                next = (num / p + 1) * p - 1;
                return ans;
            }

            next = num;
            return ans;
        }

        static int Digit(long num)
        {
            int ans = 1;
            long next = num / 10;
            while (next > 0)
            {
                ans++;
                next /= 10;
            }

            return ans;
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 17320
import scala.collection.mutable.ArrayBuffer

object Main {

  def main(args: Array[String]): Unit = {

    class UnionSet(par: Array[Int]) {
      def root(x: Int): Int =
        if (par(x) == x) x
        else {
          par(x) = root(par(x))
          par(x)
        }
      def unite(x: Int, y: Int): Unit = {
        val rx = root(x)
        val ry = root(y)
        if (rx != ry)
          par(rx) = ry
      }
      def same(x: Int, y: Int): Boolean =
        root(x) == root(y)
    }
    object UnionSet {
      def apply(n: Int): UnionSet =
        new UnionSet(Array.range(0, n))
    }

    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val W = Array.fill(N, N)(sc.nextInt())

    val _E = new ArrayBuffer[(Int, Int)]() // (辺(u,v), 重みw)
    (0 until N) foreach { i =>
      (0 until N) foreach { j =>
        if (W(i)(j) >= 0) {
          _E.append((i, j))
        }
      }
    }
    val E: List[(Int, Int)] = _E.sortBy(e => W(e._1)(e._2)).toList // 辺(軽い順)

    // 最初, 全ての頂点は別の木として初期化する
    val unionset = UnionSet(N)
    var count = 0
    // 軽い辺から見ていき
    E foreach { e =>
      val (u, v) = e
      // u, v が別の木ならば, これは軽い辺なので安全に追加できる.
      if (!unionset.same(u, v)) {
        unionset.unite(u, v)
        count += W(u)(v)
      }
    }

    // 入力が連結グラフであることから,最終的に出来上がった木は1本となり, これが最小全域木である
    // 加えた辺の重さの合計が最小全域木の重さの合計
    println(count)
  }

}



Measured memory_bytes: 63236
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <time.h>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
const int MOD = 1000000007;
int n, g[1000005];
int power(int A, int B)
{
    int tmp = 1;
    while (B)
    {
        if (B & 1)
        {
            tmp = tmp * A % MOD;
        }
        A = A * A % MOD;
        B >>= 1;
    }
    return tmp;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    if (n < 2)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << ((power(10, n) - (power(9, n) - power(8, n)) * 2 - power(8, n)) % MOD + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 3688