akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


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


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


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


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


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


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


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    X, Y = MI()
    # tmp = math.log2(Y) - math.log2(X)
    # print(int(tmp) + 1)

    ans = 0
    c = X
    while c <= Y:
        c = c * 2
        ans += 1

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 5080
#include<stdio.h>
int main(){
	int a,b,x,sum;
	scanf("%d %d",&a,&b);
	if(a<b){
    	x=a;
    	a=b;
    	b=x;
    }
  	if(a==b) sum=a*2;
	else sum=a*2-1;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MAX=1000000007;



signed main() {
 int n;
 cin>>n;
 int a[n];
 queue<int> miq,pq;
 for(int i=0;i<n;i++){
     cin>>a[i];
     
     }
   sort(a,a+n);
   int ans=0;
   miq.push(a[0]);ans-=a[0];
   pq.push(a[n-1]);ans+=a[n-1];
   for(int i=1;i<n-1;i++){
       if(a[i]<=0){
           miq.push(a[i]);
           ans-=a[i];
       }
       else {
           pq.push(a[i]);
           ans+=a[i];
       }
   }
   cout<<ans<<endl;
   while(!(miq.empty()||pq.empty())){
      
       if(miq.size()<pq.size()){
         cout<<  miq.front()<<' '<<pq.front()<<endl;
         miq.push(miq.front()-pq.front());
         miq.pop();
         pq.pop();
       }else{
           cout<<pq.front()<<' '<<miq.front()<<endl;
           pq.push(pq.front()-miq.front());
           miq.pop();
           pq.pop();
       }
   }   

 
   

      return 0;

}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

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

    int n;
    cin >> n;

    vector<string> v;
    string str;

    cin >> str;
    v.PB(str);
    FOR(i,1,n){
        cin >> str;
            
        if (find(ALL(v), str) != v.end())
        {
            cout << "No";
            return 0;
        }
        v.PB(str);
        
        
        if (v[i - 1][v[i - 1].length() - 1] != v[i][0])
        {
            cout << "No";
            return 0;
        }
        
        //dump(v[i - 1][v[i - 1].length()-1])
        //dump(v[i][0])
        
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
llint mod = 1000000007;

int main() {
  llint n, m;
  cin >> n >> m;
  n %= m;
  llint l = m - n;
  if (l > n) {
    printf("%lld\n", n);
  }
  else {
    printf("%lld\n", l);
  }
} 

Measured memory_bytes: 256
///
// File:  d.cpp
// Author: ymiyamoto
//
// Created on Sun Dec 17 22:47:43 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int32_t main()
{
  string str;
  cin >> str;

  int32_t X, Y;
  cin >> X >> Y;

  vector<int32_t> xnums;
  vector<int32_t> ynums;
  int32_t fnum = 0;
  bool isx = true;
  for (auto s : str) {
    if (s == 'F') {
      fnum++;
    } else {
      if (isx) {
        xnums.push_back(fnum);
        isx = false;
      } else {
        ynums.push_back(fnum);
        isx = true;
      }
      fnum = 0;
    }
  }
  if (isx) {
    xnums.push_back(fnum);
  } else {
    ynums.push_back(fnum);
  }

  vector<vector<bool>> dpx(xnums.size(), vector<bool>(16001, false));
  dpx[0][8000 + xnums[0]] = true;
  for (uint32_t i = 1; i < xnums.size(); i++) {
    for (int32_t x = 0; x < 16001; x++) {
      bool left = false;
      if (0 <= x - xnums[i]) {
        left = dpx[i - 1][x - xnums[i]];
      }
      bool right = false;
      if (x + xnums[i] < 16001) {
        right = dpx[i - 1][x + xnums[i]];
      }
      dpx[i][x] = left || right;
    }
  }

  vector<vector<bool>> dpy(ynums.size(), vector<bool>(16001, false));
  if (ynums.size() > 0) {
    dpy[0][8000 - ynums[0]] = true;
    dpy[0][8000 + ynums[0]] = true;
    for (uint32_t i = 1; i < ynums.size(); i++) {
      for (int32_t y = 0; y < 16001; y++) {
        bool left = false;
        if (0 <= y - ynums[i]) {
          left = dpy[i - 1][y - ynums[i]];
        }
        bool right = false;
        if (y + ynums[i] < 16001) {
          right = dpy[i - 1][y + ynums[i]];
        }
        dpy[i][y] = left || right;
      }
    }
  }

  if (dpx[dpx.size() - 1][X + 8000]) {
    if (ynums.size() == 0 || (ynums.size() > 0 && dpy[dpy.size() - 1][Y + 8000])) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


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

int main(void){
  while(true){
    int n, w, d;
    cin >> n >> w >> d;
    if(n == 0 && w == 0 && d == 0){ break; }
    
    int p, s;
    vector<pair<int, int> > cake;
    cake.push_back(make_pair(w, d));
    for(int i = 0; i < n; i++){
      cin >> p >> s;
      --p;
      s %= (cake[p].first + cake[p].second);
      pair<int, int> a, b;
      if(s < cake[p].first){
        a = make_pair(s, cake[p].second);
        b = make_pair(cake[p].first - s, cake[p].second);
      }
      else{
        a = make_pair(cake[p].first, s - cake[p].first);
        b = make_pair(cake[p].first, cake[p].second - (s - cake[p].first));
      }

      cake.erase(cake.begin() + p);
      if(a.first * a.second > b.first * b.second){ swap(a, b); }
      cake.push_back(a);
      cake.push_back(b);
    }

    vector<int> cakesize;
    for(size_t i = 0; i < cake.size(); i++){ cakesize.push_back(cake[i].first * cake[i].second); }
    sort(cakesize.begin(), cakesize.end());
    for(size_t i = 0; i < cakesize.size(); i++){
      if(i != 0){ cout << " "; }
      cout << cakesize[i];
    }
    cout << endl;
  }
  
  return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }

ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }


int main(){
    ll l,r;
    cin >> l >> r;
    if(abs(r-l) > 2019) cout << 0 << endl;
    else{
        ll ans = 2018;
        rep(i,l,r+1){
            rep(j,i+1,r+1){
                ans = min(ans,(i*j)%2019);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)i
typedef long long ll; 

using namespace std;


ll      keta(ll num)
{
    ll      res = 1;
    while (num >= 10) 
    {   
        res++;
        num /= 10; 
    }   
    return res;
}

int     main()
{
    ll N; cin >> N;
    ll res = keta(N);
    ll j = 0;

    for (ll i = 1; i * i <= N; i++)
    {   
        if (N % i != 0) continue;
        j = N / i;
        res = min(res, max(keta(i), keta(j)));
        //cout << res << " " << i << " " << j << endl;
    }   
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#define MAX 16

using namespace std;

int main(void){
	while( true ){
		int i,j;
		int n;
		int crrNum = 1;
		int jin[MAX][MAX] = {0,};
		
		cin >> n;
		if( n == 0 ) break;

		/* Indian method */
		i = n/2+1, j = n/2;
		jin[i][j] = crrNum++;
		while(true){
			int tmpi = i, tmpj = j;
			i++;
			j++;
			if( i >= n ) i = 0;
			if( j >= n ) j = 0;

			if( jin[i][j] != 0 ){
				if( i + 1 >= n ) i = 0; else i++;
				if( j - 1 < 0 ) j = n - 1; else j--;
				if( jin[i][j] != 0 ) break;
				else jin[i][j] = crrNum++;
			}else jin[i][j] = crrNum++;	
		}

		//output
		for(i = 0; i < n; i++){
			for(j = 0; j < n; j++){
				printf("%4d",jin[i][j]);
			}
			cout << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x,y,a,b;
    COMinit();
    cin>>x>>y;
    if((x-2*y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    if((x-2*y)%3==0){
        a=(2*y-x)/3;
        b=(2*x-y)/3;
    }
    cout<<COM(a+b,a)<<endl;
    return 0;
}


Measured memory_bytes: 25984
#include <iostream>
#include <string>
using namespace std;
int main() {
  string N;
  int keep = -1;
  int count = 1;

  cin >> N;
 
  for (int i=0; i < N.length(); i++){
      if (keep==N[i]){ 
        count ++;
        if (count==3){
          cout << "Yes" << endl;
          return 0;
        }
      }
      else {
        keep = N[i];
        count = 1;
      }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
<?php

$S = trim(fgets(STDIN));
$day_of_the_week_array = array("SUN"=>7,"MON"=>6,"TUE"=>5,"WED"=>4,"THU"=>3,"FRI"=>2,"SAT"=>1);

echo($day_of_the_week_array[$S])."\n";

?>

Measured memory_bytes: 15948
#include "bits/stdc++.h"
using namespace std;

long long nijou(int n){ return (long long)n * (long long)n; }

int main(){
  
  int N,D;
  int* X;
  int* Y;
  cin >> N >> D;
  X = new int[N];
  Y = new int[N];
  for(int i=0;i<N;i++)
    cin >> X[i] >> Y[i];
  
  long long D2 = nijou(D);
  int cnt = 0;
  for(int i=0;i<N;i++){
    if(nijou(X[i]) + nijou(Y[i]) <= D2){
      cnt++;
    }
  }
  
  cout << cnt;
  delete[] X;
  delete[] Y;
  return 0;
}

Measured memory_bytes: 4828
n,m = list(map(int,input().split()))
b = [0 for i in range(m)]
for i in range(n):
  ka = list(map(int,input().split()))
  k = ka[0]
  a = ka[1:]
  for j in range(k):
    b[a[j]-1] += 1
c = 0
for i in range(m):
  if b[i] == n:
    c += 1
print(c)


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Integer N = scanner.nextInt();
        Integer M = scanner.nextInt();
        Integer[] inputList = new Integer[N];
        Integer sum = 0;

        for (Integer i = 0; i < N; i++) {
            Integer vote = scanner.nextInt();
            inputList[i] = vote;
            sum += vote;
        }

        Arrays.sort(inputList, Collections.reverseOrder());
        if (inputList[M - 1] * 4 * M >= sum) {
            System.out.println("Yes");
        } else {
            System.out.print("No");
        }
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(){
int a,b,c,n,max,w;
while(scanf("%d %d %d",&a,&b,&c),a||b||c){
max=1000000000;
if(max>a*a+b*b)
max=a*a+b*b;
if(max>b*b+c*c)
max=b*b+c*c;
if(max>a*a+c*c)
max=a*a+c*c;
scanf("%d",&n);
while(n-->0){
scanf("%d",&w);
if(max<4*w*w)
printf("OK\n");
else printf("NA\n");
}
}
return 0;
}

Measured memory_bytes: 0
x1,y1,x2,y2 = map(int,input().split())

x3 = x2 - y2 + y1
y3 = y2 + x2 - x1
x4 = x3 - x2 + x1
y4 = y3 - y2 + y1
print("{} {} {} {}".format(x3,y3,x4,y4))

Measured memory_bytes: 2940
function myOut(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = input.split(" ");
	input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var len = parseInt(input[0]);
  var list = input[1].split(" ").map((a)=>Number(a));
  var max = 0;
  var output = 0;
  for(var i = 0; i < len; i++){
    if(max <= list[i]){
       max = list[i];
      output++;
       }
  }
      myOut(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;


int main(){
  int n; string s;
  cin >> n >> s;
  int ans = 0;
  int now = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'D') now--;
    else now++;
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int x[30][30];

int main()
{
	int res, n, d, s, a, i, j, k;
	cin>>n>>d;
	for (i=0; i<n; i++) for (j=0; j<d; j++) cin>>x[i][j];
	res = 0;
	for (i=0; i<n-1; i++)
		for (j=i+1; j<n; j++)
		{
			s = 0;
			for (k=0; k<d; k++) s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			a = sqrt(s) + 0.5;
			if (a * a == s) res ++;
		}
	cout<<res<<endl;	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll g(ll a, ll b){
	if(a < b) return g(b,a);
	if(a==0) return b;
	if(b==0) return a;
	else if(a%b==0) return b;
	else return g(b,a%b);
}

int main(){
	int n;
	ll k;
	cin >>n >> k;
	ll a[n];
	ll max1=0;
	FOR(i,n) {
		cin >> a[i];
		max1=max(max1,a[i]);
	}
	ll gcd=a[0];
	for(ll j=1;j<n;j++){
		gcd=g(gcd,a[j]);
	}
	//cout << gcd;
	if(k%gcd==0 && max1 >=k) cout << "POSSIBLE";
	else cout << "IMPOSSIBLE";


	return 0;
}

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

int main() {
    int p; cin >> p;
    int MAX_N=100099;

    // エラトステネスのふるい
    bitset<100100> is_prime(0); // 十分大きなサイズを確保します
    for (int i = 2; i <= MAX_N; ++i) is_prime.set(i); // とりあえず全部ふるいに入れます
    for (int i = 2; i <= MAX_N; ++i) {
        if (is_prime[i]) { // 素数 i を発見したら
            for (int j = i * 2; j <= MAX_N; j += i) {
                is_prime.reset(j); // i の倍数をふるい落とす
            }
        }
    }
    
    for(int i=p;i<MAX_N;++i){
        if(is_prime[i]){
        cout<<i<<endl;
        break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<cstdint>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<vector>
#include<string>
#include<list>
#include<deque>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
LL t[101];
int n;
LL gcd(LL a,LL b){
     if(a<b){
    LL tmp = a;
    a = b;
    b = tmp;
  }

    LL r=a%b;
    
    while(r){
    a=b;
    b=r;
    r=a%b;
    }
    return b;
}
LL lcm(LL a,LL b){
    LL g=gcd(a,b);
    return a/g*b;
}

int main(){
    LL a,b;
cin>>n>>a;
for(int i=1;i<n;i++){
    cin>>b;
    a=lcm(a,b);
}
cout<<a<<endl;
}

Measured memory_bytes: 256
n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

def binary_search(n,S,data):
    left=0
    right=n
    mid=int((left+right)/2)
    while left<right:
        if S[mid]==data:
            return True

        elif data<S[mid]:
            right=mid
            mid=int((left+right)/2)

        elif data>S[mid]:
            left=mid+1
            mid=int((left+right)/2)

    return False

answer=0
for i in range(q):
    if binary_search(n,S,T[i]):
        answer+=1

print(answer)



Measured memory_bytes: 16708
/*
ID: usaco.t3
TASK: test
LANG: C++14
*/

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _CRT_SECURE_NO_WARNINGS
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define pii pair<intt,intt>
#define vi vector<intt>
#define vii vector<pii>

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();
#define endl '\n'

#define wtfis(x) cerr << "at line " << __LINE__ << ": " << #x << " = " << (x) << endl

const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;
const intt INFLL = 9LL * 1000000000 * 1000000000;
/***************/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    IO;
    int n;
    cin >> n;
    cout << lcm(n, 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int N;
  int Y;
  cin >> N >> Y;
  
  int res10000 = -1, res5000 = -1 , res1000 = -1;
  for(int a =0 ; a <= N ; ++a){
  	for(int b =0 ; b +a <= N  ; ++b){
      int c = N -a -b;
      int total = 10000*a + 5000*b + 1000*c;
      if(total == Y){
        res10000=a;
        res5000=b;
        res1000=c;
      }
    }
  }
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define foreach(c,itr) for(__typeof(c)::iterator itr=c.begin();itr!=c.end();itr++)
typedef long long ll;
typedef long double ld;
int i,j;

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

    string s;
    cin>>s;
    if(s[s.size()-1]!='s')cout<<s<<'s'<<endl;
    else cout<<s<<"es"<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main(void){
  char x,y;
  cin>>x>>y;
  int X = x;
  int Y = y;
  if(X>Y)cout<<">"<<endl;
  else if(X<Y)cout<<"<"<<endl;
  else cout<<"="<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
S = list()
for _ in range(n):
    S.append(int(input()))
point = sum(S)
if point % 10 == 0:
    S.sort()
    for s in S:
        if s % 10 != 0:
            point -= s
            break
    else:
        point = 0
print(point)


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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	int n;
	while(cin>>n){
		int maxi=-1;
		if(n==0)break;

		string data[2000];
		rep(i,n){
			cin>>data[i];
		}

		int dp[1010][1010]={};
		rep(i,n){
			rep(j,n){
				if(data[i][j]=='*')dp[i][j]=0;
				else{
					if( i-1>=0 && j-1>=0 )
						dp[i][j] = min( dp[i-1][j] , min( dp[i][j-1] , dp[i-1][j-1] ) ) +1;
					else dp[i][j]=1;
				}
				maxi=max( dp[i][j] , maxi );
			}
		}
		cout<<maxi<<endl;
	}
	return 0;
}

Measured memory_bytes: 6256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#define N_MAX 105
#define X_MAX 10010
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<double,P > P1;
void dijkstra();
double Cal(int,int);
int n,a[N_MAX],r;
double b,v,e,f,dp[X_MAX][N_MAX];

int main(){
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;i++) cin>>a[i];
    cin>>b>>r>>v>>e>>f;
    dijkstra();
  }
  return 0;
}

void dijkstra(){
  for(int i=0;i<X_MAX;i++)
    for(int j=0;j<n;j++) dp[i][j]=INF;
  priority_queue<P1,vector<P1>,greater<P1> > Q;
  dp[0][0]=Cal(0,a[0]);
  Q.push(make_pair(dp[0][0],make_pair(a[0],1)));
  while(!Q.empty()){
    P1 v=Q.top();
    Q.pop();
    double t=v.first;
    int uy=v.second.first,ux=v.second.second;
    int ncny=uy+a[ux]-a[ux-1];
    double nccal=Cal(uy,ncny);
    if(ncny<0) continue;
    if(dp[ncny][ux]>t+nccal){
      dp[ncny][ux]=t+nccal;
      if(ux!=n-1) Q.push(make_pair(dp[ncny][ux],make_pair(ncny,ux+1)));
    }
    int cny=a[ux]-a[ux-1];
    if(cny<0) continue;
    double ccal=Cal(0,cny)+b;
    if(dp[cny][ux]>t+ccal){
      dp[cny][ux]=t+ccal;
      if(ux!=n-1) Q.push(make_pair(dp[cny][ux],make_pair(cny,ux+1)));
    }
  }
  double mincost=INF;
  for(int i=0;i<=a[n-1];i++) mincost=min(mincost,dp[i][n-1]);
  printf("%.4f\n",mincost);
}

double Cal(int begin,int end){
  double ret=0;
  for(int i=begin;i<end;i++){
    if(i>=r) ret+=1.0/(1.0*v-1.0*e*(1.0*i-1.0*r));
    else ret+=1.0/(1.0*v-1.0*f*(1.0*r-1.0*i));
  }
  return ret;
}

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

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

    vector<int64_t> A(K);
    for(int i = 0; i < K; ++i){
        cin >> A[i];
    }

    int64_t mi = 2;
    int64_t ma = 2;
    for(int i = K - 1; i > 0; --i){
        if(mi % A[i] != 0){
            mi -= mi % A[i];
        }
        if(ma % A[i] != A[i] - 1){
            ma += A[i] - (ma % A[i]) - 1;
        }
        if(mi % A[i-1] != 0){
            mi += A[i-1] - (mi % A[i-1]);
        }
        if(ma % A[i-1] != 0){
            ma -= ma % A[i-1];
        }
    }
    if(mi % A[0] != 0){
        mi -= mi % A[0];
    }
    if(ma % A[0] != A[0] - 1){
        ma += A[0] - (ma % A[0]) - 1;
    }

    if(mi > ma || mi < 2 || ma < 2){
        cout << -1 << endl;
    }
    else {
        cout << mi << " " << ma << endl;
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int a;
	string s;
	cin >> a >> s;

	if (a >= 3200)cout << s << endl;
	else cout << "red" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int a[1000];
int card[2000];
int x[2000],y[2000];
int n,m;
int hoge=0;

void kat(){
    int i,j=1;
    for(i = 1;i <= hoge; i++)x[i] = card[i];
    for(i = 1+hoge; i <= 2*n; i++){
        y[j] = card[i];
        j++;
    }
    j=1;
    for(i = 1;i <= (2*n)-hoge; i++)card[i] = y[i];
    for(i = (2*n)-hoge+1; i <= 2*n; i++){
        card[i] = x[j];
        j++;
    }
}
void rfl(){
    int i,j=1;
    for(i = n+1;i <= n*2; i++){
        y[j] = card[i];
        j++;
    }
    for(i = 1;i <= n; i++)x[i] = card[i];
    j=1;
    for(i = 1;i <= (2*n)-1; i+=2){
        card[i] = x[j];
        j++;
    }
    j=1;
    for(i = 2;i <= 2*n; i+=2){
        card[i] = y[j];
        j++;
    }
}
int main(void)
{
    int i;
    scanf("%d%d",&n,&m);
    for(i = 1;i <= 2*n; i++)card[i] = i;
    for(i = 0;i < m; i++){
        scanf("%d",&a[i]);
        if(a[i] != 0){
            hoge = a[i];
            kat();
        }
        else if(a[i] == 0) rfl();
    }
    for(i = 1;i <= 2*n; i++)printf("%d\n",card[i]);
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 100;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c)
{
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    vector<int> A(M);
    vector<int> B(M);
    vector<int> C(M);
    for (int i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--;
        B[i]--;
        dist[A[i]][B[i]] = C[i];
        dist[B[i]][A[i]] = C[i];
    }

    warshall_floyd(N);

    int ans = 0;

    for (int i = 0; i < M; i++)
    {
        if(C[i] > dist[A[i]][B[i]])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

int main () {
  int n, a;

  vector<int> a1,a2;
  cin >> n;

  REP(i, n) {
    cin >> a;
    a1.push_back(a);
  }

  REP(i, n) {
    cin >> a;
    a2.push_back(a);
  }
  int result = 0;
  REP(i, n) {
    int acc = 0;
    REP(j, n) {
      if (i==j) acc += a1[j] + a2[j];
      else if(i > j) acc += a1[j];
      else acc += a2[j];
    }

    result = max(result, acc);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<int> l(n);
    rep(i, n) scanf("%d", &l[i]);

    sort(l.begin(), l.end());
    LL ans = 0;
    rep(i, n) {
        loop(j, i + 1, n) {
            int k = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
            ans += max(k - (j + 1), 0);
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int gcd(int,int);
int main(){
  int a,b;
  scanf("%d %d", &a, &b);
  printf("%d\n",gcd(a,b));

  return 0;
}
  gcd(int x,int y){
    return y ? gcd(y,x%y) : x;
  }



Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    string S;
    cin >> S;
    
    // calculation
    REP(i, 6) {
        if (S.substr(0, i+1) + S.substr(S.length()-6+i) == "keyence") {
            cout << "YES" << "\n";
            return 0;
        } 
    }
    cout << "NO" << "\n";
    return 0;
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int h, w;
  cin >> h >> w;

  char buf[105];
  for(int i=0; i<h; ++i){
    cin >> buf;
    cout << buf << endl;
    cout << buf << endl;
  }
}

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

int main() {
 int num;
 cin >> num;
  
 int temp;
 temp = num * 100 / 108;
 if(temp * 108 / 100 == num ) {
   cout << temp << endl;
 } else if( (temp + 1) * 108 / 100 == num) {
   cout << temp + 1 << endl;
 } else {
   cout << ":(" << endl;
 }
 
 return 0; 
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int32> a(n+1);
  REP(i,n+1)cin >> a[i];

  if(n == 0){
    if(a[0] == 1){
      ANS(1);
    }else{
      ANS(-1);
    }
    return 0;
  }
  
  if(n == 1){
    if(a[0] != 0){
      ANS(-1);
      return 0;
    }
    if(a[1] == 1){
      ANS(2);
    }else if(a[1] == 2){
      ANS(3);
    }else{
      ANS(-1);
    }
    return 0;
  }

  vector<int32> asum(n+1,0);
  asum[n] = a[n];
  FORR(i,n-1,0)asum[i] = asum[i+1] + a[i];
  int64 cnt = 1 - a[0];
  int64 ans = cnt;
  if(cnt < 0){
    ANS(-1);
    return 0;
  }
  FOR(i,1,n+1){
    cnt = min(cnt * 2, asum[i]);
    ans += cnt;
    cnt -= a[i];
    if(cnt < 0){
      ANS(-1);
      return 0;
    }
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 4784
n, m, x, y = list(map(int, input().split()))

x_ = list(map(int, input().split()))
y_ = list(map(int, input().split()))

if max(x_) > x:
    max_x = max(x_)
else:
    max_x = x

if min(y_) > y:
    min_y = y
else:
    min_y = min(y_)


if max_x < min_y:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1LL<<(x))
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 400005
#define nm 1000005
#define N 1000005
#define M(x,y) x=max(x,y)
const double pi=acos(-1);
const int inf=1e9+7;
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}


struct FastIO
{
    static const int S=200;
    int wpos;
    char wbuf[S];
    FastIO():wpos(0){}
    inline int xchar()
    {
        static char buf[S];
        static int len=0,pos=0;
        if(pos==len) pos=0,len=fread(buf,1,S,stdin);
        if(pos==len) exit(0);
        return buf[pos++];
    }
    inline int read()
    {
        int s=1,c=xchar(),x=0;
        while(c<=32) c=xchar();
        if(c=='-') s=-1,c=xchar();
        for(;'0'<=c&&c<='9';c=xchar()) x=x*10+c-'0';
        return x*s;
    }
    ~FastIO()
    {
        if(wpos) fwrite(wbuf,1,wpos,stdout),wpos=0;
    }
}io;

struct edge{int t,v;edge*next;}e[nm],*h[NM],*o=e;
void add(int x,int y,int v){o->v=v;o->t=y;o->next=h[x];h[x]=o++;}
int n,m,cnt,tot,c[NM],b[NM],f[NM],d[NM];
bool v[NM];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
struct TT{
    int x,y,v;
    bool operator<(const TT&o){return v<o.v;}
}a[nm];
queue<int>q;
void spfa(){
    inc(i,2,cnt)d[i]=inf;q.push(1);mem(v);v[1]++;
    while(!q.empty()){
    int t=q.front();q.pop();v[t]=false;
    link(t)if(d[j->t]>d[t]+j->v){
        d[j->t]=d[t]+j->v;
        if(!v[j->t])v[j->t]++,q.push(j->t);
    }
    }
}

int main(){
    //freopen("data.in","r",stdin);
    n=io.read();m=io.read();
    mem(e);mem(h);o=e;
    inc(i,1,m){a[i].x=io.read();a[i].y=io.read();a[i].v=io.read();}
    sort(a+1,a+1+m);cnt=n;
    inc(i,1,m){
        int t=i;while(a[i].v==a[t].v&&t<=m)t++;t--;
        tot=0;
        inc(j,i,t){c[++tot]=a[j].x;c[++tot]=a[j].y;}
        sort(c+1,c+1+tot);
        tot=unique(c+1,c+1+tot)-c-1;
        inc(j,1,tot)f[c[j]]=c[j],b[c[j]]=0,v[c[j]]=false;
        inc(j,i,t){
        int x=find(a[j].x),y=find(a[j].y);
        if(x==y)continue;
        f[x]=y;
        }
        inc(j,1,tot){
        int x=find(c[j]);
        if(v[c[j]])continue;
        v[c[j]]++;
        if(!b[x])b[x]=++cnt;
        add(c[j],b[x],1);add(b[x],c[j],0);
        //printf("%d %d %d\n",c[j],b[x],1);
        //printf("%d %d %d\n",b[x],c[j],0);
        }
        i=t;
    }
    spfa();
    if(d[n]==inf)printf("-1\n");else printf("%d\n",d[n]);
    return 0;
}


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

using namespace std;

using ll=long long ;
void solve() {
    ll n,k;
    cin >> n >> k;
    ll res;
    if (k&1) {
        ll x=n/k;
        res = x*x*x;
    } else {
        ll x=n/k;
        res =x*x*x;
        x = n/(k/2) - n/k;
        res +=x*x*x;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int num[100001]={0},n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>num[i];
	sort(num+1,num+1+n);
	for(int i=1;i<=n;i++)
	{
		if(num[i]==num[i+1])
		{
			num[i]=0;
			num[i+1]=0;
			i++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(num[i]!=0) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    
    vector<pair<char, int>> P;
    pair<char, int> p = {S[0], 1};
    REP(i, 1, N) {
        if (S[i] == p.first) {
            p.second++;
        } else {
            P.push_back(p);
            p = {S[i], 1};
        }
    }
    P.push_back(p);

    vector<int> sums(P.size() + 1, 0);
    REP(i, 0, P.size()) sums[i + 1] += sums[i] + P[i].second;

    int ans = 0;
    REP(i, 0, P.size()) {
        int j = min((int)P.size(), i + K * 2);
        // cout << "# i : " << i << ", j : " << j << endl;
        int cur = sums[j] - sums[i];
        // cout << "--> cur : " << cur << endl;
        if (i > 0 && P[i].first == '0') cur += P[i - 1].second;
        // cout << "--> cur : " << cur << endl;
        if (j - 1 < (int)P.size() - 1 && P[j - 1].first == '0') cur += P[j].second;
        // cout << "--> cur : " << cur << endl;
        ans = max(ans, cur);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int cnt = 0;
  for (int i = 0; i < (int) S.size(); i++) {
    if (S.at(i) != T.at(i)) cnt++;
  }
  cout << cnt << "\n";
}

Measured memory_bytes: 3912
def generate(num):
    n = int(str(num)[-1])
    if n != 0:
        yield num * 10 + n - 1
    yield num * 10 + n
    if n < 9:
        yield num * 10 + n + 1

k = int(input())
lunlun = [i for i  in range(1, 10)]
p = 0
while len(lunlun) < k:
    for l in generate(lunlun[p]):
        lunlun.append(l)
    p += 1
print(lunlun[k - 1])

Measured memory_bytes: 7252
n = int(input())
A = [*map(int, input().split())]
def solve():
    MAX_A = 10**6 + 1
    C = [0] * MAX_A
    for a in A: C[a] += 1
    pairwise = True
    if sum(C[2:MAX_A:2]) > 1: pairwise = False
    for i in range(3, MAX_A, 2):
        if sum(C[i:MAX_A:i]) > 1: pairwise = False
    if pairwise: return 'pairwise'
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    if g == 1: return 'setwise'
    return 'not'
print(solve(), 'coprime')


Measured memory_bytes: 126684
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    REP(i, n){
        cin >> l[i];
    }

    int count = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                int tmp = max(max(l[i], l[j]), l[k]);
                if(2 * tmp < l[i] + l[j] + l[k]){
                    count++;
                }
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <iostream>
#include <vector>
#include <cmath>
#include <list>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
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*(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;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	string f;
	cin >> f;
	std::list<char> ans;
	char a[100000];
	f.copy(a, f.size());
	for (int i = 0; i < f.size(); i++)
	{
		ans.push_back(a[i]);
	}
	int q;
	cin >> q;
	bool revser = false;
	for (int i = 0; i < q; i++)
	{
		char mo;
		cin >> mo;
		if (mo == '1')
		{
			revser = !revser;
		}
		else
		{
			char a, b;
			cin >> a >> b;
			bool m1 = a == '1';
			if ((m1 && !revser) || (!m1 && revser))
			{
				ans.push_front(b);
			}
			else
			{
				ans.push_back(b);
			}
		}
	}

	if (!revser)
	{
		std::for_each(ans.cbegin(), ans.cend(), [](char x) {
			std::cout << (char)x;
			});
	}
	else
	{
		decltype(ans)::reverse_iterator i = ans.rbegin();
		decltype(ans)::reverse_iterator last = ans.rend();

		for (; i != last; ++i) {
			std::cout << (char)*i;
		}
	}
}


Measured memory_bytes: 41344
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i
answer = 0

(0..A).each do |a|
  (0..B).each do |b|
    (0..C).each do |c|
      answer += 1 if a * 500 + b * 100 + c * 50 == X
    end
  end
end

puts answer

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



int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int ans;
    ans=A-B;
    ans=abs(ans);
    if(ans%2==0)cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;


    }

    



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

int main(){
char s[3];
	for(int i=0;i<3;i++){
		cin>>s[i];
	
	}	
	
	if(s[0]!=s[1]||s[0]!=s[2]||s[1]!=s[2])
	{
		cout<<"Yes"<<endl;
	} 
	else
	{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[3009][3009];
ll b[200003];
ll n,m;
bool vis[1009][1009];
struct threeElements{
int _1st,_2nd,_3rd;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:15
   string s;
   cin>>s;
   int idx,idx1;
   for(int i=0;i<s.length();i++)
   {
       if(s[i]=='A')
       {
           idx=i;
           break;
       }
   }
   for(int i=0;i<s.length();i++)
   {
       if(s[i]=='Z')
       {
           idx1=i;
       }
   }
   cout<<idx1-idx+1
   ;
}


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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		//int res = 0; ;
		int t = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = int.Parse(Console.ReadLine());

		//int num = vals[0];


		int res = 0;

		if ( t % 2 == 0 ) {
			res = ( t / 2 ) * ( t / 2 );
		} else {
			res = ( t / 2 ) * ( ( t + 1 ) / 2 );
		}


		Console.WriteLine(res);

		return;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
		return nums;
	}
	
	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 11092
#include<stdio.h>
int main(void){
    int house[4][3][10] = {{{}, {}, {}},{{}, {}, {}},{{}, {}, {}},{{}, {}, {}}};
    int b,f,t,v,i,j,k,N;

    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d %d %d %d", &b, &f, &t, &v);
        house[b-1][f-1][t-1] += v;
    }

    for(i = 0; i < 4; i++){
        for(j = 0; j < 3; j++){
            for(k = 0; k < 10; k++){
                printf(" %d", house[i][j][k]);
            }
            printf("\n");
        }
        if(i < 3) printf("####################\n");
    }

    return 0;
}


Measured memory_bytes: 2104