akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

struct edge { 
        int to, c, w;
};

struct node {
        int c, d; 
        vector<edge> edges;
};

// g[v][r]: node
using graph = vector<vector<node>>;
using p     = pair<int, int>;

struct state {
        ll score;
        int v, s;

        bool operator<(const state& other) const {
                return score > other.score;
        }
};

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

        constexpr int M = 50 * 50;
        constexpr ll INF = static_cast<ll>(1e15);

        if (s > M) s = M;

        auto g = make_v(n, node());

        rep (i, m) {
                int u, v, a, b;
                cin >> u >> v >> a >> b;

                --u; --v;
                g[u].edges.push_back({v, a, b});
                g[v].edges.push_back({u, a, b});
        }
        
        rep (i, n) {
                int c, d;
                cin >> c >> d;
                g[i].c = c; g[i].d = d;
        }

        auto d = make_v(n, M, INF);

        priority_queue<state, vector<state>> q;

        d[0][s] = 0;
        q.push({0, 0, s});
       
        while (!q.empty()) {
                auto tmp = q.top();
                q.pop();

                const ll now_score = tmp.score;
                const int now_v = tmp.v, now_s = tmp.s;
                
                if (now_score > d[now_v][now_s]) continue;

                {
                        int ns = now_s;
                        while (true) {
                                int next = ns + g[now_v].c;

                                if (next >= M) break;
                                ll nd = d[now_v][ns] + g[now_v].d;

                                if (nd >= d[now_v][next]) break;
                                d[now_v][next] = nd;
                                q.push({nd, now_v, next});

                                ns = next;
                        }
                }

                for (edge e : g[now_v].edges) {
                        if (now_s >= e.c) {
                                ll nd = d[now_v][now_s] + e.w;
                                if (nd < d[e.to][now_s - e.c]) {
                                        d[e.to][now_s - e.c] = nd;
                                        q.push({nd, e.to, now_s - e.c});
                                }
                        }
                }
        }

        for (int v = 1; v < n; v++) {
                ll ans = INF;
                for (int r = 0; r < M; r++) {
                        ans = min(ans, d[v][r]);
                }
                cout << ans << endl;
        }

        return 0;
}


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

int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	
	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i-2]-arr[i]));
	}
	
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
n=input()
if n==2:print-1;exit(0)
r=range(n-1)
s=r+[n-1]
A=[[1+(i+j+1)%n for j in r]for i in s]
for i in r:
    for j in s:
        if A[A[j][i]-1][i]==j+1:
            A[j][i],A[j][i-n]=A[j][i-n],A[j][i]
print"\n".join(" ".join(map(str, e))for e in A)

Measured memory_bytes: 2692
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

X = get_nums_l()

for i,x in enumerate(X):
    if x == 0:
        print(i+1)

Measured memory_bytes: 67580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	int[] count = new int[26];
    	while (br.ready()){
        	String l = br.readLine();
        	for(char c: l.toCharArray()) {
        		int alpIdx = -1;
        		if ('a' <= c && c <= 'z') {
        			alpIdx = c - 'a';
        		}else if ('A' <= c && c <= 'Z'){
        			alpIdx = c - 'A';
        		}
        		if(alpIdx>=0){
        			count[alpIdx]++;
        		} 
        	}
    	}
    	char c = 'a';
    	int i = 0;
    	while(i<count.length) {
    		out.print(c++);
    		out.print(" : ");
    		out.println(count[i++]);
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
}

Measured memory_bytes: 24204
# -*- coding: utf-8 -*-
from collections import deque
H, W = map(int, input().split())
sx, sy = map(int, input().split())
sx -= 1
sy -= 1
gx, gy = map(int, input().split())
gx -= 1
gy -= 1
map = [list(input()) for i in range(H)]
cost_map = [[10**6]*W for i in range(H)]
d = deque()
cost_map[sx][sy] = 0
d.append([sx, sy])
while d:
    cx, cy = d.pop()
    if cx==gx and cy==gy:
        break
    ccost = cost_map[cx][cy]
    for dx, dy in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
        nx = cx + dx
        ny = cy + dy
        if 0<=nx<H and 0<=ny<W:
            if map[nx][ny]=="." and ccost < cost_map[nx][ny]:
                cost_map[nx][ny] = ccost
                d.append([nx, ny])
    dxy = [[-2, -2],[-2, -1],[-2, 0],[-2, 1],[-2, 2],
           [-1, -2],[-1, -1],[-1, 1],[-1, 2],
           [0, -2],[0, 2],
           [1, -2],[1, -1],[1, 1],[1, 2],
           [2, -2],[2, -1],[2, 0],[2, 1],[2, 2]]
    for dx, dy in dxy:
        nx = cx + dx
        ny = cy + dy
        if 0<=nx<H and 0<=ny<W:
            if map[nx][ny]=="." and (ccost + 1) < cost_map[nx][ny]:
                cost_map[nx][ny] = ccost + 1
                d.appendleft([nx, ny])
if cost_map[gx][gy] == 10**6:
    print("-1")
else:
    print(int(cost_map[gx][gy]))


Measured memory_bytes: 153920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int n,a[100005],ans=2e9;
inline int gcd( int a,int b ) { return b==0?a:gcd(b,a%b); }
int main() {
	n=_; int d=_;
	for( int i=2;i<=n;i++ ) d=gcd(d,_);
	cout<<d;
}

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

int dp[4001][4001];
char s1[4001], s2[4001];

int main() {
  while (scanf("%s", s1) != EOF) {
    scanf("%s", s2);
    int ans = 0;
    for (int i = 0; s1[i] != 0; i++) {
      for (int j = 0; s2[j] != 0; j++) {
        dp[i][j] = 0;
        if (s1[i] == s2[j]) {
          if (i == 0 || j == 0) dp[i][j] = 1;
          else dp[i][j] = dp[i - 1][j - 1] + 1;
        }
        ans = max(ans, dp[i][j]);
      }
    }
    printf("%d\n", ans);
  }
}



Measured memory_bytes: 65192
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
string A="Christmas",B="Eve";
int LiangJiaJun(){
    string k=A;
    int n;cin>>n;
    for(int i=n;i<25;i++){
        k+=" ";
        k+=B;
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

h , w = map(int, input().split())
visited = np.zeros((h,w),dtype=int)

for y in range(h):
    _in = input()
    for x, value in enumerate(_in):
        if value == '.':
            visited[y][x] = 10**9
            
for i in range(1,h):
    visited[i,:] = np.minimum(visited[i,:],visited[i-1,:]+1)
for i in reversed(range(h-1)):
    visited[i,:] = np.minimum(visited[i,:],visited[i+1,:]+1)
for j in range(1,w):
    visited[:,j] = np.minimum(visited[:,j],visited[:,j-1]+1)
for j in reversed(range(w-1)):
    visited[:,j] = np.minimum(visited[:,j],visited[:,j+1]+1)
print(np.max(visited))

Measured memory_bytes: 20276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,k;
	cin >> n >> k;
	ll a[n+1];
	for(ll i=1;i<=n;i++){
		cin >> a[i];
	}
	sort(a+1,a+1+n);
	if(k>=n){
		cout << 0 << endl;
		return 0;
	}
	ll sum=0;
	for(int i=1;i<=n-k;i++){
		sum+=a[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	x := nextInt()
	if 400 <= x && x < 600 {
		fmt.Println(8)
		return
	}
	if 600 <= x && x < 800 {
		fmt.Println(7)
		return
	}
	if 800 <= x && x < 1000 {
		fmt.Println(6)
		return
	}
	if 1000 <= x && x < 1200 {
		fmt.Println(5)
		return
	}
	if 1200 <= x && x < 1400 {
		fmt.Println(4)
		return
	}
	if 1400 <= x && x < 1600 {
		fmt.Println(3)
		return
	}
	if 1600 <= x && x < 1800 {
		fmt.Println(2)
		return
	}
	if 1800 <= x && x < 2000 {
		fmt.Println(1)
		return
	}

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <bits/stdc++.h> 
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    long long q(1);//cin>>q;
    while(q--){
      int t,g=0;cin>>t;
      while(t--)
      {
        int a,b;cin>>a>>b;
        if(a==b)
          g++;
        else
        {
          if(g==3){cout<<"Yes"<<endl;return 0;}
           g=0;
        }
     }
     if(g>=3)
      cout<<"Yes"<<endl;
     else
    cout<<"No"<<endl;return 0;
  }
}

Measured memory_bytes: 3652
import collections
n = int(input())
a = list(map(int, input().split()))
x = collections.Counter(a)

tem = 0
ans = [0]*(n+1)

for i in x:
    tem += x[i] * (x[i] - 1) // 2
    ans[i] = x[i] - 1

for i in a:
    print(tem-ans[i])

Measured memory_bytes: 26780
N,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]


inside=0
for i in range(N):
    for j in range(i,N):
        if A[i]>A[j]:
            inside+=1

outside=0
for i in range(N):
    for j in range(N):
        if A[i]>A[j]:
            outside+=1

s=inside*K+outside*((K*(K-1))//2)

print(s%(10**9+7))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll a[2*MAX];
string s;
ll n;
ll pre[2*MAX];

int main(){FAST;
cin>>s;
n = s.length();

ll p = 1;
for(ll i=n-1;i>=0;--i){
  a[i] = s[i]-'0';
  pre[i] = (pre[i+1]+a[i]*p%2019LL)%2019LL;
  p=p*10LL%2019LL;
}
vl f(2020);
f[0]++;
ll ans = 0;
for(ll i=n-1;i>=0;--i){
  ans+=f[pre[i]];
  f[pre[i]]++;
}
cout<<ans;
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


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

typedef long long ll;

ll gcd( ll x, ll y );
ll lcm( ll x, ll y );

int main()
{
    int n, c, a[11];

    while ( true ) {
        memset( a, 0, sizeof(a) );
        scanf("%d", &n );
        if ( n == 0 ) break;
        for ( int i = 0; i < n; i++ ) {
            scanf("%d", &c );
            a[c]++;
        }

        for ( int i = 0; i < 10; ++i ) {
            if ( a[i] != 0 ) {
                for ( int j = 0; j < a[i]; ++j ) {
                    printf("*");
                }
            } else {
                printf("-");
            }
            putchar('\n');
        }
    }

    return 0;
}

ll gcd( ll x, ll y )
{
    if ( y == 0 ) return x;
    return gcd( y, x % y );
}

ll lcm( ll x, ll y )
{
    return x / gcd( x, y ) * y;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n, m;
    cin >> n >> m;
    int a[n], sum = 0;
    rep(i, n) cin >> a[i], sum += a[i];

    int cnt = 0;
    rep(i, n) if(a[i] * 4 * m >= sum) cnt++;

    cout << (cnt >= m ? "Yes" : "No") << endl;

    return 0;
}

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

using namespace std;

const int N = 200001;
int h[N], dp[N];
int n, k;

int solve(int pos) {
    if (pos == 1) {
        return 0;
    }
    int& ans = dp[pos];
    if (ans != -1) {
        return ans;
    }
    ans = 2e9;
    for (int i = 1; i <= k; i++) {
        if (pos - i >= 1) {
            ans = min(ans, solve(pos - i) + abs(h[pos] - h[pos - i]));
        }
    }
    return ans;
}

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(n);
    return 0;
}


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

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

  vector<int> A(N);
  int findID = -1;
  int maxv = -1;
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
    if (maxv < A.at(i))
      findID = i;
    maxv = max(maxv, A.at(i));
  }

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

  for (int i = 0; i < N; i++)
  {
    if (findID == i)
      cout << A.at(N - 2) << endl;
    else
      cout << A.at(N - 1) << endl;
  }
}

Measured memory_bytes: 2432
#include<cstdio>
#include<cstring>
int main(void)
{
	char s[7];
	scanf("%s",s);
	if(s[0]=='S'){
		printf("Cloudy\n");
	}
	if(s[0]=='C'){
		printf("Rainy\n");
	}
	if(s[0]=='R'){
		printf("Sunny\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll N; cin >> N;
    ll res = to_string(N).size();
    ll A,B;
    // A <= B としてA,Bを求める． A <= B より Bの桁数の方が大きいことに注意．
    for (ll A=1; A<=sqrt(N); A++){
        if (N%A != 0) continue;
        B = N/A;
        // res = min(ll(to_string(B).size()),res);
        res = min((ll)log10(B)+1, res);
    }
    cout << res << endl;
    return 0;
}

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

int main ()
{
    int N, a;
    unordered_map<int, int> mp;
    cin >> N;

    mp[8] = 0;
    for (; N > 0; --N)
    {
        cin >> a;
        if (a < 400) ++mp[0];
        else if (a < 800) ++mp[1];
        else if (a < 1200) ++mp[2];
        else if (a < 1600) ++mp[3];
        else if (a < 2000) ++mp[4];
        else if (a < 2400) ++mp[5];
        else if (a < 2800) ++mp[6];
        else if (a < 3200) ++mp[7];
        else ++mp[8];
    }

    cout << max(1, static_cast<int>(mp.size()) - 1) << " " << static_cast<int>(mp.size()) - 1 + mp[8] << endl;
    return 0;
}

Measured memory_bytes: 256
#import re
import sys
input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    n = input().strip()
    k = int(input())
    if k == 1:
        ans = k1(n)
    elif k == 2:
        ans = k2(n)
    elif k == 3:
        ans = k3(n)
    
    print(int(ans))


def k1(n):
    ans = 0
    return 9*(len(n)-1)+int(n[0])

def k2(n):
    ans = 0
    if len(n) == 1:
        ans = 0
    elif len(n) >= 2:
        ans += k1(str(int(n[1:])))
        ans += (int(n[0])-1)*9*(len(n)-1)
        ans += 9*9*(len(n)-1)*(len(n)-2)/2
    return ans

def k3(n):
    ans = 0
    if len(n) <= 2:
        ans = 0
    elif len(n) >= 3:
        ans += k2(str(int(n[1:])))
        ans += (int(n[0])-1)*9*9*(len(n)-1)*(len(n)-2)/2
        ans += (len(n)-1)*(len(n)-2)*(len(n)-3)/6*9**3
    return ans

    
if __name__ == '__main__':
    main()


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

int main() {
    int K, X;
    cin >> K >> X;
    int l = X - (K-1);
    int r = X + (K-1);
    if (r==l) {
        cout << l << endl;
    } else {
        rep(i, r-l+1) {
            cout << l+i << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc155/tasks/abc155_b


N = gets.to_i
As = gets.split.map(&:to_i)

cond = As.select { |a| a.even? }.all? { |a| a % 3 == 0 || a % 5 == 0 }

puts cond ? 'APPROVED' : 'DENIED'


Measured memory_bytes: 1788
function Main(input) {
  input = input.split("\n");
  var a = input[0];
  input = input[1].split(" ");
  var ans = "";
  for(var i=0;i<a;i++){
    ans+=input[0].charAt(i);
    ans+=input[1].charAt(i);
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	static int max;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = sc.nextInt();
		}
		Arrays.sort(list);
		ArrayList<Integer> ans = new ArrayList<Integer>();
		for(int i = 0; i < Math.min(n, 50); i++) {
			for(int j = 0; j < Math.min(n, 50); j++) {
				if(i == j) continue;
				ans.add(Integer.parseInt(String.valueOf(list[i]) + String.valueOf(list[j])));
			}
		}
		Collections.sort(ans);
		System.out.println(ans.get(2));
	}
}

Measured memory_bytes: 31952
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
	vl A;
	cin >> n;
	inputv(A, n);
	a = 1;
	rep(i, n) {
		if (a == A[i])a++;
	}

	if (a == 1) {
		cout << -1 << endl;
	}
	else {
		cout << n - a + 1 << endl;
	}
}

Measured memory_bytes: 2420
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        Pair[] jobs = new Pair[N];
        for(int i = 0; i < N; i++) {
            jobs[i] = new Pair(scanner.nextInt(), scanner.nextInt());
        }
        Arrays.sort(jobs);
        int cnt = 0;
        int curTime = 0;
        for(int i = 0; i < N; i++) {
            if (curTime + jobs[i].a > jobs[i].b) break;
            cnt++;
            curTime += jobs[i].a;
        }
        if (cnt == N) out.println("Yes");
        else out.println("No");
        out.flush();
    }
    
    static class Pair implements Comparable<Pair> {
        int a, b;
        public Pair(int aa, int bb) {
            a = aa; b = bb;
        }
        public int compareTo(Pair o) {
            if (b == o.b) return a - o.a;
            return b - o.b;
        }
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


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

int a[300003];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<3*n; ++i)
        scanf("%d",&a[i]);
    sort(a, a+3*n, greater<int>());
    long long sum = 0;
    for(int i=1, j=0; j<n; i+=2)
        sum += a[i], ++j;
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int n,m; cin >> n >> m;
  vvi G(n);
  rep(i,m) {
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].pb(b);
  }
  int s,t; cin >> s >> t; s--; t--;

  vvi dist(n,vi(3,-3));
  queue<pii> q;

  dist[s][0] = 0;
  q.push(mp(s,0));

  while(!q.empty()){
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    for(auto nv : G[v]) {
      int nl = (l+1)%3;
      if(dist[nv][nl] != -3) continue;
      dist[nv][nl] = dist[v][l] + 1;
      q.push(pii(nv,nl));
    }
  }

  cout << dist[t][0]/3 << endl;
}

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

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

    int n;  cin >> n;

    vector<int> a(n), b(n);

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

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

    if(n % 2) {
        int idx = n / 2;
        int mx = b[idx], mn = a[idx];
        cout << mx - mn + 1 << '\n';
        return 0;
    }

    int idx0 = n / 2, idx1 = idx0 - 1;
    double mx = (b[idx0] + b[idx1]) / 2.0;
    double mn = (a[idx0] + a[idx1]) / 2.0;

    cout << (int)((mx - mn) / 0.5 + 1) << '\n';

    return 0;
}


Measured memory_bytes: 4776
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;
  int max=0;

  //長さの入力
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  //要素の入力
  for(i=1; i<=n; i++){
    scanf("%d",&A[i]);
    if(max<A[i]){
      max=A[i];
    }
  }
  //配列Cを初期化
  for(i=0; i<max; i++){
    C[i]=0;
  }
  //C[i]にiの出現数を記録する
  for(j=1; j<=n; j++){
    C[A[j]]++;
  }
  //C[i]にi以下の数の出現数を記録する
  for(i=1; i<=max; i++){
    C[i] = C[i] + C[i-1];
  }
  for(j=n; j>=1; j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1; i<=n; i++){
    printf("%d",B[i]);
    if(i!=n){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9584
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
def Yes(x):print("Yes")if x==True else print("No")
h1,m1,h2,m2,k=NM()
x=h1*60+m1
y=h2*60+m2
if y>x:
    print(y-x-k)
else:
    print(y+60*24-x-k)

Measured memory_bytes: 62016
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,p[1001000],cnt;
int main(){
	cin>>n;
	if(n<3){puts("No");return 0;}
	int k1=-1,k2=-1;
	if((n+1)%4){
		int r=n/4;
		if((r&-r)==r){
			if(n%4==0){puts("No");return 0;}
			puts("Yes");
			printf("1 %d\n",n/4*4+1);
			printf("1 %d\n",n/4*4);
			printf("%d %d\n",n/4*4+1,n/4*4+n);
			printf("%d %d\n",n/4*4,n/4*4+n+1);
			if(n%4==2){
				printf("%d %d\n",n/4*4,n/4*4+2);
				printf("3 %d\n",n/4*4+2+n);
			}
		}
		else puts("Yes"),k1=r&-r,k2=(n/4)^k1;
	}
	else puts("Yes");
	for(int i=0;i+3<=n;i+=4){
		if(k1==i/4||k2==i/4) continue;
		if(i)p[++cnt]=i;p[++cnt]=i+1;p[++cnt]=i+3;p[++cnt]=i+2;
		if(i)p[++cnt]=i+n;p[++cnt]=i+1+n;p[++cnt]=i+3+n;p[++cnt]=i+2+n;
	}
	if(k1>0){
		int w1=cnt+6,w2=cnt+9;
		p[++cnt]=k1*4;p[++cnt]=k1*4+3;p[++cnt]=k1*4+2;p[++cnt]=k1*4+1;
		p[++cnt]=k1*4+n;p[++cnt]=k1*4+3+n;p[++cnt]=k1*4+2+n;p[++cnt]=k1*4+1+n;
		p[++cnt]=k2*4;p[++cnt]=k2*4+1;p[++cnt]=k2*4+2;p[++cnt]=k2*4+3;
		p[++cnt]=k2*4+n;p[++cnt]=k2*4+1+n;p[++cnt]=k2*4+2+n;p[++cnt]=k2*4+3+n;
		printf("%d %d\n",p[w1],n/4*4),printf("%d %d\n",p[w2],n/4*4+n);
		if(n%4>=1) printf("%d %d\n",p[w1+2],n/4*4+1),printf("%d %d\n",p[w2],n/4*4+1+n);
		if(n%4>=2) printf("%d %d\n",p[w1+2],n/4*4+2),printf("%d %d\n",p[w2+2],n/4*4+2+n);
	}
	for(int i=1;i<cnt;i++)
		cout<<p[i]<<' '<<p[i+1]<<'\n';
	return 0;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>

using namespace std;

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

	cin >> a >> b;

	int d = a / b;
	int r = a % b;
	double f = (double)a / b;

	printf("%d %d %f\n", d, r, f);

	return 0;
}

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

int main(){
int N;
cin >> N;
vector<int> data(N);
vector<int> data_odd(N);//奇数格納用変数
vector<int> even_odd(N);//偶数格納用変数
int odd_cnt = 0;

for(int i =0;i<N;i++){
	cin >> data.at(i);
	if(data.at(i) % 2 == 1){
	odd_cnt++;
	}
}
if(odd_cnt % 2 == 0){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}

}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;


bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}


int main() {
	lli n;
	cin >> n;
	vector<lli> a(n),b(n);
	rep0(i, n)cin >> a[i];
	rep0(i, n)cin >> b[i];
	lli ans=0;
	while (1) {
		lli temp = 0;
		rep0(i, n) {
			if (b[i] > b[(i - 1 + n) % n] + b[(i + 1 + n) % n]) {
				if (a[i] < b[i]) {
					temp += (b[i] - a[i]) / (b[(i - 1 + n) % n] + b[(i + 1 + n) % n]);
					b[i]=(b[i] - a[i]) % (b[(i - 1 + n) % n] + b[(i + 1 + n) % n])+a[i];
				}
			}
		}
		ans += temp;
		if (temp == 0)break;
	}
	rep0(i, n) {
		if (b[i] != a[i]) {
			cout << -1;
			return 0;
		}
	}
	cout <<  ans << endl;
}


Measured memory_bytes: 3328
#include<stdio.h>
char map[20][13][13];
int nya;
void a_land(int y,int x){
    map[nya][y][x]='0';
    /*
    printf("%d %d\n",x,y);
    */
    if(map[nya][y-1][x]=='1'&&y!=0){
        a_land(y-1,x);
    }
    if(map[nya][y][x+1]=='1'&&x!=11){
        a_land(y,x+1);
    }
    if(map[nya][y+1][x]=='1'&&y!=11){
        a_land(y+1,x);
    }
    if(map[nya][y][x-1]=='1'&&x!=0){
        a_land(y,x-1);
    }
}
int main(void){
    int i,j,n=0;
    for(nya=0;;nya++){
        for(i=0;i<12;i++){
            if(scanf("%s",map[nya][i]) == EOF) {
                goto end;
            }
        }
        for(i=0;i<12;i++){
            for(j=0;j<12;j++){
                if(map[nya][i][j]=='1'){
                    map[nya][i][j]=='0';
                    a_land(i,j);
                    n++;
                    /*
                    printf("-----\n");
                    */
                }
            }
        }
    printf("%d\n",n);
    n=0;
    getchar();
    }
end:
return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int h, w, n;
  cin >> h >> w >> n;

  vvt<int> grid(w);
  rep(i, 0, n) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    grid[y].push_back(x);
  }
  sort(all(grid[0]));
  rep(i, 1, w) {
    grid[i].push_back(i - 1);
    sort(all(grid[i]));
  }

  int ans = INF, cnt = 0;
  int y = 0;
  rep(i, 0, w) {
    int lim = h;
    for(auto &it : grid[i]) {
      if(it > y) {
        lim = it;
        break;
      }
    }

    ans = min(ans, lim - y + cnt);
    int nxt = y + 1;
    if(i != w - 1) {
      for(auto &it : grid[i + 1]) {
        if(it == nxt) nxt++;
      }
    }
    cnt += nxt - y;
    y = nxt;
    if(y == lim) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11392
#![allow(unused_mut)]
#![allow(non_snake_case)]

#![allow(unused_imports)]
use std::io::prelude::*;
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut a: Vec<i64> =
        (0..n).map(|_| input()).collect();
    a[0]-=1;
    for i in 1..n {
        if a[i-1] <= a[i] - 1 {
            a[i]-=1;
        }
    }
    for i in 1..n {
        if a[i-1] <= a[i] {
            continue;
        }
        println!("No");
        return;
    }
    println!("Yes");
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/5

int n,m,r;
int dl[222][222];
int ds[222][222];
int dp[1111][222];
int rs[1111];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n>>m;
    if(n==0)break;
    rep(i,222)rep(j,222){
      dl[i][j]=i==j?0:INF;
      ds[i][j]=i==j?0:INF;
    }
    rep(i,1111)rep(j,222)dp[i][j]=INF;
    rep(i,m){
      int x,y,t; string sl;
      cin>>x>>y>>t>>sl; x--; y--;
      if(sl=="L"){
        dl[x][y]=dl[y][x]=t;
      }else{
        ds[x][y]=ds[y][x]=t;
      }
    }
    rep(k,n)rep(i,n)rep(j,n){
      minch(dl[i][j],dl[i][k]+dl[k][j]);
      minch(ds[i][j],ds[i][k]+ds[k][j]);
    }
    cin>>r;
    rep(i,r){
      cin>>rs[i];
      rs[i]--;
    }
    dp[0][rs[0]]=0;
    rep(i,r-1){
      int crt=rs[i],nxt=rs[i+1];
      rep(j,n){
        minch(dp[i+1][j],dp[i][j]+dl[crt][nxt]);
        if(crt==j){
          rep(k,n)minch(dp[i+1][k],dp[i][j]+ds[crt][k]+dl[k][nxt]);
        }
        rep(k,n)minch(dp[i+1][k],dp[i][j]+dl[crt][j]+ds[j][k]+dl[k][nxt]);
      }
    }
    int res=INF;
    rep(j,n)minch(res,dp[r-1][j]);
    cout<<res<<endl;
  }
	return 0;
}

Measured memory_bytes: 4416
/*
Author : N_o_o_B
Created : April 11 2020 11:03:53 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;


    int n,x,y;
    cin >> n >> x >> y;
    vi ans(n);
    rep(i,1,n){
        queue<int> q;
        q.push(i);
        vi d(n+1,-1);
        d[i] = 0;
        while(sz(q)){
            int u = q.front();
            ans[d[u]]++;
            q.pop();
            for(int y:{u-1,u+1}){
                if(y>=1 and y<=n and d[y]==-1){
                    d[y] = d[u] + 1;
                    q.push(y);
                }
            }
            if(u == x or u == y){
                int dis = d[y^x^u];
                if(dis!=-1) continue;
                d[y^x^u] = d[u] + 1;
                q.push(y^x^u);
            }
        }
    }
    fori(i,n){
        if(i) cout << ans[i]/2 << endl;
    }
    cout << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final double tax_rate = 1.08;
        int N = sc.nextInt();
        double X;
        X = (double) N / tax_rate;
        if (N == (int)Math.floor(Math.floor(X) * tax_rate)) {
            System.out.println((int)Math.floor(X));
        } else if (N == (int) Math.floor(Math.ceil(X) * tax_rate)) {
            System.out.println((int)Math.ceil(X));
        } else {
            System.out.println(":(");
        }
    }
}

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

int main()
{
    int result = 0;
    string s, t;
    cin >> s;
    cin >> t;
    result = t.compare(0, s.size(), s);
    if (s.size() + 1 == t.size())
    {
        if (result == 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */
typedef vector<vector<ll> > Matrix;

void warshall_floyd(Matrix& d) { // nは頂点数
  ll n = d.size();
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}


int main() {
  ll H, W; cin >> H >> W;
  Matrix d = Matrix(10, vector<ll>(10, INF));
  REP(i, 10) REP(j, 10){
    int c;  cin >> c;
    d[i][j] = c;
  }
  vector<ll> cnt(10, 0);
  REP(i, H) REP(j, W){
    int a; cin >> a;
    if(a==-1) continue;
    cnt[a]++;
  }

  warshall_floyd(d);

  // REP(i, 10) REP(j, 10){
  //   printf("%lld % lld : %lld\n", i, j, d[i][j]);
  // }

  ll ans = 0;
  REP(i, 10){
    ans += cnt[i] * d[i][1];
  }
  cout << ans << endl;
}


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

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int sum = 0;
	while(k>0 && a>0){
		sum += 1;
		a -= 1;
		k -= 1;
	}
	while(k>0 && b>0){
		b -= 1;
		k -= 1;
	}
	while(k>0 && c>0){
		sum -= 1;
		c -= 1;
		k -= 1;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3624
N=int(input())
L=list(map(int,input().split()))
L.sort(reverse=True)
ans=0
for i in range(N-1):
    j=N-1
    k=i+1
    while k<j:
        if L[i]<L[j]+L[k]:
            ans+=(j-k)
            k+=1
        else:
            j-=1
print(ans)


Measured memory_bytes: 3188
#include <iostream>

using namespace std;
using ll = long long;

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

	string ans = "";
	for (int i = 0; i < N; ++i) {
		ans += S[i];
		ans += T[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb push_back

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

// Check for number of Cases!!
void solve() {
    ll d, t, s;
    cin >> d >> t >> s;
    if(t * s >= d) {
        cout << "Yes";
    }else cout << "No";
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
long n, m;
 
int main() {
    cin >> n >> m;
    long sum=0;
    priority_queue<long> q;
    for(long i = 0; i < n; i++){
        long a;
        cin >> a;
        q.push(a);
    }
    for(long j = 0; j < m; j++){
        long newa = q.top();
        q.pop();
        q.push(newa/2);
    }
    while(!q.empty()){
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;
}

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

#ifdef LOCAL
#include <local.h>
#endif

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using i64 = long long;
template <typename T> using p = pair<T,T>;

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

    i64 a, b, n; cin >> a >> b >> n;
    i64 x;
    if (n >= b - 1)
        x = b - 1;
    else
        x = n;
    cout << (a*x)/b - a*(x/b) << ende;

    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(){
   int k,s,cnt=0;
   cin >> k >> s;
   for(int x =0;x<=k;x++){
       for(int y=0;y<=k;y++){
           if(s-x-y>=0&&k>=s-x-y){
               cnt++;
           }
       }
   }
   cout << cnt << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#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 sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

int main(void) {
	int n;
	int k;
	int sum = 0;
	scanf("%d%d", &n, &k);
	REP(i, k) {
		int x;
		scanf("%d", &x);
		sum += x;
	}

	if (sum > n) {
		printf("-1\n");
	}
	else {
		printf("%d\n", n - sum);
	}
}

Measured memory_bytes: 3816
N=int(input())
dp=[0,0,0]
#dp=[]
for i in range(0,N):
    new_dp=[]
    for i in range(0,3):
        new_dp.append(0)
    costs=[int(j) for j in input().split()]
    for k in range(0,3):
        for j in range(0,3):
            if(k!=j):
                new_dp[j]=max(new_dp[j],dp[k]+costs[j])
    dp=new_dp
print(max(dp[0],dp[1],dp[2]))

Measured memory_bytes: 49496
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, p;
	scanf("%lld %lld", &n, &p);
	if(n == 1) return 0 * printf("%lld\n", p);
	int ans = 1;
	for(int i = 2; 1ll * i * i <= p; i++){
		int cnt = 0;
		long long tmp_p = p;
		while(tmp_p % i == 0){
			tmp_p /= i;
			cnt++;
		}
		if(cnt >= n) ans = i;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int  n;
int res[505][505];

void dfs(int start,int to,int index){
	if(to-start+1<=1) return;
	for(int i=start;i<to;i++)
		for(int j=i+1;j<=to;j++) res[i][j]=index;
	int mid=(start+to)>>1;
	dfs(start,mid,index+1),dfs(mid+1,to,index+1);
}
int main(){
	cin>>n;
	dfs(1,n,1);

	for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
	cout<<res[i][j]<<" ";cout<<endl;
	}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int,int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(int i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b - a - b + 1;
}


Measured memory_bytes: 256
n=int(input())
s=[]
m={}
for i in range(n):
    st=input()
    if(st in m):m[st]+=1
    else:m[st]=1
mx=max(m.values())
ans=[]
for i in m:
    if(m[i]==mx):ans.append(i)
ans=sorted(ans)
for i in ans:
    print(i)

Measured memory_bytes: 32988