akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::marker::*;
use proconio::*;
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        k: usize,
    }
    // annotate for rust-analyzer
    let k: usize = k;

    let mut q = VecDeque::new();
    for i in 1..=9 {
        q.push_back(i);
    }
    let mut ans = 0u64;
    let mut cnt = 0;
    while cnt < k {
        let cur = q.pop_front().unwrap();
        let child = cur % 10;
        let parent = cur * 10;
        if child != 0 {
            q.push_back(parent + child - 1);
        }
        q.push_back(parent + child);
        if child != 9 {
            q.push_back(parent + child + 1);
        }
        ans = cur;
        cnt += 1;
    }

    println!("{}", ans);
}


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


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

int main(){
  string s;
  cin>>s;
  int ret = 0;
  int counter = 0;
  for(int i=0; s[i]; i++){
    if(s[i]=='R'){
      counter++;
      ret = max(ret,counter);
    }
    else counter = 0;
  }
  cout<<ret;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

struct Point {
  ll x;
  ll y;
  ll h;
};

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

  vector<ll> X(N), Y(N), H(N);
  for (ll i = 0; i < N; i++) {
    cin >> X[i] >> Y[i] >> H[i];
  }
  constexpr ll MAX = 100;

  for (ll y = 0; y <= MAX; y++) {
    for (ll x = 0; x <= MAX; x++) {
      for (ll i = 0; i < N; i++) {
        if (H[i] == 0) {
          continue;
        }
        // 成立できる高さを仮に決めてしまう
        const ll candidate_h = H[i] + abs(X[i] - x) + abs(Y[i] - y);
        bool flag = true;

        // 他の点と矛盾しないことを見ていく
        for (ll j = 0; j < N; j++) {
          if (j == i) {
            continue;
          }
          const ll calc_h = max(0LL, (candidate_h - abs(X[j] - x) - abs(Y[j] - y)));
          if (calc_h != H[j]) {
            flag = false;
            break;
          }
        }
        if (!flag) {
          continue;
        } else {
          cout << x << " " << y << " " << candidate_h << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a,b,ans;
int main () {
	scanf("%lld%lld%lld",&n,&a,&b);
	ans=a*(n/(a+b));
	ans+=min(a,n%(a+b));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main()
{
  
         long int a,b,c,k,ans=0;
         cin>>a>>b>>c>>k;
         if(k<=a)
           cout<<k;
           
         else if(k<=(a+b))
           cout<<a;
           
         else
          {
              ans=a;
              k=k-a;
              k=k-b;
              ans=ans-k;
              cout<<ans;
          }
   
    return 0;    
        
}

Measured memory_bytes: 3624
import qualified Data.ByteString.Char8 as C
import Data.List

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [n,k] <- r'
    let res = sum $ map ((flip $ solve1 n) k) [1..n]
    print res


nDice :: Int -> Int -> Int
nDice n k = max 0 $ ceiling $ logBase 2 (fromIntegral k / fromIntegral n)

solve1 :: Fractional a => Int -> Int -> Int -> a
solve1 nn n k = (1 / fromIntegral nn)* ((1/2)^(nDice n k))




Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

int main(void) {
	ll ans = 0;
	ll n;
	cin >> n;
	rep(i, n) {
		ans += (i+1)*((n / (i + 1))*(n / (i + 1) + 1)) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3568
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		//Scanner myObj = new Scanner(System.in);
		Scanner ret = new Scanner(System.in);
		int a,b=0,i,c=0;
		String s;
		
		
	    //a=ret.nextInt();
		for(i=0;i<3;i++)
		{
			a=ret.nextInt();
			if(a==5)
			{
			 b++;
			}
			else if(a==7)
				c++;
				
		}
		if(b==2&&c==1)
		{
		 System.out.println("YES");
		}
		else
		 System.out.println("NO");
			
	   
	}

}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(s);
  int ans = 0;
  REP(i, s.size()) {
    if (s[i] == '1') ans++;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
n,K = map(int,input().split())
use = [0,1,2,3,4,5,6,7,8,9]
useless = list(map(int,input().split()))
for i in range(K):
  use.remove(useless[i])
k = 10 - K
time = [0]
def suc(time):
  now = 0
  while True:
    if now >= len(time):
      time.append(0)
      break
    elif time[now] != k-1:
      time[now] += 1
      break
    else:
      time[now] = 0
      now += 1
  return time
#print(suc([0]))
#print(suc([1,1,1,1]))
#print(suc([1,0,1,1]))
while True:
  pay = 0
  for j in range(len(time)):
    pay += use[time[j]] * 10 ** j
  if pay >= n:
    print(pay)
    break
  time = suc(time)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
#include <unordered_map>
std::vector<std::vector<int>> connection;
std::vector<int> p;
void calc(int node, int add, int parent){
	p[node] += add;
	for(int i=0;i<connection[node].size();i++){
		if(connection[node][i] != parent){
			calc(connection[node][i], p[node], node);
		}
	}
}
int main(void){
	int n, q;
	std::cin >> n >> q;
	connection.resize(n);
	for(int i=0;i<n-1;i++){
		int a, b;
		std::cin >> a >> b;
		a--;
		b--;
		connection[a].push_back(b);
		connection[b].push_back(a);
	}
	p.resize(n);
	for(int i=0;i<n;i++)p[i] = 0;
	for(int i=0;i<q;i++){
		int x, y;
		std::cin >> x >> y;
		p[x-1] += y; 
	}
	calc(0, 0, -1);
	std::cout << p[0];
	for(int i=1;i<n;i++){
		std::cout << " " << p[i];
	}
	std::cout << std::endl;
}

Measured memory_bytes: 23424
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt();
		int t[][] = new int[n][2];
		for(int i=0;i<n;i++) {
			int a = fs.nextInt(), b = fs.nextInt();
			t[i][0] = a; t[i][1] = b;
		}
		
		Arrays.sort(t, (t1,t2)->t1[0]-t2[0]);
		long ans = 0;
		for(int i=0;i<n;i++) {
			int a = t[i][0], b = t[i][1];
			if(m>b) {
				ans += (long)b * a;
				m -= b;
			}
			else {
				ans += (long)m * a;
				break;
			}
		}
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 45700
//  299143BT
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define pi 3.1415926535
#define fi first
#define se second
#define vll vector<ll>
#define vpll vector<pair <ll,ll> >AC
#define vvll vector< vll >
#define str string
#define umap unordered_map
#define uset unordered_set
#define rep(i,n) for(ll i=0;i<n;i++)
#define repA(i,s,n) for(ll i=s;i<=n;i++)
#define repD(i,s,n) for(ll i=s;i>=n;i--)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define elif else if
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ALL(v) v.begin(),v.end()
#define sortA(v) sort(ALL(v))
#define sortD(v) sort(ALL(v),greater <ll> ())
#define print(v) for(auto itr:v) cout<<*itr<<" ";
#define sz size()
#define nl cout<<"\n";
using namespace std;
ll factorial(ll n){return (n==1||n==0)?1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll powerMod(ll x,ll y,ll m){if(y==0)return 1;ll p=powerMod(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll modInverse(ll a,ll m){return powerMod(a,m-2,m);}
ll gcd(ll a,ll b){if(a==0){return b;}else if(b==0){return a;}else{if(a>b){return gcd(a%b,b);}else{return gcd(b%a,a);}}}

bool visited[1000006]={false};
vector < int > v[1000006];
int nog=0,curr=0,x=0;


void edge(int a,int b){
    v[a].pb(b);
    v[b].pb(a);
}

void dfs(int a){
    if(visited[a]) return;
    visited[a]=true;
    curr++;
    for(auto itr:v[a]){
        dfs(itr);
    }
}

void pre(){

}

void solve(){
    int n=0,m=0;
    cin>>n>>m;
    int ans=0;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        edge(a,b);
    }
    repA(i,1,n){
        dfs(i);
        ans=max(ans,curr);
        curr=0;
    }
    cout<<ans;
}

int main(){

    pre();
    solve();
    return 0;
}


Measured memory_bytes: 39712
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int r,d,x;
    cin >> r >> d >> x;
    rep(i,10){
        x = x*r-d;
        cout << x << endl;
    }
}

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

using namespace std;

int main()
{
    int ans=0,maxx=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int tmp;
        cin>>tmp;
        if(maxx<=tmp)
        {
            ans++;
            maxx=tmp;
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	const int mod = 1e9 + 7;
	int n; cin >> n;
	vector<ll> a(n), cnt(60);
	ll ans = 0;
	rep(i, n){
		cin >> a[i];
		rep(j, 60) if(a[i] >> j & 1) cnt[j]++;
	}
	rep(i, n){
		rep(j, 60){
			if(a[i] >> j & 1) cnt[j]--;
			if(a[i] >> j & 1) ans += (1ll << j) % mod * (n - 1 - i - cnt[j]) % mod;
			else ans += (1ll << j) % mod * cnt[j] % mod;
		}
	}
	cout << ans % mod << endl;
	
	return 0;
}

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

int gcd(int a, int b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b, a % b);
  }
}

int main(){
  int n; 
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  vector<int> left(n+1, 0), right(n+1, 0);
  for(int i = 0; i < n; i++){
    left[i+1] = gcd(left[i], a[i]);
  }
  for(int i = n - 1; i >=0; i--){
    right[i] = gcd(a[i], right[i+1]);
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans = max(ans, gcd(left[i], right[i+1]));
  }
  cout << ans << endl;
}

  
  

Measured memory_bytes: 1408
#include <iostream>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

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

    set <int> froma, fromb, is;
    for (int i=ceil(a / 0.08); i < ceil((a+1) / 0.08); ++i) {
        froma.insert(i);
    }
    for (int i=ceil(b / 0.10); i < ceil((b+1) / 0.10); ++i) {
        fromb.insert(i);
    }
    set_intersection(froma.begin(), froma.end(), fromb.begin(), fromb.end(), inserter(is, is.end()));

    int ans;
    ans = *is.begin();
    if (ans == 0) ans = -1;
    cout << ans << endl;

    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  int max_height = 0;
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    if(max_height > A[i]) {
      ans += max_height - A[i];
    }
    else {
      max_height = A[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4048
s = raw_input()

ok = True
if s[0] != "A":
    ok = False
cnt = 0
for i in s[2:-1]:
    cnt += int(i == "C")
if cnt != 1:
    ok = False
for i in s:
    if i != "C" and i != "A" and i.isupper():
        ok = False
if ok:
    print "AC"
else:
    print "WA"


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

typedef long long ll;

typedef pair<ll, ll>P;
typedef pair<P, P>PP;


ll dy[5] = {0, 1, 0, -1, 0};
ll dx[5] = {1, 0, -1, 0, 0};
ll change[5][5] = {
    {0, 1, 2, 3, 4},
    {1, 2, 3, 0, 4},
    {2, 3, 0, 1, 4},
    {3, 0, 1, 2, 4},
    {4, 4, 4, 4, 4}
};

ll mp[33][33];
ll mn[33][33][5];
ll c[5];
void init(){
    for(ll y = 0; y < 33; y++){
        for(ll x = 0; x < 33; x++){
            mp[y][x] = -1;
            for(ll i = 0; i < 5; i++){
                mn[y][x][i] = -1145141919;
            }
        }
    }

}

int main(){
    
    for(ll w, h; cin >> w >> h, w;){
        init();
        for(ll y = 1; y <= h; y++){
            for(ll x = 1; x <= w; x++){
                cin >> mp[y][x];
                for(ll i = 0; i < 5; i++){
                    mn[y][x][i] = 1145141919;
                }
            }
        }
        for(ll i = 0; i < 4; i++)cin >> c[i];
        priority_queue<PP, vector<PP>, greater<PP> >Q;
        Q.push(PP(P(0, 1), P(1, 0)));
        while(!Q.empty()){
            ll cost = Q.top().first.first;
            ll x = Q.top().first.second;
            ll y = Q.top().second.first;
            ll d = Q.top().second.second;
            Q.pop();
            if(mp[y][x] == -1)continue;
            if(mn[y][x][d] <= cost)continue;
            mn[y][x][d] = cost;            
            if(y == h && x == w){
                cout << cost << endl;
                break;
            }
            for(ll i = 0; i < 4; i++){
                ll nxtC = cost;
                if(mp[y][x] != i)nxtC += c[i];
                ll dd = change[d][i];
                ll yy = y + dy[dd];
                ll xx = x + dx[dd];
                if(mn[yy][xx][dd] > nxtC){
                    Q.push(PP(P(nxtC, xx), P(yy, dd)));
                }
            }
        }
    }
    
    return 0;    
}


Measured memory_bytes: 3280
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0&&c>0){
    c=c-b;
    if(c<=0){
      cout<<"Yes";
      break;
    }
    a=a-d;
    if(a<=0){
      cout<<"No";
      break;
    }
  }

 return 0;
}


Measured memory_bytes: 3108
N = int(input())
H = list(map(int, input().split()))
for i in range(N-1):
    if H[i] <= H[i+1]:
        continue
    elif H[i] <= H[i+1]+1:
        H[i+1] += 1
        continue
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 15020
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
#define Pi 3.14159265358979;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i = 0, j = 0;//ループ用配列

	int n;
	int a[200] = {};

	int ans = 0;


	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}

	while(1){
		rep(i, n) {
			if (a[i] % 2 == 1) {
				cout << ans << "\n";
				return 0;
			}
			else {
				a[i] = a[i] / 2;
			}
		}
		
		ans++;

	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int a[105],b[105];
int n;
signed main(){
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	for(int i=0;i+3<=n;i++)
		if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
			cout<<"Yes";
			re 0;
		}
	cout<<"No";
	re 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(K);
    vector<pair<int, int>> point;
    map<int, int> xmap;
    map<int, int> ymap;
    REP(i, N){
        scanInt(xi);
        scanInt(yi);
        point.emplace_back(xi, yi);
        xmap.emplace(xi, i);
        ymap.emplace(yi, i);
    }
    ll result = LLONG_MAX;
    for (auto xit = xmap.begin(); xit != xmap.end(); ++xit){
        auto xl = xit->first;
        auto xit2 = xit;
        advance(xit2, K - 1);
        for (; xit2 != xmap.end(); ++xit2){
            auto xr = xit2->first;
            for (auto yit = ymap.begin(); yit != ymap.end(); ++yit){
                auto yl = yit->first;
                auto yit2 = yit;
                advance(yit2, K - 1);
                for (; yit2 != ymap.end(); ++yit2){
                    auto yr = yit2->first;
                    int count = 0;
                    REP(i, N){
                        auto x = point[i].first;
                        auto y = point[i].second;
                        if (xl <= x && x <= xr && yl <= y && y <= yr) ++count;
                    }
                    if (K <= count){
                        result = min(result, static_cast<ll>(xr - xl) * (yr - yl));
                    }
                }
            }
        }
    }
    printf("%lld\n", result);
}


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

struct UnionFind{
  vector< int > data;
  UnionFind(int sz){
    data.resize(sz, -1);
  }
  int Find(int a){
    return(data[a] < 0 ? a : data[a] = Find(data[a]));
  }
  void Union(int a, int b){
    a = Find(a), b = Find(b);
    if(a == b) return;
    if(data[a] < data[b]) swap( a, b);
    data[b] += data[a];
    data[a] = b;
  }
};

struct edge {
  int to, cost;
};
struct edge2 {
  int u, v, cost;
  bool operator<(const edge2& e) const {
    return cost < e.cost;
  }
};
typedef vector< vector< edge > > Graph;
typedef pair< int, int > Pi;
const int INF = 1 << 30;
int N, M, K, Q, F[100000];
Graph graph;
vector< edge2 > weighted;
set< int > buffer[100000];
int ret[100000];

void Dijkstra(Graph& g, vector< int >& min_cost){
  min_cost.assign( g.size(), INF);
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  for(int i = 0; i < K; i++){
    que.push( make_pair( 0, F[i]));
    min_cost[F[i]] = 0;
  }
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(p.first > min_cost[p.second]) continue;
    for(int i = 0; i < g[p.second].size(); i++){
      edge& e = g[p.second][i];
      if(p.first + e.cost >= min_cost[e.to]) continue;
      que.push( make_pair( p.first + e.cost, e.to));
      min_cost[e.to] = p.first + e.cost;
    }
  }
}


int main(){
  scanf("%d %d %d %d", &N, &M, &K, &Q);
  graph.resize(N);
  UnionFind uftree(N);

  for(int i = 0; i < M; i++){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    --a, --b;
    graph[a].push_back((edge){b, c});
    graph[b].push_back((edge){a, c});
    weighted.push_back((edge2){a, b});
  }

  for(int i = 0; i < K; i++){
    scanf("%d", &F[i]);
    --F[i];
  }
  for(int i = 0; i < Q; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;
    buffer[a].insert(i);
    buffer[b].insert(i);
  }

  vector< int > min_cost;
  Dijkstra( graph, min_cost);
  
  for(int i = 0; i < M; i++){
    weighted[i].cost = min( min_cost[weighted[i].u], min_cost[weighted[i].v]);
  }
  sort( weighted.rbegin(), weighted.rend());

  for(int i = 0; i < M; i++){
    int u = uftree.Find(weighted[i].u), v = uftree.Find(weighted[i].v);
    if(u == v) continue;
    uftree.Union( u, v);
    int unioned = uftree.Find(weighted[i].u);
    set< int > *oo = &buffer[u], *pp = &buffer[v];
    if(u != unioned) swap( oo, pp);
    for(set< int >::iterator it = pp -> begin(); it != pp -> end(); it++){
      if(oo -> find(*it) != oo -> end()) ret[*it] = weighted[i].cost;
      else oo -> insert(*it);
    }
  }
  
  for(int i = 0; i < Q; i++){
    printf("%d\n", ret[i]);
  }
}

Measured memory_bytes: 58532
# D
n = int(input())
tree = [[] for _ in range(n)]

for i in range(n - 1):
    u, v, w = map(int, input().split())
    tree[u - 1] += [(v - 1, w % 2)]
    tree[v - 1] += [(u - 1, w % 2)]
# print(tree)

# 白:0 黒:1 未定:-1
color = [-1] * n
q = [(0, 0)]

while q:  # qが存在する間
    a, b = q.pop()
    color[a] = b  # a番目をb色に染める
    for c, d in tree[a]:
        if color[c] == -1:  # 行き先が捜索済みでない
            q += [(c, b ^ d)] #(行き先ｃ ,和が奇数の時１ 偶数 0)
print(*color, sep='\n')


Measured memory_bytes: 37228
#include <iostream>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <string>

using namespace std;
int main()
{
	int n;
	cin >> n;
	int m = n * 3;
	long long a[m];
	for(int i = 0; i < m; i++){
		cin >> a[i];
	}
	sort(a, a+m);

	long long ans = 0;
	for(int i = 0; i < n; i++){
		ans += a[m-i*2-2];
	}
	cout << ans << endl;
}




Measured memory_bytes: 2560
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

int main(){
  // int N,M;
  string s;
  cin >> s ;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int a; cin >> a;
    string s; cin >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n, fa[100005], dep[100005];
map<ll, pair<int, int> > st;
vector<pair<int, int> > edge;
vector<int> seq;

int main()
{
	read(n);
	for(int i=1; i<=n; i++)
	{
		ll d;
		read(d);
		st.insert(make_pair(d, make_pair(1, i)));
	}
	for(int i=1; i<n; i++)
	{
		auto x = *st.rbegin();
		seq.push_back(x.second.second);
		st.erase(--st.end());
		ll y = x.first-(n-x.second.first)+x.second.first;
		auto it = st.find(y);
		if(it == st.end()) {printf("-1\n"); return 0;}
		else
		{
			it->second.first += x.second.first;
			fa[x.second.second] = it->second.second;
			edge.emplace_back(x.second.second, it->second.second);
		}
	}
	ll sum = 0;
	for(int i=seq.size()-1; i>=0; i--) dep[seq[i]] = dep[fa[seq[i]]]+1, sum += dep[seq[i]];
	if(sum != st.begin()->first) puts("-1");
	else for(auto i : edge) printf("%d %d\n", i.first, i.second);
	return 0;
}


Measured memory_bytes: 9840
n, m = gets.split.map &:to_i
h = gets.split.map { |s| [true, s.to_i] }
count = n

m.times do
  a, b = gets.split.map &:to_i
  c, d = h[a-1], h[b-1]
  if c[1] < d[1]
    count -= 1 if c[0]
    c[0] = false
  elsif c[1] > d[1]
    count -= 1 if d[0]
    d[0] = false
  else
    count -= 1 if c[0]
    count -= 1 if d[0]
    c[0] = d[0] = false
  end
end

p count

Measured memory_bytes: 30952
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long x){
    for(int cnt = 0; cnt < x; ++cnt){
        int diff = x - 100 * cnt;
        if(diff < 0)
            break;
        if(diff <= 5 * cnt) {
            cout << 1 << endl;
            return;
        }
    }
    cout << 0 << endl;
}


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


Measured memory_bytes: 256
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


n = inint()
X = inintl()

X_sorted = sorted(X)

a, b = X_sorted[n//2-1],X_sorted[n//2]

for x in X:
    if x <= a:
        print(b)
    else:
        print(a)


Measured memory_bytes: 30888
#abc114 c-755
k=input()
n=int(k)

x=['7','5','3']
m=0
def dfs(i,s):
    ans=0
    if i==m:
        if int(s)<=n and x[0] in s and x[1] in s and x[2] in s:
            return 1
        else:
            return 0
    ans+=dfs(i+1,s+x[0])
    ans+=dfs(i+1,s+x[1])
    ans+=dfs(i+1,s+x[2])
    return ans
ans=0
for l in range(3,len(k)+1):
    m=l
    ans+=dfs(0,'')
print(ans)

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

#define ntest 0

using namespace std;

map<string,int> cnt;
string verdict[] = {"AC", "WA", "TLE", "RE"};
int n;
string s;
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> s;
        cnt[s]++;
    }
    for (int i = 0; i < 4; ++i) {
        cout << verdict[i] << " x " << cnt[verdict[i]] << '\n';
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	switch N % 10 {
	case 2, 4, 5, 7, 9:
		fmt.Println("hon")
	case 0, 1, 6, 8:
		fmt.Println("pon")
	default:
		fmt.Println("bon")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

using namespace std;

typedef long long ll;
typedef long double ld;


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

    int n;
    cin >> n;
    ll sol = 0;
    n--;
    for (int a = 1; a <= n; a++)
    {
        sol += n / a;
    }
    cout << sol << "\n";
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:
const ll inf=1LL<<50;

// Description: ??°??????????????????
using edge=struct{int to;ll cost;};
using G=vector<vector<edge>>;

void add_edge(G &graph,int from,int to,ll cost){
	graph[from].push_back({to,cost});
}

// Description: ????????????????????°?????????????????????????§???????????????? 
// TimeComplexity: $\mathcal{O}(E\log V)$
// Verifyed: AOJ GRL_1_B

bool negative_cycle=false;
template <typename W> auto bellman_ford(const G &graph,int s,W inf){
	int n=graph.size(),update;
	vector<W> dist(n,inf);dist[s]=0;

	rep(loop,n){
		update=false;
		rep(v,n) if(dist[v]!=inf) for(auto &e:graph[v]){
			if(chmin(dist[e.to],dist[v]+e.cost))
				update=true;
		}
		if(!update) break;
	}

	negative_cycle=update;
	return dist;
}

int main(void){
	int n,m,s;
	cin >> n >> m >> s;
	G graph(n);

	rep(i,m){
		int a,b; ll c;
		cin >> a >> b >> c;
		add_edge(graph,a,b,c);
	}

	auto dist=bellman_ford<ll>(graph,s,inf);

	if(negative_cycle){
		cout << "NEGATIVE CYCLE" << endl;
	}else{
		rep(i,n){
			if(dist[i]==inf)
				cout << "INF" << endl;
			else
				cout << dist[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3228
h1, m1, h2, m2, k = map(int, input().split())

a = m2 - m1
if a < 0:
    mm = (h2 - h1 - 1) * 60 + (60 + a)
else:
    mm = (h2 - h1) * 60 + a


print(0 if mm - k <= 0 else mm - k)


Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//vector<ll> vll;


int main(void)
{
    //double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    //string s,s1,s2;
    //char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>a1>>a2>>n;
    if(a2>n)
        cout<<(a1*n/a2);
    else
        cout<<(a1*min(a2-1,n)/a2);
    return 0;
}





Measured memory_bytes: 3564
#include <stdio.h>
#define MAX 100

void dfs(int,int *,int *,int);

int f[MAX],d[MAX],Ad[MAX][MAX];

int main(){
  int n,i,j,u,k,v,visit,seacher[MAX];
  
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++) Ad[i][j] = 0;
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0;j < k;j++){
      scanf("%d",&v);
      Ad[u][--v] = 1;
    }
  }

  for(i = 0;i < n;i++) seacher[i] = 0;
  visit = 0;
  for(i = 0;i < n;i++) if(seacher[i] == 0) dfs(i,seacher,&visit,n);
  for(i = 0;i < n;i++) printf("%d %d %d\n",i + 1,d[i],f[i]);

  return 0;
}

void dfs(int i,int * seacher,int * visit,int n){
  int j;

  seacher[i] = 1;
  d[i] = ++*visit;
  for(j = 0;j < n;j++){
    if(Ad[i][j] == 0) continue;
    if(seacher[j] == 0) dfs(j,seacher,visit,n);
  }
  seacher[i] = 2;
  f[i] = ++*visit;
  
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
struct Gragh {
    ll N;
    vector<vl> G;
    vl visited;

    Gragh(ll n) {
        N = n;
        G.resize(N);
        resetv();
    }

    void add(ll a, ll b) { G[a].push_back(b); }

    void resetv(void) { visited = vl(N, 0); }

    //重さ無し
    void dfs(ll x) {
        visited[x] = 1;
        for (ll i : G[x]) {
            if (visited[i] == 0) {
                dfs(i);
            }
        }
    }
};
int main() {
    cin >> n >> m;
    Gragh G(2 * n);
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        G.add(a * 2, b * 2 + 1);
        G.add(b * 2, a * 2 + 1);
        G.add(a * 2+1, b * 2);
        G.add(b * 2+1, a * 2);
    }
    
    G.dfs(0);
    vl dp(2, 0);
    rep(i, n * 2) {
        if (G.visited[i] == 1)dp[i % 2]++;
    }

    
    x=dp[0];
    y=dp[1];
    k=x+y-n;
    ans=k*(n-k)+k*(k-1)/2+(x-k)*(y-k)-m;

    cout << ans << endl;
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a;
    cin >> a;
    
    cout << "ABC" << a << endl;
    

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int R,G;
    cin>>R>>G;
    cout<<2*G-R<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, A, B; cin >> n >> A >> B;
	string s; cin >> s;

	ll a = 0, b = 0;
	REP(i, s.size()) {
		if (s[i] == 'a') {
			if (a + b < A + B) {
				cout << "Yes" << endl;
				a++;
			} else {
				cout << "No" << endl;
			}
		} else if(s[i] == 'b') {
			if (a + b < A + B && b < B) {
				cout << "Yes" << endl;
				b++;
			} else {
				cout << "No" << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 848
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int r, d, x;
  cin >> r >> d >> x;
  for(int i = 0; i < 10; i++) {
    x = r*x-d;
    cout << x << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


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

int main() {
    int N, M, K;

    cin >> N >> M >> K;

    int A[N];
    int B[M];
    long long A_SUM[N+1];
    long long B_SUM[M+1];
    int k = 0;
    int ans = 0;

    A_SUM[0] = 0;
    B_SUM[0] = 0;

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

    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }

    for (int i = 1; i <= N; i++) {
        A_SUM[i] = A_SUM[i - 1] + A[i - 1];
    }

    for (int i = 1; i <= M; i++) {
        B_SUM[i] = B_SUM[i - 1] + B[i - 1];
    }

    int j = M;

    for (int i = 0; i <= N; i++) {
        if (A_SUM[i] > K) {
            break;
        }

        while (K < A_SUM[i] + B_SUM[j]) {
            j--;
        }

        ans = max(ans, i + j);
    }

   cout << ans << endl;

}


Measured memory_bytes: 8284
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	long long temp;
	if(b-1<=c) temp=b-1;
	else temp=c;
	long long ans;
	ans=(long long)((double)a*temp/b)-a*(long long)((double)temp/b);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
def b_fusing_slimes(MOD=10**9 + 7):
    from math import factorial
    N = int(input())
    X = [int(i) for i in input().split()]

    diff = [0] + [X[i + 1] - X[i] for i in range(N - 1)]
    cumsum = [0]
    for j in range(1, N):
        cumsum.append((cumsum[-1] + pow(j, MOD - 2, MOD)) % MOD)

    ans = sum([(diff[i] * cumsum[i]) % MOD for i in range(1, N)]) % MOD
    return (ans * factorial(N - 1)) % MOD

print(b_fusing_slimes())

Measured memory_bytes: 18988
n = int(input())
a = list(map(int, input().split()))

dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    dp[i][i]=0

for l in range(1,n+1):
    for i in range(n+1):
        j=i+l
        if j>n:
            continue

        if (n-l)%2==0: # sente

            dp[i][j]= max(a[j-1]+dp[i][j-1],a[i]+dp[i+1][j])

        else: # gote
            dp[i][j]= min(-a[j-1]+dp[i][j-1],-a[i]+dp[i+1][j])

print(dp[0][n])

Measured memory_bytes: 119900
L, R = map(int, input().split())

mod = 2019
min_num = float("inf")

tmp_L = L

while tmp_L < R and tmp_L <= L + 2019:
    tmp_R = tmp_L + 1

    while tmp_R <= R and tmp_R <= tmp_L + 2019:
        min_num = min((tmp_L*tmp_R)%mod ,min_num)
        tmp_R += 1
    tmp_L = tmp_L + 1

print(min_num)

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; ll H; cin >> N >> H ;
  vector<Pl> ab(2*N);
  rep(i,N){
    ll a,b; cin >> a >> b ;
    ab[2*i] = Pl(a,0);
    ab[2*i+1] = Pl(b,1);
  }
  sort(ALL(ab));
  reverse(ALL(ab));
  int ans;
  rep(i,2*N){
    ll damage,flg;
    tie(damage,flg) = ab[i];
    if(flg==0LL){
      ans = i + (H+damage-1)/damage;
      break;
    }else{
      H -= damage;
      if(H<=0){
        ans = i+1; break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    int ans = 0;
    int tmp_a;
    rep(i, n) {
        cin >> tmp_a;
        int num = 1;
        while(1) {
            if ( num > d ) break;
            ++ans;
            num += tmp_a;
        }
    }
    cout << ans + x << endl;
    return 0;
}


Measured memory_bytes: 256