akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";
const int dx[9] = { 1,1,1,0,0,0,-1,-1,-1 }, dy[9] = { 1,0,-1,1,0,-1,1,0,-1 };

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

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int h, w, n, cnt, sum;
vector<int>v;
map<int, bool>mp;
int ans[10];
signed main() {
	cin >> h >> w >> n;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		v.push_back(w * a + b);
	}
	sort(all(v));
	for (int i : v) {
		int y = i / w, x = i % w;
		rep(j, 9) {
			int nx = x + dx[j], ny = y + dy[j];
			if (1 <= nx && nx < w - 1 && 1 <= ny && ny < h - 1) {
				if (!mp[w * ny + nx]) {
					mp[w * ny + nx] = true;
					rep(k, 9) {
						int nnx = nx + dx[k], nny = ny + dy[k];
						if (binary_search(all(v), w * nny + nnx)) {
							cnt++;
						}
					}
					ans[cnt]++;
					cnt = 0; 
				}
			}
		}
	}
	rep(i, 10) {
		sum += ans[i];
	}
	ans[0] += (h - 2) * (w - 2) - sum;
	rep(i, 10) {
		cout << ans[i] << endl;
	}
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	std::string s, t;
	std::cin >> s >> t;
	int res = 0;
	for (int i = 0; i < (int) s.size(); i++) res += s[i] != t[i];
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 3916
#include <cstdio>
#include <iostream>
using namespace std;
 
void rect(int n,int m){
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
            if(!i||!j||i==n-1||j==m-1)cout << '#';
            else cout << '.';
        }
        puts("");
    }
}
 
int main(){
    int n,m;
     
    while(true){
        cin >> n >> m;
        if(!n&&!m) break;
        rect(n,m);
        puts("");
    }
     
     
    return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int S;
  cin >> S;
  cout << S%2 + (S - S%2)/10 %2 + (S - S%2 - (S - S%2)/10 %2 *10)/100 %2 << endl;
}

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

int main() {
	int n,l,j,st=0;
	int a[100002]={};
	int bt[100002]={};
	cin >> n >> l;
	for(int i=1;i<=n;i++){
		cin >>a[i];
	}
	for(int i=1;i<=n;i++){
		if(a[i-1]<a[i] && a[i] >a[i+1]){
			bt[i]=l-a[i]+bt[i-1];
			a[i]=0;
			for(j=i-1;a[j-1]<a[j];j--){
				bt[j]=l-a[j]+max(bt[j+1],bt[j-1]);
			}
			if(st<bt[j+1]){st=bt[j+1];}
		}
	}
	//for(int i=1;i<=n;i++){cout << bt[i] << ' ';}
	cout << st << endl;
	return 0;
}

Measured memory_bytes: 1948
n = int(input())
now = 1
fl = False
li = list(map(int,input().split()))
zero = False;
for i in li:
    if i == 0:
        zero = True
if zero == True:
    print(0)
else:
    for i in li:
        if fl == True:
            continue;
        now *= i
        if now > 1e18:
            print(-1)
            fl = True
    if fl == False:
        print(now)


Measured memory_bytes: 21644
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll k;
	string s;
	cin >> k >> s;
	if(s.size()>k){
		s = s.substr(0,k)+"...";
	}
	cout << s << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;
const int maxn=2e5+50;
int a[maxn];
long long b[maxn],c[maxn];
int n;
//(sum[r]-sum[l-1])/(r-l+1)>=k
//sum[r]-sum[l-1]>=k*(r-l+1)
//sum[r]-k*r>=sum[l-1]+k*(-l+1)
//sum[r]-k*r>=sum[l-1]-k*(l-1)
//for each r count the num of i that sum[r]-k*r>=sum[i]-k*(i)

int lowbit(int x){
    return x&(-x);
}

int ask(int x){
    int ret=0;
    for (;x;x-=lowbit(x)) ret+=c[x];
    return ret;
}

void change(int x,int y){
    for (;x<=n+1;x+=lowbit(x)) c[x]+=y;
}

int main(){
    long long k;
    
    scanf("%d%lld",&n,&k);
    for (int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    long long sum=0;
    for (int i=1;i<=n;i++){
        sum+=a[i];
        long long tmp=sum-k*i;
        b[i]=tmp;
    }
    b[n+1]=0;
    sort(b+1,b+n+2);
    sum=0;
    memset(c,0,sizeof(c));
    int id=lower_bound(b+1, b+n+2, 0)-b;
    change(id,1);
    long long ans=0;
    for (int i=1;i<=n;i++){
        sum+=a[i];
        long long tmp=sum-k*i;
        int id=lower_bound(b+1, b+n+2, tmp)-b;
        //if (a[i]>=k) ans++;
        ans+=ask(id);
        change(id,1);
      //  cout<<tmp<<"@@@"<<ans<<endl;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int alice=0, bob=0;
  for(int i=n-1; i>=0; i-=2){
    alice+=a[i];
  }
  for(int i=n-2; i>=0; i-=2){
    bob+=a[i];
  }
  cout<<alice-bob<<endl;
  return 0;
}

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

char s[100],t[100];
int N;

int main(){
    cin>>N;
    scanf("%s%s",&s,&t);
    for(int i=0;i<N;i++){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int n,k,ans,divi[2333];
map<int,int> mp;
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int calc(int x){
	if(mp.find(x)!=mp.end()) return mp[x];
	int ans=power(k,(x+1)/2);
	for (int i=1;i<=*divi&&divi[i]<x;i++)
		if (x%divi[i]==0) ans=(ans+mo-calc(divi[i]))%mo;
	//printf("%d %d\n",x,ans);
	return mp[x]=ans;
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i*i<=n;i++)
		if (n%i==0){
			divi[++*divi]=i;
			if (i*i!=n) divi[++*divi]=n/i;
		}
	sort(divi+1,divi+*divi+1);
	for (int i=1;i<=*divi;i++)
		ans=(ans+1ll*calc(divi[i])*(divi[i]/(2-(divi[i]&1))))%mo;
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define vll vector<ll>
#define pb push_back

using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

const string Yes = "Yes\n";
const string No = "No\n";

void solve(ll N, string S){
    if (N % 2) cout << No;
    else {
        rep(i, N / 2) {
            if (S.at(i) != S.at(i + N / 2)) {
                cout << No;
                return;
            }
        }
        cout << Yes;
    }
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    string S;
    cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
def abc128_c():
    # n個のスイッチ、m個の電球
    N, M = map(int, input().split())

    connected_switches = []
    for i in range(M):
        # [k, s1, s2, ...sn][1:]
        tmp = list(map(int, input().split()))[1:]
        connected_switches.append(tmp)

    p = list(map(int, input().split()))

    ans = 0

    # スイッチの状態(ON/OFF)をbitですべて列挙する
    for i in range(2 ** N):
        # 各電球が点灯しているかをチェックする
        for j in range(M):
            on_switch_count = 0
            # スイッチがつながっていて、かつ、onになっているものをカウント
            for k in range(N):
                # connected_switches[j]には[s1, s2, ...]が入っているため+1が必要
                if k + 1 in connected_switches[j] and ((i >> k) & 1):
                    on_switch_count += 1

            # 電灯をチェックして一つでもついていないものがあればそのスイッチの状態ではすべての電灯が付くという条件を満たせない
            if on_switch_count % 2 != p[j]:
                break
            
            if j == (M - 1):
                ans += 1

    print(ans)

if __name__ == '__main__':
    abc128_c()


Measured memory_bytes: 9104
#include <iostream>
#include <cmath>
#include <climits>

using namespace std;

int main()
{
    int N, T, E, x, t;
    int ans_idx = 0, ans = INT_MAX;

    cin >> N >> T >> E;

    for (int i = 0; i < N; ++i) {
        cin >> x;

        t = min(abs(T - (T / x) * x), abs(T - ((T + x) / x) * x));
 
        if (t <= E && t < ans) {
            ans = t;
            ans_idx = i + 1;
        }
    }

    if (ans == INT_MAX) {
        cout << "-1\n";
    }
    else
        cout << ans_idx << endl;

    return 0;
}

Measured memory_bytes: 1164
import sys
sa = list(input())
sb = list(input())
sc = list(input())
sa = sa[::-1]
sb = sb[::-1]
sc = sc[::-1]
p = "a"
while True:
    if p == "a":
        if len(sa) > 0:
            p = sa.pop(-1)
        if len(sa) == 0 and p == "a":
            print("A")
            sys.exit()
    elif p == "b":
        if len(sb) > 0:
            p = sb.pop(-1)
        if len(sb) == 0 and p == "b":
            print("B")
            sys.exit()
    else:
        if len(sc) > 0:
            p = sc.pop(-1)
        if len(sc) == 0 and p == "c":
            print("C")
            sys.exit()
    

Measured memory_bytes: 3064
n, m = gets.strip.split.map(&:to_i)
ab = readlines.map {|line| line.strip.split.map(&:to_i) }

graph = Array.new(n+1) { [0]*(n+1) }
ab.each do |a, b|
  graph[a][b] = graph[b][a] = 1
end


p (1..n).to_a.permutation(n).select {|arr| arr.first==1 &&  arr.each_cons(2).all? {|f, t| !graph[f][t].zero? } }.length



Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    string n;
    cin>>n;
  	if(n[5]-'0'||n[6]-'0'>4)cout<<"TBD";
  	else cout<<"Heisei";
	return 0;
}


Measured memory_bytes: 256
A,B,M = map(int,input().split(" "))
F = [int(i) for i in input().split(" ")]
O = [int(j) for j in input().split(" ")]

Min = min(F) + min(O)
for i in range(M):
    x,y,c = map(int,input().split(" "))
    f = F[x-1]
    o = O[y-1]
    C = f+o-c
    if C<Min:
        Min = C
print(Min)

Measured memory_bytes: 18488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,ans=0;
    cin >> n;
    for (ll x = 1; x * x <= n; ++x)
        if ((n-x) % x == 0 && (n-x)/x > x)
            ans += (n-x)/x;
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;

class Program {
  static void Main(string[] args) {
    string str = Console.ReadLine();
    int n = int.Parse(str);
    if (str.Length > 1) n -= (int)(10 * Math.Floor(n / 10.0f));
    if (n == 3) {
      Console.WriteLine("bon");
    }
    else if (((n == 0 || n == 1 ) || n == 6) || n == 8) {
      Console.WriteLine("pon");
    }
    else {
      Console.WriteLine("hon");
    }
  }
}



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


Measured memory_bytes: 2100
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,b,c,d;
 	cin >> a>>b>>c>>d;
 	if(a+b>c+d){
 		cout << "Left" << endl;
 	}else if(a+b<c+d){
 		cout << "Right" << endl;
 	}else{
 		cout << "Balanced" << endl;
 	}
 }

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
 int n,m,t;
  cin >> n >> m >>t;
  if(n+m>=t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <fstream>

int main() {
	std::vector<int> pattern(300, 0); pattern[0] = 1;
	for (auto i = 1; i <= 17; ++i) {
		const auto price = i * i;
		for (auto j = 0; j + price < pattern.size(); ++j) {
			pattern[j + price] += pattern[j];
		}
	}
	while (true) {
		int n; std::cin >> n; if (n == 0) break;
		std::cout << pattern[n] << '\n';
	}
}



Measured memory_bytes: 3004
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n;
char s[1000010];
int num(int x)
{
	int res=0;
	while(x%2==0)res++,x/=2;
	return res;
}
int a[1000010];
int main()
{
	int n;scanf("%d",&n);
	scanf("%s",s);
	n--;
	for(int i=0;i<n;i++)
		a[i]=max(s[i]-s[i+1],s[i+1]-s[i]);
	int cur=0;
	bool flag=false;
	int res=0;
	for(int i=0;i<n;i++)
	{
		if(i)cur+=num(n-i)-num(i);
		if(a[i]==1)
			res^=(cur==0),flag=true;
	}
	if(flag)printf("%d\n",res);
	else{
		cur=0;res=0;
		for(int i=0;i<n;i++)
		{
			if(i)cur+=num(n-i)-num(i);
			if(a[i]==2)
				res^=(cur==0);
		}
		printf("%d\n",res*2);
	}
	return 0;
}

Measured memory_bytes: 5120
h, w, k = map(int,input().split())
S = [list(map(int,list(input()))) for _ in range(h)]

ans = 10**9+7

for i in range(1<<(h-1)):
    group = [[0]*w]
    g_id = 0
    group[g_id] = [s+b for s, b in zip(S[0], group[0])]

    for j in range(1,h):
        if (i>>(j-1))&1:
            group.append([0]*w)
            g_id += 1
        group[g_id] = [s+b for s, b in zip(S[j], group[g_id])]
    
    if not all([all([i <= k for i in b]) for b in group]):
        continue
    
    cnt = len(group) - 1
    g_cnt = [0] * len(group)

    for jj in range(w):
        for g_id in range(len(group)):
            g_cnt[g_id] += group[g_id][jj]
        
        if any([c > k for c in g_cnt]):
            cnt += 1
            for g_id in range(len(group)):
                #縦に切る（グループ全てそこから再開なので全部新規に入れる）
                g_cnt[g_id] = group[g_id][jj]
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3316
<?php
$K = (int)fgets(STDIN);

$map_number_of_lunlun = [];
$map_number_of_lunlun[1] = [];

$sum_before = 0;
$sum = 0;
for ($i = 0; $i < 10; $i++) {
    $map_number_of_lunlun[1][$i] = [$i];
    if ($i !== 0) {
        $sum_before = $sum;
        $sum += 1;
    }
    if ($sum === $K) {
        echo $sum;
        return;
    }
}

$digits = 2;
while ($digits) {
    $map_number_of_lunlun[$digits] = [];
    $last_digits_map = $map_number_of_lunlun[$digits - 1];
    
    for ($i = 0; $i < 10; $i++) {
        if ($i === 0) {
            $map_number_of_lunlun[$digits][0] = array_merge(
                addTopDigitsNum(0, $last_digits_map[0]),
                addTopDigitsNum(0, $last_digits_map[1])
            );
        } elseif ($i === 9) {
            $map_number_of_lunlun[$digits][9] = array_merge(
                addTopDigitsNum(9, $last_digits_map[8]),
                addTopDigitsNum(9, $last_digits_map[9])
            );
        } else {
            $map_number_of_lunlun[$digits][$i] = array_merge(
                addTopDigitsNum($i, $last_digits_map[$i-1]),
                addTopDigitsNum($i, $last_digits_map[$i]),
                addTopDigitsNum($i, $last_digits_map[$i+1]),
            );
        }

        if ($i !== 0) {
            $sum_before = $sum;
            $sum += count($map_number_of_lunlun[$digits][$i]);
        }

        if ($sum >= $K) {
            break 2;
        }
    }
    $digits += 1;
}

echo $map_number_of_lunlun[$digits][$i][$K - $sum_before - 1];

function addTopDigitsNum($num, $array) {
    return array_map(function ($n) use ($num) {
        return $num.$n;
    }, $array);
}

Measured memory_bytes: 25204
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let nk = readn::<usize>(" ");
    let n = nk[0];
    let k = nk[1];
    let d = readn::<usize>(" ");
    let mut num = vec![0; 10];
    for i in 0..k {
        num[d[i]] = 1;
    }

    for i in n..1_000_000 {
        let s = i.to_string().chars().collect::<Vec<char>>();
        let mut flg = true;
        for i in 0..s.len() {
            if num[s[i] as usize - 48] == 1 {
                flg = false;
                break;
            }
        }
        if flg {
            println!("{}", i);
            return;
        }
    }
}

Measured memory_bytes: 4352
# import time
N = int(input())
ssum = 0
# start = time.time()
for k in range(1, N + 1):
    X = int(N / k)
    ssum += k * X * (X + 1) / 2
print(int(ssum))
# elapsed_time = time.time() - start
# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")

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

using namespace std;
using ll = long long;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;
class BinCoef {
  vector<MInt> f;

 public:
  BinCoef(int n) : f(n + 1) {
    f[0] = f[1] = 1;
    for (int i = 2; i <= n; i++) {
      f[i] = MInt(i) * f[i - 1];
    }
  }

  MInt NCM(int n, int m) {
    if (n < m) {
      return 0;
    }
    return f[n] * mod::Inv(f[m] * f[n - m]);
  }
};

int main(int argc, const char *argv[]) {
  ll k, n;
  string s;
  cin >> k >> s;
  n = s.size();

  BinCoef bc(n + k);
  MInt ans = 0;
  for (ll i = 0; i <= k; ++i) {
    auto now = mod::Pow(MInt(26), k - i);
    now *= mod::Pow(MInt(25), i);
    now *= bc.NCM(i + n - 1, n - 1);
    ans += now;
  }

  cout << ans.Get() << '\n';
  return 0;
}

Measured memory_bytes: 19976
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;
	cin >> N;
	ll A[N+1];REP(i,N+1)cin>>A[i];
	ll B[N];REP(i,N)cin>>B[i];
	
	// 解法
	ll ans = 0;
	ll tmp_enemy = 0;
	ll tmp_power = 0;
	REP(i,N+1){
		tmp_enemy = A[i];
		ans += min(tmp_enemy, tmp_power);
		// printf("ans: %lld\n", ans);
		tmp_enemy = max((ll)0, tmp_enemy - tmp_power);
		if (i==N) break;
		tmp_power = B[i];
		ans += min(tmp_enemy, tmp_power);
		tmp_power = max((ll)0, tmp_power - tmp_enemy);
		// printf("ans: %lld\n", ans);
	}
	
	//出力
	cout << ans << endl;
}


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

int main(){
    
    int n,a,b;
    cin >> n >> a >> b;
    
    int ans=0;
    rep(i,1,n+1){
        string s=to_string(i);
        int sum=0;
        rp(j,s.size()){
            sum += s.at(j)-'0';
        }
        if(sum>=a&&sum<=b){
            ans += i;
        }
    }
    
    cout << ans << endl;


    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
#define N 1000
#define N2 N*N
bool prime[N2+1];
int cave[N+2][N+2]={};
pair<int,int> locate[N2+1];
int last[N+2][N+2];
int dp[N+2][N+2];
int m,n;

bool wall(int x,int y){ return x==0 || y==0 || x==N+1 || y==N+1; }

int rec(int x,int y){
    if(wall(x,y) || cave[x][y]>m)return 0;
    if(dp[x][y])return dp[x][y];
    pair<int,int> child[3];
    rep(i,3)child[i]=pair<int,int>(rec(x+i-1,y-1),last[x+i-1][y-1]);
    sort(child,child+3);
    dp[x][y]=child[2].first;
    if(prime[cave[x][y]])dp[x][y]++;
    last[x][y]=child[2].second;
    if(last[x][y]==0 && prime[cave[x][y]]) last[x][y]=cave[x][y];
    return dp[x][y];
}

int main(void){
    rep1(i,N2)prime[i]=true;
    prime[0]=prime[1]=false;
    for(int i=2;i<=N2;i++){
        if(prime[i]) for(int k=2;i*k<=N2;k++) prime[i*k]=false;
    }

    int x=1,y=N,d=0;
    int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
    for(int i=N2;i>0;i--){
        cave[x][y]=i;
        locate[i] = pair<int,int>(x,y);
        if(wall(x+dx[d],y+dy[d]) || cave[x+dx[d]][y+dy[d]]) d=(d+1)%4;
        x+=dx[d];
        y+=dy[d];
    }

    while(cin>>m>>n, m|n){
        rep1(x,N)rep1(y,N) dp[x][y]=last[x][y]=0;
        int x=locate[n].first,y=locate[n].second;
        int cnt = rec(x,y);
        printf("%d %d\n",cnt,last[x][y]);
    }

    return 0;
}

Measured memory_bytes: 21808
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
    long long n, p = 0;
    cin >> n;
    long long a[n], s[n - 1];
    cin >> a[0];
    s[0] = a[0];
    for (int i = 1; i < n; i++)
    {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
        s[i] %= mod;
    }
    for (int i = 0; i < n - 1; i++)
    {
        p += s[i] * a[i + 1];
        p %= mod;
    }
    cout << p;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


ll inv(ll a,ll count) {

	ll res = 1;
	int p = count;
	while (p>0) {
		if (p & 1 == 1) { res *= a; }
		a = a*a;
		p >>= 1;
	}
	return res;
}

int main()
{
	ll N, P,p;
	cin >> N >> P;
	p = P;
	ll i = 2;
	bool flag = true;

	ll ans = 1;
	while (P>1){
		if (P%i==0) {
			int count = 0;
			while (P%i==0) {
				P /= i;
				count++;
			}
			count /= N;
			ans *=inv(i, count);

			flag = false;
		}
			i++;
			if (i*i>P) {
				break;
			}
		
	}

	if (flag) {
		if (N==1) {
			ce(p)
		}
		else {
			ce(1)
		}

	}
	else {
		if (N==1) {
			ce(p)
		}
		else {
			ce(ans)
		}
	}

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
 
int main(void){
  std::string s;
  std::cin >> s;
  int flag = 0;
  for(int i = 0; i < 3 && flag == 0; i++){
  	for(int j = i + 1; j < 3 && flag == 0; j++){
      if(s[i] != s[j])
        flag = 1;
    }
  }
  if(flag == 1){
    std::cout << "Yes";
  }else{
    std::cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;const int N=2e5+5;long long a[N],d[N],s[N],n,i;main(){cin>>n;for(;i<n;++i)cin>>a[i],s[i]=(i>1?s[i-2]:0)+a[i];for(i=1;i<n;++i)if(i&1)d[i]=max(s[i-1],d[i-2]+a[i]);else	d[i]=max(d[i-1],d[i-2]+a[i]);cout<<d[n-1];}

Measured memory_bytes: 8280
a = input()
l_si=a.split()
l_si_i = [int(s) for s in l_si]
print(max(l_si_i[0]*l_si_i[2],l_si_i[0]*l_si_i[3],l_si_i[1]*l_si_i[2],l_si_i[1]*l_si_i[3]))


Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back

main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,m;
	cin>>n>>m;
	string arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];

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

	for(int i=0;i<n;i++)
	{
		int c=0;
		for(int j=0;j<m;j++)
		{
			if(arr[i][j]=='#')
				c=0;
			else
			{
				c++;
				v[i][j]+=c;
			}
		}

		c=0;
		for(int j=m-1;j>=0;j--)
		{
			if(arr[i][j]=='#')
				c=0;
			else
			{
				v[i][j]+=c;
				c++;
			}
		}
	}

	for(int i=0;i<m;i++)
	{
		int c=0;
		for(int j=0;j<n;j++)
		{
			if(arr[j][i]=='#')
				c=0;
			else
			{
				v[j][i]+=c;
				c++;
			}
		}

		c=0;
		for(int j=n-1;j>=0;j--)
		{
			if(arr[j][i]=='#')
				c=0;
			else
			{
				v[j][i]+=c;
				c++;
			}
		}
	}

	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			ans=max(ans,v[i][j]);
	}

	cout<<ans;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
char in[1000];
int a;
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> a >> in;
	if(a < 3200)puts("red");
	else puts(in);
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
aa = inpl()

tmp = 0
for a in aa:
    if a%2 == 1:
        tmp += 1

if tmp%2 == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 15452
#include<bits/stdc++.h>
using namespace std;
const int N=200005,M=20;
int cnt,ans[N],n,m,x[N],a[M],tot,le[M][N],ri[M][N],dp1[1<<M],dp2[1<<M];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%d",&x[i]);
	while (m){
		a[++tot]=m;
		m/=2;
	}
	reverse(a+1,a+tot+1);
	for (int i=0;i<=tot;i++)
		for (int j=1;j<=n;j++)
			if (j==1||x[j]-x[j-1]>a[i])le[i][j]=j;
			else le[i][j]=le[i][j-1];
	for (int i=0;i<=tot;i++)
		for (int j=n;j;j--)
			if (j==n||x[j+1]-x[j]>a[i])ri[i][j]=j;
			else ri[i][j]=ri[i][j+1];
	for (int i=1;i<1<<tot;i++)
		for (int j=0;j<tot;j++)
			if (i&(1<<j)){
				int t=dp1[i^(1<<j)];
				if (t==n)dp1[i]=n;
				else dp1[i]=max(dp1[i],ri[j][t+1]);
			}
	for (int i=0;i<1<<tot;i++)dp2[i]=n+1;
	for (int i=1;i<1<<tot;i++)
		for (int j=0;j<tot;j++)
			if (i&(1<<j)){
				int t=dp2[i^(1<<j)];
				if (t==1)dp2[i]=1;
				else dp2[i]=min(dp2[i],le[j][t-1]);
			}
	for (int i=1;i<=n;i++)
		if (ans[le[tot][i]]){
			if (ans[le[tot][i]]==1)puts("Possible");
			else puts("Impossible");
		}
		else {
			cnt++;
			if (cnt>20){
				puts("Impossible");
				continue;
			}
			ans[le[tot][i]]=2;
			for (int j=0;j<1<<tot;j++)
				if (dp1[j]>=le[tot][i]-1&&dp2[((1<<tot)-1)^j]<=ri[tot][i]+1)ans[le[tot][i]]=1;
			if (ans[le[tot][i]]==1)puts("Possible");
			else puts("Impossible");
		}
}


Measured memory_bytes: 38272
N = int(input())
H = list(map(int, input().split()))

f = False #まだ下げられる->False / もう下げられない->True
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] > 1:
        print("No")
        exit()
    elif H[i-1] - H[i] == 1 and not f:
        f = True
    elif H[i-1] - H[i] == 1 and f:
        print("No")
        exit()
    elif H[i-1] - H[i] == 0:
        pass
    elif H[i-1] - H[i] < 0:
        f = False
print("Yes")

Measured memory_bytes: 20600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int C  = keyboard.nextInt();
		int D  = keyboard.nextInt();
		String S = keyboard.next();
		
		String[] masu = S.split("");
		
		String ans = "Yes";
		if(C > D) {	
		  ans = "No";
        int count = 0;
        for(int m = B-2; m <= D; m++) {
          if(masu[m].equals("#")) {
              count = 0;
          } else {
                  count++;
                  if(count == 3) {
                      ans = "Yes";
                      break;
                  }
            }
          }	
      }
		
		if(ans.equals("Yes")) {
			for(int i = B-1; i < D-1; i++) {
				if(masu[i+1].equals(".")) {
					continue;
				}else if(masu[i+2].equals(".")) {
                	i++;
				}else {
					ans = "No";
					break;
				}
			}
		}
		
		if(ans.equals("Yes")) {
			for(int i = A-1; i < C-1; i++) {
				if(masu[i+1].equals(".")) {
					continue;
				}else if(masu[i+2].equals(".")) {
                	i++;
				}else {
					ans = "No";
					break;
				}
			}
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 53032
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int n;
    int a[100];
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n, greater<int>());
    int x = 0;
    int y = 0;
    for (int i =0; i<n; ++i){
        if (i % 2 == 0) {
            x += a[i];
        }
        else y += a[i];
    }
    cout << x - y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	t.pop_back();
	cout<<(s==t?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;

int main(){
    char x;
    while(true){
        scanf("%c",&x);
        if(isalpha(x)){
            if(islower(x)){
                cout << (char)toupper(x);
            }else if (isupper(x)){
                cout << (char)tolower(x);
            }
        }else{
            printf("%c",x);
        }

        if(x == '\n'){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3152
if __name__ == "__main__":
    n = int(input())

    a = list(map(int, input().split()))


    if 0 in a:
      print(0)
      exit(0)

    sorted_a = sorted(a, reverse=True)

    ans = 1    
    for i in sorted_a:
      ans *= i
      if (ans > pow(10, 18)):
        print(-1)
        exit(0)

    print(ans)

Measured memory_bytes: 21724
# include <cstdio>
int main()
{
	int N , C ;
	int s [100000] , t [100000] , c [100000];
	int sm [200002];
	int tt [200002];
	
	scanf("%d %d" ,&N ,& C );
	for(int i =0;i < N ;i++)	scanf("%d %d %d" ,& s[i] ,&t[i] ,&c[i]);
	for(int i =1;i <= C ;i++)
	{	
		for(int j =0; j <200002; j++) tt[j]=0;
		for(int j =0; j < N ; j++) if (c[j]== i) tt[s[j]*2-1]++, tt[t[j]*2] --;
		for(int j =1; j <200002; j++) tt[j]+= tt[j-1];
		for(int j =0; j <200002; j++) if(tt[j] >0) sm[j]++;
	}
	int mx =0;
	for (int j =0;j <200002;j++) if( mx < sm[j]) mx = sm[j];
	printf ("%d\n" ,mx );

	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <string>
using namespace std;

enum Command {
  INSERT,
  FIND
};

int main(){
  int n;
  int which_command;
  unordered_set <string> A;
  string word;
  cin >> n;
  for (int i=0; i<2*n; i++){
    cin >> word;
    if (word == "insert") {
        which_command = INSERT;
    } else if (word == "find") {
        which_command = FIND;
    } else {
      switch (which_command){
        case INSERT:
          A.insert(word);
          break;
        case FIND:
          if (A.count(word) > 0)
            cout << "yes" << endl;
          else
            cout << "no" << endl;
          break;
        default:
          break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 30568
#include<stdio.h>
#include<string.h>
int main(void){
    char s[120];
    scanf("%s",s);
    int count = 0;
    int a = strlen(s);
    for (int i = 0; i < a/2; i++)
    {
        if (s[i] != s[a - i - 1])
        {
            count ++;
        }   
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int sum=0;
  for(int i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-i-1]) sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
        cout<<a*b/__gcd(a,b);
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, p;
	cin >> n >> p;

	int odds = 0;
	int a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (a & 1) {
			++odds;
		}
	}

	int e = n;
	if (odds) {
		--e;
	} else {
		if (p & 1) {
			cout << "0\n";
			return 0;
		}
	}

	cout << ((long long) 1 << e) << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int a, b, c;
  std::cin >> a >> b >> c;
  int x = 0;
  int y = 0;
  if (a + b + c == 17 and a*b*c == 175)
  {
    std::cout << "YES" << std::endl;
  }
  else{
    std::cout << "NO" << std::endl;
  }
}

Measured memory_bytes: 256
def main():
    A, B, C = map(int, input().split())
    K = int(input())

    cnt = 0
    while A >= B:
        B *= 2
        cnt += 1
    while B >= C:
        C *= 2
        cnt += 1
    print('Yes' if cnt <= K else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9108
input_values = input().split()
int_values = []
for i in input_values:
    int_values.append(int(i))
a = int(int_values[0] / int_values[1])
b = int_values[0] % int_values[1]
c = round(int_values[0] / int_values[1], 6)
print("{0} {1} {2:.5f}".format(a, b, c))



Measured memory_bytes: 5624
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var H = cin.ReadInt;
            var A = cin.ReadInt;
            int ans = H%A == 0 ? H/A : H/A + 1;
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 13268
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  ll N, K; cin >> N >> K;
  ll ans = N % K;
  ans = min(ans, abs(ans - K));
  cout << ans << endl;
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vvi vector<vector<int>>;
#define mi  map<int,int>
#define mii map<pii,int>
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define sz(x) (int)x.size()
#define all(v) (v).begin(), (v).end()
#define ret(x) return cout<<x,0;
#define rety return cout<<"YES",0;
#define retn return cout<<"NO",0;
#define fl fflush(stdout)   
#define hell 1000000007  
#define hell2 998244353 
#define pi 3.14159265358979323846

int solve(){
    int n;
    cin>>n;
    cout<<!n;
    //cout<<((n+1)&1);
    return 0;
}

signed main(){
    auto start = high_resolution_clock::now();
    IOS;
    int t=1;

   // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr<<"Time taken:"<<duration.count()/1000000.0<<"seconds"<<"\n";
    return 0;
} 

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

const int MAX = 300;
const int MAX2 = 90000;

int Dist(pair<int, int> p, pair<int, int> q) { // 点Pから点Qへの距離
	return abs(p.first - q.first) + abs(p.second - q.second);
}
int main() {
	int H, W, D;
	cin >> H >> W >> D;
	int A;
	static pair<int, int> num[MAX2]; // ある値がどこにあるか分かっていた方が楽なので
	for (int i = 0;i < H;i ++) {
		for (int j = 0;j < W;j ++) {
			cin >> A;
			num[A - 1] = make_pair(j, i);
		}
	}
	// ここから下準備
	static int SUM[MAX2]; // 累積和
	for (int i = 0;i < D;i ++) {
		SUM[i] = 0; // ここは距離0なのは当然
	}
	for (int i = D;i < H * W;i ++) {
		SUM[i] = SUM[i - D] + Dist(num[i], num[i - D]); // i-Dからiへ行くコストは当然だがi-Dとiの距離に等しいので
//		cout << i << ":" << SUM[i] << endl; // デバッグ用
	}
	
	int Q, L, R;
	cin >> Q;
	for (int i = 0;i < Q;i ++) {
		cin >> L >> R;
		cout << SUM[R - 1] - SUM[L - 1];
		if (i < Q - 1) cout << endl; // 改行忘れにご注意を
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、この手のクエリ型(毎回課題が与えられる)に対し、馬鹿正直にシミュレーションをすべきではない
Qが10^5であり、オーダーの末尾にQが付くので、各クエリのオーダーがO(1)かO(log(HW))でないと計算が間に合わないからだ

まず考えるのは、予め全てのLから全てのRへ行くコストを求めておく方法だね
これが終わっていれば、各クエリはO(1)で終わるでしょう
だけどLR<=300^4=81*10^8より却下

次に、問題自体に着目すると、次のことが分かる
LからRへ行くコストは、LからL+Dへ行くコストとL+DからRへ行くコストの和に等しい
この形式を取る場合、累積和が使えることが多いので検討する
今、累積和としてSUM[HW]を定義し、SUM[i]はi%Dからiまで行くコストの和だと考える
この時、LからRへ行くコストはSUM[R]-SUM[L]で求められることが分かる
(→SUM[R]-SUM[L] = R%DからRへ行くコスト - L%DからLへ行くコストであり、L%D=R%Dである)
よって各クエリに付きO(1)で求められるので、全体はO(Q)で求められることが分かった
下準備にはO(HW)掛かっているので、オーダーはO(max(HW, Q))だね
*/

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  string o, e; cin >> o >> e;

  string ans = "";
  int len = o.length() + e.length();

  int cntO = 0;
  int cntE = 0;

  reps(i, 1, len) {
    if( i % 2 == 0 ) {
      ans.pb(e[cntO]);
      ++cntO;
    }

    else {
      ans.pb(o[cntE]);
      ++cntE;
    }
  }

  cout << ans << endl;

  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 063 B / Link: http://abc063.contest.atcoder.jp/tasks/abc063_b  ----- */


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

	string s; cin >> s;
	LL ans = 1;
	set<char>ss;
	for (auto c : s) {
		if (ss.count(c))ans = 0;
		else ss.insert(c);
	}
	
	
	cout << (ans?"yes":"no") << "\n";

	return 0;
}


Measured memory_bytes: 256