akhauriyash/Code-Regression huggingface dataset:
(let* ((in (read-line))
       (ap 0)
       (zp (1- (length in))))
  (loop while (not (eq (char in ap) #\A))
        do (incf ap))
  (loop while (not (eq (char in zp) #\Z))
        do (decf zp))
  (format t "~A~%" (1+ (- zp ap))))

Measured memory_bytes: 10344
#!/usr/bin/python3
# -*- coding: utf-8 -*-
x, y, a, b, c = map(int, input().split())
p_list = list(map(int, input().split()))
p_list.sort(reverse=True)
q_list = list(map(int, input().split()))
q_list.sort(reverse=True)
r_list = list(map(int, input().split()))
r_list.sort(reverse=True)
p_list = p_list[0:x]
q_list = q_list[0:y]
p_count = 0
q_count = 0
r_count = 0
total = 0
for i in range(x + y):
    score_max = 0
    flag = 0
    if p_count < x:
        score = p_list[p_count]
        if score_max < score:
            score_max = score
            flag = 1
    if q_count < y:
        score = q_list[q_count]
        if score_max < score:
            score_max = score
            flag = 2
    if r_count < c:
        score = r_list[r_count]
        if score_max < score:
            score_max = score
            flag = 3
    if flag == 1:
        p_count += 1
    elif flag == 2:
        q_count += 1
    else:
        r_count += 1
    total += score_max
print(total) 

Measured memory_bytes: 22720
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto input = readln.split.to!(int[]);
    auto N = input[0], X = input[1], Y = input[2];
    int[] ans; ans.length = N+1;
    
    foreach (k; 1 .. N+1) {
        ans[k] = N-k;
    }
    //writeln(ans);
    // i <= X and Y <= j
    foreach (k; Y-X .. N+1) {
        int diff1;
        if (Y-k <= 0)
            diff1 = min(X, N-k);
        else if (X+k >= N+1)
            diff1 = N - max(1, Y) + 1;
        else
            diff1 = (X+k) - Y + 1;
        
        ans[k] -= diff1;
        ans[k - (Y-X-1)] += diff1;
    }
    //writeln(ans);
    // X < i < Y <= j
    foreach (i; X+1 .. (X+Y)/2) {
        foreach (j; Y .. N+1) {
            //writeln(i, " ", j, 1 + i-X + j-Y < j-i);
            if (1 + i-X + j-Y < j-i) ans[j-i]--, ans[1 + i-X + j-Y]++;
        }
    }
    
    // i <= X < j < Y
    foreach (j; (X+Y)/2+1 .. Y) {
        foreach (i; 1 .. X+1) {
            //writeln(i, " ", j, 1 + X-i + Y-j < j-i);
            if (1 + X-i + Y-j < j-i) ans[j-i]--, ans[1 + X-i + Y-j]++;
        }
    }
    
    // X < i < j < Y
    foreach (i; X+1 .. Y-1) foreach (j; X+2 .. Y) {
        //writeln(i, " ", j, 2*(j-i) >= Y-X+1);
        if (2*(j-i) >= Y-X+1) { ans[j-i]--; ans[Y-j + i-X + 1]++; }
    }
    
    foreach (k; 1 .. N) {
        writeln(ans[k]);
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long n,m;
    cin >> m >> n;
    long long arr[n];
    for(long long i=0;i<n;i++)
        cin >> arr[i];
        
        long long sum=0;
        for(long long i=0;i<n;i++)
            sum+=arr[i];
            
            if(sum<=m)
                cout << m-sum;
                else
                    cout << -1;
                    
                    return 0;
        
        
}

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

int main(){
  long long a,b;
  cin >> a >> b;
  if(a>b) swap(a,b);

  vector<long long> divisa;
  for (long long i = 1; i < ((long long) sqrt(a))+1 ; i++)
  {
    if(a%i==0) {
      divisa.push_back(i);
      if(i!=a/i) divisa.push_back(a/i);
    }
  }
  vector<long long> divis;
  for(long long divia:divisa){
    if(b%divia==0) divis.push_back(divia);
  }

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

  vector<long long> anss;
  for(long long divi:divis){
    if(divi==1) continue;
    bool flg=true;
    for(long long ans:anss){
      if(divi%ans==0) flg=false;
    }
    if(flg) anss.push_back(divi);
  }

  cout << anss.size() + 1 << endl;
//  cout << divis.size() << endl;
}

Measured memory_bytes: 384
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int64_t Q, H, S, D, N;
    std::cin >> Q >> H >> S >> D >> N;
    N *= 100;

    if (Q*2 < H) {
        H = Q*2;
    }
    if (H*2 < S) {
        S = H*2;
    }
    if (S*2 < D) {
        D = S*2;
    }

    cerr << N << endl;
    int64_t sum = 0;
    if (N % 50 != 0) {
        sum += Q;
        N -= 25;
    }

    if (N % 100 != 0) {
        sum += H;
        N -= 50;
    }

    if (N % 200 != 0) {
        sum += S;
        N -= 100;
    }

    sum += (N / 200) * D;

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

    return 0;
}


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

using namespace std;

int main(void) {
    string s;
    int k;
    cin >> s >> k;
    k--;

    vector<string> subs;
    map<string, bool> memo;

    rep(start, s.size()) {
        string si = s.substr(start, 1);
        if(subs.size()==k+1 and si > subs[k]) continue;
        rep(li, s.size()-start) {
            int l = li+1;
            string si = s.substr(start, l);
            if(subs.size()==k+1 and si > subs[k]) break;
            auto it = lower_bound(subs.begin(), subs.end(), si);
            if (memo.count(si)) continue;
            // cout << si << endl;

            subs.insert(it, si);
            if (subs.size() > k) subs.resize(k+1);
            memo[si] = true;
        }
    }
    cout << subs[k] << endl; 
}


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

class UnionFind {
public:
  vector<int> par, rank;
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;
    if(rank[x] < rank[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    if(rank[x]==rank[y]) rank[x]++;
  }
  inline bool same(int x, int y){ return find(x) == find(y); }
  inline int size(int x){ return -par[find(x)]; }
};

int main(){
  int n;
  string s;
  cin>>n>>s;
  
  int N = 1<<n;
  
  UnionFind uf(2*N+1);
  for(int i=N-1; i<=2*N-2; i++){
    if(s[i-(N-1)]=='0') uf.unite(i, 2*N);
    else uf.unite(i, 2*N-1);
  }
  
  int el = 0;
  
  for(int l= n-1; l>0; l--){
    int il = (1<<l) -1;
    int ir = 2*il;
    for(int i=il; i<=ir; i++){
      for(int j=i+1; j<=ir; j++) if(!uf.same(i,j)){
        if(uf.same(2*i+1, 2*j+1) && uf.same(2*i+2, 2*j+2)){
          uf.unite(i,j);
          el++;
        }
      }
    }
  }
  
  for(int i=N-2; i>=0; i--) if(uf.par[i]<0){
    if(uf.same(2*i+1, 2*i+2)) el++;
  }
  
  cout << N-1-el << endl;
  
}

Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    int cnt = 0;
    vector<int> array;
    rep(i, N){
        if((i + 1) == p[i]){
            cnt++;
            array.push_back(i+1);
        }
    }
    int len = (int)array.size();
    rep(i, len){
        if(array[i] - array[i+1] == -1){
            cnt--;
            i++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans=0;
  for (auto p : mp){
    int s = p.second;//s・・・sortしたときに同じ文字列となっている文字列の個数
    //ans+=s*(s-1)/2;と書くとs*(s-1)がオーバーフローしちゃうからllでキャストしておく
    ans+=(ll)s*(s-1)/2;
  }
  cout << ans << endl;
  return 0;
}


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

const int INF=(1LL<<31)-1;
int V,E,r;

struct Edge{
    int from;
    int to;
    int d;
};
vector<Edge> G;
vector<int> D(1919);

bool shortestPath(int s){
    rep(i,V) D[i] = INF;
    D[s] = 0;
    int cnt = 0;
    while(true){
        bool update = false;
        rep(i,E){
            Edge e = G[i];
            if(D[e.from]!=INF && D[e.to]>D[e.from]+e.d){
                update = true;
                D[e.to] = D[e.from] + e.d; 
            }
        }
        if(!update) break;
        cnt++;
        if(cnt>=V) return false;
    }
    return true;
}


int main(){
    cin >> V >> E >> r;
    G.resize(E);
    rep(i,E){
        int s,t,d; cin >> s >> t >> d;
        Edge e = {s,t,d};
        G[i] = e;
    }
    bool neg = shortestPath(r);

    if(!neg){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    ll res = 0;
    rep(i,V){
        if(D[i] == INF) {
            cout<<"INF" << endl;
            continue;
        }
        cout << D[i] << endl;
    }
}


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

int main(){ 
    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> num(n);

    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        num[i] = {a,b};
    }
    sort(num.begin(),num.end());
    int ans;
    ll tmp = 0;
    for(int i = 0; i < n; i++){
        if(num[i].second+tmp < k) tmp += num[i].second;
        else{
            ans = num[i].first;
            break;
        }
    }
    cout << ans << endl;
}

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

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

    for(long long a=-200; a<=200; a++){
        for(long long b=-200; b<=200; b++){
            if(((a*a*a*a*a) - (b*b*b*b*b))== x){
                cout << a << " " << b << endl;
                return 0; //インデントはこれ、これ追加したらまさかのOKでした、なんでできへんねん、大文字スペースか？
            }
        }
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(void){
    int K;
    cin>>K;
    int A,B;
    cin>>A>>B;
    for(int i=A;i<=B;i++){
        if(i%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		//input
		int a = sc.nextInt();
		int b = sc.nextInt();

		//output
		if( ( a * b ) % 2 == 1 ){
			System.out.println("Odd");
		}
		else{
			System.out.println("Even");
		}
	}
}


Measured memory_bytes: 21716
#include <cstdio>

using namespace std;

int M, N;
const int MAXLEN = 100;
char garden[MAXLEN+1][MAXLEN+1];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int cnt;

void dfs(int m, int n, char type)
{
    if (m < 0 || m >= M || n < 0 || n >= N) return;
    if (garden[m][n] != type) return;
    garden[m][n] = '!';
    for (int i = 0; i < 4; i++) {
        dfs(m+dx[i], n+dy[i], type);
    }
}

int main()
{
    while(1) {
        scanf("%d%d", &M, &N);
        if (M == 0) break;
        for (int i = 0; i < M; i++) {
            getchar();
            for (int j = 0; j < N; j++) {
                scanf("%c", &garden[i][j]);
            }
        }
        cnt = 0;
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                if (garden[i][j] != '!') {
                    dfs(i, j, garden[i][j]);
                    cnt++;
                }
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}

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

#define rep(s, n) for(int i(s); i < n; ++i)

int main() {
    int a(0), b(0);
    cin >> a >> b;
    if(a*b % 2 == 0)
        cout << "Even\n";
    else
        cout << "Odd\n";
    return 0;
}

Measured memory_bytes: 256
/*input
3 8
3 30
4 50
5 60
*/
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int const mod = 1e9+7;
int power(int x, int y, int mod = 2e18){ int ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
int gcd(int a , int b){if(a==0)return b;return gcd(b%a,a);}
int n,w;
pair<int,int> a[100001];
int dp[101][100001];
int solve(int i,int val = 0 )
{
	if(val>w)
		return -1e18;
	if(i==n)
		return 0;
	if(dp[i][val]!=-1)
		return dp[i][val];
	int ans = a[i].s+solve(i+1,a[i].f+val);
	ans = max(solve(i+1,val),ans);
	dp[i][val]=ans;
	return dp[i][val];
	
}
signed main() {
	IOS;
	cin>>n>>w;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
		cin>>a[i].f>>a[i].s;
	cout<<solve(0);
	
return 0;
}

Measured memory_bytes: 80128
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  s = get_str
  0.upto(s.size - 1) do |i|
    c = s[i]
    if i % 2 == 1
      if not ["L", "U", "D"].include?(c)
        puts "No"
        exit
      end
    else
      if not ["R", "U", "D"].include?(c)
        puts "No"
        exit
      end
    end
  end
  puts "Yes"
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
N = int(input())

def f(n):
    lists = []
    for i in range(1, n+1):
        if n % i == 0:
            lists.append(i)
    return len(lists)

count = 0
for j in range(1, N+1, 2):
    if f(j) == 8:
        count += 1
        
print(count)

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

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

    int64_t i;

    for (i = 1; i <= 100000; ++i) {
        if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
            goto success;
        }
    }

    cout << -1 << endl;
    return 0;
success:
    cout << i << endl;
}

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

using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define max(a, b) (((a)<(b))?b:a)
#define min(a, b) ((a>b)?b:a)
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pi 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-14
#define mod ((int)1e9+7)
#define maxlg 18
#define maxn 500002
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
int id = 1;
int dir[2][maxn];
vector<ll> grund;
ll L;
int gg;

ll power(ll t) {
    ll div = 1;
    while (t%div==0 ) {
        div=div*2;
    }
    return div;
}


void add(int curr,int c,string s) {
    gg++;
    if (c==s.length())return;
    int type = s[c]-'0';
    if (dir[type][curr]==0) {
        dir[type][curr] = ++id;
    }
    add(dir[type][curr],c+1,s);
}

void  add (int curr=1,int h=0) {
    int t =2;
    if (dir[0][curr]!=0) {
        t--;
        add(dir[0][curr],h+1);
    }
    if (dir[1][curr]!=0) {
        t--;
        add(dir[1][curr],h+1);
    }
    if (t==1)
    grund.push_back(power(L-h));


}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
 #endif
    int n;
    cin>>n>>L;

    rep (i,0,n) {
        string s;
        cin>>s;
         
        int c = 0;
        int curr = 1;
        while (c!=s.length()) {
            int type = s[c] - '0';
            if (dir[type][curr] == 0) {
                dir[type][curr] = ++id;
            }
            curr=dir[type][curr], c++;
        }
    }

    add();
    ll g=0;
    rep (i,0,grund.size()) {
        g = g^grund[i];
    }

    if (g==0) cout<<"Bob";
    else cout<<"Alice";
    return 0;
}








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

long long i;
string s;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	for (i = 0; i < s.length(); i++) {
		if (s[i] >= 65 && s[i] < 97) {
			cout << 'A';
		}
		else {
			cout << 'a';
		}
	}
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define d double
#define INF INT_MAX
#define output for(ll i=0;i<sizex;i++) { for(ll j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;

int n;
bool mat[21][21];
int dp[21][ ( 1 << 21 ) ];
int ALLTAKEN;
const int mod = 1000000000 + 7;

int solve( int idx, int mask ){

    if( idx == n && mask == ALLTAKEN ) return 1;
    if( idx == n ) return 0;
    
    if( dp[idx][mask] != -1 ) return dp[idx][mask];

    ll counter = 0;
    for(int j=0;j<n;j++){

        if( mask & ( 1 << j ) ) continue;
        if( !mat[idx][j] ) continue;
        counter += solve( idx+1, mask | ( 1 << j ) ) % mod;

    }

    return dp[idx][mask] = counter % mod;

}

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

    memset( dp, -1, sizeof dp );

    cin >> n;
    ALLTAKEN = ( 1 << n ) - 1;
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin >> mat[i][j];

    cout << solve( 0, 0 ) << endl;

}

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

int main()
{
	int n,m;
	string a[50],b[50];
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<m;i++) cin>>b[i];
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int k;
			for(k=0;k<m;k++){
				int l;
				for(l=0;l<m;l++){
					if(a[i+k][j+l]!=b[k][l]) break;
				}
				if(l!=m) break;
			}
			if(k==m){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;

int main(){
    int n;
    std::cin >> n;
    VEC(double,a,n);
    sort(all(a));
    double ans=(a[0]+a[1])/2;
    rrep(i,1,n-1){
        ans=(ans+a[i+1])/2;
    }
    std::cout <<keta(10)<< ans << std::endl;
}


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

int main(){
    ll a,b;
    cin >> a >> b;
    if(a*b%2==0) puts("No");
    else puts("Yes");
    
    return 0;
}








Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
ll fac[100001];

ll power(ll x, ll p){
  ll tmp = p;
  ll curr = x;
  ll res = 1;
  while(tmp){
    if(tmp % 2 == 1)res = res * curr % mod;
    curr = curr * curr % mod;
    tmp /= 2;
  }
  return res;
}

bool exi[100005];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<int> a;
  int dup = 0;
  rep(i, n + 1){
    int x;
    cin >> x;
    a.pb(x);
    if(exi[x])dup = x;
    exi[x] = true;
  }
  int nn[3] = {0};
  int curr = 0;
  rep(i, n+1){
    if(a[i] != dup)nn[curr]++;
    else curr++;
  }
  fac[0] = 1;
  FOR(i, 1, 100004){
    fac[i] = fac[i - 1] * i % mod;
  }
  for(int k = 1; k <= n + 1; k++){
    ll res = (fac[n+1] * power(fac[k], mod - 2) % mod) * power(fac[n+1-k], mod - 2) % mod;
    if(nn[0] + nn[2] >= k - 1){
      ll mtmp = (fac[nn[0] + nn[2]] * power(fac[k-1], mod - 2) % mod) * power(fac[nn[0]+nn[2]-k+1], mod-2) % mod;
      res = (res - mtmp) % mod;
      if(res < 0)res += mod;
    }
    cout << res << endl;
  }
	return 0;
}


Measured memory_bytes: 2552
package main

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

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	m := scanInt()
	sc := make([]map[rune]int, m)
	for i := range sc {
		s := scanInt()
		c := scanInt()
		sc[i] = map[rune]int{'s': s, 'c': c}
	}

	number := make([]int, n)
	marked := make([]bool, n)

	for _, v := range sc {
		if !marked[v['s']-1] {
			number[v['s']-1] = v['c']
			marked[v['s']-1] = true
		} else if number[v['s']-1] != v['c'] {
			fmt.Printf("%d", -1)
			return
		}
	}

	if number[0] == 0 && marked[0] && n != 1 {
		fmt.Printf("%d", -1)
		return
	}
	if number[0] == 0 && n != 1 {
		number[0] = 1
	}

	answer := ""
	for _, v := range number {
		answer += strconv.Itoa(v)
	}
	fmt.Printf("%s", answer)
}

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func scanStrings(n int) []string {
	a := make([]string, n)
	for k, _ := range a {
		a[k] = scanString()
	}
	return a
}


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

int main(){
  int n;
  cin>>n;
  vector<vector <int> > p(n,vector<int>(2));
  for(int i=0;i<n;i++){
    for(int j=0;j<2;j++){
      cin>>p[i][j];
    }
  }
  vector<int> city(n);
  int count=1;
  for(int i=1;i<n+1;i++){
    city[i-1]=i-1;
    count*=i;
  }
  double ans=0;
  do{
    for(int i=0;i<n-1;i++){
     double tmp=sqrt(pow(p[city[i]][0]-p[city[i+1]][0],2)+pow(p[city[i]][1]-p[city[i+1]][1],2));
     ans+=tmp;
    }                                                         
  }while(next_permutation(city.begin(),city.end()));
  printf("%.10lf\n",ans/count);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    if(K > B){
        cout << "NG";
    }else{
        for(int i = A; i <= B; i++){
            if(i % K == 0){
                cout << "OK";
                break;
            }else{
                if(i == B){
                    cout << "NG";
                }
            }
        }
    }
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>

using namespace std;



int main() {
    int a,b,c,t;
    cin >>a>>b>>c;
   
   if(a>b){
       t=a;
       a=b;
       b=t;
   }
   
   if(b>c){
       t=b;
       b=c;
       c=t;
   }
   
   if(a>b){
       t=a;
       a=b;
       b=t;
   }
   cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3068
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    int ca, cb, cc;
    ca = cb = cc = 0;
    char t = 'a';
    while (true) {
        if (t == 'a') {
            if (ca == a.size()) {
                cout << 'A' << endl;
                return 0;
            }
            t = a[ca];
            ca++;
        } else if (t == 'b') {
            if (cb == b.size()) {
                cout << 'B' << endl;
                return 0;
            }
            t = b[cb];
            cb++;
        } else if (t == 'c') {
            if (cc == c.size()) {
                cout << 'C' << endl;
                return 0;
            }
            t = c[cc];
            cc++;
        }


    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[4],b[4],c[4]={10,50,100,500},d,e=0,ju,i;
    while(cin>>d,d){
        if(e)cout<<endl;
        e++;
        int sum=0;
        for(i=0;i<4;i++){cin>>a[i];sum+=a[i]*c[i];}
        sum-=d;
        for(i=4;i--;){b[i]=sum/c[i];sum%=c[i];}
        for(i=0;i<4;i++){
            ju=a[i]-b[i];
            if(ju>0)cout<<c[i]<<' '<<ju<<endl;
        }
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
int main() {
        long long N,A,B;
        cin >> N >> A >> B;
        long long d[N - 1];
        long long prev;
        cin >> prev;
        for(long long i = 0; i < N - 1; i++){
            long long tmp;
            cin >> tmp;
            d[i] = tmp - prev;
            prev = tmp;
        }
        long long sum = 0;
        for(long long i = 0; i < N - 1; i++){
            sum += min(A * d[i],B);
        }
        cout << sum << endl;
}

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

int main(){
	int n;
	scanf("%d",&n);
	double x[10],y[10];
	for(int i = 0;i < n;i++){
		scanf("%lf %lf",&x[i],&y[i]);
	}
	double mp[10][10] = {0};
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			mp[i][j] = mp[j][i] = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	double sum = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			if(i != j)
				sum += mp[i][j];
		}
	}
	printf("%.10lf\n",sum / (n * 1.0));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a%3==0) cout<<"Possible"<<endl;
    else if(b%3==0) cout<<"Possible"<<endl;
    else if((a+b)%3==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
s=raw_input()
a=""
for k in range(len(s)):
    if s[k]=="0":
        a=a+"0"
    elif s[k]=="1":
        a=a+"1"
    elif s[k]=="B":
        if len(a)>0:
            a=a[0:len(a)-1]
print a

Measured memory_bytes: 2568
#include <bits/stdc++.h>
template<int mod>
class Combination {
    std::vector<long long> fact, finv, inv;
public:
    Combination(int sz) {
        fact.resize(sz);
        finv.resize(sz);
        inv.resize(sz);
        fact[0] = 1;
        for(int i=1;i<sz;++i) {
            fact[i] = fact[i-1] * i % mod;
        }
        inv[0] = 0;
        inv[1] = 1;
        for(int i=2;i<sz;++i) {
            inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        }
        finv[0] = 1;
        for(int i=1;i<sz;++i) {
            finv[i] = finv[i-1] * inv[i] % mod;
        }
    }
    long long C(long long n, long long k) {
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return (fact[n] * finv[k] % mod) * finv[n-k] % mod;
    }
    long long P(long long n, long long k) {
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fact[n] * finv[n-k] % mod;
    }
    long long H(long long n, long long k) {
        return this->C(n + k - 1, k);
    }
    long long getfact(int i) {
        return fact[i];
    }
    long long getinv(int i) {
        return inv[i];
    }
};
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 998244353;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n, a, b, k; cin >> n >> a >> b >> k;
  Combination<MOD> comb(300010);
  ll ans = 0;
  for(int i=0;i<=n;++i) {
    if((k - i*a) % b != 0) continue;
    ll j = (k - i*a) / b;
    if(i > n || j > n) continue;
    ans += comb.C(n, i) * comb.C(n, j) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <cstdlib>
#include <cctype>
#include <queue>
using namespace std;

int solve(char s,int a,int b){
    if(s == '+') return (a+b);
    else if(s == '-') return (a-b);
    else if(s == '*') return (a*b);
    else if(s == '/') return (a/b);
}

int main(){
    int tmp,tmp2;
    char st;
    string s;
    queue <int> que;
    while(cin >> s && s != "="){
        if(!isalnum(s[0])) st = s[0];
        else {
            tmp = atoi(s.c_str());
            que.push(tmp);
            if(que.size() == 2){
                tmp = que.front(); que.pop();
                tmp2 = que.front(); que.pop();
                que.push(solve(st,tmp,tmp2));
            }
        }
    }
    cout << que.front() << endl;
}

Measured memory_bytes: 1200
n = int(input())
h = [int(i) for i in input().split(' ')]

l, r = 0, 0
ans = 0
while l < n:
    tmp = 0
    r = l
    while r + 1 < n and h[r] >= h[r + 1]:
        r += 1
        tmp += 1
    ans = max(ans, tmp)
    l = r + 1

print(ans)


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

using namespace std;

void printVector(const vector<int> &A) {
    for(int i = 0; i < A.size(); i++) {
        cout << A[i];
        if(i+1 < A.size()) cout << ' ';
    }
    cout << endl;
}

int main() {
    int n;

    cin >> n;
    vector<int> A(n);

    for(int i = 0; i < n; i++)
        cin >> A[i];
    
    for(int i = 0; i < n; i++) {
        int v = A[i];
        int j = i-1;
        for(; j >= 0 && A[j] > v; j--)
            A[j+1] = A[j];
        A[j+1] = v;
        printVector(A);
    }

    return 0;
}


Measured memory_bytes: 3096
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vector<int> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    int ans=0,mn=inf;
    for(int i=0;i<n;++i)
    {
        if(mn>v[i])
            ++ans;

        mn=min(mn,v[i]);
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    string s;
    cin >> s;
    ll a1 = 0, a2 =  0, b = 0;
    for(auto x: s){
        if(x == 'B') b++;
        else a1 += b;
    } cout << a1;
    //cout << max(a1 ,a2);

}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 720
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#include <bits/stdc++.h>
using namespace std;
// ¯\_(ツ)_/¯
#define f first
#define s second
#define p push
#define mp make_pair
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define endl " \n"
#define newl cout<<"\n"
#define MAXN 100005
#define MOD 1000000007LL
#define EPS 1e-13
#define INFI 1000000000             // 10^9
#define INFLL 1000000000000000000ll //10^18
// ¯\_(ツ)_/¯
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long>
#define vvll vector<vll>
//vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.
#define pll pair<long long, long long>

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);

ll tc, n, m, k;

int main()
{
    fast_io();
#ifndef ONLINE_JUDGE
    //freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#endif

    cin>>n>>k;
    vll dp(k+1, 0);
    vll arr(n, 0);
    rep(i, 0, n) cin>>arr[i];
    dp[0] = 0;
    rep(state, 1, k+1) {
        rep(j, 0, n) {
            if(state - arr[j] >= 0 && !dp[state-arr[j]])
                dp[state] = 1;
        }
    }

    if(dp[k] == 1) cout<<"First";
    else cout<<"Second";

    return 0;
}

/*
2
4
0 1 0 1
5
0 0 1 0 0
*/

Measured memory_bytes: 1024
n, m = map(int, input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int, input().split()))

a.sort(key=lambda x: x[0])

ans = 0
for i in range(n):
    if m > a[i][1]:
        ans += a[i][0]*a[i][1]
        m -= a[i][1]
    else:
        ans += m*a[i][0]
        break

print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e16+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a, b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n, m, arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n, arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len = v.size();
    for(int i = 0; i < len; ++i) {
        s<<v[i];
        if(i < len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len = vv.size();
    for(int i = 0; i < len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll dp[305][305];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n, k;
    cin>>n>>k;
    Vec h(n+1, 0);
    rep(i, n)cin>>h[i+1];

    rep(i, n+1) {
        rep(j, n+1) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    //i個目まででiを選ぶ　合計j個
    REP(i, 1, n+1) {
        rep(j, n) {
            rep(l, i) {
                dp[i][j+1] = min(dp[i][j+1], dp[l][j]+max(0LL, h[i]-h[l]));
            }
        }
    }
    ll ans = INF;
    REP(i,0,n+1){
        chmin(ans,dp[i][n-k]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
a,b = input().split()
intA = int(a)
intB = int(b)

strA = ''
strB = ''

for i in range(intB):
    strA += a

for j in range(intA):
    strB += b

if strA < strB:
    print(strA)
elif strB <= strA:
    print(strB)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

bool is_pdate(int m, int d10, int d1) {
    if ((d10 >= 2 && d1 >= 2) && (d1 * d10 == m)) {
        return true;
    }
    return false;
}

int main() {
    int M, D;
    cin >> M >> D;
    int d10_max = (int)(D / 10);
    int ans=0;
    for (int m=1;m<=M;++m) {
        for (int d10=0;d10<=d10_max;++d10) {
            int d1_max = D >= 9 ? 9 : D;
            if (d10 == d10_max) {
                d1_max = D % 10;
            }
            // cout << "d10_max: " << d10_max << ", d1_max: " << d1_max << endl;
            for (int d1=1;d1<=d1_max;++d1) {
                // if (is_pdate(m,d10,d1)) {
                //     cout << m << "," << d10 << "," << d1 << endl;
                // }
                ans += is_pdate(m, d10, d1) ? 1 : 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
	int a;
    scanf("%d",&a);
    char s[a];
    scanf("%s",s);
    if(a%2!=0){
    	printf("No\n");
	}else{
		int x=1;
		for(int i=0;i<a/2;i++){
			if(s[i]!=s[i+a/2]){
				x=!x;
				break;
			}
		}
		if(x){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
    return 0;

}

Measured memory_bytes: 1612
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
using namespace std;
  
#define int long long int 
typedef vector<int> vi;
typedef vector<pair<int, int>> vpi;
typedef vector<vi> vvi;
const int mod = 1e9 + 7; 

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define debug(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define TC int t; cin >> t; while (t--) 

void Panda() {
    int n;
    cin >> n;
    vi in(n);
    for(auto &i : in) cin >> i;
    vi ans(n);
    ans[0] = 0;
    for(int i = 1; i < n; i++) {
        if(in[i - 1] > in[i]) ans[i] = in[i - 1] - in[i], in[i] = in[i] + ans[i];
    }
    int cnt = 0;
    for(auto i : ans) cnt += i;
    cout << cnt << endl;
}
  
int32_t main() {
 
    FAST;

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout); 
    
    Panda();

    return 0; 
} 

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();

    ll n,w,smv;
    cin>>n>>w;

    vector<ll>a(n+1),v(n+1);
    for(int i =0;i<n;i++)cin>>a[i+1]>>v[i+1],smv+=v[i+1];

    vector<ll>dp(smv+10,1e18);
	dp[0] = 0;
    for(int i = 1;i<=n;i++)
    {
    	for(int j = smv-v[i];j>=0;j--)
    	{
    		dp[j+v[i]] = min(dp[j]+a[i],dp[j+v[i]]);
    	}
    }
    for(int i = smv;i>=0;i--)if(dp[i]<=w){cout<<i;return 0;}


	return 0;
}

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

using namespace std;

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

const int MX = 100010;
const int mod = 1e9 + 7;
int bit[MX], f[MX];
void add(int i, int x){ for(; i < MX; i += i & -i) bit[i] += x; }
int sum(int i){
	int x = 0;
	for(; i; i -= i & -i) x += bit[i];
	return x;
}
int calc(int n, const vi &v){
	//dbg(v);
	ll res = 0;
	rep(i, n) add(i+1, 1);
	rep(i, n){
		int k = (ll)sum(v[i]) * f[n - i - 1] % mod;
		res += k;
		add(v[i]+1, -1);
	}
	return res % mod;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	f[0] = 1;
	for(int i = 1; i < MX; i++) f[i] = f[i - 1] * (ll)i % mod;
	
	int n, r;
	while(cin >> n, n){
		cin >> r;
		vi v(n);
		rep(i, n) v[i] = i;
		while(r--){
			int a, b; cin >> a >> b; a--; b--;
			swap(v[a], v[b]);
		}
		cout << calc(n, v) << endl;
	}
	return 0;
}


Measured memory_bytes: 4292
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n + 1), b(n);
	rep(i, n + 1) cin >> a[i];
	rep(i, n) cin >> b[i];

	ll ans = 0;
	
	rep(i, n) {
		ans += min(a[i], b[i]);
      b[i]-=min(a[i], b[i]);
		ans += min(a[i + 1], b[i]);
      a[i+1]-=min(a[i + 1], b[i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int c1 = sc.nextInt();
			int c2 = sc.nextInt();
			int c3 = sc.nextInt();
			int cnt=0;
			
			for(int i=1; i<=10; i++){
				if(i==c1 || i==c2 || i == c3) continue;
				if(c1+c2+i<= 20) cnt++;
			}
			
			System.out.println((cnt/7.0 >= 0.5) ? "YES" : "NO");
		}
	}

}

Measured memory_bytes: 11000
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {

  int n, h, w;
  scanf("%d%d%d", &n, &h, &w);
  printf("%d\n", (n - h + 1) * (n - w + 1));

  return 0;
}


Measured memory_bytes: 256