akhauriyash/Code-Regression huggingface dataset:
n, a, b, c = map(int, input().split())
d = {'A':a, 'B':b, 'C':c}
ns = []
for i in range(n):
    ns.append(input())
path = []
flag = True
for i, j in enumerate(ns):
    x, y = j
    if d[x] > d[y]:
        d[x] -= 1
        d[y] += 1
        path.append(y)
    elif d[x] < d[y]:
        d[x] += 1
        d[y] -= 1
        path.append(x)
    else:
        if d[x] == 0:
            flag = False
            print('No')
            break
        if i + 1 < n:
            if x in ns[i + 1]:
                d[x] += 1
                d[y] -= 1
                path.append(x)
            else:
                d[y] += 1
                d[x] -= 1
                path.append(y)
        else:
            path.append(x)
if flag:
    print('Yes')
    for i in path:
        print(i)
    



Measured memory_bytes: 86564
#include <stdio.h>

int x[5005];

int solve(int l, int u) {
	int m, i, sum, lmax, rmax;
	int r2max, l2max;
	if(l>u) return 0;
	
	if(l==u) {
		return x[l];
	}
	
	m = (l + u) / 2;
	// 左側
	lmax = -200000000;
	sum = 0;
	for(i=m;i>=l;i--) {
		sum += x[i];
		if(lmax < sum) lmax = sum;
	}
	
	// 右側
	rmax = -2000000000;
	sum = 0;
	for(i=m+1;i<=u;i++) {
		sum += x[i];
		if(rmax < sum) rmax = sum;
	}
	
	// さらに分轄
	l2max = solve(l, m);
	r2max = solve(m+1, u);
	if(l2max < r2max) l2max = r2max;
	if(lmax+rmax > l2max) l2max = lmax+rmax;
	return l2max;
}

int main(void) {
	int i, n;
	
	while(scanf("%d\n", &n) == 1) {
		if(n==0) break;
		for(i=0;i<n;i++) {
			scanf("%d\n", &x[i]);
		}
		printf("%d\n", solve(0, n-1));
	}
	
	return 0;
}

Measured memory_bytes: 616
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		for (int i = 1; i < n; i++) {
			if(a[i - 1] == a[i]) {
				cnt++;
				a[i] = Integer.MAX_VALUE;
			}
		}
		System.out.println(cnt);
	}

}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,M;
  map<string,ll> coin;
  cin>>N;
  rep(i,N){
    string d;
    cin>>d;
    coin[d]++;
  }
  cin>>M;
  rep(i,M){
    string d;
    cin>>d;
    coin[d]--;
  }
  ll ans=0;
  for(auto i=coin.begin();i!=coin.end();i++){
    ans=max(ans,i->second);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int solve(int *arr,int n){
    if(n==-1||n==0){
        return 0;
    }
    
    if(n-1>=0||n-2>=0){
        if(n-1>=0&&n-2>=0){
            return min(abs(arr[n]-arr[n-1])+solve(arr,n-1),abs(arr[n]-arr[n-2])+solve(arr,n-2));
        }
        else if(n-1>=0){
            return abs(arr[n]-arr[n-1])+solve(arr,n-1);
        }
        else if(n-2>=0){
            return abs(arr[n]-arr[n-2])+solve(arr,n-2);
        }
       
    }
    
}
int dp_solve(int *arr,int n){
    int dp[n+1];
    dp[0]=0;
    for(int i=1;i<=n;i++){
        if(i-1>=0&&i-2>=0){
            dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
        }
        else if(i-1>=0){
            dp[i]=abs(arr[i]-arr[i-1])+dp[i-1];
        }
        else if(i-2>=0){
            dp[i]=abs(arr[i]-arr[i-2])+dp[i-2];
        }
    }
    // for(int i=0;i<=n;i++){
    //     cout<<dp[i]<<" ";
    // }
    return dp[n];
}
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
    cin>>arr[i];
}
cout<<dp_solve(arr,n-1)<<endl;
 return 0;
} 

Measured memory_bytes: 1024
#include<stdio.h>

int count;

int def(int x, int y){

  if(y==0){
    return x;
  }else{
    count++;
    return def(y, x%y);
  }
}

int main(){
  int ans,a,b;

  while(scanf("%d%d",&a,&b),a){

    count=0;

    if(a > b)ans = def(a, b);
    else ans = def(b, a);


    printf("%d %d\n",ans,count);

  }


  return 0;

}

Measured memory_bytes: 600
#include<stdio.h>
int main(){
  int n, ans = 1;
  char s[101];
  scanf("%d", &n);
  scanf("%s", s);
  if(n % 2) ans  = 0;
  for(int i = 0; i < n / 2; ++i){
    if(s[i] != s[i + n / 2]) ans = 0;
  }
  if(ans) puts("Yes");
  else puts("No");
  return 0;
}

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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    ll n, k, q, tmp;
    cin >> n >> k >> q;
    vector<ll> A(n, 0);
    for(int i = 0; i < q; i++) {
        cin >> tmp;
        A[tmp - 1] += 1;
    }
    for(int i = 0; i < n; i++)
        cout << (k + A[i] - q > 0 ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);
 
int main(){
    IOS;
    ll n,m;cin>>n>>m;
    ll ac[n+1],wa[n+1];
    for(ll i=0;i<n+1;i++){ac[i]=0;wa[i]=0;}
    f(i,0,m){
        ll a;cin>>a;
        string s;cin>>s;
        if(s=="AC")ac[a]=1;
        else if(s=="WA" && ac[a]!=1)wa[a]++;
    }
    ll c=0;
    f(i,0,n+1){
        if(ac[i])c++;
    }
    ll w=0;
    f(i,0,n+1){
        if(wa[i] && ac[i])w+=wa[i];
    }
    cout<<c<<" "<<w;
    return 0;
}   

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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


  vec v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K; cin >> K;
  cout << v[K-1] << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val c = mutableListOf<List<Int>>()
    for (i in 1..3) {
        c.add(readLine()!!.split(" ").map(String::toInt))
    }
    val b1 = c[0][0]
    val b2 = c[0][1]
    val b3 = c[0][2]

    val a2 = c[1][0] - b1
    val a3 = c[2][0] - b1
    if ((c[1][1] == a2 + b2)
            && (c[1][2] == a2 + b3)
            && (c[2][1] == a3 + b2)
            && (c[2][2] == a3 + b3)) {
        println("Yes")
    } else {
        println("No")
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define F first
#define S second
#define db(x) cerr << #x << ": " << x << "\n";

ll count(vi A, vi B, vi C) {
    ll res = 0;
    for(int & a : A) 
        for(int & b : B) {
            if(b < a) 
                continue;
            int dist = b - a;
            auto it = upper_bound(C.begin(), C.end(), b);
            auto it2 = equal_range(C.begin(), C.end(), b+dist);
            res += distance(it, C.end()) - distance(it2.F, it2.S);
        }
    return res;
}

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

    int N; string s;
    cin >> N >> s;
    vi R, G, B;
    for(int i=0; i<N; i++) {
        if(s[i] == 'R')
            R.emplace_back(i);
        else if(s[i] == 'G')
            G.emplace_back(i);
        else 
            B.emplace_back(i);
    }
    ll cnt = 0;
    cnt += count(R, G, B);
    cnt += count(R, B, G);
    cnt += count(B, R, G);
    cnt += count(B, G, R);
    cnt += count(G, R, B);
    cnt += count(G, B, R);
    cout << cnt << "\n";
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(){
    int a,b,i,j;
    scanf("%d %d",&a,&b);
    while(1){
        if(a==0&&b==0){
            break;
        }
        else{
            for(i=0;i<a;i++){
                for(j=0;j<b;j++){
                    if((i+j)%2==0){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
                printf("\n");
            }
            printf("\n");
            scanf("%d %d",&a,&b);
        }
    }
    return 0;
}


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

struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int N,Q; cin >> N >> Q;
    dsu uf(N);
    while(Q--){
        int t,u,v; cin >> t >> u >> v;
        if(t) cout << uf.same(u,v) << "\n";
        else uf.merge(u,v);
    }
    
    return 0;
}


Measured memory_bytes: 3972
#include <stdio.h>

int main(){
	int A,B,C;
	scanf("%d %d %d", &A, &B, &C);
	int cnt = 0;
	for(int i = 1; i <= A; i++){
		int number = i;
		int sum = 0;
		while(number != 0){
			sum += number % 10;
			number /= 10;
		}
		if(sum >= B && sum <= C){
			cnt += i;
		}
		
	}
	printf("%d\n", cnt);
	
	return 0;
}

Measured memory_bytes: 1724
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }





//---------- ceil(n/m) ----------
int int_ceil(int n, int m)
{
	if (n % m == 0) return n / m;
	return n / m + 1;
}


signed main()
{
	int N, X, T;
	cin >> N >> X >> T;
	cout << (int_ceil(N, X) * T) << endl;
}



Measured memory_bytes: 3192
N, T = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

res = 10000

for i in range(N):
  if L[i][1] <= T:
    if res > L[i][0]:
      res = L[i][0]
     
if res == 10000:
  res = 'TLE'
print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <set>
#include <memory.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n <= 999){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod=10**9+7
g1=[1,1]
g2=[1,1]
inverse=[0,1]
for i in range(2,N*M+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)
ans=0
for i in range(1,N):
  ans+=i*(N-i)*M*M
for j in range(1,M):
  ans+=j*(M-j)*N*N
ans*=cmb(N*M-2,K-2,mod)
print(ans%mod)

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

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  float a[n];
  float ac=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(int i=0;i<n;i++)
  {
     ac+=1/a[i];
  }
  float b=1/ac;
  cout<<b;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		int a,d=0;
		Scanner sc=new Scanner(System.in);
		a=sc.nextInt();
		int c=sc.nextInt();
		for(int i=0;i<a;i++)
		{
			int b=a-(i*c);
			if(b<=0)
			{
				System.out.println(i);
				System.exit(0);
			}
			else
			{
				d++;
			}
			
			
		}
		System.out.println(d);
	
	}
}

Measured memory_bytes: 23252
nt=input().split()
n ,t = int(nt[0]),int(nt[1])
tlist=[int(x) for x in input().split()]
#print(n,t,tlist)
pretick =0
total=0
for tick in tlist:
  if tick==0:
    total+=t
  else:
    if pretick + t > tick:
      total+=(tick-pretick)
#      print(pretick,t,tick,tick-pretick,total)
    else:
      total+=t
  pretick=tick
#total+=t
print(total)

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

int main() {
  int k, L, sum = 0;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) sum = -1;

  else {
    L = 9 * k;
    if (L % 7 == 0) L /= 7;
    
    int i = 10;
    bool jug = true;
    while (jug) {
      sum++;
      i %= L;
      if (i == 1) {
        jug = false;
      }
      i *= 10;
    }
  } 
  cout << sum << endl;
}

Measured memory_bytes: 3632
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str) { return str.split.to!(T[]); }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

void main()
{
	auto S = RD!string;

	char last = S[0];
	long cnt;
	long[] blocks;
	foreach (i; 0..S.length)
	{
		if (last == S[i])
		{
			++cnt;
		}
		else
		{
			last = S[i];
			blocks ~= cnt;
			cnt = 1;
		}
	}
	blocks ~= cnt;

	auto dp = new long[2][](blocks.length+1);
	foreach (i; 0..blocks.length)
	{
		dp[i+1][0] = dp[i][0] + blocks[i];
	}
	foreach_reverse (i; 0..blocks.length)
	{
		dp[i][1] = dp[i+1][1] + blocks[i];
	}

	long ans = long.max;
	foreach (i; 1..dp.length)
	{
		ans = min(ans, max(dp[i][0], dp[i][1]));
	}
	stderr.writeln(dp);

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  map<ll,ll> mp;
  vector<ll> vec;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    mp[A[i]]++;
  }
  for (auto p : mp) {
    for (int i = 0; i < p.S/2; i++) {
      vec.push_back(p.F);
    }
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  ll ans = 0;
  if (vec.size() >= 2) {
    ans = vec[0] * vec[1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10524
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

const int MAX = 510000;
//const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    int R;
    cin >> R;

    if (R < 1200)
        cout << "ABC" << endl;
    else if (R < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <memory>
#include <vector>

int main()
{
    int n;

    std::cin >> n;

    std::vector<int> hps(n);

    for(int i=0; i<n; i++)
    {
        std::cin >> hps[i];
    }

    while(hps.size()>1)
    {
        std::sort(hps.begin(), hps.end());
        while(hps[0]<=0)
            hps.erase(hps.begin());

        for(int i=1; i<hps.size(); i++)
        {
            hps[i] %= hps[0];
        }
    }

    std::cout << hps[0] << std::endl;

    return 0;
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
  	cin>>s;
  	ll n=s.size(),c=0;
  	for(int i=0;i<n/2;i++)
    {
      if(s[i]!=s[n-1-i])
           c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
#define MAX 1e9
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
#define MOD 1000000007

int main(){
  ll N;
  cin>>N;
  string ans="";
  while(true){
    if(N==0ll){break;}
    N--;
    ll x=N%26ll;
    if(x==0ll){ans="a"+ans;}
    if(x==1ll){ans="b"+ans;}
    if(x==2ll){ans="c"+ans;}
    if(x==3ll){ans="d"+ans;}
    if(x==4ll){ans="e"+ans;}
    if(x==5ll){ans="f"+ans;}
    if(x==6ll){ans="g"+ans;}
    if(x==7ll){ans="h"+ans;}
    if(x==8ll){ans="i"+ans;}
    if(x==9ll){ans="j"+ans;}
    if(x==10ll){ans="k"+ans;}
    if(x==11ll){ans="l"+ans;}
    if(x==12ll){ans="m"+ans;}
    if(x==13ll){ans="n"+ans;}
    if(x==14ll){ans="o"+ans;}
    if(x==15ll){ans="p"+ans;}
    if(x==16ll){ans="q"+ans;}
    if(x==17ll){ans="r"+ans;}
    if(x==18ll){ans="s"+ans;}
    if(x==19ll){ans="t"+ans;}
    if(x==20ll){ans="u"+ans;}
    if(x==21ll){ans="v"+ans;}
    if(x==22ll){ans="w"+ans;}
    if(x==23ll){ans="x"+ans;}
    if(x==24ll){ans="y"+ans;}
    if(x==25ll){ans="z"+ans;}
    N/=26ll;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
N = int(input())
a = list(map(int, input().split()))
 
import heapq

left = [0]*(N+1)
l = a[:N]
left[0] = sum(l)

heapq.heapify(l)
for i in range(1, N+1):
    c = a[N+i-1]    
    lmin = heapq.heappop(l)
    if lmin < c:
        left[i] = left[i-1] + c - lmin
        heapq.heappush(l, c)
    else:
        left[i] = left[i-1]
        heapq.heappush(l, lmin)

a = [-x for x in a[::-1]]
right = [0]*(N+1)
r = a[:N]
right[0] = sum(r)

heapq.heapify(r)
for i in range(1, N+1):
    c = -a[N+i-1]    
    rmax = -heapq.heappop(r)
    if rmax > c:
        right[i] = right[i-1] - c + rmax
        heapq.heappush(r, -c)
    else:
        right[i] = right[i-1]
        heapq.heappush(r, -rmax)

ans = -10**20
for i in range(N+1):
    ans = max(ans, left[i] + right[N-i])

print(ans)

Measured memory_bytes: 42748
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

int main() {
    std::string s;
    std::cin >> s;
    
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        std::cout << -1 << std::endl;
        return 0;
    }

    if (s.size() < 26) {
        std::set<char> ab;
        for (auto i = 0; i < 26; i++) ab.insert('a' + i);
        char m = 'a';
        for (auto c : s) ab.erase(c);
        std::cout << s + *ab.begin() << std::endl;
        return 0;
    } else {
        for (auto i = 24; i >= 0; i--) {
            if (s[i] > s[i+1]) continue;
            char c = 'z';
            for (auto j = i + 1; j < 26; j++) {
                if (s[i] < s[j]) c = std::min(c, s[j]);
            }
            s[i] = c;
            s.erase(s.begin() + i + 1, s.end());
            std::cout << s << std::endl;
            return 0;
        }
    }

    return 0;
}

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

int main() 
{
    int a,b;
    cin >> a >> b;
    int i;
    int x,y,z,u,v;
    int count = 0;
    for(i = a ; i <= b ; i++ )
    {
        x = i / 10000;
        y = (i % 10000) / 1000;
        z = (i % 1000) / 100;
        u = ( i % 100) / 10;
        v = i % 10;
        if(i == 10000 * v + 1000 * u + 100 * z + 10 * y + x)
        {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    int N, K; cin >> N >> K;
    int result = 0;
    REP(i, N) {
        int x; cin >> x;
        result += min(2*x, 2*abs(x-K));
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 11
#define ull unsigned long long
using namespace std;
ull a[INF];
inline ull read()
{
	ull number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline ull gcd(ull m,ull n)
{
	return (!n)?m:gcd(n,m%n);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    int n=read();
    for(int i=1;i<=n;i++)
        a[i]=read();
    for(int i=2;i<=n;i++)
        a[i]=a[i]/gcd(a[i],a[i-1])*a[i-1];
    cout<<a[n];
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
import sys

input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv


def solve():
    N, K = map(int, input().split())
    blue = K
    red = N - K
    comb = Combination(2000, mod)

    # i == 0
    print(red + 1)

    # i >= 1
    for i in range(1, blue):
        c = comb(blue - 1, i)
        t = 0
        for j in range(i - 1, red):
            t += comb(j, i - 1) * (red - j)
            t %= mod
        ans = (c * t) % mod
        print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 42860
/* It's a shot in the dark
 				But I will make it */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
       ll n;
       cin >>n;
       ll x=1000;
       while(n>x){
       	x+=1000;
	   }
	   cout <<x-n<<"\n";
}


Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
char a[200000+5];
int alen,cnt,res;
int main()
{
	scanf("%s",a);
	alen=res=strlen(a);
	for(int i=0;i<alen;i++)
	{
		if(a[i]=='S')
			cnt++;
		if(a[i]=='T'&&cnt>=1)
		{
			cnt--;
			res-=2;
		}
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
using namespace std;
char map[101][101];
int h,w,d1[8]={0,0,-1,1,1,-1,1,-1},d2[8]={1,-1,0,0,1,-1,-1,1};
char search(int x,int y)
{
	char ans='0';
	for(int i=0;i<8;i++)
		if(map[x+d1[i]][y+d2[i]]=='#')
			ans++;
	return ans;
}
int main()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>map[i][j];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(map[i][j]=='.')
				map[i][j]=search(i,j);
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
			cout<<map[i][j];
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n, m, b = 0, w = 0;
char s[401][401];

bool vis[404][401];

void dfs(int i, int j){
	if(vis[i][j]) return;
	char clr = s[i][j];
	vis[i][j] = 1;
	if(clr == '.') b++;
	else w++;

	if(i > 1 and s[i - 1][j] != clr) dfs(i - 1, j);
	if(i < n and s[i + 1][j] != clr) dfs(i + 1, j);
	if(j > 1 and s[i][j - 1] != clr) dfs(i, j - 1);
	if(j < m and s[i][j + 1] != clr) dfs(i, j + 1); 
}
signed main()
{
	
 	FLASH


 	cin>>n>>m;
 	fr(i, 1, n + 1){
 		fr(j, 1, m + 1){
 			cin>>s[i][j];
 		}
 	}

 	int ans = 0;
 	
 	fr(i, 1, n + 1){
 		fr(j, 1, m + 1){
 			if(!vis[i][j]){
 				dfs(i,j);
 				ans += b*w;
 				b = w = 0;
 			}
 		}
 	}
 	cout<<ans;
}

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

int main(){
  
  int day = 0;
  int M = 0;
  std::cin >> day >> M;
  
  std::vector<int> homework(M+1); 
  
  homework.at(0) = 0;
  
  for(int cnt = 1; cnt <= M; cnt++){
    std::cin >> homework.at(cnt);
  }
  
  int sum = 0;
  for(int cnt = 1; cnt <= M; cnt++){
    sum += homework.at(cnt);
  }
  
  if(sum <= day){
    std::cout << day-sum << std::endl;
  }
  else{
    std::cout << -1 << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
int n,m,a,t[1005][1005];
vector<pair<int,pair<int,pair<int,int> > > >v;
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a;
            t[i][j]+=a;
            if(t[i][j]%2==1)
            {
                if(i!=n)
                {
                    t[i+1][j]++;
                    v.push_back({i,{j,{i+1,j}}});
                }
                else if(j!=m)
                {
                    t[i][j+1]++;
                    v.push_back({i,{j,{i,j+1}}});
                }
            }
        }
    }
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i].ff<<" "<<v[i].ss.ff<<" "<<v[i].ss.ss.ff<<" "<<v[i].ss.ss.ss;
        if(i!=v.size()-1)cout<<endl;
    }
}


Measured memory_bytes: 6128
#include<iostream>
#include<vector>
#include<tuple>
#include<algorithm>

using namespace std;

int main(){
  int N,W;
  cin>>N>>W;
  double cw=0,cv=0;
  vector<tuple<double,double,double> > p,n;
  while(N--){
    long long w,v;
    cin>>w>>v;
    if(w*v>0){
      ((w>0)?p:n).emplace_back(v*1./w,1.*w,1.);
    }else if(v>=0&&w<=0){
      cw+=w;
      cv+=v;
    }
  }
  sort(begin(p),end(p));
  sort(n.rbegin(),n.rend());
  while(!p.empty()){
    double vw=get<0>(p.back());
    double w=get<1>(p.back());
    double &r=get<2>(p.back());
    if(cw+w*r<=W){
      cw+=w*r;
      cv+=vw*w*r;
      p.pop_back();
    }else{
      double l=(W-cw)/w;
      cv+=vw*w*l;
      r-=l;
      break;
    }
  }
  double m=cv;
  while(!p.empty()&&!n.empty()){
    auto &pb=p.back();
    auto &nb=n.back();
    double l=min(get<2>(pb)*get<1>(pb),-get<2>(nb)*get<1>(nb));
    cv+=(get<0>(pb)-get<0>(nb))*l;
    m=max(m,cv);
    get<2>(pb)-=l/get<1>(pb);
    get<2>(nb)-=l/-get<1>(nb);
    ((get<2>(nb)<get<2>(pb))?n:p).pop_back();
  }
  cout<<fixed<<m<<endl;
}

Measured memory_bytes: 1544
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

vector<int> midN;

priority_queue<int, vector<int>, greater<int>> leftN;

priority_queue<int> rightN;

vector<long> savedLeft;
vector<long> savedRight;

int main(){
  int N=0;
  cin>>N;
  int head=0;
  int tail=N-1;
  long sumLeft=0;
  long sumRight=0;
  long res=0;
  
  for(int i=0;i<N;i++){
    int tmp;
    cin>>tmp;
    leftN.push(tmp);
    sumLeft+=tmp;
  }

  for(int i=0;i<N;i++){
    int tmp;
    cin>>tmp;
    midN.push_back(tmp);
  }

  for(int i=0;i<N;i++){
    int tmp;
    cin>>tmp;
    rightN.push(tmp);
    sumRight+=tmp;
  }

  res=sumLeft-sumRight;
  sumLeft=sumRight=0;
  savedLeft.push_back(sumLeft);
  savedRight.push_back(sumRight);
  
  for(int i=0;i<N;i++){
    int opA=midN[i]-leftN.top();
    if(opA>0){
      leftN.pop();
      leftN.push(midN[i]);
      sumLeft+=opA;
    }
    savedLeft.push_back(sumLeft);
  }

  for(int i=N-1;i>=0;i--){
    int opB=rightN.top()-midN[i];
    if(opB>0){
      rightN.pop();
      rightN.push(midN[i]);
      sumRight+=opB;
    }
    savedRight.push_back(sumRight);
  }
  
  long maxSum=0;
  for(int i=0;i<=N;i++){
    long tmp=savedLeft[i]+savedRight[N-i];
    if(tmp>maxSum)
      maxSum=tmp;
  }

  cout<<res+maxSum<<endl;
  
  return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;


int func(int x){
	int sum=0;
	while(x){
		sum+=x%10;
		x=x/10;
	}
	return sum;
}

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a<=func(i) && func(i)<=b)ans+=i;	
	}
	cout << ans << endl;
	return 0;
}


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

def main():
    n = int(input())
    an = list(map(int, input().split()))
    colors = [color(a) for a in an]
    mi = max(1, count_colors(colors))
    ma = count_colors(colors) + free_players(colors)
    print(mi, ma)

def color(r):
    assert 1 <= r <= 4800
    if r < 400:
        return "grey"
    elif r < 800:
        return "brown"
    elif r < 1200:
        return "green"
    elif r < 1600:
        return "sky"
    elif r < 2000:
        return "blue"
    elif r < 2400:
        return "yellow"
    elif r < 2800:
        return "orange"
    elif r < 3200:
        return "red"
    else:
        return "free"

def count_colors(colors):
    res = set(colors)
    res -= {"free"}
    return len(res)

def free_players(colors):
    res = 0
    for c in colors:
        if c == "free":
            res += 1
    return res

main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
int ans;
int main() {
    cin >> n;
    for (int i = 0; i < 2 * n; i++) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) ans += v[i*2];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000

int main(){
    ll x,ans=100;
    ll y=0;
    cin >> x;
    while(x>ans){
        ans+=ans/100;
        y++;
    }
cout << y << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
 
  vector <string> a,b;
  string tmp;
  int n,i;
 
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>tmp;
    a.push_back(tmp);
  }

  b.assign(a.begin(),a.end());

  for(i=0;i<n-1;i++)
  {
   for(int j=n-2;j!=i-1;j--) 
   {
    if(a[j][1]>a[j+1][1])
    {
     swap(a[j],a[j+1]);
    }
   }
  }

  for(i=0;i<n-1;i++)
  {
   cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl<<"Stable"<<endl;
 
  for(i=0;i<n-1;i++)
  {
    int now,minnum=101;
    for(int j=i;j<n;j++)
    {
      if(minnum>b[j].at(1)-'0'){
        now=j;
        minnum=b[j].at(1)-'0';
       }
    }
    if(i!=now)  swap(b[i],b[now]);
  }
 
  for(i=0;i<n-1;i++) cout<<b[i]<<" ";
  cout<<b[n-1]<<endl;
  if(a==b) cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
 
  return 0;
 
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define int long long
ll dp[100010][2];

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    dp[0][1] = 1;
    rep(i,n+1){
        if(i==0)continue;
        if(s[i-1]=='1'){
            dp[i][0] = (dp[i-1][1]+dp[i-1][0]*3)%mod;
            dp[i][1] = (dp[i-1][1]*2)%mod;
        }else{
            dp[i][0] = (dp[i-1][0]*3)%mod;
            dp[i][1] = (dp[i-1][1])%mod;
        }
        //cerr << dp[i][0] << " " << dp[i][1] << endl;
    } 
    cout << (dp[n][0]+dp[n][1])%mod << endl;
    return 0;
}

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

int main() {
	double a, b, c, d, e, f, x, y;

	while ( cin >> a >> b >> c >> d >> e >> f ){

		y = ( c * d  - a * f ) / ( b * d - a * e );
		if ( a ){
			x = ( c - b * y ) / a;
		}else{
			x = ( f - e * y ) / d;
		}

		cout << showpoint << setprecision(3);
		cout << setiosflags( ios::fixed );
		cout << ( x == -0.0 ? 0.0 : x ) << " " << ( y == -0.0 ? 0.0 : y ) << endl;

	}
}

Measured memory_bytes: 0
N=int(input())
A=[input() for i in range(N)]
from collections import Counter
A=Counter(A)
ret = []
a=((A.most_common(1))[0])[1]
for i in A.most_common():
  if i[1]==a:
    ret.append(i[0])
  else:
    break
ret.sort()
for i in ret:
  print(i)


Measured memory_bytes: 43504
#include<bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;
ll a , b  , cnt , n , m , ans , mn;
int main(){
    cin >> n;
    for( int i = 1;i <= n;i ++ ){
        if( i % 3 != 0 and i % 5 != 0 )
            cnt+=i;
    }
    cout << cnt;
}
/// ab#c ad#c
/// ab## c#d#

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define N 2333

int n,m,a[N],ans;
char s[N][N];
stack<int> q;

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();ans=max(n,m);
	for (int i=1;i<=n;i++) scanf(" %s",s[i]+1);
	for (int i=1;i<=n;i++){
		for (int j=1;j<m;j++)
			if ((s[i-1][j]^s[i-1][j+1]^s[i][j]^s[i][j+1])==0) a[j]++;else a[j]=1;
		while (!q.empty()) q.pop();
		q.push(0);a[0]=-1;
		for (int j=1;j<=m;q.push(j++))
			while (a[q.top()]>=a[j]){
				int x=q.top();q.pop();
				ans=max(ans,(j-q.top())*a[x]);
			}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4864
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];
    let s: Vec<char> = read_as_string().chars().collect::<Vec<char>>();

    if n%2 != 0{
        println!("No");
        return;
    }

    for i in 0..n/2{
        if s[i] != s[n/2+i]{
        println!("No");
        return;
        }
    }

    println!("Yes");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n];
    vi non;
    int sum=0;
    for(int i =0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
        if(arr[i]%10 !=0) non.pb(arr[i]);
    }
    sort(all(non));
    if(sum%10!=0){
        cout<<sum<<endl;
        return 0;
    }
    else{
        if(non.size()==0){
            cout<<0<<endl;
        }
        else{
            cout<<sum - non.front()<<endl;
            return 0;
        }




    }


















}




















Measured memory_bytes: 256
from collections import Counter
n = int(input())
D = list(map(int,input().split()))
if D[0] != 0:
    print(0)
    exit()

C = Counter(D)
C = dict(sorted(C.items()))

memo1 = C[1]
memo2 = 1
ans = 1
for i in range(1,n):
    if D[i] == 0:
        print(0)
        exit()

for key in C:
    if key >= 2:
        if memo2 + 1 != key:
            print(0)
            exit()
        ans = (ans * (pow(memo1,C[key])))%998244353
        memo1 = C[key]
        memo2 = key
print(ans)

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

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

    int n, k;
    cin >> n >> k;

    int digits[10] = {false};
    for (int i = 0; i < n; i++) {
        int j;
        cin >> j;
        digits[j] = true;
    }
	
    bool unsolved = true;
    while (unsolved) {
    	int m = n;
    	bool isSol = true;
        while (m > 0) {
            if (digits[m % 10]) {
            	isSol = false;
                break;
            }
            else {
                m /= 10;
            }
        }
        if (isSol){
        	cout << n;
        	unsolved = false;
        }
        m = n++;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define ll long long
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
    long long n,ans=1;
    map <int ,int>m;
    cin>>n;
    
    for(int i=2;i<=n;i++){
        int tmp=i;
        int cnt=2;
        //cout<<i<<endl;
        while(tmp>1){
            //cout<<tmp<<endl;
            if(tmp%cnt==0){
                //cout<<cnt<<endl;
                m[cnt]++;
                tmp/=cnt;
            }else{
                cnt++;
            }
        }
    }
    
    for(int i=1;i<=1000;i++){
        //cout<<m[i]<<endl;
        ans=ans*(m[i]+1)%mod;
    }
    
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
const int N = 100010;//10^5+10

const int MAX_N = 2000;
int a[MAX_N], n, x;
int f[MAX_N][MAX_N];

int main() {
	
	string s; int k; cin >> s >> k;

	//順番に文字を見ていって、a以外ならaにできないかを試みる。
	for (int i = 0; i < s.length(); i++) {
		if(s[i] != 'a') {
			int d = 26 - (s[i] - 'a');

			if (k - d >= 0) {
				k -= d;
				s[i] = 'a';
			}
		}
	}

	//ぴったりK回という指示なので余った数を最後の文字で使い切るだけ。

	//a-(c+k)-zならzに近づければいいし
	if (s[s.length()-1] + k <= 'z') {
		s[s.length() - 1] = s[s.length() - 1] + k;

	}
	//26で割ったあまりを足して、a-zの間に入るように調節してやる。
	//もっといいやり方があるかもしれない。
	else {
		s[s.length() - 1] = s[s.length() - 1] + (k % 26) - 26;
	}

	if (s[s.length() - 1] < 'a')s[s.length() - 1] += 26;

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 512
import java.util.*;

class Main {
    // 150d
    static final long MOD = 1_000_000_007;
    static final int MAX = 2000000000;
    static final int INF = 100000000;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long ans = n - m;
        if(n == m){
            ans = modfact(n) * modfact(m) * 2 % MOD ;
        } else if(n-1 == m||n+1 == m){
            ans = modfact(n) * modfact(m) % MOD;
        } else{
            ans = 0;
        }

        System.out.println(ans);

    }

    static long modfact(long i){
        if(i==0)return 1;
        return (i%MOD * modfact(i-1))%MOD; 
    }

}


Measured memory_bytes: 32084
N =int(input())
a = [0] * N
b = [0] * N
for i in range(N):
    A, B = map(int, input().split())
    a[i], b[i] = A, B
    
ans = 0
for i in range(N-1,-1,-1):
  if (a[i]+ans)%b[i]==0:
    push = 0
  else:
    push = b[i] - (a[i]+ans)%b[i]
  ans += push
print(ans)

Measured memory_bytes: 10868
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD

    def combination2(self, k, r):
        """kCrを求める O(r) kが大きいが、r <= nを満たしているときに使用"""
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.MOD
        return (res * self.inv_fact[r]) % self.MOD


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
comb = Combination(2 * 10 ** 5 + 10, MOD)

all_ptn =pow(2, n, MOD)
a_ptn = comb.combination2(n, a)
b_ptn = comb.combination2(n, b)

ans = (all_ptn - (a_ptn + b_ptn) - 1) % MOD
print(ans)

Measured memory_bytes: 54256
N = input().strip()


d = int(N[-1])
count_p = d
count_m = 10 - d

for i in range(len(N) - 2, -1, -1):
	d = int(N[i])
	
	new_count_p = min(count_p + d, count_m + (d + 1))
	new_count_m = min(count_p + (10 - d), count_m + (10 - (d + 1)))
	
	count_p = new_count_p
	count_m = new_count_m

count_m += 1

print(min(count_p, count_m))


Measured memory_bytes: 5492
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<=b; ++i)
using namespace std;
int a[10];
string s[100];
int met[100][100];
int getNum(int x, int y){
	int ans =0 ;
	rep(i, -1, 1){
		rep(j, -1, 1){
			if(met[x+i][y+j] == -1) ans++;
		}
	}
	return ans;
}
int main(){
	int n, m;
	cin  >> n >> m;
	rep(i, 1, n){
		cin >> s[i];
	}
	rep(i, 1, n){
		rep(j, 0, m-1){
			if(s[i][j] == '.') met[i][j+1] = 0;
			else met[i][j+1] = -1;
		}
	}
	rep(i, 1, n){
		rep(j , 1, m){
			if(met[i][j] == 0){
				met[i][j] = getNum(i, j);
			}
		}
	}
	rep(i, 1, n){
		rep(j, 1, m){
			if(met[i][j] == -1) cout <<"#";
			else cout << met[i][j]; 
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256