akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;

int main(void){
    ll H,N;
    cin >> H >> N;
    ll damage = 0;
    ll tmp;
    for(ll i = 0; i < N; i++){
        cin >> tmp;
        damage += tmp;
    }
    if(damage >= H){
        printf("Yes");
    }
    else{
        printf("No");
    }
    
}

Measured memory_bytes: 256
import sys
from collections import Counter

N = int(input())
d = list(map(int, input().split()))
M = int(input())
t = list(map(int, input().split()))

c = Counter(d)
for i in t:
    if c[i] > 0:
        c[i] -= 1
    else:
        print('NO')
        sys.exit()
print('YES')
    
    


Measured memory_bytes: 45004
N = int(input())
B = list(map(int, input().split()))
A = [0] * N

A[0] = B[0]
for i in range(N - 1):
    if B[i] >= A[i]:
        A[i + 1] = B[i]
    else:
        A[i] = B[i]
        A[i + 1] = B[i]

print(sum(A))

Measured memory_bytes: 3060
# 2019 6/16
# ABC130 Bounding


N, X = list(map(int, input().split()))

L = [0]
D = 0

L = L + list(map(int, input().split()))


count = 1

for i in range(1, N + 1):
    D += L[i]
    if D > X:
        break
    count += 1

print(count)

Measured memory_bytes: 3060
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    res = c
    for j in range(m):
        res += b[j]*a[i][j]
    if res > 0: ans += 1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int n,x;
  int i,j,k;
  int co;
  
  do{
    co = 0;
    scanf("%d%d",&n,&x);

    if(n == 0 && x == 0)
      break;
    else{
      for(i=1; i<=n; i++){
	for(j=1; j<=n; j++){
	  for(k=1; k<=n; k++){
	    if((i + j + k) == x){
	      if(i == j || j == k || k ==i)
		co = co;
	      else
		co++;
	    }
    	  }
	}
      }
    }

    printf("%d\n",co/6);

  }while(1);

  return(0);
}

Measured memory_bytes: 1028
n = int(input())
ans = []

for i in range(n):
    x, y = input().split()
    y = int(y)
    ans.append([x, y])

newans = ans.copy()

newans.sort(key = lambda x: (x[0], -x[1]))
for i in newans:
    print(ans.index(i)+1)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int l = Integer.parseInt(sa[2]);
		long[][] d = new long[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(d[i], 100000000000000L);
		}
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;
			int c = Integer.parseInt(sa[2]);
			if (c <= l) {
				d[a][b] = c;
				d[b][a] = c;
			}
		}
		int q = Integer.parseInt(br.readLine());
		int[] s = new int[q];
		int[] t = new int[q];
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			s[i] = Integer.parseInt(sa[0]) - 1;
			t[i] = Integer.parseInt(sa[1]) - 1;
		}
		br.close();

		int[][] ans = new int[n][n];
		long[][] ansd = new long[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(ans[i], 1000000000);
		}
		for (int i = 0; i < n; i++) {
			Set<Integer> set = new HashSet<>();
			for (int j = 0; j < n; j++) {
				set.add(j);
			}
			PriorityQueue<Node> que = new PriorityQueue<>();
			que.add(new Node(i, 0, 0));
			ans[i][i] = 0;
			while (!que.isEmpty() && !set.isEmpty()) {
				Node cur = que.poll();
				if (set.remove(cur.v)) {
					for (int j : set) {
						int alta = ans[i][cur.v];
						long c = d[cur.v][j];
						long altd = cur.d + c;
						if (altd >= 100000000000000L) {
							continue;
						}
						if (altd > l) {
							alta++;
							altd = c;
						}
						if (alta < ans[i][j]
								|| alta == ans[i][j] && altd < ansd[i][j]) {
							ans[i][j] = alta;
							ansd[i][j] = altd;
							Node next = new Node(j, alta, altd);
							que.add(next);
						}
					}
				}
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			int o = ans[s[i]][t[i]];
			if (o == 1000000000) {
				pw.println(-1);
			} else {
				pw.println(o);
			}
		}
		pw.flush();
	}

	static class Node implements Comparable<Node> {
		int v;
		int a;
		long d;

		public Node(int v, int a, long d) {
			this.v = v;
			this.a = a;
			this.d = d;
		}

		public int compareTo(Node o) {
			if (a != o.a) {
				return a - o.a;
			}
			return Long.compare(d, o.d);
		}
	}
}


Measured memory_bytes: 162512
#include<stdio.h>

int main (void)
{
        int a, b, c, s, m;
        scanf("%d%d%d",&a,&b,&c);
        m=0; s=0;

        m = b/a;
        if(m>c) s=c;
        else s=m;
        printf("%d\n",s);
        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int>
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF -1e16

#define nax 200005
bool isPrime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
bool isPowerOfTwo (unsigned int x) 
{ 
  return (!(x&(x-1))); 
}
vll prime;
signed main() {
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand (static_cast <unsigned> (time(0)));
	int t=1;
	//cin >> t;
	while (t--) 
	{
		int n,c,i;
		cin >> n;
		int a[n];
		rep(i,0,n)
		cin >> a[i];
		ll p=1000;
		    for(i=0;i<n-1;i++)
		    {
		        if (a[i]<a[i+1])
		        {
		            c=1000/a[i];
		            p=1000-a[i]*c;
		            i++;
		            //cout << c<< " "<< p << " "<<i<<endl;
		            break;
		        }
		        //cout << p <<endl;
		    }
		    for(;i<n-1;i++)
		    {
		        if (a[i]>a[i+1])
		        {
		            ll sell=c*a[i];
		            p+=sell;
		            //cout << c<<" "<<p<< " "<<i<<endl;
		            c=0;
		        }
		        else if (a[i]<a[i+1])
		        {
		            int cnt=p/a[i];
		            c+=cnt;
		            p-=a[i]*cnt;
		        }
		        //cout << p<<endl;
		        
		    }
		    p+=c*a[n-1];
		    cout <<p<<endl;
	}
	return 0;
}


Measured memory_bytes: 3656
import sys
# A,B,C = [int(n) for n in input().split()]
N,K = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())
bucket = [0]*(N+1)
A = [int(n) for n in input().split()]
dic = {}
for a in A:
    if not(a in dic):
        dic[a]=1
    else:
        dic[a]+=1
val = sorted(dic.values())
# print(val)
rc = len(val) - K
ans = 0
for r in range(rc):
    ans += val[r]
print(ans if ans >=0 else 0)


Measured memory_bytes: 35428
N = int(input())
a = list(map(int, input().split()))
colors = [0]*9
for ai in a:
  if ai >= 3200:
    colors[8] += 1
  else:
    colors[ai//400] = 1
    
cmin = max(1, sum(colors[0:8]))
cmax = sum(colors)

print(cmin, cmax)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define _USE_MATH_DEFINES

int main()
{
    int n=0,best_n=0;
    float T=0.0,A=0.0,height_i[1001]={0.0},temp_average=0.0,temp_diff_from_a=0.0,new_temp_diff_from_a=0.0;
    scanf("%d",&n);
    scanf("%f %f",&T,&A);
    for(int i=0;i<n;i++)
	scanf("%f",&height_i[i]);

    temp_average=T-height_i[0]*0.006;
    temp_diff_from_a=fabsf(A-temp_average);


    for(int i=1;i<n;i++){
	temp_average=T-height_i[i]*0.006;
	new_temp_diff_from_a=fabsf(A-temp_average);

	if(new_temp_diff_from_a<temp_diff_from_a){
	    temp_diff_from_a=new_temp_diff_from_a;
	    best_n=i;
	}

    }
    printf("%d",best_n+1);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int d, ans;
char t[200001];
int main() {
	scanf("%s", t);
	while (t[d] != NULL)d++;
	for (int i = 0; i < d; i++) {
		if (t[i] == '?')t[i] = 'D';
	}
	printf("%s\n", t);
}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
int main()
{
  set<int> mod;
  int k;
  cin>>k;
  int r=7%k;
  mod.insert(r);
  int ans=1;
  while(r!=0)
  {
    r=r*10+7;
    r%=k;
    ans++;
    if(mod.find(r)!=mod.end())
      break;
    mod.insert(r);
    
  }
  if(r==0)
    cout<<ans;
  else
    cout<<-1;
return 0;
}

Measured memory_bytes: 50416
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,M;
vector<int> G[100];

ll dfs(int u,int bit){
    if(bit==(1ll<<N)-1) return 1;
    ll res=0;
    for(auto v:G[u]){
        if((bit&(1<<v))==0){
            res+=dfs(v,bit^(1<<v));
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    cout1(dfs(0,1))
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  long long int n, k;
  cin >> n >> k;
  vector<pair<long long int, long long int>> ab(n);
  for (long long int i = 0; i < n; ++i) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab.begin(), ab.end());
  long long int sum = ab[0].second;
  for (long long int i = 0; i < n - 1; ++i) {
    if (sum >= k) {
      cout << ab[i].first << endl;
      return 0;
    }
    sum += ab[i+1].second;
  }
  cout << ab[n-1].first << endl;
  return 0;
}

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

int main() {
  string Ans = "No";  // 回答：1
  string S,T;
  cin >> S >> T;  // 入力文字列

  if( S.size()+1 == T.size()){
    if ( S == T.substr(0,S.size())){ Ans = "Yes";}
  }
  cout << Ans << endl;
}


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

const int INF = 2e9;

int main(){
    string s;
    cin >> s;
    int t = s.size();
    bool ok = true;
    rep(i,t){
        if(i%2 == 0){
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D')ok = false;
        }
        else {
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D')ok = false;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
S=input()
L=[0]*len(S)
for i in range(len(S)):
    L[i]=int(S[i])

mod=10**9+7    
    
N=len(S)
power=[1]*(N+3)
for i in range(1,N+3):
    power[i]=(power[i-1]*3)%mod

    

ans=1
for i in range(N):
    if L[N-1-i]==1:
        ans=(2*ans+power[i])%mod
print(ans%mod)

Measured memory_bytes: 42332
n = int(input())
a = 0
b = 0
for i in range(n):
	A,B = map(str,input().split())
	if A>B:
		a += 3
	elif B>A:
		b += 3
	else:
		a += 1
		b += 1
print('%d %d' % (a,b))


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int N;
int A[100010];


int main(){
    

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A, A + N);
    int k = A[N - 1];
    int min_v = 1000000001;
    int ans = -1;
    for(int i = 0; i < N - 1; i++){
        if(k % 2 == 0){
            if(abs(A[i] - k / 2) < min_v){
                min_v = abs(A[i] - k / 2);
                ans = i;
            }
        }
        else{
            if(abs(A[i] - k / 2) < min_v){
                min_v = abs(A[i] - k / 2);
                ans = i;
            }
            if(abs(A[i] - (k + 1) / 2) < min_v){
                min_v = abs(A[i] - (k + 1) / 2);
                ans = i;
            }
        }
    }
    cout << k << " " << A[ans] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {

  int n, w, d, p, s;

  while(1){
    cin>>n>>w>>d;
    if(n==0 && w==0 && d==0) break;

    vector< vector<int> > v;

    vector<int> a(3);
    a[0] = w*d;
    a[1] = w;
    a[2] = d;
    v.push_back(a);

    for(int i=0; i<n; i++){
      cin>>p>>s;
      int sd = s % (2*v[p-1][1] + 2*v[p-1][2]);
      vector<int> b1(3), b2(3);

      if(sd < v[p-1][1]){
        //cout<<"case1"<<endl;
        b1[0] = v[p-1][0] * sd / v[p-1][1];
        b2[0] =  v[p-1][0] - b1[0];
        b1[1] = sd; b2[1] = v[p-1][1] - b1[1];
        b1[2] = b2[2] = v[p-1][2];
      }else if(v[p-1][1] < sd && sd < v[p-1][1] + v[p-1][2]){
        //cout<<"case2"<<endl;
        b1[0] = v[p-1][0] * (sd - v[p-1][1]) / v[p-1][2];
        b2[0] =  v[p-1][0] - b1[0];
        b1[1] = b2[1] = v[p-1][1];
        b1[2] = sd - v[p-1][1]; b2[2] = v[p-1][2] - b1[2];
      }else if(v[p-1][1] + v[p-1][2] < sd && sd < 2*v[p-1][1] + v[p-1][2]){
        //cout<<"case3"<<endl;
        b1[0] = v[p-1][0] * (sd - (v[p-1][1] + v[p-1][2])) / v[p-1][1];
        b2[0] =  v[p-1][0] - b1[0];
        b1[1] = sd - (v[p-1][1] + v[p-1][2]); b2[1] = v[p-1][1] - b1[1];
        b1[2] = b2[2] = v[p-1][2];
      }else{
        //cout<<"case4"<<endl;
        b1[0] = v[p-1][0] * (sd - (2*v[p-1][1] + v[p-1][2])) / v[p-1][2];
        b2[0] =  v[p-1][0] - b1[0];
        b1[1] = b2[1] = v[p-1][1];
        b1[2] = sd - (2*v[p-1][1] + v[p-1][2]); b2[2] = v[p-1][2] - b1[2];
      }

      if(b1[0] < b2[0]){
        v.push_back(b1);
        v.push_back(b2);
      }else{
        v.push_back(b2);
        v.push_back(b1);
      }
      v.erase(v.begin() + (p - 1) );

    }

    sort(v.begin(), v.end());
    for(int i=0; i<(int)v.size(); i++){
      cout<<v[i][0];
      if(i != (int)v.size() - 1) cout<<" ";
    }
    cout<<endl;

  }

  return 0;
}

Measured memory_bytes: 3080
import javax.swing.plaf.multi.MultiButtonUI;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int r = sc.nextInt();
    int s = sc.nextInt();
    int p = sc.nextInt();
    String t = sc.next();
    int result = 0;
    Map<Character, Integer> scoreForAdversarial = new HashMap<>();
    scoreForAdversarial.put('r', p);
    scoreForAdversarial.put('s', r);
    scoreForAdversarial.put('p', s);
    for (int i = 0; i < k; i++) {
      int j = 0;
      while (i + k * j < n) {
        int count = 0;
        char initial = t.charAt(i + k * j);
        while (i + k * j < n && initial == t.charAt(i + k * j)) {
          count++;
          j++;
        }
        if (count % 2 == 0) {
          result += (count / 2) * scoreForAdversarial.get(initial);
        } else {
          result += ((count / 2) + 1) * scoreForAdversarial.get(initial);
        }
      }
    }
    System.out.println(result);
  }
}

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

int main() {
  string S;
  cin >> S;
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
  int64_t n, ans = (1LL << 62);
  cin >> n;
  for (int64_t i = 1; i * i <= n; i++)
  {
    if (n % i != 0)
      continue;
    ans = min(ans, i + (n / i) - 2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(int argc, const char *argv[])
{
  // 参加回数, 表示レーティング
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << "\n";
  } else {
    // r = internal - (100*10 - k)
    cout << r + 100* (10 - n) << "\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}
template <class T>
inline bool chmax(T &a, T b) //change max
{
        if (a < b)
        {
                a = b;
                return true;
        }
        return false;
}

typedef long long ll; //64bit型
using namespace std;

//無限大の値
const long long INF = 1LL << 60;

int main()
{
        int N, K;
        cin >> N >> K;
        vector<int> cost(100010);

        REP(i, N)
        {
                cin >> cost[i];
        }

        ll dp[100010];
        REP(i, N) { dp[i] = INF; }
        dp[0] = 0;

        FOR(i, 1, N)
        {
                FOR(j, 1, K + 1)
                {
                        if (i >= j)
                        {
                                chmin(dp[i], dp[i - j] + abs(cost[i] - cost[i - j]));
                        }
                }
        }
        cout << dp[N - 1] << endl;
        return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
// int s[525252];
int seq[252521];

// http://algoogle.hadrori.jp/algorithm/segment-tree.html

struct segtree {
  int N;
  vector<int> datmin, datmax, sum;
  segtree(int n, int *initial) {
    N = 1;
    while(N < n) N <<= 1;
    datmin.assign(2*N-1,0);
    datmax.assign(2*N-1,0);
    REP(i,n) datmin[i+N-1]=datmax[i+N-1]=initial[i];
    REP(_i,N-2){
      int i = N-2-_i;
      int lc = 2*i+1;
      int rc = 2*i+2;
      datmin[i] = min(datmin[lc],datmin[rc]);
      datmax[i] = max(datmax[lc],datmax[rc]);
    }
    sum.assign(2*N-1,0);
  }
  void add(int a, int b, int x) { add(a,b,x,0,0,N); }
  pii add(int a, int b, int x, int k, int l, int r) {
    if(b <= l or r <= a) return make_pair(datmin[k],datmax[k]);
    if(a <= l and r <= b) {
        sum[k] += x;
        return make_pair(datmin[k]+=x, datmax[k]+=x);
    }
    int m = (l+r)/2;
    pii left = add(a,b,x,2*k+1,l,m);
    pii right = add(a,b,x,2*k+2,m,r);
    return make_pair(
      datmin[k] = min(left.first, right.first)+sum[k],
      datmax[k] = max(left.second,right.second)+sum[k]
    );
  }
  int minquery(int a, int b) { return minquery(a,b,0,0,N); }
  int minquery(int a, int b, int k, int l, int r) {
    if(b <= l or r <= a) return 1e9;
    if(a <= l and r <= b) return datmin[k];
    int m = (l+r)/2;
    return min(minquery(a,b,2*k+1,l,m),minquery(a,b,2*k+2,m,r))+sum[k];
  }
  int maxquery(int a, int b) { return maxquery(a,b,0,0,N); }
  int maxquery(int a, int b, int k, int l, int r) {
    if(b <= l or r <= a) return -1e9;
    if(a <= l and r <= b) return datmax[k];
    int m = (l+r)/2;
    return max(maxquery(a,b,2*k+1,l,m),maxquery(a,b,2*k+2,m,r))+sum[k];
  }
  void debug(){
    REP(i,N){
      cout<<minquery(i,i+1)<<" ";
    }
    cout<<endl;
  }
};

int main(){
  scanf("%d",&n);
  int c = n/2;
  REP(i,c){
    int x;
    scanf("%d",&x);
    seq[c-1-i] -= x;
  }
  REP(i,c){
    int x;
    scanf("%d",&x);
    seq[i] += x;
  }
  segtree tr(c,seq);
  int __q;
  scanf("%d",&__q);
  while(__q--){
    int l,r,x;
    scanf("%d%d%d",&l,&r,&x);
    --l;--r;
    l -= c; r -= c;
    if(l<0 && r>=0){
      int a = -l-1;
      int b = r;
      if(a<b){
        l = a+1;
      }else{
        l = b+1;
        r = a;
        x = -x;
      }
    }else if(l<0 && r<0){
      swap(l,r);
      l = -l-1;
      r = -r-1;
      x = -x;
    }
    tr.add(l,r+1,x);
    int mn = tr.minquery(0,c);
    int mx = tr.maxquery(0,c);
    if(mn==0 && mx==0){
      puts("1");
    }else{
      puts("0");
    }
  }
  return 0;
}

Measured memory_bytes: 8128
import java.util.Scanner;

/**
 * @author yoshizaki
 * abc 129
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int step = scanner.nextInt();
        int ng = scanner.nextInt();
        long [] dp = new long[step];
        for(int i = 0; i < step; i++) dp[i] = 0;
        if (ng > 0) {
            int [] breaks = new int[step];
            for(int i = 0; i < ng ; i++) breaks[i] = scanner.nextInt();
            for(int i = 0; i < ng; i++) dp[breaks[i]-1] = -100000000000000000l;
        }
        
        if(step > 1) {
            if (dp[0] == 0 && dp[1] == 0) {
                dp[0] = 1;
                dp[1] = 2;
            } else if (dp[0] == 0) {
                dp[0] = 1;
            } else if (dp[1] == 0) {
                dp[1] = 1;
            }
            for(int i = 2; i < step; i++) {
                if (dp[i] < 0) continue;
                if (dp[i-1] > 0) dp[i] += dp[i-1];
                if (dp[i-2] > 0) dp[i] += dp[i-2];
                dp[i] %= 1000000007;
            }
        } else {
            dp[step - 1] = 1;
        }
        System.out.println(dp[step-1]);
    }
}

Measured memory_bytes: 50820
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n,t;
    scanf("%d%d",&n,&t);
    if(n*500>=t)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
void att(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
}
void sirra(){
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
}
void solve();
int main(){
	att();sirra();
	int q=1;//cin>>q;
	while(q--){
		solve();
	}
}
void solve(){
	ll n,y;int a[10009]={0};cin>>n;
	for(int i=1;i<100;i++){
		for(int j=1;j<100;j++){
			for(int k=1;k<100;k++){
				y=(i+j+k)*(i+j+k)+i*i+j*j+k*k;
				y=y/2;
				if(y>n)
					break;
				else
					a[y]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;
}

Measured memory_bytes: 3636
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(1,n-1):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        count+=1
    
    elif p[i-1]>p[i] and p[i]>p[i+1]:
        count+=1
    
    else:
        pass
print(count)

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

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

    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = INF;
    for (int i = 0; i + k <= n; i++)
        ans = min(ans, a[i + k - 1] - a[i]);
    cout << ans << endl;
}

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

int main(){

  long long i, N, Num1=10, Num2=18, Num3=8, md=1000000007, Ans;
  cin>>N;
  
  for(i=0; i<N-1; i++){
    Num1*=10;Num2*=9;Num3*=8;
    if(Num1>=md) Num1%=md;
    if(Num2>=md) Num2%=md;
    if(Num3>=md) Num3%=md;
  }
  Ans=Num1-Num2+Num3;
  if(Ans>=0){
    cout<<Ans%md<<endl;
  }else{
    cout<<Ans+md<<endl;
  }
  return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	long long n;
	cin >> n;
	vector<long long> a(n);
	vector<long long> b(n+1,0);
	for(long long i=0;i<n;i++)
	{
		cin >> a[i];
		b[a[i]]++;
	}

	long long all=0;
	for(long long i=0;i<n+1;i++)
	{
		all+=(b[i]*(b[i]-1)/2);
	}

	for(long long i=0;i<n;i++)
	{
		cout << all-(b[a[i]]*(b[a[i]]-1)/2)+((b[a[i]]-1)*(b[a[i]]-2)/2) << endl;
	}




}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  sum+=1000*(N/500);
  N%=500;
  sum+=5*(N/5);
  Out(sum);
}

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

int main() {
  int N,D,A;
  cin >>N>>D>>A;
 
 
  vector<vector<ll>> x(N,vector<ll>(2));
  rep(i,N) {
    rep(j,2){
      cin >> x.at(i).at(j);
    }
  }
  sort(x.begin(),x.end());
  vector<ll>y(N),z(N);
  rep(i,N){
    y.at(i)=x.at(i).at(0);
    z.at(i)=x.at(i).at(1);
  }
  ll ans=0;
  ll co=0;
  queue<P>q;
  rep(i,N){
    while(q.size()&&q.front().first<y.at(i)){
      co-=q.front().second;
      q.pop();
    }
    z.at(i)-=co;
    if(z.at(i)>0){
      ans+=(z.at(i)+A-1)/A;
      co+=((z.at(i)+A-1)/A)*A;
      q.push(P(y.at(i)+2*D,((z.at(i)+A-1)/A)*A));
    }
  }  
  cout<<ans<<endl;
  
}



Measured memory_bytes: 19032
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
  int A;
  
  cin >> A;

  if(A < 1200){
    printf("ABC\n");
  } else {
    printf("ARC\n");
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
 
int main() {
	int n;
	cin >> n;
	set<string> words;
	string rec[102];
	rep(i, n) {
		string w; cin >> w;
		words.insert(w);
		rec[i] = w;
	}
	bool ok = true;
	if (words.size() < n) ok = false;
	rep(i, n-1) {
		if (rec[i].back() != rec[i+1].front()) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

bool check(string s, int n) {
  for(int i  =0; i < n/2; i++) {
    if(s[i] != s[n-1-i]) return false;
  }
  return true;
}

int main() {
  string S; cin >> S;
  int N = S.size();
  bool ok = true;
  if(!check(S, N)) ok = false;
  string s1, s2;
  s1 = S.substr(0, (N-1)/2);
  if(!check(s1, s1.size())) ok = false;
  s2 = S.substr((N+3)/2-1);
  if(!check(s2, s2.size())) ok = false;
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine :: IO [Int]
  print $ solve n m

solve :: Int -> Int -> Int
solve a b = go a b
  where
    go x y
      | y == 0 = 1
      | y `mod` 2 == 0 = go (multMod x x) (y `div` 2)
      | otherwise = multMod x $ go x (y - 1)

multMod :: Int -> Int -> Int
multMod x y = (x * y) `mod` 1000000007

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define pb(a) push_back(a)

int substring(string t, string s) {
    int n=t.size(),m=s.size(),i,j;
    int ans = INT_MAX; 
    for(i=0;i<m-n+1;i++){
        int minRemoved=0;
        for(j=0;j<n;j++){
            if(t[j]!=s[i+j]){
                minRemoved++;
            }
        }
        ans=min(ans,minRemoved);
    }
    return ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n,t=1;
	//cin>>t;
	while(t--){
	  string s,t;
	  cin>>s>>t;
	  cout<<substring(t,s);
	}
	return 0;
}


Measured memory_bytes: 3620
//package Atcoder;

import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer;

public class Main{
	
	static class IO 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public IO() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	public static void main(String[] args) {
		IO fs = new IO();
		int n = fs.nextInt(),m = fs.nextInt();
		int ans = -1;
		for(int i = 1; i<=(int)Math.sqrt(m)+1; i++) {
			if(m%i == 0 && m/i>=n) {
				ans = Math.max(ans, i);
				if(i!=m/i && m/(m/i)>=n)ans = Math.max(ans, m/i);
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 25380
#include <iostream>
using namespace std;
int main(){
    int m,f,b;
    cin >> m >> f >> b;
    if(m >= b){
    cout << "0" << endl;
    }else{
    if(m + f >= b){
    cout << (b - m) << endl;
    }else{
    cout << "NA" << endl;    
    }
    }
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int n, m;
ll dp[1005][1 << 12];
int seen[1005][1 << 12];

struct Info {
  int a, b, c;
  int box[12];
} inp[1234];

ll go(int pos, int mask){
  if(mask == ((1 << n) - 1)){
    return 0;
  }
  if(pos >= m){
    return 1ll * 1e18;
  }
  if(seen[pos][mask] == 1){
    return dp[pos][mask];
  }
  ll ans = go(pos + 1, mask);
  if((mask | inp[pos].c) != mask){
    ans = min(ans, inp[pos].a + go(pos + 1, mask | inp[pos].c));
  }
  seen[pos][mask] = 1;
  return dp[pos][mask] = ans;
}

int main(){
  fastScan(n);
  fastScan(m);
  for(int i = 0; i < m; i++){
    fastScan(inp[i].a);
    fastScan(inp[i].b);
    inp[i].c = 0;
    for(int j = 0; j < inp[i].b; j++){
      fastScan(inp[i].box[j]);
      inp[i].box[j]--;
      inp[i].c = inp[i].c | (1 << inp[i].box[j]);
    }
    //cout << inp[i].c << '\n';
  }
  ll ans = go(0, 0);
  if(ans >= 1ll * 1e18){
    ans = -1;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 48128
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


S = sys.stdin.readline().rstrip()
if len(S) == len(set(list(S))):
    print('yes')
else:
    print('no')


Measured memory_bytes: 13648
inpl = lambda: list(map(int,input().split()))
N, Q = inpl()
S = input()

T = [0]*N
a_flag = False
ac_num = 0
for i in range(N):
    if S[i] == 'A':
        a_flag = True
    elif a_flag and S[i] == 'C':
        ac_num += 1
        a_flag = False
    else:
        a_flag = False
    T[i] = ac_num

for _ in range(Q):
    l, r = inpl()
    print(T[r-1]-T[l-1])

Measured memory_bytes: 6108
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 998244353;

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    cout << (b + x) / x - (a + x - 1) / x << endl;
}

Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val (n, m, k) = readLine()!!.split(' ').map { it.toInt() }
    val a = readLine()!!.split(' ').map { it.toLong() }
    var bSum = 0L
    val b = arrayOf(0L) + readLine()!!.split(' ').map {
        bSum += it.toLong()
        bSum
    }

    var answer = 0

    var aTime = 0L
    for (i in 0..n) {
        if (i > 0) {
            aTime += a[i-1]
        }
        if (aTime > k) break

        var ng = m+1
        var ok = 0
        while (Math.abs(ok-ng) > 1L) {
            val mid = (ok+ng)/2
            if (aTime + b[mid] <= k) {
                ok = mid
            } else {
                ng = mid
            }
        }
        answer = Math.max(answer, i + ok)
    }
    println(answer)
}


Measured memory_bytes: 88308
#include <iostream>
#include <vector>
#include <math.h>
#include<string>
using namespace std;

int main() {
	int n, ans = 0;
	cin >> n;
	string str;
	cin >> str;

	vector<int> a(n, 0);

	for (int i = 0; i < n; i++)
	{
		if (str[i] == 'W')
		{
			a[i] = 1;
		}
	}
	int i = 0, j = n - 1;
	while (i < n)
	{
		if (a[i] == 1)
		{
			while (j > i)
			{
				if (a[j] == 0)
				{
					swap(a[i], a[j]);
					ans++;
					break;
				}
				j--;
			}
		}
		i++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4452
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    string s;
    cin >> s;
    bool n = false;
    bool e = false;
    bool w = false;
    bool t = false;
    rep(i, s.size())if(s[i] == 'N')n = true;
    rep(i, s.size())if(s[i] == 'W')w = true;
    rep(i, s.size())if(s[i] == 'E')e = true;
    rep(i, s.size())if(s[i] == 'S')t = true;

    bool fl = true;
    if(n ^ t)fl = false;
    if(e ^ w)fl = false;
    puts(fl ? "Yes" : "No");

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,n;
    scanf("%d%d%d",&n,&a,&b);
    n+=1;
    int a1,b1;
    a1=n-a;
    b1=n-b;
    printf("%d\n",a1*b1);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int s; cin>>s;
  int a=s;
  vector<bool> check(10000,0);
  
  check[a]=true;
  bool flag=false;
  int ans=0;
  for(int i=2;flag==false;i++){
    if(a%2==0) a/=2;
    else a=3*a+1;

    if(check[a]==true){flag=true;ans=i;}
    else check[a]=true;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    ll m, n;
    cin >> m >> n;
    cout << mod_pow(m, n, MOD) << "\n";
    return 0;
}


Measured memory_bytes: 3104
N, K = map(int,input().split())
print(min(N%K,K-N%K))


'''
def DIF(N):
  global K
  return abs(N-K)

if N < DIF(N):
  print(N)
else:
  if N % K == 0:
    print(0)
  else:
    while N >= DIF(N):
      N = DIF(N)
    print(N)
'''

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
 
int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  
  if (a >= k) {
    a -= k;
  } else {
    b -= (k - a);
    a = 0;
  }
  
  if (b < 0) b = 0;

  cout << a << " " << b << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);


    long n;

    cin >> n;

    ll x[n];
    ll sorted[n];
    ll mid1, mid2;

    long i, len = n / 2 - 1;

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

        sorted[i] = x[i];
    }

    sort(sorted, sorted + n);

    mid1 = sorted[n / 2 - 1];
    mid2 = sorted[n / 2];

    rep(i, n) {
        if (x[i] < mid1) Out(mid2);
        else if (mid2 <= x[i]) Out(mid1);
        else Out(mid2);
    }

    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){

  int cnt = 1;
  rep(i,5){
    int x;
    cin >> x;
    if(x == 0){
      cout << cnt << endl;
      return 0;
    }

    cnt++;
  }
  return 0;
}


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

#define Bye return 0
#define ll long long

void solve(){
    string s, t; cin>>s>>t;

    int mini = INT_MAX;
    int s1 = s.size()-1, s2 = t.size()-1;
    for (int i=0; i<=(s1-s2); i++){
        int cont = 0;
        for (int j=0; j<=s2; j++) cont += (s[i+j]!=t[j]);
        mini = min(mini, cont);
    }
    cout<<mini<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3612
#include<iostream>

using namespace std;

int main()
{
  long long int n;
  cin>>n;
  char a[100];
  int k=0;
  while(n>0)
  {
    n=n-1;
    int b=n%26;
    a[k]=b+'a';
    k++;
    n=n/26;
  }
  for(int i=k-1;i>=0;i--)
    cout<<a[i];
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
// floor(log2(10 ** 12)) = 40
const int MAX_BIT = 45;
int64_t N, K;
int64_t ans = 0;
int64_t B[MAX_BIT][2];
int64_t M[MAX_BIT + 1];
// 貪欲法

int main() {
    cin >> N >> K;
    for (int i = 0; i < MAX_BIT; i++) {
        B[i][0] = B[i][1] = 0;
    }
    for (int i = 0; i < N; i++) {
        int64_t A;
        cin >> A;
        for (int j = 0; j < MAX_BIT; j++) {
            if ((A >> j) & 1)
                B[j][0]++;
            else
                B[j][1]++;
        }
    }
    M[0] = 0;
    for (int i = 0; i < MAX_BIT; i++) {
        M[i + 1] = (max(B[i][0], B[i][1]) << i) + M[i];
    }
    int64_t val = 0;
    for (int n = MAX_BIT - 1; n >= 0; n--) {
        int cur = (K >> n) & 1;
        val <<= 1;
        if (cur) {
            ans = max(ans, ((val + B[n][0]) << n) + M[n]);
        }
        val += B[n][cur];
    }
    ans = max(ans, val);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	int n,s=0,k;
	cin >> n;
	k = n;
	while (k > 9) {
		s += k % 10;
		k = k / 10;
	}
	s += k;
	if(n % s==0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return(0);
}


Measured memory_bytes: 256