akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] s = new int[n];
        int[] l = new int[n];
        int[] p = new int[n];
        for(int i=0; i<n; i++){
            s[i] = sc.nextInt();
            l[i] = sc.nextInt();
            p[i] = sc.nextInt();
        }
        int m = sc.nextInt();
        int[] w = new int[m];
        for(int i=0; i<m; i++) w[i] = sc.nextInt();

        int[] point = new int[394];
        Arrays.fill(point, -1);

        point[0] = 0;
        for(int i=0; i<394; i++){
            for(int j=0; j<n; j++){
                for(int k=s[j]; k<=l[j]; k++){
                    if(i-k<0) break;
                    if(point[i-k]!=-1) point[i]  = Math.max(point[i], point[i-k] + p[j]);
                }
            }
        }

        boolean boo = true;
        for(int i=0; i<m; i++) if(point[w[i]]==-1) boo = false;
        if(!boo) System.out.println(-1);
        else for(int i=0; i<m; i++) System.out.println(point[w[i]]);
    }

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

Measured memory_bytes: 24952
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep2(i, 1, n + 1) {
    ll a;
    cin >> a;
    if(i % 2 && a % 2) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;

int main()
{
    int t,n,j,k;
    bool one = false;
    bool two = false;
    bool thr = false;
    bool fou = false;
    bool fiv = false;
    bool six = false;
    bool sev = false;
    bool eig = false;
    bool nin = false;
    vector<int> b;
    map<int,int> bingo;
    for(int i=1;i<10;i++){
        cin>>t;
        bingo[t] = i;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>j;
        j=bingo[j];
        if(j!=0){
            b.pb(j);
            if(j==1){
                one = true;
            }
            if(j==2){
                two = true;
            }
            if(j==3){
                thr = true;
            }
            if(j==4){
              fou = true;  
            }
            if(j==5){
               fiv = true; 
            }
            if(j==6){
               six = true; 
            }
            if(j==7){
                sev = true;
            }
            if(j==8){
                eig = true;
            }
            if(j==9){
                nin = true;
            }

        }
    }
    sort(all(b));
    if(one&&two&&thr){
        log("Yes");
    }
    else if(fou&&fiv&&six){
        log("Yes");
    }
    else if(sev&&eig&&nin){
        log("Yes");
    }
    else if(one&&fou&&sev){
        log("Yes");
    }
    else if(two&&fiv&&eig){
        log("Yes");
    }
    else if(thr&&six&&nin){
        log("Yes");
    }
    else if(one&&fiv&&nin){
        log("Yes");
    }
    else if(thr&&fiv&&sev){
        log("Yes");
    }
    else {
        log("No");
    }
}



Measured memory_bytes: 256
/*
[abc132] F - Small Products
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_R = 1e5;
const int MAX_K = 100;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
};

int N, K;
gf dp[MAX_K + 1][MAX_R];
vector<int> t;

ll solve() {
    for (int i = 1; i * i <= N; i++) {
        t.push_back(i);
        if (N / i != i) {
            t.push_back(N / i);
        }
    }
    sort(t.begin(), t.end(), greater<int>());
    int T = t.size();
    t.push_back(0);

    for (int i = 1; i <= T; i++) {
        dp[0][i] = 1;
    }
    for (int k = 1; k <= K; k++) {
        for (int i = 1; i <= T; i++) {
            dp[k][i] =
                dp[k][i - 1] + dp[k - 1][T - i + 1] * (t[T - i] - t[T - i + 1]);
        }
    }

    return dp[K][T].n;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 40064
n,m=map(int,input().split())
ans_list=[]
for _ in range(n):
    ans_list.append(0)
h_list=list(map(int,input().split()))
#print(h_list)
road_list=[]
for i in range(m):
  road_list.append(list(map(int,input().split())))
#print(road_list)
#roadset=get_unique_list(road_list)
#print(roadset)
roadnum=len(road_list)
#print(roadnum)

for i in range(roadnum):
  templist=road_list[i]
  a=templist[0]
  b=templist[1]
  #print([a,b])
  if h_list[a-1]>h_list[b-1]:
    ans_list[b-1]+=1
  elif h_list[a-1]==h_list[b-1]:
    ans_list[a-1]+=1
    ans_list[b-1]+=1
  else:
    ans_list[a-1]+=1
print(ans_list.count(0))

Measured memory_bytes: 31976
import scala.io.StdIn.readLine

object Main {
  def getTop3() = {
    {
      for(i<-1 to 8) yield {
        val n = readLine.split(" ")
        (n(0).toInt, n(1).toDouble)
      }
    }.toList.sortBy(_._2)
  }

  def main(args:Array[String]) = {
    val x1 = getTop3
    val x2 = getTop3
    val x3 = getTop3
    val r = List(x1(0),x1(1),x2(0),x2(1),x3(0),x3(1))
    r.foreach {e => println(e._1+" "+"%.2f".format(e._2)) }
    val r2 = (x1.drop(2) ++ x2.drop(2) ++ x3.drop(2)).sortBy(_._2)
    println(r2(0)._1 + " " + "%.2f".format(r2(0)._2))
    println(r2(1)._1 + " " + "%.2f".format(r2(1)._2))
  }
}

Measured memory_bytes: 44088
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
if s == 'hi' or s == 'hihi' or s == 'hihihi' or s == 'hihihihi' or s == 'hihihihihi':
    print('Yes')
else:
    print('No')

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll h, n;
    cin >> h >> n;
    REP(i, n){
        ll a;
        cin >> a;
        h -= a;
    }
    cout << (h <= 0 ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll s;
	cin >> s;

	ll x = 0, y = 0;

	ll x1 = (ll)1e9;
	ll x2 = 1;
	
	ll y2 = (s / x1) + (ll)(s % x1 != 0LL);
	ll y1 = x1 * y2 - s;

	cout << x << " " << y << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 最初の文字の固まりを整数値と想定して読み込む
        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            int count = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    for (int k = 1; k <= n; k++) {
                        if (x == i + j + k && i != j && j != k && k != i) {
                            count++;
                        }
                    }
                }
            }
            count = count / 6;
            System.out.printf("%d\n", count);
        }
    }
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, k;
  cin >> n >> k;
  vi32 cnt(n + 1);
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int x;
      cin >> x;
      cnt[x]++;
    }
  }
  int ans = 0;
  reps(i, n) {
    if (!cnt[i]) ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct item {
	int value;
	int weight;
	item(int v = 0, int w = 0) {
		value = v; weight = w;
	}
};

const int MAX_W = 10010;
const int MAX_N = 101;

int main() {
	int N, W;
	cin >> N >> W;
	vector<item> items(N, 0);
	for(int i = 0; i < N; ++i) {
		int v, w;	
		cin >> v >> w;	
		items[i] = item(v, w);
	}

	int dp[MAX_W][MAX_N]; // ??????i?????§????????????????±?????????¨???????????????????????????w????????£???????????????????????§???
	fill_n((int *)dp, MAX_W*MAX_N, 0);	

	for(int w = 0; w <= W; ++w) {
		for(int i = 0; i < N; ++i) {
			if(w < items[i].weight) {
				dp[w][i] = dp[w][i - 1];
			} else {
				dp[w][i] = max(dp[w][i - 1], dp[w - items[i].weight][i] + items[i].value);		
			}	
		}
	}
	
	cout << dp[W][N-1] << endl;
	return 0;
}

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

int main(){
  int N, c = 0;
  cin >> N;
  int a[N];
  for(int i = 0; i < N && c < 3; i++) {
    cin >> a[i];
    if(a[i] != i+1) {c++;}
  }
  if(c == 0 || c == 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);

        String S = scan.nextLine();
        String T = scan.nextLine();

        int len = S.length();
        int ans = 0;

        for(int i = 0; i < len; i++){
            char charS = S.charAt(i);
            char charT = T.charAt(i);
            if(charS != charT){
                ans++;
            }
        }
        System.out.println(ans);
        scan.close();
    }
}


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

int main(){
    // input
    int N;
    string S;
    cin >> N >> S;

    // count slime
    int ans = 1;
    for(int i=1; i<N; i++ ){
        if( S[i] != S[i-1] ){
            ans++;
        }
    }

    // output
    cout << ans << endl;
} 

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    long long x, y;
    std::cin >> x >> y;

    int i = 0;
    while(x <= y){
        ++i;
        x *= 2;
    }
    std::cout << i << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>

using namespace std;

int main(int argc, const char * argv[]) {
    int n, k;
    cin >> n >> k;
    vector<long long> c(n,0);
    
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    if(n == 1 && c[0] == 1){
        cout << 0 << endl;
    }
    long long m = 9999999999;
    for(int i = 0; i + k - 1< n; i++){
        m = min(m, abs(c[i+k-1] - c[i]) + min(abs(c[i+k-1]), abs(c[i])));
        //cout << c[i+k-1] << "," << c[i] << endl;
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b,c,d;
    cin >>a >> b >> c >> d;
    int ans=max(a*b,c*d);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
using System;
 
class Program
{
	static void Main(String[] arg)
	{
        //出力用の文字列
        String ret;
 
        // 整数の取得
        String[] nums = Console.ReadLine().Split(' ');
        int a = int.Parse(nums[0]);
        int b = int.Parse(nums[1]);
        
        // 積の演算
        int product = a * b;
 
        if(product % 2 == 0)
        {
            ret = "Even";
        }
        else
        {
            ret = "Odd";
        }
      
        Console.WriteLine(ret);
		}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string in; cin >> in;

    int cnt0 = 0, cnt1 = 0;
    for(auto& e : in){
        (e == '0' ? cnt0:cnt1)++;
    }

    cout << 2 * min(cnt0, cnt1) << endl;

    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
void fast() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}

#define endl '\n'
// #define double long double
// #define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

void solve() {
	string s;
	cin >> s;
	string t;
	cin >> t;
	
	if (s.length() > 10 || s.length() == 0) {
		cout << "No";
	}
	
	else if (t.length() == s.length()+1) {
		bool c = true;
		for (int i = 0; i < s.length(); i++) {
			if (t[i] != s[i]) {
				c = false;
				break;
			}
		}
		
		if (c) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
	
	else {
		cout << "No";
	}
}

signed main() {
    
    fast();
    int t = 1;
    //cin >> t; // comment this line if single case
    while (t--) {
        solve();
    }
    
    
}


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

typedef long long ll;

int main() {
    int H, W;
    bool ok = true;
    cin >> H >> W;
    vector<string>A(H);
    set<char>s;
    for (int i = 0; i < H; i++) {
        cin >> A[i];
    }
    map<char, int>mp;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            mp[A[i][j]]++;
            s.insert(A[i][j]);
        }
    }
    int a, b, c;
    a = (H/2)*(W/2);
    b = (H%2)*(W/2) + (W%2)*(H/2);
    c = (H%2)*(W%2);
    int cnt1 = 0;
    int cnt2 = 0;
    int cnt3 = 0;
    for (auto itr = s.begin(); itr != s.end(); itr++) {
        if (mp[*itr] % 4 == 0) {
            cnt1 += (mp[*itr]/4);
        } else if (mp[*itr] % 2 == 0) {
            cnt1 += (mp[*itr]/4);
            mp[*itr] -= (mp[*itr]/4)*4;
            cnt2 += (mp[*itr]/2);
        } else {
            cnt1 += (mp[*itr]/4);
            mp[*itr] -= (mp[*itr]/4)*4;
            cnt2 += (mp[*itr]/2);
            mp[*itr] -= (mp[*itr]/2)*2;
            cnt3 += mp[*itr];
        }
    }

    if (a <= cnt1) {
        cnt1 -= a;
        cnt2 += cnt1*2;
        if (b == cnt2 && c == cnt3) {
            cout << "Yes" << endl; 
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n = gets.to_i
flowerInput = gets.split.map(&:to_i)

def mizuyari(flowers, n)
  l = 0
  ls = false
  flowers.each do |flower|
    if flower == 0 && !ls
      l += 1
    else
      ls = true
      break
    end
  end

  r = l
  flowers[l..n-1].each do |flower|
    if flower == 0
      break
    else
      r += 1
    end
  end

  r -= 1

  [l, r]
end

count = 0

until flowerInput.all?{|f| f==0}
  res = mizuyari(flowerInput, n)
  # puts flowerInput[res[0]..res[1]]
  eachcount = 0
  flowerInput.each do |flo|
    flowerInput[eachcount] = flo - 1 if eachcount.between?(res[0], res[1])
    eachcount += 1
  end
  count += 1
end

puts count

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int n,k;
  int ans = 0;
  cin >> n >> k;
  while(n>0){
    n /= k;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    int x;
    vector<queue<int>> b(n);
    rep(i,n)rep(j,n-1){
        cin>>x;
        x --;
        b[i].emplace(x);
    }
    set<int> seen;
    int ans=-1;
    bool f=1;
    while(f){
        f=0;
        rep(i,n){
            if(b[i].empty()) continue;
            int op=b[i].front();
            if(op<i) continue;
            if(seen.count(op) || seen.count(i)) continue;
            if(b[op].front() != i) continue;
            f=1;
            b[i].pop();
            b[op].pop();
            seen.emplace(op);
            seen.emplace(i);
        }
        ans ++;
        seen.clear();
    }
    rep(i,n){
        if(!b[i].empty()){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 8076
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
template<typename T = int, T mod = 1'000'000'007, typename U = long long>
struct umod{
    T val;
    umod(): val(0){}
    umod(U x){ x %= mod; if(x < 0) x += mod; val = x;}
    umod& operator += (umod oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
    umod& operator -= (umod oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
    umod& operator *= (umod oth){ val = ((U)val) * oth.val % mod; return *this; }
    umod& operator /= (umod oth){ return *this *= oth.inverse(); }
    umod& operator ^= (U oth){ return *this = pwr(*this, oth); }
    umod operator + (umod oth) const { return umod(*this) += oth; }
    umod operator - (umod oth) const { return umod(*this) -= oth; }
    umod operator * (umod oth) const { return umod(*this) *= oth; }
    umod operator / (umod oth) const { return umod(*this) /= oth; }
    umod operator ^ (long long oth) const { return umod(*this) ^= oth; }
    bool operator < (umod oth) const { return val < oth.val; }
    bool operator > (umod oth) const { return val > oth.val; }
    bool operator <= (umod oth) const { return val <= oth.val; }
    bool operator >= (umod oth) const { return val >= oth.val; }
    bool operator == (umod oth) const { return val == oth.val; }
    bool operator != (umod oth) const { return val != oth.val; }
    umod pwr(umod a, U b) const { umod r = 1; for(; b; a *= a, b >>= 1) if(b&1) r *= a; return r; }
    umod inverse() const {
        U a = val, b = mod, u = 1, v = 0;
        while(b){
            U t = a/b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        if(u < 0)
            u += mod;
        return u;
    }
};
using U = umod<>;
template<typename U>
struct NCR {
    vector<U> fact, ifact;
    NCR(int size){
        fact.resize(size + 1); ifact.resize(size + 1);
        fact[0] = 1;
        for(int i = 1; i <= size; i++) fact[i] = fact[i - 1] * i;
        ifact[size] = fact[size].inverse();
        for(int i = size - 1; i >= 0; i--) ifact[i] = ifact[i + 1] * (i + 1);
    }
    U ncr(int n, int r){
        if(n < r) return 0;
        return fact[n] * ifact[r] * ifact[n - r];
    }
};
using N = NCR<U>;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k; cin >> n >> k;
	N kit(n);
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	U ans = 0;
	for(int i = 0; i < n; i++){
		ans += kit.ncr(i, k - 1) * a[i];
		ans -= kit.ncr(n - i - 1, k - 1) * a[i];
	}
	cout << ans.val << '\n';
	return 0;
}


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

int main(){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  ll p[a],q[b],r[c];
  rep(i,0,a) cin>>p[i];
  rep(i,0,b) cin>>q[i];
  rep(i,0,c) cin>>r[i];
  sort(p,p+a);
  sort(q,q+b);
  sort(r,r+c);
  reverse(p,p+a);
  reverse(q,q+b);
  reverse(r,r+c);
  int d=0;
  int e=0;
  int f=0;
  ll ans=0;
  rep(i,0,x+y){
    if(f==c){
      if(d==x){
        ans+=q[e];
        e++;
      }
      else if(e==y){
        ans+=p[d];
        d++;
      }
      else{
        if(p[d]>=q[e]){
          ans+=p[d];
          d++;
        }
        else{
          ans+=q[e];
          e++;
        }
      }
    }
    else if(d==x){
      if(r[f]>=q[e]){
        ans+=r[f];
        f++;
      }
      else{
        ans+=q[e];
        e++;
      }
    }
    else if(e==y){
      if(r[f]>=p[d]){
        ans+=r[f];
        f++;
      }
      else{
        ans+=p[d];
        d++;
      }
    }
    else{
      if(r[f]>=p[d] && r[f]>=q[e]){
        ans+=r[f];
        f++;
      }
      else if(p[d]>=q[e]){
        ans+=p[d];
        d++;
      }
      else{
        ans+=q[e];
        e++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

S,W = Ints()

if S<=W:
    print('unsafe')
else:
    print('safe')

Measured memory_bytes: 61660
import sys


def root(x):
    if parent[x] < 0:
        return x
    else:
        parent[x] = root(parent[x])
        return parent[x]


def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return False
    else:
        if y > x:
            x, y = y, x
        parent[x] += parent[y]
        parent[y] = x
        return True


def size(node):
    return -parent[root(node)]

if __name__ == '__main__':
    input = sys.stdin.readline
    n, m = map(int, input().split())
    input_list = [list(map(int, input().split())) for _ in range(m)]
    parent = [-1] * n
    ans_list = []
    ans = int(n*(n-1)/2)
    for a, b in input_list[::-1]:
        ans_list.append(ans)
        tmp = size(a-1) * size(b-1)
        if unite(a-1, b-1):
            ans -= tmp

    for ans in ans_list[::-1]:
        print(ans)


Measured memory_bytes: 35596
i=61,f[],c,m,y;main(s){for(;~s?++f["=2>?J13IK<@V&"[-~--s]+y*12+*f]:~scanf("%d,%d,%d",f,&y,&s)?s*=4:++i<180?i%12>1?(y=f[i])?y>m?m=y:1:++c:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;

int x[100004], y[100004];
int sx[100004], sy[100004];
signed main(){
	int n, m, xx, yy;
	scanf("%lld%lld", &n, &m);
	for(int i = 1;i <= n;i++)scanf("%lld", &x[i]);
	for(int i = 1;i <= m;i++)scanf("%lld", &y[i]);
	xx = x[1], yy = y[1];
	if(xx < 0)for(int i = 1;i <= n;i++)x[i] = (x[i]-xx)%mod;
	if(yy < 0)for(int i = 1;i <= m;i++)y[i] = (y[i]-yy)%mod;
	
	for(int i = 1;i <= n;i++)sx[i] = (sx[i-1]+x[i])%mod;
	for(int i = 1;i <= m;i++)sy[i] = (sy[i-1]+y[i])%mod;
	
	int s = 0, b = 0;
	for(int i = 1;i < m;i++){
		int t = (2*mod+(sy[m]-sy[i])-((m-i)*y[i])%mod)%mod;
		b = (b+t)%mod;
	}
	for(int i = 1;i < n;i++){
		int a = (2*mod+(sx[n]-sx[i])-((n-i)*x[i])%mod)%mod;
		s = (s+a*b)%mod;
	}
	printf("%lld\n", s);
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bool check(int t, int x, int y, int tt, int xx, int yy){
  int step = tt - t;
  int dist = abs(xx-x) + abs(yy-y);
  if(step < dist) return false;
  if(step == dist) return true;
  if((step - dist)%2 == 0) return true;
  return false;
}


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

  int t = 0, x = 0, y = 0;
  bool ok = true;
  rep(i,N){
    int tt, xx, yy;
    cin >> tt >> xx >> yy;
    if(!check(t, x, y, tt, xx, yy)){
      ok = false;
      break;
    }
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}




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

signed main(){
	string s;
	while(cin >> s){
		if(s == "0") break;
		int amari = 0;
		ll dp[11] = {1},ans = 0;
		for(int i = 0;i < s.length();i++){
			if(i % 2) amari = (amari + s[i] - '0') % 11;
			else amari = (amari - (s[i] - '0') + 11) % 11;
			ans += dp[amari];
			if(i == s.length() - 1 || s[i + 1] != '0') dp[amari]++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b;
  cin >> a >> b;
  bool ok = a<=8&&b<=8;
  cout << (ok?"Yay!":":(") << endl;
}


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

int main(){
	int i;
	int n,r,p,c;
	while(cin>>n>>r,(n || r)){
		int huda[52],tmp[52];
		for(i=1;i<=n;i++){
			huda[i]=n-i+1;
		}
		while(r--){
			cin>>p>>c;
			for(i=1;i<p;i++)
				tmp[i]=huda[i];
			for(i=p;i<p+c;i++)
				huda[i-p+1]=huda[i];
			for(i=1;i<p;i++)
				huda[i+c]=tmp[i];
		}
		cout<<huda[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
##Educational-DP B
n,k = map(int,input().split())
h = tuple(map(int,input().split()))

dp = [float('inf')] * n
dp[0] = 0

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
        
#print(dp)
print(dp[-1])

Measured memory_bytes: 87732
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 3000;
/**/
int main() {
	// 入力
	ll R;cin>>R;
    
	// 解法
	double ans = R * 2 *M_PI;
	//出力
	printf("%.10f\n", ans);
}


Measured memory_bytes: 3724
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
struct Point{double x,y;};
struct Circle{Point x;double r;}c0,c1;
Point operator +(Point a,Point b){return (Point){a.x+b.x,a.y+b.y};}
Point operator -(Point a,Point b){return (Point){a.x-b.x,a.y-b.y};}
Point operator *(Point a,double b){return (Point){a.x*b,a.y*b};}
bool operator >(Point a,Point b){return a.x>b.x||(a.x==b.x&&a.y>b.y);}
double arg(Point a){return atan2(a.y,a.x);}
Point polar(double a,double b){return (Point){a*cos(b),a*sin(b)};}
double norm(Point a){return a.x*a.x+a.y*a.y;}
double abs(Point a){return sqrt(norm(a));}
void read(Point &a){a.x=read(),a.y=read();}
void read(Circle &a){read(a.x),a.r=read();}
void print(Point a){printf("%.8lf %.8lf",a.x,a.y);}
pair<Point,Point>getintersection(Circle c0,Circle c1)
{
	double t=arg(c1.x-c0.x),d=abs(c1.x-c0.x);
	double a=acos((c0.r*c0.r+d*d-c1.r*c1.r)/(2*d*c0.r));
	return make_pair(c0.x+polar(c0.r,t+a),c0.x+polar(c0.r,t-a));
}
int main()
{
	read(c0),read(c1);
	pair<Point,Point>ans=getintersection(c0,c1);
	if(ans.first>ans.second)swap(ans.first,ans.second);
	print(ans.first);putchar(' ');print(ans.second);
	return printf("\n"),0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	ll N, A, B; cin >> N >> A >> B;
	ll q = N / (A + B), r = N % (A + B);
	ll ans = A * q + min(r, A);
	cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#APC1 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a % b == 0:
  print(-1)
else:
  print(a)
  


Measured memory_bytes: 38256
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
using namespace std;

int i;
string s, x;

int main()
{
    cin >> s;
    for (i = 0; i < s.size(); i++) {
        if (s[i] == 'B' && x.size()) x.pop_back();
        else if (s[i] != 'B') x += s[i];
    }
    cout << x << endl;
    return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();
        final int A = sc.nextInt();
        final int B = sc.nextInt();

        int ans = 0;
        for (int i = 1; i <= N; i++) {
            int sum = Arrays.stream(String.valueOf(i).split("")).mapToInt(Integer::valueOf).sum();
            if (A <= sum && sum <= B) ans += i;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 40532
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int x,y;
	bool flag=false;
	for(int i=0;i<s.length();i++){
		if(s[i]=='A'&&flag==false){
			x=i;
			flag=true;
		}
		else if(s[i]=='Z')
		{
			y=i;
		}
	}
	cout<<y-x+1;
}

Measured memory_bytes: 640
n = int(raw_input())
a = map(int,raw_input().split())

count = 0
result = []
x=[0]*n
for i in xrange(n,0,-1):
    total = 0
    for j in xrange(i,n+1,i):
        total += x[j-1]
    if  total % 2 != a[i-1]:
        x[i-1]=1
        result.append(i)
    else:
        pass
print len(result)
print ' '.join(map(str,result))

Measured memory_bytes: 17428
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 2510;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
struct Edge{
    ll from,to,cost;
};
class Bellman_Ford{
    private:
        vector<Edge> edges;
        vector<ll> d;
        ll V;
    public:
        Bellman_Ford(vector<Edge>& g,ll v):edges(g),V(v){
            d.resize(v,INF);
        }
        bool bellman_ford(ll s){
            d[s] = 0;
            rep(i,V){
                rep(j,edges.size()){
                    Edge e = edges[j];
                    if(d[e.from] != INF && d[e.to] > d[e.from]+e.cost){
                        d[e.to] = d[e.from]+e.cost;
                        if (i == V-1) return true;
                    }
                }
            }
            return false;
        }
        ll operator[](ll a){
            return d[a];
        }
};
vector<vector<ll>> g(2510);
vector<bool> done(2510,0);
void dfs(ll v){
    done[v] = true;
    for (ll u:g[v]){
        if (done[u]) continue;
        dfs(u);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll p,a,b,c,v,e;
    cin >> v >> e >> p;
    vector<vector<ll>> graph(e,vector<ll>(3));
    rep(i,e){
        cin >> a >> b >> c;
        c -= p;
        c *= -1;
        --a;
        --b;
        g[b].push_back(a);
        graph[i] = {a,b,c};
    }
    dfs(v-1);
    vector<Edge> ng;
    rep(i,e){
        if (done[graph[i][0]] && done[graph[i][1]]){
            ng.push_back(Edge{graph[i][0],graph[i][1],graph[i][2]});
        }
    }
    Bellman_Ford solve(ng,v);
    if (solve.bellman_ford(0)) PRINT(-1);
    else{
        PRINT((-solve[v-1] < 0 ? 0 : -solve[v-1]));
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s;
    cin >> s;
    string a = "";
    vector<int> v;
    int k = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != 'x') {
            a += s[i];
            v.push_back(k);
            k = 0;
        }
        else {
            k++;
        }
    }
    v.push_back(k);
    string b = a;
    reverse(b.begin(), b.end());
    if (a != b) {
        puts("-1");
        return 0;
    }
    int ans = 0;
    for (int l = 0, r = v.size()-1; l < r; l++, r--) {
        ans += abs(v[l]-v[r]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
int main() {
    int Q;
    cin >> Q;
    vector<int> v;
    while (Q--) {
        int q;
        cin >> q;
        if (q == 0) {
            int x;
            cin >> x;
            v.push_back(x);
        } else if (q == 1) {
            int x;
            cin >> x;
            cout << v[x] << endl;
        } else {
            v.pop_back();
        }
    }
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int n;
	cin >> n;
	string c;
	cin >> c;
	int r = 0;
	int w = 0;
	for (int i = 0; i < n; i++) {
		if (c[i] == 'R') r++;
		else w++;
	}
	int minv = min(r, w);

	int sub = 0;
	for (int i = 0; i < r; i++) {
		if (c[i] == 'R') sub++;
	}

	cout << min(r-sub, minv) << endl;
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)



int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll count_A = 0;
    ll count_B = 0;
    ll count_C = 0;
    ll ans;
    while (A > 0 && count_A < K) {
        A -= 1;
        count_A += 1;
    }
    while (B > 0 && (count_A + count_B) < K)
    {
        B -= 1;
        count_B += 1;
    }
    while (C > 0 && (count_A + count_B + count_C) < K)
    {
        C -= 1;
        count_C += 1;
    }
    ans = count_A - count_C;
    cout << ans << endl;
}


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

int main() {
  int N, M, S;
  cin >> N;
  string strN[N];
  for (int i = 0; i < N; i++)
    cin >> strN[i];
  cin >> M;
  string strM[M];
  for (int i = 0; i < M; i++)
    cin >> strM[i];
  vector<int> s(N);
  
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (strN[i] == strN[j])
        s.at(i)++;
    }
    for (int j = 0; j < M; j++){
      if (strN[i] == strM[j])
        s.at(i)--;
    }
    if (S < s.at(i))
      S = s.at(i);
  }
  cout << S << endl;         
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const double Pi=acos(-1.0);
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=0;
    int tmp=min(a,d);
    ans+=tmp;
    d-=tmp;
    tmp=min(b,d);
    d-=tmp;
    tmp=min(c,d);
    ans-=tmp;
    cout<<ans;
}

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

int N, M;
ll K;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M >> K;
	vector<ll> A(N), B(M);
	for(int i=0; i<N; i++)
		cin >> A[i];
	for(int i=0; i<M; i++)
		cin >> B[i];
	// front 부터 빼내기.
	ll sum = 0;
	for(int i=0; i<N; i++)
		sum += A[i];

	int j = 0, res = 0, cnt = N;
	for(int i=N-1; i>=0; i--)
	{
		while (j<M && K-sum >= B[j]) sum += B[j++], cnt++;
		
		if (sum <= K) res = max(res, cnt);

		sum -= A[i]; cnt--;
	}
	while (j<M && K-sum >= B[j]) sum += B[j++], cnt++;
	if (sum <= K) res = max(res, cnt);

	cout << res;
	return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector <int> > path(n, vector<int>(n,0));
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        path[a-1][b-1]=1;
        path[b-1][a-1]=1;
    }
    vector<int> order(n-1);
    for(int i=1;i<n;i++){
        order[i-1]=i;
    }
    int ans=0;
    do{
        int count=0;
        if (path[0][order[0]]==1) count++;
        else continue;
        for(int i=0;i<n-2;i++){
            if(path[order[i]][order[i+1]]==1)count++;
        }
        if(count==n-1) ans++;
    }while(next_permutation(order.begin(),order.end()));
    cout<<ans<<endl;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }
  bool can = true;
  int hi;
  if (H.at(0) >= 1)
  {
    hi = H.at(0) - 1;
  }
  else
  {
    hi = H.at(0);
  }
  int now;
  for (int i = 1; i < N; i++)
  {
    if (hi - H.at(i) >= 1)
    {
      can = false;
      break;
    }
    else
    {
      if (H.at(i) == hi)
        continue;
      else
        hi = H.at(i) - 1;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


int main() {
	long long int n; std::cin >> n;
	long long int sum = 0;
	for (auto i = 0; i < n; ++i) {
		int v; std::cin >> v;
		sum += v;
	}
	std::cout << sum - n * (n + 1) / 2 << std::endl;
}


Measured memory_bytes: 3116
#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);
////////////////////////////

int main(){
    ll n;cin>>n;
    ll t[n];
    ll sum=0;
    rep(i,0,n-1){
        cin>>t[i];
        sum+=t[i];
    }
    ll m;cin>>m;
    ll p[m],x[m];
    ll ans[m];
    rep(i,0,m-1){
        cin>>p[i]>>x[i];
        ans[i]=sum+(x[i]-t[p[i]-1]);
    }
    rep(i,0,m-1){
        cout<<ans[i]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict


n=IN()
a=LI()
q=IN()
d=defaultdict(int)
for i in range(n):
    d[a[i]]+=1
s=sum(a)
for i in range(q):
    x,y=MAP()
    s+=(y-x)*d[x]
    d[y]+=d[x]
    d[x]=0
    print(s)
        


Measured memory_bytes: 24172
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;
const int MOD = 1e9+7;
ll fact( int c ){if( c == 1 || c == 0 )return 1;else return c * fact( c -1 );}
ll npr( int a, int b ){return ( fact( a ) / fact( a -b ) );}
ll ncr( int a, int b ){return ( fact( a ) / ( fact( b ) * fact( a -b ) ) );}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif*/
   int n;
   cin>>n;
   set<int>s;
   for(int i=0;i<n;i++)
   {
     ll x;
     cin>>x;
     if(s.count(x))
        s.erase(x);
     else
        s.insert(x);
   }
   cout<<(int)s.size();
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if((a==b && a!=c) || (b==c && b!=a) ||  (c==a && c!=b)){
     cout << "Yes" << endl;
  }else{
     cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256