akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

vector<int> uf, usz;
int nc;

void init(int n){
  vector<int> uf_(n);
  vector<int> usz_(n, 1);
  uf = uf_;
  usz = usz_;
  nc = n;

  for(int i = 0; i < uf.size(); i++){
    uf[i] = i;
  }
}

int find(int a){
  return (uf[a] == a) ? a : uf[a] = find(uf[a]);
}

void union_(int a, int b){
  a = find(a);
  b = find(b);

  if(a != b){
    if(usz[a] >= usz[b]){
      swap(a, b);
    }
    uf[a] = b;
    usz[b] += usz[a];
    nc--;
  }
}

int check(int a, int b){
  return (find(a) == find(b)) ? 1 : 0;
}

int get_size(int a){
  return usz[find(a)];
}

ll bl[400*400+10];
ll wh[400*400+10];

int main() {
  clr(bl,0);
  clr(wh,0);
  ll h,w;
  cin>>h>>w;
  init(h*w);
  vector<string> vs;
  rep(y,0,h){
    string s;
    cin>>s;
    vs.pb(s);
  }
  rep(y,0,h-1){
    rep(x,0,w){
      if(vs[y][x]!=vs[y+1][x]){
        union_(y*w+x,(y+1)*w+x);
      }
    }
  }
  rep(y,0,h){
    rep(x,0,w-1){
      if(vs[y][x]!=vs[y][x+1]){
        union_(y*w+x,y*w+x+1);
      }
    }
  }
  rep(y,0,h){
    rep(x,0,w){
      ll a = find(y*w+x);
      if(vs[y][x]=='#'){
        bl[a]++;
      }
      else{
        wh[a]++;
      }
    }
  }
  ll ans = 0;
  rep(i,0,400*400+10){
    ans += bl[i]*wh[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5248
using System;

namespace atcoderA
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int r = int.Parse(input[0]);
            int g = int.Parse(input[1]);
            int b = int.Parse(input[2]);
            Console.WriteLine((100 * r + 10 * g + b) % 4 == 0 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int N = 500005, Mod = 998244353;
int F[N], I[N];
inline int Power(int a, int b)
{
    int ret = 1;
    for (; b; b >>= 1, a = 1LL * a * a % Mod)
        if (b & 1) ret = 1LL * ret * a % Mod;
    return (ret);
}
inline int nCr(int r, int n)
{
    if (n < 0 || r < 0 || n < r)
        return (0);
    return (1LL * F[n] * I[r] % Mod * I[n - r] % Mod);
}
int main()
{
    for (int i = F[0] = 1; i < N; i ++)
        F[i] = 1LL * F[i - 1] * i % Mod;
    I[N - 1] = Power(F[N - 1], Mod - 2);
    for (int i = N - 2; ~ i; i --)
        I[i] = 1LL * I[i + 1] * (i + 1) % Mod;

    int n, k;
    scanf("%d%d", &n, &k);
    int tot = 0;
    for (int r = max(k / 2 + 1, n); r <= k; r ++)
        tot = (tot + nCr(r, k) - nCr(k - r - r + n - 1, k) + 0LL + Mod) % Mod;
    if (k % 2 == 0 && k >= n + n)
        tot = (tot + nCr(k / 2, k - 1) - nCr(n - 2, k - 1) + 0LL + Mod) % Mod;
    return !printf("%d\n", tot);
}

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

int a[201];
int main()
{
	ios::sync_with_stdio(false);
	int n,ans=0;
int tot;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	while(1){
		bool f=1;
		for(int i=1;i<=n;i++)
			if(a[i]%2==0) a[i]/=2;
			else{
				f=0;
				break;
			}
		if(f) ans++;
		else break;
	}
	cout<<ans;
return 0;
}

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

int main()
{ 
	int S,h,m,s;
	cin >> S;
		h = S / 3600;
		m = (S - h * 3600) / 60;
		s = S - h * 3600 - m * 60;
	cout <<h<<":"<<m<<":"<<s<<"\n";

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
// 15:40-
const int MAX_N=1e4+1;
int N,H,W;
LL A[MAX_N];
int G[100][100]={};
void solve() {
  ZERO(G);
  int cur=0;
  REP(i,N) while(A[i]>0) {
    int r=cur/W,c=cur%W;
    G[r][c]=i+1;
    --A[i];
    ++cur;
  }
  
  REP(i,H) if(i%2) {
    int l=0,r=W-1;
    while(l<r) swap(G[i][l],G[i][r]),++l,--r;
  }
  REP(i,H) REP(j,W) cout<<G[i][j]<<(j==W-1?'\n':' ');
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>H>>W>>N;
  REP(i,N) cin>>A[i];
  solve();
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;
char g[2005][2005];
int u[2005][2005], dow[2005][2005], lef[2005][2005], righ[2005][2005];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%s", g[i] + 1);
    for (int i = 1; i <= n; ++i){
        int cnt = 0;
        for (int j = 1; j <= m; ++j){
            if (g[i][j] == '.') ++cnt;
            else cnt = 0;
            lef[i][j] = cnt;
        }
    }
    for (int i = 1; i <= n; ++i){
        int cnt = 0;
        for (int j = m; j >= 1; --j){
            if (g[i][j] == '.') ++cnt;
            else cnt = 0;
            righ[i][j] = cnt;
        }
    }
    for (int j = 1; j <= m; ++j){
        int cnt = 0;
        for (int i = 1; i <= n; ++i){
            if (g[i][j] == '.') ++cnt;
            else cnt = 0;
            u[i][j] = cnt;
        }
    }
    for (int j = 1; j <= m; ++j){
        int cnt = 0;
        for (int i = n; i >= 1; --i){
            if (g[i][j] == '.') ++cnt;
            else cnt = 0;
            dow[i][j] = cnt;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j){
            ans = max(ans, u[i][j] + dow[i][j] + righ[i][j] + lef[i][j]);
        }
    }
    printf("%d\n", ans - 3);
    return 0;
}


Measured memory_bytes: 66944
import sys
from copy import deepcopy

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def drop(H, W, G):
    for i in range(1, H):
        for j in range(W):
            if G[i][j] == -1 and G[i - 1][j] != -1:
                k = i
                for k in range(i, 0, -1):
                    if G[k][j] != -1:
                        break
                    G[k][j], G[k - 1][j] = G[k - 1][j], -1


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

    ans = 0
    for i in range(H):
        for j in range(W):
            G = deepcopy(G_init)
            G[i][j] = -1
            drop(H, W, G)

            current_ans = 0
            step = 0
            while True:
                score = 0
                for row in G:
                    seq = [[row[0], 1]]
                    for n in row[1:]:
                        if n == seq[-1][0]:
                            seq[-1][1] += 1
                        else:
                            seq.append([n, 1])
                    idx = 0
                    for n, c in seq:
                        if n != -1 and c >= K:
                            score += n * c
                            row[idx : idx + c] = [-1] * c
                        idx += c

                if score == 0:
                    break

                current_ans += score * pow(2, step)
                step += 1
                drop(H, W, G)

            if current_ans > ans:
                ans = current_ans

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 55644
import scala.io.{StdIn => in}

object Main extends App {
  val Array(r, g, b, n) = in.readLine.split(" ").map(_.toInt)

  var cnt = 0
  for {
    i <- 0 to n/r
    j <- 0 to n/g
    k = n - r*i - g*j
    if 0 <= k
  } {
    if(k%b == 0) {
      cnt += 1
      // debug(i,j,k)
    }
  }

  val ans = cnt
  println(ans)

  def debug(any:Any*):Unit = {
    if(this.getClass.toString != "class Main$")
      println(any.mkString(" "))
  }
}

Measured memory_bytes: 112856
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  vector<char>ans(s.size());
  int j=-1;
  for(int i=0;i<s.size();i++)
  {
      if(s[i]=='B')
      {
        if(j==-1)
          continue;
        else
          j--;
      }
      else
      {
        ans[j+1]=s[i];
        j++;
      }
  }
  for(int i=0;i<=j;i++)
  {
    cout<<ans[i];
  }
  
  return 0;
}

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


ll N, X, Y;
vector<vector<ll>> d;


ll dfs(ll i, ll j){
    if(d[i][j] != -1) return d[i][j];
    if(i < X && j > X) return X-i+dfs(X, j);
    if(j > Y && i < Y) return j-Y+dfs(i, Y);
    if(i < X && j <= X) return j-i;
    if(i >= Y && j > Y) return j-i;
    d[i][j] = min(j-i, i-X+Y-j+1);
    return d[i][j];
}

int main(){
    cin >> N >> X >> Y;
    d.resize(N+1,vector<ll>(N+1, -1));
    vector<ll> ans(N, 0);
    rep(i, 1, N){
        rep(j, i+1, N+1){
            ans[dfs(i,j)]++;
        }
    }
    rep(i, 1, N) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 31616
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

# 訪れなくてもいい区間の最大値を求める
L = []
for i in range(0, M-1):
    L.append(X[i+1] - X[i])

print(X[-1] - X[0] - sum(sorted(L, reverse=True)[:N-1]))

Measured memory_bytes: 13968
import java.util.*;

public class Main {
    static int[] damages;
    static int[] powers;
    static int[] dp;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		damages = new int[n];
		powers = new int[n];
		for (int i = 0; i < n; i++) {
		    damages[i] = sc.nextInt();
		    powers[i] = sc.nextInt();
		}
		dp = new int[h + 1];
		System.out.println(dfw(h));
   }
   
   static int dfw(int helth) {
       if (helth <= 0) {
           return 0;
       }
       if (dp[helth] == 0) {
           dp[helth] = Integer.MAX_VALUE;
           for (int i = 0; i < damages.length; i++) {
               dp[helth] = Math.min(dp[helth], dfw(helth - damages[i]) + powers[i]);
           }
       }
       return dp[helth];
   }

}


Measured memory_bytes: 28648
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 100010
#define inf (1<<30)
int a[100][100],b[100];
int main(){
	int n,m,a,b;
	in(n);in(m);in(a);in(b);
	cout<<(n-a)*(m-b)<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
A = list(map(int,input().split()))
N = A[0]
M = A[1]

L = [[] for i in range(N)]
for i in range(M):
    X,Y = map(int,input().split()) 
    L[X-1].append(Y-1)
    L[Y-1].append(X-1)

#print(L)

def hitohudegaki(i,done):
    pattern = 0
    
    if i in done:
        return 0
    
    elif len(done) == N-1:
        return 1
    
    for j in range(len(L[i])):
        pattern += hitohudegaki(L[i][j],done+[i])
            
    return pattern



print(hitohudegaki(0,[]))


Measured memory_bytes: 3064
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt()
  val e = List.fill(2 * m)(sc.nextInt())
  val count = e.groupBy(identity).view.mapValues(_.length)
  for (i <- 1 to n) {
    println(count.getOrElse(i, 0))
  }
}


Measured memory_bytes: 55592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<int> A;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if(a[i] < K){
            A.push_back(a[i]);
            cnt ++;
        }
    }
    int ans = N - cnt;
    
    swap(N, cnt);
    vector<vector<bool>> dp1(N+1, vector<bool> (K+1, false));
    vector<vector<bool>> dp2(N+1, vector<bool> (K+1, false));
    for (int i = 0; i < N+1; i++) {
        dp1[i][0] = true;
        dp2[i][0] = true;
    }
    for (int i = 0; i < N; i++) {
        for (int j = K; j >= 0; j--) {
            if(j - A[i] >= 0 && dp1[i][j-A[i]] == true){
                dp1[i+1][j] = true;
            }
            if(dp1[i][j]){
                dp1[i+1][j] = true;
            }
            if(j - A[N-i-1] >= 0 && dp2[i][j-A[N-i-1]] == true){
                dp2[i+1][j] = true;
            }
            if(dp2[i][j]){
                dp2[i+1][j] = true;
            }            
        }
    }

    for (int i = 0; i < N; i++) {
        // dp1[i]とdp2[N-i-1]でK - A_i以上K未満を作れるか判定
        int tmp = 0;
        for (int j = 1; j < A[i]+1; j++) {
            if(dp1[i][K-j]){
                tmp++;
            }
        }
        if(dp2[N-i-1][0] && tmp > 0){
            ans++;
            continue;
        }
        bool check = false;
        for (int j = A[i]+1; j <= K; j++) {
            if(dp1[i][K-j]){
                tmp++;
            }
            if(dp1[i][K-j+A[i]]){
                tmp--;
            }
            if(dp2[N-i-1][j-A[i]] && tmp > 0){
                ans++;
                check = true;
                break;
            }
        }
        if(check) continue;
        for (int j = 0; j < A[i]; j++) {
            if(dp1[i][A[i]-1-j]){
                tmp--;
            }
            if(dp2[N-i-1][K-A[i]+j] && tmp > 0){
                ans++;
                check = true;
                break;
            }
        }
    }
    printf("%d\n", cnt - ans);

}

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

using namespace std;
string s;
map <string,int > m;
int n,i;
long long sum;
int main()
{
    cin>>n;
    cin.get();
    for (i=1;i<=n;i++)
    {
        cin>>s;
        sort (s.begin(),s.end());
        m[s]++;
        sum=sum+m[s]-1;
    }
    cout<<sum;
}


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

typedef long long llong;

#define N_MAX 200000
#define SENTINEL 2000000000
int leftA[N_MAX / 2 + 2], rightA[N_MAX / 2 + 2];

llong merge(int A[], int left, int mid, int right) {
    llong count = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) leftA[i] = A[left + i];
    leftA[n1] = SENTINEL;
    int leftCur = 0;
    
    for (int i = 0; i < n2; i++) rightA[i] = A[mid + i];
    rightA[n2] = SENTINEL;
    int rightCur = 0;
    
    for (int i = left; i < right; i++) {
        if (leftA[leftCur] <= rightA[rightCur]) {
            A[i] = leftA[leftCur];
            leftCur++;
        } else {
            count += mid - left - leftCur;
            A[i] = rightA[rightCur];
            rightCur++;
        }
    }
    
    return count;
}

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

int main() {
    int N, A[N_MAX];
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    
    llong ans = mergeSort(A, N, 0, N);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
        ret[i]++;
        n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int64_t div_ct(int64_t n) {
    int64_t res = 1;
    auto p = prime_factor(n);
    for(auto itr=p.begin(); itr!=p.end(); itr++) {
        // cerr << itr->first << ' ' << itr->second << endl;
        res *= (itr->second + 1);
    }
    return res;
}

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

    int64_t ans = 0;
    ans += div_ct(N-1) - 1; // 1を除く
    for(int64_t i=2; i*i<=N; i++) {
        if(N%i == 0) {
            int64_t tmp = N;
            while(tmp % i == 0) {
                tmp /= i;
            }
            if(tmp % i == 1) {
                ++ans;
                // cerr << i << endl;
            }
            tmp = N;
            int64_t j = N/i;
            if(i == j) continue;
            while(tmp % j == 0) {
                tmp /= j;
            }
            if(tmp % j == 1) {
                ++ans;
                // cerr << j << endl;
            }
        }
    }

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


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int k, t;
  cin >> k >> t;
  int max_v{};
  REP(i, t) {
    int a;
    cin >> a;
    max_v = max(max_v, a);
  }
  cout << max(max_v - 1 - (k - max_v), 0) << endl;
}


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

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
#define rep(i, n)for(int i=0; i<n; i++)

long long INF = 1000000007;

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

  int ans = 0;
  for(int a=1; a<=N; a++){
    ans = ans + (N-1)/a;
  }

  
  
  cout << ans << endl;

  return 0;
}


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

#define all(c) (c).begin(),(c).end()
#define allDESC(c) (c).begin(),(c).end(),greater<int>()
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define mod 1000000007

int main(){
  int n,h,w;cin>>n>>h>>w;
  cout << (n-h+1)*(n-w+1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
  int N;
  std::string S;

  std::cin >> N >> S;
  int x = 0;
  int res = 0;
  for (char ch: S) {
    if (ch == 'I') {
      ++x;
    } else if (ch == 'D') {
      --x;
    }
    res = std::max(res, x);
  }
  std::cout << res << std::endl;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n; 
    double t,a;
    cin >> n;
    cin >> t >> a;

    int ans = 0;
    double anstmp = 100000.0,h;
    rep(n) {
        cin >> h;
        if(abs(anstmp-a) > abs(t-0.006*h - a)) {
            ans = i+1;
            anstmp = t-0.006*h;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const long long  max_n = 5000;
long long cnt[111];
long long b = 1;
long long n,a,W;
const int INF = 1e9;
const int mod = 1e9 + 7;
long long s[max_n],v[max_n],w[1000];
long long dp[max_n];
vector<vector<int> > G;

long long solve(){
    if(n>=10)   return a;
    else    return a+100*(10-n);
}
int main(){
    cin >> n >> a;

    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

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

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

	LL ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			int v = a[i] + a[j];
			ans += lower_bound(a.begin(), a.end(), v) - a.begin()-(j+1);
			
		}
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    k,x =map(int, sys.stdin.readline().split())
    l=[]
    for i in range(x-k+1,x+k):
        l.append(i)
    print(*l)



Measured memory_bytes: 5356
#include <cstdint>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> divs;
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		int cnt = 0;
		while (a % 2 == 0) {
			a /= 2;
			cnt++;
		}
		divs.push_back(cnt);
		sum += cnt;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int N;
    cin >> N;
    if(N == 1) cout << "Hello World" << endl;
    else{
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
}


Measured memory_bytes: 3612
#include<stdio.h>

int main(void){
int i,j,k;
int a[10];
for(i=0;i<10;i++){

    scanf("%d",&a[i]);
}
for(i=0;i<10;i++){
    for(j=0;j<10;j++){
        if(a[i]>a[j]){k=a[i];a[i]=a[j];a[j]=k;}
    }
}
for(i=0;i<3;i++){
    printf("%d\n",a[i]);
}
return 0;
}



Measured memory_bytes: 2108
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
        t: String,
    }
    let mut ans = 0;
    for (a, b) in s.chars().into_iter().zip(t.chars().into_iter()) {
        if a != b {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2796
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,x;
    cin>>n>>m;
    (m>=n)? cout<<"unsafe\n":cout<<"safe\n";
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int a = 0;
		int b = 0;

	   for(int i = 0;i<S.length;i++){
		   if(S[i]=='a' && (a+b)<(A+B)){
			   a++;
			   System.out.println("Yes");
		   }else if(S[i]=='b' && b<B && (a+b)<(A+B)){
			   b++;
			   System.out.println("Yes");
		   }else{
			   System.out.println("No");
		   }
	   }
	}
}

Measured memory_bytes: 23240
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int inf = 1000000000;
const double eps = 1e-7;

void solve() {
	int r;
	cin >> r;
	cout << fixed << setprecision(12) << 2.0 * acos(-1.0) * r << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i)
		solve();
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
  else if(s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
import numpy as np
import sys

N = int(input())

H = np.array(list(map(int, input().split())))

H = H[::-1]

for i in range(N-1):
    if H[i] >= H[i+1]:
        continue
    if H[i] < H[i+1]:
        H[i+1] -= 1

        if H[i] < H[i+1]:
            print('No')
            sys.exit()

print('Yes')


Measured memory_bytes: 23096
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int main () {
	fastCin;
	ll d, t, s;
	cin >> d >> t >> s;
	if (t*s >= d) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3080
N, M = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(M)]
sPY = sorted(PY, key=lambda py: (py[0],py[1]))

i = 1
bp = 1
d = {}
for p, y in sPY:
    if p != bp:
        i = 1
        bp = p
    d[y] = i
    i += 1

for p, y in PY:
    print("{0:06}{1:06}".format(p, d[y]))

Measured memory_bytes: 33924
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n_nodes, n_path = map(int,input().split())
paths = [[0,0] for _ in range(n_path)]
for i in range(n_path):
    a,b = map(int,input().split())
    paths[i] = [a-1,b-1]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        '''
        xとyは-=1して使う
        '''
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

now_ans = combinations_count(n_nodes,2)
paths = paths[::-1]
uf = UnionFind(n_nodes)
ans_ls = [0] * (n_path)
ans_ls[-1] = now_ans
for i,path in enumerate(paths[:-1]):
    a,b = path
    if not uf.same(a,b):
        now_ans -= uf.size(a)*uf.size(b)
        uf.union(a,b)
    ans_ls[-2-i] = now_ans
for ans in ans_ls:
    print(ans)
    


Measured memory_bytes: 30008
#include <cstdio>
#include <math.h>
using namespace std;

typedef struct vec2 {
	double x, y;
	vec2(){}
	vec2(int a, int b) {
		x = a;
		y = b;
	}
	vec2(double a, double b) {
		x = a;
		y = b;
	}
	vec2 operator*(double l) {
		return{ x*l,y*l };
	}
	vec2 operator-(const vec2 &r) {
		return{ x - r.x,y - r.y };
	}
	vec2 operator+(const vec2 &r) {
		return{ x + r.x,y + r.y };
	}
	double dis() {
		return sqrt(pow(x, 2) + pow(y, 2));
	}
} vec2;
double dot(vec2 v1, vec2 v2) {
	return v1.x*v2.x + v1.y*v2.y;
}

vec2 v[4];
int q, t1, t2;

void read(int i) {
	scanf("%d%d", &t1, &t2);
	v[i] = vec2(t1, t2);
}

int main(){
	read(0);
	read(1);
	v[1] = v[1] - v[0];
	scanf("%d", &q);
	for (int I = 0; I < q; I++) {
		read(2);
		v[2] = v[2] - v[0];
		v[3] = v[1] * (dot(v[1], v[2]) *(1.0 / pow(v[1].dis(),2)));
		v[3] = v[0] + v[3];
		printf("%.9f %.9f\n", v[3].x, v[3].y);
	}

	return 0;
}

Measured memory_bytes: 2704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(),m=s.nextInt();
        int height[] = new int[n+1];
        for(int i=0;i<n;i++)height[i+1]=s.nextInt();
        HashMap<Integer, PriorityQueue<Integer>>hm = new HashMap<>();
        PriorityQueue<Integer>priorityQueue;
        for(int i=0;i<n;i++){
            priorityQueue = new PriorityQueue<>(Collections.reverseOrder());
            hm.put(i+1,priorityQueue);
        }
        for(int i=0;i<m;i++){
            int u = s.nextInt(),v=s.nextInt();
            priorityQueue = hm.get(u);
            priorityQueue.add(height[v]);
            hm.put(u,priorityQueue);
            priorityQueue = hm.get(v);
            priorityQueue.add(height[u]);
            hm.put(v,priorityQueue);

        }
        int cnt=0;

        for(int i=1;i<=n;i++){
            priorityQueue = hm.get(i);
            if(priorityQueue.isEmpty())cnt++;
            else if(priorityQueue.peek()<height[i])cnt++;
        }

        System.out.println(cnt);


    }
}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 78972
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> data(n);
    rep(i,0,n){
        data[i]=s[i];
    }
    set<int> cnt;
    vector<int> variety(n+1);
    for(int i = n-1;i>=0;i--){
        cnt.insert(data[i]);
        variety[i]=cnt.size();
    }
    
    ll ans = 0;
    set<int> first;
    rep(i,0,n){
        
        if(!first.count(data[i])){
            first.insert(data[i]);
            set<int> second;
            rep(j,i+1,n){
                
                if(!second.count(data[j])){
                    ans += variety[j+1];
                    second.insert(data[j]);
                }
            }
        }
    }
    cout<<ans<<endl;
    
    

    return 0;
}


Measured memory_bytes: 3776
#include <iostream>

using namespace std;

int main()
{

    char c;
    int charno;
    cin>>c;
    if(c=='z'|| c=='Z'){
        cout<<"cannot"<<endl;
    }
    else{
    charno=(int)c;
    cout<<(char)++charno<<endl;}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define EPS 1e-8
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

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

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
template <typename T>
T power_mod(T base, int exp, int mod = MOD) {
    T res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
template <typename T>
T power(T base, int exp) {
    T res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, MOD - 2);
}

/******************************** template ********************************/
#define MAXN 55
int r, g;

int main() {
    cin >> r >> g;
    cout << 2 * g - r;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 200001
#define INF   1000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll a[MAX_N];

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

    ll N;
    cin >> N;
    for(ll i = 0; i < N; i++) cin >> a[i];
    
    ll dp[MAX_N];
    fill(dp, dp + N, INF);
    
    for(ll i = 0; i < N; i++) {
      ll lb = -1;
      ll ub = N;
      ll mid = (lb + ub) / 2;

      while (lb + 1 < ub) {
	if (dp[mid] < a[i]) lb = mid;
	else ub = mid;
	mid = (lb + ub) / 2;
      }
      dp[ub] = a[i];
    }

    ll len = 0;
    for(ll i = 0; i < N; i++) {
      if (dp[i] == INF || dp[i] != i+1) break;
      len++;
    }

    if (len == 0) cout << -1 << endl;
    else cout << N - len << endl;
    
    return 0;
}
    


Measured memory_bytes: 3328
#include <ctime>
#include <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <queue>
#include <numeric>
using namespace std;

#define int long long
#define INF 1e18
#define EPS 1e-9
#define NIL -1

int n;
int arr[100005];

int solve() {
    int cnt = 0;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        if(i % 2 == 0) {
            if(sum + arr[i] <= 0) {
                cnt += abs(sum + arr[i] - 1);
                sum = 1;
            } else {
                sum += arr[i];
            }
        } else {
            if(sum + arr[i] >= 0) {
                cnt += abs(sum + arr[i] + 1);
                sum = -1;
            } else {
                sum += arr[i];
            }
        }
    }
    return cnt;
}

signed main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> arr[i];

    int ans = solve();

    for(int i = 0; i < n; i++) arr[i] *= -1;

    cout << min(ans, solve()) << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int ctoi(char);

int main()
{
    int64_t N;
    cin >> N;
    int64_t bb = 2, b = 1;
    for (int i = 2; i <= N; i++)
    {
        int64_t tmp = b + bb;
        bb = b;
        b = tmp;
    }
    cout << b << endl;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    cout << N * N * N << endl;
}

Measured memory_bytes: 256
N = int(input())
d = {}

max = 1
for i in range(N):
    s = input()
    if s in d.keys():
        d[s] += 1
        if max < d[s]:
            max = d[s]
    else:
        d[s] = 1

r = []
for k,v in d.items():
    if v == max:
        r.append(k)

r.sort()
for p in r:
    print(p)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

int N, M;
vii jobs;

int solve() {
    sort(ALL(jobs));
    ll ans = 0;

    int job_i = 0;
    priority_queue<int> que;
    FOR (i, 1, M+1) {
        while (job_i < N) {
            if (jobs[job_i].first == i) {
                que.push(jobs[job_i].second);
                job_i++;
            }
            else break;
        }
        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }
    return ans;
}

int main() {
    cin >> N >> M;
    REP (i, N) {
        int a, b;
        cin >> a >> b;
        jobs.PB(MP(a, b));
    }
    cout << solve() << endl;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

string s,t;
cin >> s >> t;
if(s == t.substr(0,SZ(s))) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int m = 0;
    int ans = 0;
    for(int i=0; i<n; i++){
        int t;
        cin >> t;
        if(t >= m) ans++;
        m = max(m, t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;

    if(a > b)
        cout << "a > b" << endl;
    else if(a < b)
        cout << "a < b" << endl;
    else
        cout << "a == b" << endl;
    return 0;
}

Measured memory_bytes: 3064
let n = read_int()
let a = Array.make (n + 1) 0

let rec f i =
  if i = n + 1 then a.(n)
  else
    let rec g i j k =
      if j < k then j - k / i
      else g i j (k * i) in
    a.(i) <- 1 + min a.(g 6 i 1) a.(g 9 i 1);
    f (i + 1)

let () = Printf.printf "%d\n" (f 1)


Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
int f[110][100010],n,k,a[110],sum[110],mode=1000000007,sum1[100010];
int main()
{
//	freopen("a.txt","r",stdin);
//	freopen("a1.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=0;i<=a[1];i++)
		f[1][i]=1;
	for(int i=2;i<=n;i++)
	{
		
		for(int j=1;j<=k+1;j++)
			sum1[j]=(sum1[j-1]+f[i-1][j-1])%mode;
		for(int j=0;j<=min(sum[i],k);j++)
		{
			f[i][j]=((sum1[min(j,sum[i-1])+1]-sum1[max(0,j-a[i])]))%mode;
			if(sum1[min(j,sum[i-1])+1]-sum1[max(0,j-a[i])]<0)
				f[i][j]+=mode;
		}
	//	cout<<f[i][700]<<endl;
	}
	cout<<f[n][k]%mode<<endl;
	return 0;
}


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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  int big=a;
  if(big<b) big=b;
  if(big<c) big=c;
  
  int ans=big;
  for(int i=0; i<k; i++) ans*=2;
  ans+=a+b+c-big;

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


Measured memory_bytes: 256