akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define ref goto refrain

class dice{
	public:
	int o,u,s,e,n,w;//over,under,south,east,north,west
}a;

void change(int*a,int*b,int*c,int*d){
	int temp=*a;		*a=*b;	*b=*c;	*c=*d;	*d=temp;
}

void search(int u,int s){
	while(u!=a.o){
		change(&a.u,&a.n,&a.o,&a.s);
		if(u==a.o) break;
		change(&a.u,&a.e,&a.o,&a.w);
	}
	while(s!=a.s){
		change(&a.s,&a.e,&a.n,&a.w);
	}
	cout<<a.e<<endl;
}
			
		
int main(){
	cin>>a.o>>a.s>>a.e>>a.w>>a.n>>a.u;
	int n,s,u;//s:前面、u:上面
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>u>>s;
		search(u,s);
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll h,w,n;
    cin>>h>>w>>n;
    ll x1=max(h,w),x2=min(h,w);
    ll b1=n/(x1);
    if (n%x1==0)
    {
        cout<<b1<<"\n";
    }
    else
    {
        cout<<b1+1<<"\n";
    }
    
}


Measured memory_bytes: 256
a,b,c,d=map(int,input())
if a+b+c+d==7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"="+"7")
elif a+b+c-d==7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"="+"7")
elif a+b-c+d==7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"="+"7")
elif a-b+c+d==7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"="+"7")
elif a-b-c+d==7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"="+"7")
elif a+b-c-d==7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"="+"7")
elif a-b+c-d==7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"="+"7")
elif a-b-c-d==7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"="+"7")

Measured memory_bytes: 9276
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, k, a, cur, i, res;
map<int, int> mapa;
map<int, int>::iterator it;
VI wek;

int main() {
scanf("%d %d", &n, &k);
mapa.clear();
for (i=0;i<n;i++) {
	scanf("%d", &a);
	cur = mapa[a];
	mapa[a] = cur + 1;
}
wek.clear();
for (it = mapa.begin();it!=mapa.end();it++) wek.pb(it->second);
sort(wek.begin(), wek.end());
res = 0;
for (i=0;i<(int)wek.size() - k;i++) res += wek[i];
printf("%d\n", res);
return 0;
}



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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		string s = to_string(i);
		if (s.size() & 1) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using in6 = int64_t;
using ind = double;
using vi = vector<in6>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<in6,in6>;
using psi = pair<string,in6>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n;
  cin >> n;
  vi high(n);
  rep(i,n) cin >> high[i];
  in6 ans = 1;
  repa(i,1,n) {
    bool check = 1;
    rep(j,i) {
      if(high[i] < high[j]) check = 0;
    }
    if(check) ans++;
  }
  cout << ans;
  hinata;
}

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

temp = abs(a - (t - h_list[0] * 0.006))
result = 1
i=1
for h in h_list:
    if abs(a - (t - h * 0.006)) < temp:
        temp = abs(a - (t - h * 0.006))
        result = i
    i += 1
print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    int N,D,ans = 0;
    cin >> N >> D;
    vector<vector<int>> vec;
    for(int i = 0;i < N;i++){
        vector<int> tmp;
        for(int j = 0;j < D;j++){
            int x;
            cin >> x;
            tmp.push_back(x);
        }
        vec.push_back(tmp);
    }
    for(int k = 0; k < N-1;k++){
        for(int i = k+1;i < N;i++){
            float root = 0.0;
            for(int j = 0;j < D;j++){
                root += pow((float)(vec[k][j] - vec[i][j]),2.0f);
            }
            root = sqrt(root);
            if(ceil(root) == floor(root)) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;


int main(){

        int n,i=1,x;

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

        while(1){
                x=i;
                if(i>n) {
                        putchar('\n');
                        return 0;
                }
                //printf("\ni %d x %d\n",i,x);

                if(x%3 == 0) {
                        printf(" %d",i);
                } else {
                        do {
                                //printf("\ndo i %d x %d\n",i,x);
                                if(x%10 == 3) {
                                        printf(" %d",i);
                                        break;
                                }
                                else
                                        x/=10;
                        } while(x);
                }
                i++;
        }
}


Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
using namespace std;
const int INF = 0x3f3f3f3f;

struct Node{
	int key;
	Node *prev, *next;
};

Node *nil;

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

Node* listSearch(int key) {
	Node *cur = nil->next;
	while( cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *t) {
	if ( t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int Key) {
	deleteNode(listSearch(Key));
}
int main(){
	int n, temp;
	char s[15];
	scanf("%d", &n);
	init();
	for(int i = 0; i < n; i ++)
	{
		scanf("%s", s);
		if(!strcmp(s, "insert"))
		{
			cin >> temp;
			insert(temp);
		}
		else if(!strcmp(s, "delete"))
		{
			cin >> temp;
			deleteKey(temp);
		}
		else if(!strcmp(s, "deleteFirst"))
			deleteFirst();
		else
			deleteLast();
	}
	Node *node = nil->next;
	while(node != nil)
	{
		printf("%d", node->key);
		if(node->next != nil)
			printf(" ");
		node = node->next;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 34464
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val as = new Array[Long](n)
    for (i <- 0 until n) {
      as(i) = sc.nextLong
    }

    var isFinished = false
    while (!isFinished) {
      val min = as.filter(_ != 0).min
      val minIndex = as.indexOf(min)
      for (i <- 0 until n) {
        if (i != minIndex) {
          as(i) = as(i) % min
        }
      }

      if (as.count(_ != 0) == 1) {
        isFinished = true
      }
    }
    println(as.find(_ != 0).get)
  }
}


Measured memory_bytes: 59524
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vec<ll> v(n),c(n); rep(i,n)cin >> v[i]; rep(i,n)cin >> c[i];
    ll ans = 0;
    rep(i,n){
        if(v[i] - c[i] > 0)ans += v[i] - c[i]; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

typedef struct Node {
    int val;
    struct Node *left;
    struct Node *right;
    int count;
} Node;

Node *getNewNode(int val){
    static int i = 0;
    static Node node[2000000];
    node[i].val = val;
    node[i].left = nullptr;
    node[i].right = nullptr;
    node[i].count = 1;
    return &node[i++];
}

Node *insert(Node *t, int val){
    if(t == nullptr){
        return getNewNode(val);
    }
    if(val < t->val){
        t->left = insert(t->left, val);
    } else if(val > t->val){
        t->right = insert(t->right, val);
    } else if(val == t->val){
        t->count++;
    }
    return t;
}

Node *extract(Node *t){
    if(t == nullptr) return nullptr;
    if(t->right == nullptr){
	std::printf("%d\n", t->val);
	t->count--;
	if(t->count == 0) return t->left;
	else return t;
    }
    t->right = extract(t->right);
    return t;
}

int main(){
    Node *root = nullptr;
    while(1){
	char op[8];//max 7 char "extract"                                                                                                                                                                                           
	std::scanf("%s", op);
	if(std::strncmp(op, "insert", 6) == 0){
            int val;
            std::scanf("%d", &val);
            root = insert(root, val);
	} else if(std::strncmp(op, "extract", 7) == 0){
            root = extract(root);
	} else if(std::strncmp(op, "end", 3) == 0){
            break;
	}
    }
    return 0;
}



Measured memory_bytes: 5872
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

int main()
{
    int N;
    string s;
    cin >> N >> s;
    int x  = 0;
    int maxi = 0;
    for(int i = 0;i < N;i++)
    {
        if(s[i] == 'I')
            x++;
        else
            x--;
        maxi = max(maxi,x);
    }
    cout << maxi << '\n';
}


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

int main(){
    int n,m,q; cin>>n>>m>>q;
   vector<vector<int>> a(n,vector<int> (n,0));
    for(int i=0;i<m;i++){
        int l,r; cin>>l>>r;
        l--; r--;
       a[l][r]++;
    }

    vector<vector<int>> s(n+1,vector<int> (n+1,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j]+a[i][j];
        }
    }

    for(int i=0;i<q;i++){
        int x,y; cin>>x>>y;
        x--;
        cout<<s[y][y]-s[x][y]-s[y][x]+s[x][x]<<endl;
    }
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    int n;
    cin >> n;
    long long ans = 0;
    vector< vector< long long > > cnt(200, vector< long long>(200, 0));
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        int l = s.length(), d = l-1;
        long long v = 0;
        for(int j=0;j<l;j++){
            if(s[j] == '.'){
                d = j;
            }else{
                v = v*10 + s[j]-'0';
            }
        }
        int p2 = d-l+1, p5 = d-l+1;
        while(v%2 == 0){
            v /= 2;
            p2++;
        }
        while(v%5 == 0){
            v /= 5;
            p5++;
        }
        for(int x=40; x+p2 >= 0; x--){
            for(int y=40; y+p5 >= 0; y--){
                ans += cnt[x+40][y+40];
            }
        }
        cnt[p2+40][p5+40]++;
        // cout << v << "  " << p2 << " " << p5 << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3520
a,b,c = map(int,input().split())
if a%2==1 or b%2==1 or c%2==1:
    print(0)
    exit()
elif a==b==c:
    print(-1)
    exit()
def f(a,b,c):
    cnt = 0
    while True:
        if a%2==0 and b%2==0 and c%2==0:
            a_ = b//2+c//2
            b_ = a//2+c//2
            c_ = a//2+b//2
            a,b,c=a_,b_,c_
            cnt+=1
        else:
            break
    return cnt
print(f(a,b,c))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int A, B; cin >> A >> B;
    int K = (A + B) / 2;
    if (abs(A-K) == abs(B-K)) {
        cout << K << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef pair<int ,int> ipair;
typedef long long ll;
int main(){

	int n;
	cin >> n;
	vector< ll > xpos(n);
	vector< ll > ypos(n);
	vector< ll > h(n);

	
	bool flag = false;
	int a,b,c;
	for(int i = 0; i < n; i++)
	{
		cin >> xpos[i] >> ypos[i] >> h[i];
		if(h[i] != 0 and flag == false){
			flag = true;
			a = xpos[i];
			b = ypos[i];
			c = h[i];
		}
	}

	ll x_kotae=0, y_kotae=0;
	for(int x = 0; x <= 100; x++)
	{
		
		for(int y = 0; y <= 100; y++)
		{
			bool flag = true;
			ll tmp = abs(a-(ll)x) + abs(b-(ll)y) + c;
			for(int i = 0; i < n; i++)
			{
				if((tmp < abs(xpos[i] - (ll)x) + abs(ypos[i] - (ll)y)+h[i] && h[i] >= 1) || (tmp > abs(xpos[i] - (ll)x) + abs(ypos[i] - (ll)y)+h[i])){
					flag = false;
					break;
				}
			}
			if (flag == true){
				cout << x << " " << y << " " << tmp << endl;
			}
			
		}
		
	}
	
	return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

inline ll gcd(ll a, ll b) {
  for (; a; swap(b %= a, a));
  return b;
}

signed main() {
    string s;
    cin >> s;
    string k = "keyence";
    bool ans = false;
    if (s[0] != k[0]){
        ans = equal(be(k), end(s) - k.size(), end(s));
    } else if (s[s.size() - 1] != k[k.size() - 1]) {
        ans = equal(be(k), begin(s), begin(s) + k.size());
    } else {
        int c = 0;
        rep(i, k.size()){
            if (s[i] == k[i]) ++c;
        }
        debug(c);
        if(c == k.size()){
            ans = true;
        } else {
            ans = equal(begin(k)+c, end(k), end(s) - (k.size() - c),  end(s));
        }
    }
    cout << (ans ? "YES" : "NO") << nl;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
    int group;
    int no;
    float time;
} TIME;

int main(void)
{
    int i, j;
    TIME data[24];
    TIME tmp;
    int n;
    
    for (i = 0; i < 24; i++){
        scanf("%d%f", &data[i].no, &data[i].time);
        data[i].group = (i / 8) + 1;
    }
    
    for (i = 0; i < 24; i++){
        for (j = 0; j < 24 - 1; j++){
            if (data[j].time > data[j + 1].time){
                tmp = data[j];
                data[j] = data[j + 1];
                data[j + 1] = tmp;
            }
        }
    }
    
    for (i = 1; i <= 3; i++){
        n = 0;
        for (j = 0; j < 24; j++){
            if (data[j].group == i){
                printf("%d %.2f\n", data[j].no, data[j].time);
                data[j].no = -1;
                if (++n == 2){
                    break;
                }
            }
        }
    }
    
    n = 0;
    for (j = 0; j < 24; j++){
        if (data[j].no != -1){
            printf("%d %.2f\n", data[j].no, data[j].time);
            if (++n == 2){
                break;
            }
        }
    }
    
    return (0);
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(2));
  for(int i = 0; i < N; i++) {
    A[i][1] = i;
    cin >> A[i][0];
  }

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

  for(int i = 0; i < N; i++) {
    cout << A[i][1] + 1;
    if(i == N - 1) {
      cout << endl;
    }
    else {
      cout << " ";
    }
  }


  return 0;
}


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

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

	int N;
	string S;
	cin >> N >> S;

	if( N & 1 ) {
		cout << "No" << endl;
	}
	else {
		bool result = true;
		int x = N / 2;

		for( int i = 0; i < x; ++i ) {
			if( S[i] != S[x+i] ) {
				result = false;
				break;
			}
		}

		cout << (result ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,d,i;
while(1){
scanf("%d\n",&a);
if(a==0){
break;
}
else{
for(i=0;i<a;i++){
scanf("%d %d %d\n",&b,&c,&d);
if(b==100 || c==100 || d==100){
printf("A\n");
}
else if(b>=90 && c>=90){
printf("A\n");
}
else if(b+c+d>=240){
printf("A\n");
}
else if(b+c+d>=210){
printf("B\n");
}
else if(b+c+d>=150 && (b>=80 || c>=80)){
printf("B\n");
}
else{
printf("C\n");
}
}
}
}
return 0;
}











Measured memory_bytes: 1984
#include<stdio.h>

int main() {
    int a, b; 
    scanf("%d%d", &a, &b); 
    if (a < b) {
        printf("a < b\n"); 
    }else if (a > b) {
        printf("a > b\n"); 
    }else if (a == b) {
        printf("a == b\n"); 
    }

    return 0; 
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    REP(i,s.size()) cout << "x";
    cout << '\n';

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define f(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define d(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ri register int
#define ll long long
#define il inline
int max(int x, int y) {return x>y?x:y;} int min(int x, int y) {return x<y?x:y;}
long long n_i;
int sat(ll i) {
  ll m=n_i; while(m%i==0) m/=i; return (m%i==1);
}
int sigma1(long long n) {
  int ans = 0;
  for(ll i=2; i*i<=n; ++i) {
    if(n%i==0) ans += sat(i) + sat(n/i) - (i == n/i);
  }
  return ans+sat(n);
}
int main(){
  cin>>n_i;
  if(n_i == 2) puts("1");
  else printf("%d\n", sigma1(n_i)+sigma1(n_i-1));
  return 0;
}
// sto wyxkk orz


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a==b && c==d || a==d && b==c){
		printf("yes\n");
	}
	else{
		printf("no\n");
	}
	return 0;
}



Measured memory_bytes: 2124
#include<stdio.h>
int main(void){
	int a = getchar()*256+getchar();
	char n;
	switch(a){
		case 'S'*256+'U': n=7; break;
		case 'M'*256+'O': n=6; break;
		case 'T'*256+'U': n=5; break;
		case 'W'*256+'E': n=4; break;
		case 'T'*256+'H': n=3; break;
		case 'F'*256+'R': n=2; break;
		case 'S'*256+'A': n=1; break;
	}
	putchar(n+'0');
	putchar(10);
}


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	string s;
	cin >> s;
	unsigned long long int sum = 0;
	unsigned long long int n = s.size();
	for(unsigned long long int i = 0; i < n; i++) {
		sum += (s[i] - '0');
	}
	if(sum % 9 == 0) cout << "Yes";
	else cout << "No";
	return 0;
}

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

#define ll long long
#define ii pair<int,int>
#define INF 1e9 + 7
#define vi vector<ll>
#define add emplace_back


int main(){ios_base::sync_with_stdio(false);
    //cannot use same element multiple times 
    int n, w, weight, val;
    cin >> n >> w;
    vi dp(w+1);

    for(int k=0; k<n; ++k){
        cin >> weight >> val;
        for(int i=w; i>=weight; --i) dp[i] = max(dp[i], dp[i-weight]+val);
    }
    
    cout << dp[w] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int n,k;
LL dp[111][256][111];
const LL mod = 1e9 + 7;

int main(){
	scanf("%d%d" , &n , &k);
	dp[0][0][0] = 1;
	repp(i,1,n+1){
		int a;
		scanf("%d" , &a);
		dp[i][0][0] = 1;
		repp(j,0,256){
			repm(l,i,0){
				dp[i][j][l] = (dp[i-1][j][l] + dp[i-1][j^a][l-1]) % mod;
			}
		}
	}
	LL ans = 0;
	LL x = 1;
	repp(i,1,n+1){
		x = x * i % mod;
		(ans += dp[n][k][i] * x % mod) %= mod;
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 22400
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()

if N == 0:
    print('0')
    exit()

cnt = 0
rep = abs(N)
lista = []

while rep != 0:
    split = (rep % 2 ** (cnt + 1)) // 2 ** cnt
    if split == 0:
        lista.append(0)
    else:
        lista.append(1)
    if N * (-1) ** cnt < 0:
        rep += (split * (2 ** cnt))
    else:
        rep -= (split * (2 ** cnt))
    cnt += 1
lista.reverse()
print(''.join(map(str, lista)))

Measured memory_bytes: 60780
from functools import reduce
import fractions

n=int(input())
a_list=list(map(int,input().split()))

# 最小公倍数
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

# mの選び方 → 最小公倍数-1
m=lcm_list(a_list)-1

mod_all=0
for a in a_list:
    mod_all+=m%a
print(mod_all)

Measured memory_bytes: 5640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define ll long long int
#define rep(i,n) for(int i = 0;i < (n);i++)
ll INF = 1000000010; 
const ll MOD = 1000000007;


int main(){ 
    int a, b; cin >> a >> b;
    int n = to_string(b).size();
    int s = b + pow(10,n) * a;

    rep(i,350){
        if(i*i == s){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
} 

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

int check(int n){
  if (400<=n&&n<600)
    return 8;
  if (600<=n&&n<800)
    return 7;
  if (800<=n&&n<1000)
    return 6;
  if (1000<=n&&n<1200)
    return 5;
  if (1200<=n&&n<1400)
    return 4;
  if (1400<=n&&n<1600)
    return 3;
  if (1600<=n&&n<1800)
    return 2;
  if (1800<=n&&n<2000)
    return 1;
  }
    


int main()
{
  int n;
  cin >> n ;
  
  cout << check(n) << endl;  

return 0;
}

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

int main(){
    int n,i;
    cin >> n;
    for(i=0;i<n;++i){
        int k;
        cin >> k;
        if(k%2==0){
            if(k%3!=0 && k%5!=0){
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int min = 0;
        int max = n;
        for(int i = 0; i < m; i++) {
        	int l = sc.nextInt();
        	int r = sc.nextInt();
        	min = Math.max(min, l);
        	max = Math.min(r, max);
        }
        int ans = max - min + 1;
        if(ans > 0) {
        	System.out.println(ans);
        }else {
        	System.out.println(0);
        }
    }
}

Measured memory_bytes: 64456
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    int S = accumulate(arr.begin(), arr.end(), 0);
    int ans = -1;
    int gap = 1e5;
    for(int i = 0; i < n; i++) {
        if (abs(arr[i]*n-S) < gap) {
            gap = abs(arr[i]*n-S);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
  int a[4],u[10],h,b,t;
  while(cin>>a[0]){
    rep(i,10) u[i]=0;
    h = 0;
    b = 0;
    rep(i,3)
      cin >> a[i+1];
    rep(i,4)
      u[a[i]] = 1;
    rep(i,4){
      cin >> t;
      if(a[i] == t) h++;
      if(u[t]) b++;
    }
    cout << h << " " << b-h << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N == 0 || N == 1) {
    if (N == 0) cout << 2 << endl;
    if (N == 1) cout << 1 << endl;
    return 0;
  }

  N--;
  long long a = 2;
  long long b = 1;
  long long ans;
  for(int i = 0; i < N; i++) {
    ans = a + b;
    a = b;
    b = ans;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a, b, k, flag;
int main(){
	cin >> k >> a >> b;
	for(int i=a; i<=b; i++){
		if(i % k == 0){
			flag = 1;
			break;
		}
	}
	if(flag == 0){
		cout<< "NG";
	}else{
		cout<< "OK";
	}
	return 0;
} 

Measured memory_bytes: 3588
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
struct comp{

    bool operator()(const pair<int, string>& p1, const pair<int, string>& p2){
        if(p1.first == p2.first){
            return p1.second < p2.second;
        }
        return p1.first> p2.first;
    }
};


int main(){
   IOS

    int n; cin>>n;

    unordered_map<string, int> mp;

    for(int i = 0; i < n; i++){
        string s ;
        cin>>s;
        mp[s]++;
    }

    vector<pair<int, string>> v;

    for(auto i : mp){
        v.pb({i.second, i.first});
    }

    sort(all(v), comp());

    cout<<v[0].second<<"\n";

    for(int i = 1; i < v.size(); i++){
        if(v[i].first == v[0].first){
            cout<<v[i].second<<"\n";
        }
    }

   














}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 27972
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
long long a,b,k;
cin >> a >> b >> k;
a-=k;
ll che=0;
if(a<0){che = abs(a);
a=0;
}
b-=che;
if(b<0)b=0;
cout << a <<" "<<b<<endl;
}
 


Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<string>
#include<cmath>
#include<vector>
#include<tuple>
#include <algorithm>
using namespace std;
template <typename T>
void show(vector<T> &vec){
    for (auto value : vec) {
        cout << value << " ";
    }
    cout << endl;
}
int main(){
    int n, k;
    cin >> n >> k;
    cout << ceil(double(n-1)/double(k-1));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#define MAXSIZE 101
#define PI 3.141592653589
using namespace std;
int main(){
  string s;
  getline(cin,s);

  for(int i=0;i<s.size();i++){
    if(islower(s[i])){
      s[i]=toupper(s[i]);
    }else if(isupper(s[i])){
      s[i]=tolower(s[i]);
    }
  }
  std::cout << s << '\n';

}

Measured memory_bytes: 3196
#include <stdio.h>

int n;

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

	long long a = 0;
	for (int i = 1; i <= n; i++){
		long long c = n / i;
		a += c * (c + 1) / 2 * i;
	}

	printf ("%lld\n", a);
	return 0;

}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 320;

int dis[N][N], dis2[N][N];
int n, m, len;

void init(){

   for (int i = 0; i <= n; ++i)
   {
      for (int j = 0; j <= n; ++j)
      {
         dis[i][j] = inf;
      }
   }

   for (int i = 0; i <= n; ++i)
   {
      dis[i][i] = 0;
   }

}

void build(int dis[][N]){
   for (int k = 1; k <=n ; ++k)
      for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= n ; ++j)
            dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
}

int32_t main(){_

   cin>>n>>m>>len;

   init();

   for (int i = 0; i < m; ++i)
   {
      int x, y, z;
      cin >> x >> y >> z;
      if(z > len)continue;
      dis[x][y] = z;
      dis[y][x] = z;
   }

   build(dis);

   for (int i = 1; i <= n; ++i)
   {
      for (int j = 1; j <= n; ++j)
      {
         dis2[i][j] = (dis[i][j] <= len) ? 1 : inf;
         tr(i, j, dis[i][j], dis2[i][j]);
      }
   }

   build(dis2);

   int q;
   cin >> q;

   for (int i = 0; i < q; ++i)
   {
      int s, t;
      cin >> s >> t;
      int tt = dis2[s][t];
      --tt;
      if(tt >= inf / 2)tt = -1;
      cout<<tt;
      cout<<endl;
   }


   return 0;
}

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

int main(){
	bool f=true;
	int n,i,m;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>m;
		if(m%2==0&&m%5!=0&&m%3!=0) f=false;
	}
	if(f==false) cout<<"DENIED";
	else cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 256
INF = 10 ** 12
H, N = gets.split.map(&:to_i)
lists = []
maxa = 0
N.times do
  a, b = gets.split.map(&:to_i)
  lists << [a, b]
  maxa = a if maxa < a
  # lists << gets.split.map(&:to_i)
end
# p lists
dp = Array.new(maxa + H + 1, INF)
dp[0] = 0
# binding.pry
ans = INF
lists.size.times do |j|
  lists[j][0].upto(dp.size - 1) do |i|

    dp[i] = dp[i - lists[j][0]] + lists[j][1] if dp[i] > dp[i - lists[j][0]] + lists[j][1]
    if i >= H
      ans = dp[i] if ans > dp[i]
    end
  end
end
# p dp
puts ans

Measured memory_bytes: 3964
n, k = map(int, input().split())
mod = 10**9+7

def nCr(N, R, mod):
  R = min(R, N-R)
  numer = denom = 1
  for i in range(1, R+1):
    numer = numer * (N+1-i) % mod
    denom = denom * i % mod
  res = numer * pow(denom, mod-2, mod) % mod
  return res

for i in range(1,k+1):
  if n-k+1<i:
    print (0)
    continue
  y = nCr(n-k+1,i,mod)
  y *= nCr(k-1,i-1, mod)
  print (y%mod)

Measured memory_bytes: 9160
M = int(input())
N = list(map(int, input().split()))
import numpy as np
npN = np.array(N)
count_all=0
for i in range (npN.max()):
    before = npN[0]
    
    if npN[0]==0:
        count=0
    else:
        count=1

    for i in range (len(N)):
        if before == 0 and npN[i]!= 0:
            count+=1
            before = npN[i]
        else:
            before = npN[i]
        if npN[i]!=0:
            npN[i]-=1
    count_all+=count
print(count_all)

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

int main() {
  int x[5];
  for (int i = 0; i < 5; i++) {
    scanf("%d", &x[i]);
    if (x[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

#define LIMIT 1000000
int strtoi(string s){
    stringstream ss;
    int n;
    ss << s;
    ss >> n;
    return n;
}

string itos(int n){
    stringstream ss;
    string s;
    ss << n;
    ss >> s;
    return s;
}

int main(){
    int q;
    string s;
    cin >> q;
    for(int i=0;i<q;++i){
        int n, m;
        set<int> hist;
        int cnt=0;
        cin >> s;
        for(int k=0;;++k){
            vector<int> v;
            if(strtoi(s) < 10) break;
            for(int j=1;j<s.size();++j){
                n = strtoi(s.substr(0,j));
                m = strtoi(s.substr(j));
                v.push_back(n*m);
            }
            s = itos(*(max_element(v.begin(), v.end())));
            if(hist.find(strtoi(s))!=hist.end()||k>=LIMIT){
                cnt = -1;
                break;
            }
            hist.insert(strtoi(s));
            ++cnt;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1256
import sys
input = sys.stdin.readline
def print_ans(input_line):
    """Test Case
    >>> print_ans("Sunny")
    Cloudy
    >>> print_ans("Rainy")
    Sunny
    """
    if input_line == "Sunny":
        print("Cloudy")
    elif input_line == "Rainy":
        print("Sunny")
    else:
        print("Rainy")


if __name__ == '__main__':
    input_line = input().rstrip()
    print_ans(input_line)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N;
    string s;
    cin >> N >> s;
    int ans = 0;
    REP(i, 10) {
        REP(j, 10) {
            REP(k, 10) {
                int v[3] = {i, j, k};
                int c    = 0;
                REP(l, N) {
                    if(s[l] - '0' == v[c]) {
                        c++;
                    }
                    if(c == 3) break;
                }
                if(c == 3) ans++;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

if n < 10:
    print(n)

elif n < 100:
    print(9)

elif n < 1000:
    print(n - 90)

elif n < 10000:
    print(909)

elif n < 100000:
    print(n - 9090)

else:
    print(90909)

Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double sum = 0;
        for (int n = 0; n < N; n += 1) {
            double x = sc.nextDouble();
            String u = sc.next();
            if (u.equals("BTC")) {
                sum += x * 380000.0;
            } else {
                sum += x;
            }
        }
        System.out.println(sum);
    }
}


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

m = 0
tmp = min(a)
while m != tmp:
    m = tmp
    for i in range(n):
        if a[i] != m:
            a[i] = a[i] % m
        if a[i] < m and a[i] != 0:
            tmp = a[i]
print(m)


Measured memory_bytes: 20004
#include<bits/stdc++.h>
#define hh ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int maxn=100005;
int n,ans=0;
int arr[maxn]={0};
int main(){
    hh;
    cin>>n;
    for(int i=0;i<n;i++)    cin>>arr[i];
    for(int i=1;i<n-1;i++){
        if( (arr[i]>arr[i-1]&&arr[i]<arr[i+1]) || (arr[i]<arr[i-1]&&arr[i]>arr[i+1]) ){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
var a:Array[1..32]of Longint=(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51);
n:Longint;
begin
read(n);
writeln(a[n]);
end.

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {


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

	}

	for (int i = 0; i < n; i++) {
		cin >> b[i];
		if (a[i] > b[i])s += a[i] - b[i];
	}

	cout << s << endl;
		
	

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

int main(void) {
    int a;
    int b;
    cin >> a >> b;
    int aria = a * b;
    int rec = (a + b) * 2;
    cout << aria << " " <<rec << endl;
    return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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


int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<int> n0;
    vector<int> n1;
    auto now = S[0];

    if( now != '1')
        n1.push_back(0);

    int num = 0;

    // Make freq list
    rep(i, N) {
        if(now != S[i]) {
            if(now == '0')
                n0.push_back(num);
            else
                n1.push_back(num);
            num = 0;
            now = S[i];
        }
        num++;
    }
    if(now == '0') {
        n0.push_back(num);
        n1.push_back(0);
    } else {
        n1.push_back(num);
    }

    assert(n0.size() == n1.size() - 1);

    int ret = 0;
    int current = 0;

    // pick k 0 
    rep(i, K) {
        if( i >= n0.size()) {
            if(i < n1.size()) {
                current += n1[i];
            }
            if(i+1 < n1.size()) {
                current += n1[i+1];
            }
            cout << current << endl;
            return 0;
        }
        current += n0[i];
        current += n1[i];
    } 
    current += n1[K];
    ret = current;

    rep(i, n0.size() - K) {
        current -= n0[i];
        current += n0[i+K];
        current -= n1[i];
        current += n1[i+K+1];
        ret = max(ret, current);
    }
    cout << ret << endl;

    return 0;
}


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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  int n; cin >> n;
  int F[n][5][2], P[n][10], gettmp;
  REP(i, n) REP(j, 5) REP(k, 2) cin >> F[i][j][k];
  REP(i, n) REP(j, 11) cin >> P[i][j];
  int res = -INFi;
  FOR(i, 1, 1 << 10){
    int profit = 0;
    REP(k, n){
      int bit_search = 1, numb = 0;
      REP(j, 5){
        if(F[k][j][0] == 1 && (i & bit_search) != 0) numb++;
        bit_search <<= 1;
      }
      REP(j, 5){
        if(F[k][j][1] == 1 && (i & bit_search) != 0) numb++;
        bit_search <<= 1;
      }
      profit += P[k][numb];
    }
    chmax(res, profit);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt();
		int[][] ls = new int[m][]; 
		for(int i=0;i<m;i++) {
			int k = fs.nextInt();
			ls[i] = fs.nextIntArray(k);
			for(int j=0;j<k;j++)ls[i][j]--;
		}
		int p[] = fs.nextIntArray(m);
		
		int cnt = 0;
		for(int i=0;i<(1<<n);i++) {
			boolean ok = true;
			for(int j=0;j<m;j++) {
				int tcnt = 0;
				for(int k=0;k<ls[j].length;k++) {
					int now = ls[j][k];
					if ((i>>now&1)==1)tcnt++;
				}
				if(tcnt%2!=p[j]) {
					ok = false;
					break;
				}
			}
			if(ok)cnt++;
		}
		System.out.println(cnt);
	}
}

//高速なScanner
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;
	}
}

Measured memory_bytes: 21332
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int L=sc.nextInt();
    String[] s= new String[N];
    for(int i=0;i<N;i++) {
      String demostring=sc.next();
      if(demostring.length()==L) {
        s[i]=demostring;
      } else {
        System.out.println("string is not same length");
      }
    }

    Arrays.sort(s);
    for(int j=0;j<N;j++) {
      System.out.print(s[j]);
    }


}
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	string w;

	cin>>w;

	int f=0;
	int o=0;

	int a[101]={};
	rep(i,w.size()){
		if(w[i]=='a'){
			a[i]=1;
		}else if(w[i]=='b'){
			a[i]=2;
		}else if(w[i]=='c'){
			a[i]=3;
		}else if(w[i]=='d'){
			a[i]=4;
		}else if(w[i]=='e'){
			a[i]=5;
		}else if(w[i]=='f'){
			a[i]=6;
		}else if(w[i]=='g'){
			a[i]=7;
		}else if(w[i]=='h'){
			a[i]=7;
		}else if(w[i]=='i'){
			a[i]=8;
		}else if(w[i]=='j'){
			a[i]=8;
		}else if(w[i]=='k'){
			a[i]=9;
		}else if(w[i]=='l'){
			a[i]=10;
		}else if(w[i]=='m'){
			a[i]=11;
		}else if(w[i]=='n'){
			a[i]=12;
		}else if(w[i]=='o'){
			a[i]=13;
		}else if(w[i]=='p'){
			a[i]=14;
		}else if(w[i]=='q'){
			a[i]=15;
		}else if(w[i]=='r'){
			a[i]=16;
		}else if(w[i]=='s'){
			a[i]=17;
		}else if(w[i]=='t'){
			a[i]=18;
		}else if(w[i]=='u'){
			a[i]=19;
		}else if(w[i]=='v'){
			a[i]=20;
		}else if(w[i]=='w'){
			a[i]=21;
		}else if(w[i]=='x'){
			a[i]=22;
		}else if(w[i]=='y'){
			a[i]=23;
		}else if(w[i]=='z'){
			a[i]=24;
		}

	}


	rep(i,w.size()){
		o=0;
		if(a[i]!=0){
			rep(j,w.size()){
				if(i!=j){
					if(a[i]==a[j]){
						o++;
						a[j]=0;
					}
				}
			}
			w[i]=0;
			if((o+1)%2>0){
				f=1;
				break;
			}
		}

	}
		if(f==0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
		return 0;
}


Measured memory_bytes: 256