akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

vector<ll> Digits;
bool ask() {
  char c;
  cin >> c;
  return c == 'Y';
}
void answer(ll x) { cout << "! " << x << endl; }
void solve() {
  for (ll i = 0; i < 10; ++i) {
    ll ng = i == 0 ? 0 : -1, ok = 9;
    while (ok - ng > 1) {
      ll mid = (ok + ng) / 2;
      cout << "? ";
      for (ll digit : Digits) cout << digit;
      cout << mid;
      for (ll i = 0; i < 11 - Digits.size() - 1; ++i) cout << 9;
      cout << endl;
      (ask() ? ok : ng) = mid;
    }
    Digits.push_back(ok);
  }
  for (ll i = 10;; --i) {
    assert(i > 0);
    ll x = 0;
    for (ll j = 0; j < i; ++j) x = x * 10 + Digits[j];
    if (Digits[i - 1] != 0) {
      answer(x);
      return;
    }
    cout << "? " << x - 1 << endl;
    if (ask() == (to_string(x - 1) < to_string(x))) {
      answer(x);
      return;
    }
  }
}
int main() {
  solve();
  return 0;
}


Measured memory_bytes: 596
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)
function eval(a::Tuple{Int,Int},b::Tuple{Int,Int})
	if a[1]-a[2]>b[1]-b[2]
		1
	elseif a[1]-a[2]==b[1]-b[2]
		0
	else
		-1
	end
end

function hpush(h::Array{Tuple{Int,Int},1},x::Tuple{Int,Int})
	push!(h,x)
	if length(h) > 1
		l = length(h)
		k = l>>1
		while eval(x,h[k])==1&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(k>>1,1)
			l = l>>1
		end
	end
end

function hpop(h::Array{Tuple{Int,Int},1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>l
				break
			elseif 2*k+1>l
				if eval(z,h[2*k])>=0
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if eval(z,h[2*k])>=0&&eval(z,h[2*k+1])>=0
					break
				else
					t = eval(h[2*k],h[2*k+1])>=0 ? 2*k : 2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end

function main()
	n = readline() |> parseInt
	a = Tuple{Int,Int}[]
	b = Tuple{Int,Int}[]
	f = 0
	lx = 0
	rx = 0
	for i in 1:n
		s = readline() |> chomp
		l = 0
		r = 0
		for j in 1:length(s)
			if s[j]=='('
				l += 1
			else
				if l==0
					r+=1
				else
					l-=1
				end
			end
		end
		if l>r
			push!(a,(l,r))
		else
			push!(b,(l,r))
		end
		lx+=l
		rx+=r
	end
	f = 0
	if lx!=rx
		f = 1
	end
	lc = 0
	a = sort(a,by=x->x[2])
	for i in 1:length(a)
		if lc-a[i][2]<0
			f = 1
		end
		lc+=a[i][1]-a[i][2]
	end
	b = sort(b,by=x->x[1],rev=true)
	for i in 1:length(b)
		if lc-b[i][2]<0
			f = 1
		end
		lc += b[i][1]-b[i][2]
	end
	println(f==0 ? "Yes" : "No")
end

main()

Measured memory_bytes: 250936
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    if (n % 1000 == 0) {
        cout << 0;
    }else {
        for (int i = 0; i < 100; i++){
        if (i*1000 > n){
            cout << i*1000 - n;
            return 0;
        }
    }
        
    }
    
}

Measured memory_bytes: 3624
from itertools import product

H,W,K = map(int,input().split())
C = []
for _ in range(H):
    c = list(input())
    C.append(c)

# print(C)
ans = 0 

for row_bit in product(range(2), repeat=H):
    # print(row_bit) 
    # print(row_bit[0])
    # print(row_bit[1])
    for col_bit in product(range(2), repeat=W):
        # print(col_bit)
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)


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

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

int ans = 0;
for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
        if (S - X - Y >= 0 && S - X - Y <= K) {
            ans++;
        }
    }
}
cout << ans << endl;

}

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

using namespace std;

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    for(int i = 0; i < N; i++){
        cin >> x.at(i);
    }
    for(int i = 0; i < M; i++){
        cin >> y.at(i);
    }
    int maxX = *max_element(x.begin(), x.end());
    int minY = *min_element(y.begin(), y.end());

    for(int i = X + 1; i <= Y; i++){
        if(maxX < i && i <= minY){
            cout << "No War" << endl;
            return 0;
        }
    }

    cout << "War" << endl;
    return 0;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    vector< int > A(N), B(N), C(N - 1);
    cin >> A >> B >> C;
    
    int ans = whole(accumulate, B, 0);
    range(i, 0, N - 1) {
        if (A[i] + 1 == A[i + 1]) ans += C[A[i] - 1];
    }
    
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
A, B = map(int, input().split())

# gcd, lcm ###############################################################
def gcd(a, b):
  if b > a:
    a, b = b, a
  a, b = b, a % b
  if b == 0:
    return a
  else:
    return gcd(a,b)

def lcm(a, b):
  return a * b // gcd(a, b)

print (lcm(A,B))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
map<int, int> e;
int i, j, k, l, m, n, cnt;
int main() {
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%d", &k);
		if(e[k] != 0) {
			e[k] = 0;
			--cnt;
		} else {
			e[k] = 1;
			++cnt;
		}
	}
	printf("%d\n", cnt);
}

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

int main() {
  long long A, B, C;
  cin >> A >> B >> C;
  if ((C - B - A) > 0 && 4 * A * B < (C - B - A) * (C - B - A)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)

const int INF = 100000000;
const double EPS = 1e-8;
typedef pair<double, double> P;

double dp[1510][1510];
int main(){
  int N, K;
  cin>>N>>K;
  vector<P> _v, v;
  REP(i, N){
    double x, y, r;
    cin>>x>>y>>r;
    double t1 = atan2(y, x);
    double t2 = asin(r/sqrt(x*x+y*y));
    double b = t1 - t2, e = t1 + t2;
    if(b < -M_PI && e < 0) { b += 2*M_PI; e += 2*M_PI; }
    if(b < 0) b = 0;
    if(e > M_PI) e = M_PI;
    if(b < e) _v.push_back(P(b,e));
  }
  sort(_v.begin(), _v.end());
  //REP(i, _v.size()) printf("(%lf,%lf) ", _v[i].first, _v[i].second);
  REP(i, _v.size()){
    while(i + 1 < _v.size() && abs(_v[i].first - _v[i+1].first) < EPS) i++;
    v.push_back(_v[i]);
  }
  int M = v.size();
  vector<int> from(M, INF);
  REP(i, M) FOR(j, i+1, M) if(v[i].second > v[j].first) from[j] = min(from[j], i);
  memset(dp, 0, sizeof(dp));
  dp[1][1] = v[0].second - v[0].first;
  FOR(i, 1, M){
    int f = from[i];
    if(f == INF) f = i - 1;
    FOR(k, 1, i + 2) dp[i+1][k] = max(dp[i][k], max(
          dp[f+1][k-1] + (v[i].second - max(v[f].second, v[i].first)),
          dp[f][k-1] + (v[i].second - v[i].first)));
    //printf("%d:",f); REP(k, i + 2) printf("%lf ", dp[i+1][k]); cout<<endl;
  }
  double ans = 0;
  REP(k, K + 1) ans = max(ans, dp[M][k]/M_PI);
  printf("%.13lf\n",ans);
  return 0;
}

Measured memory_bytes: 18000
# -*- coding: utf-8 -*-
from copy import deepcopy


def main():
    problems = int(input())
    solve_times = [int(e) for e in input().split()]
    drinks = int(input())

    for i in range(drinks):
        solve_times_copy = deepcopy(solve_times)
        problem_idx, solve_time = [int(e) for e in input().split()]
        problem_idx -= 1
        solve_times_copy[problem_idx] = solve_time
        print(sum(solve_times_copy))


main()


Measured memory_bytes: 3700
from sys import setrecursionlimit
setrecursionlimit(10**6)
n,k=map(int,input().split())
paths=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    paths[a-1].append(b-1)
    paths[b-1].append(a-1)
inf=100000000000000
nums=[-inf]*n
nums[0]=k
from collections import deque
now=deque()
now.append(0)
def bfs(d):
    global n,k,paths,nums,now
    l=len(now)
    if d==1:
        for i in range(l):
            p=now.popleft()
            ln=len(paths[p])
            next_num=k-1
            for j in range(ln):
                if nums[paths[p][j]]==-inf:
                    nums[paths[p][j]]=next_num
                    now.append(paths[p][j])
                    next_num-=1
    else:
        for i in range(l):
            p=now.popleft()
            ln=len(paths[p])
            next_num=k-2
            for j in range(ln):
                if nums[paths[p][j]]==-inf:
                    nums[paths[p][j]]=next_num
                    now.append(paths[p][j])
                    next_num-=1
    if len(now):bfs(d+1)
bfs(1)
ans=1
for i in range(n):
    if nums[i]<=0:
        print(0)
        exit()
    ans*=nums[i]
    ans%=(10**9+7)
print(ans)

Measured memory_bytes: 160672
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

// MMMMM
// 012345

void solve() {
  ll N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<ll> Macc(N+1);
  Macc[0] = 0;
  rep (i, N) {
    Macc[i+1] = Macc[i];
    if (S[i] == 'M') Macc[i+1]++;
  }
  rep (i, Q) {
    ll K;
    cin >> K;
    ll ans = 0;
    ll d = 0;
    ll m = 0;
    rep (i, N) {
      if (i - K >= 0 and S[i-K] == 'D') {
        d -= 1;
        m -= Macc[i] - Macc[i-K];
      }
      if (S[i] == 'D') d++;
      if (S[i] == 'M') m += d;
      if (S[i] == 'C') ans += m;
    }
    cout << ans << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 9244
n,k = map(int,input().split())

left = 0
right = 0
ans = 0
MOD =10**9+7
for i in range(n+1):
	left += i
	right += n-i
	if i >= k-1:
		ans += right - left + 1
		ans %= MOD

print(ans%MOD)


Measured memory_bytes: 9180
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char s[15]={};
long long ans=0;
int num[15]={};
void DFS(int loc,int len,long long sum,long long t) //当前位置 长度 现有和 不加+时累积的和
{
	if(loc==len-1){ //加到末尾了
		ans+=sum+t; //答案加上现有和和不加+累积的和
		return;
	}
	DFS(loc+1,len,sum+t,num[loc+1]); //加+ 则t断开，重新为下一个数
	DFS(loc+1,len,sum,t*10+num[loc+1]); //不加+ sum不变，t累积
}
int main()
{
	int len;
	scanf("%s",s);
	len=strlen(s);
	for(int i=0;i<len;i++)
		num[i]=s[i]-'0';
	DFS(0,len,0,num[0]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

vector<ll> card;
vector<vector<ll>> ans;

ll calc(ll x, ll y){
    if(ans.at(x).at(y) != -1){
        return ans.at(x).at(y);
    }

    ll ret;
    if(x > y){
        if(y == 0){
            ret = abs(card.at(x) - card.at(y));
        }else if(x > y + 1){
            ret = calc(y + 1, y);
        }else{
            // x == y + 1 and y > 0
            ret = calc(0, y);
            for(int i = 1; i < y; ++i){
                ret = max(ret, calc(i, y));
            }
        }
    }else{
        if(x == 0){
            ret = abs(card.at(x) - card.at(y));
        }else if(y > x + 1){
            ret = calc(x, x + 1);
        }else{
            // x + 1 == y and x > 0
            ret = calc(x, 0);
            for(int i = 1; i < x; ++i){
                ret = min(ret, calc(x, i));
            }
        }
    }
    ans.at(x).at(y) = ret;
    return ret;
}

int main(){
    ll n, z, w;
    cin >> n >> z >> w;
    card.resize(n + 2);
    for(int i = 0; i < n; ++i){
        cin >> card.at(n - 1 - i);
    }
    card.at(n) = w;
    card.at(n + 1) = z;
    ans.resize(n + 2, vector<ll>(n + 2, -1));
    cout << calc(n + 1, n) << endl;
    return 0;
}

Measured memory_bytes: 31616
#include <iostream>
#include <algorithm>

using namespace std;

struct Dise
{
  int top;
  int bottom;
  int north;
  int east;
  int south;
  int west;
  void toNorth()
  {
    int t = top, b = bottom, n = north, s = south;
    top = s, bottom = n, north = t, south = b;
  }
  void toEast()
  {
    int t = top, b = bottom, e = east, w = west;
    top = w, bottom = e, east = t, west = b;
  }
  void toSouth()
  {
    int t = top, b = bottom, n = north, s = south;
    top = n, bottom = s, north = b, south = t;
  }
  void toWest()
  {
    int t = top, b = bottom, e = east, w = west;
    top = e, bottom = w, west = t, east = b;
  }
  void toTop(int a)
  {
    if (a == north)
      toSouth();
    else if (a == east)
      toWest();
    else if (a == south)
      toNorth();
    else if (a == west)
      toEast();
    else if (a == bottom)
    {
      toNorth();
      toNorth();
    }
  }
  void spin()
  {
    int n = north, e = east, s = south, w = west;
    north = w, east = n, south = e, west = s;
  }
} d1, d2;

int main()
{
  int n[2][6];
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 6; j++)
    {
      cin >> n[i][j];
    }
  d1.top = n[0][0], d1.south = n[0][1], d1.east = n[0][2],
  d1.west = n[0][3], d1.north = n[0][4], d1.bottom = n[0][5];
  d2.top = n[1][0], d2.south = n[1][1], d2.east = n[1][2],
  d2.west = n[1][3], d2.north = n[1][4], d2.bottom = n[1][5];

  // ??°?????????????§???????
  sort(n[0], n[0] + 6);
  sort(n[1], n[1] + 6);
  for (int i = 0; i < 6; i++)
    if (n[0][i] != n[1][i])
    {
      cout << "No" << endl;
      return 0;
    }

  d2.toTop(d1.top);
  while (d2.south != d1.south)
  {
    d2.spin();
  }

  if (d1.north == d2.north && d1.east == d2.east && d1.west == d2.west)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3148
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

vector<vector<ll>> dp(2000,vector<ll>(2000,0));

void DP(){
    dp[0][0]=1;
    for(int i=0;i<2000;i++){
        for(int t=1;t<2000;t++){
            if(i-t>=0){
                dp[i][t]=dp[i][t-1]+dp[i-t][t];
                dp[i][t]%=MOD;
            }
            else{
                dp[i][t]=dp[i][t-1];
            }
        }
    }
}

int main(){
    ll n,k;
    cin>>n>>k;
    DP();
    cout<<dp[n][k]<<endl;
    
    
    return 0;
}




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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;

#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin() , (a).end()
#define rall(a) (a).rbegin() , (a).rend()

ll next(){ll x; cin >> x;return x;}
const int maxn = 2e5 + 2 , intf = 2e9;
const ll inf = 2e18 , mod = 1e9 + 7;
const ld eps = 1e-9;


void solve(){
    ll x; cin >> x;
    cout << (x / 500)*1000 + ((x % 500) / 5) * 5;
}


signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    
    for (int t = 1; t--;) solve();

	return 0;
}
/*


*/



Measured memory_bytes: 256
def examA():
    N = I()
    B = LI()
    ans = [0]*N
    flag = False
    for i in range(N-1,-1,-1):
        for j in range(i,-1,-1):
            if j+1==B[j]:
                ans[i] = B[j]
                del B[j]
                break
        if ans[i]==0:
            print("-1")
            flag = True
            break
    if not flag:
        for v in ans:
            print(v)

from string import digits
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 3832
h, w = map(int, input().split())
pad = '.' * (w + 2)
sl = []
sl.append(pad)
for i in range(h):
  s = '.' + str(input()) + '.'
  sl.append(s)
sl.append(pad)
for i in range(1, h + 1):
  strlist = list(sl[i])
  for j in range(1, w + 1):
    if sl[i][j] == '.':
      wc = 0
      for p in range(i - 1, i + 2):
        for q in range(j - 1, j + 2):
          if sl[p][q] == '#':
            wc += 1
      strlist[j] = str(wc)
  sl[i] = "".join(strlist)
for i in range(1, len(sl) - 1):
  print(sl[i][1:-1])


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = [0] * N

A.reverse()
num = A[0]
for i in range(1, N):
    if i % 2 == 0:
        num -= A[i]
    else:
        num += A[i]

B[0] = num

for i in range(1, N):
    B[i] = 2 * (A[i] - (B[i - 1] // 2))
B.reverse()
B = list(map(str, B))
print(' '.join(B))

Measured memory_bytes: 75236
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll h, w;
	cin >> h >> w;
	vector<string>c(h);
	for (ll i = 0; i <h; i++) {
		cin >> c[i];
	}
	for (ll i = 0; i <c.size(); i++) {
		for (ll k = 0; k < 2; k++) {
			for (ll j = 0; j <c[i].size(); j++) {
				cout << c[i][j];
			}
			cout<<endl;
		}
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int mod=1e9+7;
int main(){
int n=read(),pre=0,now,zy[3][3]={{0,3,6},{0,2,2},{0,1,3}};
string a[2];cin>>a[0]>>a[1];
ll ans=1;
for (int i=0;i<n;++i){
  now=a[0][i]==a[1][i]?1:2;
  ans=ans*zy[pre][now]%mod;
  pre=now,i+=now==2;
  }write(ans);
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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")
    };
}

macro_rules! chmax {
    ($x:expr, $e:expr) => {
        if $x < $e {
            $x = $e;
        }
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        if $x > $e {
            $x = $e;
        }
    };
}

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}

const INF: i64 = 1 << 60;

struct Solver {
    ABCD: Vec<char>,
    ans: Vec<char>,
}

impl Solver {
    fn dfs(&mut self, i: usize, acc: i64, ops: &mut Vec<char>) {
        if i == self.ABCD.len() {
            if acc == 7 {
                self.ans = ops.clone();
            }
            return;
        }
        let d = self.ABCD[i] as i64 - '0' as i64;
        ops.push('+');
        self.dfs(i+1, acc + d, ops);
        ops.pop();
        ops.push('-');
        self.dfs(i+1, acc - d, ops);
        ops.pop();
    }
    fn solve(&mut self) {
        let d = self.ABCD[0] as i64 - '0' as i64;
        self.dfs(1, d, &mut Vec::new());
    }
}

fn main() {
    input!{
        ABCD: chars,
    }
    let mut solver = Solver { ABCD: ABCD.clone(), ans: Vec::new() };
    solver.solve();
    println!("{}{}{}{}{}{}{}=7",
                ABCD[0],
                solver.ans[0],
                ABCD[1],
                solver.ans[1],
                ABCD[2],
                solver.ans[2],
                ABCD[3],
            );
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}
bool cmp(pair < int , string >   a , pair < int , string >   b){
  if(a.first < b.first ) return true;
  else return false;
}
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
const int mod=998244353;
int fac[200005];
void calfac(){
  fac[0]=1;
  fac[1]=1;
  for(int i = 2 ; i < 200005;i++) fac[i]= (fac[i-1]*i)%mod;
}
int inv(int a){
  return binpow(a , mod-2,mod);
}
int comin(int n , int r){
  return (fac[n] * ((inv(fac[r]) * inv(fac[n-r]))%mod))%mod;
}
int32_t main(){  
  int n,m,k;
  cin >> n >> m >> k;
  calfac();
  int ans = 0;
  for(int i = 0 ; i <=k ; i++){
   // cout << ans << " " << comin(n-1,i) << " " << m << " " <<  comin(n-1,i) * m << " " << binpow(m-1,n-1-i  , mod) << " " <<  (((comin(n-1,i) * m)%mod) * binpow(m-1,n-1-i  , mod))%mod << "\n";
      ans = (ans + (((comin(n-1,i) * m)%mod) * binpow(m-1,n-1-i  , mod))%mod)%mod;
  }
  cout << ans << "\n";
  return 0;
} 
/*
10010
01011
11000

16+
*/

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

int main(){
  long long W,H,x,y;  cin >> W >> H >> x >> y;
  cout << fixed << setprecision(15) << (double)W*H/2 << ' ';
  if(2*x == W && 2*y == H)  cout << '1' << endl;
  else cout << '0' << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

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


Measured memory_bytes: 2108
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<ll> vll;
typedef std::vector<vll> vvll;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

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

int main() {
  int n;
  scan(n);
  vll a(n);
  scan(a);
  ll ans = a[0];
  rep (i, n) {
    ans = gcd(ans, a[i]);
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,input,l;
set<int>total;
int main()
{
    total.clear();
    cin>>n;
    for(int i=0;i<n;i++){
            l=total.size();
        cin>>input;
        total.insert(input);
        int k=total.size();
        if(l==k){
            total.erase(input);
        }
    }
    cout<<total.size();
    return 0;
}


Measured memory_bytes: 4864
/**
 *  author: Behradm
 *  Created: 2020.06.21 16:15:45
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  if (isupper(c))
    cout << "A\n";
  else
    cout << "a\n";  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i,0,H) {
    cin >> S[i];
  }

  vector<vector<i64>> dist(H, vector<i64>(W, 1e18));
  using P = pair<pair<i64, i64>, i64>;
  deque<P> que;

  if(S[0][0] == '.') {
    dist[0][0] = 0;
    que.push_back({ { 0, 0 }, (i64)('.') });
  }
  else {
    dist[0][0] = 1;
    que.push_back({ { 0, 0 }, (i64)('#') });
  }

  vector<i64> D{ 1, 0, -1, 0 };
  while(!que.empty()) {
    i64 x = que.front().first.first;
    i64 y = que.front().first.second;
    char c = que.front().second;
    que.pop_front();

    for(i64 d = 0;d < 2;d++) {
      i64 i = x + D[d];
      i64 j = y + D[d ^ 1];
      if(0 <= i && i < H && 0 <= j && j < W) {
        i64 add = 0;
        if(c != S[i][j] && S[i][j] == '#') {
          add = 1;
        }
        if(dist[i][j] > dist[x][y] + add) {
          dist[i][j] = dist[x][y] + add;
          if(add == 0) {
            que.push_front({ { i, j }, (i64)(S[i][j]) });
          }
          else {
            que.push_back({ { i, j }, (i64)(S[i][j]) });
          }
        }
      }
    }
  }

  cout << dist[H - 1][W - 1] << endl;
}


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

int main() {
  int n, a;
  cin >> n >> a;
  bool ok = false;
  for (int i = 0; i <= min(n,a); i++) {
    if ((n-i) % 500 == 0) {ok = true;}
  }
  
  if (ok) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 500010
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)            //counts no of ones in binary representation
#define w(t)     int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

bool isprime(ll n){			//to check whteher no is prime or not
	if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

int main(){
	fast;
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int cnt=0;
	while(b<=a){
		b*=2;
		cnt++;
	}
	while(c<=b){
		c*=2;
		cnt++;
	}
	if(cnt>k)	cout<<"No";
	else	cout<<"Yes";
	//cout<<"Case #"<<x<<": "<<y<<endl;
}

Measured memory_bytes: 3632
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

void dfs(string s, const int& n, int& res){
  int x = stoll(s);
  if (x <= n){
    if (
        s.find("3")!=string::npos &&
        s.find("5")!=string::npos &&
        s.find("7")!=string::npos
        ){
      dump(x, n);
      res++;
    }
    dfs(s + "3", n, res);
    dfs(s + "5", n, res);
    dfs(s + "7", n, res);
  }
}

int toi(char c){
  return c - '0';
}

int solve(){
  int n;cin>>n;
  string s = to_string(n);
  int res = 0;
  dfs("0", n, res);
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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


def solve(N: int, A: int, B: int, C: int, D: int, E: int):
    print(ceil(N/min(A,B,C,D,E))+4)



# 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
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    solve(N, A, B, C, D, E)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    int N = S.size();
    int count = 0;
    for (int i = 1; i < N; i++) {
        if (S.at(i) != S.at(i-1)){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3716
int main(int argc ,const char *argv[])
{
    int d[4][3][10],n,b,f,r,v;
    //初期化
    for(int i=0;i<4;i++)for(int j=0;j<3;j++)for(int k=0;k<10;k++){
        d[i][j][k]=0;
    }
    //input
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        d[b-1][f-1][r-1]+=v;
    }
    //output
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                printf(" %d",d[i][j][k]);
            }
            putchar('\n');
        }
        if(i<3){
            for(int j=0;j<20;j++){
                putchar('#');
            }
            putchar('\n');
        }
    }
    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <cstdio>
 
using namespace std;
 
typedef long long ll;
 
const int NOT_FOUND = -1;
 
int binarySearch(vector<int> &A, int n){
  int left  = 0;
  int right = A.size();
 
  while(left < right){
    int mid = (left + right) / 2;
 
    if(A[mid] == n){
      return mid;
    }else if(A[mid] > n){
      right = mid;
    }else{
      left = mid + 1;
    }
  }
 
  return NOT_FOUND;
}
 
int main(){
  int n, q, key;
 
  while(cin >> n){
    vector<int> S(n);
 
    for(int i = 0; i < n; i++){
      scanf("%d", &S[i]);
    }
 
    int findCount = 0;
    cin >> q;
 
    for(int i = 0; i < q; i++){
      cin >> key;
      int result = binarySearch(S, key);
 
      if(result != NOT_FOUND){
        findCount += 1;
      }
    }
 
    cout << findCount << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3236
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
a = []
b = []
for _ in range(n):
    ai, bi = LI()
    a.append(ai)
    b.append(bi)
p = 0
for ai, bi in zip(a[::-1], b[::-1]):
    ai += p
    if ai % bi == 0:
        continue
    elif bi > ai:
        p += bi - ai
    else:
        p += bi - (ai % bi)
print(p)


Measured memory_bytes: 12660
import math
n = int(input())
m = int(input())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(m)]
p = [0 for i in range(n+1)]

for i in range(m):
    for j in range(n):
        if B[i][j] == A[i]:
            p[j+1] += 1
        else:
            p[A[i]] += 1
for i in range(1,n+1):
    print(p[i])



Measured memory_bytes: 5772
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
#define     PI          3.141592653589793238462643383279502884L
 
 
int main()
{
	int K;
	string S;

	cin >> K >> S;
	if(S.size()<=K)cout << S << endl;
	else
	{
		for(int i = 0; i < K; i++)
		{
			cout << S[i];
		}
		cout << "..." << endl;
	}
    

    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3508
#include<stdio.h>

int main(){
	int a,b,c,d,e,f;
	scanf("%d %d %d",&a,&b,&c);
	d=10*a+b+c;
	e=10*b+c+a;
	f=10*c+a+b;
	if(d>=e&&d>=f) {
		printf("%d",d);
	} else if(e>=d&&e>=f){
		printf("%d",e);
	}else{
		if(f>=e&&f>=d)
			printf("%d",f);
	}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	string s;
	char a;
	cin>>n>>s;
	a=n;
	for(i=0;i<s.size();i++) 
	{
		s[i]+=a;
		if(s[i]>'Z')s[i]-=26;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
using System;
namespace Miko_Atcoder
{
    class B_FBSum
    {
        static void Main(string[] args)
        {
            Int64 N = Int64.Parse(Console.ReadLine());
            Int64 Sum = N * (N + 1) / 2;
            for(Int64 i = 1;i <= N; i++)
            {
                if (i % 3 == 0 || i % 5 == 0) Sum -= i;
            }
            Console.WriteLine(Sum);
        }
    }
}

Measured memory_bytes: 27496
N=int(input())
a=0
t=0
w=0
r=0
for i in range(N):
    p=input()
    if(p=='AC'):
        a=a+1
    elif(p=='TLE'):
        t=t+1
    elif(p=='WA'):
        w=w+1
    else:
        r=r+1
print('AC x '+str(a))
print('WA x '+str(w))
print('TLE x '+str(t))
print('RE x '+str(r))

Measured memory_bytes: 74744
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

from itertools import accumulate

if K>=50:
    print(*[N]*N)
    exit()
    
for _ in range(K):
    ans=[0]*(N+1)
    for i,a in enumerate(A):
        ans[max(0,i-a)]+=1
        ans[min(i+a+1,N)]-=1
    A = list(accumulate(ans))[:-1]
    if all(i == N for i in A):
        break
print(*A)

Measured memory_bytes: 179908
N=int(input())
A=list(map(int, input().split()))
cnt=sum([1 if a < 0 else 0 for a in A])
lAl=list(map(abs, A))
if cnt % 2 == 1:
	print(sum(lAl) - 2 * min(lAl))
else:
	print(sum(lAl))


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

int main(){
  int A,B,C;
  cin >> A >> B>> C;
  if(A==B&& B!=C){
    cout << "Yes" <<endl;
  }
else if(B==C&& C!=A){
  cout << "Yes" <<endl;
}
else if(C==A && A!=B){
  cout << "Yes" <<endl;
}
  else{cout <<"No" <<endl;}
}



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

int main() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	pair<int, char> t;
	char prev = s[0];
	int cnt = 0, now = 0;
	vector<int> l, r;
	for (int i = 0; i < n; i++)
	{
		if(prev == s[i]) {
			cnt++;
		}
		else {
			l.push_back(cnt);
			now += cnt - 1;
			cnt = 1;
			prev = s[i];
		}
	}
	l.push_back(cnt);
	now += cnt - 1;

	now += 2 * min(k, ((int)l.size() - 1) / 2);
	k -= min(k, ((int)l.size() - 1) / 2);
	if(k > 0 && l.size() % 2 == 0) now++;
	cout << now << endl;
	return 0;
}



Measured memory_bytes: 3976
N = int(input())
S_lists = [input() for i in range(N)]

S_dict = {}

for S in S_lists:
    S_list = list(S)
    S_list.sort()

    S_str = "".join(S_list)
    if S_str in S_dict.keys():
        S_dict[S_str] = S_dict[S_str] + 1
    else:
        S_dict[S_str] = 1

answer = 0
for v in S_dict.values():
    if v > 1:
        answer += int(v * (v - 1) / 2)

print(answer)


Measured memory_bytes: 24976
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    l = list(map(int, input().split()))
    m = [i for i in range(102)]
    s = list(set(m) - set(l))
    answer_list = []
    for i in s:
        if i <= X:
            answer_list.append(X - i)
        else:
            answer_list.append(i - X)
    answer = min(answer_list)
    if X - answer in s:
        print(X - answer)
    else:
        print(X + answer)


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++ ){
        if(n%i == 0 && n/i <=9 && n/i >=1)
            return cout << "Yes" << endl,0;
    }
    cout << "No" << endl;
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	string S;
	
	cin >> S;
	
	cout << (regex_match(S, regex("A[a-z]+C[a-z]+")) ? "AC" : "WA");
	
	return 0;
}

Measured memory_bytes: 384
# A, B 水 100g単位
# C, D 砂糖
# E 100g の水に溶ける砂糖の量
# F ビーカーに入る砂糖水の重さ

a, b, c, d, e, f = gets.split.map(&:to_i)
a *= 100
b *= 100

max_concentration = -1
ans = nil
0.upto(f/a) do |na|
  0.upto((f - a*na)/b) do |nb|
    water = a*na + b*nb
    next if water == 0
    0.upto((f - a*na - b*nb)/c) do |nc|
      0.upto((f - a*na - b*nb - c*nc)/d) do |nd|
        sugar = c*nc + d*nd
        break if sugar.fdiv(water) > e.fdiv(100)
        concentration = (100*sugar).fdiv(water+sugar)
        if concentration > max_concentration
          ans = [water + sugar, sugar]
          max_concentration = concentration
        end
      end
    end
  end
end

puts ans.join(' ')

Measured memory_bytes: 1788
#include<cstdio>
#define MAX 500005

int A[MAX];
int n;
int left(int i)
{
	return 2 * i;
}
int right(int i)
{
	return 2 * i + 1;
}
void maxHeapify(int A[], int i)
{
	int l,r,max;
	l = left(i);
	r = right(i);
	max = i;

	if(l <= n && A[l] > A[max]) max = l;
	if(r <= n && A[r] > A[max]) max = r;

	if(max != i)
	{
		int cur = A[i];
		A[i] = A[max];
		A[max] = cur;
		maxHeapify(A,max);
	}
}
int main()
{
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
		scanf("%d", &A[i]);

	for(int i=n/2; i>=1; i--)
		maxHeapify(A,i);

	for(int i=1; i<=n; i++)
		printf(" %d", A[i]);
	printf("\n");


	return 0;
}


Measured memory_bytes: 4532
#include <stdio.h>

int main()
{
  char s[200001], t[200001];
  scanf("%s%s", s, t);
  int i=0;
  int ans=0;
  while(s[i]){
    if(s[i]!=t[i]) ans++;
    i++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2060