akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;
    vector<int> v(n), c(n);
    for(int i = 0; i < n; ++i)  cin >> v[i];
    for(int i = 0; i < n; ++i)  cin >> c[i];
    vector<int> table;
    for(int i = 0; i < n; ++i){
        table.emplace_back(v[i] - c[i]);
    }
    sort(table.begin(), table.end());
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(table[i] > 0)    ans += table[i];
    }
    cout << ans << endl;
}

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

#define PI acos(-1)
#define pb push_back
#define lli long long int
#define mp make_pair
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  (n % 1000 == 0) ? cout << "0\n" : cout << 1000 - (n % 1000) << endl;
  return 0;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

int N;
int A[200005];

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>A[i];
    int ans=0;
    int ma=A[0];
    for(int i=1;i<N;++i){
        if(A[i]<ma)ans+=ma-A[i];
        chmax(ma,A[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5164
import java.util.*;
public class Main {
  public static void main(String [] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int cnt[] = new int[N];
      int cnt1 = 0;
      int cnt2 = 0;
      int cnt3 = 0;
      int cnt4 = 0;
      int cnt5 = 0;
      int cnt6 = 0;
      int cnt7 = 0;
      int cnt8 = 0;
      int cnt9 = 0;
      int min = 0;
      int max = 0;
      for (int  i = 0 ; i < N ; i++) {
        int a = sc.nextInt();
        if (a >= 1 && a <= 399) {
          cnt1 = 1;
        } else if (a >= 400 && a <= 799) {
          cnt2 = 1;
        } else if (a >= 800 && a <= 1199) {
          cnt3 = 1;
        } else if (a >= 1200 && a <= 1599) {
          cnt4 = 1;
        } else if (a >= 1600 && a <= 1999) {
          cnt5 = 1;
        } else if (a >= 2000 && a <= 2399) {
          cnt6 = 1;
        } else if (a >= 2400 && a <= 2799) {
          cnt7 = 1;
        } else if (a >= 2800 && a <= 3199) {
          cnt8 = 1;
        } else if (a >= 3200 && a <= 4800) {
          cnt9++;
        } 
      }
      min = cnt1 + cnt2 + cnt3 + cnt4 + cnt5 + cnt6+ cnt7 + cnt8;
      max = min + cnt9;
      if (min == 0) {
        min = 1;
      }
      System.out.println(min + " " + max);
  }
}

Measured memory_bytes: 19924
#define _CRT_SECURE_NO_WARNING

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm> 
using namespace std;
typedef long long ll;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>9||b>9)
	{
		printf("-1\n");
		return 0;
	}
	printf("%d\n",a*b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    long a,b,n;
    cin >> a >> b >> n;
    long ans;
    if(n>=b){
        cout << (a*(b-1))/b;
    }    
    else{
        cout << (a*n)/b;
    }

    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// ?¨??????\???????????????????????????????????????
Scanner sc = new Scanner(System.in);
int w = sc.nextInt();
int n = sc.nextInt();
int[] values = new int[w];
for (int i = 0; i < values.length; i++) {
values[i] = i + 1;
}
for (int i = 0; i < n; i++) {
String str = sc.next();
String[] ab = str.split(",");
int a = Integer.parseInt(ab[0]) - 1;
int b = Integer.parseInt(ab[1]) - 1;
// a??¨b????????£???values??????????????????

int c;
c=values[a];
values[a]=values[b];
values[b]=c;

}
// values??????????????????
for(int i=0;i<n;i++){
  System.out.println(values[i]);
}
}
}

Measured memory_bytes: 26308
n = input()

ans = 0

x = y = z = 0
for _ in xrange(n):
    s = raw_input().strip()
    for i in xrange(len(s) - 1):
        if s[i] == 'A' and s[i + 1] == 'B': ans += 1

    if s[0] == 'B' and s[-1] == 'A': z += 1
    elif s[0] == 'B': y += 1
    elif s[-1] == 'A': x += 1

m = min(x, y)
ans += m + z

if x == 0 and y == 0:
    if z > 0: ans -= 1

ans = max(0, ans)
print ans

Measured memory_bytes: 33900
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int a[100000];
int main(){
	int n,l,min=1000000;
	cin>>n>>l;
	for(int i=1;i<=n;i++){
		a[i]=l+i-1;
	} 
	int s=0;
	for(int i=1;i<=n;i++){
		s=s+a[i];
	}
	for(int i=1;i<=n;i++){
		if(abs(s-(s-a[i]))<min)min=abs(s-(s-a[i]));
	}
	if(s<0)cout<<s+min;
	else cout<<s-min;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,j;
    double sum=0,s,p;
    char str1[20],ch[20];

    scanf("%s %s",str1,ch);

   strcat(str1,ch);

   n=strlen(str1);
    for(i=n-1,j=0; i>=0; j++,i--)
   {
       sum+=(str1[i]-48)*pow(10,j);
   }


    s=sqrt(sum);

    p=floor(s);

    //cout<<p<<endl<<s;

    if(p==s)cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll dp[100001][2];
int main(){
    int n;
    cin >> n;
    VLL a(n);
    rep(i,n) cin >> a[i];


    dp[0][1] = -a[0];
    dp[0][0] = a[0];
    FOR(i,1,n){
        //使わない
        dp[i][0] = max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]);
        dp[i][1] = max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]);
    }
    cout << dp[n-1][0] << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n, i, j;
  string s;

  cin >> n >> s;

  ll r, g, b;
  r = g = b = 0;

  for(i=0;i<n;i++){
    if(s[i]=='R'){
      ++r;
    }
    else if(s[i]=='G'){
      ++g;
    }
    else if(s[i]=='B'){
      ++b;
    }
  }

  ll cnt = 0;

  for(i=1;i<=n/2;i++){
    j = 0;
    while(2*i+j<n){
      if(s[j]!=s[j+i]&&s[j]!=s[j+2*i]&&s[j+i]!=s[j+2*i]){
        ++cnt;
      }
      ++j;
    }
  }

  cout << r * g * b - cnt << endl;

  return 0;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  
  int count = 0;
  
  for(int i = 0; i < 3; i++){
    if(s.at(i)==t.at(i)){
      count++;
    }
    else{
      continue;
    }
  }
  
  cout << count << endl;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = 0;
  for(int i = 1; i < n; ++i) {
    if(a[i] < a[i - 1]) ans += a[i - 1] - a[i];
    a[i] = max(a[i], a[i - 1]);
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3984
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
SS ss;
#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int x,y,z;
int v[5],n,e,a;
int jump[60],add[60];
double mem[60][5010];

int main() {
	IL{
		cin>>x>>y>>z;
		if(x==0&&y==0&&z==0)break;
		rep(i,x)cin>>v[i];
		memset(jump,0,sizeof(jump));
		memset(add,0,sizeof(add));
		rep(i,z){
			cin>>n>>e>>a;
			if(e==1)jump[n]=a;
			if(e==2)add[n]=a;
			if(e==3)add[n]=-a;
		}
		repc(i,y)rep(j,5010)mem[i][j]=0;
		mem[0][0]=1;
		rep(i,y)rep(j,5010)if(mem[i][j]>0)rep(k,x){
			int next=i+v[k];
			if(next>y)next=y;
			int value=j+add[next];
			if(value<0)value=0;
			next+=jump[next];
			if(next>y)next=y;
			mem[next][value]+=mem[i][j]/x;
		}
		double res=0;
		rep(j,5010)res+=mem[y][j]*j;
		cout<<(int)res<<endl;
	}
	return 0;
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for(int i=0; i<n; i++) {
        cin >> c[i];
        for(int j=0; j<m; j++) cin >> a[i][j];
    }
    int ans = 1e9;
    for(int s=0; s < 1 << n; s++) {
        int sum = 0;
        vector<int> d(m);
        for(int i=0; i<n; i++) {
            if(s >> i & 1) {
                sum += c[i];
                for(int j=0; j<m; j++) d[j] += a[i][j];
            }
        }
        bool ok = true;
        for(int j=0; j<m; j++) {
            if(d[j] < x) ok = false;
        }
        if(ok) ans = min(ans, sum);
    }
    if(ans == 1e9) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3568
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a: String = read!();
    let b: String = read!();
    let a = a.chars().collect_vec();
    let b = b.chars().collect_vec();
    let mut c:usize=0;
    for i in 0..a.len() {
        for j in 0..a.len() {
            if a[j]==b[(i+j)%a.len()]{
                c+=1;
            }
        }
        if c==a.len() {
            println!("Yes");
            exit(0)
        }
        c=0;
    }
    println!("No")
}

Measured memory_bytes: 2132
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double result = 0;
        for (int i = 0; i < n; i++) {
            result += 1 / sc.nextDouble();
        }

        System.out.println(1 / result);
    }
}


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

using namespace std;

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

int main() {
  
  int N, M, Q;
  while(cin>>N>>M>>Q&&(N|M|Q)) {
    int S[36][1000];
    string prev; rep(i, M) prev += '0';
    rep(i, 36) {
      rep(j, 1000) S[i][j] = 1;
    }
    
    rep(I, Q) {
      string s, t; cin >> s >> t;
      rep(i, N) rep(j, M) {
        if(bool(s[i]-'0') == (t[j]-'0'==prev[j]-'0')) {
          S[i][j] = 0;
        }
      }
      prev = t;
    }
    
    rep(j, M) {
      int id = -1;
      rep(i, N) {
        if(id != -1 && S[i][j]) { id = -1; break; }
        if(id == -1 && S[i][j]) { id = i; }
      }
      if(id == -1) { cout << '?'; }
      else { cout << ( id < 10 ? char('0'+id) : char('A'+(id-10))); }
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1352
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def contBlack(g, h, w):
    cnt = 0
    for i in range(h):
        for j in range(w):
            if g[i][j] == '#':
                cnt += 1
    return cnt

def turnrow(g, a, w):
    for j in range(w):
        g[a][j] = 'R'



def turnclumn(g, a, h):
    for i in range(h):
        g[i][a] = 'R'

from copy import deepcopy

def main():
    H, W, K = map(int, readline().split())
    grid = []
    for _ in range(H):
        grid.append(list(input()))

    cnt = 0
    for i in range(1<<H):           
        G = deepcopy(grid)
        for j in range(H):
            if (i>>j) & 1:
                turnrow(G, j, W)

        for k in range(1<<W):
            Gg = deepcopy(G)
            for l in range(W):
                if (k>>l) & 1:
                    turnclumn(Gg, l, H)
            
            # for i in range(H):
            #     print(Gg[i])
            # print()

            if contBlack(Gg, H, W) == K:
                cnt += 1

    print(cnt)
if __name__ == '__main__':
    main()


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int n, y,sum;

  cin >> n >> y;

  REPB(i,n){
      REP(j,(n-i+1)){
          sum = 10000 * i + 5000 * j + 1000 * (n-i-j);
          if(sum == y){
              cout << i << " " << j << " " << (n - i - j) << endl;
              return 0;
            }          
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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

typedef long long ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	// freopen("input.in", "r", stdin);
	// freopen("input.out", "w", stdout);
	int n, x, t; cin >> n >> x >> t;
	cout << setprecision(10) << ceil((double) n / x) * t << nl;

}

Measured memory_bytes: 3796
'use strict'
function Main(input) {
	let num = input;
  	let count = 0;
	for (let i = 1; i < 10; i++) {
		let divide = num / i;
		if (divide < 10 && Number.isInteger(divide)) {
        	count+=1;
        } 
    }
  console.log(count > 0 ? 'Yes' : 'No');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
string s;
int n;
bool a[200000];
vector<int>e[200000];
signed main() {
	cin >> s;
	n = s.size();
	for (int i = 0; i < n; i++) {
		a[i + 1] = (int)(s[i] - '0');
	}
	for (int i = 0; i + i <= n; i++) {
		if (a[i] != a[n - i] || !a[n - 1]) {
			cout << -1 << endl;
			return 0;
		}
	}
	e[0].push_back(1);
	e[1].push_back(0);
	int t = 1, r = 2, k = n - 1;
	//最後に根っこになったやつ、操作をできる最前線のやつ
	for (int i = n - 2; i + i >= n; i--) {
		if (!a[i]) continue;
		for (int j = 0; j < k - i; j++) {
			e[t].push_back(r);
			e[r++].push_back(t);
		}
		t = r - 1;
		k = i;
	}
	while (r < n) {
		e[t].push_back(r);
		e[r++].push_back(t);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < e[i].size(); j++) {
			if (e[i][j] < i) cout << e[i][j] + 1 << " " << i + 1 << endl;
		}
	}
}

Measured memory_bytes: 9976
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
b = list(map(int, input().split()))
ans = []
for i in range(n):
    target = None
    for j in range(n-i):
        if int(b[j])==j+1:
            target = j
    if target is None:
        ans = -1
        break
    ans.append(target+1)
    b = b[:target] + b[target+1:]
else:
    ans = "\n".join(map(str, ans[::-1]))
print(ans)

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

using ll = long long;

constexpr ll inf = 2e9;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    const int m = s.size();

    vector<vector<vector<ll>>> val(m, vector<vector<ll>>(10, vector<ll>(11, inf)));
    for(int i = 0; i < m; ++i) {
        for(int len = 0; len < 10; ++len) {
            if(i - len < 0) continue;
            auto t = s.substr(i - len, len + 1);
            int need = 0;
            for(int j = 0; j <= len; ++j) {
                if(j == 0) {
                    if((len != 0 && t[j] == '0') || !isdigit(t[j])) {
                        need += 1;
                        t[j] = len == 0 ? '0' : '1';
                    }
                } else {
                    if(!isdigit(t[j])) {
                        need += 1;
                        t[j] = '0';
                    }
                }
            }
            auto check =
                [&] (int p) {
                    return ((p == 0 && t[p] == (len == 0 ? '0' : '1')) || (p != 0 && t[p] == '0'));
                };
            int idx = 0;
            val[i][len][need] = stol(t);
            while(idx < (int)t.size()) {
                while(idx < (int)t.size() && check(idx)) idx++;
                if(idx < (int)t.size()) {
                    need += 1;
                    t[idx] = (len != 0 && idx == 0) ? '1' : '0';
                    val[i][len][need] = stol(t);
                }
                idx++;
            }
        }
    }
    //cout << val[9][9][10] << endl;
    // 0: => //, 1: => +
    vector<vector<vector<ll>>> dp(m + 1, vector<vector<ll>>(m + 1, vector<ll>(2, inf)));
    dp[0][0][1] = 0;
    for(int i = 0; i < m; ++i) {
        for(int cnt = 0; cnt <= m; ++cnt) {
            for(int pre = 0; pre <= 9; ++pre) {
                for(int x = 0; x <= pre + 1; ++x) {
                    if(i - pre < 0 || cnt + x > m) continue;
                    dp[i + 1][cnt + x][0] = min(dp[i + 1][cnt + x][0], dp[i - pre][cnt][1] + val[i][pre][x]);
                }
            }
            const int add = (s[i] != '+');
            if(cnt + add <= m) {
                dp[i + 1][cnt + add][1] = min(dp[i + 1][cnt + add][1], dp[i][cnt][0]);
            }
        }
    }
    ll ans = -1;
    for(int i = 0; i <= m; ++i) {
        if(dp[m][i][0] <= n) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 59240
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;


using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}
void min_self(ll& a, ll b) {
    a = min(a, b);
}


// O(n * W)
const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
            //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);}

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

int main() {
  string S;
  int ans = 0;

  cin >> S;

  for (int i = 0; i < S.length(); i++) {
    int cnt = 0;

    for (int j = i; j < S.length(); j++) {
      if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G'|| S[j] == 'T') {
        cnt++;
      } else
        break;
    }

    if (ans < cnt)
      ans = cnt;
  }

  cout << ans << endl;
}


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

int main(void){
	int N, A;

	cin >> N >> A;

	while( N >= 500){
		N = N - 500;
	}
	if( N <= A ){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var k int
	antennas := ScanNums(5)
	fmt.Scan(&k)

	anyUnconnectable := false
	for _, length := range antennas[1:] {
		if length - antennas[0] > k {
			anyUnconnectable = true
		}
	}

	if anyUnconnectable {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
results = []

loop do
  n, x = gets.split.map(&:to_i)
  break if [n, x].all?(&:zero?)

  count = 0

  [*1..n].combination(3) do |a|
    count += 1 if a.inject(:+) == x
  end

  results << count
end

results.each do |result|
  p result
end



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

int era(int year, int month, int day) {
    if (year < 1868
        || (year == 1868
            && (month < 9
                || (month == 9 && day < 8))
        )) {
        return 0;
    } else if (year < 1912
               || (year == 1912
                   && (month < 7
                       || (month == 7 && day < 30))
               )) {
        return 1;
    } else if (year < 1926
               || (year == 1926
                   && (month < 12
                       || (month == 12 && day < 25))
               )) {
        return 2;
    } else if (year < 1989
               || (year == 1989 && month == 1 && day < 8)) {
        return 3;
    } else {
        return 4;
    }
}

int main() {
    int year, month, day;
    while (cin >> year >> month >> day) {
        switch (era(year, month, day)) {
        case 0:
            cout << "pre-meiji" << endl;
            break;
        case 1:
            printf("%s %d %d %d\n", "meiji", year - 1867, month, day);
            break;
        case 2:
            printf("%s %d %d %d\n", "taisho", year - 1911, month, day);
            break;
        case 3:
            printf("%s %d %d %d\n", "showa", year - 1925, month, day);
            break;
        case 4:
            printf("%s %d %d %d\n", "heisei", year - 1988, month, day);
            break;
        }
    }
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

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

    map<int, int> nh;  // number - height
    for (int i = 0; i < n; i++) {
        nh[i - a[i]]++;
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        nh[i - a[i]]--;
        ans += nh[i + a[i]];
    }

    cout << ans << endl;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int NIL = -1;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> graph[n];
    rep(i,0,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    //BFS
    int group[n];
    rep(i,0,n) group[i] = NIL;
    queue<pair<int,int>> bfs;
    bfs.push(make_pair(0,2)); // 最初はあまり1グループ
    int mod1 =1; int mod2 = 2; int mod3 = 3;
    group[0] = mod1;
    int amari = 2;
    int cnt1=1;int cnt2=0;
    while(!bfs.empty()){
        int locate = bfs.front().first; 
        int amari = bfs.front().second;
        bfs.pop();
        rep(i,0,graph[locate].size()){
            int to = graph[locate][i];
            if(group[to] != NIL) continue; //行き先が着色されてたら
            if(amari==2) {
                group[to] = mod2;
            }
            if(amari==1){ 
                group[to] = mod1;
            }
            int namari;
            if( amari == 2) namari = 1;
            else namari = 2;
            bfs.push(make_pair(to,namari));
        }
    }
    int mod1cnt=0;
    rep(i,0,n){
        if(group[i] == 1)mod1cnt++;
    }
    if(mod1cnt<(double)n/3.0){ 
        rep(i,0,n){
            if(group[i]==1){ cout << mod3<<" "; mod3+=3; }
            else{ 
                if(mod1<=n){ cout << mod1<<" "; mod1+=3;}
                else if(mod2<=n){cout << mod2<<" ";mod2+=3; }
                else{cout << mod3 << " "; mod3+=3;}
            }
        }
    }else if(mod1cnt>2.0*(double)n/3.0){
        rep(i,0,n){
            if(group[i]==2){ cout << mod3<<" "; mod3+=3; }
            else{ 
                if(mod1<=n){ cout << mod1<<" "; mod1+=3;}
                else if(mod2<=n){cout << mod2<<" ";mod2+=3; }
                else{cout <<mod3 <<" "; mod3+=3;}
            }
        }
    }else{
        rep(i,0,n){
            if(group[i]==1){
                if(mod1<=n){ cout << mod1<<" "; mod1+=3; }
                else { cout << mod3<<" ";mod3+=3;}
            }else{
                if(mod2<=n){ cout << mod2<<" "; mod2+=3; }
                else { cout << mod3<<" ";mod3+=3;}
            }
        }
    }
    //rep(i,0,n) cout << group[i] << " ";
    cout << endl;
}

Measured memory_bytes: 15216
#include <bits/stdc++.h>
#define io_optimized ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
#define int int_fast32_t
	io_optimized
	int n,r;
	while(cin>>n>>r)
	{
		cout<<(n>=10?r:r+100*(10-n))<<"\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; 
string S;
cin >> N >> S;

rep(i, 0, S.size()){
    if (S[i] + N > 'Z') cout << (char)(S[i] + N - 'Z' + 'A' - 1);
    else cout << (char)(S[i] + N);
}
cout << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

int gcd(int p, int q){
  if(p%q==0)return q;
  return gcd(q, p%q);
}

int main(){
  int k, ans=0;
  cin>>k;
  
  for(int a=1;a<=k;a++)for(int b=1;b<=k;b++)for(int c=1;c<=k;c++){
    ans+=gcd(gcd(a, b), c);
  }
  
  cout<<ans<<endl;
  return 0;
}

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

int dp[101][4][4][4];

int main(void){
    //入力
    int N;
    cin >> N;
    
    //割る数
    int mod = 1000000007;
    
    //長さ０の文字列は１である
    //0,1,2に関する制約しかないので
    //Sは３３３Sと考えても問題ない
    dp[0][3][3][3] = 1;
    
    //文字列の文字数
    for(int len = 0; len < N; len++){
        //最後から１文字目の文字
        for (int i = 0; i < 4; i++){
            //最後から２文字目の文字
            for (int j = 0; j < 4; j++){
                //最後から３文字目の文字
                for (int k = 0; k < 4; k++){
                    //条件に当てはまるものが無い場合はcontinue
                    if (dp[len][i][j][k] == 0) continue;
                    
                    //新しく追加する文字
                    for (int l = 0; l < 4; l++){
                        //ダメな５つの条件をカットする
                        if (l == 2 && i == 1 && j == 0) continue;
                        if (l == 2 && i == 0 && j == 1) continue;
                        if (l == 1 && i == 2 && j == 0) continue;
                        if (l == 2 && i == 1 && k == 0) continue;
                        if (l == 2 && j == 1 && k == 0) continue;
                        
                        //ダメな条件を抜けたら、lを足した文字列が作れる
                        dp[len + 1][l][i][j] += dp[len][i][j][k];
                        dp[len + 1][l][i][j] %= mod;
                    }
                }
            }
        }
        
    }
    
    //答えの入れ物を作る
    int ans = 0;
    
    
    //長さNの全部の答えをまとめる
    for (int i = 0; i < 4; i++){
            //最後から２文字目の文字
        for (int j = 0; j < 4; j++){
                //最後から３文字目の文字
            for (int k = 0; k < 4; k++){
                ans += dp[N][i][j][k];
                ans %= mod;
                
                    
            }
        }
        
    }   
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;


int c1, c5, c10, c50, c100, c500;
int ans;

int main(){
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	ans = c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;
	if (ans >= 1000){
		cout << 1 << endl;
		return 0;
	}

	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  long long int n,d,count=0;
  cin>>n>>d;
  for(long long int i=0;i<n;i++){
    long long int x,y;
    cin>>x>>y;
    if(sqrt(x*x+y*y)<=d)
      count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
   ll w , h , x , y ;
   cin >> w >> h >> x >> y;
   ll area1 = w*h;
   cout << fixed << setprecision(10) << (area1*1.0)/2 << " ";
   if( w%2==0 && h%2==0 && x == w/2 && y == h/2){
        cout << 1  << " " ;
   }
   else
        cout << 0 << " " ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

int n, m;
int main() {
    cin >> n >> m;
    vector<vector<int>> graph(n, vector<int>(n));
    rep(i, 0, m){
        int a, b; cin >> a >> b;
        a--;b--;
        graph[a][b] = true;
        graph[b][a] = true;
    }

    vector<int> convinations;
    rep(i, 0, n) convinations.push_back(i);

    int ans = 0;

    int size = convinations.size();
    do{
        if(convinations[0] != 0) continue;
        bool ok = true;
        rep(i, 0, size-1){
            int a = convinations[i];
            int b = convinations[i+1];
            if(!graph[a][b]) ok = false;
        }
        if(ok) ans++;
    }while(next_permutation(ALL(convinations)));

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005],dp[2][3005][3005],n;

ll dfs(ll x,ll y,ll s)
{
	if(dp[s][x][y]!=-1)
		return dp[s][x][y];
	if(x==y)
	{
		dp[0][x][x]=arr[x];
		dp[1][x][x]=-1*arr[x];
		return dp[s][x][y];
	}
	ll a,b;
	if(s==0)
	{
		a=dfs(x+1,y,1)+arr[x];
		b=dfs(x,y-1,1)+arr[y];
		dp[s][x][y]=max(a,b);
	}
	else
	{
		a=dfs(x+1,y,0)-arr[x];
		b=dfs(x,y-1,0)-arr[y];
		dp[s][x][y]=min(a,b);
	}
	return dp[s][x][y];
}

int main()
{
	ll i;
	boost
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(i=1;i<=n;i++)
		cin>>arr[i];
	dfs(1,n,0);	
	cout<<dp[0][1][n];
	return 0;
}

Measured memory_bytes: 141824
#include<iostream>
using namespace std;
int main(){
  int a,b,ans=0;
  cin>>a>>b;
  if(a==1&&b==1) cout<<1000000<<endl;
  else{
    if(a==1) ans+=300000;
    if(b==1) ans+=300000;
    if(a==2) ans+=200000;
    if(b==2) ans+=200000;
    if(a==3) ans+=100000;
    if(b==3) ans+=100000;
    cout<<ans<<endl;
  }
}

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

int main()
{
  int k, x;
  cin >> k >> x;
  int a = x - (k - 1);
  int b = x + (k - 1);
  vector<int> vec(k * 2 - 1);
  for (int i = 0; i < k * 2 - 1; i++)
  {
    while (a <= b)
    {
      vec.at(i) = a;
      cout << vec.at(i) << ' ';
      a++;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
while True:
  n = int(input())
  if n == 0:break
  def to_code(s):
    ret = s[0]
    flag = False
    for c in s:
      if flag:ret += c
      flag = c in "aiueo"
    return ret
  
  lst = [to_code(input()) for _ in range(n)]
  for k in range(51):
    used = {}
    for code in lst:
      if code[:k] in used:
        break
      used[code[:k]] = True
    else:
      print(k)
      break
  else:
    print(-1)


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

int main()
{
    ll a, b, h, m;
    cin >> a >> b >> h >> m;

    double hd = double(h);
    double md = double(m);

    double hAngle = (hd * 30.f) + (md / 60.f * 30.f);
    double mAngle = md * 6.f;
    double angleDiff = abs(hAngle - mAngle);
    if(angleDiff > 180.f)
    {
        angleDiff = 360.f - angleDiff;
    }

    double ad = double(a);
    double bd = double(b);
    double rad = angleDiff * M_PI / 180.f;
    double sqrAns = (ad*ad) + (bd*bd) - (cos(rad) * (2 * ad * bd));
    double ans = sqrt(sqrAns);

    cout << fixed << setprecision(20) << ans;

    return 0;
}


Measured memory_bytes: 4168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <locale>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int ans = -1;
    ans = N * (N - 1) / 2;
    ans += M * (M - 1) / 2;
    cout << ans << endl;
    return 0;
}

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

const int INF = 0x3f3f3f3f;
const int SIZE = 200005;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;

const int doise26 = 1 << 26;
int prefixSum[SIZE];
int dp[doise26];
int minpos[SIZE];

int main() {
	string s;
	cin >> s;
	for(int i = 1; i <= s.length(); i++) {
		prefixSum[i] = prefixSum[i-1] ^ 1 << s[i-1] - 'a';
	}
	minpos[0] = INF;
	minpos[s.length() + 1] = 0;
	dp[0] = s.length() + 1;
	for(int i = 1; i <= s.length(); i++) {
		minpos[i] = minpos[dp[prefixSum[i]]] + 1;
		for(int j = 0; j < 26; j++) {
			minpos[i] = min(minpos[i], 1 + minpos[dp[prefixSum[i] ^ 1 << j]]);
		}
		if(minpos[dp[prefixSum[i]]] > minpos[i]) {
			dp[prefixSum[i]] = i;
		}
	}
	//for(int i = 1; i <= s.length(); i++) {
	//	printf("%d ", minpos[i]);
	//}
	//printf("\n");
	printf("%d\n", minpos[s.length()]);	
	return 0;
}

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

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

    int64_t cnt[5] = {};
    string s = "MARCH";
    for(int i = 0; i < N; ++i){
        string S;
        cin >> S;
        for(int j = 0; j < 5; ++j){
            if(S[0] == s[j]) cnt[j]++;
        }
    }

    int64_t ans = 0;
    for(int i = 0; i < 3; ++i){
        for(int j = i + 1; j < 4; ++j){
            for(int k = j + 1; k < 5; ++k){
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N, T;
    cin >> N >> T;
    ll sum = 0, prev = 0;
    for(int i = 0; i < N; ++i) {
        int t;
        cin >> t;
        if(i == 0) {
            prev = 0;
            continue;
        }
        if(prev + T > t)
            sum += t - prev;
        else
            sum += T;
        prev = t;
    }
    cout << sum + T << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
  
int A[2000002],B[2000002];
int C[10001];
int n;
void Counting_Sort(int A[], int B[], int n);
  
int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
  
    scanf("%d",&A[i]);
  
}
  Counting_Sort(A, B, 10000);
  
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
}
  printf("%d\n",B[n]);
  
  return 0;
}
  
  
void Counting_Sort(int A[],int B[],int k){
  int i,j;
  for(i=0;i<=k;i++){
    C[i]=0;
  }
  
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
 for(i=1;i<=k;i++){
    C[i] =C[i]+ C[i-1];
  }
   
 for(j=n;j>=0;j--){
   B[C[A[j]]] = A[j];
   C[A[j]] = C[A[j]] -1;
 }
  
 return;
}

Measured memory_bytes: 16264
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll v;cin>>v;vec.push_back(v);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO"
#define YES cout << "YES"
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
ll inv(ll a)
{
    ll p=mod2;
    ll b=p-2,ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll ncr(ll n,ll m)
{
    ll p=mod2;
    if(m > n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<n+1;i++)up*=i,up%=p;
    for(int i=1;i<m+1;i++)down*=i,down%=p;
    return up*inv(down)%p;
}

ll countDigit(ll n)
{   
    return floor(log10(n) + 1); 
}  
ll a_pow_b(ll a,ll b)
{
    ll p=1000000007;
    ll ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll gcd(ll a,ll b) 
{ 
    if (b==0) 
        return a; 
    return gcd(b,a%b);      
} 
ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
}
bool isPerfectSquare(ll x) 
{   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
}
ll ncr123(ll n, ll k){
    if (k == 1) {
        return n;
    }
    if (k == 2) {
        return n * (n - 1) / 2;
    }
    if (k == 3) {
        return n * (n - 1) * (n - 2) / 6;
    }
}
bool com(const pi &a,const pi &b)   //acc to second element sort for vec of pi
{ 
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
}

void solve(){

    
    string a,b;
    cin>>a>>b;

    ll n=a.length();
    
    string p=b.substr(0,n);
    if(p==a){
        cout<<"Yes";
        return;
    }
    cout<<"No";

    return ;
}
 
 
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>

using namespace std;


int main(){

	int N, C[20], V[20];
	int answer = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		if (C[i] > V[i])
			answer += (C[i] - V[i]);
	}

	cout << answer;

	return 0;
}

Measured memory_bytes: 256