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

int main(){
    int N, M, X, Y, i, j, in, flag = 0, max, min;
    vector <int> x, y;

    cin >> N >> M >> X >> Y;

    for(i = 0; i < N; i++){
        cin >> in;
        x.push_back(in);
    }
    for(i = 0; i < M; i++){
        cin >> in;
        y.push_back(in);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if(X - x[N - 1] > 0){
        max = X;
    }else{
        max = x[N - 1];
    }
    if(y[0] - Y > 0){
        min = Y;
    }else{
        min = y[0];
    }
    if(Y - X > 1){
        flag++;
    }
    if(min - max > 0){
        flag++;
    }

    if(flag == 2){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
while not (H==0 and W==0):
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()
    H, W = map(int, input().split())



Measured memory_bytes: 7008
n, k = list(map(int, input().split(' ')))
an = list(map(int, input().split(' ')))

check = [-1] * n
i = 0
count = 0
while True:
    if check[i] != -1:
        lsize = count - check[i] 
        tail = count - lsize
        break
    check[i] = count
    count += 1
    i = an[i] - 1

l = k
if k > tail:
    l = ((k - tail) % lsize) + tail

for i in range(n):
    if check[i] == l:
        print(i + 1)
        break



Measured memory_bytes: 88872
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;


//   a/b mod c
ll moddiv(ll a,ll b){
	ll x0=MOD,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%MOD;
      if (x2==1){
        ans=(n2+MOD)%MOD;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%MOD)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1) ans=ans*aa%MOD;
    aa=aa*aa%MOD;
    beki/=2;
    if (beki==0)break;
  }
  return ans;
}







int main(){
  ll ans=0LL;
  cin >> n >> k;
  vi a(n),lnum(n),rnum(n);
  REP(i,n) cin>>a[i];
  REP(i,n){
    for(int j=0;j<n;j++){
      if (a[i]>a[j]){
        if (i<j){
          rnum[i]++;
        }
        if (i>j){
          lnum[i]++;
        }
      }
    }
  }


  ll k2=moddiv((k*(k-1))%MOD,2LL);
  if (k%2==0){
    k2=(k/2)*(k-1)%MOD;
  }else{
    k2=((k-1)/2)*k%MOD;
  }
  REP(i,n){
    ans+=((ll)rnum[i]*k)%MOD+((ll)lnum[i]+(ll)rnum[i])*k2%MOD;
    ans%=MOD;
    //lnum[i]
  }
/*
  //配列結果REP cout
  for (auto elem : rnum) {
    cout<<elem<<endl;
  }
  cout<<endl;
  for (auto elem : lnum) {
    cout<<elem<<endl;
  }
*/

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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  int n, l, h, h1, h2, x, y, z;
  char a[100];
  gets(a);
  n = strlen(a);
  l = 0;
  h = n - 1;
  h1 = ((n-1)/2) - 1;
  h2 = ((n+3)/2) - 1;
  
  while(h>l)
  {
      if(a[l++]!=a[h--])
      {
          x = 0;
          break;
      }
      if(l>=h)
      x = 1;
  }
  
  l = 0;
  while(h1>l)
  {
      if(a[l++]!=a[h1--])
      {
          y = 0;
          break;
      }
      if(l>=h1)
      y = 1;
  }
  
  h = n - 1;
  while(h>h2)
  {
      if(a[h2++]!=a[h--])
      {
          z = 0;
          break;
      }
      if(h2>=h)
      z = 1;
  }
  
  if(x==1 && y==1 && z==1)
  printf("Yes\n");
  else
  printf("No\n");
  
  return 0;
}

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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


int main(){
  int n; cin >> n;
  vector<int> v(n);
  for(auto&&e:v){
    cin >> e;
  }
  int ans = 0, cnt = 0;
  for(int i = 0; i < n - 1; ++i){
    if(v[i] >= v[i+1]){
      cnt++;
    } else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,a=0,b=0,c=0,ans=0,val=0;cin>>n;
  vector<ll> va(10,0),vb(10,0),vc(10,0),v_(10,0);
  string s,s_;cin>>s;
  rep(i,n-2) {
    a=s[i]-'0';
    if(va[a]!=0) continue;
    else {
      va[a]+=1; vb=v_;
      for(ll j=i+1;j<=n-2;++j) {
        b=s[j]-'0';
        if(vb[b]!=0) continue;
        else {
          vb[b]+=1; vc=v_;
          for(ll k=j+1;k<=n-1;++k) {
            c=s[k]-'0';
            if(vc[c]!=0) continue;
            else {vc[c]+=1;ans++;}
          }
        }
      }
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
ab = []

n1 = set()
nN = set()

for _ in range(M):
    a, b = map(int, input().split())
    if (a == 1) or (b == 1):
        n1.add(b if a == 1 else a)
    if (a == N) or (b == N):
        nN.add(b if a == N else a)

ans = 'IMPOSSIBLE'
if len(n1 & nN) > 0:
    ans = 'POSSIBLE'
print(ans)

Measured memory_bytes: 18936
N = int(input())
F = [[] for _ in range(N)]
for i in range(N):
    F[i] = list(map(int, input().split()))
P = [[] for _ in range(N)]
for i in range(N):
    P[i] = list(map(int, input().split()))

joisino = [False] * 10


def dfs(i):
    if i == 10:
        if joisino.count(True) == 0:
            return -float('inf')
        score = 0
        for j in range(N):
            G = [(joisino[k] and (F[j][k] == 1)) for k in range(10)]
            count = G.count(True)
            score += P[j][count]
        return score
    else:
        ans1 = dfs(i + 1)
        joisino[i] = True
        ans2 = dfs(i + 1)
        joisino[i] = False
        return max(ans1, ans2)


ans = max(-float('inf'), dfs(0))
print(ans)


Measured memory_bytes: 45660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt(),H=sc.nextInt(),N=sc.nextInt();
		int[] arrayx = new int[N];
		int[] arrayy = new int[N];
		int[] arraya = new int[N];
		int maxX=W,minX=0,maxY=H,minY=0;

		for(int i=0;i<N;i++) {
			arrayx[i] = sc.nextInt();
			arrayy[i] = sc.nextInt();
			arraya[i] = sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			if(arraya[i]==1 && arrayx[i]>=minX) {
				minX=arrayx[i];
			}else if(arraya[i]==2 && arrayx[i]<=maxX) {
				maxX=arrayx[i];
			}else if(arraya[i]==3 && arrayy[i]>=minY) {
				minY=arrayy[i];
			}else if(arraya[i]==4 && arrayy[i]<=maxY){
				maxY=arrayy[i];
			}
			//System.out.println(minX+" "+maxX+" "+minY+" "+maxY);
		}


		if((maxX-minX)>=0&&(maxY-minY)>=0) {
			System.out.println((maxX-minX)*(maxY-minY));
		}else {
			System.out.println(0);
		}


	}
	public static int sample(int n) {
		return n;
	}

}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h * 2);
  for (int i = 0; i < h * 2; i += 2) {
    cin >> a.at(i);
    a.at(i + 1) = a.at(i);
  }

  for (int i = 0; i < h * 2; i ++) {
    cout << a.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

constexpr ll INF = 1145141919810364364;

void chmax(ll &x, ll y) { x = max(x, y); }

int main() {
    int n;
    cin >> n;
    vector<pair<ll, int>> v(n);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        v[i] = {a, i};
    }
    sort(v.begin(), v.end(), greater<>());

    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, -INF));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int left = 0; left <= i; left++) {
            int right = i - left;
            chmax(dp[left + 1][right], dp[left][right] + abs(left - v[i].second) * v[i].first);
            chmax(dp[left][right + 1], dp[left][right] + abs(n - (right + 1) - v[i].second) * v[i].first);
        }
    }

    ll ret = 0;
    for (int i = 0; i <= n; i++)chmax(ret, dp[i][n - i]);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 34624
#include<bits/stdc++.h>
#define inf 999999999
using namespace std;
int n,m,p;
vector<int> rev[2510];
struct node{
	int u,v,c;
}edge[5010];
bool f[2510];
int dis[2510];
void dfs(int x)
{
	if(f[x]) return;
	f[x]=1;
	for(vector<int>::iterator it=rev[x].begin();it!=rev[x].end();it++) dfs(*it);
}
bool Bellman_Ford()
{
	for(int i=1;i<=n;i++) dis[i]=(i==1)? 0:inf;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	if(dis[edge[j].v]>dis[edge[j].u]+edge[j].c)
	dis[edge[j].v]=dis[edge[j].u]+edge[j].c;
	for(int i=1;i<=m;i++)
	if(dis[edge[i].v]>dis[edge[i].u]+edge[i].c&&f[edge[i].v]&&dis[edge[i].v]<=inf/2) return false;
	return true;
}
int main()
{
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=m;i++)
	{
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		edge[i].u=x,edge[i].v=y,edge[i].c=p-c;
		rev[y].push_back(x);
	}
	dfs(n);
	if(!Bellman_Ford()) cout<<-1<<endl;
	else cout<<max(-dis[n],0)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
  #define hell                         1000000007 
  #define M                            1000000007
  #define Maxi                      10000000000000000
      #define lcm(a,b)                     (a*b)/__gcd(a,b)
      #define ll                           long long

      #define vll                          vector<ll>
      #define vi                           vector<long long>
      #define pll                          vector< pair<ll,ll> >
      #define pb                           push_back
      //#define mp                           make_pair
      #define all(v)                       v.begin(),v.end()
      #define lbnd                         lower_bound
      #define ubnd                         upper_bound
      #define bs                           binary_search
      #define F                            first
      #define S                            second
      #define rep(i,a,b)                   for(i=a;i<b;i++)
      #define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
      #define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
      #define ret(x)                       return cout<<x,0;
      #define dbg(x)                       cout << #x << " is " << x << endl;
      //#define endl                           '\n'
   
   
      // Debug //
   
      #define trace(x)                 cerr << #x << ": " << x << endl;
      #define trace1(x)                cerr << #x << ": " << x << endl;
      #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
      #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
      #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
      #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
      #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


  using namespace std;



  int main()
  {

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);cout.tie(NULL);
      
      

        ll a,b,c;
        cin>>a>>b>>c;

        a-=b;
        cout<<max(c-a,0LL)<<endl;
    return 0;

        
    }



  //10773275
  //4306643

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int n,x[50],y[50];
bool v[50];

void dfs(int u,ll p,ll q){
    v[u]=true;
    for(int i=0;i<n;i++){
        if(!v[i]&&x[i]==x[u]+p&&y[i]==y[u]+q){
            dfs(i,p,q);
        }else if(!v[i]&&x[i]==x[u]-p&&y[i]==y[u]-q){
            dfs(i,p,q);
        }
    }
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    int ans=INF;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ll p=x[i]-x[j];
            ll q=y[i]-y[j];
            for(int k=0;k<n;k++){
                v[k]=false;
            }
            int tmp=0;
            for(int k=0;k<n;k++){
                if(!v[k]){
                    dfs(k,p,q);
                    tmp++;
                }
            }
            ans=min(tmp,ans);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b&&a>c)
		printf("%d",b*c/2);
	if(b>a&&b>c)
		printf("%d",a*c/2);
	if(c>a&&c>a)
		printf("%d",a*b/2);
	return 0;
} 

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


int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int sa=abs(a-b)-1;
  if(sa%2==0){
    cout << "Borys" << endl;
  }else{
    cout << "Alice" << endl;
  }
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const int INF = 1001001001;

 
int main(){
    int n, k;
    cin >> n >> k;
    int h[n];
    rep(i, n) cin >> h[i];
    // vec<vec<int>> dp(n, vec<int>(k));
    // dp[0][0] = 0;
    // rep(i, n) dp[i+1][0] = dp[i][0] + abs(h[i]-h[i+1]);
    // rep(i, n-2) rep(j, k) {
        
    // } 

    vec<int> dp(n);
    dp[0] = 0;
    rep(i, n-1) {
        dp[i+1] = dp[i] + abs(h[i+1]-h[i]);
        rep(j, k-1) {
            if (i-j-1<0) break;
            dp[i+1] = min(dp[i+1], dp[i-j-1] + abs(h[i-j-1] - h[i+1]) );
        }
        //cout << dp[i+1] << " ";
    }
    cout << dp[n-1] << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    ll m = 0;
    REP(i, N)
    {
        if (i + 1 != A[i])
            m++;
    }

    if (m <= 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
N, L = map(int, input().split())

taste = [0] * N
minimum = 10000
minAbs = 10000

for i in range(N) :
    taste[i] = L + i
    if abs(taste[i]) < minAbs :
        minimum = taste[i]
        minAbs = abs(taste[i])

print(sum(taste) - minimum)


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

int main(void){
	int N,M;
	cin >> N >> M;
	priority_queue <pair<int,int>>q;
	long long ans = 0;
	vector<int> A(N),B(M),C(M);
	for(int i=0;i<N;i++)cin >> A[i];
	for(int i=0;i<M;i++)cin >> B[i] >> C[i];
	for(int i=0;i<N;i++){
		q.push(make_pair(A[i],1));
	}
	for(int i=0;i<M;i++){
		q.push(make_pair(C[i],B[i]));
	}
	for(int i=0;i<N;i++){
		pair<int,int> p = q.top();
		q.pop();
		ans += p.first;
		if(p.second>1){
			p.second--;
			q.push(p);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int hp_taka, at_taka;
  int hp_aoki, at_aoki;
  cin >> hp_taka >> at_taka >> hp_aoki >> at_aoki;


  while(hp_taka > 0 || hp_aoki > 0){

    hp_aoki -= at_taka;

    if(hp_aoki <= 0){
      cout << "Yes" << endl;
      break;
    }

    hp_taka -= at_aoki;
    
    if(hp_taka <= 0){
      cout << "No" << endl;
      break;
    }

  }


  return 0;
}

Measured memory_bytes: 3544
#include<iostream>
using namespace std;
int main() {
	char a;
	int b[3];
	cin >> b[0]>>a>>b[1];
	while (a != '?') {
		if (a == '+')
			cout << b[0] + b[1] << endl;
		else if (a == '-')
			cout << b[0] - b[1] << endl;
		else if (a == '*')
			cout << b[0] * b[1] << endl;
		else if (a == '/')
			cout << b[0] / b[1] << endl;
		cin >> b[0] >> a >> b[1];
	}
	return 0;
}

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

const int SIZE = 100;
int Adj[SIZE][SIZE+3];
int d[SIZE];
int f[SIZE];
int t=0;

void DFS(int id){
    
    //t++;

    // タイムスタンプが押されている
    if (d[id-1] != 0){
        return;
    }

    d[id-1] = ++t;

    for(int i=2;Adj[id-1][i]!=0;i++){
        DFS(Adj[id-1][i]);
    }

    f[id-1] = ++t;
}

int main(){
    int n;
    cin >> n;
    
    // 初期化
    for(int i=0;i<SIZE;i++){
        d[i] = 0;
        f[i] = 0;
        for(int j=0;j<SIZE+3;j++){
            Adj[i][j] = 0;
        }
    }

    // 入力受付
    for(int i=0;i<n;i++){
        cin >> Adj[i][0] >> Adj[i][1];
        for(int j=0;j<Adj[i][1];j++){
            cin >> Adj[i][j+2];
        }
    }

    for(int i=1;i<=n;i++){
        if(d[i-1]!=0){
            continue;
        }
        DFS(i);
    }

    // 出力
    for(int i=0;i<n;i++){
        cout << i+1 << " " << d[i] << " " <<f[i] << endl;
    }
}


Measured memory_bytes: 3144
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    data=Tuple{Int,Int,Int}[(0,0,0) for i in 1:n+1]
    for i in 2:n+1
        t,x,y=parseMap(split(readline()))
        data[i]=(t,x,y)
    end
    ans="Yes"
    for i in 2:n+1
        dif_t=data[i][1]-data[i-1][1]
        dif_xy=abs(data[i][2]-data[i-1][2])+abs(data[i][3]-data[i-1][3])
        if dif_t<dif_xy
            ans="No"
            break
        elseif dif_t%2!=dif_xy%2
            ans="No"
            break
        end
    end
    println(ans)
end
main()

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

namespace ABC128
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Dictionary<string[], int> dic = new Dictionary<string[], int>();
            for (int i = 0; i < N; i++)
            {
                string[] a = Console.ReadLine().Split(' ');
                int number = 1000 - int.Parse(a[1]);
                string r = a[0];
                while (r.Length < 10)
                {
                    r = r + " ";
                }
                string n = r + number.ToString("D3");
                dic.Add(a, i + 1);
            }

            foreach(var v in dic.OrderByDescending(x=>int.Parse(x.Key[1])).OrderBy(x=>x.Key[0]))
            {
                Console.WriteLine(v.Value);
            }

        }

    }
}


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

int main() {
    int n;
    cin >> n;
    map<int, int> a;
    int d;
    for (int i = 0; i < n; i++) {
        cin >> d;
        a[d]++;
    }
    int m;
    cin >> m;
    map<int, int> b;
    int t;
    for (int i = 0; i < m; i++) {
        cin >> t;
        b[t]++;
    }
    for (const auto x : b) {
        if (a[x.first] < x.second) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

bool sec_do(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second > b.second;
  }
}

void sort_bags(vector<vector<int>>& x, const vector<pair<int, int>> w) {
  rep(i, x.size()) x[i].push_back(0);

  int idx = 0;
  x[idx].push_back(w[0].second);
  for (int i = 1; i < w.size(); i++) {
    if (w[i].first != w[i-1].first) idx++;
    x[idx].push_back(w[i].second);
  }

  rep(i, x.size()) {
    for (int j = 1; j < x[i].size(); j++) {
      x[i][j] += x[i][j-1];
    }
  }

}

ll get_ans(const vector<vector<int>> x, ll w1, ll W) {
  ll ans = 0LL;
  rep(i, x[0].size()) {
    rep(j, x[1].size()) {
      rep(k, x[2].size()) {
        rep(l, x[3].size()) {
          ll weight = i * w1 + j * (w1+1) + k * (w1+2) + l * (w1+3);
          if (weight > W) continue;
          ans = max(ans, (ll)x[0][i]+x[1][j]+x[2][k]+x[3][l]);
        }
      }
    }
  }

  return ans;
}

int main() {
  int N; ll W; cin >> N >> W;
  vector<pair<int, int>> w(N);
  rep(i, N) cin >> w[i].first >> w[i].second;

  sort(all(w), sec_do);

  vector<vector<int>> x(4);
  sort_bags(x, w);


  ll w1 = w[0].first;
  ll ans = get_ans(x, w1, W);

  cout << ans << endl;

  return 0;
}



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

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int n;  cin >> n;   vector<int> vec(n); map<int, long long int> mp;
    for(int i=0;n>i;i++){
        cin >> vec[i];  mp[vec[i]]++;
    }
    long long int ans=1;
    for(auto it=mp.begin();it!=mp.end();it++){
        ans+=((it->second)*((it->second)-1))/2;
    }
    for(int i=0;n>i;i++){
        cout << ans-mp[vec[i]] << "\n";
    }

}


Measured memory_bytes: 10368
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

g = []


def rec(i, s, N):
    # print(s)
    global g
    g.append(int(s))
    if len(s) > N:
        return

    if i - 1 >= 0:
        rec(i-1, s + str(i-1), N)
    rec(i, s + str(i), N)
    if i + 1 <= 9:
        rec(i+1, s + str(i+1), N)


def main():
    global g
    K = I()
    ans = []

    for i in range(1, 10):
        rec(i, str(i), 9)
    g = sorted(g)
    print(g[K-1])


if __name__ == '__main__':
    main()


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

int a[200000];
struct ac
{
    int b,c;
};
bool cmp(ac a,ac b)
{
    return a.c>b.c;
}
ac ace[200000];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>ace[i].b>>ace[i].c;
    }
    sort(a+1,a+1+n);
    sort(ace+1,ace+1+m,cmp);
    ll ans=0;
    int r=1;
    for(int i=1;i<=n;i++)
    {
        if(ace[r].c>a[i])
        {
            if(ace[r].b)
            {
                ans+=ace[r].c;
                ace[r].b--;
            }
        }
        else
            ans+=a[i];
        if(ace[r].b==0)
            r++;

    }
    cout<<ans<<'\n';







}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
ll fac[200005];
void init()
{
    fac[0]=fac[1]=1;
    for(int i=2;i<=200000;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
    return ;
}
ll pow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;
        }
        a=a*a%mod;
        n=n>>1;
    }
    return ans;
}
ll work(ll m,ll n)
{
    ll ans=fac[m+n-2];
    ans=ans*pow(fac[n-1],mod-2)%mod;
    ans=ans*pow(fac[m-1],mod-2)%mod;
    return ans;
}
int main()
{
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    init();
    ll pre=0,ans=0,k=w-b;
    for(int i=b+1;i<=w;i++,k++)
    {
        ll cnt=work(h-a,i);
        ll tmp=cnt*work(a,w-i+1)%mod;
        ans=(ans+tmp)%mod;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 1792
from sys import stdin
import heapq
n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
a = [-1 * x for x in a]
heapq.heapify(a)
for i in range(m):
    harf = heapq.heappop(a)
    harf = ((harf*(-1))//2)*(-1)
    heapq.heappush(a,harf)
print(sum(a)*(-1))

Measured memory_bytes: 69288
N = int(input())
book = []
for i in range(N):
    s,p = input().split()
    book.append([s, int(p)*-1])
book1 = sorted(book,key = lambda x:x[1])
book2 = sorted(book1, key = lambda x:x[0])

for i in range(N):
    print(book.index(book2[i])+1)

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

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	int count=0;
	int min_=std::numeric_limits<int>::max();
	for(int i=0;i<n;i++){
	    if(min_>a[i]){
	        min_=a[i];
	        count++;
	    }
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
using edge = pair<int,ll>;
vector<vector<edge> > tree;
vector<ll> dist;

void dfs(int v, int p, ll d) {
  dist[v] = d;
  for (auto e : tree[v]) {
    if(e.first == p) continue;
    dfs(e.first, v, d+e.second);
  }
}

int main(){
  int n;
  cin >> n;
  tree.resize(n);
  dist.resize(n,0);
  rep(i,n-1) {
    int a,b,c;
    cin >> a >> b >> c;
    --a;--b;
    tree[a].push_back({b,c});
    tree[b].push_back({a,c});
  }
  int q,k;
  cin >> q >> k;
  --k;

  dfs(k,-1,0);

  rep(i,q) {
    int x,y;
    cin >> x >> y;
    --x,--y;
    cout << dist[x] + dist[y] << endl;
  }
  
  return 0;
}

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

int main(){
	int N, W;
	int cnt[100];
	while(cin >> N >> W, N){
		for(int i = 0; i < 100; i++){
			cnt[i] = 0;
		}
		int mw = 0;
		for(int i = 0; i < N; i++){
			int v;
			cin >> v;
			cnt[v / W]++;
			mw = max(mw, v / W);
		}
		int mh = 0;
		for(int i = 0; i <= mw; i++){
			mh = max(cnt[i], mh);
		}
		double ans = 0.01;
		for(int i = 0; i < mw; i++){
			ans += (1.0 / mw * (mw - i)) * (1.0 / mh * cnt[i]);
		}
		printf("%.10lf\n", ans);
	}
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define GI int
#define UL unsigned int
#define ULL unsigned long long int
#define LI long int
#define LL long long
#define LF double
#define LLF long double
#define FOR(a,b,c) for(a=b;a<=c;a++)
#define rFOR(a,b,c) for(a=b;a>=c;a--)
#define pb push_back
#define mp make_pair
#define IOF ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main(){
	IOF
    GI x;
    cin>>x;
    if(x==0)cout<<1<<endl;
    else cout<<0<<endl;


return 0;
}

Measured memory_bytes: 3580
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const ll MOD = 800000011;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

int N; string S;
int b = 10009;
bool solve(int k) {
	vector<int>hs(N);
	int x = 0;
	REP(i, k) {
		x *= b;
		x += (S[i] - '0') % MOD;
		x %= MOD;
	}
	hs[0] = x;
	ll bk = bin_pow(b, k);
	FOR(i, 1, N - k+1) {
		hs[i] = mult(hs[i - 1] , b);
		hs[i] = sub(hs[i], mult(bk, (S[i-1] - '0')));
		hs[i] = add(hs[i], S[i+k-1] - '0');
	}
	REP(i, N - 2*k+1) {
		FOR(j, i + k, N - k+1) {
			if (hs[i] == hs[j]) {
				//pe(i)print(j);
				return true;
			}
		}
	}
	return false;
}
bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return true;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> S;

	ll ok = 0, ng = N / 2 + 1;
	while (abs(ng - ok) > 1) {
		int mid = (ok + ng) / 2;
		//pe("mid:")print(mid);
		if(solve(mid)){
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	print(ok);
	/*int x = 8e8;
	REP(i, 10000) {
		x += 1;
		if (prime(x)) {
			print(x);
			return 0;
		}
	}*/
}


Measured memory_bytes: 256
import math

n = int(input())

def foo(p1, p2):
    s_x = p1[0] + (p2[0] - p1[0]) / 3.0
    s_y = p1[1] + (p2[1] - p1[1]) / 3.0
    t_x = p1[0] + (2 * (p2[0] - p1[0])) / 3.0
    t_y = p1[1] +  (2 * (p2[1] - p1[1])) / 3.0
    u_x = math.cos(math.radians(60)) * (t_x - s_x) - math.sin(math.radians(60)) * (t_y - s_y) + s_x
    u_y = math.sin(math.radians(60)) * (t_x - s_x) + math.cos(math.radians(60)) * (t_y - s_y) + s_y

    return [[s_x, s_y], [u_x, u_y], [t_x, t_y]]

def bar(arr):
    result = []
    for i in range(len(arr) - 1):
        result.append(arr[i])
        result.extend(foo(arr[i], arr[i + 1]))
    result.append(arr[-1])
    return result

result = [[0, 0], [100.0, 0]]

for i in range(n):
    result = bar(result)

for ret in result:
    print("{} {}".format(ret[0], ret[1]))



Measured memory_bytes: 6284
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <iomanip>

using namespace std;

typedef complex<double> Point;
#define rep(i, n) for(int i=0; i<(n); ++i)
const double eps = 1e-8, inf = 1e8, pi = acos(-1.);

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

inline double cross(const Point& a, const Point& b){
    return imag(conj(a) * b);
}

inline double dot(const Point& a, const Point& b){
    return real(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if(cross(b, c) > eps)return 1;
    if(cross(b, c) < -eps)return -1;
    if(dot(b, c) < 0)return 2;
    if(norm(b) < norm(c))return -2;
    return 0;
}

struct Line : vector<Point> {
    Line(const Point& a, const Point& b){
        push_back(a); push_back(b);
    }
};

inline Point proj(const Line& l, const Point& p){
    double t = dot(p - l[0], l[1] - l[0]) / norm(l[0] - l[1]);
    return l[0] + (l[1] - l[0]) * t;
}

inline bool interSP(const Line& s, const Point& p){
    return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < eps;
}

inline bool interSS(const Line& s, const Line& t){
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
           ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

inline double distSP(const Line& s, const Point& p){
    const Point r = proj(s, p);
    return interSP(s, r)? abs(r - p): min(abs(s[0] - p), abs(s[1] - p));
}

inline double distSS(const Line& s, const Line& t){
    return interSS(s, t)? 0: min(min(distSP(s, t[0]), distSP(s, t[1])), min(distSP(t, s[0]), distSP(t, s[1])));
}

int N, M, L;

double solve(vector<vector<Line> >& pent){
    vector<vector<double> > dist(N, vector<double>(N));
    rep(i, N)rep(j, i){
        dist[i][j] = inf;
        for(auto s: pent[i])for(auto t: pent[j])chmin(dist[i][j], distSS(s, t));
        dist[j][i] = dist[i][j];
    }
    rep(k, N)rep(i, N)rep(j, N)chmin(dist[i][j], dist[i][k] + dist[k][j]);
    return dist[M][L];
}

int main(){
    while(cin >> N >> M >> L, N|M|L){
        M--; L--;
        vector<vector<Line> > pent(N);
        rep(i, N){
            int x, y, a, r;
            cin >> x >> y >> a >> r;
            vector<Point> v;
            rep(j, 5)v.push_back(Point(x, y) + polar(1. * r, (a + 72 * j + 90) * pi / 180));
            rep(j, 5)pent[i].emplace_back(v[j], v[(j + 2) % 5]);
        }
        cout << fixed << setprecision(20) << solve(pent) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1436
a=int(input())
b=input()
c=[]
d=[]
e=""
for i in range(len(b)):
  c.append(ord(b[i]))
for i in range(len(b)):
  d.append((int(c[i])+a-65)%26+65)
for i in range(len(b)):
  e=e+chr(d[i])
print(e)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1e9 + 7
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll h, w, H, W;
    cin >> h >> w;
    cin >> H >> W;
    cout << (h*w - (H*w + (W*h - W*H)));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>

//#define TEST

using namespace std;

int main(void) {
    int n;
    cin >> n;
    
    int r[n];
    for(int i=0; i<n; i++) {
        cin >> r[i];
    }

    int profit = r[1]-r[0];
    int r_min = r[0];
    
#ifdef TEST
    cout << "default : " << "r_min = " << r_min << " : " << "profit = " << profit << " : \n";
#endif
    
    for(int i=1; i<n; i++) {
        
        
#ifdef TEST
        cout << "i = " << i << " : ";
#endif
        
        if( profit < r[i]-r_min) {
            profit = r[i]-r_min;
            
#ifdef TEST
            cout << "profit = " << profit << " : ";
#endif
        }
        
        if( r_min > r[i] ) {
            r_min = r[i];
#ifdef TEST
            cout << "r_min = " << r_min << " : ";
#endif
        }
#ifdef TEST
        cout << endl;
#endif
    }

#ifdef TEST
    cout << "ans = ";
#endif
    cout << profit << endl;
    
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
 int n, m;

 cin >> n >> m;

  V<int> count(n, 0);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    count[a]++;
    count[b]++;
  }

  rep(i, n) {
    cout << count[i] << endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,m;
    cin >> n >> m;
    int dif = 0;
    vector<int>v(m);
    rep(i,m)cin >> v[i];
    if(m == 1){
        return cout << max(v.front() - 1 , n - v.front()) << endl, 0;
    }
    rep(i,v.size()){
        int a = v[i] - (i?v[i-1]:1);
        int b = (i+1 != v.size() ? v[i+1]:n)- v[i];
        if(i == 0)a=a*2;
        if(i+1 == v.size())b=b*2;
        cmax(dif,max((a/2),(b/2)));
      
    }
    cout << dif << endl;
}





Measured memory_bytes: 3152
import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int ac=0,wa=0,tle=0,re=0;
        for(int i=0;i<x;i++)
        {
            String str=sc.next();
            if(str.equals("AC"))
              ac++;
             else if(str.equals("WA"))
              wa++;
             else if(str.equals("TLE"))
              tle++;
             else if(str.equals("RE"))
              re++;
        }
        System.out.println("AC x "+ac);
        System.out.println("WA x "+wa);
        System.out.println("TLE x "+tle);
        System.out.println("RE x "+re);
     }
}

Measured memory_bytes: 58624
program bm
implicit none
integer::N
integer::K
integer::d
integer,allocatable,dimension(:)::A
logical,allocatable,dimension(:)::SUNUKE
integer::ans=0

integer::i,j
read*,N,K
allocate(SUNUKE(N))
SUNUKE=.true.
do i=1,K
    read*,d
    allocate(A(d))
    read*,A
    do j=1,d
        SUNUKE(A(j))=.false.
    end do
    deallocate(A)
end do
do i=1,N
    if(SUNUKE(i))ans=ans+1
end do
print"(I0)",ans
end program bm

Measured memory_bytes: 2932
#ABC132 B
n = int(input())
p = list(map(int, input().split()))
C = 0
for i in range(1, n - 1):
    L = [p[i - 1], p[i], p[i + 1]]
    L.sort()
    if p[i] == L[1]:
        C += 1
print(C)

Measured memory_bytes: 2940
#include <iostream>

int main(int argc, char **argv) {
  char hoge;
  for(int i = 0; i < 4; i++){
    std::cin.get(hoge);
    std::cout << hoge;
  }
  std::cout << " ";
  for(int i = 0; i < 8; i++){
    std::cin.get(hoge);
    std::cout << hoge;
  }
  std::cout << std::endl;
  return 0;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 3e2;
int n, m, mod, dp[nsz + 5][nsz + 5], suf[nsz + 5][nsz + 5], C[nsz + 5][nsz + 5];

void inline upd(int &a, const int b) {
    a += b;
    a >= mod && (a -= mod);
}

int main() {
    scanf("%d%d%d", &n, &m, &mod);
    circ (i, 0, n) {
        C[i][0] = 1;
        cont (j, i) {
            upd(C[i][j], C[i - 1][j] + C[i - 1][j - 1]);
        }
    }
    for (int i = m; i >= 0; --i) {
        dp[1][i] = 1;
        upd(suf[1][i], suf[1][i + 1] + dp[1][i]);
    }
    circ (i, 2, n + 1) {
        for (int k = m; k >= 0; --k) {
            cont (j, i - 1) {
                upd(dp[i][k], (num) dp[i - j][k] * suf[j][k + 1] % mod * C[i - 2][j - 1] % mod);
            }
            upd(suf[i][k], suf[i][k + 1] + dp[i][k]);
        }
    }
    printf("%d\n", dp[n + 1][0]);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll fpow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1LL)
			res = (res * x) % mod;
		y = y >> 1LL;
		x = (x * x) % mod;
	}
	return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second < b.second);}
bool fd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.first > b.first);}
bool sd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second > b.second);}
ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};
bool valid(ll x, ll y, ll n, ll m) {
	if (x < 0 || y < 0) {
		return false;
	}
	else if (x >= n || y >= m) {
		return false;
	}
	else
		return true;
}
#define MAXN 1000001
ll spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (ll i = 3; i * i < MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (ll j = i * i; j < MAXN; j += i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m, x;
	cin >> n >> m >> x;
	vector<pair<ll, vector<ll>>> v;
	for (int i = 0; i < n; i++) {
		pair<ll, vector<ll>> p;
		int x;
		cin >> x;
		p.first = x;
		vector<ll> vec;
		for (int j = 0; j < m; j++) {
			int c;
			cin >> c;
			vec.push_back(c);
		}
		p.second = vec;
		v.push_back(p);
	}
	int minimum_cost = INT_MAX;
	for (int i = 1; i <= pow(2, n); i++) {
		int cost = 0;
		vector<ll> val(m);
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				cost += v[j].first;
				for (int k = 0; k < m; k++)
					val[k] += v[j].second[k];
			}
		}
		bool flag = true;
		for (int k = 0; k < m; k++) {
			if (val[k] < x) {

				flag = 0;
				break;
			}
		}
		if (flag)
			minimum_cost = min(minimum_cost, cost);
	}
	if (minimum_cost != INT_MAX)
		cout << minimum_cost;
	else
		cout << -1;
	return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  map<char,int> mp;
  for(auto &i:s){
    mp[i]++;
    if(mp[i]>1){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}


Measured memory_bytes: 256
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

add_a=[]
for i in range(n-1):
    add_a.append(max(a[i]+a[i+1]-x,0))

ans=0
for i in range(n-1):
    ans+=min(add_a[i],a[i+1])
    if i!=n-2:
        add_a[i+1]=max(0,add_a[i+1]-min(add_a[i],a[i+1]))
    add_a[i]-=min(add_a[i],a[i+1])
ans+=add_a[0]

print(ans)

Measured memory_bytes: 20028
import java.util.*;

class Main
{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();
        
        int result = n / x;
        int judge = n % x;
        if (judge != 0) {
            result++;
        } 
        int answer = result * t;
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 35620
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n, a, b, c1=0, c2=0;
	long long int v,v1, vsum=0, vmax, ans=1;
	double ave;
	scanf("%d %d %d", &n, &a, &b);
	multiset<long long int> vs;
	for(int i=0; i<n; i++){
		scanf("%lld", &v);
		vs.insert(v);
	}
	auto itr=vs.end();
	for(int i=0; i<a; i++){
		itr--;
		v=*itr;
		if(i==0){
			vmax=v;
		}
		vsum=vsum+v;
	}
	ave=(double)vsum/(double)a;
	printf("%f\n", ave);
	if(v!=vmax){
		itr=vs.end();
		for(int i=0; i<n; i++){
			itr--;
			v1=*itr;
			if(v1>v){
				c1++;
			}
			if(v1==v){
				c2++;
			}
		}
		for(int j=1; j<=a-c1; j++){
			ans=ans*(c2+1-j)/j;
		}
		printf("%lld\n", ans);
	}else{
		itr=vs.end();
		for(int i=0; i<n; i++){
			itr--;
			v1=*itr;
			if(v1==vmax){
				c1++;
			}
		}
		ans=0;
		for(int i=a; i<=b && i<=c1; i++){
			long long int ans1=1;
			for(int j=1; j<=i; j++){
				ans1=ans1*(c1+1-j)/j;
			}
          
			ans=ans+ans1;
		}
		printf("%lld\n", ans);
	}
	return 0;
}


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

  if(x==a)
    cout<<"Balanced"<<endl;
  else if(a>x)
    cout<<"Left"<<endl;
  else
    cout<<"Right"<<endl;
  return(0);
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val d = sc.nextInt()
    val c = Array(26) { sc.nextInt() }
    val s = Array(d) { Array(26) { sc.nextInt() } }
    for (i in 0 until d) {
        val max = s[i].max()!!
        for (j in 0 until 26) {
            if (s[i][j] == max) {
                println(j + 1)
                break
            }
        }
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 39668