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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  ll n;cn(n)
  ll mx = 0;
  map<string,ll> m;
  rep(i,n){
    string st;cn(st)
    auto t = m.find(st);
    if (t==m.end()){
      m.insert({st,1});
      mx = max( mx, 1ll );
    }else{
      ++t->second;
      mx = max( mx, t->second );
    }
  }
  rpv(m){
    //co("#",v.first)
    if (v.second == mx){
      co(v.first)
    }
  }
}

Measured memory_bytes: 25216
a = [x for x in input().split()]
cnt_5 = 0
cnt_7 = 0
for x in a:
    if x == '5':
        cnt_5 += 1
    elif x == '7':
        cnt_7 += 1

print('YES' if cnt_5 == 2 and cnt_7 == 1 else 'NO')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int M1, M2, D1, D2;
// using ll = long long;


int main(){
    cin >> M1 >> D1;
    cin >> M2 >> D2;
    if(M2 - M1 == 1){
        if(D2 == 1){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

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

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

    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	
	int happ=0;
	happ+=(n/500)*1000;
	n=n%500;
	happ+=(n/5)*5;
	cout<<happ;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////
ll c[3][2];

int main(){
    ll m,n;cin>>m>>n;
    ll a[n];
    rep(i,0,n-1){
        cin>>a[i];
    }
    ll ans=0;
    if(m==2){
        rep(i,0,n-1){
            c[a[i]][i%2]++;
        }
        ans=min(c[2][0]+c[1][1],c[1][0]+c[2][1]);
        //cout<<c[2][0]<<c[1][1]<<c[1][0]<<c[2][1]<<endl;
        cout<<ans<<endl;
    }else{
        ll counter=1;
        if(n-1>=1){
            rep(i,1,n-1){
                if(a[i]==a[i-1]){
                    counter++;
                }else{
                    ans=ans+(counter/2);
                    counter=1;
                }
            }
        }
        ans=ans+(counter/2);
        cout<<ans<<endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3884
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
const long long INF = 1LL << 60;
using namespace std;

int n,k;
ll h[100010];
ll dp[100010];

int main(){
	cin >>n>>k;
	cinf(n,h);
	for(int i=0;i<100010;i++) 
		dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int R, G, B, N;

  cin >> R >> G >> B >> N;

  int ans = 0;

  for(int i=0;i*R<=N;i++){
    for(int j=0;j*G<=N;j++){
      if(i*R + j*G > N) break;

      ans += (N - i*R - j*G) % B == 0;
    }
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
x = [int(input()) for i in range(6)]

min = x[1]
for i in range(5):
    if min > x[i+1]:
        min = x[i+1]

if x[0]%min == 0:
    print(x[0]//min+4)
else:
    print(x[0]//min+5)

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

bool IsEven(const string &str)
{
    if (str.size() % 2 == 1) {
        return false;
    }

    auto half = str.size() / 2;
    for (size_t i = 0; i + half < str.size(); i += 1) {
        if (str[i] != str[i + half]) {
            return false;
        }
    }
    return true;
}

int Solve(const string &str)
{
    for (size_t to_delete = 1; to_delete < str.size(); to_delete += 1) {
        auto length = str.size() - to_delete;
        if (IsEven(str.substr(0, length))) {
            return length;
        }
    }
    return 0;
}

int main()
{
    string str;
    getline(cin, str);

    auto res = Solve(str);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
W, H, N = [int(i) for i in input().split()]
xx = []
yy = []
aa = []
for _ in range(N):
    x, y, a = [int(i) for i in input().split()]
    xx.append(x)
    yy.append(y)
    aa.append(a)

xs, ys = 0, 0
xe, ye = W, H
for i in range(N):
    if aa[i] == 1:
        xs = max(xs, xx[i])
    elif aa[i] == 2:
        xe = min(xe, xx[i])
    elif aa[i] == 3:
        ys = max(ys, yy[i])
    else:
        ye = min(ye, yy[i])

if xs < xe and ys < ye:
    print((xe - xs) * (ye - ys))
else:
    print(0)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int K,S,t,tK;
    int R=0;
    cin>>K>>S;
    for(int i=0;i<=K;i++)
    {
        for(int j=0;j<=K;j++)
        {
            if(S-i-j>=0&&(S-i-j<=K))R++;
        }
    }
    cout<<R<<endl;
    return 0;
}


Measured memory_bytes: 256
N=input()
flag = 0
l=len(N)
if l != 7:
        for i in range(7):
                g=N[0:i]+N[i+l-7:l]
                if g=='keyence':flag=1
        if flag==1:print("YES")
        else :print("NO") 
elif N=='keyence':print("YES")
else :print("NO")

Measured memory_bytes: 3064
use proconio::input;

const M: u64 = 1000_000_007;

fn calc(n: usize, k: usize, a: &Vec<usize>) -> u64 {
    let mut dp = vec![vec![0; k + 1]; n];
    for j in 0..=a[0] {
        dp[0][j] = 1;
    }
    for j in (a[0] + 1)..=k {
        dp[0][j] = 0;
    }
    for i in 1..n {
        let mut cum = vec![0; k + 2];
        for j in 1..=(k + 1) {
            cum[j] = (cum[j - 1] + dp[i - 1][j - 1]) % M;
        }
        for j in 0..=k {
            let ks = if a[i] > j { 0 } else {j - a[i]};
            dp[i][j] = (cum[j + 1] + M - cum[ks]) % M;
        }
    }
    dp[n - 1][k]
}

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    println!("{}", calc(n, k, &a));
}


Measured memory_bytes: 80996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, X, m[100];
	cin >> N >> X;
	int goukei = 0;
	int saishou = 1000;
	rep(i, N) {
		int kari;
		cin >> kari;
		goukei += kari;
		saishou = min(saishou, kari);
	}

	X -= goukei;
	int kotae = N + X / saishou;

	co(kotae);
	Would you please return 0;
}

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

using namespace std;

int memo[15];

int main() {
    int r,d;
    cin >> r >> d >> memo[0];

    for(int i = 1;i<=10;i++){
        memo[i] = r*memo[i-1]-d;
        cout << memo[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    int x, y;
    cin >> x >> y;
    for(int c = 0; c <= x; c++){
        int t = x-c;
        if(c*2+t*4 == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool C[30];
vector<ll> A[30];

int main()
{
    string S, T;
    cin >> S >> T;
    memset(C, 0, sizeof(C));
    REP(i, S.length())
    {
        C[S[i] - 'a']++;
        A[S[i] - 'a'].push_back(i);
    }
    REP(i, 30)
    {
        A[i].push_back(INF);
    }

    bool e = true;
    REP(i, T.length())
    {
        if (C[T[i] - 'a'] == 0)
            e = false;
    }

    if (!e)
    {
        cout << -1 << endl;
        return 0;
    }

    ll index = -1;
    ll ans = 0;
    REP(i, T.length())
    {
        ll n = T[i] - 'a';
        ll m = lower_bound(A[n].begin(), A[n].end(), index + 1) - A[n].begin();
        if (A[n][m] == INF)
        {
            m = 0;
            ans += A[n][m] + (S.length() - index);
        }
        else
        {
            ans += A[n][m] - index;
        }
        index = A[n][m];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#define int long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

using namespace std;

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

void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

signed main()
{
	fast();
	int n, x;
	cin >> n >> x;
	vector <int> a(n);
	int ans = 0;
	for (int & e : a)
        cin >> e;

    for (int i = 0; i + 1 < n; ++i)
    {
        int need = a[i] + a[i + 1] - x;
        if (need > 0)
        {
            ans += need;
            int can = min (need, a[i + 1]);
            a[i + 1] -= can;
            need -= can;
            a[i] -= need;
        }
    }

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


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

int main(void){
    int temp_max,x, N, i;
    cin >> N;
    x = 0;temp_max=0;
    char s[N];
    for (i=0; i<N; i++){
        cin >> s[i];
        if (s[i]=='I') x+=1;
        if (s[i]=='D') x-=1;
        temp_max=max(temp_max,x);
    } 
    cout << temp_max << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main() {
  ll N,K;
  cin >> N >> K;
  vector <ll> stones(N);
  for(int i = 0; i < N; i++){
    cin >> stones[i];
  }
  vector <ll> dp(N,999999999);
  dp[0] = 0;
  for(int q = 1; q < N; q++){
    for(int p =  1; p < K + 1; p ++){
      if(q-p >= 0){
        dp[q] = min(dp[q], dp[q-p] + abs(stones[q-p] - stones[q]));
      }
    }
  }
  cout << dp[N-1];
}

Measured memory_bytes: 4848
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        String s;
        Map<String, Integer> map = new TreeMap<>();
        int max = 0;
        for (int i = 0; i < n; i++) {
            s = br.readLine();
            int val = map.containsKey(s) ? map.get(s) + 1 : 1;
            map.put(s, val);
            max = Math.max(max, val);
        }

        br.close();

        for (Entry<String, Integer> entry : map.entrySet()) {
            if (entry.getValue() == max) {
                bw.write(entry.getKey() + "\n");
            }
        }

        bw.flush();

    }
}

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

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private String[] keys = {
    "dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"
  };

  private void solve(Scanner sc, PrintWriter out) {
    String S = sc.nextLine();

    int i = 0;
    while (i < S.length()) {
      boolean found = false;
      for (int j = 0; j < keys.length; ++j) {
        int keylen = keys[j].length();
        if (i + keylen <= S.length()) {
          String s = S.substring(i, i + keylen);
          if (s.equals(keys[j])) {
            i += keylen;
            found = true;
            break;
          }
        }
      }
      if (!found) {
        break;
      }
    }
    out.println((i == S.length() ? "YES" : "NO"));
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  private long ceil2pow(long n) {
    if (n == 0) {
      return 1;
    }
    n--;
    n |= (n >>> 1);
    n |= (n >>> 2);
    n |= (n >>> 4);
    n |= (n >>> 8);
    n |= (n >>> 16);
    n++;
    return n;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

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

using namespace std;

int main(void) {
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#define MAX_N 12
#define INF 10000
using namespace std;
vector<int> cakes;
int n;
double d[MAX_N][MAX_N];
double dp[1 << MAX_N][MAX_N];

void calc_dist(){
    int n = cakes.size();
    for (int i = 0; i < n; i++) {
        for (int j = 0;  j < n; j++) {
            if (i == j) {
                d[i][j] = 0;
            }else{
                double dist = sqrt(pow(cakes[i] + cakes[j], 2) - pow(cakes[i] - cakes[j], 2));
                d[i][j] = dist;
            }
        }
    }
}

void solve(){
    n = cakes.size();
    for (int s = 0; s < (1 << n); s++) {
        for (int j = 0; j < n; j++) {
            dp[s][j] = INF;
        }
    }
    for (int i = 0; i < n; i++) {
        dp[1 << i][i] = cakes[i];
    }
    
    for (int s = 0; s < (1 << n); s++) {
        for (int v = 0; v < n; v++) {
            for (int u = 0; u < n; u++) {
                if (!(s >> u & 1)) {
                    dp[s | (1 << u)][u] = min(dp[s | (1 << u)][u], dp[s][v] + d[v][u]);
                }
            }
        }
    }
}


int main()
{
    int len;

    while (cin >> len) {
        cakes.clear();
        string str;
        getline(cin, str);
        stringstream ss(str);
        while (!ss.eof()) {
            int r;
            ss >> r;
            cakes.push_back(r);
        }
        calc_dist();
        solve();
        bool ok = false;
        for (int i = 0; i < n; i++) {
            if (dp[(1 << cakes.size()) - 1][i] + cakes[i] <= len) {
                ok = true;
            }
        }
        if (ok){
            cout << "OK" << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1616
#include<stdio.h>
int main(void)
{
	int card[4][14], i, j, n, b;
	char a;

	//すべてのカードをとりあえず0に
	for (i = 0; i < 4; i++)
	{
		for (j = 1; j <= 13; j++)
		{
			card[i][j] = 0;
		}
	}

	scanf("%d", &n); //カードの枚数指定


	//持っているカードにチェックとして1をつける
	for (i = 1; i <= n*2; i++)
	{
		scanf("%c %d", &a, &b);

		if (a == 'S')
		{
			card[0][b] = 1;
		}
		if (a == 'H')
		{
			card[1][b] = 1;
		}
		if (a == 'C')
		{
			card[2][b] = 1;
		}
		if (a == 'D')
		{
			card[3][b] = 1;
		}
	}



	//持ってないカードの表示
	for (i = 0; i < 4; i++)
	{

		for (j = 1; j <= 13; j++)
		{

			if (card[i][j] == 0) // チェックがついていないとき
			{
				if (i == 0)
				{
					printf("S %d\n", j);
				}
				if (i == 1)
				{
					printf("H %d\n", j);
				}
				if (i == 2)
				{
					printf("C %d\n", j);
				}
				if (i == 3)
				{
					printf("D %d\n", j);
				}
			}
		}
	}


	return 0;
}


Measured memory_bytes: 2060
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	vector<int>a(3);
	for (int i = 0; i < 3; i++)
	{
		cin >> a.at(i);
	}
	sort(a.begin(), a.end(), greater<int>());
	cout<<a.at(0)*10+a.at(1)+a.at(2)<<endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> l(n+1);
    l[0] = 2, l[1] = 1;
    for(int i = 2; i <= n; ++i) {
        l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;

namespace C
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var cn = new int[n - 1];
			var sn = new int[n - 1];
			var fn = new int[n - 1];
			for (var i = 0; i < n - 1; i++)
			{
				var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
				cn[i] = line[0];
				sn[i] = line[1];
				fn[i] = line[2];
			}

			var result = new int?[n];
			result[n - 1] = 0;
			result[n - 2] = sn[n - 2] + cn[n - 2];
			for (var i = n - 3; i >= 0; i--)
			{
				var tmp = sn[i] + cn[i];
				for (var j = 0; i + j + 1 < n - 1; j++)
				{
					if (tmp <= sn[i + j + 1])
					{
						result[i] = result[i + j + 1];
						break;
					}

					tmp += (fn[i + j + 1] - tmp % fn[i + j + 1]) % fn[i + j + 1] + cn[i + j + 1];
				}

				if (result[i] == null) { result[i] = tmp; }
			}

			foreach (var r in result) { Console.WriteLine(r); }
		}
	}
}

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

int main() {
    int num;
    string y,r;

    cin >> y >> r;

    int counter = 0;
    for(int i=0; i<3; i++) {
        if(y[i] == r[i]) counter++;
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r)          \
	for (int i = l; i < r; i++) \
		cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;
vector<pair<int, long long>> g[3000];
vector<int> gr[3000];
bool reachableFromN[3000];

void bfs(int src)
{
	reachableFromN[src] = true;
	queue<int> q;
	q.push(src);

	while (!q.empty())
	{
		auto curr = q.front();
		q.pop();
		for (auto ne : gr[curr])
		{
			if (ne != curr)
			{
				if (!reachableFromN[ne])
				{
					reachableFromN[ne] = true;
					q.push(ne);
				}
			}
		}
	}
}
int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	long long n, m, p;
	cin >> n >> m >> p;

	for (int i = 0; i < m; i++)
	{
		long long a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		c -= p;
		g[a].push_back({b, c});
		gr[b].push_back(a);
	}

	bfs(n - 1);

	//Bellman Ford O(V*E):Finds shortest paths from src to all vertices in V-1 passes if no neg cycle
	long long dist[n];
	long long NMAX = -1000000000000000000;
	fill(dist, dist + n, NMAX);
	/* 	print(dist, 0, n); */
	dist[0] = 0;
	for (int i = 0; i < n; i++)
	{

		for (int j = 0; j < n; j++)
		{
			if (dist[j] == NMAX)
				continue;
			for (auto edge : g[j])
			{
				if (dist[edge.first] < (dist[j] + edge.second))
				{
					dist[edge.first] = (dist[j] + edge.second);
				}
			}
		}
	}

	//If we can relax for more than V-1, i.e Vth time, then neg cycle exists
	for (int j = 0; j < n; j++)
	{
		if (dist[j] == NMAX)
			continue;
		for (auto edge : g[j])
		{

			if (dist[edge.first] == NMAX)
				continue;

			if (dist[edge.first] < (dist[j] + edge.second) && reachableFromN[edge.first])
			{
				cout << -1 << endl;
				return 0;
			}
		}
	}

	cout << max(0ll, dist[n - 1]) << endl;

	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

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


void Calc() {
  string s = in;
  set<char> ss;
  for (auto& i : s) {
    ss.insert(i);
  }
  err(ss);
  rep(i, 'a', 'z' + 1) {
    if (ss.find(i) == ss.end()) {
      cout << (char)(i) << endl;
      return;
    }
  }
  cout << ("None") << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string s,a="ACGT";
  int ans=0,m=0;
  bool f=false;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(!f) m=0;
    f=false;
    for(int j=0;j<4;j++){
      if(s[i]==a[j]) f=true;
    }
    if(f) m++;
    ans=max(m,ans);
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int a, b;
  cin >> a >> b;
  for (int i = 1; i <= N; ++i) {
    if (i * 8 / 100 == a && i * 10 / 100 == b) {
      cout << i << '\n';
      return;
    }
  }
  cout << "-1\n";
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



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

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

const int INF = 1e9 + 7;

using namespace std;

void bfs(int st, vector<vector<int>>& tree, vector<int>& tree_cost) {
  queue<pair<int, int>> que; // dst, cost
	que.push(make_pair(st, 0));

	vector<int> search_tree(100001, 0);

	while (que.size() != 0) {
		pair<int, int> top = que.front();
		que.pop();

		tree_cost[top.first] = top.second;
		search_tree[top.first] = 1;

		for (int node : tree[top.first]) {
			if (search_tree[node] == 0)
				que.push(make_pair(node, top.second + 1));
		}
	}

	return ;
}

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

	int n;
	int u, v;
	cin >> n >> u >> v;
	u--; v--;

	vector<vector<int>> tree(n);
	vector<int> t_cost(n, 0);
	vector<int> a_cost(n, 0);

	rep (i, 0, n - 1) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;

		tmp1--; tmp2--;
		tree[tmp1].push_back(tmp2);
		tree[tmp2].push_back(tmp1);
	}

	bfs(u, tree, t_cost);
	bfs(v, tree, a_cost);

	// search max value
	int res = 0;
	rep (i, 0, n) {
		if (t_cost[i] < a_cost[i]) {
			res = max(res, a_cost[i] - 1);
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 7168
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def reduce(y, x):
    tmp = gcd(x, y)
    return (y // tmp, x // tmp)

def get_z(y, x): # y/x (mod 1000000007)
    inv_x = pow(x, MOD - 2, MOD)
    return y * inv_x % MOD

def make_combs(n, k):
    fact = [1] * (n + 1)
    for i in range(2, n + 1):
        fact[i] = (fact[i - 1] * i) % MOD

    ret = [0] * (n + 1)
    for i in range(k, n + 1):
        a = fact[i]
        b = (fact[k] * fact[i - k]) % MOD
        ret[i] = get_z(a, b)
    return ret


def make_pow(y, x, n):
    ret = [0] * (n + 1)
    yy = [1] * (n + 1)
    xx = [1] * (n + 1)
    for i in range(1, n + 1):
        yy[i] = ((yy[i - 1] * y) % MOD)
        xx[i] = ((xx[i - 1] * x) % MOD)
    for i in range(n + 1):
        #print(yy[i], xx[i])
        ret[i] = get_z(yy[i], xx[i])
    return ret

def solve(n: int, A: int, B: int, C: int):
    y = 0
    x = 0
    AB = 100 - C
    combs = make_combs(2 * n, n - 1)
    a, a_ab = reduce(A, AB)
    b, b_ab = reduce(B, AB)
    a_pow = make_pow(a, a_ab, n)
    b_pow = make_pow(b, b_ab, n)
    #print(combs)
    #print(a_pow)
    #print(b_pow)
    for i in range(n, n * 2):
        com = combs[i - 1]
        #tmp  = (A / ab) ** (n) + (B / ab) ** (i - n)
        #tmp += (B / ab) ** (n) + (A / ab) ** (i - n)
        tmp  = a_pow[n] * b_pow[i - n]
        tmp += b_pow[n] * a_pow[i - n]
        #print(a_pow[n], b_pow[i - n], b_pow[n], a_pow[i - n])
        x = (x + tmp * com) % MOD
        y = (y + tmp * com * i) % MOD
    x = (x * (100 - C)) % MOD
    y = (y * 100) % MOD
    ret = get_z(y, x)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(N, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 48932
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	auto ans = "No";
	if (A == B)
	{
		if (A != C)
		{
			ans = "Yes";
		}
	}
	else if (A == C || B == C)
	{
		ans = "Yes";
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N;cin>>N;
  typedef pair<int,int> P;
  std::vector<P> v(N);
  for(int i=0;i<N;i++){
    int a;cin>>a;
    v[i]=P(a,i);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<N;i++)cout<<v[i].second+1<<" ";cout<<endl;
}


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

int main() {
  ll n;
  cin>>n;
  ll s=0;
if (n==0){
  cout<<0;
  return 0;
}

  vector<ll> ans(50);
  ll now=2;
  ll i=0;
  while(n!=0){
  //  if (n==0)break;
//  cout<<n<<endl;
    if (n%now!=0){
      ll temp=n%now;
      if (temp<0)temp+=now;
      ans[i]=1;
     if(i%2==0)n-=temp;
     if(i%2==1)n+=temp;

  //    if (i%2==1)n-=now;
    }
    now*=2;
    i++;
  }
  for(int j=i-1;j>=0;j--){
    cout<<ans[j];
  }

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

double N,K;
double beki[100010]; 

void rui(int i){
  int n=i;
  double cnt=1;
  while(i<K){
    i=i*2;
    cnt*=(double)1/2;
  }
  beki[n]=cnt;
}

int main(){
  cout << fixed << setprecision(15);
  cin >> N >> K;
  for(int i=1;i<=N;i++){
    rui(i);
  }
  double ans=0;
  for(int i=1;i<=N;i++){
    ans+=(double)1/N*beki[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    for(int i = 0;i<k;i++){

        if(a<b && c>b){
          break;
        }
        else if (a>=b)
            {b = b*2;
            continue;}
        else if(c<=b)
            {c=c*2;
            continue;}

    }


     if(a<b && c>b){
          cout<<"Yes";

        }
        else
            cout<<"No";

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  if (n > k) {
    REP(i, k) { cout << s[i]; }
    cout << "..." << endl;
  } else {
    print(s);
  }
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include <string>
#include <algorithm>
using namespace std;
bool isleft(char c)
{
	string right="qwertasdfgzxcvb";
	return find(right.begin(),right.end(),c)==right.end();
}
int main()
{
	string input;
	while(cin>>input){
		if(input=="#")break;
		bool curleft=isleft(input[0]);
		int ret=0;
		for(int i=1;i<input.size();i++){
			if(isleft(input[i])!=curleft)ret++;
			curleft=isleft(input[i]);
		}
		cout<<ret<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
n = gets.to_i
a = []
b = []
connect_vertex = Array.new(n+1,0)
g = Array.new(n+1).map{Array.new}
(n-1).times do |i|
  a[i], b[i] = gets.chomp.split(" ").map(&:to_i)
  g[a[i]].push(b[i])
  g[b[i]].push(a[i])
  connect_vertex[a[i]] += 1
  connect_vertex[b[i]] += 1
end
max = connect_vertex.max
puts max

ans = Hash.new
dist = Array.new(g.length,-1)
dist[1] = 0
queue = [1]
visited = Array.new(n+1,0)
while !queue.empty?
  v = queue[0]
  queue.shift
  unko = 1
  g[v].each{|des|
    if dist[des] == -1
      dist[des] = dist[v] + 1
      if unko != visited[v]
        ans[[v,des]] = unko if v < des
        ans[[des,v]] = unko if v > des
        visited[des] = unko
        queue.push(des)
      else
        unko += 1
        ans[[v,des]] = unko if v < des
        ans[[des,v]] = unko if v > des
        visited[des] = unko
        queue.push(des)
      end
      unko += 1
    end
   }
end

(n-1).times do |i|
  puts ans[[a[i],b[i]]] if a[i] < b[i]
  puts ans[[b[i],a[i]]] if a[i] > b[i]
end

Measured memory_bytes: 30464
for _ in range(10000):
    h, w = map(int, input().split())

    h += 1
    w += 1

    if h == 1:
        if w == 1:
            break

    for i in range(h - 1):

        isHKisu = True
        if (i % 2 == 0):
            isHKisu = False

        l = ""

        for j in range(w - 1):

            isWKisu = True
            if (j % 2 == 0):
                isWKisu = False

            if isHKisu:
                if isWKisu:
                    l += '#'
                else:
                    l += '.'
            else:
                if isWKisu:
                    l += '.'
                else:
                    l += '#'
        print(l)
    print()


Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll H, W, K;
	cin >> H >> W >> K;
	VVLL MAP;   //1->あり
	MAP.resize(W+1, VLL(H+1,0));
	VVLL MAPP;
	MAPP.resize(W + 1, VLL(H + 1, 0));
	for (ll y = 1; y <=H; y++) {
		string S;
		cin >> S;
		for (ll x = 1; x <= W; x++) {
			if (S[x - 1] == '#') {
				MAP[x][y] = 1;
				MAPP[x][y] = 1;
			}
			
		}
	}
	for (ll y = 1; y <= H; y++) {
		for (ll x = 1; x <= W; x++) {
			MAPP[x][y] += MAPP[x - 1][y] + MAPP[x][y - 1] - MAPP[x - 1][y - 1];
		}
	}
	VVLL ans;
	ans.resize(W+1, VLL(H+1, 0));
	ll sy = 1;
	for (; sy <= H; sy++) {
		if (MAPP[W][sy] != 0)break;
	}
	ll count = 0;
	for (ll y = sy; y <= H; y++) {
		//その段にイチゴがある
		if (MAPP[W][y] != MAPP[W][y - 1]) {
			count++;
			ll x = 1;
			for (; x <= W; x++) {
				if (MAP[x][y] == 0)ans[x][y] = count;
				else break;
			}
			ans[x++][y] = count;
			for (; x <= W; x++) {
				if (MAP[x][y] == 0)ans[x][y] = count;
				else {
					count++;
					ans[x][y] = count;
				}
			}
		}
		else {
			for (ll x = 1; x <= W; x++) {
				ans[x][y] = ans[x][y-1];
			}
		}
	}
	for (ll y = sy - 1; y >= 1; y--) {
		for (ll x = 1; x <= W; x++) {
			ans[x][y] = ans[x][y + 1];
		}
	}
	for (ll y = 1; y <= H; y++) {
		for (ll x = 1; x <= W; x++) {
			cout << ans[x][y] << " ";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
int rev[3100][3100];
int dp[3100][3100];
char s[3100];
char t[3100];
char ans[3100];
int main(){
	scanf("%s%s",s,t);
	int N=strlen(s);
	int M=strlen(t);
	for(int i=0;i<3100;i++)for(int j=0;j<3100;j++)
		dp[i][j]=-3100;
	dp[0][0]=0;
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			if(i+1<=N){
				if(dp[i+1][j]<dp[i][j]){
					dp[i+1][j]=dp[i][j];
					rev[i+1][j]=0;
				}
			}
			if(j+1<=M){
				if(dp[i][j+1]<dp[i][j]){
					dp[i][j+1]=dp[i][j];
					rev[i][j+1]=1;
				}
			}
			if(i+1<=N&&j+1<=M&&s[i]==t[j]){
				if(dp[i+1][j+1]<dp[i][j]+1){
					dp[i+1][j+1]=dp[i][j]+1;
					rev[i+1][j+1]=2;
				}
			}
		}
	}
	int ns=N;
	int nt=M;
	int at=dp[N][M]-1;
	while(ns||nt){
		if(rev[ns][nt]==0)ns--;
		else if(rev[ns][nt]==1)nt--;
		else{
			ns--;nt--;
			ans[at]=s[ns];
			at--;
		}
	}
	printf("%s\n",ans);
}


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

P StoP(string a){
  int top=0,first=0;
  for(int i=0;i<a.size();i++){
    if(a[i]=='(') top++;
    else if(top) top--;
    else first++;
  }
  return P(first,top);
}

int main(){
  int n;
  cin>>n;
  
  P p[101];
  int cnt=0;
  for(int i=0;i<n;i++){
    string tmp;
    cin>>tmp;
    p[i]=StoP(tmp);
    if(!p[i].second) cnt+=p[i].first,i--,n--;
  }


  bool ans=1,used[101]={};
  int top=0;
  for(int i=0;i<n&&ans;i++){
    int idx=-1,mx=-110;
    for(int j=0;j<n;j++){
      if(used[j]||top-p[j].first<0)continue;
      int k=p[j].second-p[j].first;
      if(mx<k) mx=k,idx=j;
    }
    if(idx==-1) ans=0;
    top+=mx;
    used[idx]=1;
  }
  cout<<(ans&&!(top-cnt)? "Yes":"No")<<endl;
	
  
  return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
using namespace std;


int main(){
	char str[11];
	int a,b;
	cin >> a >> b;
	int check = 1;
	for( int i = 0 ; i < a; i++ ){
		cin >> str[i];
		if ( isdigit(str[i]) ); else check = 0;
	}
	
	cin >> str[a];
	if ( str[a] == '-' ); else check = 0;
	
	for( int i = a + 1 ; i < a + b + 1 ; i++ ){
		cin >> str[i];
		if ( isdigit(str[i]) ); else check = 0;
	}
	
	if ( check ) cout << "Yes"; else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
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;
}

int main() {
    string a, b;
    cin >> a >> b;
    int na = a.size();
    int nb = b.size();
    if (na > nb) {
        b = string(na - nb, '0') + b;
    } else if (na < nb) {
        a = string(nb - na, '0') + a;
    }
    if (a > b)
        cout << "GREATER"
             << "\n";
    else if (a < b)
        cout << "LESS"
             << "\n";
    else
        cout << "EQUAL"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
c = list(itertools.permutations(p,n))
c.sort()
for i in range(len(c)):
    if list(c[i]) == p:
        one = i
    if list(c[i]) == q:
        two = i
print(abs(one-two))
        



Measured memory_bytes: 8504
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=500000;

vector<vector<pii>> G;
vec ans;
void bfs(int x,int p,int c){
    int now=1;
    for(auto e:G[x]){
        if(e.first==p)continue;
        if(now==c)now++;
        ans[e.second]=now;
        bfs(e.first,x,now);
        now++;
    }
}
main(){
    int n=in();
    ans.resize(n-1);
    G.resize(n+1);
    rep(i,n-1){
        int a=in(),b=in();
        G[a].pb({b,i});
        G[b].pb({a,i});
    }
    int size=0;
    rep2(i,1,n){
        size=max(size,(int)G[i].size());
    }
    bfs(1,0,0);
    cout<<size<<endl;
    for(auto e:ans)cout<<e<<endl;
}

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

int main()
{
    int n, m;
    std::cin >> n >> m;
    std::vector<int> counts(n);
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        std::cin >> a >> b;
        --a;
        --b;
        ++counts[a];
        ++counts[b];
    }

    for (int i = 0; i < n; ++i)
    {
        std::cout << counts[i] << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;
	int are = 2e9;
	ll goukei = 0;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		if (a > b) are = min(are, b);
		goukei += b;
	}

	if (are == 2e9) co(0);
	else co(goukei - are);

	Would you please return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200002)


def dfs(i, c):
    C[i] = True
    P[i] = c
    for t in G[i]:
        if (C[t[0]] == True):
            continue
        dfs(t[0], c+t[1])
    return


N, M = list(map(int, input().split()))
G = [[] for _ in range(N+1)]
P = [None for _ in range(N+1)]
C = [False for _ in range(N+1)]

for i in range(M):
    l, r, d = list(map(int, input().split()))
    G[l].append((r,d))
    G[r].append((l,-d))

for i in range(1, N+1):
    if (C[i] == False):
        dfs(i,0)

f = False
for i in range(1, N+1):
    for t in G[i]:
        if ((P[t[0]] - P[i]) != t[1]):
            f = True
if (f):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 132524
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>

using ll = long long;

using namespace std;

struct barrier { ll x, y, r=0; };

#define MAX_N 2000
#define INF (1e18)

using P = pair<double, int>;
#define fi first
#define se second

// 各点への最短経路 dijkstra
double d[MAX_N];  //頂点kから各点への距離
vector<P> G[MAX_N]; //隣接行列
int n; 
void dijkstra(int k) { //Gは隣接行列 G[i][j].firstが距離, secondが向かう頂点名, kはスタートする頂点
    fill(d, d+n, INF); d[k] = 0;
    priority_queue< P, vector<P>, greater<P> > que;
    que.push(P(0, k));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int now = p.second;
        if (d[now] < p.first) continue;
        for (auto g:G[now]) {
            int to = g.second;
            double newd = g.first + d[now];
            if (d[to] > newd) {
                d[to] = newd;
                que.push(P(d[to], to));
            }
        }
    }
}

int main() {
    barrier s, t;
    cin >> s.x >> s.y >> t.x >> t.y >> n;
    barrier bars[n+2];
    bars[0] = s;
    bars[1] = t;
    for (int i=0; i<n; i++) cin >> bars[i+2].x >> bars[i+2].y >> bars[i+2].r;
    n += 2;
    for (int i=0; i<n; i++) {
        for (int j=0; j<i; j++) {
            double dij = max(0., hypot(bars[i].x - bars[j].x, bars[i].y - bars[j].y) - bars[i].r - bars[j].r);
            G[i].push_back({dij, j});
            G[j].push_back({dij, i});
        }
    }
    dijkstra(0);
    cout << setprecision(15) << fixed << d[1] << '\n';
    return 0;
}

Measured memory_bytes: 22128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a)	cout << k << endl;
	else if (k <= a + b)	cout << a << endl;
	else {
		cout << a - (k - a - b) << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define int long long
using namespace std;
int s(int n)
{
	int x=0;
	while(n)x+=n%10,n/=10;
	return x;
}
signed main()
{
	int k,n=1,d=1;
	cin>>k;
	cout<<"1\n";
	while(--k)
	{
		if((n+d*10)*s(n+d)<(n+d)*s(n+d*10))d*=10;
		cout<<(n+=d)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256