akhauriyash/Code-Regression huggingface dataset:
# python3
# -*- coding: utf-8 -*-
import sys
import math
import bisect
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
lmtx = lambda h: [list(map(int, lmis())) for _ in range(h)]
sys.setrecursionlimit(1000000000)


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


# main
n, m = mis()
alist = lmis()

freedays = n - sum(alist)

if freedays < 0:
    print('-1')
else:
    print(str(freedays))


Measured memory_bytes: 11296
//Abraao Caiana de Freitas - UFCG

#include <bits/stdc++.h>
using namespace std;
#define maxx 100100
#define mp make_pair
#define sec second
typedef pair<int,int> ii;
typedef long long ll;
int dp[maxx][3],h[maxx][3];
int main(){
    ios_base::sync_with_stdio(false);    
    cin.tie(NULL);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> h[i][0] >> h[i][1] >> h[i][2];
    dp[1][0] = h[1][0];
    dp[1][1] = h[1][1];
    dp[1][2] = h[1][2];

    for(int i = 2; i <= n; i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + h[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + h[i][1];
        dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + h[i][2];
    }
    cout << max(max(dp[n][0],dp[n][1]),dp[n][2]) << "\n";
    return 0;
}

Measured memory_bytes: 5928
#include <iostream>
using namespace std;
#define FOR(i,n) for(i=0;i<n;++i)
int main(void){
    int i,begin,end;
    string s;
    cin>>s;
    
    FOR(i,s.length()){
        if(s[i]=='A'){
            begin=i;
            break;
            
        }
    }
    FOR(i,s.length()){
        if(s[i]=='Z'){
            end=i;
        }
    }
    cout<<end-begin+1;
    
    
    return 0;
}


Measured memory_bytes: 640
import sys
n=int(input())
l = list(map(int,input().split()))
m=int(n/2)
ans=0
if n%2==1:
    for i in range(m+1):
        if l[i*2]%2==1:
            ans+=1
    print(ans)
    sys.exit()
else:
    for i in range(m):
        if l[i*2]%2==1:
            ans+=1
    print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   if(a!=b && b!=c && c!=a)
    cout<<3<<endl;
   else if(a==b & a!=c || a==c & a!=b ||c==b & c!=a)
    cout<<2<<endl;
   else
     cout<<1<<endl;
    return 0;
}




Measured memory_bytes: 256
def solve(n, a_list):
    if len(set(a_list)) == n:
        return "YES"
    else:
        return "NO"


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    res = solve(n, a_list)
    print(res)


def test():
    assert solve(5, [2, 6, 1, 4, 5]) == "YES"
    assert solve(6, [4, 1, 3, 1, 6, 2]) == "NO"
    assert solve(2, [10000000, 10000000]) == "NO"


if __name__ == "__main__":
    test()
    main()


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

int p[1000010];

int main(){
	int n;
	int count;

	//エラトステネスの篩
	//素数のリストをつくる
	for (int i = 0; i <= 1000000; i++) p[i] = 1;
	p[0] = p[1] = 0;
	for (int i = 2; i*i <= 1000000; i++){
		if (p[i] == 1){
			for (int j = 2; i*j <= 1000000; j++){
				p[i*j] = 0;
			}
		}
	}

	//素数のカウント
	while (cin >> n){
		count = 0;
		for (int i = 0; i <= n; i++){
			if (p[i] == 1)count++;
		}
		cout << count << endl;
	}

	return 0;
}


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

using namespace std;

int const N = 2e5 + 5;
int const MAX = 105;


int n, a[N], d[N];

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> d[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	priority_queue < pair < int, int > > que;
	for (int i = 1; i <= n; i++) {
		que.push(make_pair(a[i], i));
	}
	a[0] = a[n];
	a[n + 1] = a[1];
	long long ans = 0;
	while (!que.empty()) {
		pair < int, int > p = que.top(); que.pop();
		int val = p.first;
		int id = p.second;
		int pre = a[id - 1];
		int nxt = a[id + 1];
		if (a[id] == d[id]) {
			continue;
		}
		if (a[id] - d[id] < pre + nxt) {
			continue;
		}
		ans += (a[id] - d[id]) / (pre + nxt);
		a[id] = (a[id] - d[id]) % (pre + nxt) + d[id];

		a[0] = a[n]; a[n + 1] = a[1];
		que.push(make_pair(a[id], id));
	}

	for (int i = 1; i <= n; i++) {
		if (a[i] != d[i]) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int A[N];

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

  for (int i = 0; i < N; i++) {
    if (A[i] > M1) {
      M1 = A[i];
    } else if (A[i] > M2) {
      M2 = A[i];
    }
  }

  for (int i = 0; i < N; i++) {
    if (A[i] == M1) {
      cout << M2 << endl;
    } else {
      cout << M1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2432
#include <string.h>

#include <algorithm>
#include <iostream>
#include <vector>

#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main(void) {
  int K;
  cin >> K;
  string str = "";
  string ACL = "ACL";
  for (int i = 0; i < K; i++) {
    str += ACL;
  }

  cout << str << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <map>
#include <set>
#include <unordered_set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>
#include <atomic>
#include <thread>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define DFOR(i,s,e) int i = s;for(;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define DFORR(i,s,e) int i = s;for(;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }



const int N = 200001, inf = 10000;
int b[N];
vector<int> rt[N];
vector<int> st;
int n,m;

void upd(int i, int v) {
  for (i += n + 1; st[i] > v; i >>= 1) st[i] = v;
}

int que(int l, int r) {
  int ret = N;
  for (l += n + 1, r += n + 2; l < r; l >>= 1, r >>= 1) {
    if (l & 1) Min(ret, st[l++]);
    if (r & 1) Min(ret, st[--r]);
  }
  return ret;
}

void solve() {
  string str;
  cin >> str;
  if (str[1] != str[2]) {
    cout << "No" << ln;
    return;
  }
  if (str[0] == str[1] || str[3] == str[1]) {
    cout << "Yes" << ln;
  }
  else cout << "No" << ln;
}


void init() {
  
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }
  
  
  return 0;
}



Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[][] f = new int[n][10];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 10; j++) {
				f[i][j] = sc.nextInt();
			}
		}
		int[][] p = new int[n][11];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 11; j++) {
				p[i][j] = sc.nextInt();
			}
		}
		int a[], b, idx, cnt, tmp, max = Integer.MIN_VALUE;
		for (int i = 1; i < 1024; i++) {
			int t = i;
			b = 512;
			idx = 9;
			a = new int[10];
			while (idx >= 0) {
				if (t / b > 0) {
					a[idx]++;
					t = t - b;
				}
				b = b / 2;
				idx--;
			}
			tmp = 0;
			for (int j = 0; j < n; j++) {
				cnt = 0;
				for (int k = 0; k < 10; k++) {
					if (a[k] == f[j][k] && a[k] == 1) {
						cnt++;
					}
				}
				tmp += p[j][cnt];
			}
			max = Math.max(max, tmp);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 25892
#include<cstdio>

int main(){
    long long m,n,l,i,j,k,s;
    scanf("%lld%lld%lld",&n,&m,&l);
    long long a[n][m],b[m][l];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%lld",&a[i][j]);/*Aの入力*/
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%lld",&b[i][j]);/*Bの入力*/
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            s = 0;
            for(k=0;k<m;k++){
                s = s + a[i][k] * b[k][j];
            }
            if(j==l-1){
                printf("%lld",s);
            }
            else{
                printf("%lld ",s);
            }
        }
        printf("\n");
    }               
    return 0;    
}


Measured memory_bytes: 2832
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = 1000000000;

int main() {
	int d, n;
	while (cin >> d >> n, d) {
		int a[n], e[n], r[n];
		rep (i, n) cin >> a[i] >> e[i] >> r[i];
		//耐久値、経験値
		int dp[d + 1][101];
		rep (i, d + 1) rep (j, 101) dp[i][j] = INF;
		dp[d][0] = 0;
		for (int i = d; i >= 0; i--) rep (j, 101) {
			if (dp[i][j] == INF) continue;
			rep (k, n) {
				if (r[k] > j) continue;
				//a[i] -> 減る耐久値, e[i] -> 得る経験値
				dp[max(0, i - a[k])][min(100, j + e[k])] = min(dp[max(0, i - a[k])][min(100, j + e[k])],
																											 dp[i][j] + 1);
			}
		}
		int ans = INF;
		rep (i, 101) ans = min(ans, dp[0][i]);
		cout << (ans == INF ? "NA" : to_string(ans)) << endl;
	}
	return 0;
}


Measured memory_bytes: 3332
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int gcd(int a, int b){ //最大公約数
  if(a % b == 0) return b;
  return gcd(b, a % b);
}
int main(){
  int n,X;
  cin >> n >> X;
  int g;
  rep(i, n){
    int x;
    cin >> x;
    x = abs(x - X);
    if(!i) g = x;
    else g = gcd(g, x);
  }
  cout << g << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll a, b, c, d;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
		if (b > a) puts("No");
		else if (d < b) puts("No");
		else if (c >= b) puts("Yes");
		else {
			d %= b; a %= b;
			ll e = gcd(d, b), lim = (b - a - 1) / e;
			a += lim * e;
			if (a + e < b) a += e;
			puts(a > c ? "No" : "Yes");
		}
	}
}

Measured memory_bytes: 256
N = int(input())


def dfs(s):  # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0  # s 自体が七五三数なら +1

    for c in '753':
        ret += dfs(s + c)

    return ret


print(dfs('0'))

Measured memory_bytes: 2940
#include <iostream>
#include<vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
typedef long long int lld;
typedef unsigned long long int llu;
using namespace std;
const int m=1e9;
int main()
{
	llu n,w,i;
	cin>>n>>w;
	llu wt[n],v[n];
	for(i=0;i<n;i++) cin>>wt[i]>>v[i];
	llu k[n+1][w+1],j;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
			if(i==0||j==0) k[i][j]=0;
			else if(wt[i-1]<=j)
			{
				k[i][j]=max(k[i-1][j],v[i-1]+k[i-1][j-wt[i-1]]);
			}
			else k[i][j]=k[i-1][j];
		}
	}
	cout<<k[n][w];
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

vector<ll> so;
bool a[100010];
bool b[100010];
ll c[100010];
int main() {
	ll q;
	cin>>q;
	so.push_back(2);
	for(int i=3;i<100010;i+=2){
		bool ch=true;
		for(int j=0;j<so.size();j++){
			if(i%so[j]==0){
				ch=false;
				break;
			}
			if(i<so[j]*so[j]){
				break;
			}
		}
		if(ch){
			so.push_back(i);
		}
	}
	for(int i=0;i<so.size();i++){
		ll now=so[i];
		a[now]=true;
		ll nex=now*2-1;
		if(nex<=100000){
		b[nex]=true;
		}
	}
	for(int i=1;i<100010;i++){
		if(a[i]==true&&b[i]==true){
			c[i]++;
		}
		c[i+1]=c[i];
	}
	for(int i=0;i<q;i++){
		ll l,r;
		cin>>l>>r;
		cout << c[r]-c[l-1]<<endl;
	}
	return 0;
}

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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

const int maxn = 1e3+1;
ll arr1[maxn],arr2[maxn], n, m, t, k;
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

ll ct() {
    ll diffs=0;
    for (int i=0;i<26;i++) {
        diffs += abs(arr1[i]-arr2[i]);
    }
    return diffs;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s,p;
    cin>>s>>p;
    n=s.size();
    m=p.size();
    ll ans=m;
    for (int i=0;i+m<=n;i++){
        ll diffs=0;
        for (int j=0;j<m;j++)
            if(p[j]!=s[i+j])
                diffs++;
        ans=__min(ans,diffs);
    }
    cout << ans << "\n";
}


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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

#define dodebug(i, n, arr)	for(int i=0;i<n;++i)	cout<<arr[i]<<" ("<<i<<")\n";

ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

int n;
vector<ll> a(3010);
vector<vector<ll> > dp(3010, vector<ll>(3010, -1));

ll dodp(int l, int r){
	// cout<<"doing for "<<l<<" "<<r<<'\n';
	if(l==r)	return a[l];
	// if(l>r)		return 1e10;
	if(dp[l][r] != -1)	return dp[l][r];

	dp[l][r] = max(a[l] - dodp(l+1,r), a[r] - dodp(l,r-1));

	return dp[l][r];
}

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

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

	// cout<<dodp(0, n-1)<<'\n';
	//note the recursive call happens successively, and it returns for the first time when it reaches single element and the end
	//therefore an iterative approach is:
	for(int l=n-1;l>-1;--l){
		for(int r=l;r<n;++r){
			if(l==r)	dp[l][r] = a[l];
			else		dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
		}
	}

	cout<<dp[0][n-1]<<"\n";

	// for(int l=0;l<n;++l){
	// 	for(int r=0;r<n;++r)	cout<<dp[l][r]<<" ";
	// 	cout<<"\n";
	// }

	return 0;
}

Measured memory_bytes: 74564
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll countDigit(int n);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,x=0,xn=0,sum=0,sumTmp = 0;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	sum = accumulate(all(a),0LL);
	for (ll i = 1; i < n; i += 2) {
		sumTmp += a[i];
	}
	x = sum - 2 * sumTmp;
	rep(i, n) {
		cout << x << endl;
		x = 2 * a[i] - x;
	}
}




Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,a) repi(i,0,a)
using namespace std;
typedef long long ll;

int H, W;
ll L;
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};
bool inrange(int x, int y){ return x >= 0 && x < W && y >= 0 && y < H;}

int main(){
    while(cin >> H >> W >> L, H || W || L){
        vector<string> maze(H);
        rep(i,H) cin >> maze[i];
        int x, y, dir;
        rep(i,H)rep(j,W){
            if(maze[i][j] == 'W'){ dir = 0; x = j; y = i; break;}
            else if(maze[i][j] == 'N'){ dir = 1; x = j; y = i; break;}
            else if(maze[i][j] == 'E'){ dir = 2; x = j; y = i; break;}
            else if(maze[i][j] == 'S'){ dir = 3; x = j; y = i; break;}
        }
        int field[128][128][4];
        memset(field,-1,sizeof(field));
        field[y][x][dir] = 0;
        ll turn = 1;
        bool rooped = false;
        while(turn <= L){
            int nx, ny, ndir;
            rep(i,4){
                ndir = (dir+i)%4;
                nx = x + dx[ndir];
                ny = y + dy[ndir];
                if(inrange(nx, ny) && maze[ny][nx] != '#'){
                    x = nx; y = ny; dir = ndir;
                    break;
                }
            }
            if(!rooped && field[y][x][dir] >= 0){
                rooped = true;
                ll roop = turn - field[y][x][dir];
                turn += (L - turn) / roop * roop;
                turn++;
            }
            else{
                field[y][x][dir] = turn;
                turn++;
            }
        }
        cout << y+1 << ' ' << x+1 << ' ';
        cout << (dir==0? 'W': dir==1? 'N': dir==2? 'E': 'S') << endl;
    }
    return 0;
}

Measured memory_bytes: 1512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	string rv;
	rrep(i, n){
		rv.push_back(s[i]);
	}
	// cerr << s << " " << rv << endl;
	if(rv != s){
		cout << "No" << endl;
		return 0;
	}

	string ss, rr;
	rep(i, (n-1)/2){
		ss.push_back(s[i]);
	}
	// cerr << ss << endl;
	rrep(i, ss.size()){
		rr.push_back(ss[i]);
	}
	if(ss != rr){
		cout << "No" << endl;
		return 0;
	}

	ss.clear(); rr.clear();
	rep2(i, (n+3)/2-1, n){
		ss.push_back(s[i]);
	}
	// cerr << ss << endl;
	rrep(i, ss.size()){
		rr.push_back(ss[i]);
	}
	if(ss != rr){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll H, W, h1, w1, h2, w2, ans=-1, tmp=0;
string S;
ll dy[] = {1, 0, -1, 0};
ll dx[] = {0, 1, 0, -1};
vector<ll> visited;
vector<vector<ll>> color, G;
vector<vector<char>> A;

void dfs(ll h, ll w, ll id){
    for(int i=0;i<4;i++){
        int ny = h + dy[i], nx = w + dx[i];
        if(!(0 <= ny && ny < H && 0 <= nx && nx < W)) continue;
        if(A[ny][nx]=='.'&&color[ny][nx]==-1){
            color[ny][nx]=id;
            dfs(ny, nx, id);
        }
    }
}

void bfs(ll bd1, ll bd2) {
    queue<pair<ll,ll>> Q;
    Q.push(make_pair(bd1, 0));
    while(!Q.empty()) {
        pair<ll,ll> p = Q.front();
        Q.pop();
        if(visited[p.first]!=-1) continue;
        visited[p.first] = p.second;
        if(p.first==bd2) {
            ans = p.second;
            break;
        }
        for(int i=0;i<G[p.first].size();i++) {
            if(visited[G[p.first][i]]==-1) Q.push(make_pair(G[p.first][i], p.second+1));
        }
    }
}

signed main(){
    cin >> H >> W >> h1 >> w1 >> h2 >> w2;
    h1--;
    w1--;
    h2--;
    w2--;
    A.resize(H);
    color.resize(H);
    for(int i=0;i<H;i++) {
        color[i].resize(W, -1);
        for(int j=0;j<W;j++) {
            char a;
            cin >> a;
            A[i].push_back(a);
        }
    }
    for(int i=0;i<H;i++) {
        for(int j=0;j<W;j++) {
            if(A[i][j]=='.'&&color[i][j]==-1) {
                color[i][j] = tmp;
                dfs(i, j, tmp);
                tmp++;
            }
        }
    }
    G.resize(tmp);
    visited.resize(tmp, -1);
    //cout << "OK" << endl;
    /*
    for(int i=0;i<H;i++) {
        for(int j=0;j<W;j++) {
            cout << color[i][j] << " ";
        }
        cout << endl;
    }
    */
    for(int i=0;i<H;i++) {
        for(int j=0;j<W;j++) {
            for(int l=i-2;l<i+3;l++) {
                if(l>=0&&l<H) {
                    for(int k=j-2;k<j+3;k++) {
                        if(k>=0&&k<W) {
                            if(color[l][k]!=-1&&color[i][j]!=-1&&color[l][k]!=color[i][j]) {                                
                                G[color[i][j]].push_back(color[l][k]);
                                G[color[l][k]].push_back(color[i][j]);                                
                            }
                        }
                    }
                }
            }
        }
    }
    //cout << "OK" << endl;
    if(color[h1][w1]!=-1&&color[h2][w2]!=-1) bfs(color[h1][w1], color[h2][w2]);
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int INF = 1e9+7;
int main()
{
    int h,w,maxm=0,p=0,i,j,k,r,a,b,d,x,y;
    int p1[]={-1,0,1,0};
    int p2[]={0,1,0,-1};

    cin>>h>>w;

    string s[h];
    for(i=0;i<h;i++)
        cin>>s[i];
    
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(s[i][j]=='#')
                continue;
            
            int B[h][w];
            for(k=0;k<h;k++)
                for(r=0;r<w;r++)
                    B[k][r]=INF;
            
            queue <pair<pair<int,int>,int>> q;
            q.push({{i,j},0});
            B[i][j]=0;
            p=0;
            //cout<<i<<" "<<j<<endl;
            while(!q.empty())
            {
                a = q.front().first.first;
                b = q.front().first.second;
                d = q.front().second;
                p = max(p,d);
                q.pop();

                for(k=0;k<4;k++)
                {
                    x = a+p1[k];
                    y = b+p2[k];

                    if(x>=0 && y>=0 && x<h && y<w && B[x][y]==INF && s[x][y]!='#')
                    {
                        B[x][y]=d+1;
                        q.push({{x,y},d+1});
                    }
                }
            }
            
            maxm=max(maxm,p);
        }
    }
    cout<<maxm<<endl;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

string s;

int main() {
    cin >> s;
    REP(i, 3) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3580
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };


int main () {
	int s;
	cin >> s;
	vector<int> ans;
	ans.push_back (s);
	int i = 1;

	while (true) {
		i++;
		if (s % 2 == 0) {
			s /= 2;
		} else {
			s = 3 * s + 1;
		}
		
		for (const auto& x : ans) {
			if (x == s) {
				cout << i << endl;
				return 0;
			}
		}
		ans.push_back (s);
		//cout << s << endl;
	}

	

}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define ACL
#ifdef ACL
#include <atcoder/all>
using namespace atcoder;
#endif
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
using LD = long double;
using VI = vector<int>;
using VVI = vector<vector<int> >;
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T> >;
template <typename T> using VVV = vector<vector<vector<T> > >;
void print() {cout << endl;}
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <typename T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <typename T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> void SORT (T &v) {sort(v.begin(), v.end());}
template <typename T> void SORTR (T &v) {sort(v.begin(), v.end(), greater<>());}
template <typename T> T GCD(T x,T y) {return __gcd(x,y);}
template <typename T> T LCM(T x,T y) {return x/__gcd(x,y)*y;}
template <typename T> int SZ(T v) {return v.size();}
template <typename T> T PCNT(T x) {return __builtin_popcountll(x);}
template <typename T> T BIT(T x) {return 1LL<<(x);}
int INF = 2000000000;
long double PI = acosl(-1);
int MOD = 1000000007;


int32_t main() {
    chrono::system_clock::time_point start_time, end_time;
    start_time = chrono::system_clock::now();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0, res = 0;
    
    int N;
    cin >> N;
    FOR(A,1,1e6+1) {
        ans += (N-1)/A;
    }
    cout << ans << endl;

    
    



    end_time = chrono::system_clock::now();
    assert(chrono::duration_cast<chrono::milliseconds>(end_time-start_time).count() < 2500);
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc179/abc179_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc179/abc179_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc179/abc179_c && sh shellscripts/submit_cpp.sh
*/


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    int n;
    string s;
    cin>>n>>s;
    REP(i,s.size()){
        char c = s[i];
        int x = c - 'A';
        x = (x + n) % 26;
        s[i] = x + 'A';
    }
    cout << s << endl;
    return 0;
}


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

int main() {
	char card[200],h1[200],h2[200];
	int sn, h, i;

	while (scanf("%s", card), strcmp(card, "-") != 0) {
		scanf("%d", &sn);

		for (i = 0;i < sn;i++) {
			scanf("%d", &h);

			strncpy(h1, card + h, strlen(card) - h);
			strncpy(h2, card, h);
			
			h1[strlen(card) - h] = '\0';
			h2[h] = '\0';

			strcpy(card, "");

			strcat(card, h1);
			strcat(card, h2);
		}

		printf("%s\n", card);
	}

	return 0;
}

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

int main() {
  int k,n;
  cin>>k>>n;
  int a[n];
  for(int i=0;i<n;i++){
    int l;
    cin>>l;
    a[i]=l;
  }
  sort(a,a+n);
  if(k>2*a[n-1]-2)cout<<0<<endl;
  else cout<<2*a[n-1]-k-1<<endl;
}


Measured memory_bytes: 256
N = int(input())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))

ans = 0
before_A = -1
for A in Alist:
    ans += Blist[A-1]
    if before_A+1 == A:
        ans += Clist[before_A-1]
    before_A = A

print(ans)

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

using namespace std;

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

    long long x;
    cin >> x;
    long long sum = 0;
    long long i = 0;
    while (sum < x) {
        i++;
        sum += i;
    }
    cout << i << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int n4, n3, n2, n1,n;
    int count = 0;
    int A = sc.nextInt();
    int B = sc.nextInt();
    for(int i=1; i<=N; i++) {
      n4 = i / 1000;
      n3 = i / 100 - n4*10;
      n2 = i / 10 - n4*100 - n3*10;
      n1 = i % 10;
      n = n1+n2+n3+n4;
      if(i == 10000) {
        count += 10000;
      } else if(n>=A && n<=B) {
        count += i;
      }
    }
    System.out.println(count);
  }
}

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

int main(){
	int x[3], count5 = 0, count7 = 0;
	cin >> x[0];
	cin >> x[1];
	cin >> x[2];
	for (int i=0; i<3; i++){
		if (x[i] == 5) ++count5;
		if (x[i] == 7) ++count7;
	}
	if (count5==2 && count7==1) cout << "YES" << endl;
	else cout << "NO" << endl;	
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int flag,i,j,n,count=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(;;)
    {
        flag=0;
        for(j=0;j<n;j++)
        {
            if(a[j]%2==0)
                a[j]=a[j]/2;
            else if(a[j]%2!=0){
                flag=1;
                break;
            }
        }
        if(flag==1)
            break;
        count++;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    int p[21];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
    }
    int m=0;
    for (int i = 1; i < n-1; i++) {
        if((p[i-1]<p[i] && p[i]<=p[i+1]) || (p[i-1]>=p[i] && p[i]>p[i+1])){
            m++;
        }
    }
    std::cout << m << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long
    #define int long long 
    #define ull unsigned long long 
    #define ld long double
    #define sb __builtin_popcount
    #define vi vector<int>
    #define vc vector<char>
    #define ii pair<int, int>
    #define pq priority_queue<ii, vector<ii>, greater<ii>>
    #define vii vector<ii>
    #define sz(a) int((a).size())
    #define f(a, b) for (int i = a; i < b; i++)
    #define fr(a, b) for (int i = a - 1; i >= b; i--)
    #define tr(x, m) for (auto x : m)
    #define in(a, b) (b.find(a) != string::npos)
    #define minin(a) *min_element(all(a))
    #define maxin(a) *max_element(all(a))
    #define X first
    #define Y second
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define rall(v) reverse(v.begin(), v.end())
    #define unq(v) v.erase(unique(all(v)), v.end())
    #define el "\n"
    #define mx3(a, b, c) max(max(a, b), c)
    #define mn3(a, b, c) min(min(a, b), c)
    #define S(v) accumulate(all(v), (ll)0)
    #define SP(n) cout.precision(n)
    const ld PI = atan(1.0) * 4.0;
    const ll MOD = 1e9 + 7;
    const ll INF = 1e18;
    const ld EPS = 0.0000001;
    const ll MD = 998244353;


        int32_t main() {
            fio;
            int n;
            cin>>n;
            string x;
            set<string> s;
            for(int i=0;i<n;i++){
                cin>>x;
                s.insert(x);
            }
            cout<<s.size()<<el;
            return 0;
        }


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

a=A%4
b=B%4

ans=0
cnt=0
for i in range(a,4):
    ans=ans^(A+cnt)
    cnt+=1
cnt=0
for i in range(b,-1,-1):
    ans=ans^(B-cnt)
    cnt+=1
print(ans)

Measured memory_bytes: 9148
#include<iostream>
using namespace std;
#include<cstring>
char s[100005];
int main()
{
	scanf("%s",s+1);
	int flag=0;
	int i;
	int len=strlen(s+1);
	for(i=1;i<=len-1;i++)
	{
		if(s[i]==s[i+1])
		{
			flag=1;break;
		}
		if(i+2<=len&&s[i]==s[i+2])
		{
			flag=2;
			break;
		}
		
	}
	if(flag==1)
	printf("%d %d\n",i,i+1);
	if(flag==2)
	printf("%d %d\n",i,i+2);
	if(flag==0)
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  rep(i,n){
    set<int> st;
    int tans=0;
    rep(j,i){
      st.insert(s[j]);
    }
    for(int j=i;j<n;j++){
      if(st.count(s[j])) {
        tans++;
        st.erase(s[j]);
      }
    }
    ans = max(ans,tans);
  }
  cout << ans << endl;

  return 0;
    

}


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

int main(){
  string S,T;
  cin>>S>>T;
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  if(S.size()+1!=T.size()) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
struct Union{
  vector<int> par;
  Union(int a){
  par=vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(int a,int b){
    return (find(a)==find(b));
  }
  int size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    int c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
int main(){
    int a[32]={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 q;
    cin >> q;
    cout << a[q-1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,m,d;
	int i,j,k;
	int c,r;
	char s[128][128];
	scanf("%d %d %d",&n,&m,&d);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	r=0;
	for(i=0;i<=n-d;i++){
		for(j=0;j<m;j++){
			c=1;
			for(k=0;k<d;k++){
				if(s[i+k][j]=='#'){
					c=0;
					break;
				}
			}
			r+=c;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<=m-d;j++){
			c=1;
			for(k=0;k<d;k++){
				if(s[i][j+k]=='#'){
					c=0;
					break;
				}
			}
			r+=c;
		}
	}
	printf("%d\n",r);
	return 0;
}


Measured memory_bytes: 2708
/**
 *    author:  tourist
 *    created: 01.01.2020 20:27:38       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(2 * n - 1);
  for (int i = 0; i < 2 * n - 1; i++) {
    cin >> a[i];
  }
  int low = 1, high = 2 * n - 1;
  while (low < high) {
    int mid = (low + high + 1) >> 1;
    int me = (a[n - 1] >= mid);
    int val = n - 1;
    for (int d = 1; d <= n - 1; d++) {
      for (int sign = -1; sign <= 1; sign += 2) {
        int them = (a[n - 1 + sign * d] >= mid);
        if ((them ^ (d % 2)) != me) {
          val = d - 1;
          break;
        }
      }
      if (val != n - 1) {
        break;
      }
    }
    bool one = me ^ (val % 2);
    if (one) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }
  cout << low << '\n';
  return 0;
}


Measured memory_bytes: 1024
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << 2 * min(count(all(s), '0'), count(all(s), '1')) << endl;
	return 0;
}


Measured memory_bytes: 512
N = gets.to_i
S1 = gets.chomp

skip = false
previous = nil
count = 1

N.times do |i|
  if skip
    skip = false
    next
  end

  unless i == N - 1
    if S1[i] == S1[i + 1]
      current = 'Y'
    else
      current = 'X'
    end

    if previous.nil?
      count *= (current == 'X') ? 3 : 6
    elsif previous == 'X'
      count *= 2
    else
      count *= (current == 'X') ? 1 : 3
    end

    skip = current == 'Y'
    previous = current
  else
    if i.zero?
      count *= 3
    else
      count *= (previous == 'X') ? 2 : 1
    end
  end
end

puts count % 1000000007

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
using namespace std;
const int TIME = 24*60*60;
int train_t[TIME+1]; 

int timeset(string s,int mode){
  int h = (s[0] - '0') * 10 + s[1] - '0';
  int m = (s[3] - '0') * 10 + s[4] - '0';
  int ss = (s[6] - '0') * 10 + s[7] - '0';
  int t = h * 60 * 60 + m * 60 + ss;
  if(mode)train_t[t] += 1;
  else train_t[t] -= 1;
}

int main(){
  int n;
  while(cin >> n){
    if(!n)break;
    REP(i,TIME)train_t[i] = 0;
    string s;
    REP(i,n){
      cin >> s;
      timeset(s,1);
      cin >> s;
      timeset(s,0);
    }
    int max_vehicle = 0;
    REP(i,TIME){
      train_t[i+1]+= train_t[i];
      max_vehicle = max(max_vehicle,train_t[i+1]);
    }
    cout << max_vehicle << endl;
  }
  return 0;
}

Measured memory_bytes: 3524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int d = sc.NextInt();

        string answer = "Christmas";

        for (int i = 0; i < 25 - d; i++)
        {
            answer += " Eve";
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
	var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			int K = (int)inputArray[0];
			var S = retreiveStringArray()[0];

			if (S.Length <= K) {
				Console.WriteLine(S);
				return;
			}

			var ans = S.Substring(0, K);
			ans += "...";

			//答えの出力
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28260
#include <algorithm>
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

std::string N;

int main()
{
  std::cin >> N;

  std::string R = N;

  std::reverse( all(R) );

  bool fl = true;

  rep( i, N.size() )
    fl &= N[i]==R[i];

  std::cout << (fl ? "Yes" : "No" ) << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <algorithm>
//#include <cmath>
#include <vector>
#include <string>

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

    int32_t N, Q;
    std::string S;
    std::cin >> N >> Q;
    std::cin >> S;

    // create the array substrAC[l][r] before the querry to avoid recursive calcuration for the same substring area.
    // substrAC[1][1] = 0, 
    // substrAC[1][2] = 1 :if S[0] == 'A' && S[1] == 'C, 0 : else'
    // substrAC[1][3] = substrAC[1][2] + 1 (if S[3-2] == 'A' && S[3-1] == 'C')
    // substrAC[1][4] = substrAC[1][3] + 1 (if S[4-2] == 'A' && S[4-1] == 'C')
    // substrAC[2][3] = substrAC[1][3] - substrAC[1][2]
    // substrAC[2][N] = substrAC[1][N] - substrAC[1][2]
    // substrAC[M][N] = substrAC[1][N] - substrAC[1][M]
    int32_t substrAC[N];
    substrAC[0] = 0;
    for(int32_t i = 0; i < N -1; i++){
        if(S[i] == 'A' && S[i+1] == 'C'){
            substrAC[i+1] = substrAC[i] + 1;
        }
        else{
            substrAC[i+1] = substrAC[i];
        }
    }

    int32_t l, r;
    for(int32_t i = 0; i < Q; i++){
        std::cin >> l >> r;
        std::cout << substrAC[r-1] - substrAC[l-1] << std::endl;
    }

    return 0;
}


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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,K;
const int MAX_K = 1000;
int board [2] [MAX_K + 1] [MAX_K + 1];

int main()
{
	scanf("%d%d",&N,&K);
	FOR(i,0,N){
		int x,y;
		char s [17];
		scanf("%d%d%s",&x,&y,s);
		if((s [0] == 'B') ^ (x % (K * 2) >= K) ^ (y % (K * 2) >= K)){
			board [0] [y % K] [x % K]++;
		}
		else{
			board [1] [y % K] [x % K]++;
		}
	}

	FOR(i,0,2) FOR(j,0,K + 1) FOR(k,0,K + 1){
		if(j > 0) board [i] [j] [k] += board [i] [j - 1] [k];
		if(k > 0) board [i] [j] [k] += board [i] [j] [k - 1];
		if(j > 0 && k > 0) board [i] [j] [k] -= board [i] [j - 1] [k - 1];
	}

	int ans = 0;
	FOR(i,0,2) FOR(j,0,K) FOR(k,0,K){
		int sum = board [i] [K] [K] - board [i] [j] [K] - board [i] [K] [k] + board [i] [j] [k] * 2;
		sum += board [!i] [j] [K] + board [!i] [K] [k] - board [!i] [j] [k] * 2;
		chmax(ans,sum);
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

void solve() {
    ll a, v;
    ll b, w;
    ll t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    ll s = v - w;
    ll d = abs(a - b);
    ll k = s * t;
    cout << (k >= d ? "YES" : "NO") << endl;
}

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



Measured memory_bytes: 3124