akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main(){
	int a;
  cin>>a;
	if (a < 1000){
		cout << "ABC" << endl;
	}
	else{
		cout << "ABD" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		int [] x = new int[110];
		int i = 0;
		int a = 0;
		
		while (cin.hasNext()){
			i = cin.nextInt();
			x[i]++;
		}
		
		for (i = 0; i < 100; i++){
			if (a < x[i]){
				a = x[i];
			}
		}
		for (i = 0; i < 100; i++){
			if (a == x[i]){
				System.out.println(i);
			}
		}
	}
}

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

#define ll long long
#define mod 100000000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n;
    cin>>n;
    int a[n+1];
    int b[n+1];
    int c[n];
    ffor(i,1,n+1) cin>>a[i];
    ffor(i,1,n+1) cin>>b[i];
    ffor(i,1,n) cin>>c[i];
    int ans=0;
    int prev=-1;
    ffor(i,1,n+1)
    {
        int index=a[i];
        ans+=b[index];
        if(prev==index-1) ans+=c[prev];
        prev=index;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
mod = 10**9 +7
N = int(input())
C = [input() for _ in range(N)]
dic ={}
lis = [1]
before =C.pop(0)
dic[before]=[0]

for i,s in enumerate(C):
    lis.append(lis[-1])
    if s in dic.keys():
        if s != before:
            lis[-1] += lis[dic[s][-1]+1]
            #for j in dic[s]:
            #    lis[-1] += lis[j]
            dic[s].append(i)
    else:
        dic[s] = [i]
    before = s
    lis[-1] = lis[-1]%mod
print(lis[-1])

Measured memory_bytes: 58584
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 11, 2020 3:22 PM
 *    Problem Name  : B - Papers, Please
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc155/tasks/abc155_b
 *    @genarated by : ai-virtual-assistant
**/

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

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

    int n;
    cin >> n ;

    int x,cnt=0;
    for(int i=0; i<n; i++){
        cin >> x;
        if(x%2 == 0){
            if(x%3!=0 && x%5!=0){
                cnt++;
            }
        }
    }

    if(cnt > 0) cout << "DENIED" << endl;   
    else cout << "APPROVED" << endl;

    return 0 ;
}


Measured memory_bytes: 3624
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
MOD = 10**9+7

s = input()
t = input()

sl = len(s)
tl = len(t)

dp = [[0 for _ in range(tl+1)]for _ in range(sl+1)]

for i in range(sl):
    for j in range(tl):
        if s[i] == t[j]: dp[i+1][j+1] = dp[i][j] + 1
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

ans = ''
while sl > 0 and tl > 0:
    if dp[sl-1][tl] == dp[sl][tl]:
        sl -= 1
    elif dp[sl][tl-1] == dp[sl][tl]:
        tl -= 1
    else:
        ans = s[sl-1] + ans
        sl -= 1
        tl -= 1
print(ans)
        


Measured memory_bytes: 125272
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Mod-Int
constexpr int MOD = 1000000007;
struct ModInt {
    ll val;
    ModInt() = default;
    ModInt(ll x) : val(x % MOD + (x < 0 ? MOD : 0)) {}
    ModInt &operator+= (const ModInt &x) {if ((val += x.val) >= MOD) val -= MOD; return *this;}
    ModInt &operator-= (const ModInt &x) {if ((val -= x.val) < 0) val += MOD; return *this;}
    ModInt &operator*= (const ModInt &x) {(val *= x.val) %= MOD; return *this;}
    ModInt operator+ (const ModInt &x) const {return ModInt(*this) += x;}
    ModInt operator- (const ModInt &x) const {return ModInt(*this) -= x;}
    ModInt operator* (const ModInt &x) const {return ModInt(*this) *= x;}
    ModInt pow(ll t) const {
        if (!t) return ModInt(1);
        ModInt m = pow(t / 2);
        m *= m;
        if (t & 1) m *= *this;
        return m;
    }
    ModInt inv() const {return pow(MOD - 2);}
    ModInt &operator/= (const ModInt &x) {return *this *= x.inv();}
    ModInt operator/ (const ModInt &x) const {return ModInt(*this) /= x;}
    friend istream &operator>> (istream &is, ModInt &x) {is >> x.val; return is;}
    friend ostream &operator<< (ostream &os, const ModInt &x) {os << x.val; return os;}
};

// Main
int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    rep(i, n) rep(j, n) cin >> a[i][j];
    
    vector<ModInt> memo(1 << n, ModInt(0));
    vector<bool> solved(1 << n, false);
    auto rec = [&](auto f, int s, int k) -> ModInt {
        if (solved[s]) return memo[s];
        if (s == 0) return ModInt(1);
        ModInt res(0);
        rep(i, n) {
            if (((s >> i) & 1) && a[k][i]) res += f(f, s ^ (1 << i), k + 1);
        }
        solved[s] = true;
        memo[s] = res;
        return res;
    };
    cout << rec(rec, (1 << n) - 1, 0) << "\n";
}


Measured memory_bytes: 19812
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
bool prime[100010];

int main(){
	int q;
	cin >> q;
	for(int i = 2; i <= 100005; i++){
		prime[i] = true;
	}
	for(int i = 2; i * i< 100005; i++){
		if(prime[i]){
			for(int j = i * 2; j < 100005; j += i){
				prime[j] = false;
			}
		}
	}
	vector<int> a(100001);
	for(int i = 1; i < a.size(); i++){
		a[i] += a[i - 1];
		if(i % 2 == 0 || !prime[i]) continue;
		if(prime[(i + 1) / 2]) a[i]++;
	}
	for(int i = 0; i < q; i++){
		int x, y;
		cin >> x >> y;
		cout << a[y] - a[x - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, a, b;
int p[110];

int solve() {
    int s0 = 0, s1 = 0, s2 = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] <= a) {
            s0++;
        } else if (p[i] <= b) {
            s1++;
        } else {
            s2++;
        }
    }
    return min(s0, min(s1, s2));
}

void input() {
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) cin >> p[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3160
#include<iostream>
using namespace std;
int main()
{ 
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int xx,yy;
    for(int i=0;i<n;i++)
    {
        cin>>xx;
        if(xx>x)
         x=xx;   
    }
    for(int i=0;i<m;i++)
    {      
         cin>>yy;
         if(yy<y) 
              y=yy;
    }  
   if(x<y) 
        cout<<"No War"<<endl; 
   else 
        cout<<"War"<<endl;
    return 0;
}


Measured memory_bytes: 256
a,b,q = map(int,input().split())
s = [-float('inf')]+[int(input()) for i in range(a)]+[float('inf')]
t = [-float('inf')]+[int(input()) for i in range(b)]+[float('inf')]
x = [int(input()) for i in range(q)]
import bisect
for x_ in x:
    s_r = bisect.bisect_right(s,x_)
    t_r = bisect.bisect_right(t,x_)
    res = float('inf')
    for S in [s[s_r-1],s[s_r]]:
        for T in [t[t_r-1],t[t_r]]:
            d1 = abs(S-x_)+abs(T-S)
            d2 = abs(T-x_)+abs(S-T)
            res = min(res,d1,d2)
    print(res)

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

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

Measured memory_bytes: 256
H,W=map(int,input().split())
S=[list(input()) for i in range(H)]

dx=[0, -1, 1]
dy=[0, -1, 1]

for i in range(H):
	for j in range(W):
		cnt=0
		if S[i][j]!="#":
			for x in dx:
				for y in dy:
					if 0<=i+y<H and 0<=j+x<W:
						if S[i+y][j+x]=="#":
							cnt+=1
			S[i][j]=str(cnt)				
		
for s in S:
	print("".join(s))


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

using namespace std;

vector<vector<array<int, 2>>> E;

int64_t dfs(int i, int goal, int from){
    if (i == goal)
        return 0;
    for (const auto &e: E[i]){
        if (e[0] == from)
            continue;
        auto res = dfs(e[0], goal, i);
        if (res >= 0)
            return res | (1L << e[1]);
    }
    return -1;
}

int main(){
    int n;
    cin >> n;
    E.resize(n);
    for (int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        E[a].push_back({b, i});
        E[b].push_back({a, i});
    }
    int m;
    cin >> m;
    vector<int> U(m), V(m);
    for (int i = 0; i < m; i++){
        cin >> U[i] >> V[i];
        U[i]--; V[i]--;
    }

    vector<int64_t> masks(m);
    for (int i = 0; i < m; i++){
        masks[i] = dfs(U[i], V[i], -1);
    }

    int64_t ans = (1L << (n - 1));
    for (int bits = 1; bits < (1 << m); bits++){
        int64_t mask = 0;
        for (int i = 0; i < m; i++){
            if (bits >> i & 1)
                mask |= masks[i];
        }
        int c = __builtin_popcount(bits) & 1 ? -1 : 1;
        ans += c * (1L << (n - 1 - __builtin_popcountl(mask)));
    }
    
    cout << ans << endl;
}

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

int main () {

  int n, x;

  while (cin >> n >> x) {
    int count = 0;
    if (n == 0 && x == 0) {
      break;
    }

    for (int i = 1; i <= n; i++) {
      for (int j = i+1; j <= n; j++) {
        for (int k = j+1; k <= n; k++) {
          if (i + j + k == x) {
            count++;
          }
        }
      }
    }

    cout << count << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    int tmp = INF;
    int cnt = 0;
    rep(i, n){
        int p;
        cin >> p;
        if(tmp >= p){
            tmp = p;
            cnt++;
        }
    }
    cout << cnt << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;


i64 comb(i64 n, i64 k) {
    i64 ret = 1;
    if (k > n/2) {
        k = n-k;
    }
    i64 a = 2;
    times(k, ki) {
        ret *= n-ki;
        if (a <= k && ret % a == 0) {
            ret /= a;
            if (a < k) {
                a++;
            }
            else {
                a = k+1;
            }
        }
    }
    while (a < k) {
        ret /= a;
        a++;
    }
    return ret;
}

i64 solve() {
     indef(i32, n, p);
     i64 cnt_odd = 0;
     i64 cnt_even = 0;
     times(n, i) {
         indef(i32, ai);
         if (even(ai)) {
             cnt_even++;
         }
         else {
             cnt_odd++;
         }
     }

     i64 ep = 0;
     upto(0, cnt_even, ce) {
         ep += comb(cnt_even, ce);
     }
     i64 op = 0;
     if (p == 0) {
         for (i64 co = 0; co <= cnt_odd; co += 2) {
             op += comb(cnt_odd, co);
         }
     }
     else {
         for (i64 co = 1; co <= cnt_odd; co += 2) {
             op += comb(cnt_odd, co);
         }
     }
     
     return ep * op;
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    cout << fixed << setprecision(9);
    out(solve());

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int N=2000;
typedef bitset<N> bs;

bs shl(const bs &x,int n,int c){
  bs y(x<<c);
  if(c>0)
    y|=x>>(n-c);
  y^=y>>n<<n;
  return y;
}

bs to_bitset(const string &a){
  bs ret;
  rep(i,a.length()){
    ret[i]=a[i]=='1';
  }
  return ret;
}

int f(const string &a,const string &b){
  int n=a.length();
  vector<bs> shift(n);
  bs ab=to_bitset(a),bb=to_bitset(b);
  rep(i,n){
    shift[i]=shl(bb,n,i)^ab;
  }
  if(!bb.any()){
    return ab.any()?1e8:0;
  }
  int ans=1e8;
  // full
  {
    int mi=1e8;
    rep(i,n){
      mi=min(mi,(int)shift[i].count()+min(i,n-i));
    }
    ans=min(ans,mi+n);
  }
  vector<bs>poss_neg(n);
  poss_neg[0]=bb;
  rep(i,n-1){
    poss_neg[i+1]=poss_neg[i]|shl(bb,n,n-i-1);
  }
  vector<bs>poss_pos(n);
  poss_pos[0]=bb;
  rep(i,n-1){
    poss_pos[i+1]=poss_pos[i]|shl(bb,n,i+1);
  }
  // O(n^2 * N/64)
  for(int k=-n+1;k<=n-1;++k){
    int imi=k<0?-k:0;
    int ima=k<0?n-1:n-k-1;
    int del=k<0?k+n:k;
    int bc=shift[del].count();
    int prev=n;
    for(int i=imi;i<=ima;++i){
      int p=min(prev,n-i-1),llim=max(0,k);
      while(p>=llim){
	bs poss=poss_neg[i]|poss_pos[p];
	if((shift[del]|poss)==poss){
	  p--;
	}else{
	  break;
	}
      }
      p++;
      if(p<n-i)
	ans=min(ans,2*i+2*p-abs(k)+bc);
      prev=p;
    }
  }
  return ans;
}

int main(){
  string a,b;
  cin>>a>>b;
  int ans=1e8;
  rep(i,1){
    ans=min(ans,f(a,b));
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
  }
  cout<<(ans==1e8?-1:ans)<<endl;
}


Measured memory_bytes: 1792
#include "iostream"
using namespace std;

int Teamkeisan(int c, int a, int n) {
	int team = 0;
	for (; n > 0; n--) {
		if ((c > 0) && (a > 0)) {
			team++;
			c--;
			a--;
		}
	}
	for (; a > 0; a--) {
		if ((c > 1) && (a > 0)) {
			team++;
			c-=2;
		}
	}
	return team + c / 3;
}



int main()
{
	int Q = 0;
	int c[100], a[100], n[100];
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> c[i] >> a[i] >> n[i];
	}
	for (int i = 0; i < Q; i++) {
		cout << Teamkeisan(c[i], a[i], n[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	ll n, a[100010], b[100010];
	cin >> n;
	REP(i, n) cin >> a[i] >> b[i];

	ll cnt = 0;
	for(int i = n-1;i >= 0;i--){
		if((a[i]+cnt) % b[i] == 0) continue;
		else{
			cnt = cnt + b[i] - (a[i]+cnt) % b[i];
		}
	}
	cout << cnt << endl;
	rtn 0;
}

Measured memory_bytes: 1792
#include <iostream>
 
using namespace std;
int main(){
  int n;
  cin >> n;
  if (n / 100 == 7 || n % 100/10 == 7 || n % 10 == 7)
    {
      cout << "Yes";
    }
    else
    {
      cout << "No";
    }
}


Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author ena000078
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        ArrayList<Integer> brList1 = new ArrayList<>();
        boolean[] ship = new boolean[N+1];
                
        for(int i=0;i<M;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(b == N){
                brList1.add(a);
            }else if(a == 1){
                ship[b] = true;
            }
        }
        
        String pos = "IMPOSSIBLE";
        for(int tBr1 : brList1){
            if (ship[tBr1]){
                pos = "POSSIBLE";
                break;
            }
        }
        System.out.println(pos);
    }
    
}


Measured memory_bytes: 95480
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;



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

	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	int maxx = -10000, minx = 10000;
	int x;
	rep(i, 0, N)
	{
		cin >> x;
		chmax(maxx, x);
	}
	rep(i, 0, M)
	{
		cin >> x;
		chmin(minx, x);
	}

	if (X < Y&& maxx < minx&&maxx < Y&&X < minx)
	{
		cout << "No War" << endl;
	}
	else
	{
		cout << "War" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    string s;cin>>s;
    vector<int> cnt(26,0);
    for(int i=0;i<(int)s.size();i++) cnt[(int)(s[i]-'a')]++;
    
    int ans=INF;
    for(int i=0;i<26;i++){
        int m=0;
        int l=0,r=0;
        for(int j=0;j<(int)s.size();j++){
            if(s[j]==(char)('a'+i)||j==(int)s.size()-1){
                l=r;
                r=j;
                m=max(m,max(r-l-(s[l]==s[r]?1:0),0));
            }
        }
        ans=min(ans,m);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace b
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var X = Console.ReadLine().Split(' ');
            int A = int.Parse(X[0]);
            int B = int.Parse(X[1]);
            int C = int.Parse(X[2]);
            int D = int.Parse(X[3]);
            while (true)
            {
                C = C - B;
                if(C <= 0)
                {
                    Console.WriteLine("Yes");
                    break;
                }
                A = A - D;
                if(A <= 0)
                {
                    Console.WriteLine("No");
                    break;
                }
            }
        }
    }
}


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

long long gcd(long long a,long long b)
{
	long long r=max(abs(a),abs(b));
	long long l=min(abs(a),abs(b));
	if (l==0LL)
	{
		return r;
	}
	return gcd(l,r%l);
}

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

int main(int argc, char const *argv[])
{
	long long n,m;
	cin>>n>>m;
	string s,t;
	cin>>s>>t;
	long long g=gcd(n,m),a=n/g,b=m/g;
	int f=1;
	for (long long i = 0; i < g; ++i)
	{
		long long l=i*a,r=i*b;
		if (s.at(l)!=t.at(r))
		{
			f=0;
		}
	}
	if (f)
	{
		cout<<lcm(n,m)<<endl;
	}
	else
	{
		cout<<"-1\n";
	}
	return 0;
}


Measured memory_bytes: 512
i,j,c,b,v,u,D[10000];main(N,K,T,U,V,L,x){
scanf("%d%d%d%d%d%d",&N,&K,&T,&U,&V,&L);
for(;i<N;i++)scanf("%d",&x),D[x]=1;
for(;j<L;b?v++,b--:u++,j++)if((c+=D[j])>K||c&&!b)c--,b=T*V;
printf("%f\n",1.*v/V+1.*u/U);
exit(0);}

Measured memory_bytes: 668
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

int main(void)
{
    int ans = 0;
    int n;
    int i;
    int f = 1;

    scanf("%d", &n);
    int t[n], x[n], y[n];
    scanf("%d%d%d", &t[0], &x[0], &y[0]);
    if ((t[0] < x[0] + y[0]) || (t[0] % 2) != ((x[0] + y[0]) % 2))
        f = 0;

    for (i = 1; i < n; i++)
    {
        scanf("%d%d%d", &t[i], &x[i], &y[i]);
        int tmp = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        if (((t[i] - t[i - 1]) < tmp) || (((t[i] - t[i - 1]) % 2) != (tmp % 2)))
            f = 0;
    }

    if (f == 1)
        puts("Yes");
    else
        puts("No");

    return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 605;

vector<int> G[maxn];

//LL path1[maxn];

double es[maxn];

int N,M,OK;


double dfs(int v,int ban){
    if(es[v] >= -0.5) return es[v];

    double &ret = es[v];

    int div = 0;
    double length = 0;

    double max_l = 0;

    for(auto a:G[v]){
        double k =  dfs(a,ban);
        if(k >= -0.01){
            div++;
            length += k + 1;
        }
        if(v == ban){
            max_l = max(max_l,k+1);
        }
    }

    if(v == ban){
        div--;
        length -= max_l;
    }

    if(!div) OK = 0;

    if(div) return (ret = length/div);
    return (ret = -0.3);
}


int main()
{
     cin >> N >> M;

    _for(i,0,M){
        int s,t;
        cin >> s >> t;
        G[s].PB(t);
    }

    _rep(i,0,N) es[i] = -1;
    es[N] = 0;

    double E = dfs(1,0);



    _rep(i,1,N-1){
        _rep(i,0,N) es[i] = -1;
        es[N] = 0;
        OK = 1;
        double e = dfs(1,i);
        if(e >= 0.1 && OK) E = min(E,e);
    }

    printf("%.10lf\n",E);

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
//Use above if bruteforcing with lots of small operations. Or just use it anytime, there's no downside.
//AVX is better slightly
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC



int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0);
    //ifstream cin ("test.in");
    ll a, b, n;
    cin >> a >> b >> n;
    cout << a * smin(n, (b-1)) / b;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
  int H, W;
  scanf("%d%d", &H, &W);
  int a[H][W];
  for (int i=0 ; i<H ; i++) {
    for (int j=0 ; j<W ; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int N = 0;
  vector<string> vc;
  for (int i=0 ; i<H ; i++) {
    for (int j=0 ; j<W-1 ; j++) {
      if (a[i][j] % 2 == 1) {
        a[i][j]--;
        a[i][j+1]++;
        N++;
        vc.push_back(to_string(i+1) + " " + to_string(j+1) + " " + to_string(i+1) + " " + to_string(j+2));
      }
    }
  }
  for (int i=0 ; i<H-1 ; i++) {
    if (a[i][W-1] % 2 == 1) {
      a[i][W-1]--;
      a[i+1][W-1]++;
      N++;
      vc.push_back(to_string(i+1) + " " + to_string(W) + " " + to_string(i+2) + " " + to_string(W));
    }
  }
  printf("%d\n", N);
  for (int i=0 ; i < vc.size() ; i++) {
    string str = vc[i];
    printf("%s\n", str.c_str());
  }
}

Measured memory_bytes: 11892
N,M,X = gets.chomp.split.map(&:to_i)
C = N.times.map{gets.chomp.split.map(&:to_i)}

bits = [0, 1].repeated_permutation(N).to_a
ans = 10**7

bits.each do |bit|
  rikaido = [0] * (M + 1) 
  (0..N-1).each do |j|
    if bit[j] == 1
      (0..M).each do |k|
        rikaido[k] += C[j][k]
        if rikaido[1..M].all? {|n| n >= X}
          ans = rikaido[0] if ans >= rikaido[0]
        end
      end
    end
  end
end

puts ans == (10**7) ? -1 : ans

Measured memory_bytes: 15576
#include<stdio.h>
int main(void)
{
	int i,j,n,r,x[100],w;
	char t[100],q[10];
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf(" %c",&t[i]);
			x[i]=0;
			for(j=0;j<n-1;j++){
				scanf("%d",&r);
				if(r==0) x[i]+=100;
				else if(r==2) x[i]++;
			}
		}
		for(i=0;i<n;i++){
			for(j=1;j<n;j++){
				if(x[j-1]<x[j]){
					w=x[j-1];
					x[j-1]=x[j];
					x[j]=w;
					q[0]=t[j-1];
					t[j-1]=t[j];
					t[j]=q[0];
				}
			}
		}
		for(i=0;i<n;i++) printf("%c\n",t[i]);
	}
	return 0;
}

Measured memory_bytes: 2732
#include<stdio.h>
int main(void)
{
	int a,x;
	scanf("%d",&a);
	x=0;
	if(a/100==1)x++;
	if(a/10==11||a/10==1)x++;
	if(a/1==111||a/1==101||a/1==11||a/1==1)x++;
	printf("%d\n",x);
	return 0;
}	

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

long long int f(long long int a)
{
  if(a%2==0)
  {
    a = ((a/2)%2 == 0 ? 0:1)^a;
  }
  else
  {
    a++;
    a = (a/2)%2 == 0 ? 0:1;
  }
  return a;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    long long int a,b;
    cin>>a>>b;
    long long int x_a = f(max(a-1,(long long int)0));
  	long long int x_b = f(b);
  //cout<<x_a<<" "<<x_b;
  	cout<<(x_b ^ x_a);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

void North(int* data)
{
	int tmp = data[5];
	data[5] = data[0];
	data[0] = data[2];
	data[2] = data[4];
	data[4] = tmp;
}

void East(int* data)
{
	int tmp = data[5];
	data[5] = data[3];
	data[3] = data[2];
	data[2] = data[1];
	data[1] = tmp;
}

void West(int* data)
{
	int tmp = data[5];
	data[5] = data[1];
	data[1] = data[2];
	data[2] = data[3];
	data[3] = tmp;
}

void South(int* data)
{
	int tmp = data[5];
	data[5] = data[4];
	data[4] = data[2];
	data[2] = data[0];
	data[0] = tmp;
}

void Right(int* data)
{
	int tmp = data[0];
	data[0] = data[1];
	data[1] = data[4];
	data[4] = data[3];
	data[3] = tmp;
}

void Left(int* data)
{
	int tmp = data[0];
	data[0] = data[3];
	data[3] = data[4];
	data[4] = data[1];
	data[1] = tmp;
}

int main()
{
	int n;
	while (cin >> n && n){
		int data[] = { 5, 4, 1, 3, 2, 6 };

		int ans = 0;
		FOR(i, n){
			ans += data[2];

			string a; cin >> a;
			
			if (a == "North"){
				North(data);
			}
			else if (a == "East"){
				East(data);
			}
			else if (a == "West"){
				West(data);
			}
			else if (a == "South"){
				South(data);
			}
			else if (a == "Right"){
				Right(data);
			}
			else if (a == "Left"){
				Left(data);
			}
		}
		ans += data[2];

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
li = []
ans = 0

for i in range(5):
    a = int(input())
    li.append(a)

tmp =  [(200 - li[0]) % 10, (200 - li[1]) % 10, (10 - li[2]) % 10, (10 - li[3]) % 10, (10 - li[4]) % 10]
max_i = tmp.index(max(tmp)) 

for i in range(5):
    if i == max_i:
        ans += li[i] 
    
    else:
        add = li[i] + ((10 - li[i]) % 10)
        ans += add

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int N, T;
	cin >> N >> T;

	vector<int> t(N);
	FOR(i, 0, N) cin >> t[i];

	lint ans = T;

	FOR(i, 1, N) {
	
		if (t[i] - t[i - 1] > T) ans += T;
		else ans += t[i] - t[i - 1];
	}

	cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int c[100010]; // c[i] : i, i+1を結ぶ道のコスト

int main(){
    int n, m;
    cin >> n >> m;

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        c[min(a,b)]++;
        c[max(a,b)]--;
    }
    rep(i, n) c[i+1] += c[i];

    bool flag = true;
    rep(i, n+1) flag &= (c[i]%2 == 0);

    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 640
s = input()

c = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "L":
      c = 1
  elif i % 2 == 1:
    if s[i] == "R":
      c = 1
if c == 1:
  print("No")
else:
  print("Yes")

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


int main(){
    int64_t n, d, a;
    cin >> n >> d >> a;
    vector<pair<int64_t, int64_t>> monster(n);

    for (int i=0; i<n; i++){
        int64_t x, h;
        cin >> x >> h;
        monster.at(i) = make_pair(x, h);
    }
    sort(monster.begin(), monster.end());
    
    int64_t ans = 0;

    vector<int64_t> powers(n);
    int c = 0;
    vector<int64_t> check(n);

    for (int i=0; i<n; i++){
        int64_t x = monster.at(i).first, h = monster.at(i).second;

        if (i > 0){
            powers.at(i) = powers.at(i-1) + check.at(i);
        }

        int64_t power = max((int64_t)0, (int64_t)ceil((double)(h - powers.at(i)) / (double)a));
        ans += power;

        powers.at(i) += power * a;
        check.at(i) += power * a;
        c = max(i+1, c);
        while (c < n){
            if (monster.at(c).first <= x + 2 * d){
                c++;
            }
            else{
                break;
            }
        }
        if (c < n){
            check.at(c) -= power * a;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    string str;
    while(cin >> str, str != "-")
    {
        int m; cin >> m;
        for(int i=0; i<m; ++i)
        {
            int h; cin >> h;
            str = str.substr(h)+str.substr(0,h);
        }
        cout << str << endl;
    }
}



Measured memory_bytes: 3216
// C - Big Array

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

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

	map<int, ll> cnt;

	int a, b;
	for (int i=0; i<N; i++) {
		cin >> a >> b;
		cnt[a] += b;
	}

	int ans;
	ll cum_cnt = 0;
	for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
		cum_cnt += itr->second;
		if (cum_cnt >= K) {
			ans = itr->first;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4224
#include <cstdio>
#include <iostream>
#include <set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  int n;
  cin >> n;
  ll a = 1;
  ll b = 1;
  
  REP(i, n) {
    ll x, y;
    cin >> x >> y;
    ll p = (a+x-1) / x;
    ll q = (b+y-1) / y;
    ll m = max(p, q);
    a = x * m;
    b = y * m;
  }

  cout << a+b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

string runlength(string s){
  int cnt = 0;
  char now=s.at(0);
  string vec="";
  REP(i,s.size()){
    if(s.at(i)==now){
      cnt++;
    }else{
      vec.push_back(now);
      vec.push_back(cnt+'0');
      cnt=1;
      now=s.at(i);
    }
  }
  vec.push_back(now);
  vec.push_back(cnt+'0');
  return vec;
}

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

  int cnt = 0;
  int now = 1;
  REP(i,S.size()){
    if(now==S.at(i)-'0'){
      cnt++;
    }else{
      vec.push_back(cnt);
      cnt=1;
      now=1-now;
    }
  }
  vec.push_back(cnt);
  if(S.at(N-1)=='0'){
    vec.push_back(0);
  }
  vector<int> vec2;
  vec2.push_back(0);
  int sum = 0;
  REP(i,vec.size()){
    sum+=vec.at(i);
    vec2.push_back(sum);
  }

  int MAX = 0;
  if(K>=(vec.size()-1)/2){
    cout << N << endl;
  }else{
    REP(i,vec2.size()){
      if(i%2==1&&i+K*2<=vec2.size()-1){
        MAX=max(MAX,vec2.at(i+K*2)-vec2.at(i-1));
      }
    }
    cout << MAX << endl;
  }
}

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

int main( void ) 
{
	char s[202],p[101];
	int i,j,k;
	int len=0;
	
	scanf( "%s", s );
	scanf( "%s", p );
	
	len=strlen( s );
	memmove( s+len, s, len+1 );	
	
	i=j=0;
	while( 1 ) {	
		if( p[0] == s[i] ) {
			j=0;
			k=i;	
			while( p[j] == s[k] ) {
				j++;
				k++;			
			 }
		 	if( '\0' == p[j] ) {
				printf( "Yes\n" );
				break;
			}		 
		} else {
			j=0;
		}
		if( '\0' == s[i++] ) {
			printf( "No\n" );	
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 532
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N, x;
  cin >> N >> x;

  if(x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  if(N == 2) {
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
    return 0;
  }

  int a[2 * N - 1];
  a[N - 1] = x;
  a[N] = x - 1;
  a[N - 2] = x + 1;
  if(x == 2) {
    a[N - 3] = x + 2;
  } else {
    a[N - 3] = x - 2;
  }

  int n = 1;
  REP(i, 2 * N - 1) {
    if(i >= N - 3 && i <= N) continue;
    if(x != 2) {
      if(n == x - 2) n = x + 2;
    } else {
      if(n == x - 1) n = x + 3;
    }
    a[i] = n;
    n++;
  }

  REP(i, 2 * N - 1) { cout << a[i] << endl; }
}


Measured memory_bytes: 2304
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int H, W;
char board[60][60];
 
signed main() {
    cin >> H >> W;
    rep(i,0,H) rep(j,0,W) cin >> board[i][j];

    bool ok = true;
    rep(i,0,H) rep(j,0,W) {
        if(board[i][j] == '.') continue;
        bool exist = false;
        rep(k,0,4) {
            int nx = i + dx[k], ny = j + dy[k];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            exist |= (board[nx][ny] == '#');
        }
        if(!exist) ok = false;
    }

    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
/*
---------------------------------
题解：
我还是太蒟了，没有想到能二分答案……
我们二分塔顶的值，把小于等于这个值的变为1，大于变为0。
我们可以发现如果有多个个1或0连在一起，那么他们就无法被分开，他会一直往上走。
那也就是说，最后那组先走到顶那组就赢了，那就要看那组离中心更近。
那会不会存在两个不同阵营的组距离一样远能，你会发现这是不可能的。
因为，如果距离相等，那么中间一定是奇数个位置，我们用1和0,交替隔开两组，
那么最后一个位置肯定会和左边或者右边一样，又形成一个组，所这两个组要么都是1，要么都是0。
解决了这些问题就能愉快的判断了！
CODE：
---------------------------------题解1

最后还有一种特殊情况。就是没有任何两个相邻的。
大概长这样。。
    0
  0 1 0
0 1 0 1 0
我们只需要特判一下就行了。
总结，一道二分贪心题，需要一定的手推过程找到规律。
---------------------------------题解2-------2018.11.6
对于不好做的题目，考虑二分答案。
check()对于一个最终的结果d可不可能出现，由于答案唯一，最终得到l<=d<=r
即可巧妙地求出答案.
---------------------------------------------2018.11.7
*/
#include<iostream>
#include<cstdio>
#include<cassert>
using namespace std;

int n,a[200005];

inline bool check(const int &k){
    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;
    if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;
    for(int i=1;i<n-1;i++){
        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;
        if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;
    }
    return a[1]<=k;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<n<<1;i++)scanf("%d",a+i);
    int l=1,r=(n<<1)-1;
    while(l<r){//满足 l<=k<=r
        int mid=l+r>>1;
        if(check(mid))r=mid;//结果可能小于等于k
        else l=mid+1;//不可能-->结果大于k-->往右半部分搜
    }
    assert(l==r);
    printf("%d",l);
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a==b){
		printf("Draw\n");
	}else if(a!=1&&b!=1){
		if(a>b){
			printf("Alice\n");
		}else{
			printf("Bob\n");
		}
	}else if(a==1){
		printf("Alice\n");
	}else{
		printf("Bob\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _dbg(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_dbg(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=2e5+5;
int b[N],s[N];
int32_t main(){
    int n;
    cin>>n;
    forn(i,n){
        cin>>b[i];
        b[i+n]=b[i];
    }
    for(int i=n+n-1;i>=0;--i)s[i]=b[i]+s[i+2];
    forn(i,n){
        int pl=s[i]-s[i+n+1];
        int mn=s[i+1]-s[i+n];
        int a=pl-mn;
        cout<<a<<' ';
    }
    cout<<'\n';

    return 0;
}


Measured memory_bytes: 4480