akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

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

  vector<int> d;
  while (n > 0) {
    int x = n % 26;
    if (x == 0) {
      x = 26;
      n -= 26;
    }
    d.push_back(x);
    n /= 26;
  }

  string s;
  for (auto x : d) {
    s += (x - 1) + 'a';
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}


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

signed main() {

  int hi,hy,ki,ky,a,b,c,d;
  cin>>hi>>hy>>ki>>ky>>a>>b>>c>>d;
  int h = a*hi + b*hy + (hi/10)*c + (hy/20)*d;
  int k = a*ki + b*ky + (ki/10)*c + (ky/20)*d;
  string ans;
  if (h > k) {
    ans = "hiroshi";
  } else if (h < k) {
    ans = "kenjiro";
  } else {
    ans = "even";
  }
  cout << ans << endl;
}



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

int main() {
int x;
cin>>x;
int ans=1;
for(int i=2;i<=x;i++)
{
  //cout<<"hi"<<endl;
  for(int j=2;pow(i,j)<=x;j++)
  {
    //cout<<"hello"<<endl;
     if(pow(i,j)>ans)
     {
         ans=pow(i,j);
         //cout<<ans<<endl;
     }
  }
}
cout<<ans<<endl;
}

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

using namespace std;

int main(){
  int n,sum=0;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  int drinks;
  cin >> drinks;
  for(int i=0;i<drinks;i++){
    int ind,val,tmp;
    cin >> ind >> val;
    tmp=v[ind-1];
    v[ind-1]=val;
    cout << accumulate(v.begin(), v.end(), 0) << endl;
    v[ind-1]=tmp;    
  }
  return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

cumsum = 0
remains = {0:1}
for i in range(n):
    cumsum += a[i]
    r = cumsum%m
    if not r in remains.keys():
        remains[r] = 1
    else:
        remains[r] += 1
# print(remains)

ans = 0
for k, v in remains.items():
    ans += v*(v-1)//2
print(ans)

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

int main() {
  int n;
  cin >> n;
  int a[n], b[n-1];
  
  
  for(int i = 0;i<n-1;i++){
    cin >> b[i];
  }
  int res = b[0]+ b[n-2];
  for(int i = 1;i <n-1;i++){
    res += min(b[i],b[i-1]);
  }
  
  cout << res << endl;
 }

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

int n, k;
vector<int> h(500000);

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> h.at(i);

    sort(h.begin(), h.begin()+n);

    int ans = 2000000000;
    for (int i = 0; i < n-k+1; ++i)
    {
        ans = min(ans, h.at(i+k-1) - h.at(i));
    }

    cout << ans << endl;
}

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

int main(void) {
    string ipt;
    int cnt = 0, best = -1;
    cin >> ipt;
    for (int i = 0; i < ipt.size(); i ++) {
        if (ipt.at(i) == 'A' || ipt.at(i) == 'T' || ipt.at(i) == 'C' || ipt.at(i) == 'G') 
            cnt ++;
        else {
            best = max(best, cnt);
            cnt = 0;
        }
    }
    best = max(best, cnt);
    cout << best << '\n';
    return 0;
}

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

int calc(int x) {
	int ret = 0;
	while (x % 100 == 0) {
		x /= 100;
		ret++;
	}
	return ret;
}

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

	int cnt = 0, val = 0;
	while (cnt < n) {
		val++;
		if (calc(val) == d) cnt++;
	}
	cout << val << endl;

	return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let kk= i::i();
    let ss= i::i();

    let mut count=0;

    for xx in 0..(kk+1) {
        for yy in 0..(kk+1) {
            let mut zz=ss-xx-yy;
            if (zz>=0&&zz<=kk){
                count+=1;
            }
        }
    }
    println!("{}", count);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i32() -> i32 {
        read()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}

Measured memory_bytes: 4352
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000000
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << "\n"
#define pr2(a,b)cout << a <<  " " <<b<< "\n"
#define pr3(a,b,c) cout << a <<" " << b << " " << c << "\n"

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
const int maxn = 2*1e5 + 10;


void solve(){
    int r;
    cin >> r;

    double ans = 2.0*(double)pi*(double)r;

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

} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

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

 


Measured memory_bytes: 3796
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    while(n >= 0){
        if(n % 7 == 0){
            cout << "Yes" << endl;
            return 0;
        }
        n -= 4;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import math
mod=10**9+7

n,m=map(int,input().split())
if abs(n-m)>1:
      print(0)
      exit()

if n==m:
      print((math.factorial(n)*math.factorial(m)*2)%mod)
      exit()

print((math.factorial(n)*math.factorial(m))%mod)

Measured memory_bytes: 5180
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


int main()
{ios_base::sync_with_stdio(false);
ll n,ans=0;
cin>>n;
for(ll i=1;i<=n;i++)
{
	ans+=n/i;
	if(n%i==0)ans--;
}
ol(ans);
return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int n=0;
  for(int i=0;i<s.size();i++){
    string tmp=s.substr(i,1);
    n+=stoi(tmp);
  }
  if(stoi(s)%n==0) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
using System;

namespace abc061A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            if (C >= A && C <= B)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

int main(){
  int n,c=0;
  cin >> n;
  int h[n];
  vector<int> a;
  rep(i,n) cin >> h[i];
  rep(i,n-1){
 	 if(h[i+1]<=h[i])
       c++;
    else{
      a.push_back(c);
      c=0;}
    
  }
  a.push_back(c);
  cout << *max_element(a.begin(),a.end());
  
  return 0;

}

Measured memory_bytes: 1276
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        if (a + b >= c) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        inp.close();
    }
}

Measured memory_bytes: 21844
package main

import "fmt"

func main() {
	var p, s string
	fmt.Scan(&s, &p)
	s += s
	dp := make([][]int, len(s)+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, len(p)+1)
		dp[i][0] = 0
	}

	l := 0
	for i := 1; i <= len(s); i++ {
		for j := 1; j <= len(p); j++ {
			if s[i-1] == p[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
				if l < dp[i][j] {
					l = dp[i][j]
				}
			} else {
				dp[i][j] = 0
			}
		}
	}
	if l == len(p) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1324
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#define pb push_back
#define mp make_pair
#define p1 first
#define p2 second
using namespace std;

int main()
{
    //freopen("a.inp","r",stdin);
    int n, k; cin >> n >> k;
    k += k+1; cout << (n+k-1) / k;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

cnt = 0
while max(set(h)) > 0:
    flg = False
    for i in h:
        if i <= 0:
            flg = False
            continue
        else:
            if not flg:
                cnt += 1
            flg = True
    h = list(map(lambda x: x-1, h))

print(cnt)

Measured memory_bytes: 39280
a,b=map(int, input().split()) 
if a ==1 or b == 1:
    print(1)
    exit()
if a%2 != 0:
    if b%2 != 0:
        if a > b:
            print(int((-(-a//2))+(a*(b-1)/2)))
        else:
            print(int((-(-a//2))+(a*(b-1)/2)))
    else:
        print(int(a*b/2))
else:
    print(int(a*b/2))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 +7;
int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int * a = new int [n+1];
    int * b = new int [n+1];
    a[0]= a[1]=a[2] =0;
    b[0]=b[1]=b[2]=0;
    for(int i=3;i<=n;i++){
        a[i] = b[i-3]+1;
        b[i] = b[i-1]+a[i];
        a[i]%= mod;
        b[i]%=mod;
    }
    cout<<a[n];
    return 0;
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys


def solve(N: int):
    print((N-1)//2)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 101
#define MAXS 901
#define INF 1000000000
#define mod 1000000007

signed main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool can = true;
  while (1)
  {
    if (can)
    {
      c -= b;
      if (c <= 0)
      {
        cout << "Yes\n";
        return 0;
      }
      can = false;
    }
    else
    {
      a -= d;
      if (a <= 0)
      {
        cout << "No\n";
        return 0;
      }
      can = true;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int n, m;

  scanf("%d", &n);
  scanf("%d", &m);

  if( (m==1)&&(n==1)){
    printf("1\n");
    return 0;
  }else if( m==1 ){
    printf("%d\n", n-2);
    return 0;
  }else if( n==1 ){
    printf("%d\n", m-2);
    return 0;
  }
  long result = (long)(m-2)*(long)(n-2);
  
  printf("%ld\n", result);
  return 0;
	 
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
int n;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	if(!(n & (n - 1))) {puts("No"); return 0;}
	puts("Yes"); puts("1 2"); puts("2 3");
	printf("%d %d\n", 3, n + 1); printf("%d %d\n", n + 1, n + 2); printf("%d %d\n", n + 2, n + 3);
	for(int i = 4; i + 1 <= n; i += 2)
	{
		int j = i + 1;
		printf("%d %d\n", 1, i);
		printf("%d %d\n", 1, j);
		printf("%d %d\n", i, j + n);
		printf("%d %d\n", j, i + n);
	}
//	if(n % 2 == 0)
//	{
//		for(int i = 4; i <= n; i ++)
//		{
//			int j = (n ^ i ^ 1);
//			if(j != 3 && j < n)
//			{
//				printf("%d %d\n", i, n);
//				printf("%d %d\n", j, 2 * n);
//			}
//		}
//	}
	if (n%2==0)
		{
			for (int i=4;i<=n;i++)
			{
				int j=n^i^1;
				if (j!=3 && j<n)
				{
					cout << i << " " << n << endl;
					cout << j << " " << 2*n << endl;
					return 0;
				}
			}
		}
	fclose(stdin);
	fclose(stdout);
	return 0;
}


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

using namespace std;

int arr[100005];
int n;

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	int ans=0;
	for(int i=0;i<n-1;i++)
	{
		if(arr[i]==i+1)
		{
			ans++;
			swap(arr[i],arr[i+1]);
		}
	}
	if(arr[n-1]==n)
		ans++;
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vvi matrix;

int N,M,A,B,C,T;

void init(matrix &mat)
{

  mat[N-1][N-2]             = A;
  mat[0][0] = mat[N-1][N-1] = B;
  mat[0][1]                 = C;
  REP(i,1,N-1)
    {
      mat[i][i-1] = A;
      mat[i][i] = B;
      mat[i][i+1] = C;
    }
}

matrix identity(int n)
{
  matrix A(n,vector<int>(n));
  for(int i=0;i<n;i++) A[i][i] = 1;
  return A;
}

matrix multi(const matrix& A,const matrix& B)
{
  matrix C(A.size(),vector<int>(B[0].size()));
  for(int i=0;i<C.size();++i)
    for(int j=0;j<C[i].size();++j)
      for(int k=0;k<A[i].size();++k)
	C[i][j] = (C[i][j]+(A[i][k]*B[k][j])%M)%M;
  return C;
}

matrix pow(const matrix& A,int e)
{
  return !e?identity(A.size()):
    (e%2?multi(A,pow(A,e-1)):pow(multi(A,A),e/2));
}

void print(matrix &mat)
{
  cout << "^^^^^^^^^^" << endl;
  rep(i,mat.size())
    {
      rep(j,mat[i].size())
	{
	  cout << mat[i][j] << " ";
	}
      cout << endl;
    }
  cout << "-------------" << endl;
}

int main()
{
  while(cin >> N >> M >> A >> B >> C >> T,N|M|A|B|C|T)
    {
      matrix s(N,vi(1));
      rep(i,N)cin >> s[i][0];
      matrix coef(N,vi(N,0));
      init(coef);
      coef = pow(coef,T);
      s = multi(coef,s);
      rep(i,N)cout << (i?" ":"") << s[i][0];
      cout << endl;
    }
  return 0;
}

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

using namespace std;
long long a[100005];
long long now=0;
pair<long long,long long>cp[100005];
bool cmp(pair<long long,long long>a,pair<long long,long long>b){
	return a.second>b.second;
}
int main(){
//	bool f=0;
	long long n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<m;i++){
		cin>>cp[i].first>>cp[i].second;
	}
	sort(cp,cp+m,cmp);
	for(int i=0;i<n;i++){
		if(a[i]<cp[now].second){
			cp[now].first--;
			a[i]=cp[now].second;
		}
		if(cp[now].first==0)now++;
	}
	long long ans=0;
	for(int i=0;i<n;i++)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S;
	ll K;
	cin >> S >> K;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] != 'a') {
			int down = 26 - (S[i] - 'a');
			//cout << down << endl;
			if (down <= K) {
				K -= down;
				S[i] = 'a';
			}
		}
	}
	ll end = ((S[S.size()-1] - 'a') + K) % 26;
	S.back() = end + 'a';
	cout << S << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i = 0;i<n;i++)
		cin>>a[i];
	int b[n];
	b[1] = abs(a[0]-a[1]);
	b[0]=0;
	for(int i = 2;i<n; i++)
	{
		b[i] = min(b[i-2]+abs(a[i]-a[i-2]), b[i-1]+abs(a[i]-a[i-1]));
	}
	cout<<b[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    string s;
    cin >> s;

    map<char, int> m;
    for(char c: s){
        if(m.find(c) == m.end()){
            m[c] = 1;
            continue;
        }
        m[c]++;
    }

    int ans = s.length();
    ans = ans * (ans - 1) / 2 + 1;
    for(int i = 'a'; i <= 'z'; i++){
        int x = m[(char)i];
        ans -= x * (x - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <ll> v(m);
  rep(i, m) cin >> v.at(i);
  vector <ll> d(n+1, INF);
  d.at(0) = 0;
  rep(i, n+1) {
    rep(j, m) {
      if (i - v.at(j) >= 0) {
        d.at(i) = min(d.at(i), d.at(i-v.at(j))+1);
      }
    }
  }
  cout << d.at(n) << endl;
}


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int left = A + B;
    int right = C + D;
    
    if(left > right){
        cout << "Left\n";
    }
    else if(left == right){
        cout << "Balanced\n";
    }
    else{
        cout << "Right\n";
    }
}

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

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N * 3);
    vector<long long> S1(N + 1, 0);
    vector<long long> S2(N + 1, 0);
    for(int i = 0; i < 3 * N; i++)cin >> A[i];
    priority_queue<ll, vector<ll>, greater<ll>> M;
    priority_queue<ll> m;
    
    for(int i = 0; i < 2 * N; i++){
        if(i < N){
            S1[0] += A[i];
            M.push(A[i]);
        }else{
            S1[i + 1 - N] = S1[i - N] + A[i];
            M.push(A[i]);
            S1[i + 1 - N] -= M.top();
            M.pop();
        }
    }
    
    reverse(A.begin(), A.end());
    
    for(int i = 0; i < 2 * N; i++){
        if(i < N){
            S2[0] += A[i];
            m.push(A[i]);
        }else{
            S2[i + 1 - N] = S2[i - N] + A[i];
            m.push(A[i]);
            S2[i + 1 - N] -= m.top();
            m.pop();
        }
    }
    
    reverse(S2.begin(), S2.end());
    
    long long ans = -1e15;
    for(int i = 0; i <= N; i++){
        ans = max(ans, S1[i] - S2[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std; 
#define int int64_t
#define itn int
#define fi first
#define se second
#define mod 1000000007
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,x,t;
  cin>>n>>x>>t;
  if(n%x==0) cout<<n/x*t<<"\n";
  else{
    cout<<n/x*t+t<<"\n";
  }
  return 0;
}


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

using namespace std;

int main()
{
  int n,i,j,found;
  vector <int> v;
  
  cin >> n;
  
  for(i=1;i<=n;i++){
    cin >> j;
    v.push_back(j);
  }
  
  found = 1;
  for(i=0;i<n;i++){
    if(v[i]%2 == 0 && (v[i]%3!=0 && v[i]%5!=0)){
      found = 0;
      break;
    }
  }
  
  if(found) cout << "APPROVED";
  else cout << "DENIED";
  
  return 0;
}

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

typedef long long LL;

struct Point {
    int x;
    int y;
    int id;
    Point(int _x, int _y) {
        x = _x;
        y = _y;
    }
};

static bool cmpx(Point const & p1, Point const & p2) {
    return p1.x < p2.x;
}
static bool cmpy(Point const & p1, Point const & p2) {
    return p1.y < p2.y;
}

struct Unionset {
    vector<int> parents;
    Unionset(int n) {
        parents = vector<int>(n, -1);
        for (int i = 0; i < n; i++) parents[i] = i;
    }
    int find(int i) {
        if (parents[i] == i) return i;
        int ret = find(parents[i]);
        parents[i] = ret;
        return ret;
    }
    void add(int i, int j) {
        int dadi = find(i);
        int dadj = find(j);
        if (dadi == dadj) return;
        parents[dadi] = dadj;
        return;
    }
    bool check(int i, int j) {
        int dadi = find(i);
        int dadj = find(j);
        return dadi==dadj;
    }
};

int main() {
//    freopen("test.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    vector<Point> towns(n, Point(0, 0));
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &towns[i].x, &towns[i].y);
        towns[i].id = i;
    }
    vector<Point> townx = towns;
    vector<Point> towny = towns;

    sort(townx.begin(), townx.end(), cmpx);
    sort(towny.begin(), towny.end(), cmpy);


    multimap<int, pair<int, int> > graph;

    for (int i = 1; i < n; i++) {
        graph.insert({townx[i].x - townx[i-1].x, {townx[i].id, townx[i-1].id}});
        graph.insert({towny[i].y - towny[i-1].y, {towny[i].id, towny[i-1].id}});
    }
    Unionset connect = Unionset(n);

    LL cost = 0;

    for (auto it = graph.begin(); it != graph.end(); it++) {
        int id1 = it->second.first;
        int id2 = it->second.second;
        if (it->first == 0) {
            connect.add(id1, id2);
        }
        else if (!connect.check(id1, id2)) {
            cost += it->first;
            connect.add(id1, id2);
        }
    }
    cout << cost << endl;

    return 0;


}

Measured memory_bytes: 15104
package main

import (
	"fmt"
)

func main() {

	var S string

	fmt.Scan(&S)

	for i:=1;i<4;i++{

		if S[i-1:i] == S[i:i+1] {

			fmt.Println("Bad")
			return
		}
	}

	fmt.Println("Good")
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   int N;
   cin >> N;
   vector<long> a(N + 1);
   vector<long> b(N);
   long ans = 0;
   
   for(int i = 0;i < N + 1;i++){
       cin >> a[i];
   }
   for(int i = 0;i < N;i++){
       cin >> b[i];
   }
   for(int i = 0;i < N;i++){
       long temp = min(a[i],b[i]);
       ans += temp;
       b[i] -= temp;
       temp = min(a[i + 1],b[i]);
       ans += temp;
       a[i + 1] -= temp;
   }
   cout << ans << endl;
   
}


Measured memory_bytes: 1792
#include<iostream>
#include<set>
using namespace std;
set<int> s;
const int maxn=2e5+5;
int n,a[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        s.insert(a[i]);
    }
    if(s.size()==n)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 10368
n=int(input())
c=list(map(int, input().split()))

anc = float('inf')
tmp = 0
for p in range(min(c),max(c)+1):
    for i in c:
        tmp += (i-p)**2
    if tmp < anc:
        anc = tmp
    tmp = 0
print(anc)

Measured memory_bytes: 3060
/* AUTHOR :  SHIVANK JAIN */

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

#define ll long long
#define li long int

#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define reprev(i,n,a) for(int i=n;i>=a;i--)
#define endl "\n"

#define vi vector<int>
#define vll vector<ll>
#define vpi vector< pair<int , int> >
#define mapi map<int , int>
#define mapll map<ll ,ll >
#define seti set<int> 

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define sort(v) sort(v.begin() , v.end())

#define BIG 1000000007
int gcd(int a, int b) 
{ // builtin function __gcd(a,b)
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){

     fast;itt;now;
 
//    #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,d;  cin>>a>>b>>c>>d;
     bool f = 0;
     while(a > 0 and c >0){
     	if(f == false)
     	 c -= b;
		else
		 a -= d;
	  f = !f;	    
	 }
//	 cout<<a<<" "<<c<<endl;
     if(a <= 0)
      cout<<"No"<<endl;
     else 
      cout<<"Yes"<<endl;
}

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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
        mp[a[i]]++;
    }
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    for(int i = 0; i < n; i++){
        if(a[i] == b[0] && mp[b[0]] == 1){
            cout << b[1] << endl;
        }
        else cout << b[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 8704
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int a, n, m;
	cin >> a >> n >> m;
	int y;
	int ans = 0;
	for (y = 1; y <= 72; y++) {
		int x = 0;
		long long result = pow(y + a, n);
		if (result > m) continue;
		while (result) {
			x += result % 10;
			result /= 10;
		}
		if (result <= m && x==y) {
			ans++;
		}
	}
	cout << ans << endl;
	return(0);
}


Measured memory_bytes: 3368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int a,b,tmp;

		Scanner scan = new Scanner(System.in);

		while(true)
		{
		    a = scan.nextInt();
		    b = scan.nextInt();

		    tmp = a | b;

		    if(tmp == 0) break;

		    else if(b<a)
		    {
		    	tmp = a;
		    	a = b;
		    	b = tmp;
		    }

		    System.out.println(a + " " + b);
		}

	    scan.close();

	}
}

Measured memory_bytes: 36148
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int N; cin >> N;
	V<ll> h(N), dp(N,0); REP(i, N) cin >> h[i];
	dp[1] = abs(h[1] - h[0]);
	FOR(i, 2, N) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf = 1e9;
const int MAX = 1e5+5;
const ll MOD = 1e9+7;
#define REP(i, n) for (int i = 0; i < (n); ++i)

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n, m; cin >> n >> m;
    vector<ll> step(n+1, 0);
    step[0] = 1;
    priority_queue<int, vector<int>, greater<int>> p;
    int tmp;
    REP(i, m){
        cin >> tmp;
        p.push(tmp);
    }
    if(m != 0){
        tmp = p.top();
        p.pop();
        if(tmp == 1){
            step[1] = 0;
            tmp = p.top();
            p.pop();
        } else step[1] = 1;
    } else{
        tmp = 0;
        step[1] = 1;
    }
    for(int i=2; i<n; i++){
        if(i == tmp){
            step[i] = 0;
            tmp = p.top();
            p.pop();
        }else{
            step[i] = step[i-1] + step[i-2];
            step[i] %= MOD;
        }
    }
    ll ans;
    if(n >= 2) ans = (step[n-1] + step[n-2]) % MOD;
    else ans = step[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s,t;
    cin>>s>>t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s<t) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  string s1 = "dream", s2 = "dreamer", s3 = "erase", s4 = "eraser";
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  reverse(s3.begin(), s3.end());
  reverse(s4.begin(), s4.end());
  
  string t;
  while(true){
    if(s == "") break;
    if(s == t) break;
    t = s;
    if(s.substr(0, 5) == s1) s.erase(0, 5);
    if(s.substr(0, 7) == s2) s.erase(0, 7);
    if(s.substr(0, 5) == s3) s.erase(0, 5);
    if(s.substr(0, 6) == s4) s.erase(0, 6);
  }
  if(s == "") cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

#define lol long long

int main() {

	string s, t;
	cin >> s >> t;

	for (int i = 0; i < s.size(); i++) {

		if (s == t) {
			cout << "Yes";
			return 0;
		}

		s = s[s.size() - 1] + s;
		s.pop_back();

	}

	cout << "No";

	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, c) = readLine()?.split(" ")?.map { it.toInt() } ?: return

    // i <= a * b を満たす a の倍数 i について、 (i % b) == c となる i　が存在するかを確認する
    for (i in a..(a * b) step a) {
        if (i % b == c) {
            println("YES")
            return
        }
    }
    println("NO")
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  vector<vector<int>> A(N, vector<int>(N));
  REP(i, N) REP(j, N) cin >> A[i][j];
  const ll mod = 1e9+7;
  vector<ll> dp(1 << N);
  dp[0] = 1;
  REP(state, 1 << N) {
    int i = __builtin_popcount(state);
    REP(j, N) {
      if ((state >> j & 1) == 0 and A[i][j]) {
        dp[state | (1 << j)] += dp[state];
        dp[state | (1 << j)] %= mod;
      }
    }
  }

  cout << dp[(1 << N) - 1] << endl;
  return 0;
}


Measured memory_bytes: 16640
def bigger(a,b)
	return (a > b) ? a : b
end

def smaller(a,b)
	return (a > b) ? b : a
end

time = $stdin.read.split(" ")
time.map! do |element|
	element.to_i
end
a=time[0]
b=time[1]
c=time[2]
d=time[3]
max = bigger(a,c)
min = smaller(b,d)
#p max
#p min

if max <= min
	p(min - max)
else
	p(0)
end



Measured memory_bytes: 1788
n = int(input())
mod = (int)((10**9)+7)
if n < 2:
    print(0)
else:
    ans = 2*pow(9,n,mod) - pow(8,n,mod)
    a2 =  pow(10,n,mod)
    a = a2-ans
    if(a<0) :a+=mod
    print(a%mod)


Measured memory_bytes: 61624
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5+5;
int N,M;
vector<int> edges[maxn];
int dp[maxn];

int get_dp(int u){
    if(dp[u]!=-1)return dp[u];
    dp[u] = 0;
    for(auto to:edges[u]){
        dp[u] = max(dp[u], 1 + get_dp(to));
    }
    return dp[u];
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>N>>M;
    int x,y;
    for(int i = 0; i<M; i++){
        cin>>x>>y;
        edges[x].push_back(y);
    }
    memset(dp, -1, sizeof(dp));

    int ans = 1;
    for (int i = 1; i <= N; i++) get_dp(i);
    for (int i = 1; i <= N; i++) ans = max(ans, dp[i]);
    cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 7424
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
using namespace std;

int main(){
  ll N;
  cin>>N;
  vector<ll> b(N-1);
  for(ll i=0;i<N-1;i++){
    cin>>b[i];
  }
  ll ans =0;
  ll yyy=b[0];
  for(ll i=0;i<N-2;i++){
    if(b[i]>b[i+1]){
      b[i]=b[i+1];
    }
  }

ans+=yyy;
  for(ll i=0;i<N-1;i++){
    ans+=b[i];
  }
  
  cout<<ans<<endl;

}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for ai in range(a+1):
	for bi in range(b+1):
		for ci in range(c+1):
			if x == ai*500 + bi* 100 + ci*50:
				count+=1
				
print(count)

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

string solve(string s) {
  for (int i = 0; i < s.size(); i++) {
    if ((((i+1) % 2 == 1) && (s[i] == 'L')) ||
        (((i+1) % 2 == 0) && (s[i] == 'R'))) return "No";
  }
  
  return "Yes";
}

int main() {
  string s;
 
  cin >> s;
  cout << solve(s) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		rep(i,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	ll cnt=1;
	rep(i,n){
		if(v[i]==cnt)cnt++;
	}
	if(cnt==1)cout<<-1<<endl;
	else{
		cout<<n-cnt+1<<endl;
	}

}


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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
typedef long long ll;


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int a, b, c;
    cin >> a >> b >> c;

    if (a == b && b == c && c == a) {
        cout << "No" << endl;

        return 0;
    }

    if (a == b || b == c || c == a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3568
#include<stdio.h>
int main(void){
char a[3]={};
int b[3]={};
int i;
int j=0;
if(scanf("%c",&a[0])==1);
if(scanf("%c",&a[1])==1);
if(scanf("%c",&a[2])==1);
for(i=0;i<3;i++){
        if(a[i]=='a')b[0]++;
        if(a[i]=='b')b[1]++;
        if(a[i]=='c')b[2]++;
}
for(i=0;i<3;i++){
        if(b[i]!=1)j=1;
}
        if(j==1)printf("No");
        else printf("Yes");
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int h,w,k;
    cin>>h>>w>>k;
    int ca[h][w];
    int ans[h][w];
    set<int> ht;
    set<int> wt;
    vector<int> wh[301];
    int rw=0;
    rep(i,h){
        rep(j,w){
            ans[i][j]=0;
        }
    }

    rep(i,h){
        string s;
        cin>>s;
        rep(j,s.size()){
            ca[i][j]=(s[j]=='#'?1:0);
            if(s[j]=='#'){
                ht.insert(i);
                wt.insert(j);
                rw=max(rw,j);
                wh[i].push_back(j);
            }
        }
    }
//    rep(i,h){
//        rep(j,w){
//            cout<<ca[i][j]<<" ";
//        }
//        cout<<endl;
//    }



    vector<int> hk;
    int ac = 1;
    int prei = 0;
    for(auto &aa:wt){
       // cout<<aa<<" "<<prei<<endl;
        int kt = 0;
        vector<int> wq;

        for(int j=0;j<h;j++){
        for(int i=prei;i<=aa;i++){
                if(ca[j][i]==1){kt++;wq.push_back(j);}
            }
        }
        if(kt==1){
            for(int j=prei;j<=aa;j++){
            for(int i=0;i<h;i++){
               ans[i][j]=ac;
            }
        }ac++;
        }else{
            int pp=0;
            rep(q,wq.size()) {
                if(q==wq.size()-1) {
                    for(int j=prei;j<=aa;j++){
                        for(int i=pp;i<h;i++){
                            ans[i][j]=ac;
                        }
                    }
                    ac++;
                }else {
                    for(int j=prei;j<=aa;j++){
                        for(int i=pp;i<=wq[q];i++){
                            ans[i][j]=ac;
                        }
                    }
                    ac++;
                    pp=wq[q]+1;
                }
            }

        }

        prei=aa+1;
    }

    if(rw!=w-1){
        for(int j=0;j<h;j++){
            int t=ans[j][rw];
            for(int i=rw;i<w;i++){
                ans[j][i]=t;

            }
        }
    }

    rep(i,h){
        rep(j,w){
            cout<<ans[i][j]<<" ";

            }
        cout<<endl;
        }








    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;


int main(void){
    ll n;
    cin>>n;
    char s[100000];
    int i=0;
    while(n!=0){
        ll z=n%26;
        if(z==0) z=26;
        z--;
        s[i]='a'+z;
        if(n<27){
            i++;
            break;
        }
        n-=z+1;
        n/=26;
        i++;
    }
    for(int j=i-1;j>=0;j--)cout<<s[j];
    cout<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int n,m; cin>>n>>m;

    std::vector<pair<ll, int>> ab;

    rep(i,n){
        ll a; int b; cin >> a >> b;
        ab.push_back(make_pair(a,b));
    }

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

    ll ans = 0LL;
    int cnt = 0;

    rep(i, n){
        ll price = ab[i].first;
        int num = ab[i].second;

        if(cnt+num > m){
            ans += price*(m-cnt);
            break;
        } else {
            cnt += num;
            ans += price*num;
        }

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2420
#include "stdio.h"

char CF[16] = {'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
char letter[17];
int ans = 0;

int main() {
	scanf("%s", letter);
	for (int i = 0; i < 16; i++) {
		if (CF[i] != letter[i])ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  REP(i,n) cin >> s[i];
  ll ans = 0;
  REP(b,n){
    vector<string> t(n);
    REP(i,n) t[i] = s[i].substr(b+1) + s[i].substr(0, b+1);
    
    bool flag = true;
    REP(i,n) REP(j,n){
      if(t[i][j]!=t[j][i]) flag = false;
    }
    if(flag) ans += n;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 648
#include <iostream>
void solve(int N) {
  for (int i = 0; i <= N / 4; ++i) {
    if ((N - i * 4) % 7 == 0) {
      std::cout << "Yes" << std::endl;
      return;
    }
  }
  std::cout << "No" << std::endl;
}

int main(int argc, char *argv[]) {
  int N;
  std::cin >> N;
  solve(N);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	while(1){
		int a,b;
	    char op;
		cin>>a>>op>>b;
		if(op=='?')break;
		switch(op){
		case '+':
			cout<<a+b<<endl;
			break;
		case '-':
			cout<<a-b<<endl;
			break;
		case '*':
			cout<<a*b<<endl;
			break;
		case '/':
			cout<<a/b<<endl;
	   }
	}
	return 0;
}

Measured memory_bytes: 1160