akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n;
  string s;
  int v;
  cin >> n >> s >> v;

  char str = s.at(v-1);

  for(int i=0; i<n; i++){
    if(s.at(i) != str){
      s.at(i) = '*';
    }
  }
  cout << s;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl '\n'
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    prt((A)*(B))

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
using namespace std; 

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n, d;
    cin>>n>>d;
    (n%(d+d+1)==0)?cout<<n/(d+d+1)<<endl:cout<<(n/(d+d+1))+1<<endl;
	
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>
#include <array>

typedef long long ll;

int main(int argc, char *argv[])
{
    ll x;

    std::cin >> x;

    ll a = 0;
    do {
        const double a5 = std::pow(static_cast<double>(a), 5);
        const double b5 = a5 - x;
        const double bsign = (b5<0)?-1:1;
        const double b5_nosign = b5 * bsign;
        ll b_nosign = std::pow(static_cast<double>(b5_nosign), 0.2);
        while(std::pow(static_cast<double>(b_nosign), 5) > b5_nosign) {
            b_nosign--;
        }
        ll b = b_nosign * bsign;

        if (a5 - std::pow(static_cast<double>(b), 5) == x) {
            std::cout << a << " " << b << std::endl;
            break;
        }
        a++;
    } while (1);

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int main(){
    string s;
    cin>>s;
    int n = s.length();
    string t = "";
    rep(i,n){
        if(s[i]=='0'||s[i]=='1'){
            t += s[i];
        }
        if(s[i]=='B'){
            int T = t.length();
            if(T!=0){
                t.erase(T-1);
            }
        }
    }
    cout<<t<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll A,B,C;
	cin >> A>>B>>C ;
	
	
	cout << max(ll(0),(C-B)*(A-2)+1) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 0, cnt1 = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W')cnt++;
		else cnt1++;
	}
	if (cnt1 == n || cnt == n)
		cout << "0" << endl;
	else {
		int have = 0;
		for (int i = 0; i < cnt1; i++) {
			if (s[i] == 'R')have++;
		}
		cout << cnt1 - have << endl;
	}
}

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

using namespace std;
typedef long long ll;

int main() {
  ll n, x;
  cin >> n >> x;

  vector<ll> a(n);
  for (int i = 0; i < n ; i++) {
    cin >> a[i];
  }

  vector<ll> dp(n);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    dp[i] = a[i];
    ans += dp[i];
  }

  for (int i = 1; i < n; i++) {
    ll sub = i * x;
    for (int j = 0; j < n; j++) {
      dp[j] = min(dp[j], a[(j - i + n) % n]);
      sub += dp[j];
    }
    ans = min(ans, sub);
  }
  cout << ans << endl;

  return 0;
}

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

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

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

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

void solve() {
  int n, a, b; cin >> n >> a >> b;
  cout << min(a, b) << " " << max(0, a + b - n) << endl;
}

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

  solve();
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
//#define int long long int
using namespace std;
typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	if(s[1] == 'B')
		cout << "ARC"<<endl;
	else
	{
			cout <<"ABC"<<endl;
	}
	
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void C();

int main()
{
	C();
	fflush(stdout);
	return 0;
}

static void C()
{
	int N, K;
	get(N, K);

	std::vector<LLONG> ai(N);
	for (int i = 0; i < N; i++) {
		get(ai[i]);
	}

	for (int i = K; i < N; i++) {
		if (ai[i - K] < ai[i]) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
}


Measured memory_bytes: 4836
def main():
	from random import randint
	from time import time
	t1=time()

	d=int(input())
	c=list(map(int,input().split()))
	s=[]
	for i in range(d):
		r=list(map(int,input().split()))
		s.append(r)

	def score(T):
		last=[0]*26
		happy=0
		for i in range(d):
			last[T[i]-1]=i+1
			happy+=s[i][T[i]-1]
			for j in range(26):
				happy-=(i+1-last[j])*c[j]
		return happy

	t=[]
	for i in range(d):
		t.append(i%26+1)

	t2=time()
	while t2-t1<1.85:
		tt=t.copy()
		if t2-t1<0.3:
			x=4
		elif t2-t1<0.5:
			x=3
		elif t2-t1<0.7:
			x=2
		else:
			x=1
		for i in range(x):
			tt[randint(1,d)-1]=randint(1,26)
		if score(tt)>score(t):
			t=tt.copy()
		t2=time()
	for x in t:
		print(x)

if __name__ == '__main__':
	main()

Measured memory_bytes: 83888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll a,b,c;cin>>a>>b>>c;
    if(a<b and b<c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3100
def gcb(a,b):
    if a>b:
        x,y=a,b
    else:
        x,y=b,a
    while True:
        if x%y!=0:
            x,y=y,x%y
        else:
            return y
def lcb(a,b):
    return a*b//gcb(a,b)
N=int(input())
T=[int(input()) for _ in range(N)]
ans=1
for i in range(N):
    ans=lcb(ans,T[i])
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{

   int H,A,a,i;
   a=0;
   scanf("%d%d", &H, &A);
   for (i=0; H>0;i++){
      H=H-A;
      a++;
   }
   printf("%d\n",a);
   return 0;
}


Measured memory_bytes: 128
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A+1):
	for b in range(B+1):
		for c in range(C+1):
			if a * 500 + b * 100 + c * 50 == X:
				ans+=1;

print(ans)

Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        cs: chars,
    }

    for i in 0..cs.len() {
        match (i+1) % 2 {
            0 => match cs[i] {
                'R' => { println!("No"); return; },
                _ => {},
            },
            1 => match cs[i] {
                'L' => { println!("No"); return; },
                _ => {},
            },
            _ => {},
        }
    }
    println!("Yes");
}

Measured memory_bytes: 4352
#include <stdio.h>
int main(){
    int a, b, c;
    int r = 0;
    scanf("%d %d %d", &a, &b, &c);
    for (int i = a; i >= a && i <= b; i++)
    {
        if(c % i == 0){
            r++;
        }
    }
    printf ("%d\n", r);
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int coun[2000];

void bfs(int now, int maxi, vector<int> *graph){
	vector<int> dist(2001, -1);
	dist[now] = 0;
	queue<int> que;
	que.push(now);
	while(!que.empty()){
		int v = que.front();
		que.pop();

		for (int i = 0; i < graph[v].size(); i++){
			if (dist[graph[v][i]] != -1) continue;

			dist[graph[v][i]] = dist[v] + 1;
			que.push(graph[v][i]);
			if (now < graph[v][i]) coun[dist[graph[v][i]]]++;
		} 
	}
}


int main(){
	int n, x, y;
	cin >> n >> x >> y;
	vector<int> graph[2001];
	for (int i = 1; i < n; i++){
		graph[i].push_back(i+1);
		graph[i+1].push_back(i);
	}
	graph[x].push_back(y);
	graph[y].push_back(x);
	for (int i = 1; i <= n-1; i++){
		bfs(i, n-1, graph);
	}
	for (int i = 1; i <= n-1; i++){
		cout << coun[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
n = int(input())
commands = []
for i in range(n):
    command, key = input().split(" ")
    commands.append((command, key))

dic = {}
for command in commands:

    if command[0] == "insert":
        dic[command[1]] = ""
    elif command[0] == "find":
        print("yes") if command[1] in dic else print("no")


Measured memory_bytes: 208500
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

struct CONBINATION {
    vector<ll> kai, mokai;

    ll mod_pow (ll x, ll y) {
        ll ret = 1;
        while (y) {
            if (y&1) ret = ret*x%MOD;
            x = x*x%MOD;
            y /= 2;
        }
        return ret;
    }

    void init (int _n) {
        kai.assign(_n+1, 0);
        mokai.assign(_n+1, 0);
        kai[0] = 1;
        for (int i = 1; i <= _n; i++) kai[i] = kai[i-1]*i%MOD;
        for (int i = 0; i <= _n; i++) mokai[i] = mod_pow(kai[i],MOD-2);
    }

    ll conb (ll x, ll y) {
        ll z = x-y;
        ll ret = kai[x]*mokai[y]%MOD;
        ret = ret*mokai[z]%MOD;
        return ret;
    }
} conb;

ll X, Y;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> X >> Y;
    if ((X+Y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll n = (X+Y)/3;
    X -= n;
    Y -= n;
    if (X < 0 || Y < 0) {
        cout << 0 << endl;
        return 0;
    }
    conb.init(2000000);
    cout << conb.conb(n, X) << endl;
}

Measured memory_bytes: 31616
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    return gcd(b, a % b)

@mt
def slv(N, A):
    ans = reduce(gcd, A)
    return ans


def main():
    N = read_int()
    # N, M = read_int_n()
    A = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
vector<int>v;
v.push_back(a);
v.push_back(b);
v.push_back(c);
sort(v.rbegin(),v.rend());
int x=v[0]*10+v[1]+v[2];
cout<<x<<endl;
return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str, A: int, B: int, U: str):
    if U==S:
        print(' '.join(map(str, [A-1, B])))
    else:
        print(' '.join(map(str, [A, B-1])))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    U = next(tokens)  # type: str
    solve(S, T, A, B, U)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
int a,b;
scanf("%d %d",&a,&b);
for (a==a;a<=b;a++){
	if(a%n==0){
		printf("OK");
		return 0;
	}
	else{
		continue;
	}
}
printf("NG");
return 0;
}

Measured memory_bytes: 1720
H,W,N = map(int,input().split())
ssr,ssc = map(int,input().split())
S = input()
T = input()

ssr -= 1
ssc -= 1

A = ["L", "R", "U", "D"]

A2 = {"L": -1, "R": 1, "U": -1, "D": 1}

D ={"L": "R", "R": "L", "U": "D", "D": "U"}

ans = "YES"

flg = 0

for a in A :
    
    sr = ssr
    sc = ssc
    
    if flg :
        break
        
    for i in range(N) :
        if (a in ["L", "R"]) and (a == S[i]) :
            sc += A2[a]
            
            if (sc < 0) or (sc >= W) :
                ans = "NO"
                flg = 1
                break

        elif (a in ["U", "D"]) and (a == S[i]) :
            sr += A2[a]
            
            if (sr < 0) or (sr >= H) :
                ans = "NO"
                flg = 1
                break
            
        if (a in ["L", "R"]) and (D[a] == T[i]) :
            if (sc == 0) and (D[a] == "L") :
                continue
            elif (sc == W-1) and (D[a] == "R") :
                continue
            sc += A2[D[a]]
            

            
        elif (a in ["U", "D"]) and (T[i] == D[a]) :
            if (sr == 0) and (D[a] == "U") :
                continue
            elif (sr == H-1) and (D[a] == "D") :
                continue
            sr += A2[D[a]]
        #print((sr,sc))
print(ans)
        

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

main() {
  int N, M; cin >> N >> M;
  vector<int> cnt(N, 0);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    cnt[a]++; cnt[b]++;
  }
  for (int i = 0; i < N; i++) cout << cnt[i] << endl;

}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	ll N,a,r;
	scanf("%lld",&N);
	r=N/11*2;
	a=N%11;
	if(a>0)r+=a>6?2:1;
	printf("%lld\n",r);
	return 0;
}


Measured memory_bytes: 256
<?php
$s=str_split(fgets(STDIN));
$t=str_split(fgets(STDIN));
for($i=0;$i<count($s)-1;$i++){
    if($s[$i]==$t[$i]){
        $ans="Yes";
    }else{
        $ans="No";
        break;
    }
}
echo $ans;

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename T> T fl(T x, T y) { return x / y; }           //   floor(x / y)
template<typename T> T ce(T x, T y) { return (x + y - 1) / y; } // ceiling(x / y)

string s;
int n;

int main() {
	cin >> s;
	n = s.size();
	
	int ans = n / 2, c0 = n / 2, c1 = n / 2;
	inc(i, ce(n, 2)) {
		int j = fl(n - 1, 2) - i;
		int k = ce(n - 1, 2) + i;
		if(s[j] == '0' && s[k] == '0') { c0++; } else { c0 = -1e7; }
		if(s[j] == '1' && s[k] == '1') { c1++; } else { c1 = -1e7; }
		setmax(ans, max(c0, c1));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    string s, t;
    cin >> s >> t;

    int64_t ans = 0;
    for (auto i : irange(0L, 3L)) {
        if (s[i] == t[i]) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

int main(void) {
    cin >> n;
    vector<ll> xx(n);
    rep (i, 0, n) cin >> xx[i];
    m = 10000000000;
    rep (i, 1, 100) {
        ll souwa = 0;
        rep (j, 0, n) {
            souwa += (i - xx[j]) * (i - xx[j]);
        }
        if (m > souwa) m = souwa;
    }

    cout << m << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, a, b;
  cin >> n >> a >> b;
  if(a > b || (a != b && n == 1)){
    cout << 0 << endl;
    return 0;
  }

  n -= 2;

  cout << 1 + n*b - n*a << endl;
  return 0;
}

Measured memory_bytes: 256
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	for(auto &code : b) cin >> code;
	int answer = 0;
	while(n--)
	{
		int result = c;
		for(int i = 0; i < m; ++i)
		{
			int a;
			cin >> a;
			result += a * b[i];
		}
		answer += (result > 0);
	}
	cout << answer << '\n';
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  int sum=0;
  cin >> N >> M;
  if(N>=2){
    sum+=N*(N-1)/2;
  }
  if(M>=2){
    sum+=M*(M-1)/2;
  }
  cout << sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,a,b;cin>>n>>a>>b;
    ll buf=b-a;
    if(buf%2==0){
        cout<<buf/2<<endl;
        return 0;
    }
    ll buf1=(b-a)/2+a,buf2=(b-a)/2+n-b+1;
    ll res=min(buf1,buf2);
    cout<<res<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
const ll inf = 1e9;

ll gcd(ll a,ll b){
    if(a < b)swap(a, 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 factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        rep0(i, N) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n;
    cin >> n;
    vector<string> s(n),ans;
    rep0(i, n)cin >> s[i];
    sort(all(s));
    s.push_back("A");
    ll cnt = 1,maxs = 0;
    rep0(i, n){
        if(s[i] != s[i + 1]){
            maxs = max(maxs,cnt);
            cnt = 1;
        }else ++cnt;
    }
    maxs = max(maxs,cnt);
    cnt = 1;
    rep0(i, n){
        if(s[i] != s[i + 1]){
            if(cnt == maxs)ans.push_back(s[i]);
            cnt = 1;
        }else ++cnt;
    }
    sort(all(ans));
    rep0(i, ans.size())pf(ans[i]);
    return 0;
}


Measured memory_bytes: 18064
#!/usr/bin/env python3

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

    INF = 1 << 60
    dp = [INF] * 100010

    dp[0] = 0

    for i in range(N):
        for j in range(1, K + 1):
            if i + j < N:
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))

    print(dp[N - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 84828
#include<iostream>
#include<cstdio>
#include<vector>
const int N=205;
int n;
char s[30],ans[N];
void query(std::vector<int> &g) {
    printf("? ");
    for(int v:g) printf(" %d",v);printf("\n");
    fflush(stdout);
    scanf("%s",s);
}
int main() {
    scanf("%d",&n);
    std::vector<int> w;
    for(int i=1;i<=n;i++) w.push_back(i);
    query(w);
    char u=s[0],v=(s[0]=='R'?'B':'R');
    int l=1,r=n+1,mid;
    while(l+1<r) {
        mid=(l+r)>>1;
        w.clear();
        for(int j=0;j<n;j++) w.push_back(j+mid);
        query(w);
        if(s[0]==u) l=mid;
        else r=mid;
    }
    ans[l]=u;
    ans[l+n]=v;
    //printf("%d\n",l);
    w.clear();
    for(int j=1;j<l;j++) w.push_back(j);
    for(int j=l+n+1;j<=n+n;j++) w.push_back(j);
    for(int j=l+1;j<l+n;j++) {
        w.push_back(j);
        query(w);
        ans[j]=s[0];
        w.pop_back();
    }w.clear();
    for(int j=l+1;j<l+n;j++) w.push_back(j);
    for(int j=1;j<l;j++) {
        w.push_back(j);
        query(w);
        ans[j]=s[0];
        w.pop_back();
    }
    for(int j=l+n+1;j<=n+n;j++) {
        w.push_back(j);
        query(w);
        ans[j]=s[0];
        w.pop_back();
    }
    ans[n+n+1]='\0';
    printf("! %s",ans+1);
    return 0;
}


Measured memory_bytes: 724
#include <stdio.h>

int main(void)
{
    int i, n, x, c=0;
    int a[101]={0};

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &x);
        if (a[x]==0) {
            a[x] = 1;
            c++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_046
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var ta = new long[n, 2];
            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                ta[i, 0] = int.Parse(input[0]);
                ta[i, 1] = int.Parse(input[1]);
            }

            long takahashi = ta[0,0];
            long aoki = ta[0, 1];
            for(int i = 1; i < n; i++)
            {
                long rateT = 0, rateA = 0;
                rateT= takahashi / ta[i, 0];
                if (takahashi % ta[i, 0] > 0) rateT++;
                rateA = aoki / ta[i, 1];
                if (aoki % ta[i, 1] > 0) rateA++;

                if (ta[i, 1] * rateT < aoki)
                {
                    takahashi = ta[i, 0] * rateA;
                    aoki = ta[i, 1] * rateA;
                }
                else if(ta[i, 0] * rateA < takahashi)
                {
                    takahashi = ta[i, 0] * rateT;
                    aoki = ta[i, 1] * rateT;
                }
                else
                {
                    long rate = rateA < rateT ? rateA : rateT;
                    takahashi = ta[i, 0] * rate;
                    aoki = ta[i, 1] * rate;
                }
            }

            Console.WriteLine(takahashi + aoki);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}
ll modexpo(ll a, ll b, ll m) {if (b == 0) {return 1;} else if (a == 1) {return 1;} if (b % 2 == 0) {ll t = modexpo(a, b / 2, m); t = (t * t) % m; return t;} else {ll t = modexpo(a, b / 2, m); t = (t * t) % m; t = (t * a) % m; return t;}}

ll dp[100001][101];

ll fn(ll sv, ll n, ll w[], ll v[] ) {

	if (sv == 0) {
		return 0;
	}
	if (n == 0) {
		return 1e18;
	}

	if (dp[sv][n] != -1) {
		return dp[sv][n];
	}


	ll op1 = fn(sv, n - 1, w, v);
	ll op2 = 1e18;
	if (sv >= v[n - 1]) {
		op2 = fn(sv - v[n - 1], n - 1, w, v) + w[n - 1];
	}


	ll ans = min(op1, op2);
	// cout << ans << endl;
	dp[sv][n] = ans;
	return ans;
}

int main() {

	// taskkill /IM "cp.exe" /F
	fast
      /*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
  */



	ll n, wt;
	cin >> n >> wt;
	ll w[n], v[n];
	ll sv = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
		sv += v[i];
	}
	memset(dp, -1, sizeof(dp));
	for (ll i = sv; i >= 0; i--) {
		ll t = fn(i, n, w, v);
		// cout << t << endl;
		if (t <= wt) {
			cout << i << endl;
			return 0;
		}
	}
	cout << 0 << endl;


}

Measured memory_bytes: 79232
import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
ans = 0
i = 0

while i<N:
    lim = T[i]+K
    ans += 1
    cnt = 0
    
    while i<N and cnt<C and T[i]<=lim:
        i += 1
        cnt += 1
        
print(ans)

Measured memory_bytes: 77108
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

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

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    h1, m1, h2, m2, k = MI()

    min1 = h1 * 60 + m1
    min2 = h2 * 60 + m2

    # print(min2 - min1)
    print(max(0, min2-min1-k))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9492
#include<bits/stdc++.h>
using namespace std;
char s[4];
int main()
{
	scanf("%s",s);
	int ans=0;
	for (register int i=0;i<4;++i)
	  if (s[i]=='+') ans++; else ans--;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto &
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline int size(const T& a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

int main() {
    lint a, b, c;
    cin >> a >> b >> c;
    if(a&b&c&1){
        cout << min(a*b, min(a*c, b*c)) << endl;
    } else {
        cout << 0 << endl;
    }
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

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

  for(int i=0;i<N;i++){
    cin>>h[i];
  }

  vector<ll> dp(N,1e12);
  dp[0]=0;
  for(int i=1;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i-j<0) break;
      dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;
}




Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def powm(a, n, m):
    if a == 1 or n == 0:
        return 1
    if n % 2 == 0:
        s = powm(a, n // 2, m)
        return s * s % m
    else:
        return a * powm(a, n - 1, m) % m

def solve(N: int, K: int):
    # base = powm(2,N+1,MOD)
    sumMinus = 0
    lastMinimum = 0
    lastMaximum = 0
    for i in range(1,N+2):
        lastMinimum += i-1
        lastMaximum += N-(i-1)
        # print(i, lastMinimum, lastMaximum)
        if i >= K:
            count = lastMaximum-lastMinimum+1
            sumMinus= (sumMinus+count)%MOD
            # print(i,lastMinimum,lastMaximum,count)
    print(sumMinus)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 67196
// AOJ 1308 Awkward Lights
// 2018.3.8 bal4u

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

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define N 630
#define ABS(a)	((a)>=0?(a):-(a))
#define p(r,c)	((r)*m+(c))

int main()
{
	int m, n, mn, d, i, j, k, r, c, ans;

	while (m = in()) {
		n = in(), d = in(), mn = m*n;

bitset <N> B[N];

		for (i = 0; i < n; i++) for (j = 0; j < m; j++) {
			if (in()) B[p(i, j)][mn] = 1;
			for (r = 0; r < n; r++) for (c = 0; c < m; c++) {
				if (r == i && c == j || ABS(r-i) + ABS(c-j) == d)
					B[p(i, j)][p(r, c)] = 1;
			}
		}

		k = 0;
		for (i = 0; i < mn; i++) {
			for (j = k; j < mn; j++) if (B[j][i]) break;
			if (j == mn) continue;
			swap(B[j], B[k]);
			for (j = k+1; j < mn; j++) if (B[j][i]) B[j] ^= B[k];
			k++;
		}

		ans = '1';
		for (i = k; i < mn; i++) if (B[i][mn]) { ans = '0'; break; }
		putchar(ans), putchar('\n');
	}
	return 0;
}


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

int main() {
        int N, M;
        long long cost = 0;
        cin >> N >> M;
        N;

        vector<long long> P(M);
        vector<long long> K(N,0);
        vector<long long> I(N,0);
        vector<long long> C(N,0);
        vector<long long> L(N,0);
        rep(m, M) {
                cin >> P.at(m);
        }
        for(int n = 1; n < N; n++) {
                cin >> K.at(n) >> I.at(n) >> C.at(n);
        }
        int i = 0, v1, v2, a, b;
        v1 = P.at(i);
        while (i < M-1) {
                i++;
                v2 = P.at(i);
                a = min(v1, v2);
                b = max(v1, v2);
//              cout << "a = " << a << " b = " << b << endl;
                for(int j = a; j < b; j++)      L.at(j)++;
                v1 = v2;
        }
        rep(n, N) {
                if (K.at(n) * L.at(n) < L.at(n) * I.at(n) + C.at(n)) {
                        cost += K.at(n) * L.at(n);
                } else {
                        cost += L.at(n) * I.at(n) + C.at(n);
                }
        }
        cout << cost << endl;

        return 0;
}



Measured memory_bytes: 6804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

double dis(double x1,double y1,double x2,double y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main() {
    int n;
    cin>>n;
    double x[n],y[n];
    rep(i,n) cin>>x[i]>>y[i];
    vector<int> order(n);
    rep(i,n) order[i]=i;

    double ans=0;
    do{
        rep(i,n-1){
            ans+=dis(x[order[i]],y[order[i]],x[order[i+1]],y[order[i+1]]);
        }
    }while(next_permutation(all(order)));

    double a=1;
    rep(i,n) a*=(i+1);
    ans/=a;

    cout<<setprecision(10)<<ans<<endl;
}




Measured memory_bytes: 256
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________
template <typename T = long long, const int sz = 5 * 10000000> struct IO {
    char reader[sz], writer[sz];
    char *now, *now2 = writer;
    IO() {
        reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
        now = reader;
    }
    inline T read() {
        while(*now && *now <= 32) now++;
        if(*now == '-') {
            now++;
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return -res;
        } else {
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return res;
        }
    }
    inline string read_str() {
        string res;
        while(*now and *now != '\n' and *now != ' ') res += *now++;
        now++;
        return res;
    }
    inline void write(T x, char margin = ' ') {
        if(x == 0) {
            putchar('0');
            putchar(margin);
            return;
        }
        if(x < 0) {
            putchar('-');
            x = -x;
        }
        while(x) {
            *now2 = '0' + x % 10;
            now2++;
            x /= 10;
        }
        do {
            now2--;
            putchar(*now2);
        } while(now2 != writer);
        putchar(margin);
    }
    inline void write_str(string s, char margin = ' ') {
        for(auto c : s) putchar(c);
        putchar(margin);
    }
};
IO<int> io;
int n, m, k;
constexpr int MAX = 1e9 + 1;
constexpr int N = 200010;
int a[N], b[N];
int nn;
main() {
    n = io.read(), m = io.read(), k = io.read();
    nn = n;
    rep(i, n) {
        a[i + 1] = io.read() + a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while(*io.now && *io.now <= 32) io.now++;
                while('0' <= *io.now and *io.now <= '9') io.now++;
            }
            break;
        }
    }
    rep(i, m) {
        b[i + 1] = io.read() + b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    int now = nn;
    int ans = now;
    for(int i = 1; i <= m; i++) {
        while(b[i] + a[now] > k) now--;
        ans = max(ans, i + now);
    }
    io.write(ans);
}


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

using namespace std;

int main()
{
    int n;
    int arr[200001];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    long long ans = 0;
    for(int i=1; i<n; i++){
        if(arr[i] >= arr[i-1])
            continue;
        else{
            ans += arr[i-1] - arr[i];
            arr[i] = arr[i-1];
        } 
    }
    // for(int i=0; i<n; i++)
    //     cout << arr[i] << ' ';
    // cout << '\n';
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4432
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    long long r,d,x;
    cin>>r>>d>>x;
    for(int i=0;i<10;i++){
        x=r*x-d;
        cout<<x<<endl;
    }
    return 0;
}

Measured memory_bytes: 3548
#include<cstdio>
using namespace std;
char s[110][110];
int n,m;
int main()
{
	scanf("%d%d",&n, &m);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			scanf(" %c", &s[i][j]);
		
	}
	for(int i=0;i<n;i++)
	{
		bool flag=false;
		for(int j=0;j<m;j++)
			if(s[i][j]=='#')
				flag=true;
		if(flag==true)
			continue;
		for(int j=0;j<m;j++)
			s[i][j]='/';
	}
	for(int i=0;i<m;i++)
	{
		bool flag=false;
		for(int j=0;j<n;j++)
			if(s[j][i]=='#')
				flag=true;
		if(flag==true)
			continue;
		for(int j=0;j<n;j++)
			s[j][i]='/'; 
	}
	for(int i=0;i<n;i++)
	{
		bool flag=false;
		for(int j=0;j<m;j++)
			if(s[i][j]!='/')
			{
				printf("%c", s[i][j]);
				flag=true;
			}
		if(flag==true)
			printf("\n");
	}	
	return 0;
 } 

Measured memory_bytes: 888