akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//たてたて、よこよこ、たてよこ、よこたて　の４か
//10^5^2は無理だな
//たてたて、よこよこは3でわったあまりででるか
//たてよこ、よこたて
//はNでいける
int main(){
  ll H,W; cin>>H>>W;
  ll hw=W/2;
  ll hh=H/2;
  ll ans=1e10;
  //たてたて
  if(W%3==0){
    cout<<0<<endl;
    return 0;
  }
  else if(W>3) ans=min(ans,H);
  //よこよこ
  if(H%3==0){
    cout<<0<<endl;
    return 0;
  }
  else if(H>3) ans=min(ans,W);
  //よこたて
  for(int i=1; i<H; i++){
    ll a=i*W,b=(H-i)*hw,c=(H-i)*(W-hw);
    ll low=min(a,min(b,c)), high=max(a,max(b,c));
    ans=min(ans,high-low);
  }
  //たてよこ
  for(int i=1; i<W; i++){
    ll a=i*H,b=(W-i)*hh,c=(W-i)*(H-hh);
    ll low=min(a,min(b,c)), high=max(a,max(b,c));
    ans=min(ans,high-low);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while (b <= a) {
        b += b;
        k--;
    }
    while (c <= b) {
        c += c;
        k--;
    }
    cout << (k >= 0 ? "Yes": "No") << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void){
    int n, x = 0, max = 0;
    char s[101];

    scanf("%d %s", &n, s);
    for(int i = 0; i < n; i++){
        if(s[i] == 'I'){
            x++;
        }else{
            x--;
        }
        if(max < x) max = x;
    }

    printf("%d", max);

    return 0;
}

Measured memory_bytes: 1732
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    map<char, ll> mp;
    for(int i = 0; i < n; i++){
        string x;
        cin >> x;
        if(x[0] == 'M' || x[0] == 'A' || x[0] == 'R' || x[0] == 'C' || x[0] == 'H'){
            mp[x[0]]++;
        }
    }
    string s = "MARCH";
    ll ans = 0;
    for(int i = 0; i < (1 << 5); i++){
        vector<char> v;
        for(int j = 0; j < 5; j++){
            if(i & (1 << j)){
                v.PB(s[j]);
            }
        }
        if(SZ(v) == 3){
            ll r = 1;
            for(auto &j : v){
                r *= mp[j];
            }
            ans += r;
        }
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string ans = "";
    if (n == 0) ans = "0";
    while (n != 0) {
        if (n % (-2) == 0) {
            ans = "0" + ans;
        } else {
            n--;
            ans = "1" + ans;
        }
        n /= -2;
    }
    cout << ans << endl;
    
    return 0;
}



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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define INF INT_MAX
#define NINF INT_MIN
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "\n";
    err(++it, args...);
}

const int N = 3e3 + 5;
int n, a[N];
vector< vector< ll > > dp(N, vector<ll>(N,NINF));

ll calc(int i, int j) {

	if(i == j && (i+j+n+1) % 2 == 0)
		return a[i];
	else if(i == j)
		return -a[i];
	else if(dp[i][j] != NINF)
		return dp[i][j];

	if(((i+j+n+1)%2) == 0)
		return dp[i][j] = max(a[i]+calc(i+1,j), calc(i,j-1) + a[j]);
	else
		return dp[i][j] = min(calc(i+1,j)-a[i], calc(i,j-1)-a[j]);	

}

int main() {

	cin >> n;

	tik(i,0,n)
		cin >> a[i];

	cout << calc(0,n-1);
}

Measured memory_bytes: 71040
#include <iostream>

using namespace std;

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

  int WW,EE; //リーダーよりWest(East)にいてWest(East)を向いている人の数
  WW = 0;
  EE = 0;
  for(int i = 1; i < N; i++){
    if(S[i] == 'E') EE++;
  }

  int ans;
  ans = EE;
  for(int i = 1; i < N; i++){
    if(S[i-1] == 'W') WW++;
    if(S[i] == 'E') EE--;
    int sum = WW + EE;
    ans = min(ans, sum);
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#define int long long
struct tree {int p,l,r;};
using namespace std;
vector<int> num;
int n,l;
tree a[200000];
void dfs(int a0,int h){
  int ch=0;
  if(!~a[a0].l) ch++;
  if(!~a[a0].r) ch++;
  if(ch==1) num.push_back(l-h);
  if(~a[a0].l) dfs(a[a0].l,h+1);
  if(~a[a0].r) dfs(a[a0].r,h+1);
}
signed main(){
  int r=0,cnt=1;
  char c;
  for(int i=0;i<200000;i++) a[i].p=a[i].l=a[i].r=-1;
  cin>>n>>l;scanf("%c",&c);
  for(int i=0;i<n;i++){
    int whe=0;
    for(;scanf("%c",&c)&&c!='\n';){
      if(c=='0'){
	if(!~a[whe].l) a[whe].l=cnt,a[cnt].p=whe,cnt++;
	whe=a[whe].l;
      }
      else {
	if(!~a[whe].r) a[whe].r=cnt,a[cnt].p=whe,cnt++;
	whe=a[whe].r;	
      }
    }
  }
  dfs(0,0);
  if(num.empty()) cout<<"Bob"<<endl;
  else {
    int b=1;
    for(;!(num[0]%(b*2));b*=2);
    r=b;
    for(int i=1;i<(int)num.size();i++){
      b=1;
      for(;!(num[i]%(b*2));b*=2);
      r^=b;
    }
    if(r) cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
  }
  return 0;
}

Measured memory_bytes: 10484
import java.util.*;
public class Main {

	public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
	  int b = sc.nextInt();	
		if((a*b)%2==0) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
int main(void){

    char str[3000];
    char *tok;
    int m,n;
    int i1,i2,i3,i;
    int a[1000];
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    m=strtol(tok,NULL,10);
  
 	int max=0;
  	int maxindex=-1;
  
  	fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    a[0]=strtol(tok,NULL,10);
  	max=a[0];
  	maxindex=0;
  	for(i=1;i<m;i++){
    	tok=strtok(NULL," ");
    	a[i]=strtol(tok,NULL,10);
      		if(max<a[i]){
              max=a[i];
              maxindex=i;
            }
    }
      
    int total=0;
    for(i=0;i<m;i++){
      	if(i!=maxindex){
          	total+=a[i];
        }
    }
  
    if(max<total){
      	printf("Yes");
    }else{
      	printf("No");
    }
  
}


Measured memory_bytes: 128
from sys import stdin

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
  
def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [g]
    while 3 * g + 1 < n:
        g = 3 * g + 1
        G.append(g)
    m = len(G)
    G.reverse()
    print(m)
    print(' '.join(map(str, G)))
    for i in range(m):
        insertionSort(A, n, G[i])

n =  int(stdin.readline())
A = [int(stdin.readline()) for i in range(n)]

shellSort(A, n)
print(cnt)
for a in A:
    print(a)



Measured memory_bytes: 45516
#include <iostream>
using namespace std;
int main(){
  char a[10] = {0}, b[10] = {0};
  int c = 0;
  cin >> a;
  cin >> b;
  for(int i = 0; i < 3; i++){
    if(a[i] == b[i]){
      c++;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
// Problem : A - We Love Golf
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll goal;
	cin>>goal;
	
	ll curr=100;
	int ans=0;
	
	while (curr<goal){
		curr=floor(curr*1.01);
		ans++;
	}
	
	cout<<ans;
	
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,m;
	cin>>n>>m;
	vector<string> s(n);
	for(int i=0;i<n;i++)
		 cin>>s[i];
	sort(s.begin(),s.end());
	for(string i:s)
		cout<<i;
	
	return 0;
}

Measured memory_bytes: 256
input = gets.chomp.split.map(&:to_i)
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]
ans = (g1.include?(input[0]) && g1.include?(input[1]) ||
          g2.include?(input[0]) && g2.include?(input[1]) ||
          g3.include?(input[0]) && g3.include?(input[1]) )
  if ans  
    puts "Yes" 
  else
    puts "No"
  end

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<string> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


struct BipartiteMatching {
    vector<vector<int> > graph;
    vector<int> match, alive, used;
    int timestamp;

    BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

    void add_edge(int u, int v) {
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    bool dfs(int idx) {
        used[idx] = timestamp;
        for (auto &to : graph[idx]) {
            int to_match = match[to];
            if (alive[to] == 0) continue;
            if (to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
                match[idx] = to;
                match[to] = idx;
                return true;
            }
        }
        return false;
    }

    int bipartite_matching() {
        int ret = 0;
        for (int i = 0; i < graph.size(); i++) {
            if (alive[i] == 0) continue;
            if (match[i] == -1) {
                ++timestamp;
                ret += dfs(i);
            }
        }
        return ret;
    }

    void output() {
        for (int i = 0; i < graph.size(); i++) {
            if (i < match[i]) {
                cout << i << "-" << match[i] << endl;
            }
        }
    }
};

int main() {
    ll x, y, e;
    cin >> x >> y >> e;

    BipartiteMatching bipartiteMatching(x + y);
    rep(i, e) {
        ll ui, vi;
        cin >> ui >> vi;
        bipartiteMatching.add_edge(ui, vi + x);
    }

    cout << bipartiteMatching.bipartite_matching() << endl;
}



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


int nxt(int nos){
    int x = nos & (nos - 1);
    while (x > 0) {
        nos = nos & (nos - 1);
        x = x & (x - 1);
    }
    return nos<<1;
}

int main(){
    int N;cin>>N;
    vector<int> nos(N);
    for(auto &x: nos) cin>>x;
    sort(nos.rbegin(),nos.rend());
    map<int,int> req;
    int cnt = 0;
    for(auto x: nos){
        if(req[x] != 0){
            req[x] -= 1;
            cnt += 1;
        }else{
            req[nxt(x) - x] += 1;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 19712
h,w,k = map(int,input().split())
field = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    s = input()
    for j in range(w):
        if s[j] == "#":
            field[i][j] = 1



def tobin(x,n):
    return format(x,'b').zfill(n)

# print(field)

ans = 0
for i in range(2**h):
    for j in range(2**w):
        f1 = tobin(i,h)
        f2 = tobin(j,w)


        temp = 0
        for hoge in range(h):
            for l in range(w):
                if f1[hoge] == "0" and f2[l] == "0":
                    temp += field[hoge][l]
        if temp == k:
            ans += 1
            # print(f1, f2,temp)

print(ans)



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

int main() {
    int n,a,b,ans=-1;
    cin>>a;
    cin>>b;
    int start=1;
    int end=1000000;
    while(start<=end){
        int mid=(start+end)/2;
        int tax_A=floor(mid*0.08);
        int tax_B=floor(mid*0.1);
        if(tax_A==a && tax_B==b){
            ans=mid;
            end=mid-1;
        }
        else if (tax_A>a && tax_B>b || tax_A>a || tax_B>b){
            end=mid-1;
        }
        else{
            start=mid+1;
        }
    }
    if(ans==-1){
        cout<<"-1";
    }
    else{
        cout<<ans;
    }
    return 0;
       
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int x, y, a, b, stock;

  while(scanf("%d %d",&a,&b) != EOF){
    if(a < b){
      x = b;
      y = a;
    }else{
      x = a;
      y = b;
    }
    while(y != 0){
      x %= y;
      stock = x;
      x = y;
      y = stock;
    }

    printf("%d\n",x);
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long a = sc.nextLong();
        long b = sc.nextLong();
      long g=gcd(a,b);
      //int min=Math.min(a,b);
      int o=1;
      	for (int i=2;i<=Math.sqrt(g);i++){
          if(g%i==0){
            o++;
            while(g%i==0)g /= i;
          }
        }
       if(g!=1)o++;
	   System.out.println(o);
	}
  
  private static long gcd(long a, long b){
        
        if(b == 0){
            return a;
        }else{
            return gcd(b, a % b);
        }
    }
}

Measured memory_bytes: 23636
#include <cstdio>

int main(){
    int D,N;
    scanf("%d%d",&D,&N);
    if(D == 0){
        if(N < 100){
            printf("%d",N);
        }else{
            printf("%d",N + 1);
        }
    }else if(D == 1){
        if(N < 100){
            printf("%d",100 * N);
        }else{
            printf("%d",100 * N + 100);
        }
    }else if(D == 2){
        if(N < 100){
            printf("%d",100 * 100 * N);
        }else{
            printf("%d",10000 * N + 10000);
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    int C[2];
    C[0]=A+B,C[1]=A-B,C[2]=A*B;
    sort(C,C+3);
    cout<<C[2];
    return 0;
}

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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

int main(){
    nimble
    int n;
    cin>>n;
    vector<ll> a(n);
    ll as=0;
    rep(i,0,n){
        cin>>a[i];
    }
    rep(i,1,n){
        if(a[i-1]>=a[i]){
            as+=a[i-1]-a[i];
            a[i]=a[i-1];
            continue;
        }
    }
    cout<<as;
    return 0;
}


Measured memory_bytes: 4764
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        sx: i64, sy: i64,
        tx: i64, ty: i64
    }

    let dx = tx - sx;
    let dy = ty - sy;
    let mut ret = vec![];
    push(dx,'R',&mut ret);
    push(dy,'U',&mut ret);
    push(dx,'L',&mut ret);
    push(dy+1,'D',&mut ret);
    push(dx+1,'R',&mut ret);
    push(dy+1,'U',&mut ret);
    ret.push('L');
    ret.push('U');
    push(dx+1,'L',&mut ret);
    push(dy+1,'D',&mut ret);
    ret.push('R');
    println!("{}", ret .iter().cloned().collect::<String>());
}

fn push(n: i64, c: char, x: &mut Vec<char>) {
    for _ in 0..n {
        x.push(c);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define endl "\n"
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    using ll = long long;
    ll n; cin >> n;
    vector<ll> a(n);

    // 最終的な大きさはsum, 合体する回数はn-1回
    for(ll i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end()); a.emplace_back(0);

    vector<ll> sum(n+1);
    vector<bool> chk(n+1, false);
    for(ll i=0; i<n; i++){
        sum[i] += a[i];
        sum[i+1] += sum[i];
        if(2*sum[i] >= a[i+1]) chk[i] = true;
    }
    ll ans = 0, pos = n-1;
    while(pos >= 0 && chk[pos]) ans++, pos--;
    cout << ans << endl;
}

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

#define BAD     (0)
#define GOOD    (1)
#define UNKNOWN (2)

int main(void)
{
    int A, B, C;
    int N;
    int I[1001], J[1001], K[1001], R[1001];
    int parts[301];
    int parts_old[301];
    int i;
    
    while (1){
        scanf("%d%d%d", &A, &B, &C);
        if ((A | B | C) == 0){
            break;
        }
        
        scanf("%d", &N);
        for (i = 0; i < N; i++){
            scanf("%d%d%d%d", &I[i], &J[i], &K[i], &R[i]);
        }
        
        for (i = 1; i <= A + B + C; i++){
            parts[i] = UNKNOWN;
        }
        
        do {
            memcpy(parts_old, parts, sizeof(parts));

            for (i = 0; i < N; i++){
                if (R[i] == 1){
                    parts[I[i]] = parts[J[i]] = parts[K[i]] = GOOD;
                }
                else {
                    if (parts[I[i]] == GOOD && parts[J[i]] == GOOD){
                        parts[K[i]] = BAD;
                    }
                    if (parts[I[i]] == GOOD && parts[K[i]] == GOOD){
                        parts[J[i]] = BAD;
                    }
                    if (parts[J[i]] == GOOD && parts[K[i]] == GOOD){
                        parts[I[i]] = BAD;
                    }
                }
            }

        } while (memcmp(parts_old, parts, sizeof(parts)) != 0);
        
        for (i = 1; i <= A + B + C; i++){
            printf("%d\n", parts[i]);
        }
    }
    return (0);
}

Measured memory_bytes: 632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        String[] input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        long M = long.Parse(input[1]);
        long K = long.Parse(input[2]);
        long mod = 998244353;
        Combination.combInit(1000000, mod);
        long result = 0;
        for (int i = 0; i <= K; i++)
        {
            long subtotal = M;
            subtotal *= Mpow(M - 1, N - i - 1, mod);
            subtotal %= mod;
            subtotal *= Combination.combination(N - 1, i);
            subtotal %= mod;
            result += subtotal;
            result %= mod;
        }
        Console.WriteLine(result);
    }
    public static long Mpow(long x, long n, long m)
    {
        long ans = 1;
        while (n > 0)
        {
            if (n % 2 == 1)
            {
                ans = ans * x % m;
                n -= 1;
            }
            x = x * x % m;
            n /= 2;
        }
        return ans;
    }
}
static class Combination
{
    static long combMax;
    static long combMOD;

    static long[] factorial;
    static long[] inverse;
    static long[] factInv;

    public static void combInit(long _max, long _mod)
    {
        combMax = _max;
        combMOD = _mod;
        factorial = new long[combMax];
        inverse = new long[combMax];
        factInv = new long[combMax];

        factorial[0] = factorial[1] = 1;
        factInv[0] = factInv[1] = 1;
        inverse[1] = 1;

        for (int i = 2; i < combMax; i++)
        {
            factorial[i] = factorial[i - 1] * i % combMOD;
            inverse[i] = combMOD - inverse[combMOD % i] * (combMOD / i) % combMOD;
            factInv[i] = factInv[i - 1] * inverse[i] % combMOD;
        }
    }

    public static long combination(int n, int k)
    {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return factorial[n] * (factInv[k] * factInv[n - k] % combMOD) % combMOD;
    }
}

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

int main()
{
  int n, i, k, j, key = 0;
  int *data;

  scanf("%d", &n);

  data = (int *)malloc(n * sizeof(int));

  for(i = 0; i < n; i++)
    scanf("%d", &data[i]);

  for(k = 0; k < n; k++){
    if(k != 0)
      printf(" ");
    printf("%d", data[k]);

  }

  //printf("\b");

  printf("\n");
  
  /*ここからが挿入ソート*/
  for(i = 1; i < n; i++){    
    key = data[i];
    j = i - 1;
    
    while(j  >= 0 && data[j] > key){
      data[j + 1] = data[j];
      j = j - 1;
    }

    data[j + 1] = key;

    for(k = 0; k < n; k++){
      if(k != 0)
	printf(" ");
      printf("%d", data[k]);

    }
      
    //printf("\b");
    printf("\n");
  }
  
  return 0;
}





Measured memory_bytes: 2140
#include <stdio.h>



void max_heapify(int *a, int i, int n)

{

  int j, temp;

  temp = a[i];

  j = 2 * i;

  while (j <= n)

    {

      if (j < n && a[j+1] > a[j])

	j = j + 1;

      if (temp > a[j])

	break;

      else if (temp <= a[j])

        {

	  a[j / 2] = a[j];

	  j = 2 * j;

        }

    }

  a[j/2] = temp;

  return;

}

void build_maxheap(int *a,int n)

{

  int i;

  for(i = n/2; i >= 1; i--)

    {

      max_heapify(a,i,n);

    }

}

int main()

{

  int n, i, x;

    

  
  scanf("%d",&n);
  int a[500001];

  for (i = 1; i <= n; i++)

    {

       
      scanf("%d",&a[i]);

    }

  build_maxheap(a,n);

    

  for (i = 1; i <= n; i++)

    {

      printf(" %d",a[i]);

    }
  printf("\n");
  return 0;
}



Measured memory_bytes: 4512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  string s[3];
  char c;int i=0;
  rep(i,0,3)cin>>s[i];
  c=s[0][0];
  while(1){
    if(c=='a'){
      s[i].erase(0,1);
      i=0;
      if(s[0].size()==0){
        cout<<'A'<<endl;
        return 0;
      }
    }else if(c=='b'){
      s[i].erase(0,1);
      i=1;
      if(s[1].size()==0){
        cout<<'B'<<endl;
        return 0;
      }
    }else if(c=='c'){
      s[i].erase(0,1);
      i=2;
      if(s[2].size()==0){
        cout<<'C'<<endl;
        return 0;
      }
    }
    c=s[i][0];
  }
}


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

int main(){
  char s[111][111];
  int n,l,i;
  scanf("%d%d",&n,&i);
  for(i=0;i<n;i++){
    scanf("%s",s[i]);
  }
  qsort(s,n,sizeof(s[0]),strcmp);
  for(i=0;i<n;i++){
    printf("%s",s[i]);
  }
}

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

int main(){
  long N;
  cin >> N;
  vector<long> A(N);
  vector<long> C(N,0);
  for(int i=0; i<N; i++){
    cin >> A[i];
    C[A[i]-1]++;
  }
  long ans = 0;
  for(int i=0; i<N; i++){
    ans += C[i]*(C[i]-1)/2;
  }
  for(int i=0; i<N; i++){
    long c=C[A[i]-1];
    cout << ans+(c-1)*(c-2)/2-c*(c-1)/2 << endl;
  }
  return 0;
}

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

const long long MOD=1000000007;

int main(){
  int N; string s; cin >> N >> s;
  int red=0,blue=0;
  for(int i=0; i<N; i++){
    if(s[i]=='R') red++;
    else blue++;
  }
  if(red>blue) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int N, Btop = 0, Aback = 0, size, ans = 0;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s.at(i);
  bool flag = false;
  for (int i = 0; i < N; i++) {
    size = s.at(i).size();
    if (s.at(i).at(0) == 'B') {
      Btop++;
      if (s.at(i).at(size - 1) != 'A') flag = true;
    }
    for (int j = 0; j < size - 1; j++) {
      if (s.at(i).at(j) == 'A' && s.at(i).at(j + 1) == 'B') ans++;
    }
    if (s.at(i).at(size - 1) == 'A') {
      Aback++;
      if (s.at(i).at(0) != 'B') flag = true;
    }
  }
  ans += min(Btop, Aback);
  if (Btop > 0 && flag == false) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 896
while True:
  n,k = map(int,input().split())
  if n == 0 and k == 0:
    break
  lst = []
  for i in range(n):
    lst.append(int(input()))
  count = 0
  for i in range(k):
    count += lst[i]
  ans = count
  for i in range(k, n):
    count += lst[i]
    count -= lst[i - k]
    ans = max(ans,count)
  print(ans)



Measured memory_bytes: 9604
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int l[MAX/2+2], r[MAX/2+2];
int cnt;

void merge(int [], int, int, int, int);
void mergeSort(int [], int, int, int);

int main(){
  int a[MAX], n, i;

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &a[i]);
  }
  mergeSort(a, n, 0, n);
  for(i = 0;i < n;i++){
    if(i) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
  printf("%d\n", cnt);
  return 0;
}

void merge(int a[], int n, int left, int mid, int right){
  int n1, n2, i, j, k;

  n1 = mid - left;
  n2 = right - mid;
  for(i = 0;i < n1;i++){
    l[i] = a[left+i];
  }
  for(i = 0;i < n2;i++){
    r[i] = a[mid+i];
  }
  l[n1] = r[n2] = SENTINEL;
  i = j = 0;
  for(k = left;k < right;k++){
    cnt++;
    if(l[i] <= r[j]){
      a[k] = l[i++];
    }
    else a[k] = r[j++];
  }
}

void mergeSort(int a[], int n, int left, int right){
  int mid;

  if(left+1 < right){
    mid = (left + right) / 2;
    mergeSort(a, n, left, mid);
    mergeSort(a, n, mid, right);
    merge(a, n, left, mid, right);
  }
}

Measured memory_bytes: 4508
#include <iostream>
#include <map>
#include <utility>

using namespace std;
const long mod = 1000000007;


long modbeki(long N){
    long res = 1; for(long i=0;i<N;i++) res = (res*2)%mod;
    return res;
}

long gcd(long a, long b){
    if(a < b) return gcd(b, a);
    long r = a%b;
    while(r){
        a = b;
        b = r;
        r = a%b;
    }
    return b;
}


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

    // 傾き有理数 (分母、分子) : 個数 (正、負)
    map< pair<long,long>, pair<long,long> > data{};

    // 原点の登場回数を数える (複数回出てくることに注意)
    long num_origin=0;

    // 「内積0は一緒になれない」というのと同じ。内積 = コサイン類似度 = 傾き
    for(long i=0;i<N;++i){
        long A,B;
        cin >> A >> B;
        
        if(A*B==0){ // 原点 or 軸上
            if(A==0&&B==0){
                num_origin++; //原点は単体でしか条件を満たす部分集合を作れない
            }else if(A==0){
                if(!data.count({0,1})) data[{0,1}] = {0,0};
                data[{0,1}] = { data[{0,1}].first+1, data[{0,1}].second   };
            }else{
                if(!data.count({0,1})) data[{0,1}] = {0,0};
                data[{0,1}] = { data[{0,1}].first,   data[{0,1}].second+1 };
            }
        }else{
            // 第二象限 -> 第四象限、第三象限 -> 第一象限 (Aが正となる) Z x Z -> N x Z
            if(A<0){ A*= -1; B*=-1; }
            
            // 第一象限(正の傾き)にあるか、第四象限(負の傾き)にあるか？
            int is_positive = B > 0;
            // 直角になるものは同じ N x Z -> N x N x {+,-}
            if(B<0){ long swap=A; A=-B; B=swap; }
            // 既約分数に変換
            long G = gcd(A,B); A = A/G; B = B/G;

            // キーがなければ初期化しておく
            if(!data.count({A,B})) data[{A,B}] = {0,0};
            if(is_positive){ // 正の傾き
                data[{A,B}] = { data[{A,B}].first+1, data[{A,B}].second   };
            }else{ // 負の傾き
                data[{A,B}] = { data[{A,B}].first,   data[{A,B}].second+1 };
            }
        }
    }


    // 同じ傾きのやつで正負がことなる組み合わせを取り出すことは禁止
    // それぞれの傾きの中で選び出し方をカウントする
    //    | g | = | g_neg |^2 + | g_pos |^2 - 1
    //    -1 + Π | g |

    // 何も選ばないというのは除外
    if(data.size()==0){
        cout << num_origin << endl;
        return 0;
    }

    long prod=1;
    for(auto itr=data.begin(); itr!=data.end(); ++itr){
        pair<long,long> pos_neg = itr->second;
        long pos = pos_neg.first;
        long neg = pos_neg.second;

        long patterns = ( (modbeki(pos) + modbeki(neg))%mod + (mod-1) )%mod;
        //cout << (itr->first).second << " / " << (itr->first).first << " : (" << pos << ", " << neg << ") -> " << patterns << endl;
        prod = (prod * patterns )%mod; // φは二回数えてしまうので
    }
    prod = (prod+(mod-1))%mod; // φは入れない

    cout << (num_origin+prod)%mod << endl;

    return 0;
}


Measured memory_bytes: 19164
//条件を「奇数文字目が L でない，偶数文字目が R でない」と言い換えることで単純に書くことができます．

#include <stdio.h>
#include <string.h>

int main()
{
    char s[101];
    int num, length;

    scanf( "%s", s );

    length = strlen( s ); //文字列の長さを得る

    for( num = 0; num < length; num++ )
    {
        if (num % 2 == 1 ) //偶数
        {
            if ( s[num] == 'R' ) 
            {
                printf("No\n");
                return 0;
            }
        }
        else //奇数
        {
            if ( s[num] == 'L' )
            {
                printf("No\n");
                return 0;
            }
        }
    }

    printf( "Yes\n" );
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int x;
  cin >> x;
  cout << (x < 1200 ? "ABC" : "ARC") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

int main(){
	int N,K; cin>>N>>K;
	int H[N], dp[N];
	rp(i, 0, N) cin>>H[i];
	int INF = 1e+9;
	dp[0] = 0;
	rp(i, 1, N){
		dp[i] = INF;
		rp(k, 1, K+1)
			if(i-k>=0) chmin(dp[i], dp[i-k] + abs(H[i-k] - H[i]));
	}
	cout<< dp[N-1] <<endl;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        double r = Double.parseDouble(br.readLine());
        double L = 2.0 * r * Math.PI;
        double S = r * r * Math.PI;
        
        System.out.printf("%.6f " , S);
        System.out.printf("%.6f\n" , L);
    }
}

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

int main() {
	string S;
cin>>S;
if(S[6]>'4')
{
cout<<"TBD"<<endl;
}
else if(S[6]=='1')
{
if(S[5]=='1')
{
cout<<"TBD"<<endl;
}
else 
cout<<"Heisei"<<endl;
}

else if(S[6]=='2')
{
if(S[5]=='1')
{
cout<<"TBD"<<endl;
}
else 
cout<<"Heisei"<<endl;
}
else if(S[6]=='3')
{
cout<<"Heisei"<<endl;
}
else if(S[6]=='4')
{
cout<<"Heisei"<<endl;
}
	
else if(S[6]=='0')
{
cout<<"TBD"<<endl;
}	
}


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


int N;
int Q;
int sz;

vector<int> node;


void update(int index,int val)
{
	index = index + sz - 1;
	node[index] += val;
	while(index > 0)
	{
		index = (index - 1) / 2;
		node[index] = node[index * 2 + 1] + node[index * 2 + 2];
	}
}

int get_sum(int a,int b,int k,int l,int r)
{
	if(r <= a || b <= l) return 0;

	if(a <= l && r <= b) return node[k];

	int vl = get_sum(a,b,2 * k + 1,l,(l + r) / 2);
	int vr = get_sum(a,b,2 * k + 2,(l + r) / 2,r);
	return vl + vr;
}
int main()
{
	cin >> N >> Q;
	stringstream result;

	sz = 1;
	while(sz < N) sz *= 2;
	node.resize(2 * sz - 1,0);

	int com,x,y;

	for(int i = 0;i < Q;i++)
	{
		cin >> com >> x >> y;

		if(com == 0)
		{
			update(x - 1,y);
		}
		else
		{
			 result << get_sum(x - 1,y - 1 + 1,0,0,sz) << endl;

		}
	}
	cout << result.str();
	return 0;
}



Measured memory_bytes: 4708
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;
        private static long max = 999999999999;

        static void Main(string[] args)
        {
            var n = Read().Int();
            var l = new long[10000001];
            var mul = 1;
            var now = 0;
            while (true)
            {
                if (mul > 10000000)
                {
                    break;
                }
                now += mul;
                if (now > 10000000)
                {
                    now = 0;
                    mul++;
                    continue;
                }
                l[now]++;
            }
            var ans = 0L;
            for (int i = 1; i <= n; i++)
            {
                ans += l[i] * i;
            }
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 94792
#include "bits/stdc++.h"
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> brd(h);

	for (int i = 0; i < h; i++)
	{
			cin >> brd.at(i);
	}
	vector<vector<int>> cnt(2, vector<int>(max(w,h)));
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (brd.at(i).at(j) == '.') {
				cnt.at(0).at(i)++; cnt.at(1).at(j)++;
			}
		}
	}
	for (int i = 0; i < h; i++)
	{
		if (cnt.at(0).at(i) < w) 
		{
			for (int j = 0; j < w; j++)
			{
				if (cnt.at(1).at(j) < h)
				{
					cout << brd.at(i).at(j);
				}
			}

		cout << endl;
		}
	}
}


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

int main() {
  
  int n;
  string s;
  cin >> n >> s;
  
  int m = s.size();
  
  REP(i,m) {
    s[i] += n;
    if(s[i] > 'Z') s[i] -= 26;
  }
  
  cout << s << endl;
    
}

Measured memory_bytes: 256
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

bool first = true;

string s, p;
bool input() {
    s = readln.chomp;
    if (s == "") return false;
    string buf;
    while (buf = readln.chomp, buf != "") {
        s ~= buf;
    }
    p = readln.chomp;
    readln;
    return true;
}

void solve() {
    int[char] x;
    bool[char] pset;
    foreach (c; p) pset[c] = true;
    int count = 0;
    int AnsPos = -1, AnsLen = int.max / 2, AnsCount = 0;
    int lb = 0, ub = 0;
    while (true) {
        //writeln([lb, ub]);
        if (count == p.length) {
            if (AnsLen > ub - lb) { 
                AnsPos = lb;
                AnsLen = ub - lb; 
                AnsCount = 1;
            } else if (AnsLen == ub - lb) {
                AnsCount++;
            }
            if (s[lb] in pset) {
                x[ s[lb] ]--;
                if (x[ s[lb] ] == 0) count--;
            }
            lb++;
        } else if (ub < s.length) {
            if (s[ub] in pset) {
                x[ s[ub] ]++;
                if (x[ s[ub] ] == 1) count++;
            }
            ub++;
        } else {
            break;
        }
    }
    //if (first) first = false;
    //else writeln;
    writeln(AnsCount);
    if (AnsCount > 0) {
        writeln;
        while (true) {
            //writeln([s.length], " ", [AnsPos, AnsLen]);
            if (AnsPos + 72 < AnsPos + AnsLen) {
                writeln(s[AnsPos .. AnsPos + 72]);
                AnsPos += 72;
                AnsLen -= 72;
            } else {
                writeln(s[AnsPos .. AnsPos + AnsLen]);
                break;
            }
        }
    }
    writeln;
}

void main() {
    while (input) solve;
}

Measured memory_bytes: 2312
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;

ll match[10] = {0,2,5,5,4,5,6,3,7,6};

bool stra_gt_strb(string a, string b){
  if(a.length() > b.length()){
    return true;
  } else if(a.length() < b.length()){
    return false;
  } else {
    return (a > b);
  }
}
     
int main(){
  ll N, M;

  //cout << sizeof(ll) << endl;

  cin >> N >> M;

  int arr[M];
  for(int i = 0; i < M; ++i){
    cin >> arr[i];
  }

#ifdef DEBUG
  printf("N=%lld, M=%lld\n", N, M);
  for(int i = 0; i < M; ++i){
    cout << arr[i] << " ";
  }
  cout << endl;
#endif

  string dp[N+1];
  dp[0] = "0";
  for(int i = 1; i < N+1; ++i){
    //cout << "i=" << i << endl;
    string tmp_max = "0";
    for(int j = 0; j < M; ++j){
      //cout << "tmp_max=" << tmp_max << endl;
      if(i - match[arr[j]] > 0 && dp[i - match[arr[j]]] != "0"){
	string cur = dp[i - match[arr[j]]] + to_string(arr[j]);
	// cout << "j="<< j << endl;
	// cout << "1: " << dp[i - match[arr[j]]] << endl;
	// cout << "2: " << arr[j] << endl;	
	if( stra_gt_strb(cur, tmp_max) ) tmp_max = cur;
	cur =  to_string(arr[j]) + dp[i - match[arr[j]]];
	if( stra_gt_strb(cur, tmp_max) ) tmp_max = cur;
      }
      if((i - match[arr[j]] == 0) && stra_gt_strb(to_string(arr[j]), tmp_max) )  tmp_max = to_string(arr[j]);
    }
    dp[i] = tmp_max;
  }

  // for(int i = 0; i < N+1; ++i){
  //   cout << dp[i] << " ";
  // }
  // cout << endl;

  cout << dp[N] << endl;
  
  return 0;
}


Measured memory_bytes: 32000
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n, k = MII()
    cnt = 0
    for b in range(k+1, n+1):
        p = n//b
        r = n%b
        if k==0:
            cnt += p*(b-k)+max(0, (r-k))
        else:
            cnt += p*(b-k)+max(0, (r-k+1))
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

h,a=lmp()
print((h-1)//a+1)

Measured memory_bytes: 77464
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  cout << (800 * n) - 200 * (n / 15) << endl;
  return 0;
}

Measured memory_bytes: 384
S = list(input())
S = set(S)
S = list(S)
S.sort()
alphabet = list('abcdefghijklmnopqrstuvwxyz')

if(len(S) == 26):
  print('None')
else:
 for i in range(len(S)):
   alphabet.remove(S[i])
 print(alphabet[0])

Measured memory_bytes: 3956
fun main(args: Array<String>) {
    val (N, W) = readLine()!!.split(" "). map { it.toInt() }
    val dp = LongArray(W+1)
    val w = IntArray(N+1)
    val v = IntArray(N+1)
    for(i in 0 until N) {
        val a = readLine()!!.split(" "). map { it.toInt() }
        w[i] = a[0]
        v[i] = a[1]
    }

    for (i in 0 until N) {
        for (j in W downTo w[i]) {
            dp[j] = Math.max(dp[j], dp[j - w[i]] + v[i])
        }
    }
    println(dp.max())
}

Measured memory_bytes: 40280