akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  char *str; // stdin

  str = (char *)malloc(sizeof(char) * 7);
  scan = scanf("%s", str);
  if (str[2] == str[3])
  {
    if (str[4] == str[5])
    {
      printf("Yes");
      return (0);
    }
  }
  printf("No");
  return (0);
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>


//ð·_Ì¼O(®)Æ»Ìð·_©çLÑé¹Ì{ðÂ\¢Ìðé¾B
typedef struct{
	int name;
	int miti;
}Kousa;

int main(){
	int a,b,i;
	Kousa c[102];
	
	
	//ÅÌüÍ
	while(~scanf("%d%d",&a,&b)){
		if(a==0 && b==0)break;
		
		//\¢ÌzñÌú»
		memset(c,0,sizeof(c));
		
		
		//±±©ç\¢ÌzñÉãüµÄ¢­B
		c[0].miti++;
		c[0].name=a;
		for(i=0;;i++){
			if(c[i].name==b || c[i].name==0){
				c[i].name= c[i].name!=0 ? c[i].name:b;
				++c[i].miti;
				break;
			}
		}
		
		while(scanf("%d%d",&a,&b)){
			if(a==0 && b==0)break;
			
			//ó¢Ä¢é©¯¶¼O¾Á½çãüµÄA¹ðPÂ«·
			for(i=0;;i++){
				if(c[i].name==a || c[i].name==0){
					c[i].name=c[i].name!=0 ? c[i].name:a;
					++c[i].miti;
					break;
				}
			}
			for(i=0;;i++){
				if(c[i].name==b || c[i].name==0){
					c[i].name=c[i].name!=0 ? c[i].name:b;
					++c[i].miti;
					break;
				}
			}
			
		}

		a=0;//tOú»
		
		//X^[gÆS[ÓOÉ¹ªï{ÌÆ±ëª êÎtOð§ÄéB
		for(i=0;i<102;i++){
//			if(c[i].name!=0)printf("%d %d %d\n",i,c[i].name,c[i].miti);
			if(c[i].name!=1 && c[i].name!=2 && c[i].miti%2==1){
				a=1;
			}
			if(c[i].name==1 && c[i].miti%2==0){
				a=1;
			}
			if(c[i].name==2 && c[i].miti%2==0)a=1;
		}
		
		
		if(a==1){
			printf("NG\n");
		}else{
			printf("OK\n");
		}
	}
	return 0;
}

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

int main() {
    string S;  cin >> S;
    int N = stoi(S), fN = 0;
    for (char c : S) fN += stoi(c + ""s);
    if (N % fN == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3548
import java.util.Scanner;
public class Main{
    public static void Print(int a, int b, String str){
        if(b != str.length()-1)
            System.out.println(str.substring(a,b+1));
        else
            System.out.println(str.substring(a));
    }
    public static String Reverse(int a, int b, String str){
        char[] s1 = str.toCharArray();
	char s2[] = new char[b-a+1];
	for(int i = 0 ; i < b-a+1 ; i++)
		s2[i] = s1[a+i];
	for(int i = 0 ; i < b-a+1 ; i++)
		s1[a+i] = s2[b-a-i];
	String newstr = new String(s1);
	return newstr;
    }
    public static String Replace(int a, int b, String p, String str){
        char[] s1 = str.toCharArray();
	char[] s2 = p.toCharArray();
	for(int i = 0 ; i < s2.length ; i++)
		s1[a + i] = s2[i];
	String newstr = new String(s1);
	return newstr;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int q = sc.nextInt();
        for(int i = 0 ; i < q ; i++)
        {
            String order = sc.next();
            if(order.equals("print"))
            {
                int a = sc.nextInt();
                int b = sc.nextInt();
                Print(a,b,str);
            }
            else if(order.equals("reverse"))
            {
                int a = sc.nextInt();
                int b = sc.nextInt();
                str = Reverse(a,b,str);
            }
            else
            {
                int a = sc.nextInt();
                int b = sc.nextInt();
                String p = sc.next();
                str = Replace(a,b,p,str);
            }
        }
    }
}


Measured memory_bytes: 29612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll s,ans,dp[3001][3001],prefsum[3001];
const ll mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    for(int i=3;i<=s;i++)
        dp[1][i]=1;
    if(s>=3)
        ans=1;
    for(int i=2;i<=s;i++)
    {
        if(i*3>s)
            break;
        for(int suma=0;suma<=s;suma++)
            prefsum[suma]=0;
        for(int suma=(i-1)*3;suma<=s;suma++)
            prefsum[suma]=(prefsum[suma-1]+dp[i-1][suma])%mod;
        for(int suma=i*3;suma<=s;suma++)
        {
            ll valmax=suma-3;
            ll valmin=(i-1)*3;
            dp[i][suma]=prefsum[valmax]-prefsum[valmin-1];
            if(dp[i][suma]<0)
                dp[i][suma]+=mod;
            if(suma==s)
            {
                ans=(ans+dp[i][suma])%mod;
            }
        }
    }
    cout<<ans;
    return 0;
}


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

    int main(){
    int n;
    cin >> n;
    int card[n];
    for (int i=0;i<n;i++)cin >> card[i];
    stable_sort(card,card+n,greater<int>());
    int ans = 0;
    for (int i = 0;i<n;i++){
        if (i % 2 == 0) ans += card[i];
        else ans -= card[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n,m = list(map(int, input().split()))
    lnum = 0
    rnum = 100000
    for i in range(m):
        l,r = list(map(int, input().split()))
        lnum = max(lnum, l)
        rnum = min(rnum, r)
    
    result = rnum - lnum + 1
    if(result < 0):
        print(0)
    else:
        print(result)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, a, b) = [int(e) for e in lines[0].split(" ")]

    return (n, a, b)


def solve(n, a, b):

    c = n // (a + b)
    r = n % (a + b)

    d = min([r, a])
    
    result = c*a + d

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main(){
	int N;
	ll A,B;
	vector<ll>X;
	cin >> N >> A >> B;
	ll input;
	for(int i=0;i<N;i++){
		cin >> input;
		X.push_back(input);
	}
	
	ll answer=0;
	for(int i=0;i<N-1;i++){
		if((X[i+1]-X[i])*A > B){
			answer += B;
		}else{
			answer += (X[i+1]-X[i])*A;
		}
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#define N 2234
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
using namespace std;
inline void MIN(int &a, int b) {
	if (b < a)	a = b;
}
struct edge{
	int nxt, to;
}e[N << 1];
int head[N], ecnt;
inline void addedge(int from, int to) {
	e[++ecnt] = (edge){head[from], to};
	head[from] = ecnt;
}
int n;
char s[N];
int ans = 987654321, res;
int f[N], sum[N];
/*
int dfs(int cur, int faa, int nwd) {
	if (s[cur] == '1')	res += nwd;
	else	sum[cur] = 0;
	f[cur] = 0;
	int mx = 0, tot = 0;
	for (int i = head[cur]; i; i = e[i].nxt) {
		int to = e[i].to ;if (to == faa)	continue;
		int tmp = dfs(to, cur, nwd + 1);
		tmp += sum[to];
		MAX(mx, tmp);
		sum[cur] += sum[to];
		tot += tmp;
//		if (tmp >= f[cur])	f[cur] = tmp - f[cur];
//		else	f[cur] = f[cur] - tmp;
	}
	if (tot - mx >= mx)	f[cur] = sum[cur] & 1;
	else	f[cur] = sum[cur] - mx - mx;
	if (s[cur] == '1')	sum[cur]++;
	return f[cur];
}
*/
int siz[N];
void dfs(int cur, int faa, int nwd) {
	sum[cur] = siz[cur] = 0;
	int mx = 0, mxf = 0;
	for (int i = head[cur]; i; i = e[i].nxt) {
		int to = e[i].to; if (to == faa)	continue;
		dfs(to, cur, nwd + 1);
		sum[to] += siz[to];
		if (sum[to] > mx)	mx = sum[to], mxf = to;
		sum[cur] += sum[to];
		siz[cur] += siz[to];
	}
	if (sum[cur] - mx >= mx) {
		f[cur] = sum[cur] >> 1;
	} else {
		f[cur] = sum[cur] - mx + min(f[mxf], (mx - sum[cur] + mx) >> 1);
	}
//	if (cur == 1)	printf("mx = %d, sum = %d\n", mx, sum[cur]);
	if (s[cur] == '1')	res += nwd, ++siz[cur];
//	printf("sum[%d] = %d, siz[%d] = %d\n", cur, sum[cur] ,cur, siz[cur]);
}

inline void work(int rt) {
//	printf("work(%d)\n", rt);
	res = 0;
	dfs(rt, 0, 0);
	if (f[rt] * 2 == res) MIN(ans, res / 2);//, printf("rt = %d\n", rt);
}
int main() {
	read(n);
	scanf("%s",s + 1);
	for (int i = 1; i < n; ++i) {
		int u, v; read(u), read(v);
		addedge(u, v), addedge(v, u);
	}
	for (int i = 1; i <= n; ++i)	work(i);
	if (ans == 987654321)	puts("-1");
	else	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3344
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val Ks = Array.fill(N)(in.nextInt)

  val (sum, _) = Ks.foldLeft((0, 0)){case ((sum, pre), h) => if (pre < h) (sum + (h - pre), h) else (sum, h)}
  println(sum)
}

Measured memory_bytes: 27456
import sys
range = xrange
input = raw_input

n = int(input())
S = [input() for _ in range(n)]

BA = []
BX = []
XX = []
XA = []
for s in S:
    if s[0] == 'B':
        if s[-1] == 'A':
            BA.append(s)
        else:
            BX.append(s)
    elif s[-1] == 'A':
        XA.append(s)
    else:
        XX.append(s)

picker = []
ends_with_A = False
while BA or BX or XX or XA:
    if not ends_with_A:
        X = XA or BA or XX or BX
    else:
        X = BA or BX or XX or XA
    picker.append(X.pop())
    if picker[-1][-1] == 'A':
        ends_with_A = True
    else:
        ends_with_A = False
print ''.join(picker).count('AB')

Measured memory_bytes: 33900
/*
─────────▄▄▄▄▄▄▄▄▄▄▄▄─────────
─────▄▄▀▀░░░░░░░░░░░░▀▀▄▄─────
───▄▀░░░░░░░░░░░░░░░░░░░░▀▄───
──█░░░░░▄▄▄▄▄░░░░▄▄▄▄▄░░░░░█──
─█░░░░░██░█░██▄▄██░█░██░░░░░█─
█░░░░░░░▀▀▀▀▀░░░░▀▀▀▀▀░░░░░░░█
█░░░░▄▄▄░░░░░░░░░░░░░░▄▄▄░░░░█
█░░░░██▀█▄▄▄▄▄▄▄▄▄▄▄▄██▀█░░░░█
─█░░░▀██▄████████▄▄▄▄██▄▀░░░█─
──█░░░░▀██▀▀▀▀████████▀░░░░█──
───▀▄░░░░▀▄▄▄▄██████▀░░░░▄▀───
─────▀▀▄▄░░░░░░░░░░░░▄▄▀▀─────
─────────▀▀▀▀▀▀▀▀▀▀▀▀─────────
*/
#include <bits/stdc++.h>

using namespace std;

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

	int n;
	cin >> n;
	vector<double> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for (int i = 1; i < n; ++i) {
		v[i] = (v[i] + v[i - 1]) / 2;
	}
	cout << v.back();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define loop(i,a,b) for(int i=a; i<b; i++)
#define INF 10000000000099ll
#define mod 1000000007
#define MAX 3000
int dp[MAX+1][MAX+1];

string printLcs(string s, string t, int n, int m){
    int i= n, j=m;
    string res="";
    while(i>0 && j>0){
        if(s[i]==t[j]){
            res.push_back(s[i]);
            i--;j--;
        }
        else{
            if(dp[i][j-1] > dp[i-1][j])
                j--;
            else
                i--;
        }
    }
    reverse(res.begin(), res.end());
    return res;
}

void solve(string s, string t, int n, int m)
{
    for(int i=1; i<n; i++){
        for(int j=1; j<m; j++){
            if(s[i]==t[j]) dp[i][j]= 1+ dp[i-1][j-1];
            else {
                dp[i][j]= max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
}

int main()
{
    FASTIO;
    string s, t;
    cin>>s>>t;
    s=" "+ s;
    t=" "+ t;
    int n= s.length();
    int m= t.length();
    memset(dp, 0, sizeof dp);
    solve(s, t, n, m);
    cout<<printLcs(s, t, n-1, m-1);
    return 0;
}




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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int b = n - 1;
  int c = k - 1;
  cout << (b + c - 1) / c << endl;
}


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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COUT(x) cout << x << endl
//#define int long long

template<typename T> constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	int A, B;
	cin >> A >> B;

	VI cal(3);
	cal[0] = A + B;
	cal[1] = A - B;
	cal[2] = A * B;

	int max = -INF;

	for (auto& c : cal) {
		if (c > max) max = c;
	}

	COUT(max);

	return 0;
}


Measured memory_bytes: 256
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2], reverse=True)
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h != max(_H - abs(cx - x) - abs(cy - y), 0):
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  int ans = 0;
  for (int i = 1; i < s.size(); i++) {
    if (s[i-1] == s[i]) {
      s[i] = s[i-1] == '0' ? '1' : '0';
      ans++;
    }
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),K = in();
    vector<int> x(N);
    REP(i,N)x[i] = in();
    int answer = 0;
    REP(i,N){
        answer += min(abs(x[i]),abs(x[i] - K));
    }
    cout << answer * 2<< "\n";
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
s = 0
for i in range(N):
    j = N-1-i
    b = B[j]
    if b < A[j+1]:
        s += b
        A[j+1] -= b
    elif b < A[j]+A[j+1]:
        s += b
        A[j] = A[j] -(b-A[j+1])
        A[j+1] = 0
    else:
        s += A[j]+A[j+1]
        A[j] = 0
print(s)

Measured memory_bytes: 18476
N = int(input())
*W, = map(int, input().split())
s1, s2 = 0, sum(W)
ans = sum(W)
for i in range(N):
	s1 += W[i]
	s2 -= W[i]
	ans = min(ans, abs(s1 - s2))
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
	int sort[101] = {0};
	int n, i;
	scanf("%d", &n);

	int ans = 0;
	for(i=0;i<n;i++)
	{
		int k;
		scanf("%d", &k);
		sort[k]++;
		if(sort[k]==1)
			ans++;
	}

	printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

main()
{
	ll n,d;
	cin>>n>>d;
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		if(sqrt(x*x + y*y) <= d)
			ans++;	
	}	
	
	cout<<ans<<endl;

}

Measured memory_bytes: 3672
#標準入力をし0だった場合はループを抜ける
while True:
    num = int(input())
    if num == 0:break
    else:
        num1 = int(input())
        kei = 0
        
        #勉強時間の合計を計算する
        for _ in range(num1):
            a,b = map(int,input().split())
            kei += b - a
            
        #勉強時間が足りてたら"OK"足りてなかったら足りない時間を出力する
        if num <= kei:print("OK")
        else:print(num - kei)


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

int main() {
    int n;
    cin >> n;
    long long  a[n + 1];
    long step= 0;
    for (int i= 1; i<= n;i++) cin >> a[i];
    long long before= 0;
    for (int i= 1; i<= n;i++) {
        if (before > a[i]) {
            int diff= before - a[i];
            step+= diff;
        }
        else before= a[i];
    }
    cout << step << endl;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

    LL n; cin >> n;
    VLL a(n); REP(i,n) cin >> a[i];
    VLL v(n,0);

    LL counter = 0, counter2 = 0;
    REP(i,n) {
        if (a[i]%4==0) counter++;
        else if ((a[i]%4!=0)&&(a[i]%2==0)) counter2++;
    }
    counter2 = counter2/2;

    LL needs = 0;
    if (n%2==1) needs = (n-1)/2;
    else needs = (n/2);

    if (needs<=(counter+counter2)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define optimizar_io cin.tie(0); ios_base::sync_with_stdio(0);
#define endl '\n'
typedef long long ll;
using namespace std;
map<char,int> mapa;
int dirs[4];
string s;
int main(){
    optimizar_io;
    cin >> s;
    for(int i = 0; i<s.size(); i++){
        mapa[toupper(s[i])]++;
    }
    bool ans = true;
    if(mapa['N'] > 0 && mapa['S'] == 0 || mapa['S'] > 0 && mapa['N'] == 0){
        ans = false;
    }
     if(mapa['E'] > 0 && mapa['W'] == 0 || mapa['W'] > 0 && mapa['E'] == 0){
        ans = false;
    }
    if(ans){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int n;
	int loan;

	cin >> n;
	loan;

	loan = 100000;

	for(int i=0; i<n; i++){
		loan = loan+loan*0.05;
		loan = loan+999;
		loan = loan/1000*1000;
	}

	cout << loan << endl;
	
	return 0;
}

Measured memory_bytes: 0
q, h, s, d = map(int, input().split())
n = int(input())
h = min(q*2, h)
s = min(h*2, s)
if 2*s <= d:
  print(s*n)
else:
  if n%2==0:
    print(d*(n//2))
  else:
    print(d*(n//2)+s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

ll digit_sum(ll n)
{
    ll res = 0LL;
    while (n)
    {
        res += n % 10LL;
        n /= 10LL;
    }
    return res;
}

ll next_snuke(ll n)
{
    ll now = n;
    ll base = 1;
    ll smallest = n;
    double small = (double) smallest / digit_sum(smallest);
    while(now < 100L * n)
    {
        ll check = (now / base) % 10L;
        if (check != 9)
        {
            // cout << "*" << now << ' ' << check << ' ' << base << ' ' << (double)(now+base) / digit_sum(now + base) << endl;
            now += base;
            double d_now = (double)now / digit_sum(now);
            if (small > d_now)
            {
                smallest = now;
                small = d_now;
            }
            if (check == 8) base *= 10L;
        }
        else
            base *= 10L;
    }
    return smallest;
}

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

    ll snuke = 0LL;
    while (k)
    {
        snuke = next_snuke(snuke + 1LL);
        cout << snuke << endl;
        --k;
    }
    // cout << next_snuke(6999999999999999LL + 1LL) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 10000000009

int main() {
    FAST_IO
    string s;
    char c[10];
    ll i,j;
    cin>>s;
    s.replace(s.begin(),s.begin()+4,"2018");
    cout<<s<<endl;
return 0;
}


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

using ll = long long;

const int N = 300;

int n, a[N][N];
ll r;

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) scanf("%d", a[i] + j);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < i; j++){
            r += a[i][j];
            for(int k = 0; k < n; k++){
                if(i == k || j == k) continue;
                if(a[i][j] > a[i][k] + a[k][j]){ puts("-1"); return 0; }
                if(a[i][j] == a[i][k] + a[k][j]){ r -= a[i][j]; break; }
            }
        }
    }
    printf("%lld\n", r);
}

Measured memory_bytes: 640
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

/** Problem0070 : Combination of Number Sequences **/
int tb[11][331];
int use[10];

void dfs(int d, int sum)
{
	tb[d-1][sum]++;
	rep(i, 10) {
		if (use[i]==0) {
			use[i]=1;
			dfs(d+1, sum+i*d);
			use[i]=0;
		}
	}
}

int main()
{
	int n, s;
	dfs(1, 0);
	while (cin>>n>>s) {
		if (s>330) {
			cout << 0 << endl;
		} else {
			cout << tb[n][s] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1172
import itertools

l, r = map(int, input().split())
l_rest = l % 2019
r_rest = r % 2019

if l_rest == 0 or r_rest == 0:
    print(0)
elif r-l < 2019:
    lr_list = list(range(l_rest, r_rest+1))
    lr_comb = list(itertools.combinations(lr_list, 2))
    min_rest = 2018
    for comb in lr_comb:
        rest = comb[0] * comb[1]
        min_rest = min(min_rest, rest%2019)
    print(min_rest)
elif r-l >= 2019:
    print(0)

Measured memory_bytes: 148280
#include<bits/stdc++.h>
using namespace std;
template<typename tn> void read(tn &a){
    tn x=0,f=1;char c=' ';
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
    a=x*f;
}
int a;
int main(){
	read(a);
	int b=(a>>1)+((a&1)?1:0);
	double ans=1.0*b/a;
	printf("%.10lf\n",ans); 
	return 0;
} 

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

long long n;
long long solve()
{
    long long dem=0;
    while (n>=500)
    {
        n-=500;
        dem+=1000;
    }
    while (n>=5)
    {
        n-=5;
        dem+=5;
    }
    return dem;
}
int main()
{
    cin >> n;
    long long ans=solve();
    cout << ans;
}


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

int main() {
  int n; cin >> n;
  vector<char> s(n);
  rep(i,n) cin >> s[i];
  
  int ans=0, sum=0;
  for(int i=0; i<n-1; ++i) {
    if (s.at(i) == s.at(i+1)) {
      sum++;
    }
  }
  ans = n - sum;
  cout << ans << endl;
  return 0;
}
 
  

Measured memory_bytes: 384
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#include <ios>
#include <iomanip>
#include <map> // pair
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
 
int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int A[N+1];
  int B[N];
  for(int i = 0; i < N+1; i++){
    cin >> A[i];
  }
  for(int i = 0; i < N; i++){
    cin >> B[i];
  }
  ull count = 0ULL;
  for(int i = N; i >= 0; i--){
    if(i < N){
      if(B[i] > 0){
        if(A[i] > B[i]){
          A[i] -= B[i];
          count += B[i];
          B[i] = 0;
        }else{
          count += A[i];
          B[i] -= A[i];
          A[i] = 0;
        }
      }
    }
    if(i-1 >= 0){
      if(B[i-1] > 0){
        if(A[i] > B[i-1]){
          A[i] -= B[i-1];
          count += B[i-1];
          B[i-1] = 0;
        }else{
          count += A[i];
          B[i-1] -= A[i];
          A[i] = 0;
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>

using namespace std;

int main()
{
	int n, b;
	cin >> n >> b;
	map<int, int> eat;
	for (int i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		for (int j = 0; j < k; j++)
		{
			int food;
			cin >> food;
			eat[food]++;
		}
	}

	int count = 0;
	for (auto m : eat)
	{
		if (m.second == n)
		{
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        String s = scan.next();
        long sum = 0;

        for (int i = 0; i<s.length(); i++) {
            int a = Character.getNumericValue(s.charAt(i));
            sum += a;
        }

        if (sum % 9 == 0) {

            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 40180
#include <stdio.h>

#define INF 1000000000

int main() {
  int n,x;
  scanf("%d %d", &n, &x);

  int* m = new int[n];
  for(int i=0;i<n;i++) {
    scanf("%d", &m[i]);
  }

  int min = INF;
  for(int i=0;i<n;i++) {
    if(m[i] < min) {
      min = m[i];
    }
    x -= m[i];
  }

  printf("%d\n", x/min + n);

  return 0;
}


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


int main()
{
	int n;
	cin>>n;
	int arr[n+10];
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		for(int j=0;j<i;j++)
		{
			sum+=arr[i]*arr[j];
		}
	}
	cout<<sum;
}

Measured memory_bytes: 256
D, G = map(int, input().split())
PC = [list(map(int, input().split())) for i in range(D)]


points = []
patterns = []
    
def flagfun(flag):
    if len(flag) == D:
        patterns.append(flag)
        return
    
    flagfun(flag+'0')
    flagfun(flag+'1')
    
def index_pattern():
    flagfun('')
    idxes = []
    for pattern in patterns:
        tmp_idx = []
        for idx, flag in enumerate(pattern):
            if flag == '1':
                tmp_idx.append(idx)
        idxes.append(tmp_idx)
    return idxes

def culc_points():
    for i, scores in enumerate(PC):
        max_score = (i+1)*scores[0]*100 + scores[1]
        points.append([scores[0], max_score])

culc_points()

idxes = index_pattern()
count = 1000000

for idx in idxes:
    tmp_count = 0
    tmp_score = 0
    remain_idx = [i for i in range(D)]
    for i in idx:
        tmp_count += points[i][0]
        tmp_score += points[i][1]
        num_index = remain_idx.index(i)
        remain_idx.pop(num_index)
           
    if tmp_count >= count:
        continue
    
    if tmp_score >= G:
        count = tmp_count
        continue
    
    max_idx = remain_idx.pop(-1)
    for i in range(1, points[max_idx][0]):
        tmp_count += 1
        tmp_score +=(max_idx+1)*100
        if tmp_count >= count:
            break
            
        if tmp_score >= G:
            count = tmp_count
            break

print(count)

Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,k;
    cin >> n >> k;
    int cnt = (n+1)/2;
    if(cnt >= k) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, T;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  bool flag = true;
  while (flag) {
    for (int i = 0; i < N; i++) {
      if (a[i] % 2 != 0) {
        flag = false;
      }
    }
    if (flag == true) {
      for (int i = 0; i < N; i++) {
        a[i] /= 2;
      }
      T++;
    }
  }
  cout << T << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[2 * n];
        for (int i = 0; i < 2 * n; i++) {
            arr[i] = in.nextInt();
        }
        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < arr.length; i = i + 2) {
            sum += arr[i];
        }

        System.out.println(sum);
    }
}


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

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

int main() {
  string s;
  cin >> s;
  ll res = s.size();
  rep(i, s.size()) {
    if (s.at(i) == 'A') break;
    res--;
  }
  rep(i, s.size()) {
    if (s.at(s.size()-1-i) == 'Z') break;
    else res--;
  }
  cout << res << endl;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long x = scan.nextLong();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextLong();
		}
		long ans = 0;
		int b = 0;
		Arrays.sort(a);
		for (int i = 0; i < n; i++) {
			x = x-a[i];
			if (x < 0) {
				b = i;
				break;
			}
		}
		if (x > 0) {
			ans = n-1;
			System.out.println(ans);
			return;
		}
		else if (x == 0) {
			ans = n;
			System.out.println(ans);
			return;
		}
		else {
			ans = b;
			System.out.println(ans);
			return;
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  if(accumulate(ALL(a), 0ll)  < accumulate(ALL(b), 0ll)) {
    cout << -1 << endl;
    return 0;
  }

  priority_queue<ll> pq;
  ll del_sum = 0ll;
  int ans = 0;
  rep(i, n) {
    if(a[i] >= b[i]) pq.push(a[i]-b[i]);
    else {
      ++ans;
      del_sum += b[i]-a[i];
    }
  }

  while(del_sum > 0) {
    ++ans;
    ll del = pq.top(); pq.pop();
    del_sum -= del;
  }

  cout << ans << endl;
}


Measured memory_bytes: 2936
def comb(n, k)
  if(n < 0)
    return 0
  else
    a = 1
    for i in 1...k
      a = a * (n - i + 1) / i
    end
    return a
  end
end

n, m, r = gets.split.map(&:to_i)
puts comb(r - n * m + n - 1, n)

Measured memory_bytes: 8516
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 2005
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int f[MN][MN],st[MN];
int n,m,res;
bool a[MN][MN],b[MN][MN];
char s[MN];
int main()
{
	n=in();m=in();
	for (int i=1;i<=n;++i){
		scanf("%s",s);
		for (int j=1;j<=m;++j) a[i][j]=(s[j-1]=='#');
	}res=max(n,m);
	for (int i=1;i<n;++i)
	for (int j=1;j<m;++j) b[i][j]=(a[i][j]^a[i+1][j]^a[i][j+1]^a[i+1][j+1]);
	for (int i=1;i<n;++i)
	for (int j=1;j<m;++j) if (!b[i][j]) f[i][j]=f[i-1][j]+1;else f[i][j]=0;
	for (int i=1;i<n;++i){
		int top=0;
		for (int j=1;j<=m;++j){
			while (top&&f[i][j]<=f[i][st[top]])
			res=max(res,(j-st[top-1])*(f[i][st[top]]+1)),--top;st[++top]=j;
		}
	}printf("%d",res);return 0; 
}

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

using namespace std;

typedef long long ll;

ll L, n;
ll ans;
ll a[200005];
ll b[200005];
ll c[200005];

int main()
{
    scanf("%lld%lld", &L, &n);
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        b[i] = b[i - 1] + a[i];
    }
    for(ll i = n; i >= 1; i--)
    {
        c[i] = c[i + 1] + (L - a[i]);
    }
    for(ll i = 1; i <= n; i++)
    {
        ll t = min(i - 1, n - i);
        ll t1 = 2 * (b[i - 1] - b[i - 1 - t]) + 2 * (c[i + 1] - c[i + 1 + t]) + max(a[i], L - a[i]);
        ans = max(ans, t1);
    }
    for(ll i = 1; i <= n - 1; i++)
    {
        ll t = min(i, n - i);
        ll t1 = 2 * (b[i] - b[i - t]) + 2 * (c[i + 1] - c[i + 1 + t]) - min(a[i], L - a[i + 1]);
        ans = max(ans, t1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	char a;
	while(scanf("%c",&a)!=EOF)
		if(a>='a'&&a<='z')
			printf("%c",a-'a'+'A');
		else
			printf("%c",a);
	return 0;
}

Measured memory_bytes: 524
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(;T>0;T--){
			Read();
			var chk = Check();
			Console.WriteLine(chk ? "Yes" : "No");
		}
	}
	
	bool Check(){
		long a = A, b = B, c = C, d = D;
		
		if(b > a){
			return false;
		}
		a -= b;
//Console.WriteLine("a:{0}",a);		
		if(a > c){
			a -= (((a - c) + b - 1)/b) * b;
		}
//Console.WriteLine("a:{0}",a);		
		
		if(a < 0) return false;
//Console.WriteLine("1");
		//if(a <= C - D) return false;
//Console.WriteLine("2");
		if(D < B) return false;
		//if(D == B) return true;
		
		var unit = gcd(D, B);
//Console.WriteLine("unit:{0}",unit);
		a += (((C - a + 1) + unit - 1)/unit) * unit;
//Console.WriteLine("a:{0}",a);		
		return (a - B >= Math.Max(0,C - D));
		
	}
	
	long gcd (long a, long b){
		return a == 0 ? b : gcd(b % a, a);
	}
	
	void Read(){
		var d = rla();
		A = d[0]; B = d[1]; C = d[2]; D = d[3];
	}
	
	int T;
	long A, B, C, D;
	public Sol(){
		T = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, k; cin >> n >> k;
    string S; cin >> S;
    vector<int> num;
    if (S[0] == '0') num.push_back(0);
    for(int i = 0; i < S.size();)
    {
        int j = i;
        while(j < S.size() && S[j] == S[i]) j++;
        num.push_back(j - i);
        i = j;
    }
    if (S.back() == '0') num.push_back(0);

    vector<int> s(num.size() + 1, 0);
    rep(i, num.size()) s[i + 1] = s[i] + num[i];

    int ans = 0;
    for(int left = 0; left < s.size(); left += 2)
    {
        int right = left + k * 2 + 1;
        if (right >= s.size()) right = s.size() - 1;
        chmax(ans, s[right] - s[left]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1272
from collections import Counter


def main():
    N, K = map(int, input().split())
    A = map(int, input().split())

    c = Counter(A)

    ans = 0
    n_type = len(c)
    for count in sorted(c.values()):
        if n_type <= K:
            break
        ans += count
        n_type -= 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 41500
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    private static readonly Scanner sc = new Scanner();
    static void Main(string[] args)
    {
        bool[] used = new bool[30];

        string s = sc.Str;

        foreach(var c in s)
        {
            if (used[c - 'a'])
            {
                Console.WriteLine("no");
                return;
            }
            used[c - 'a'] = true;
        }

        Console.WriteLine("yes");
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Line { get { return Console.ReadLine(); } }

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Line.Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public string[] StrArr { get { return Line.Split(' '); } }
    public int Int { get { return int.Parse(Str); } }
    public int[] IntArr { get { return Line.Split(' ').Select(int.Parse).ToArray(); } }
    public long Long { get { return long.Parse(Str); } }
    public long[] LongArr { get { return Line.Split(' ').Select(long.Parse).ToArray(); } }
    public double Double { get { return double.Parse(Str); } }
    public double[] DoubleArr { get { return Line.Split(' ').Select(double.Parse).ToArray(); } }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=1e16;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll n,m;
	cin>>n>>m;
	vp in(n);
	rep(i,n)cin>>in[i].first>>in[i].second;
	ll out=0,q=in[0].first;
	loop(i,1,n)in[i].first-=q;
	in[0].first=0;
	rep(i,n+1){
		ll W=m-q*i;
		if(W<0)continue;
		vvi dp(i+1,vi(400));
		rep(w,n){
			for(int j=i-1;j>=0;j--)rep(k,400){
				if(k+in[w].first<400)dp[j+1][k+in[w].first]=max(dp[j+1][k+in[w].first],dp[j][k]+in[w].second);
			}
		}
//		rep(j,10)cout<<" "<<dp[i][j];cout<<endl;
		rep(j,min(W+1,400LL))out=max(out,dp[i][j]);
	}
	cout<<out<<endl;
}











Measured memory_bytes: 588
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a == b && a == c){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 35612
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) 
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int p[200000];
int par[200001];
int f[200001];
int cnt[200001];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int dfs(int x) {
	if (x == par[x]) {
		return x;
	}
	else {
		par[x] = dfs(par[x]);
		return par[x];
	}
}

int main() {
	int n;
	//*
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d", &p[i]);
	}
	/*/
	n = 2e5;
	REP(i, n) {
		p[n - 1 - i] = i + 1;
	}
	//*/
	REP(i, n+1) {
		par[i] = i;
		f[i] = 0;
		cnt[i] = 0;
	}
	REP(i, n) {
		f[p[i]]++;
		if (f[p[i] - 1]) {
			par[p[i]] = dfs(p[i]-1);
		}
	}
	REPS(i, n) {
		cnt[par[i]]++;
	}
	int max = 0;
	REPS(i, n) {
		if (cnt[i] > max)max = cnt[i];
	}
	PRINTD(n - max);
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int n, k, s;
    int ans = 0;
    cin >> n >> k;
    for(size_t i = 0; i < n; i++)
    {
        cin >> s;
        if(abs(k-s)>s) ans += s*2;
        else ans += (k-s)*2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	int n, a, b;
	char x, y;
	cin >> n >> x >> a >> y >> b;

	if (a > 4) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}

	return 0;
}

Measured memory_bytes: 256