akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,K,H[305];
vector<int>x={0};
int dp[305][305][305];
signed main(){
	cin>>N>>K;
	rep(i,N){
		cin>>H[i];x.pb(H[i]);
	}
	sort(all(x));x.erase(unique(all(x)),x.end());
	int M=len(x);
	rep(i,N+1)rep(j,K+1)rep(k,M)dp[i][j][k]=inf;
	dp[0][0][0]=0;
	rep(i,N){
		H[i]=lower_bound(all(x),H[i])-x.begin();
		int memo1[305][305],memo2[305][305];
		rep(j,i+2)rep(k,M)memo1[j][k]=memo2[j][k]=inf;
		rep(j,i+1){
			rep(k,M){
				chmin(dp[i+1][j][H[i]],dp[i][j][k]+max(0ll,x[H[i]]-x[k]));
				chmin(memo1[j+1][k],dp[i][j][k]);
				chmin(memo2[j+1][k],dp[i][j][k]);
			}
		}
		rep(j,i+2)for(int k=M-1;k>0;k--){
			chmin(memo1[j][k-1],memo1[j][k]);
		}
		rep(j,i+2)rep(k,M-1){
			chmin(memo2[j][k+1],memo2[j][k]+x[k+1]-x[k]);
		}
		rep(j,i+2)rep(k,M){
			chmin(dp[i+1][j][k],min(memo1[j][k],memo2[j][k]));
		}
	}
	int ans=inf;
	rep(i,M)chmin(ans,dp[N][K][i]);
	cout<<ans<<endl;
}


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

int main(){
  int num[31]={0};
  for(int i=0;i<28;i++){
    int a;
    cin>> a;
    num[a]=1;
  }

  for(int i=1;i<31;i++){
    if(num[i]==0) cout<< i<< endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

#include <iostream>
 
int main(void)
{
    int64_t A, B;
    std::cin >> A >> B;

    int64_t sum = A + B;

    if (sum % 2 == 1) {
        std::cout << "IMPOSSIBLE" << std::endl;
        return 0;
    }

    sum /= 2;

    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstdio>
using namespace std;
#define PI acos(-1,0)
#define eps 1e-10
#define ll long long
#define mst(ss,b) memset((ss),(b),sizeof(ss))
using namespace std;
int main()
{
    int flag=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length()-1;i++)
    {
        if(s[i]==s[i+1])
        {
            cout<<i+1<<" "<<i+2<<endl;
            flag=1;
            break;
        }
        else if(i<s.length()-2&&s[i]==s[i+2])
        {
            cout<<i+1<<" "<<i+3<<endl;
            flag=1;
            break;
        }
    }
    if(flag!=1)
    cout<<-1<<" "<<-1<<endl;
    return 0;
}


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

int main(int argc, char const *argv[])
{
    int n, d;
    cin >> n >> d;
    vector<vector<int>> X(n, vector<int>(d));
    for(int i = 0; i < n; i++)  {
        for(int j = 0; j < d; j++) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        for(int j= i + 1; j < n; j++) {
            int diff = 0;
            for(int k = 0; k < d; k++) {
                diff += pow(X[i][k] - X[j][k], 2);
            }
            bool flag = false;
            for(int k = 1 ; k <= diff; k++) {
                if(k * k == diff) {
                    flag = true;
                    break;
                }
            }
            if(flag) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  cin >> s;
  int s1 = s / 100, s2 = (s - s1 * 100) / 10 , s3 = s -s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))


def readmap():
    return map(int, input().split())


N = read()
L = readlist()
L.sort()
if sum(L[:(N-1)]) > L[N-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(n-(a+b-c));
	}

}



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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

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

const int MAX_N = 202;

int main(){
  ll K; cin >> K ;
  ll k,r,N;
  N = 50;
  k = K / N; r = K % N;
  ll a = N - 1 + k - r;
  ll b = 2 * N - r + k;
  cout << N << endl;
  rep(i,N-r) cout << a << " ";
  rep(i,r) cout << b << " ";
  cout << "" << endl;
  return 0;
}

Measured memory_bytes: 256
// ツ姪債擬ツ地ツ凝ヲツ予ツ選2010 H. Road Construction

#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

typedef vector< vector< pair<int, pair<int, int> > > > graph;

class Node{
public:
	int pos, dist, cost;
	Node(int pos, int dist, int cost) : pos(pos), dist(dist), cost(cost) {}
	bool operator < (const Node &nd) const { 
		return make_pair(dist, cost) > make_pair(nd.dist, nd.cost); 
	}
};

int main(){
	int N, M;
	static int dist[10000];
	static bool visit[10000];
	while(cin >> N >> M, N){
		graph g(N);
		for(int i=0;i<M;i++){
			int u, v, d, c; cin >> u >> v >> d >> c;
			g[u-1].push_back(make_pair(v-1, make_pair(d, c)));
			g[v-1].push_back(make_pair(u-1, make_pair(d, c)));
		}
		int ans = 0;
		memset(dist, -1, sizeof(dist));
		memset(visit, false, sizeof(visit));
		dist[0] = 0;
		priority_queue<Node> qu; qu.push(Node(0, 0, 0));
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			int pos = nd.pos, d = nd.dist;
			if(dist[pos]!=-1 && dist[pos] < d) continue;
			if(visit[pos]) continue;
			visit[pos] = true;
			ans += nd.cost;
			for(int i=0;i<g[pos].size();i++){
				int next = g[pos][i].first;
				if(dist[next]==-1 || dist[next] >= dist[pos] + g[pos][i].second.first){
					dist[next] = dist[pos] + g[pos][i].second.first;
					qu.push(Node(next, dist[next], g[pos][i].second.second));
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1976
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

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

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

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


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  int n,m;
  cin>>n>>m;
  map<int,vector<int> > p;
  for(int i = 0; i < n; i++){
    int a,b;
    cin>>a>>b;
    p[a].push_back(b);
  }
  ll sum = 0;
  priority_queue<int> q;
  for(int i = 0; i <= m; i++){
    for(int j = 0; j < p[i].size(); j++){
      // cout<<p[i][j]<<endl;
      q.push(p[i][j]);
    }
    if(q.size()!=0){
      sum+=q.top();
      q.pop();
    }
  }
  cout<<sum<<endl;
  return 0;
}



Measured memory_bytes: 10880
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        string s;
        cin>>s;
        sort(all(s));
        if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]){
            cout<<"Yes";
         
     }
     else cout<<"No";
        }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)

main :: IO ()
main = do
  t <- readLn
  unless (t == 0) $ do
    solve t <$> replicateM 9 (read <$> getLine) >>= print
    main

solve :: Int -> [Int] -> Int
solve t xs = t - (sum xs)



Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N,M,X,b=0,c=0;
	cin >> N >> M >> X;
	for(int i=0;i<M;i++)
	{
		int a;
		cin >> a;
		if(a>X)
			b++;
		else 
			c++;
	}
	cout << min(b,c);
}

Measured memory_bytes: 256
n = int(input())  # 6
a = list(map(int, input().split()))  # [1, 4, 3, 6, 2, 5]
print(' '.join([str(n) for n in a]))

for i in range(1, len(a)):
	j = a[i]
	for k in range(i - 1, -1, -1):
		if a[k] > j:
			a[k + 1] = a[k]
			a[k] = j
	print(' '.join([str(n) for n in a]))



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ll n;
  cin >> n;
  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0, go = 5;
  while (go <= n) {
    ll res = n / go;
    debug(res);
    ans += res/2;
    go *= 5;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sc scanf
#define pr printf
#define pb push_back
#define EPS 1e-10

using namespace std;

typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;


int main() {
	string s;
	cin >> s;
	int ant = 0;
	int chain = 1;
	int limchain = 1000000000;
	ll sum = 0;
	for(char ch: s) {
		if (ch == '<') {
			ant++;
			sum += ant;
			limchain = 1000000000;
			chain = 1;
		} else {
			if (ant == 0) {
				if (!(limchain > chain)) sum++;
				sum += chain;
				chain++;
			} else {
				limchain = ant;
				ant = 0;
				chain = 1;
				sum += ant;
			}
		}
	}
	pr("%lld\n", sum);
	
	return 0;
}


Measured memory_bytes: 900
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    X = [int(i) for i in readline().split()]

    ans = float('inf')
    for i in range(1,101):
        tmp = 0
        for x in X:
            tmp += (x - i)**2
        
        if tmp < ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    vector<int> b(m);
    vector<int> c(n,0);
    rep(i,m){
        cin>>a.at(i)>>b.at(i);
        cout<<endl;
    }
    rep(i,m){
        c.at(a.at(i)-1)++;
        c.at(b.at(i)-1)++;
    }
    rep(i,n){
        cout<<c.at(i)<<endl;
    }

    cout<<endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<set>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	set<string> str_set;

	string str;
	cin>>str;

	int K;
	cin>>K;
	
	int ma_r = str.size();

	ma_r = min(ma_r,K);

	for(int r = 1; r <= ma_r; r++){
		for(int i = 0; i + r <= str.size(); i++){
			auto s = str.substr(i,r);
			str_set.insert(s);
		}
	}


	auto itr = str_set.begin();

	REP(i,(K-1))itr++;

	cout<<*itr<<endl;

	return 0;

}



Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#define int long long
using namespace std;

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> a(N), b(N);
  int sa = 0, sb = 0;
  for(int i = 0; i < N; ++i) cin >> a[i], sa += a[i];
  for(int i = 0; i < N; ++i) cin >> b[i], sb += b[i];
  int t = sa - sb;
  int cnt = 0;
  for(int i = 0; i < N; i++) {
    if(b[i] <= a[i]) cnt += a[i] - b[i];
    else cnt -= (b[i] - a[i]) / 2;
  }
  cout << (cnt > 0 ? "No" : "Yes") << endl;
  return 0;
}


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

#define INF (ll)9999999999999999
#define log(x) cout << (x) << endl
using ll = long long;

ll mn = INF;
int dp[100][100][100]={0};
void solve(int a,int b,int c,ll x) {
	if (a==b && b==c) {
		mn = min(mn, x);
		return;
	}
	if (dp[a][b][c]) return;
	dp[a][b][c]=1;
	if (a>70||b>70||c>70) return;

	solve(a+2,b,c,x+1);
	solve(a,b+2,c,x+1);
	solve(a,b,c+2,x+1);
	solve(a+1,b+1,c,x+1);
	solve(a+1,b,c+1,x+1);
	solve(a,b+1,c+1,x+1);
}

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

	solve(a,b,c,0);

	log(mn);
	return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;

ll a[200010],ans=0;
int main(){
    int n;
    scanf("%d",&n);
    rep(i,0,n) scanf("%lld",&a[i]);
    sort(a,a+n,greater<ll>());
    ans+=a[0];
    rep(i,2,n) ans+=a[i/2];
    printf("%lld",ans);
}


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

int main() {
  long long h;
  cin >> h;

  long long num = 0;
  long long e = 1;
  while(h != 1){
    h /= 2;
    num += e;
    e *= 2;
  }

  num += e;

  cout << num << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){ 
    int n,k,x,y,res=0;
    cin >> n >> k >> x >> y;
    if(n < k) cout <<  x * n << endl;
    else cout <<  x * k + (n-k) * y<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

string itos(int n){
	stringstream ss; ss << n;
	return ss.str();
}
string get(int n){
	if(n % 15 == 0)return "FizzBuzz";
	if(n % 3 == 0)return "Fizz";	
	if(n % 5 == 0)return "Buzz";
	return itos(n);
}
int main(){
	int m,n;
	while(cin >> m >> n && m){
		vector<int> p(m);
		rep(i,m)p[i] = i;
		int pos = 0;
		rep(i,n){
			string t;
			cin >> t;
			if(p.size() == 1) continue;
			if(t == get(i+1) ) pos++;
			else p.erase(remove(p.begin(),p.end(),p[pos]),p.end());
			pos %= p.size();
		}
		rep(i,p.size())
			cout << p[i]+1 << (i == p.size()-1?"\n":" ");
	}
}

Measured memory_bytes: 940
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

int N;
vector<int> A, B;

int main() {
	cin >> N;
	A.assign(N, 0);
	B.assign(N, 0);
	for (int i = 0; i < N; i++)
		cin >> A[i] >> B[i];
	vector<pii> Bi_sorted(N);
	for (int i = 0; i < N; i++)
		Bi_sorted[i] = pii(B[i], i);
	sort(Bi_sorted.begin(), Bi_sorted.end());
	ll t = 0;
	bool is_ok = true;
	for (const auto& e : Bi_sorted)
	{
		int b = e.first;
		int i = e.second;
		t += A[i];
		if (t > b) {
			is_ok = false;
			break;
		}
	}
	string ans;
	if (is_ok)
		ans = "Yes";
	else
		ans = "No";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	//ABC162 A
	string n;
	// N (3桁の整数)

	cin >> n;

	if (n.find("7") != -1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
	int array[4][52] = {0};
	int n, i, j;
	char mark;
	scanf("%d", &n);
	for(i=0;i<=n;i++){
		scanf("%c %d\n", &mark, &j);
		switch(mark){
		case 'S':
			array[0][j] = 1;
			break;
		case 'H':
			array[1][j] = 1;
			break;
		case 'C':
			array[2][j] = 1;
			break;
		case 'D':
			array[3][j] = 1;
			break;
		}
	}
	for(i=0;i<4;i++){
		for(j=1;j<=13;j++){
			if(array[i][j] == 0){
				switch(i){
				case 0:
					printf("S %d\n", j);
					break;
				case 1:
					printf("H %d\n", j);
					break;
				case 2:
					printf("C %d\n", j);
					break;
				case 3:
					printf("D %d\n", j);
					break;
				}
			}
		}
	}
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }

int main(){
    ll a[3][3] = {},b[3][3] = {};
    rep(i,0,3) rep(j,0,3) cin >> b[i][j];
    
    ll n;
    cin >> n;
    rep(i,0,n){
        ll x;
        cin >> x;
        rep(j,0,3){
            rep(k,0,3){
                if(b[j][k] == x) a[j][k] = 1;
            }
        }
    }

    bool flag = false;
    rep(i,0,3) if(a[i][0] == a[i][1] && a[i][1] == a[i][2] && a[i][0] == 1) flag = true;
    rep(i,0,3) if(a[0][i] == a[1][i] && a[1][i] == a[2][i] && a[0][i] == 1) flag = true;
    if(a[0][0] == a[1][1] && a[1][1] == a[2][2] && a[1][1] == 1) flag = true;
    if(a[0][2] == a[1][1] && a[1][1] == a[2][0] && a[1][1] == 1) flag = true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=2e5+5;
const LL mod=1e9+7;
int read() {
	char ch=getchar();int x=0,f=1;
	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;
}
int gcd_(int a,int b) {return b==0?a:gcd_(b,a%b);}
LL fpow(LL a,LL b) {
	LL res=1;
	while(b) {
		if(b&1) res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
LL num[maxn];
bool cmp(LL a,LL b) {
	return a>b;
}
int main() {
//	cout<<"Accepted!\n";
	int n;
	cin>>n;
	LL res=0;
	for(int i=0;i<n;++i) {
		cin>>num[i];
	}
	sort(num,num+n,cmp);
	int k=n/2;
	for(int i=0;i<k;++i) {
		if(i) res+=2*num[i];
		else res+=num[i];
	} 
	if(n%2) res+=num[k];
	cout<<res;
	return 0;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

set<int> make_prime_set(int lim){
  set<int> ps;
  vector<bool> chk(lim+1, true);
  chk.at(0) = chk.at(1) = false;
  rep2(i, 2, chk.size()){
    if(chk.at(i) == false) continue;
    ps.insert(i);
    for(int j = i+i; j < chk.size(); j +=i) chk.at(j) = false;
  }
  return ps;
}

int main(){
  auto ps = make_prime_set(1e6);
  int a;
  cin >> a;
  cout << *ps.lower_bound(a) << endl;
  return 0;
}

Measured memory_bytes: 7452
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<String> box = new ArrayList<>();
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            box.add(sc.next());
        }
        List<String> list = new ArrayList<String>(new LinkedHashSet<>(box));
        System.out.println(list.size());
    }
}

Measured memory_bytes: 73508
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n,m,x;
    cin >> n >> m >> x;
    vvll che(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<=m;j++){
            ll d;
            cin >>d;
            che.at(i).push_back(d);
        }
    }
    ll ans = 1e17;
    for(int bit=0;bit<=pow(2,n);bit++){
        ll money = 0;
        vector<ll>skill(m,0);
        for(int j=0;j<n;j++){
            if(bit&(1<<j)){
                for(int k=0;k<che.at(j).size();k++){
                    if(k==0){
                        money+=che.at(j).at(k);
                    }
                    else{
                        skill.at(k-1)+=che.at(j).at(k);
                    }
                }
                bool ok = 1;
                for(int k=0;k<m;k++){
                    if(skill.at(k)<x)ok=0;
                }
                if(ok){
                    ans = min(ans,money);
                }
            }
        }
    }
    if(ans==1e17){
        cout<<-1<<endl;
        return 0;
    }
    cout << ans<<endl;
}
    



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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ELRU {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m, q; cin >> n >> m >> q;
      vector<int> a(q);
      rep(i, q) {
        cin >> a[i];
      }
      reverse(all(a));
      // value, pos
      map<int, int> used;
      vector<int> cnt;
      vector<int> rev;
      rep(i, q) {
        if (used.find(a[i]) == used.end()) {
          used[a[i]] = cnt.size();
          cnt.push_back(1);
          rev.push_back(a[i]);
        } else {
          int pos = used[a[i]];
          if (pos == 0 || cnt[pos-1] > cnt[pos]) {
            cnt[pos]++;
          }
        }
      }

      bool flag = true;
      bool flag2 = true;
      set<int> st;
      for(int i=1; i<=m; i++) {
        st.insert(i);
      }
      for(int i=0; i<cnt.size(); i++) {
        if (cnt[i] < n) {
          flag = false;
        }
        if (!flag && rev[i] != *st.begin()) {
          flag2 = false;
        }
        st.erase(rev[i]);
      }
      if (flag || flag2) {
        cout << "Yes" << endl;
        return;
      }
      cout << "No" << endl;
    }
};

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

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

cnt=0
last=a[n]
for i in range(n):
    if b[i]>=a[i]:
        cnt+=min(b[i], a[i]+a[i+1])
        a[i+1]=max(0, a[i+1]-(b[i]-a[i]))
        a[i]=0
    else:
        cnt+=b[i]
        a[i]=a[i]-b[i]
print(cnt)


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const int maxN = 1e6 + 5;
const int MAX = 2e3 + 7;

int n;
ll cost[MAX][MAX];
ll change;

int cnt(int i, int range) {
	if (i - range > 0) return i - range;
	return (i - range) + n;
}

int main() {
	scanf("%d%lld",&n,&change);
	RI(i, n)
		scanf("%lld",&cost[i][0]);
	RI(i, n) {
		RI(j, n) {
			cost[i][j] = min(cost[i][j - 1], cost[cnt(i, j)][0]);
		}
	}
	
	
	ll ans = inf;
	REP(i, n + 1) {
		ll sum = change * (long long)i;
		RI(j, n) {
			sum += cost[j][i];
		}
		mini(ans, sum);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 31616
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC081C_NotSoDiverse();

#if 1
int main()
{
	ABC081C_NotSoDiverse();
	fflush(stdout);
	return 0;
}
#endif

static void ABC081C_NotSoDiverse()
{
	int N, K;
	get2int(N, K);

	std::map<int, int> balls;
	for (int i = 0; i < N; i++) {
		int num;
		get1int(num);
		balls[num]++;
	}
	
	int surp = (int)balls.size() - K;
	if (surp <= 0) {
		printf("0\n");
		return;
	}

	std::vector<int> counts;
	for (auto it = balls.begin(); it != balls.end(); it++) {
		counts.push_back(it->second);
	}

	std::sort(counts.begin(), counts.end());

	int minCount = 0;
	for (int i = 0; i < surp; i++) {
		minCount += counts[i];
	}
	printf("%d\n", minCount);
}


Measured memory_bytes: 10748
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int dp[200000];
    dp[0]=0;
    cin>>N;
    for(int i=1;i<200001;i++){
        dp[i]=9999999;
    }
    for(int i=0;i<N;i++){
        if(dp[i]+1<dp[i+1]){
            dp[i+1]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+6]){
            dp[i+6]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+9]){
            dp[i+9]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+36]){
            dp[i+36]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+81]){
            dp[i+81]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+216]){
            dp[i+216]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+729]){
            dp[i+729]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+1296]){
            dp[i+1296]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+6561]){
            dp[i+6561]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+7776]){
            dp[i+7776]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+46656]){
            dp[i+46656]=dp[i]+1;
        }
        if(dp[i]+1<dp[i+59049]){
            dp[i+59049]=dp[i]+1;
        }
        
    }
    cout << dp[N] <<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    char ch;
    cin >> ch;
    cout << (ch >= 'a' && ch <= 'z' ? "a" : "A") << endl;
    return 0;
}


Measured memory_bytes: 3664
def d_igeta(N, M, X, Y):
    tmp1 = 0
    tmp2 = 0
    for k, x in enumerate(X):
        k += 1
        tmp1 += (k - 1) * x - (N - k) * x
    for k, y in enumerate(Y):
        k += 1
        tmp2 += (k - 1) * y - (M - k) * y
    return (tmp1 * tmp2) % (10**9 + 7)

N,M = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
print(d_igeta(N, M, X, Y))

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a % 3 && b % 3 && (a + b) % 3) cout << "Impossible" << endl;
    else cout << "Possible" << endl;
}

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

int N,Z,W;
int A[100010];

int main()
{
    scanf("%d%d%d",&N,&Z,&W);
    for(int i = 0; i < N; i++)scanf("%d",A + i);
    if(N == 1)printf("%d\n",abs(W - A[0]));
    else printf("%d\n",max(abs(W - A[N - 1]),abs(A[N - 2] - A[N - 1])));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        for (int i = 0; i < n; i++){
            numberArray[i] = sc.nextInt();
        }

        int count = 0;

        for (int i = 0; i < n; i++){
            int minIndex = i;
            for (int j = i; j < n; j++){
                if (numberArray[j] < numberArray[minIndex]){
                    minIndex = j;
                }
            }
            if(i != minIndex){
                int before = numberArray[i];
                numberArray[i] = numberArray[minIndex];
                numberArray[minIndex] = before;
                count++;
            }
        }

        StringJoiner sj = new StringJoiner(" ");
        Arrays.stream(numberArray).forEach(i -> sj.add(String.valueOf(i)));
        System.out.println(sj.toString());
        System.out.println(count);

    }

}


Measured memory_bytes: 32228
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long p = scan.nextLong();
        long m = scan.nextLong();
        long ans = p;
        while (p > m){
            p = p%m;
            ans = Math.min(ans,p);
        }
        System.out.println(Math.min(ans,Math.abs(p-m)));
    }
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int A, B;
    cin >> A >> B;

    A -= B * 2;
    if(A < 0) { A = 0; }

    printf("%lld\n", A);

    return 0;
}


Measured memory_bytes: 256
// C++ 14
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>

#define ll long long
#define loop(x, start, end) for(int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)

using namespace std;


int main(void) {
  int n, v, c, l;
  cin >> n;

  int mat[n][n];

  loop(i,0,n) {
    loop(j,0,n) {
      mat[i][j] = 0;
    }
  }

  loop(i, 0, n) {
    cin >> v >> c;
    loop(j,0,c) {
      cin >> l;
      mat[v-1][l-1] = 1;
    }
  }

  loop(i,0,n) {
    loop(j,0,n) {
      if (j) cout << " ";
      cout << mat[i][j];
    }
    cout << endl;
  }
}



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

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);

ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<vector<ll>> matrix;

char s[1000000];
char t[1000000];
int main() {
  ll n, m;
  scanf("%lld %lld\n%s%s", &n, &m, s, t);
  ll ret = n*m/__gcd(n,m);
  map<ll, char> dp;
  for(int i = 0; i < n; i++) {
    dp[(ret/n)*i] = s[i];
  }
  for(int i = 0; i < m; i++) {
    ll want = (ret/m) * i;
    if(dp.count(want) && dp[want] != t[i]) {
      printf("-1\n");
      return 0;
    }
  }
  printf("%lld\n", ret);
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<P>a(n+1);
  rep(i,0,n){
    cin>>a[i].fi;
    a[i].fi*=-1;
    a[i].se=i;
  }
  a[n]=MP(0,n);
  sort(ALL(a));
  vector<ll>ret(n);
  buf=a[0].fi;
  ll idx=a[0].se;
  rep(i,1,n+1){
    if(idx>a[i].se){
      ret[idx]+=(a[i].fi-buf)*i;
      buf=a[i].fi;
      idx=a[i].se;
    }
    else{
      ret[idx]+=(a[i].fi-buf)*i;
      buf=a[i].fi;
    }
  }
  rep(i,0,n)cout<<ret[i]<<endl;
  return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int dist = 1; dist < n; dist++){
        int cnt = 0;
        for(int i = 0; i + dist < n; i++){
            if(s[i] == s[i + dist] && cnt < dist) cnt++;
            else cnt = 0;
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using ii = pair<int,int>;

#define ff first
#define ss second

const int maxn = 1e5+10;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,k;
	ll ans=0;
	cin >> a >> b >> c >> k;
	ans+=min(a,k);
	k=max(0,k-a);
	k=max(0,k-b);
	ans-=min(k,c);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>

struct edge
{
	int a, b;
	long long int w;
};

bool compare(const edge x, const edge y)
{
	return x.w < y.w;
}

/*long long int sums[310] = { 0 }, roots[310] = { 0 };

void initialize(int n)
{
	for (int i = 0; i < n; ++i)
	{
		sums[i] = 1;
		roots[i] = i;
	}
}

int root(int index)
{
	while (roots[index] != index)
	{
		roots[index] = roots[roots[index]];
		index = roots[index];
	}
	
	return index;
}

void makeUnion(int a, int b)
{
	int rootOfA = root(a), rootOfB = root(b);
	if (sums[rootOfA] >= sums[rootOfB])
	{
		sums[rootOfA] += sums[rootOfB];
		roots[rootOfB] = roots[rootOfA];
	}
	else
	{
		sums[rootOfB] += sums[rootOfA];
		roots[rootOfA] = roots[rootOfB];
	}
}
*/
int main()
{
	int n;
	long long int a[310][310] = { 0 };
	std::cin >> n;
	
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			std::cin >> a[i][j];
		}
	}
	
	for (int k = 0; k < n; ++k)
	{
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < n; ++j)
			{
				if (a[i][k] + a[k][j] < a[i][j] || (a[i][j] == 0 && (i != j)))
				{
					std::cout << -1;
					return 0;
				}
			}
		}
	}
	
	long long int ans = 0;
	
	for (int i = 0; i < n; ++i)
	{
		for (int j = i; j < n; ++j)
		{
			bool flag = true;
			for (int k = 0; k < n; ++k)
			{
				if (a[i][k] + a[k][j] == a[i][j] && i != j && i != k && j != k)
				{
					flag = false;
				}
			}
			
			if (flag)
			{
				ans += a[i][j];
			//	std::cout << i << " " << j << "\n";
			}
		}
	}
	
	std::cout << ans;
	
/*	edge edges[10010];
	int count = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (a[i][j] != 0)
			{
				edges[count].a = i;
				edges[count].b = j;
				edges[count].w = a[i][j];
				++count;
			}
		}
	}
	
	long long int matrix[310][310] = { 0 };
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (i != j)
		}
	}
	
	std::sort(edges, edges + count, compare);
	initialize(n);
	long long int ans = 0;
	for (int i = 0; i < count; ++i)
	{
		int rootOfA = root(edges[i].a), rootOfB = root(edges[i].b);
		
		if (rootOfA != rootOfB)
		{
			
			makeUnion(rootOfA, rootOfB);
			ans += edges[i].w;
		}
	}*/
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	string s;cin>>s;
	int cnt=0;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[i-1]){
			cnt++;
			s[i]=(s[i-1]=='0'?'1':'0');
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include<cstdio>
using namespace std;
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int A[n][m],b[m];
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    
    for(int i=0;i<m;i++){
        scanf(" %d",&b[i]);
    }
    int ans[n];

    for(int i=0;i<n;i++){
        ans[i]=0;
        for(int j=0;j<m;j++){
            int tmp;
            tmp=A[i][j]*b[j];
            ans[i]+=tmp;
        }
        printf("%d\n",ans[i]);
    }

}


Measured memory_bytes: 2712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 100

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, B[MAX_N];
int main(int argc, char **argv) {
    cin >> N;
    for(int i = 0; i < N - 1; ++i)
        cin >> B[i];
    
    int res = 0;
    res += B[0];
    for(int i = 0; i < N - 2; ++i)
        res += min(B[i], B[i + 1]);
    res += B[N - 2];
    
    cout << res << endl;
}

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

const int N=601000;

char s[N];
int n,a[N],sum;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>s;n=strlen(s);
	for(int i=0;i<n;++i)a[i]=9*(s[n-i-1]-'0');
	for(int i=0;i<n;++i){
		a[i+1]+=a[i]/10;
		a[i]%=10;
	}
	while(a[n]){
		a[n+1]+=a[n]/10;
		a[n]%=10;
		++n;
	}
	for(int i=0;i<n;++i)sum+=a[i];
	for(int ans=1;;++ans){
		sum+=9;a[0]+=9;
		for(int i=0;a[i]>=10;++i){
			sum-=a[i];sum+=a[i]/10;
			a[i+1]+=a[i]/10;a[i]%=10;
			sum+=a[i];
		}
		if(sum<=9*ans){
			cout<<ans<<'\n';
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)
		break;
		int x[n],ma=0,mi=0,ans=0;
		for(int i=0;i<n;i++){
			cin>>x[i];
			ans+=x[i];
			if(i==0)
			mi=x[i];
			ma=max(x[i],ma);
			mi=min(x[i],mi);
		}
		cout<<(ans-(ma+mi))/(n-2)<<endl;
	}
return 0;
}

Measured memory_bytes: 1160
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a,b,c = S()
print('A'+b[0]+'C')

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

long long f(long long h)
{
	if (h == 1) return 1;
	return 2 * f(h / 2) + 1;
}

signed main(void)
{
	long long h;
	cin >> h;

	cout << f(h) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

n=int(input())
ba=[[0]*2 for i in range(n)]
for i in range(n):
    ai,bi=map(int,input().split())
    ba[i]=[bi,ai]
    
ba.sort() 

t=0
for i in range(n):
    t+=ba[i][1]
    if t>ba[i][0]:
        print("No")
        sys.exit()
print("Yes") 

Measured memory_bytes: 38268
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int DP[(1 << 26)] = {};

//map<int, int> m;
//map<int, int>::iterator ite;

int main(){
	
	string str;
	cin >> str;
	
	for(int i = 0; i < (1 << 26); i++){
		DP[i] = str.size();
	}
	
	DP[0] = 0;
	int num = 0;
	for(int i = 0; i < str.size(); i++){
		num ^= (1 << (str[i] - 'a'));
		int res = DP[num] + 1;
		for(int j = 0; j < 26; j++){
			int state = (num ^ (1 << j));
			res = min(res, DP[state] + 1);
		}
		DP[num] = min(DP[num], res);
	}
	
	cout << max(DP[num], 1) << endl;
	
	return 0;
}


Measured memory_bytes: 262660