akhauriyash/Code-Regression huggingface dataset:
// WIP

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
template<typename T> struct is_container {
template<typename C> static char test(typename C::const_iterator*); template<typename> static int test(...);
static bool const value = sizeof(test<T>(nullptr)) == sizeof(char) && !std::is_same<std::string, T>::value;
};
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
istream& operator>>(istream& i, T& x) { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#ifndef DEBUG
#define DEBUG 0
#endif
#define dbg(X) do { if (DEBUG) { cout << #X ": " << (X) << endl << flush; } } while (0)
#define dbg2(X) do { if (DEBUG) { cout << #X ":" << endl; for (auto& __x : (X)) { cout << __x << endl << flush; } } } while (0)
#define dbgv(...) do { if (DEBUG) { cout << "(" #__VA_ARGS__ "): " << make_tuple(__VA_ARGS__) << endl << flush; } } while (0)
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
ostream& operator<<(ostream& o, const T& x) { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  ll x; // [101, 10^18]
  cin >> x;

  // NOTE: 1.01^1000 ~ 20000
  int k = 0;
  ll y = 100;
  while (y < x) {
    y += y / 100;
    k++;
  }
  cout << k << endl;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  mainCase();
  return 0;
}

/*
python misc/run.py atcoder/abc165/b/main.cpp --check

%%%% begin
1000000000000000000
%%%%
3760
%%%% end
*/


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,d;
    int i,j,k;
    int x,y,z;
    char A,B,C;
    int h;
    char p,q,m,n;
    while(scanf("%c%c%c%c",&p,&q,&m,&n)!=EOF)
    {
        getchar();
        a=(int)p-'0';
        b=(int)q-'0';
        c=(int)m-'0';
        d=(int)n-'0';

        for(h=0,i=0;i<2;++i)
        {
            if(i==0)
            {
                x=a+b;
                A='+';
            }
            else
            {
                x=a-b;
                A='-';
            }
            for(j=0;j<2;++j)
            {
                if(j==0)
                {
                    y=x+c;
                    B='+';
                }
                else
                {
                    y=x-c;
                    B='-';
                }
                for(k=0;k<2;++k)
                {
                    if(k==0)
                    {
                        z=y+d;
                        C='+';
                    }
                    else
                    {
                        z=y-d;
                        C='-';
                    }
                    if(z==7)
                    {
                        printf("%d%c%d%c%d%c%d=7\n",a,A,b,B,c,C,d);
                        h=1;break;
                    }
                }
                if(h==1) break;
            }
            if(h==1) break;
        }
    }
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
 
int main()
{
  int a=0,b=0,n;
  string A,B;
 
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A>>B;
    if(A==B){
      a++;
      b++;
    }
    else if(A>B)a+=3;
    else b+=3;
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}

Measured memory_bytes: 3176
//
// Created by Naman Bhalla on 2019-08-18.
//

#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);


    int a;
    string s;
    cin >> a >> s;

    if(a >= 3200){
        cout << s << "\n";
    } else {
        cout << "red" << "\n";
    }

    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 N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int s;
    cin>>s;
    map<int,int>m;
    int a,tmp;
    a=s;
    int ans=0;
    bool f=true;
    while(f){
        m[a]++;
        ans++;
        if(m[a]>1){
            false;
            break;
        }else{
            tmp=a;
            if(a%2==0){
                a=a/2;
            }else{
                a=a*3+1;
            }
        }
    }OUT(ans);
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();

    println!("{}", (0..(s.len())).fold(0 as u64, |a, i| if s[i] != t[i] { a + 1 } else { a }));
}


Measured memory_bytes: 3940
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define  MN                           INT_MIN
#define  MX                           INT_MAX
#define int	long long
const int nmax = 100001; 

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int dp[110000];
int32_t main()
{
	int n,w;
	cin >> n >> w;
	int price[n],weight[n];
	for(int i = 0;i<n;i++)
		cin >> weight[i] >> price[i];
	for(int i = 0;i<n;i++)
	{
		for(int j = w;j>=0;j--){
			//cout << j + weight[i] << endl;
			if(j+weight[i] <= w){
				dp[j+weight[i]] = max(dp[j+weight[i]],dp[j]+price[i]);
			}
		}
	}
	int ans=0;
	for(int i = 0;i<=w;i++)
		ans = max(ans,dp[i]);
	cout << ans << endl;
}
	

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	int H[100001];
	for (int i = 0; i < n; ++i)
	{
		cin >> H[i];
	}
	int ans = 1;
	int ma = 1;
	int now = H[0];
	for (int i = 1; i < n; ++i)
	{
		ans = (now >= H[i]?ans + 1:1);
		ma = max(ans, ma);
		now = H[i];
	}
	cout << ma - 1 << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
L = list(map(int, input().split()))

if N < 2:
    print(0)
    exit()

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        if L[i] == L[j]:
            continue

        for k in range(j + 1, N):
            if (L[i] != L[k]) and (L[j] != L[k]) and (L[i] + L[j] > L[k]) and (L[j] + L[k] > L[i]) and (
                    L[k] + L[i] > L[j]):
                cnt += 1

print(cnt)


Measured memory_bytes: 9204
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc[1000];
char ca,cb,cc,cd[1000][1000];
vector<int> va,vb,vc;


int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>aa[i]>>ab[i];
    }
    a=aa[0];
    b=ab[0];
    
    for(int i=1;i<n;i++){
        while(true){
            if(a%aa[i]==0 and a/aa[i]*ab[i]>=b){
                b=a/aa[i]*ab[i];
                break;
            }
            if(b%ab[i]==0 and b/ab[i]*aa[i]>=a){
                a=b/ab[i]*aa[i];
                break;
            }
            a++;
            b++;
        }
        
        
    }
    C a+b E;
}

Measured memory_bytes: 2304
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define SORT(x) (sort(x.begin(),x.end()))
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) (reverse(x.begin(),x.end()))

struct RMQRUQ {
	int n;
	vector<int> dat, lazy;
 
	RMQRUQ(){}
	RMQRUQ(int n_) {
		n = 1; while(n < n_) n *= 2;
		dat.assign(n*2, INT_MAX);
		lazy.assign(n*2, INT_MAX);
	}
 
	void eval(int len, int k) {
		if(lazy[k] == INT_MAX) return;
		if(k*2+1 < n*2-1) {
			lazy[2*k+1] = lazy[k];
			lazy[2*k+2] = lazy[k];
		}
		dat[k] = lazy[k];
		lazy[k] = INT_MAX;
	}
 
  // [a, b)
	int update(int a, int b, int x, int k, int l, int r) {
		eval(r-l, k);
		if(b <= l || r <= a) return dat[k];
		if(a <= l && r <= b) {
			lazy[k] = x;
			return lazy[k];
		}
		return dat[k] = min(update(a, b, x, 2*k+1, l, (l+r)/2), update(a, b, x, 2*k+2, (l+r)/2, r));
	}
	int update(int a, int b, int x) { return update(a, b, x, 0, 0, n); }
	// [a, b)
	int query(int a, int b, int k, int l, int r) {
		eval(r-l, k);
		if(b <= l || r <= a) return INT_MAX;
		if(a <= l && r <= b) return dat[k];
		int vl = query(a, b, 2*k+1, l, (l+r)/2);
		int vr = query(a, b, 2*k+2, (l+r)/2, r);
		return min(vl, vr);
	}
	int query(int a, int b) { return query(a, b, 0, 0, n); }
};

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

	int N,Q;
	cin >> N >> Q;
	RMQRUQ tr(Q+8);
	tr.update(0,Q+7,-1);
	vector< pair<int, pair<int,int> > > xst(N);
	FOR(i,0,N){
		int s,t,x;
		cin >> s >> t >> x;
		xst[i] = {x,{s,t}};
	}
	vector<int> D(Q);
	FOR(i,0,Q){
		cin >> D[i];
	}
	D.push_back(INT_MAX);
	SORT(xst);
	REV(xst);
	FOR(i,0,N){
		int s_x = xst[i].second.first - xst[i].first;
		int t_x = xst[i].second.second - xst[i].first;
		int a = POSL(D,s_x);
		int b = POSU(D,t_x-1);
		tr.update(a,b,xst[i].first);
	}
	FOR(i,0,Q){
		cout << tr.query(i,i+1) << endl;
	}
}


Measured memory_bytes: 9200
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int mod = 1000000007;

long long pw(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1ll) {
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

int main() {
	long long a, b;
	cin >> a >> b;
	if (a == b) {
		puts("1");
		return 0;
	}

	long long l = 1ll << 60;
	while ((a & l) == (b & l)) {
		l >>= 1;
	}

	long long q = l - (a & (l - 1));
	long long k = l / 2;
	while (k > 0 && (b & k) == 0) {
		k >>= 1;
	}
	if (k == 0) {
		k = 1;
	} else {
		k *= 2;
	}

	cout << 2 * q + min(k, (a & (l - 1))) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;
    std::vector<std::string> cand { "maerd", "remaerd", "esare", "resare" };
    for (auto it = s.rbegin(); it != s.rend(); ) {
        auto jt = std::find_if(cand.begin(), cand.end(), [&](const auto &c) {
            return std::equal(c.begin(), c.end(), it);
        });
        if (jt == cand.end()) {
            std::cout << "NO" << std::endl;
            return 0;
        }
        it += jt->size();
    }

    std::cout << "YES" << std::endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	bool ok = false;
	rep(i,S.size()){
		if(S[i] == '7') ok = true;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3652
import sys
readline = sys.stdin.readline
from operator import itemgetter
class UnionFind:
    def __init__(self, n):
        self.p = list(range(n))
        self.rank = [0] * n
    def find_root(self, x):
        if x != self.p[x]:
            self.p[x] = self.find_root(self.p[x])
        return self.p[x]
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)
    def unite(self, x, y):
        u = self.find_root(x)
        v = self.find_root(y)
        if u == v: return
        if self.rank[u] < self.rank[v]:
            self.p[u] = v
        else:
            self.p[v] = u
            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1
n, m = map(int, readline().split())
edges = [tuple(map(int, readline().split())) for _ in [0] * m]
edges.sort(key=itemgetter(2), reverse=True)
uf = UnionFind(n)
ans = 0
for _ in [0] * (n - 1):
    while edges:
        s, t, w = edges.pop()
        if not uf.same(s, t):
            uf.unite(s, t)
            break
    ans += w
print(ans)

Measured memory_bytes: 26388
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int h,w,n,sr,sc;
    string s,t;
    cin>>h>>w>>n>>sr>>sc>>s>>t;
    int x=1;
    int xr=sr,xc=sc;
    rep(i,n){
        if(s[i]=='U') xr--;
        if(xr<=0||xr>h||xc<=0||xc>w) x=0;
        if(t[i]=='D'&&xr!=h) xr++;
    }
    xr=sr,xc=sc;
    rep(i,n){
        if(s[i]=='D') xr++;
        if(xr<=0||xr>h||xc<=0||xc>w) x=0;
        if(t[i]=='U'&&xr!=1) xr--;
    }
    xr=sr,xc=sc;
    rep(i,n){
        if(s[i]=='R') xc++;
        if(xr<=0||xr>h||xc<=0||xc>w) x=0;
        if(t[i]=='L'&&xc!=1) xc--;
    }
    xr=sr,xc=sc;
    rep(i,n){
        if(s[i]=='L') xc--;
        if(xr<=0||xr>h||xc<=0||xc>w) x=0;
        if(t[i]=='R'&&xc!=w) xc++;
    }
    if(x) cout<<"YES"<<"\n";
    else cout<<"NO"<<"\n";
}

Measured memory_bytes: 776
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    vector<int> ans(n, 0);
    for(int i=0; i<n-1; ++i){
        int c, s, f;
        cin >> c >> s >> f;
        for(int j=0; j<=i; ++j){
            ans[j] = max(ans[j], s);
            ans[j] = (ans[j] + f - 1) / f * f + c;
        }
    }

    for(int i=0; i<n; ++i)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> x(m),d(m-1);
  for(int i=0;i<m;i++){
    cin >> x[i];
  }
  if(n>=m){
    cout << 0 << endl;
  }
  else{
    sort(x.begin(),x.end());
    for(int i=0;i<m-1;i++){
      d[i]=abs(x[i+1]-x[i]);
    }
    sort(d.begin(),d.end());
    int ans=0;
    for(int i=0;i<m-n;i++){
      ans+=d[i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>

int main() {
    int a, b, c;    

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;

    for (int i = 0; i < b; i++) {
        if ( a*i % b == c ) {
            std::cout << "YES" << std::endl;
            return 0;
        }
    }

    std::cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;

int main() {
  int N;
  cin >> N;
  int min_val = N + 1;
  int res = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a < min_val) {
      min_val = a;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

#define INF 1e+9 //初期化注意
#define MAX_V 100000 //頂点数の最大値

struct edge {
	int to;
	int cost;
	//edge e ={to, cost}
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int N;// 頂点の数
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
	//sからiへの最短距離をd[i]に保存 i=e.to
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + N, INF);
	d[s] = 0;//初期位置へのコストは0

	que.push(P(0, s));
	//queはmake_pair(cost,to)?

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;//v=e.to	from s to v
		//すでにこの経路よりいい経路が見つかっているなら無視
		if (d[v] < p.first) continue;
		

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			// i 番目の v と v'を結ぶ辺　G=<e.to, e.cost>
			//e.to=v'
	                //e.cost means v to v' cost e.cost
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				//from s to v'> from s to v + from v to v'
				//vを経由したほうがコストが低いなら経由する
				que.push(P(d[e.to], e.to));
			}
		}
	}
}


	//dijkstra(int s); nからの最短距離を計算
	//d[i]はsからiまでの最短距離が保存される the path from s to i cost d[i]



void solve()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>>g(n);
	vector<int>dist(n,-1);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<int>que;
	que.push(0);
	dist[0]=0;
	vector<int>visited(n);
	while(que.size()){
		int now=que.front();
	//	cout<<now+1<<endl;
		que.pop();
		
		rep(i,size(g[now])){
			if(dist[g[now][i]]==-1){
				dist[g[now][i]]=dist[now]+1;
				que.push(g[now][i]);
			}
		}
	}
	map<int,int>ans;
	bool ok=true;
	
	rep(i,n){
		if(i){
			bool t=false;
			rep(j,size(g[i])){
				if(dist[i]-1==dist[g[i][j]]){
					ans[i]=g[i][j];
					t=true;
				}
			}
			if(!t){
				ok=false;
			}
		}
	}
	if(ok){
		cout<<"Yes"<<endl;
		rep(i,n){
			if(i){
				//cout<<dist[i]<<" ";
				cout<<ans[i]+1<<endl;
			}
		}
	}else{
		cout<<"No"<<endl;
	}

}

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


Measured memory_bytes: 17260
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,K; cin>>N>>K;
  string s; cin>>s;
  
  int cnt=1;
  for(int i=1;i<N;i++){
    if(s[i]!=s[i-1]) cnt++;
  }
  //cout<<cnt<<endl;
  cout<<min(N-1,N-cnt+2*K)<<endl;
  
  return 0;
}

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

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

    priority_queue<ll> a;
    for(int i=0; i<n; i++){
        ll ii;
        cin >> ii;
        a.push(ii);
    }

    for(int i=0; i<m; i++){
        ll top = a.top();
        top /= 2;
        a.pop();
        a.push(top);
    }

    ll ans = 0;
    for(int i=0; i<n; i++){
        ll tmp = a.top();
        a.pop();
        ans += tmp;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
A = [lr() for _ in range(H)]
answer = []
for i in range(H):
    for j in range(W-1):
        if A[i][j]&1:
            answer.append((i+1, j+1, i+1, j+2))
            A[i][j+1] += 1

for i in range(H-1):
    if A[i][-1]&1:
        answer.append((i+1, W, i+2, W))
        A[i+1][-1] += 1

print(len(answer))
print('\n'.join('{} {} {} {}'.format(a, b, c, d) for a, b, c, d in answer))


Measured memory_bytes: 35168
#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>>;


const int mod = 2019;

int main(){
    string s; cin >> s;
    int n = s.size();
    reverse(ALL(s));
    vector<int> sum(n+1);
    sum[0] = 0;
    int k = 1;
    for(int i = 0; i < n; i++){
        sum[i+1] = (sum[i] + (int)(s[i] - '0')*k) % mod;
        k *= 10;
        k %= mod;
    } 
    int cnt[2019] = {};
    rep(i,n+1) cnt[sum[i]]++;
    int ans = 0;
    rep(i,2019) ans += cnt[i]*(cnt[i]-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 4372
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

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();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_N = 100000;

int solve() {
    return 0;
}

std::string solve(int N, int Q, string& S, vector<int>& l, vector<int>& r) {
    vector<int> cumulativeSum(N);
    int sum = 0;
    char* prev = &S[0];

    REP(i,1,N) {
        if (*prev == 'A' && S[i] == 'C') {
            sum++;
        }
        cumulativeSum[i] = sum;
        prev = &S[i];
    }

    stringstream ss;

    REP(i,0,Q) {
        ss << cumulativeSum[r[i]-1] - cumulativeSum[l[i]-1] << "\n";
    }

    return ss.str();
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, Q;
    string S;

    cin >> N >> Q >> S;

    vector<int> l(Q), r(Q);

    REP(i,0,Q) cin >> l[i] >> r[i];

    cout << solve(N, Q, S, l, r);

    return 0;
}



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

int main(void){
    int hito[4][3][10]={},v,n,b, f, r;
    
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        hito[b-1][f-1][r-1]+=v;
    }
    
    for(b=0;b<4;b++){
        for(f=0;f<3;f++){
            for(r=0;r<10;r++){
                 cout << " " << hito[b][f][r];   
            }
            cout << endl;
        }
        if(b==3)break;
        cout << "####################" << endl;
    }
   
    
}



Measured memory_bytes: 3108
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0;
    int mx=0;
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        ans+=h;
        mx=max(mx,h);
    }
    ans=ans-(mx/2);
    cout<<ans<<endl;






return 0;
}

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

int main() {
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if (s[0]==s[1] && s[2]==s[3] && s[1] != s[2])
    cout << "Yes" << endl;
  else
    cout <<"No" << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <stdio.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<ll> vec(n);
    ll c=0;
    for(int i=0;i<n;i++){
        ll a,b;
        cin >> a >> b;
        vec[i]=a+b;
        c -= b;
    }
    sort(vec.begin(),vec.end(),greater<int>());
    if(n%2==0){
        for(int i=0;i<n/2;i++){
            c += vec[i*2];
        }
    }else{
        for(int i=0;i<n/2+1;i++){
            c += vec[i*2];
          //  cout<<vec[i]<<endl;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 1024
n = int(input())
m = 10**9+7
primes = [2,3,5,7,11,13,17,19,23,29,31]
D = [0]*1001

for i in range(2, n+1):
    for p in primes:
        while(i % p == 0):
            D[p] += 1
            i //= p
    if i > 1:
        D[i] += 1

score = 1
for d in D:
    score = (score * (d + 1)) % m
print(score)


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

#define ll long long
#define vl vector<ll>
#define fo(i,a,b) for(ll i=a; i<b; i++)

int main(){
    int N;
    string d[200000];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    set<string> values; // insert するときに重複を取り除いてくれます
    for (int i = 0; i < N; ++i) {
        values.insert(d[i]); // 挿入します
    }

    // set のサイズを出力します
    cout << values.size() << endl;
}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

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

int main(void){
	int counter=0;
	char ascii[27]={};
	string given;

	cin >> given;

	for(int i=0;i<4;i++){
		ascii[given[i]-'A']++;
	}
	
	for(int i=0;i<27;i++){
		if(ascii[i]==2){
			counter++;
		}
	}

	cout << (counter==2?"Yes":"No") << endl;

	return 0;
}


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

int main(){
  long n;
  long val[4];
  double amount[4]={0.25,0.5,1,2};
  for(int i=0;i<4;i++)
    cin >> val[i];
  cin >> n;
  long score;
  long min_score=-1;
  long remain;
  for(int i=0;i<4;i++){
    score = (long)(n/amount[i])*val[i];
    remain = n-(long)(n/amount[i])*amount[i];
    long tmp_score=-1;
    for(int j=0;j<4;j++){
      if(i==j) continue;
      long tmp = remain;
      if(tmp_score == -1) tmp_score = (long)(remain/amount[j])*val[j];
      else tmp_score = min(tmp_score,(long)(remain/amount[j])*val[j]);
    }
    if(min_score==-1) min_score = tmp_score+score;
    else min_score = min(min_score,tmp_score+score);
  }
  cout << min_score  << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int a[310][310], b[310][310];
int n;
int f[310][310];

void warshall_floyd(){
   rep(k, 0, n){
       rep(i, 0, n){
           rep(j, 0, n){
               if(i == k || j == k) continue;
               if(b[i][j] >= b[i][k] + b[k][j]){
                    b[i][j] = b[i][k] + b[k][j];
                    f[i][j] = 0;
               }
           }
       }
   }
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 0, n){
        rep(j, 0, n){
            cin >> a[i][j];
            b[i][j] = a[i][j];
            f[i][j] = 1;
        }
    }
    warshall_floyd();
    int ans = 0;
    rep(i, 0, n){
        rep(j, 0, n){
            if(a[i][j] != b[i][j]){
                cout << -1 << endl;
                return 0;
            }
            if(f[i][j]) ans += b[i][j];
        }
    }
    cout << ans / 2 << endl;
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    if(n == 1){
        P("Hello World");
    }else{
        int a,b;
        cin >> a >> b;
        P(a+b);
    }
}

int main() {
    solve();
    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(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<ll> c(n-1), s(n-1), f(n-1);
	rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
	rep(i,n) {
		ll time = 0;
		for (int j = i; j < n-1; j++) {
			if (time < s[j]) time = s[j];
			if (time % f[j] != 0) time += f[j] - time % f[j];
			time += c[j];
		}
		cout << time << endl;
	}
}

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

Measured memory_bytes: 3648
"""
メモ型再起？
ダイクストラじゃあきつそう
1sec!?

各点高々1回しか選ばれない工夫が必要
qにいれて少しづつ進めてく？
→各点高々4回しか選択されない
"""


H,W = map(int,input().split())

A = []
q = []

for i in range(H):

    a = list(input())
    A.append(a)

    for j in range(W):
        if a[j] == "#":
            q.append([i,j])

ans = 0
while len(q) > 0:

    #print (q)
    
    nq = []
    flag = False

    for i,j in q:
        if i > 0 and A[i-1][j] == ".":
            A[i-1][j] = "#"
            nq.append([i-1,j])
            flag = True
        if i < H-1 and A[i+1][j] == ".":
            A[i+1][j] = "#"
            nq.append([i+1,j])
            flag = True
        if j > 0 and A[i][j-1] == ".":
            A[i][j-1] = "#"
            nq.append([i,j-1])
            flag = True
        if j < W-1 and A[i][j+1] == ".":
            A[i][j+1] = "#"
            nq.append([i,j+1])
            flag = True
    q = nq
    if flag:
        ans += 1


print (ans)

Measured memory_bytes: 169840
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		double W=stdIn.nextDouble();
		double H=stdIn.nextDouble();
		int X=stdIn.nextInt();
		int Y=stdIn.nextInt();
		if(W%2==0&&H%2==0){
			if(W/2==X&&H/2==Y)
				System.out.println(W*H/2+" "+1);
			else
				System.out.println(W*H/2+" "+0);
		}
		else
			System.out.println(W*H/2+" "+0);
	}
}

Measured memory_bytes: 22228
N = int(input())
A = list(map(int, input().split()))

flag = True
counter = 0
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if A[i-1] > A[i]:
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            counter += 1

print(' '.join(map(str, A)))
print(counter)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
const long long mod = 1000000007 ;
const int N = 1000000;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define HelloFile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
ll n, rep[N], sz[N], cost = 0;
vector< pair<ll, pair<ll, ll> > > vx, vy;
map< ll, vector< pair<ll, ll> > > mp;
int findU(int u)
{
    return ( rep[u] == u )? u : rep[u] = findU(rep[u]);
}
bool join(int a, int b)
{
    a = findU(rep[a]);
    b = findU(rep[b]);
    if( a == b )
        return true;
    if( sz[a] < sz[b] )
        swap(a, b);
    sz[a] += sz[b];
    rep[b] = a;
    return false;
}
int main()
{
    Hello
    for(int i = 0; i <= 100005; i++)
        rep[i] = i;
    for(int i = 0; i <= 100005; i++)
        sz[i] = 1;
    cin >> n;
    for(int i = 0, x, y; i < n; i++)
    {
        cin >> x >> y;
        vx.push_back( {x, {y, i}} );
        vy.push_back( {y, {x, i}} );
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());
    for(int i = 0; i < vx.size() - 1; i++)
    {
        mp[ abs( vx[i].first - vx[i + 1].first ) ].push_back( {vx[i].second.second, vx[i + 1].second.second} );
        mp[ abs( vy[i].first - vy[i + 1].first ) ].push_back( {vy[i].second.second, vy[i + 1].second.second} );
    }
    map< ll, vector< pair<ll, ll> > > :: iterator it;
    for(it = mp.begin(); it != mp.end(); it++)
    {
        for(ll j = 0; j < (it->second).size(); j++)
        {
            if ( !join( (it->second)[j].first, (it->second)[j].second ) )
                cost += (it->first);
        }
    }
    cout << cost;
    return 0;
}


Measured memory_bytes: 18212
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
 
int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == s[i + 1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().strip().split()))
LIMIT = 10**18

z = False
for x in a:
    if x == 0:
        z = True

if z:
    print(0)
else:
    ans = 1
    for x in a:
        ans = ans * x
        if ans > LIMIT:
            break
    print(ans if ans <= LIMIT else -1)

Measured memory_bytes: 84644
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count=0
for i in range(N):
  fir=min(A[i],B[i])
  count+=fir
  sec=min(A[i+1], max(0,B[i]-fir))
  count+=sec
  A[i+1]-=sec
  
print(count)

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

main()
{
    int x; cin>>x;
    int n; cin>>n;
    bool app[111]={};
    for(int i=0; i<n; ++i)
    {
        int y; cin>>y;
        app[y]=1;
    }
    for(int i=x,j=x; ; i--,j++)
    {
        if(!app[i])
        {
            cout << i << "\n";
            return 0;
        }
        if(!app[j])
        {
            cout << j << "\n";
            return 0;
        }
    }

}

Measured memory_bytes: 3604
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools

mod = int(1e9+7)

def main():
    s = input()
    ans = 0
    for i in range(len(s)):
        if s[i] == '1':
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

bool isprime(ll n) {
  if (n == 1) return 0;
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) {
      return 0;
    }
  }
  return 1;
}

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

  ll x;
  cin >> x;

  while (1) {
    if (isprime(x)) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int x[5];
int main()
{
	memset(x,0,sizeof(x));
	int n,a;lint out=1,mo=1000000007;
	cin>>n;
	rep(i,n){
		cin>>a;
		int y=-1,z=0;
		rep(j,3){
			if(a==x[j]) y=j,z++;
		}
		//cout<<z<<endl;
		out*=z;out%=mo;
		if(y>=0) x[y]++;
	}
	cout<<out<<endl;
}


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

int main() {
  int N,M=0;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
    M=max(M,p.at(i));
  }
  int O=-1;
  cout<<M<<" ";
  for(int i=0;i<N;i++){
    if(abs(M-2*p.at(i))<abs(M-2*O)&&p.at(i)!=M){
      O=p.at(i);
    }
  }
  cout<<O<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
struct LIS {
    vector<int>& v;
    vector<int> dp, id, ret, info;
    // info 1:unused 2:使っても良い 3:必ず使う
    int n, lis;
    LIS(vector<int>& _v) : v(_v) {
        n = v.size();
        dp.resize(n, INT_MAX / 2);
        id.resize(n, 0);
        rep(i, 0, n) {
            // 狭義単調増加列
            //id[i] = lower_bound(dp.begin(), dp.end(), v[i]) - dp.begin();
            // 広義単調増加列
            id[i] = upper_bound(dp.begin(), dp.end(), v[i]) - dp.begin();
            dp[id[i]] = v[i];
        }
        int nl = *max_element(id.begin(), id.end());
        lis = nl;
        ret.resize(nl + 1, 0);
        rrep(i, n - 1, 0) if (id[i] == nl) ret[nl] = v[i], nl--;

        info.resize(n);
        vector<int> ma(n + 1), cnt(n);
        ma[lis] = INT_MAX / 2;
        rrep(i, n - 1, 0) {
            // 狭義単調増加列
            //if (ma[id[i] + 1] <= v[i]) info[i] = 1;
            // 広義単調増加列
            if (ma[id[i] + 1] < v[i]) info[i] = 1;

            else cnt[id[i]]++, ma[id[i]] = max(ma[id[i]], v[i]);
        }

        rrep(i, n - 1, 0) if (info[i] == 0 && cnt[id[i]] == 1) info[i] = 3;
        rep(i, 0, n) if (info[i] == 0) info[i] = 2;
    }
};

/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



double PI = 2 * acos(0.0);
typedef long long ll;
string A;
int X1, Y1, X2, Y2, N, X[201010], Y[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> X1 >> Y1 >> X2 >> Y2 >> N;
    rep(i, 0, N) cin >> X[i] >> Y[i];
    if (X1 > X2) {
        X1 = 100000000 - X1;
        X2 = 100000000 - X2;
        rep(i, 0, N) X[i] = 100000000 - X[i];
    }
    if (Y1 > Y2) {
        Y1 = 100000000 - Y1;
        Y2 = 100000000 - Y2;
        rep(i, 0, N) Y[i] = 100000000 - Y[i];
    }

    vector<pair<int, int>> v;
    rep(i, 0, N) if (Y1 <= Y[i] && Y[i] <= Y2 && X1 <= X[i] && X[i] <= X2) v.push_back({ X[i], Y[i] });
    sort(v.begin(), v.end());

    vector<int> vv;
    vv.push_back(-1);
    fore(p, v) vv.push_back(p.second);
    vv.push_back(INT_MAX / 2 - 1);
    LIS lis(vv);

    lis.lis--;
    //cout << lis.lis << endl;
    

    double ans = 100.0 * (X2 - X1 + Y2 - Y1);
    ans += (5.0 * PI - 20.0) * lis.lis;
    if (lis.lis == min(X2 - X1, Y2 - Y1) + 1) ans += 5.0 * PI;
    printf("%.15f\n", ans);
}

Measured memory_bytes: 9072
N, M = map(int, input().split())
A, B = [0] * N, [0] * N
for i in range(N):
	A[i], B[i] = map(int, input().split())

#  値段Aの昇順でソート
C = sorted(zip(A, B))
A, B = zip(*C)

ans, cnt, i = 0, 0, 0
while cnt < M:
	tmp = min(B[i], M - cnt)
	cnt += tmp
	ans += A[i] * tmp
	i += 1
print(ans)


Measured memory_bytes: 26852
#!/usr/bin/env python3


def main():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    min_cost = min(a) + min(b)
    for i in range(M):
        x, y, c = map(int, input().split())
        cost = a[x - 1] + b[y - 1] - c
        if min_cost > cost:
            min_cost = cost

    print(min_cost)


if __name__ == "__main__":
    main()


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

int main() {
  int n, t;
  cin >> n >> t;
  vector<tuple<int, int, int>>p;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    p.emplace_back(a, b, i + 1);
  }
  for (int i = 0; i < n; i++) {
    if (get<1>(p[i]) > t) get<0>(p[i]) = 10000;
  }
  int keep = 10000;
  int ans = keep;
  for (int i = 0; i < n; i++) {
    if (ans > get<0>(p[i])) {
      ans = get<0>(p[i]);
    }
  }
  if (ans == keep) cout << "TLE" << endl; 
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long a, b, c, d, e = 0, f;
	cin >> f;
	a = f / 1000;
	b = f % 1000 / 100;
	c = f % 100 / 10;
	d = f % 10;
	if (a + b + c + d == 7) {
		cout << a << '+' << b << '+' << c << '+' << d << '=' << '7' << endl;
		e++;
	}
	else if (a + b + c - d == 7) {
		if (e == 0) {
			cout << a << '+' << b << '+' << c << '-' << d << '=' << '7' << endl;
			e++;
		}
	}
	else if (a + b - c + d == 7) {
		if (e == 0) {
			cout << a << '+' << b << '-' << c << '+' << d << '=' << '7' << endl;
			e++;
		}
	}
	else if (a - b + c + d == 7) {
		if (e == 0) {
			cout << a << '-' << b << '+' << c << '+' << d << '=' << '7' << endl;
			e++;
		}
	}
	else if (a + b - c - d == 7) {
		if (e == 0) {
			cout << a << '+' << b << '-' << c << '-' << d << '=' << '7' << endl;
			e++;
		}
	}
	else if (a - b - c + d == 7) {
		if (e == 0) {
			cout << a << '-' << b << '-' << c << '+' << d << '=' << '7' << endl;
			e++;
		}
	}
	else if (a - b + c - d == 7) {
		if (e == 0) {
			cout << a << '-' << b << '+' << c << '-' << d << '=' << '7' << endl;
			e++;
		}
	}
	else if (a - b - c - d == 7) {
		if (e == 0) {
			cout << a << '-' << b << '-' << c << '-' << d << '=' << '7' << endl;
		}
	}
	cin >> e;
}

Measured memory_bytes: 256
from itertools import permutations

n=int(input())
lst=[list(map(int,input().split())) for _ in range(n)]

nc=n
sm=1
while nc>=1:
    sm*=nc
    nc-=1

dis=0

for x in permutations(range(n)):
    for i in range(n-1):
        dis+=((lst[x[i+1]][0]-lst[x[i]][0])**2+(lst[x[i+1]][1]-lst[x[i]][1])**2)**0.5

print(dis/sm)


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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n , k;
    cin >> n >> k;

    vector<int> a(n);
    for (int &x : a)
        cin >> x;

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

    int rem = max(0 , n - k);

    long long ans = 0;
    for (int i = 0; i < rem ;i++)
        ans += a[i];

    cout << ans;
}


Measured memory_bytes: 3944
/// Template by Zayed ///

///************************************************************///
/// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>

#include <string>
#include <cstring>
#include <sstream>

#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>

#include <algorithm>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>

#include <cmath>
#include <cstdlib>
#include <cctype>
#include <ctime>
///************************************************************///
using namespace std;
int caseno = 1;
///************************************************************///
#define NL '\n'
#define SF scanf
#define PF printf
#define PC() printf("Case %d: ", caseno++)//NOTES:printf
#define PC cout << "Case "//NOTES:cout
#define CN cout << caseno++ << ": "//NOTES:cout
#define CLR(ar) memset(ar, 0, sizeof(ar))
#define SET(ar) memset(ar, -1, sizeof(ar))
#define READ() freopen("in.txt", "r", stdin)
#define WRITE() freopen("out.txt", "w", stdout)
#define BOOST std::ios_base::sync_with_stdio(0);
#define FOR(I,J,K) for(I = J; I < K; I++)
#define REV(I,J,K) for(I = J; I > K; I--)
///************************************************************///
typedef long long LL;//NOTES:"%lld"
typedef unsigned long long ULL;//NOTES:"%llu"
typedef long long int64;//NOTES:int64
typedef unsigned long long uint64;//NOTES:uint64
///************************************************************///
#define INF (1 << 31) - 1
#define MOD 1000000007
#define pii pair<int, int>
#define pLL pair<LL, LL>
#define pis pair<int, string>
#define psi pair<string, int>
#define PI 2 * acos(0.0);
#define EPS 1e-11;
///************************************************************///
// Numeric Functions
// Translator Functions
///************************************************************///

/*
*******4 Direction Array*******
int dx[] = {0, 0, - 1, 1}, dy[] = {-1, 1, 0, 0};
*******8 Direction Array*******
int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};
********Knight Moves********
int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1};
*/

const int SIZE = 1e6;


int main()
{
	///BOOST
	int tcases, I, J, K, N, n, m, cnt = 0, len, X, Y, Z, k, S;
	///READ();
	///WRITE();
	cin >> k >> S;
	for(I = 0; I <= k; I++)
	{
		X = I;
		for(J = 0; J <= k; J++)
		{
			Y = J;

			if(X + Y <= S)
			{
				Z = S - (X + Y);
				if(Z <= k)
					cnt++;
			}

		}
	}

	cout << cnt << NL;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

int main()
{
    string s;
    cin >> s;

    ll ans = 0;
    for (ll i = 0; i < s.size(); i++)
    {
        if (s[i] == '+'){
            ans += 1;
        } else if (s[i] == '-'){
            ans -= 1;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int n, x;
  cin >> n >> x;
  int d = 0;
  int cnt = 1;
  
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    d += l;
    if(d > x) {
      break;
    }
    cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256