akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T> inline void IN(T &x) {
	x = 0; T f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); }
	x *= f;
}
template<typename A, typename B> inline void IN(A &x, B &y) { IN(x); IN(y); }
template<typename A, typename B, typename C> inline void IN(A &x, B &y, C &z) { IN(x); IN(y); IN(z); }
 
#define FastI ios_base::sync_with_stdio(0), cin.tie(0);
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define endl '\n'
#define REP(i, l, r) for (auto i = (l); i <= (r); ++i)
#define PER(i, l, r) for (auto i = (l); i >= (r); --i)
#define FOR(i, l, r) for (auto i = (l); i < (r); ++i)
#define ROF(i, l, r) for (auto i = (l); i > (r); --i)
#define FORN(i, n) for (auto i = 0; i < (n); ++i)
#define REPN(i, n) for (auto i = 1; i <= (n); ++i)
#define FORA(i, a) for (auto &i : a)
template<class T> void cout_1d(T &v) { FORA(i, v) cout << i << " "; puts(""); }
template<class T> void cout_2d(T &vv) { FORA(v, vv) cout_1d(v); }
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define SIZE(X) ((int)(X).size())
#define UNIQUE(x) (X).erase(unique(ALL(x), (X).end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define NEG1(a) memset(a, -1, sizeof(a))
#define MAXA(a) memset(a, 0x3f, sizeof(a))
#define MAXB(b) memset(b, 0x7f, sizeof(b))
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 #define ll long long int
const LD PI = acos(-1.0);
const LL MOD = 998244353;
//const LL MOD = 1e9+7;
const LL MAXN = 2e5 + 7;
 
void solve()
{
	string s1,s2;
	cin >> s1 >> s2;
	VVI dp(s1.size()+1, VI(s2.size()+1, 0));
	int i, j;
	for ( i=0; i <= s1.size(); i++)
	{
		for ( j=0; j <= s2.size(); j++)
		{
			if ( i==0||j==0)
			dp[i][j]=0;
			else if ( s1[i-1] == s2[j-1])
				dp[i][j] = 1+ dp[i-1][j-1];
			else
				dp[i][j] = max( dp[i-1][j], dp[i][j-1]);
		}
	}
	
	

	string s="";
	int n = s1.size();int m= s2.size();
	while ( n > 0 && m > 0)
	{
		if ( s1[n-1] == s2[m-1])
		{
			s+=s1[n-1];
			n--;
			m--;
		}
		else
		{
			if ( dp[n][m-1] < dp[n-1][m])
				n--;
			else
				m--;
		}
	}
	 reverse(s.begin(), s.end());
	cout <<s << endl;

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

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

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

    if (a == 'D') {
        if (b == 'H') {
            b = 'D';
        } else {
            b = 'H';
        }
    }

    cout << b << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m=0;
		for(int i=0;i<n;i++){
			int l = sc.nextInt();
			int r = sc.nextInt();
			m+=r-l+1;
		}
		System.out.println(m);
	}
}


Measured memory_bytes: 25704
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if (u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if (T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if (T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = ( h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
  int pp;
  pp = T[u].parent;
  if ( pp == NIL ) return NIL;
  if ( T[pp].left != u && T[pp].left != NIL )
    return T[pp].left;
  if ( T[pp].right != u && T[pp].right != NIL )
    return T[pp].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].left != NIL ) deg++;
  if ( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if (T[u].parent == NIL) {
    printf("root\n");
  } else if (T[u].left == NIL && T[u].right == NIL ) {
    cout << "leaf" << endl;
  } else {
    cout << "internal node" << endl;
  }
}

int main() {
  int v, l, r, root = 0;
  cin >> n;

  for (int i = 0; i < n; i++) T[i].parent = NIL;

  for (int i = 0; i < n; i++) {
    cin >> v >> l >> r;
    T[v].left = l;
    T[v].right = r;
    if (l != NIL) T[l].parent = v;
    if (r != NIL) T[r].parent = v;
  }

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) root = i;
  }

  setDepth(root, 0);
  setHeight(root);

  for (int i = 0; i < n; i++) print(i);

  return 0;

}


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


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

int gcd3(int a, int b, int c){
    int ab = gcd(a, b);
    return(gcd(ab, c));
}

int main() {
    /*変数定義，入力*/
    int K;
    cin >> K;

    //ll A, B;cin >> A >> B;
    //vector<ll> a(N);  rep(i, N) cin >> a[i];
    
    /*演算*/
    ll sum = 0;

    //3数が等しい
    rep(i, K){
        sum += i + 1;
    }
    //2数が等しい
    rep(i, K){
        rep(j, i){
            sum += gcd3(i + 1, j + 1, j + 1) * 3;
            sum += gcd3(i + 1, i + 1, j + 1) * 3;
        }
    }

    //すべて別の数
    rep(i, K){
        rep(j, i){
            rep(k, j){
                sum += gcd3(i + 1, j + 1, k + 1) * 6;
            }
        }
    }
    
    /*出力*/
    cout << sum << endl;
    /*終了*/
    return 0;
}

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

int n, m;
string ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    cin >> n >> m;
}

void solve(){
    ans = "No";
    if(n == m)
        ans = "Yes";
}

void out(){
    cout << ans;
}


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

bool is_prime(int n)
{
  bool ans = true;
  for (int i = 2; i <= sqrt(n); i++)
  {
    if (n % i == 0)
    {
      ans = false;
      break;
    }
  }
  return ans;
}

int main()
{
  int x;
  cin >> x;
  while (true)
  {
    if (is_prime(x))
    {
      cout << x << endl;
      break;
    }
    x++;
  }
}

Measured memory_bytes: 256
S = input()
T = input()
def diff_count(A,B):
    diff = 0
    for a,b in zip(A,B):
        if a!=b:
            diff += 1
    return diff
ans = len(T)
for i in range(len(S) - len(T)+1):
    temp = S[i:i+len(T)]
    diff_num = diff_count(T,temp)
    ans = min(diff_num,ans)
print(ans)

Measured memory_bytes: 9072
#include<bits/stdc++.h>
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define INF 1e10
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define MM int m=(l+r)>>1;
#define len (r-l+1)
using namespace std;
const int maxn = 1e5+10;
int n,m,a[maxn],b[maxn];
int32_t main(){
    IOS;
    cin>>n>>m;
    cout<<n-m+1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll k, now;
    cin >> k;
    priority_queue<ll, vector<ll>, greater<ll>> que;
    REP(i, 9)que.push(i);
    rep(i, k){
        now = que.top();
        que.pop();
        if(now % 10 == 0){
            que.push(now*10);
            que.push(now*10+1);
        }
        else if(now % 10 == 9){
            que.push(now*10+9);
            que.push(now*10+8);
        }
        else{
            ll a = now % 10;
            que.push(now*10+a);
            que.push(now*10+a+1);
            que.push(now*10+a-1);
        }
    }
    cout << now << endl;
}   

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

int main() {
	string a, b; cin >> a >> b;
	int num = atoi((a + b).c_str());
	int sq = sqrt(num);

	cout << (sq * sq == num ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <climits>

using namespace std;

typedef pair<int, int> PII;

const int M = 100005;

int n, m, q;

int a[M];
bool used[M];
int cnt[M], ord[M];
vector<int> seq;

void add(int x) {
  if (!used[x]) {
    int f = seq.size();
    used[x] = true;
    ord[x] = f;
    if (cnt[f] > 0) {
      cnt[f] -= 1;
      cnt[f + 1] += 1;
    }
    seq.push_back(x);
  } else {
    int k = ord[x];
    if (cnt[k] > 0) {
      cnt[k] -= 1;
      cnt[k + 1] += 1;
    }
  }
}

int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < q; i += 1) {
    cin >> a[i];
    a[i] -= 1;
  }
  reverse(a, a + q);
  cnt[0] = n;
  for (int i = 0; i < q; i += 1) add(a[i]);
  for (int i = 0; i < m; i += 1) if (!used[i]) seq.push_back(i);
  int sh = 0;
  while (!cnt[sh]) sh += 1;
  auto alt = seq;
  sort(alt.begin() + sh, alt.end());
  if (alt == seq) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int cnt[100005];
int main() {
	int n;
	cin >> n;
	int a;
	while(n--){
	    cin >> a;
		cnt[a - 1]++;
		cnt[a]++;
		cnt[a + 1]++;
	}
	int max=0;
	for(int i = 0;i < 100005; i++){
		if(cnt[i] > max){
            max = cnt[i];
        }
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <vector>
#define REP(a,b) for(int a=0; a<(b); ++a)
#define x first
#define pb push_back
#define mp make_pair
#define y second
#define all(a) a.begin(), a.end()
#define l(x) (x<<1)
#define r(x) ((x<<1) | 1)
#define lsb(x) (x&(-x))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef VI::iterator vit;
typedef tuple<int,int,int> PIII;
const int inf=2e9+5;
const LL LLinf=9e18+5;
const int LOGMAX=18;
const int MOD=70657;
const LD pi=acos(-1.0);
const int NMAX = 100000+69;
const int INF = 0x3f3f3f3f;
const int dx[] = {0,0,-1,1,1,1,-1,-1};
const int dy[] = {-1,1,0,0,1,-1,1,-1};


int dpl[5005][5005];
int dpr[5005][5005];
int A[5005];
int rs, n, k;

int solve(){
  cin>>n>>k;
  for(int i=1; i<=n; ++i)
    cin>>A[i];

  dpl[0][0]=1;
  for(int i=1; i<=n; ++i){
    dpl[i][0] = 1;
    for(int j=0; j<k; ++j) 
    {
      dpl[i][j] |= dpl[i-1][j];
      if(j + A[i] < k)
        dpl[i][j+A[i]] |= dpl[i-1][j];
    }
  }

  dpr[n+1][0]=1;
  for(int i=n; i>=1; --i){
    dpr[i][0] = 1;
    for(int j=0; j<k; ++j) 
    {
      dpr[i][j] |= dpr[i+1][j];
      if(j + A[i] < k)
        dpr[i][j+A[i]] |= dpr[i+1][j];
    }
  }
  for(int i=n+1; i>=0; --i){
    for(int j=0; j<k; ++j) 
    {
      if(j >= 1)
      dpr[i][j] += dpr[i][j-1];
    }
  }
  rs = n;

  for(int i=1; i<=n; ++i){
    bool qh = 0;
    for(int j=0; j<k; ++j){
      if(dpl[i-1][j]) {
        if(k-j-1>=0){
          int q = dpr[i+1][k-j-1];
          if(k-A[i]-j-1 >= 0){
            q -= dpr[i+1][k-A[i]-j-1];
          }
          if(q > 0){
            qh = 1;
          }
        }
      }
    } 

    rs-=qh;
  }
  cout<<rs<<"\n";
  return 0;
}

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

  solve();
	 
	return 0;
}


Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD = 1000000007;
ll cnt =0,ans=0;
const int MAX = 510000;

int main(){
    int n;  cin >> n;
    
    ll a = 1;
    vector<ll> b(n);
    for(int i=0;i<n;i++) {
        cin >> b[i];
        
    }

    for(int i=0;i<n;i++){
        if(b[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    for(int i=0;i<n;i++){
        if(b[i]<=1000000000000000000/a){
             a *= b[i];
             }
        else {
            cout << -1 << endl;
            return 0;
            }
        }
         cout << a << endl;
    }
       


Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

mat bunkai(ll a){
  if(a<=0) return {};
  if(a==1) return {{1,1}};
  vector<ll> f;
  ll b=a;
  for(ll i=2;i*i<=a;i++){
    if(b%i==0){
      f.push_back(i);
      b=b/i;
      i--;
    }
  if(b==1)break;
  }
  if(b!=1)f.push_back(b);

  vector<vector<ll>> u;
  ll p=f[0];
  ll c=1;
  for(ll i=1;i<f.size();i++){
    if(f[i]==p)c++;
    else{
      u.push_back({p,c});
      p=f[i];
      c=1;
    }
  }
  u.push_back({p,c});

  return u;
}

int main(){

  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++)cin >> a[i];
  vector<vector<ll>> F(1000001);//Fは1~10^6の素因数分解(既に計算したものを入れていく)

  for(ll i=1;i<1000001;i++){
    if(i==1)F[i]={1};
    else{
      for(ll j=2;j*j<=i;j++){
        if(i%j==0){
          F[i]=F[i/j];
          F[i].push_back(j);
          break;
        }
      }
      ll b=F[i].size();
      if(b==0)F[i].push_back(i);
      sort(F[i].begin(),F[i].end());
    }
    //cout << i << endl;
  }

  //cout << 5 << endl;


  //cout << 5 << endl;

  vec s(1000001);

  //cout << 5 << endl;

  for(ll i=0;i<n;i++){
    //cout << 5 << endl;
    vec f=F[a[i]];
    vector<vector<ll>> u;
    ll p=f[0];
    ll c=1;
    for(ll i=1;i<f.size();i++){
      if(f[i]==p)c++;
      else{
        u.push_back({p,c});
        p=f[i];
        c=1;
      }
    }
    u.push_back({p,c});    
    for(ll j=0;j<u.size();j++){
      s[u[j][0]]++;
    }
    //cout << i << endl;
  }

  //cout << 5 << endl;

  ll m=0;
  for(ll i=2;i<1000001;i++)m=max(m,s[i]);

  if(m<=1)cout << "pairwise coprime" << endl;
  else if(m<n) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;


}

Measured memory_bytes: 100084
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  char s[10000];
  cin>>s;
  int m=strlen(s);
  for(int i=0;i<m;i++){
    if(s[i]+n<91) cout<<char(s[i]+n);
    else cout<<char(s[i]+n-90+64);
  }
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long n = ILongs()[0];
            WriteLine((n-1)*n/2);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}



int main(){

ios::sync_with_stdio(false);
cin.tie(0);
int a,b,c,d;

cin>>a>>b>>c>>d;

while(true){
c-=b;
if(c<=0){
cout<<"Yes"<<endl;
break;
}
a-=d;
if(a<=0){
cout<<"No"<<endl;
break;
}

}


}



//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;



Measured memory_bytes: 3636
### subroutines

def calc_score(srv)
  asc = bsc = 0
  nsrv = srv.length

  for i in (1...nsrv)
    if srv[i] == 'A'
      asc += 1
    else
      bsc += 1
    end
  end

  if asc > bsc
    asc += 1
  else
    bsc += 1
  end

  [asc, bsc]
end

### main

while true

  line = gets.strip
  break if line == '0'

  srvs = []
  srvs << line.split('')
  srvs << gets.strip.split('')
  srvs << gets.strip.split('')

  for srv in srvs
    asc, bsc = calc_score(srv)
    puts "#{asc} #{bsc}"
  end
end

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

using namespace std;

int x[26];
int main() {
    int n; cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        x[s[i] - 'a']++;
    }
    long long res = 1;
    for (int i = 0; i < 26; i++) {
        res = 1LL * res * (x[i] + 1) % 1000000007;
    }
    cout << res - 1 << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n=as.nextInt();
		String a = as.next();
		int l = 0;
		int s = 0;
		for(int i=0;i<n;i++){
			if(String.valueOf(a.charAt(i)).equals("I")){
				s++;
			}else{
				s--;
			}
			l = Math.max(l, s);
		}
		System.out.println(l);
	}
}

Measured memory_bytes: 10196
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def MS(): return map(str,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

a, b, c, k = MI()

if k <= a:
    print(k)
elif a < k <= a + b:
    print(a)
else:
    print(a - (k - a - b))

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

int xmax[100005];
int main(){
  int w, h, n;
  cin >> w >> h >> n;
  fill(xmax, xmax+h+1, 0);
  for(int i=0; i<n; i++) {    int x, y;
    cin >> x >> y;
    xmax[y]=max(xmax[y], x);
  }
  for(int i=h-2; i>=0; i--){
    xmax[i]=max(xmax[i], xmax[i+1]);
  }
  int ans=1234567890;
  for(int i=0; i<h; i++){
    ans=min(ans, i+xmax[i+1]);
  }
  cout << ans << endl;
}

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

int main(){
  int H, W, D;
  cin >> H >> W >> D;
  unordered_map<int, pair<int, int> > mp;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      int a;
      cin >> a;
      mp[a] = make_pair(i+1,j+1);
    }
  }
  vector<int> val(H*W);
  for (int i=0; i<H*W; i++){
    if (i<D) val[i] = 0;
    else val[i] = val[i-D] + abs(mp[i+1].first-mp[i+1-D].first) + abs(mp[i+1].second-mp[i+1-D].second);
  }
  int Q;
  cin >> Q;
  vector<int> ans(Q);
  for (int i=0; i<Q; i++) {
    int l, r;
    cin >> l >> r;
    ans[i] = val[r-1] - val[l-1];
  }
  for (int i=0; i<Q; i++) cout << ans[i] << endl;
  return 0;
}


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

using namespace std;

int seen[111111];

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

	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		seen[x]++;
	}

	long long ans = 1;
	bool valid = true;
	for (int i = n-1; i >= 0; i -= 2) {
		if (i == 0) {
			valid &= (seen[i] == 1);
		} else {
			ans *= 2;
			ans %= 1000000007;
			valid &= (seen[i] == 2);
		}
	}

	if (!valid) {
		cout << 0;
		return 0;
	}

	cout << ans;
}

Measured memory_bytes: 640
def main():
    N = int(input())
    a = map(int, input().split())
    single = double = triple = 0
    for sushi in a:
        if sushi == 1:
            single += 1
        elif sushi == 2:
            double += 1
        elif sushi == 3:
            triple += 1
    dp = [[[0 for i in range(1+single+double+triple-j-k)]
           for j in range(double + triple + 1 - k)] for k in range(triple + 1)]
    for k in range(triple+1):
        for j in range(double + triple + 1-k):
            for i in range(1+single+double+triple-j-k):
                if i == 0 and j == 0 and k == 0:
                    continue
                first = second = third = 0
                if i-1 >= 0 and j >= 0 and k >= 0:
                    first = dp[k][j][i-1]
                if i+1 >= 0 and j-1 >= 0 and k >= 0:
                    second = dp[k][j - 1][i+1]
                if i >= 0 and j+1 >= 0 and k-1 >= 0:
                    third = dp[k-1][j + 1][i]
                dp[k][j][i] = (first*i + second * j +
                               third * k + N) / (i + j + k)
    print(dp[triple][double][single])


if __name__ == "__main__":
    main()


Measured memory_bytes: 156168
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> h(n + 1);
    forn (i, 1, n + 1)
        cin >> h[i];
    h[0] = -1e9;
    vector <int> dp(n + 1, 1e9);
    dp[1] = 0;
    forn (i, 2, n + 1) {
        for (int j = i - 1; j >= i - k && j >= 0; --j)
            chkmin(dp[i], dp[j] + abs(h[i] - h[j]));
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    string g;
    cin>>g;
    if(g=="#")break;
    int y,m,d;
    cin>>y>>m>>d;
    if(y<=30||(y==31&&m<4)||(y==31&&m==4&&d<=30))cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
    else cout<<"? "<<y-30<<" "<<m<<" "<<d<<endl;
  }
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  string s,t;
  cin>>s>>t;
  ll a=0,i=0;

while(i<s.size())
{
  if(s[i]!=t[i])
    a++;
  i++;
}
deb(a)
}

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

int main(){
 int n, m;  cin >> n >> m;

 vector<ll> br(n+1, true);
 vector<ll> path(n+1, 0);
 for(int i=0; i<m; i++){
   int x; cin >> x;
   br.at(x) = false;
 }

  path[0] = 1;
  if(br[1]) path[1] = path[0];
 for(int i=2; i<=n;i++){
   if(!br[i]) continue;
   if(br[i-1] && br[i-2]) path[i] = (path[i-1]+path[i-2])%MOD;
   else if(br[i-1]) path[i] = path[i-1];
   else if(br[i-2]) path[i] = path[i-2];
 }
 cout << path[n] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<string> data;
  string tmp;
  tmp = s.at(0);
  data.push_back(tmp);
  int p;
  for(int i=1;i<n;i++){
    tmp = s.at(i);
    p = data.size() - 1;
    if(i==n-1){
      if(tmp != data.at(p)){
        data.push_back(" ");
      }
      break;
    }
    if(tmp == data.at(p)){
      data.push_back(tmp);
      tmp = s.at(i+1);
      data.at(p+1) += tmp;
      i++;
    }else{
      data.push_back(tmp);
    }
  }
  p = data.size();
  cout << p << endl;
}

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

int main() {
    int h,w,count;
    cin>>h>>w;
    vector<string> s(h);
    int dx[8]={1,0,-1,0,1,-1,-1,1};
    int dy[8]={0,1,0,-1,-1,-1,1,1};
    rep(i,h) cin>>s[i];
    rep(i,h) {
        rep(j,w) {
            if (s[i][j]=='#') continue;
            count=0;
            rep(dir,8) {
                int nh=i+dy[dir];
                int nw=j+dx[dir];
                if (nh<0||nh>=h||nw<0||nw>=w) continue;
                if (s[nh][nw]=='#') count++;
            }
            s[i][j]='0'+count;
        }
    }
    rep(i,h) {
        rep(j,w) {
            cout<<s[i][j];
        }
        cout<<endl;
    }
}



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

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputNum = br.readLine().split(" ");

		if(toInt(inputNum[0]) <  toInt(inputNum[1])  && toInt(inputNum[1]) < toInt(inputNum[2])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

	public static int toInt(String stringNum){
		return Integer.parseInt(stringNum);
	}

}

Measured memory_bytes: 17024
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e10
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;

//bit全探索
vector<ll>bitSearch(int bit,int n){
    vector<ll>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    S.push_back(1e9);
    return S;
}

int main(){
   int n;
   cin >> n;
   vector<ll> a(n);
   bool f = true;
   rep(i, n){
      cin >> a[i];
      if(i == 0)continue;
      if(a[i - 1] != a[i])f = false;
   }
   if(f){
      cout << n << endl;
      return 0;
   }
  
   vector<ll> list(n);
   rep(i, n){
      list[i] = - (2 * n) + i;
   }
   rep(i, n){
      int lb = lower_bound(ALL(list), a[i]) - list.begin();
      if(list[lb] < 0){
         list[lb] = a[i];
      }
      else {
         list[lb - 1] = a[i];
      }
     //sort(ALL(list));
   }
   ll res = 0;
   rep(i, n){
      if(list[i] > 0)res++;
   }
   cout << res << endl;
  //for(auto l : list)cout << l << " ";
}

Measured memory_bytes: 4404
import scala.io.StdIn.{readInt,readLine}

object Main {

  def main(args:Array[String]) = {
    var n = 0
    while( {n=readInt;n} != 0 ){
      val list = for(i<-1 to n) yield {
        val s = readLine.split(" ")
        (s(0), s(2).toDouble/((s(1).toDouble/100)*(s(1).toDouble/100)))
      }
      println(list.sortWith{(x,y) => Math.abs(22.0-x._2) < Math.abs(22.0-y._2)}.take(1)(0)._1)
    }
  }
}

Measured memory_bytes: 46452
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
using namespace std;

int main(){
    int N;
    double v[100];
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> v[i];
    }
    sort(v, v + N);
    double ans = (v[0] + v[1])/2;
    for(int i = 2; i < N; i++){
        ans = (ans + v[i]) /2;
    }
    cout << ans << endl;
    return 0;
}

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

const long MAX = 200000;
#define SENTINEL 2000000000;


int L[MAX/2 +2],R[MAX/2 +2];

long long merge (int A[],int n,int left,int mid, int right){
    int i,j,k;
    long long cnt = 0;
    int n1 = mid -left;
    int n2 = right - mid;
    for (int i = 0; i < n1 ; ++i) L[i] = A[left + i];
    for (int i = 0; i < n2 ; ++i)  R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    i = j = 0;
    for (int k = left; k < right ; ++k) {

        if(L[i] <= R[j]){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
            cnt += n1 - i; //=mid+j-k-1
        }
    }
    return cnt;
}

long long mergesort(int A[],int n, int left,int right){
    int mid;
    long long v1,v2,v3;
    if(left + 1 < right){
        mid = (left + right)/2;
        v1 = mergesort(A,n,left,mid);
        v2 = mergesort(A,n,mid,right);
        v3 = merge(A,n,left,mid,right);
        return v1 + v2 + v3;
    } else return 0;
};

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

    cin >> n;
    for ( i = 0; i < n ; ++i) {
        cin >> A[i];
    }

    long long ans = mergesort(A,n,0,n);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2716
h,w=map(int,input().split())
maze=[list(input()) for _ in range(h)]
dx=[1,0,-1,0]
dy=[0,1,0,-1]
queue=[]
ans = 0
cn = 0
for i in maze:
     cn += i.count("#")
queue.append([0,0,0])
while len(queue)>0:
    x,y,cnt=queue.pop(0)
    ans=cnt
    if x == h - 1 and y == w - 1:
        print(h*w-ans-cn-1)
        exit()
    for i in range(4):
        X=x+dx[i]
        Y = y + dy[i]
        if not (0 <= X < h and 0 <= Y < w):
             continue
        if maze[X][Y]=="#":
            continue
        if maze[X][Y]==".":
            queue.append([X,Y,cnt+1])
            maze[X][Y]="#"
print(-1)


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  REP(i, 1, n - 1) {
    if ((p[i] < p[i + 1] && p[i] > p[i - 1]) ||
        (p[i] < p[i - 1] && p[i] > p[i + 1]))
      ans++;
  }
  cout << ans << endl;
}


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

int main(void){
  int time, sum = 0;
  cin >> time;
  vector<vector<int>> num(time, vector<int>(2));
    
  for(int i = 0; i < time; i++){
    cin >> num.at(i).at(0) >> num.at(i).at(1);
    sum += num.at(i).at(1) - num.at(i).at(0) + 1;
  }
  cout << sum << endl;
}

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

int main() {
	double weight;
	while (cin >> weight) {
		if (weight <= 48.00) cout << "light fly" << endl;
		else if (weight <= 51.00) cout << "fly" << endl;
		else if (weight <= 54.00) cout << "bantam" << endl;
		else if (weight <= 57.00) cout << "feather" << endl;
		else if (weight <= 60.00) cout << "light" << endl;
		else if (weight <= 64.00) cout << "light welter" << endl;
		else if (weight <= 69.00) cout << "welter" << endl;
		else if (weight <= 75.00) cout << "light middle" << endl;
		else if (weight <= 81.00) cout << "middle" << endl;
		else if (weight <= 91.00) cout << "light heavy" << endl;
		else cout << "heavy" << endl;
	}
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
int D, X;
int A[100];

void solve(){
	D--;
	rep(i, N){
		X += D / A[i] + 1;
	}
	cout << X << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> D >> X;
	rep(i, N) {
		cin >> A[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 256
import collections
N,M=map(int,input().split())
L=list(map(int,input().split()))
R=[0]
sums=0
for i in L:
  sums+=i
  sums=sums%M
  R.append(sums)
c = collections.Counter(R)
A=list(c.values())
A=[i*(i-1)//2 for i in A]
print(sum(A))

Measured memory_bytes: 21364
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str  = sc.nextLine();
        String[] astr = str.split(" "); //状況に合わせて
        Boolean flag  = true;
        int[] in_data = Stream.of(astr).mapToInt(x->{
            try{
                return Integer.parseInt(x);
            }
            catch(Exception e){
                e.printStackTrace();
            }
            return 0;
        }).toArray();
        sc.close();

        int r = in_data[0];
        int d = in_data[1];
        int x = in_data[2];
        int tmp = x;
        int ans = 0;

        for(int i=0;i<10;i++){
            ans = r*tmp - d;
            tmp = ans;
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 26452
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string str;
        string[] strer = new string[2];
        var strlist = new List<string>();
        var data = new List<int>();
        int cou = 0;
       
        do
        {
            str = Console.ReadLine();
            if (str == "0 0")
            {
                break;
            }

            strer = str.Split(' ');

            foreach (string s in strer)
            {
                data.Add(int.Parse(s));
            }            
          
        } while (true);

        
        for (int i = 0; i < (data.Count/2); i++)
        {

            for (int j =0; j < data[cou]; j++)
            {

                if ( (j % 2) == 0 )
                {
                    for ( int k = 0; k < data[cou + 1]; k++)
                    {
                        if ((k % 2) == 0 )
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }

                }

                else
                {
                    for ( int k = 0; k < data[cou + 1]; k++ )
                    {
                        if ( (k % 2) == 0 )
                        {
                            Console.Write(".");
                        }
                        else
                        {
                            Console.Write("#");
                        }
                    }

                }
                
                Console.Write("\n");
            }
            Console.Write("\n");
            cou += 2;

        }
               
    }
}


Measured memory_bytes: 17808
freq = [[0, 0], [0, 0], [0, 0], [0, 0]]
while line = gets
    score = line.chomp.split.map(&:to_f)
    score.each_with_index{|s, i|
        case s
        when 1.1 .. 2.0 then freq[0][i] += 1
        when 0.6 .. 1.0 then freq[1][i] += 1
        when 0.2 .. 0.5 then freq[2][i] += 1
        else freq[3][i] += 1
        end
    }
end
freq.each{|f| puts f.join(" ")}

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

using namespace std;

int main() {
	cin.sync_with_stdio(false);

	string s;
	cin >> s;
	int count_a;
	int count_z;
	int flag_a = true;
	int flag_z = true;
	for (int i = 0;i < s.length();i++) {
		if (flag_a && s[i] == 'A') {
			count_a = i;
			flag_a = false;
		}
		if (flag_z && s[s.length() - i - 1] == 'Z') {
			count_z = s.length() - i;
			flag_z = false;
		}
		if (!flag_a && !flag_z) {
			break;
		}
	}
	cout << count_z - count_a << endl;
	return 0;
}

Measured memory_bytes: 720
//
// Created by Imamura, Yuta on 2020/02/09.
//
#include <bits/stdc++.h>
using namespace std;

// repr(i,10,13) -> 10,11,12
#define repr(i,a,b) for(int i=a;i<b;i++)
// rep(i,3) -> 0,1,2
#define rep(i,n) for(int i=0;i<n;i++)
// reprrev(i,10,13) -> 12,11,10
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
// reprev(i,3) -> 2,1,0
#define reprev(i,n) reprrev(i,0,n)

vector<vector<char>> s;
vector<vector<char>> t;
vector<vector<int>> a;

int main() {
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    s = vector<vector<char>>(h, vector<char>(w));
    t = vector<vector<char>>(h, vector<char>(w));
    a = vector<vector<int>>(h, vector<int>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> s[i][j];
        }
    }
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '.') {
                repr(k, i-1, i+2) {
                    if (k < 0 || k > h - 1) continue;
                    repr(l, j-1, j+2) {
                        if (l < 0 || l > w - 1) continue;
                        if (s[k][l] == '#') {
                            a[i][j]++;
                        }
                    }
                }
                printf("%c", '0' + a[i][j]);
            } else {
                printf("%c", '#');
            }
        }
        printf("\n");
    }
}

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

using namespace std;

long long f(long long);

int main(int argc, char const *argv[]) {
  long long n, a, b, ans, sum;

  cin >> n >> a >> b;

  ans = 0;

  for (long long i = 1; i <= n; i++)
  {
    sum = f(i);
    if (sum >= a && sum <= b)
    {
      ans += i;
    }
  }

  cout << ans << endl;

  return 0;
}

long long f(long long x)
{
  if (x / 10 == 0)
  {
    return x;
  }
  else
  {
    return f(x / 10) + x % 10;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<int> rain(N, 0); // 2つ前の山との降水量の差
  for (int i = 0; i < N-2; i++) rain[i+2] = (A[i+1] - A[i])*2;
  rain[1] = (A[0] - A[N-1])*2;
  int sub = rain[1];
  for (int i = 0; i < N; i+=2) sub += rain[i];
  int Rain = A[0] - (sub/2); // 山1の降水量
  vector<int> ans(N, Rain);
  int tmp = 0;
  for (int i = 0; i < N; i+=2) {
    tmp += rain[i];
    ans[i] += tmp;
  }
  for (int i = 1; i < N-1; i+=2) {
    tmp += rain[i];
    ans[i] += tmp;
  }
  for (int i = 0; i < N; i++) cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 4548
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] KS = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int res = 0;
        for (int i = 0; i <= KS[0]; i++)
        {
            for (int j = 0; j <= KS[0]; j++)
            {
                if (0 <= KS[1] - (i + j) && KS[1] - (i + j) <= KS[0]) res++;
            }
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef vector<int> Vi;
typedef vector<vector<int>> VVi;
typedef pair<int, int> pii;

int n, k;

void init()
{
	cin >> n >> k;
}


int main()
{
	init();

	int lim = (n - 1) * (n - 2) / 2;
	if (k > lim)
	{
		cout << -1 << endl;
		return 0;
	}

	vector<pii> edges, candidates;

	REP(i, n - 1)
		edges.emplace_back(pii(i + 1, n));

	REP(i, n - 2)
		for(int j = i + 1; j < n - 1; ++j)
			candidates.emplace_back(pii(i + 1, j + 1));

	int cur = lim;
	int i = 0;
	for (; cur > k; --cur)
	{
		edges.emplace_back(candidates[i++]);		
	}

	cout << edges.size() << endl;
	for (auto edge : edges)
	{
		cout << edge.first << " " << edge.second << endl;
	}

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define sq(x) x * x
#define ll long long
#define pb push_back
#define mk make_pair
#define ld long double
#define pr pair<int,int>
#define sz(s) int(s.size())
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 2e2+7;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;
ll a, b, n , cnt ,mx,ans,c;
ll used[ N ];
string s;
int main()
{
        TIME;
        cin >> s;
        for( int i = 0;i < 3;i ++ ){
            if( s[i]=='1' )
                s[i]='9';
            else
                s[i]='1';
        }
        cout << s << endl;
        return 0;
}


/* MADE BY
//________________________________________________________
//________________________________________________________ //
                                                           //
// ██╗   ██╗     ██████╗     ███████╗    ██╗    ███╗   ██╗ //
// ╚██╗ ██╔╝    ██╔═══██╗    ██╔════╝    ██║    ████╗  ██║ //
//  ╚████╔╝     ██║   ██║    ███████╗    ██║    ██╔██╗ ██║ //
//   ╚██╔╝      ██║   ██║    ╚════██║    ██║    ██║╚██╗██║ //
//    ██║       ╚██████╔╝    ███████║    ██║    ██║ ╚████║ //
//    ╚═╝        ╚═════╝     ╚══════╝    ╚═╝    ╚═╝  ╚═══╝ //
//________________________________________________________ //
//________________________________________________________ */


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

#define ll long long int

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


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

    int A, B, C; cin >> A >> B >> C;
    int res = C - min(C, A - B);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x);
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = {0,1,0};

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

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

	int n = s.size();

	reverse(s.begin(),s.end());

	bool flag = false;

	for (int i = 0; i < n-1; i++) {
		if (s[i] != '9') {
			flag = true;
			s[i] = '9';
		}
	}

	if (flag) {
		cout << (s[n - 1] - '1') + (n - 1) * 9 << endl;
	}
	else {
		cout << (s[n-1] - '0') + (n-1) * 9  << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
    int x, y;
    if (scanf("%d%d", &x, &y) < 2) return 0;

    if ((x > 0 && y > 0) || (x < 0 && y < 0))
    {
        if (x < 0)
        {
            if (abs(y) > abs(x)) printf("%d\n", abs(y) - abs(x) + 2);
            else printf("%d\n", abs(x) - abs(y));
        }
        else
        {
            if (abs(y) > abs(x)) printf("%d\n", y - x);
            else printf("%d\n", abs(x) - abs(y) + 2);
        }
    }
    else
    {
        if (abs(x) == 0 && y > 0) printf("%d\n", abs(y));
        else if (abs(y) == 0 && x > 0) printf("%d\n", abs(x) + 1);
        else if (abs(y) > abs(x)) printf("%d\n", abs(y) - abs(x) + 1);
        else if (abs(y) == 0) printf("%d\n", abs(x));
        else printf("%d\n", abs(x) - abs(y) + 1);
    }

    return 0;
}


Measured memory_bytes: 128