akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

    int count = 0;
    for (int i = 1; i < n - 1; ++i) {
        int max_val = v[i - 1];
        int min_val = v[i - 1];
        for (int k = i; k <= i + 1; ++k) {
            max_val = max(max_val, v[k]);
            min_val = min(min_val, v[k]);
        }

        if (min_val != v[i] && max_val != v[i])
            ++count;
    }

    cout << count << '\n';
}


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

int n,a[100010],mn,mx,cnt;

void work()
{
	scanf("%d",&n),mn=n;
	for (int i=1; i<=n; i++)
		scanf("%d",&a[i]),mn=min(mn,a[i]),mx=max(mx,a[i]);
	if (mn==mx)  puts((2*mn<=n)||(mn==n-1)?"Yes":"No"),exit(0);
	if (mn!=mx-1)  puts("No"),exit(0);
	for (int i=1; i<=n; i++)  cnt+=(a[i]==mn);
	if ((cnt>=mx)||(2*(mx-cnt)>n-cnt))  puts("No"),exit(0);
	puts("Yes");	
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 640
/**akshaykumar99**/

#include<bits/stdc++.h>
using namespace std;

#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int MOD=1e9+7 ;
const long long INF=1e15;
const long long LINF=LLONG_MAX;

typedef long long ll;
typedef long double ld;
typedef vector<ll> lvc;
typedef pair<ll,ll> lpr;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
 
  ll a,b;
  cin>>a>>b;
  ll z,x,c;
  z=a+b;
  z=max(z,a-b);
  cout<<max(z,a*b);

    


}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;
using std::upper_bound;
using std::lower_bound;
using std::binary_search;

using std::iota;

typedef unsigned long long ll;

int main(void) {
    ll k;
    cin >> k;

    ll n = 50;
    vector<ll> a(n);
    iota(a.begin(), a.end(), k / n);

    ll m = k % n;
    for(ll i = 0; i < m; i++){
        a[i] += n;
        a[i] -= (m - 1);
    }
    for(ll i = m; i < n; i++){
        a[i] -= m;
    }

    cout << n << endl;
    for(ll i = 0; i < n - 1; i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n),s(n);
    rep(i,0,n){
        ll k;
        cin>>k;
        a.at(i)=k;
        s.at(i)=k-(i+1);
    }
    
    sort(all(s));
    ll b=s.at(n/2);
    
    ll ans=0;
    rep(i,0,n){
        ans+=abs(a.at(i)-(b+i+1));
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main() {
    int X;
    cin >> X;
    int num = 0;
    int i = 0;
    while(true){
        num = X + i;
        bool flag = true;
        if(num > 2){
            repX(i,num,2){
                if(num%i==0){
                    flag = false;
                    break;
                }
            }
        }
        if(flag){
            cout << num << endl;
            return 0;
        }

        i++;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def calc(x):
    c2, c5 = 0, 0
    if '.' in x:
        x = x.rstrip('0')
        cnt = len(x) - x.index('.') - 1
        c2, c5 = -cnt, -cnt
    x = int(x.replace('.', ''))
    while x % 2 == 0:
        c2 += 1
        x = x // 2
    while x % 5 == 0:
        c5 += 1
        x = x // 5
    return c2, c5
    
    
d = defaultdict(int)
n = int(input())
A = []
for _ in range(n):
    a = input()
    c2, c5 = calc(a)
    d[(c2, c5)] += 1
ans = 0
key = list(d.keys())
for i in range(len(key)):
    c2, c5 = key[i]
    v = d[(c2, c5)]
    if (c2 >= 0) & (c5 >= 0):
        ans += v * (v - 1) // 2
    for j in range(i + 1, len(key)):
        n2, n5 = key[j]
        if ((n2 + c2) >= 0) & ((n5 + c5) >= 0):
            ans += v * d[(n2, n5)]
print(ans)            


Measured memory_bytes: 9420
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n;
  string s;
  cin>>n>>s;
  string t;
  int ans=0;
  rep(i,n-2){
    t=s.substr(i,3);
    if(t=="ABC") ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]
C = Counter(A)
Q = int(input())
S = sum(n * c for n, c in C.items())
for i in range(Q):
    b, c = map(int, input().split())
    t = C[b]
    S += (c-b)*t
    C[c] += t
    C[b] = 0
    print(S)


Measured memory_bytes: 23996
#include <iostream>

using namespace std;

int main()

{

  ios::sync_with_stdio(false);

  cin.tie(0);

  cout.tie(0);

  int d, t, s;

  cin >> d >> t >> s;

  string res = "Yes";

  if (d > t * s)

    res = "No";

  cout << res << endl;

  return 0;

}

Measured memory_bytes: 3068
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string.h>
#include <math.h>



int main(){
        char *c = (char*)malloc(sizeof(char)*10);
        scanf("%s",c);
        printf("%s\n", ((c[2] == c[3] && c[4]==c[5]) ? "Yes":"No" ) );
        free(c);
        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

const int MOD = 1000000007;


inline int add(int a, int b)
{ 
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

inline int sub(int a, int b)
{ 
  a -= b;
  if (a < 0) a += MOD;
  return a;
}

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

  int N, K;

  std::cin >> N >> K;

  vector<vector<int>> dp = vector<vector<int>>(N+1, vector<int>(K+1, 0));
  vector<vector<int>> prefix = dp;
  prefix[0] = vector<int>(K+1, 1);

  for (int i = 1; i <= N; ++i)
  { 
    int kid;
    cin >> kid;

    for (int sum = 0; sum <= K; ++sum)
    { 
      int R = min(kid, sum);

      dp[i][sum] = sub(prefix[i - 1][sum], (sum - R > 0 ? prefix[i - 1][sum - R - 1] : 0));
      prefix[i][sum] = add(dp[i][sum], (sum > 0 ? prefix[i][sum - 1] : 0));
    }
  }

  std::cout << dp[N][K];

  return 0;
}

Measured memory_bytes: 79736
/* ex3_2
   urah  */

#include <stdio.h>

int main(void){
    int N_ones_place;

    // 入力受け取り
    scanf("%d", &N_ones_place);

    // 条件分岐
    if (N_ones_place%10 == 3) {
        printf("bon");
    } else if (N_ones_place%10 == 0 || N_ones_place%10 == 1 || N_ones_place%10 == 6 || N_ones_place%10 == 8){
        printf("pon");
    } else {
        printf("hon");
    }

    return 0;
}


Measured memory_bytes: 1732
S = input()
len_s = len(S)
for i in range(2, len_s, 2):
    deleted_str = S[:-i]
    center = (len_s - i) // 2
    mae = deleted_str[:center]
    ato = deleted_str[center:]
    if mae == ato:
        print(len(deleted_str))
        break


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
	string s,t;

	cin >> s;
	cin >> t;

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

	if(s==t){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

	return 0;
}

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


int main(void){
    // Your code here!
    string s;
    cin >> s;
    int a, b, c, d;
    a = s[0]-'0';
    b = s[1]-'0';
    c = s[2]-'0';
    d = s[3]-'0';
    int signs[2] = {1, -1};
    for(int i=0; i<2; i++) {
        for(int j=0; j<2; j++) {
            for(int k=0; k<2; k++) {
               int tmp = a + b*signs[i] + c*signs[j] + d*signs[k];
               if(tmp == 7) {
                   cout << a << (i==0?"+":"-") << b << (j==0?"+":"-") << c << (k==0?"+":"-") << d << "=7" << endl;
                   return 0;
               }
            }
        }    
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string s, tmp;
  cin >> s;
  tmp = "i";
  for(int i=0; i<s.length(); i++)
    if(tmp=="i" && s[i]=='h') tmp="h";
    else if(tmp=="h" && s[i]=='i') tmp="i";
    else tmp="no";
  
  if(tmp!="no" && s[s.length()-1]=='i') cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}

const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}


void solve(){
    int n,m,x;
    cin >> n >> m >> x;
    int mat[n+5][m+5],cost[n+5];
    FOR(i,0,n){
        cin >> cost[i];
        FOR(j,0,m)cin >> mat[i][j];
    }
    int ans = inf;
    FOR(i,0,(1<<n)){
        int lvl[m+5],tot = 0;
        memset(lvl,0,sizeof lvl);
        FOR(j,0,n){
            if(i&(1<<j)){
                tot += cost[j];
                FOR(k,0,m)lvl[k] += mat[j][k];
            }
        }
        bool fo = 1;
        FOR(j,0,m)if(lvl[j] < x)fo = 0;
        if(fo)ans = min(ans,tot);
    }
    if(ans == inf)ans = -1;
    cout << ans;
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
       solve();
       cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

string move(ll sx,ll sy,ll tx,ll ty){
    string S;
    if (sx>tx){
        rep(i,sx-tx){
            S += 'L';
        }
    }
    else if (sx<tx){
        rep(i,tx-sx){
            S += 'R';
        }
    }
    if (sy>ty){
        rep(i,sy-ty){
            S += 'D';
        }
    }
    else if (sy<ty){
        rep(i,ty-sy){
            S += 'U';
        }
    }
    return S;
}

int main(){
    ll sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    string S;
    ll xx = tx - sx;
    ll yy = ty - sy;
    rep(i,xx){
        S += 'R';
    }
    rep(i,yy){
        S += 'U';
    }
    rep(i,xx){
        S += 'L';
    }
    rep(i,yy+1){
        S += 'D';
    }
    rep(i, xx+1){
        S += 'R';
    }
    rep(i,yy+1){
        S += 'U';
    }
    S += "LU";
    rep(i,xx+1){
        S += 'L';
    }
    rep(i,yy+1){
        S += 'D';
    }
    S += 'R';
    cout << S << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();

		int ans = 0;
		if(A + B >= C) {
			ans = B + C;
		}else {
			ans  = 2 * B + A + 1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int prime[2020],np;
bool vis[10101];
void findprime()
{
	memset(vis,0,sizeof(vis));
	np=0;
	for(int i=2;i<=10000;i++)
	{
		if(!vis[i])
			prime[++np]=i;
		for(int j=1;j<=np&&i*prime[j]<=10000;j++)
		{
			vis[i*prime[j]]=true;
			if(i%prime[j]==0)
				break;
		}
	}
}
long long ans[505][505];
long long gcd(long long x,long long y)
{
	if(y==0)
		return x;
	return gcd(y,x%y);
}
long long lcm(long long x,long long y)
{
	return x/gcd(x,y)*y;
}
int hx[4]={-1,1,0,0};
int hy[4]={0,0,-1,1};
int main()
{
	int n;
	findprime();
	scanf("%d",&n);
	if(n==2)
	{
		printf("4 7\n23 10");
		return 0;
	}
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=n+1;j++)
			ans[i][j]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if((i+j)%2==0)
				ans[i][j]=prime[(i+j)/2]*prime[(n-j+1+i)/2+n];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if((i+j)%2==1)
			{
				for(int k=0;k<4;k++)
					ans[i][j]=lcm(ans[i][j],ans[i+hx[k]][j+hy[k]]);
				ans[i][j]++;
			}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			printf("%lld ",ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 5120
use std::io::*;
use std::str::FromStr;

fn main() {
	let n: usize = read();
	let mut v = Vec::new();
	let mut p: i32;
	for _ in 0..n {
		p = read();
		v.push(p);
	}
	p = 0;
	v.sort();
	for i in &v {
		if p == *i {
			println!("NO");
			return ();
		}
		p = *i;
	}
	println!("YES");
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 4352
import numpy as np
N_1=list(map(int, input().split()))
N_2=list(map(int, input().split()))
N_3=list(map(int, input().split()))
N=int(input())
a=[int(input()) for i in range(N)]

n=np.array([N_1,N_2,N_3])

for a_n in a:
    if a_n in n:
        n[n==a_n]=0
    else:
        pass
i=0
    
if np.all(n[0:,0]==0)==True:
    i=+1
    
elif np.all(n[0:,1]==0)==True:
    i+=1
    
elif np.all(n[0:,2]==0)==True:
    i+=1
    
elif np.all(n[0,0:]==0)==True:
    i+=1
    
elif np.all(n[1,0:]==0)==True:
    i+=1

elif np.all(n[2,0:]==0)==True:
    i+=1

elif n[0,0]==0 and n[1,1]==0  and n[2,2] ==0:
    i+=1
    
elif n[0,2]==0 and n[1,1]==0 and n[2,0] ==0:
    i+=1
    
if i>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12472
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
int fact(int x,int k){
    if(k==0)return 1;
    else if(k==1)return x%mod;
    else if(k%2==0)return fact(x*x%mod,k/2);
    else return fact(x*x%mod,k/2)*x%mod;
}
signed main(){
    string s;cin>>s;
    int A=0,B=0,C=0;
    int cnt=0;
    rep(i,0,s.size()){
        if(s[i]=='A')A+=fact(3,cnt);
        else if(s[i]=='B')B+=A;
        else if(s[i]=='C')C+=B;
        else{
            C*=3;C%=mod;
            C+=B;C%=mod;
            B*=3;B%=mod;
            B+=A;B%=mod;
            A*=3;A%=mod;
            A+=fact(3,cnt);A%=mod;
            cnt++;
        }
        //cout<<A<<" "<<B<<" "<<C<<endl;
    }
    cout<<C%mod<<endl;return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long

using namespace std;

//ll ar[101010];

    int main()
    {
        int n;
       ll sum=0,ans=1e18,x=0;
        cin>>n;
        vector<long long>ar(n);
        for(int i=0;i<n;i++){
            cin>>ar[i];
            sum+=ar[i];
        }
        for(int i=0;i<n;i++){
            x+=ar[i];
           if(i+1<n) ans=min(ans,abs(sum-2*x));
        }
        cout<<ans<<endl;
    }




Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
	int n;
	int Fibo[50];
	Fibo[0] = 1;
	Fibo[1] = 1;

	cin >> n;
	for (int i = 2; i <= n; i++)
		Fibo[i] = Fibo[i - 1] + Fibo[i - 2];
	cout << Fibo[n] << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <cmath>
int sumD(int n);
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  string s,s1;
  int sum=0;
  cin>>s>>s1;
  int k=s.size();
  for(int i=0;i<k;i++)
  {
    if(s[i]!=s1[i])
        sum++;
  }
  cout<<sum;
}


Measured memory_bytes: 3884
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
using namespace std;

int ans[200005];

int main(){
	int n;
	scanf("%d",&n);
	int id1=n/2+1,id2=id1-1,id=0,m=n;
	if(n%2) id1=n/2+2,id2=id1-1,id=1; 
	while(m){
		int x;
		scanf("%d",&x);
		if(id%2) {
			ans[id2]=x;
			id2--;
		}
		else {
			ans[id1]=x;
			id1++;
		}
		id++;
		m--;
	}
	for(int i=1;i<=n;i++) {
		if(i-1) printf(" ");  
		printf("%d",ans[i]);
	} 
	printf("\n");
return 0;
}

Measured memory_bytes: 2944
"""
dp[i] : 足場iに到達するにあたって、たどり着く最小回数
"""
INF = 10**10
dp = [INF]*110000
N = int(input())
hs  = list(map(int, input().split())) + [INF,INF]
dp[0] = 0
for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i]+abs(hs[i+1]-hs[i]))
    dp[i+2] = min(dp[i+2], dp[i]+abs(hs[i+2]-hs[i]))
print(dp[N-1])



Measured memory_bytes: 14876
#include<stdio.h>
int n,a[111];
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	int res = 2147483647;
	for(int w = -100; w <= 100; w++){
		int now = 0;
		for(int i=1; i<=n; i++)
			now += (a[i]-w)*(a[i]-w);
		if(now<res)
			res=now;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 128
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, K;
  cin >> N >> K;
  vector<vector<lint>> A(N, vector<lint>(N));
  REP(i, N) REP(j, N) cin >> A[i][j];
  mcf_graph<lint, lint> g(N*2+2);
  g.add_edge(N*2, N*2+1, N*K, (lint)1e9);
  REP(i, N) g.add_edge(N*2, i, K, 0);
  REP(i, N) g.add_edge(N+i, N*2+1, K, 0);
  REP(i, N) REP(j, N) g.add_edge(i, N+j, 1, (lint)1e9-A[i][j]);
  auto flow = g.flow(N*2, N*2+1, N*K);
  cout << (N*K*(lint)1e9 - flow.second) << "\n";
  vector<string> ans(N);
  REP(i, N) REP(j, N) ans[i] += '.';
  auto edges = g.edges();
  REP(i, edges.size()) {
    if(edges[i].flow == 0 || edges[i].from == N*2 || edges[i].to == N*2 + 1) continue;
    ans[edges[i].from][edges[i].to-N] = 'X';
  }
  REP(i, N) cout << ans[i] << "\n";
}

Measured memory_bytes: 3936
a, b, c = sorted(list(map(int, input().split())))

def gain(x, y):
	if (y - x) % 2 == 0:
		return (y - x) // 2
	else:
		return (y - x) // 2 + 2

ans1 = b + c - (2 * a)
ans2 = gain(a, b) + c - b
ans3 = gain(a, c) + gain(b, c)

print(min(ans1, ans2, ans3))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){

	long long int n,a,b;
	cin>>n>>a>>b;
	long long int x=n/(a+b);
	long long int ans=x*a;
	x*=(a+b);
	if(x+a<=n){
	
		ans+=a;
	}
	else{
	
		ans+=a;
		x+=a;
		ans-=(x-n);
	}
	cout<<ans<<'\n';
	return 0;
}


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

int main()
{
  long n;
  cin >> n;
  n--;
  vector<int> a(20,0);
  int i, j;
  long k = 1;
  for(i = 0; i<20;++i){
    k *= (long)26;
    if(n < k){
      for(j = 0; j<=i;++j){
        a[j] = n % (long)26;
        n /= (long)26;
      }
      break;
    }else{
      n -= k;
    }
  }
  string name(i+1, 'a');
  for(j = 0; j<=i;++j){
    name[i-j] = 'a' + a[j];
  }
  cout << name << endl;
}


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

int main()
{
        int N;
        cin >> N;
        map<int,int> m;
        for (int i = 1; i < N; ++i) {
                int a;
                cin >> a;
                m[a-1]++;
        }
        for (int i = 0; i < N; ++i) {
                cout << m[i] << endl;
        }



}


Measured memory_bytes: 13020
s = input()
s = s[:-1]
if len(s) % 2 == 1:
    s = s[:-1]
for i in range(len(s) // 2):
    f = True
    for j in range(len(s) // 2):
        if s[j] != s[len(s) // 2 + j]:
            f = False
    if f:
        break
    s = s[:-2]

print(len(s))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int m, n;
	int i;
	int x;
	int count;
	
	while (1){
		scanf("%d %d", &m, &n);
		if (m == 0){
			break;
		}
		
		count = 0;
		
		for (i = m; i <= n; i++){
			x = i;
			
			while (x % 2 == 0){
				x /= 2;
			}
			
			while (x % 3 == 0){
				x /= 3;
			}
			
			while (x % 5 == 0){
				x /= 5;
			}
			
			if (x == 1){
				count++;
			}
		}
		
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void){
	int i, j, k, l, m, n;
	int d, w, low, high, ans, tmp;
	int e[10][10];

	while(1){
		scanf("%d%d", &d, &w);
		if(d == 0 && w == 0) break;
		for(i=0; i<d; i++){
			for(k=0; k<w; k++){
				scanf("%d", &e[i][k]);
			}
		}

		ans=0;
		for(i=0; i<d; i++){
			for(j=0; j<w; j++){
				for(k=0; k<d; k++){
					for(l=0; l<w; l++){
						low = 10;
						high = tmp = 0;
					
						for(m=i; m<=k; m++){
							for(n=j; n<=l; n++){
								if(m==i || m==k || n==j || n==l){
									if(e[m][n] < low) low = e[m][n];
								}
							}
						}
					
						for(m=i+1; m<k; m++){
							for(n=j+1; n<l; n++){
								if(e[m][n] > high) high = e[m][n];
								tmp += low - e[m][n];
							}
						}
						if(low > high && tmp > ans) ans = tmp;
					}
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2040
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(n):
    s = input()
    if(s == "AC"):
        AC += 1
    elif(s == "WA"):
        WA += 1
    elif(s == "TLE"):
        TLE  += 1
    else:
        RE += 1
print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))


Measured memory_bytes: 9124
n, k, q = map(int, input().split())
a = list(map(int, input().split()))

d = [a]
a = sorted(a)
ans = a[q - 1] - a[0]

while True:
    newd = list()
    li = list()
    for sub in d:
        for c in sub:
            if c != a[0]:
                li.append(c)
            else:
                newd.append(li)
                li = list()
        newd.append(li)
        li = list()

    d = list()
    a = list()
    for li in newd:
        if len(li) < k:
            continue
        else:
            d.append(li)
            li = sorted(li)
            a.extend(li[0:len(li) - k + 1])
 
    a.sort()

    if len(a) >= q:
        ans = min(a[q - 1] - a[0], ans)
    else:
        break
print(ans)

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

int main() {
  int n = 0;
  int n1000 = 0;
  int n100 = 0;
  int n10 = 0;
  int n1 = 0;
  int hoge = 0;
  
  cin >> n;
  hoge = n;
  n1000 = hoge / 1000;
  hoge = hoge % 1000;
  n100 = hoge / 100;
  hoge = hoge % 100;
  n10 = hoge / 10;
  hoge = hoge % 10;
  n1 = hoge / 1;
  hoge = hoge % 1;  

  if (n10 == n100) {
    if ((n10 == n1) || (n10 == n1000)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0);}



int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    map<int,int> cnt;
    while (n--)
    {
        int cur;
        cin >> cur;
        ++cnt[cur];
    }
    if (cnt.size() <= k)
        FINAL_OUT(0);
    vector<int> a;
    for(const auto& p : cnt)
        a.push_back(p.second);
        
    sort(a.begin(), a.end());
    n = cnt.size();
    int ans = 0;
    int i = 0;
    while (n > k)
    {
        ans += a[i++];
        --n;
    }
    cout << ans << endl;
}       

Measured memory_bytes: 10744
#include<stdio.h>

int main(){
  int i, j, k, n, v;
  int a[100];
  
  scanf("%d", &n);
  
    for( i = 0 ; i < n ; i++ ){
      scanf("%d", &a[i]);
    }
    
    for( i = 0 ; i < n ; i++ ){
      if(i > 0)
        printf(" ");
      printf("%d", a[i]);
    }
      printf("\n");
    
    for( i = 1 ; i < n ; i++ ){
      v = a[i];
      j = i - 1;
      
        while( j >= 0 && a[j] > v ){
          a[j + 1] = a[j];
          j--;
        }
       a[j + 1] = v;
     for( k = 0 ; k < n ; k++ ){
       if(k > 0)
         printf(" ");
       printf("%d", a[k]);
     }
      printf("\n");
     }
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

int N,a[310],S;
int f[2][90010];
int g[90010];
const int MOD = 998244353;

int main() {
	scanf("%d",&N);
	for (int i=1;i<=N;i++) {
		scanf("%d",&a[i]);
		S += a[i];
	}
	f[0][0] = 1;
	g[0] = 1;
	for (int i=1;i<=N;i++) {
		int now = i & 1, last = now ^ 1;
		for (int j=0;j<=S;j++) {
			f[now][j] = f[last][j] * 2 % MOD;
		}
		for (int j=a[i];j<=S;j++) {
			f[now][j] = (f[now][j] + f[last][j - a[i]]) % MOD;
		}
		for (int j=S;j>=a[i];j--) {
			g[j] = (g[j] + g[j - a[i]]) % MOD;
		}
		/*
		printf("%d:\n",i);
		for (int j=0;j<=S;j++) {
			printf("f[%d]=%d\n",j,f[now][j]);
		}
		*/
	}
	int ans = 0;
	for (int i=(S+1)/2;i<=S;i++) {
		ans = (ans + f[N & 1][i]) % MOD;
	}
	//printf("%d\n",g[S/2]);
	if (S % 2 == 0) {
		ans = (ans - g[S / 2] + MOD) % MOD;
	}
	int p3 = 1;
	for (int i=1;i<=N;i++) {
		p3 = p3 * 3LL % MOD;
	}
	ans = ((p3 - 3LL * ans) % MOD + MOD) % MOD;
	printf("%d\n",ans);
}

Measured memory_bytes: 1280
#include <iostream>

void swap(int *a, int *b);

int main(void)
{
int b[3]={0,0,0};
int i=0;
for(; i < 10; i++){
int s;
scanf("%d",&s);
if(b[2] < s){b[2]=s;}
if(b[1] < b[2]){swap(&b[1],&b[2]);}
if(b[0] < b[1]){swap(&b[0],&b[1]);}
}
std::cout << b[0] << std::endl << b[1] << std::endl << b[2] << std::endl;
return 0;
}

void swap(int *a, int *b){
int c=*a;
*a=*b;*b=c;
return;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll dp[2][2001][2];
ll fact[2001];
bool cf[2001];
ll mod = 924844033;

int main() {
	int n, k; cin >> n >> k;
	
	int cp = 1;
	REP(j, 2) {
		REP(i, k) {
			int now = i;
			cf[cp++] = false;
			now += k;
			
			while (now < n) {
				cf[cp++] = true;
				now += k;
			}
		}
	}
	
	dp[0][0][0] = 1;
	FOR(i, 1, 2 * n + 1) {
		int now = i & 1;
		int bef = !now;
		
		memset(dp[now], 0, sizeof(dp[now]));
		REP(j, n + 1) {
			if (cf[i]) {
				dp[now][j][0] += dp[bef][j][0] + dp[bef][j][1];
				if (j > 0) dp[now][j][1] += dp[bef][j - 1][0];
			}
			else {
				dp[now][j][0] += dp[bef][j][0] + dp[bef][j][1];
			}
			dp[now][j][0] %= mod; dp[now][j][1] %= mod;
		}
	}
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	
	ll ans = 0;
	REP(i, n + 1) {
		ll now = (dp[0][i][0] + dp[0][i][1]) % mod;
		now = now * fact[n - i] % mod;		
		ans += now * (i & 1 ? -1 : 1);
		ans = (ans + mod) % mod;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main()
{
    int N,a,b;
   scanf("%d",&N);
   if(10<=N&&N<=99)
   {
       a=N/10;
       b=N%10;
       if (a==9||b==9)
       {
           printf("Yes\n");
       }
       else
       {
        printf("No\n");
       }
   }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k, x, y;
    int ans = 0;
    cin >> n >> k >> x >> y;
    for (int i = 1; i <= n; i++)
    {
        if(i <= k){
            ans += x;
        }else{
            ans += y;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
ll h,w;
ll i,j,k;
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>h>>w;
  char s[h+2][w+2];
  rep(i,h)rep(j,w)cin>>s[i][j];
  ll dx[4] = {1,0,-1,0};
  ll dy[4] = {0,1,0,-1};
  bool ans = true;
  rep(i,h)rep(j,w){
    if(s[i][j]=='#'){
      ll cnt = 0;
      rep(k,4){
        ll dyy = i+dy[k];
        ll dxx = j+dx[k];
        if(dyy<h&&dyy>-1&&dxx<w&&dxx>-1){
          if(s[dyy][dxx]=='#') cnt++;
        }
      }
      if(cnt == 0) ans = false;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}
int main(){
  solve();
  return 0;
}


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

int main() { 
    long long A, B;
	cin >> A >> B;
	for(int i = 1; i <= B; i++) {
		if((A * i) % B == 0) {
			cout << A * i << endl; 
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int a[201000];
int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	int r = 1; long long ans = 0;
	int s = 0;
	for(int i = 1; i <= n; i++)
	{
		while(r <= n)
		{
			if((s & a[r]) == 0) s ^= a[r++];
			else break;
		}
		ans += r - i;
		s ^= a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
const int N=2e5+10;
char A[N],B[N];
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
char G[5]="DRUL";
int main()
{
	int h,w,n;scanf("%d%d%d",&h,&w,&n);
	int x,y;scanf("%d%d",&x,&y);x--,y--;
	int x0=x,y0=y;
	scanf(" %s %s",A,B);
	for(int i=0;i<4;i++){
		int j=0;x=x0,y=y0;
		for(j=0;j<n;j++){
			if(A[j]==G[i]){
				x+=dir[i][0],y+=dir[i][1];
				if(x<0||y<0||x>=h||y>=w)break;
			}
			if(B[j]==G[(i+2)%4]){
				x+=dir[(i+2)%4][0],y+=dir[(i+2)%4][1];
				if(x<0||y<0||x>=h||y>=w)x-=dir[(i+2)%4][0],y-=dir[(i+2)%4][1];
			}
		}//cout<<j<<"A\n";
		if(j!=n)return cout<<"NO\n",0;
	}cout<<"YES\n";
}



Measured memory_bytes: 640
#include<stdio.h>

#define MAX 200000

#define N -1

struct treeNode{
  int p;
  int l;
  int r;
};

struct treeNode T[MAX];

int doKansu(int);

void doKansu2(int);

int n,H,D[MAX];  
 
int main(){

  int i,j,d,v,c,l;
 
  scanf("%d",&n);
 
  for (i = 0;i < n;i ++)
    {
      T[i].p = T[i].l = T[i].r = N;
    }
 
  for (i = 0;i < n;i ++)
    {

      scanf("%d %d",&v,&d);
      
      for (j = 0;j < d;j ++)
	{
	  scanf("%d",&c);

	  if(j == 0)
	    {
	      T[v].l = c;
	      T[c].p = v;
	    }
	  else if(j == 1)
	    {
	      T[v].r = c;
	      T[c].p = v;
	    }
	  else T[c].p = v;
	}
    }
  
  for (i = 0;i < n;i ++)
    {
      D[i] = doKansu(i);
    }
  
  for(i = 0;i < n;i ++)
    {
      doKansu2(i);
    }
  
  return 0;
}

int doKansu(int u){

  int d = 0;
  
  while(T[u].p != -1)
    {
      u = T[u].p;
      d ++;
    }
  
  return d;
 
}
 
void doKansu2(int u){

  int i = 0;
  int count = 0;
  
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);
  
  if(T[u].p == -1)
    {
      printf("root, [");
    
      if(T[u].l != -1 )
	{
	  printf("%d",T[u].l);
	
	  if(T[u].r != -1) printf(", %d",T[u].r);

	  for (i = 0;i < n;i ++)
	    {
	      if(T[i].p==u && T[u].l != i && T[u].r != i)
		{
		  printf(", %d",i);
		}       
	    }
	}
      printf("]\n");
    }
   
  else{
    if(T[u].l != -1)
      {
	printf("internal node, [%d",T[u].l);    
	if(T[u].r != -1 )
	  {
	    printf(", %d",T[u].r);
	  
	    for (i = 0;i < n;i ++)
	      {
		if(T[i].p == u && T[u].l != i && T[u].r != i)
		  {
		    printf(", %d",i);
		  }
	      }
	  }
	printf("]\n");
      }
    else printf("leaf, []\n");
  }
}

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

const int inf = -1000;
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;
}
int main() {


   int a,b,c;
   cin>>a>>b>>c;
   
   cout<<min({a+b,a+c,b+c});
    return 0;

      }


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long res = 0;
  while (n--) {
    int v;
    cin >> v;
    res += v - (n + 1);
  }
  cout << res << '\n';
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int inf=0x3f3f3f3f;
int n,k;
int a[maxn];
bool check(int x)
{
	int sum=0;
	for(int i=1;i<=n;i++)
		sum+=(a[i]-1)/x+1-1;
	if(sum>k)
		return 0;
	else
		return 1;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>k;
	int maxv=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		maxv=max(a[i],maxv);
	}
	int l=1,r=maxv+1,mid,ans;
	while(l<r)
	{
		mid=(l+r)/2;
		if(check(mid))
		{
			r=mid;
			ans=mid;
		}
		else
			l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 4368
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
int main(){
	mp::cpp_int N;
	std::cin >> N;
	mp::cpp_int A = 1;
	for(mp::cpp_int i=0;i<N;i++){
		mp::cpp_int S;
		std::cin >> S;
		A *= S;
		if(A > 1000000000000000000 || A < 0){
			A = -1;
		}
	}
	std::cout << A << std::endl;
}


Measured memory_bytes: 3704
#include <stdio.h>


int main(){
	
	int a;
	
	scanf("%d",&a);
	
	if(a>=2800){
		printf("AGC\n");
	} else if(a>=1200){
		printf("ARC\n");
	} else {
		printf("ABC\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int N,M;
    vector<int> D;
    vector<int> T;
    int input;
    cin >> N;
    REP(i,N){
        cin >> input;
        D.push_back(input);
    }
    cin >> M;
    REP(i,M){
        cin >> input;
        T.push_back(input);
    }
    sort(D.begin(),D.end());
    sort(T.begin(),T.end());
    int index1 = 0;
    int index2 = 0;
    while(index1 < N && index2 < M){
        if(D[index1] > T[index2]){
            break;
        }
        if(D[index1] == T[index2]) index2++;
        index1++;
    }
    if(index2 == M) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 2548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp72 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(ulong.Parse).ToArray();

            ulong a = st[0];
            ulong b = st[1];
            ulong x = st[2];

            if (a == 0) {
                Console.WriteLine(b / x + 1);
            } else {
                Console.WriteLine(b / x - (a - 1) / x);
            }


            


        }
    }
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	map<int , int> mp;
	rep(i , 3){
		int x;
		cin >> x;
		++mp[x];
	}
	for(auto e : mp){
		if(e.se == 1)dier(e.fi);
	}

	return 0;
}

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

int main() {
    string A;
    cin >> A;
    int N = A.size();
    vector<int> cnt(26);
    for (int i = 0; i < N; i++) {
        cnt[A[i] - 'a']++;
    }

    long long res = (long long)N * (N - 1) / 2;

    for (int i = 0; i < 26; i++) {
        res -= (long long)cnt[i] * (cnt[i] - 1) / 2;
    }

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

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
  int a, b;

  scanf("%d %d", &a, &b);

  if (a < b) {
    printf("a < b\n");
  } else if(a > b) {
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }

  return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K,X;
ll A[100005];
ll ans;
ll total;
ll a;
string s;
 
 
int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        a;
        s;
        cin >> a >> s;
        if(s == "AC"){
            if(A[a-1]!=-1){
                ans += 1;
                total += A[a-1];
                A[a-1]=-1;
            }
        }else{
            if(A[a-1]!=-1){
                A[a-1]+= 1;
            }
        }
    }
    cout << ans << ' '<<total<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>
#define flush fflush(stdout)

const int INF = 1e8;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
	_

	int t = 1, n;

	//cin>>t;

	rep(nc, 0, t){
		cin>>n;
		vi x(n), y(n);

		rep(i, 0, n)
			cin>>x[i];

		rep(i, 0, n)
			cin>>y[i];

		int ans = 0;
		rep(i, 0, n)
			if(x[i] - y[i] > 0) ans += x[i] - y[i];

		cout<<ans; cn;
	}

	return 0;
}

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

int main() {
	char s[32];
	scanf("%s", s);

	for (int i = 0; i < 5; i++)
		printf("%c", s[i]);
	printf(" ");

	for (int i = 6; i < 13; i++)
		printf("%c", s[i]);
	printf(" ");

	for (int i = 14; i < 19; i++)
		printf("%c", s[i]);
	printf("\n");

}

Measured memory_bytes: 256
// ABC086_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N, M;
    cin >> N >> M;
//    vector<ll> vec(N);
//    REP(i, N) cin >> vec[i];
    
    // calculation
    if ((N*M)%2 == 1) {
        cout << "Odd" << "\n";
    } else {
        cout << "Even" << "\n";
    }
    
    return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  int N, t;
  cin >> N >> t;
  vector<P> A(N);
  rep(i, N) cin >> A[i].first >> A[i].second;

  vector<vector<ll>> dp1(N + 1, vector<ll>(t, 0));
  rep(i, N) {
    int a, b;
    a = A[i].first;
    b = A[i].second;
    rep(j, t - 1) {
      if (j - a < 0)
        dp1[i + 1][j] = dp1[i][j];
      else
        dp1[i + 1][j] = max(dp1[i][j], dp1[i][j - a] + b);
    }
  }

  vector<vector<ll>> dp2(N + 1, vector<ll>(t, 0));
  std::reverse(A.begin(), A.end());
  rep(i, N) {
    int a, b;
    a = A[i].first;
    b = A[i].second;
    rep(j, t - 1) {
      if (j - a < 0)
        dp2[i + 1][j] = dp2[i][j];
      else
        dp2[i + 1][j] = max(dp2[i][j], dp2[i][j - a] + b);
    }
  }
  std::reverse(A.begin(), A.end());
  std::reverse(dp2.begin(), dp2.end());

  ll ans = 0;
  rep(i, N) {
    ll mm = 0;
    rep(j, t) mm = max(mm, dp1[i][j] + dp2[i + 1][t - 1 - j]);
    ans = max(ans, mm + (ll)A[i].second);
  }
  std::cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 141184
function main(input){
              
    	const args = input.split(' ');
    	const x = parseInt(args[0],10);
      	const a = parseInt(args[1],10);
    	const b = parseInt(args[2],10);
      
    		if(b-a<=0){
    			console.log("delicious");
    			return;
    			}
    		else{
    			if(b-a < x+1){
              		console.log("safe");
    				}
      			else{
              		console.log("dangerous");
            		}
            }
    	}
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter

N,M = [int(x) for x in stdin.readline().rstrip().split()]
counter = 0
country = 1

ID = []

for i in range(M):
    p,y = [int(x) for x in stdin.readline().rstrip().split()]
    ID.append([p,y,i,"no"])
ID.sort(key=itemgetter(0,1))

for i in range(M):
    if ID[i][0] != country:
        counter = 0
    country = ID[i][0]
    counter += 1
    ID_m = format(ID[i][0],"06") + format(counter,"06")
    ID[i][3] = ID_m
    
ID.sort(key=itemgetter(2))

for i in range(M):
    print(ID[i][3])

Measured memory_bytes: 32408
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b;
	cin >>a >>b;
	cout <<max({(2 * a) - 1, (2 * b) - 1, a + b});
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

int main()
{
    int N;
    cin >> N;
    int m = 0;
    while(m < N){
        m += 1000;
    }
    cout << m - N << endl;
}


Measured memory_bytes: 3592