akhauriyash/Code-Regression huggingface dataset:
import collections

n=int(input())
arr=list(map(int,input().split()))
cnt=collections.defaultdict(int)
for val in arr: #あらかじめ各Aiの個数を数えておく
    cnt[val]+=1
sums=sum(arr) #あらかじめAiの総和を求めておく
q=int(input())
for _ in range(q):
    b,c=map(int,input().split())
    diff=(c-b)*(cnt[b]) #各クエリにおいて数列Aの総和は(値がBiである要素の個数)*(Ci-Bi)だけ変化する
    sums+=diff
    print(sums) 
    cnt[c]+=cnt[b] #値がCi,Biである要素の個数を更新する
    cnt[b]=0

Measured memory_bytes: 24248
s = input()
ans = 0
slist = [int(i) for i in s]
for i in range(len(s)-1):
  if slist[i] == slist[i+1]:
    ans += 1
    if slist[i+1] == 1:
      slist[i+1] = 0
    else:slist[i+1] = 1
print(ans)


Measured memory_bytes: 45020
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <cmath>
# include <functional>
# include <utility>
# define MOD 1000000000+7
# define INF 2000000000
#define rep(i,rept)	for(int i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
int main() {
	//new
	int x, y;
	cin >> x;
	cout << x*x << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define  f first
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define mp make_pair
#define  s second

using namespace std;

int main(){
    int x;cin>>x;
    cout<<1-x;
	return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	static boolean[] comp = new boolean[1310];
	static ArrayList<Integer> list = new ArrayList<>();
	
	public static void main(String[] args) {
		sieve();
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0; i < N; i++) {
			if(i != 0)
				sb.append(" ");
			sb.append(list.get(i));
		}
		System.out.println(sb.toString());
	}
	
	public static void sieve() {
		for(int i = 2; i < comp.length; i++) {
			if(!comp[i]) {
				if(i % 5 == 3)
					list.add(i);
				for(int j = 2; i*j < comp.length; j++)
					comp[i*j] = true;
			}
		}
	}
}

Measured memory_bytes: 21332
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// get a integer
		int N = sc.nextInt();
		
		// map[N]: the table of the sides of polygon 
		int map[] = new int[N];

		int Max = 0;
		int sumOfSideLength = 0;

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

			map[i] = sc.nextInt	();
			sumOfSideLength = sumOfSideLength + map[i];
			
			if (map[i]> Max)
			{
				Max = map[i];
			}
		}

		sumOfSideLength = sumOfSideLength - Max*2;
		
		if (sumOfSideLength > 0)
		{
			System.out.println("Yes");
		}	
		
		else
		{
			System.out.println("No");
		}	
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
using namespace std;
int main() {
    string d;
    int m;

    while (true) {
        cin >> d >> m;
        if (d == "-") break;
        int h = 0;
        for (int i = 0; i < m; i++) {
            int a;
            cin >> a;
            h += a;
        }
        h = h % d.size();
    
        string r = "";
        for (int i = 0; i < d.size(); i++) {
            r += d[(i + h) % d.size()];
        }
        cout << r << endl;
    }

    return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;

int main() 
{
    io();
    li n;
    cin>>n;
    li x=n*n*1LL;
    li y=x*n*1LL;
    cout<<n+x+y;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int x, y;
    std::cin>>x>>y;

    std::list<int> a = {4, 6, 9, 11};
    auto itrx = std::find(a.begin(), a.end(), x);
    auto itry = std::find(a.begin(), a.end(), y);
    std::string ans;
    if(x == 2 || y == 2){
        ans = "No";
    }else if((itrx == a.end() && itry == a.end()) ||
            (itrx != a.end() && itry != a.end())){
        ans = "Yes";
    }else{
        ans = "No";
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a[100005],b[100005],n,ans,t,maxx,minn,j,k,sum;
int main()
{
    cin>>n>>t;
    for (int i=0; i<n; i++) cin >> a[i];
    int max_dif=0, cnt=0, minA=a[0];
    for(int i=1; i<n;i++)
    {
        if(a[i]-minA==max_dif) cnt++;
        if(a[i]-minA>max_dif)
        {
            max_dif=a[i]-minA;
            cnt=1;
        }
        if(minA>a[i]) minA=a[i];
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
int H, W, M;
set<i_i> st;
 
void input() {
    cin >> H >> W >> M;
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        st.insert({a, b});
    }
}
 
void solve() {
    map<int, int> mph, mpw;
    int hmaxval = 0;
    int wmaxval = 0;
    vector<int> hmax, wmax;
    for(auto tmp : st) {
        chmax(hmaxval, ++mph[tmp.first]);
        chmax(wmaxval, ++mpw[tmp.second]);
    }
    for(auto tmp : mph) {
        if(hmaxval == tmp.second) hmax.push_back(tmp.first);
    }
    for(auto tmp : mpw) {
        if(wmaxval == tmp.second) wmax.push_back(tmp.first);
    }
    int ANS = hmaxval + wmaxval - 1;
    for(auto h : hmax) {
        for(auto w : wmax) {
            if(st.find({h, w}) == st.end()) {
                ANS++;
                cout << ANS << endl;
                return;
            }
        }
    }
    cout << ANS << endl;
}
 
int main() {
    input();
    solve();
    return 0;
}

Measured memory_bytes: 49484
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
const int N=100005;
struct node
{
	int x,y;
}t;
bool operator <(node a,node b)
{
	if(a.x!=b.x)
		return a.x<b.x;
	return a.y<b.y;
}
set<node> st;
set<int> e[N];
int n,i,j,k;
map<node,int> mp;
int main()
{
	scanf("%d",&n);
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&j,&k);
		if(j>k)
			swap(j,k);
		++mp[(node){j,k}];
		e[j].insert(k);
		e[k].insert(j);
	}
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&j,&k);
		if(j>k)
			swap(j,k);
		++mp[(node){j,k}];
		e[j].insert(k);
		e[k].insert(j);
	}
	for(map<node,int>::iterator ddq=mp.begin();ddq!=mp.end();ddq++)
		if((ddq->second)>=2)
			st.insert(ddq->first);
	i=0;
	while(!st.empty())
	{
		t=*(st.begin());
		st.erase(t);
		e[t.x].erase(t.y);
		e[t.y].erase(t.x);
		if(e[t.x].size()<e[t.y].size())
			swap(t.x,t.y);
		for(set<int>::iterator ddq=e[t.y].begin();ddq!=e[t.y].end();ddq++)
		{
			e[t.x].insert(*ddq);
			e[*ddq].insert(t.x);
			mp[(node){min(t.x,*ddq),max(t.x,*ddq)}]+=mp[(node){min(t.y,*ddq),max(t.y,*ddq)}];
			if(mp[(node){min(t.y,*ddq),max(t.y,*ddq)}]==2)
				st.erase((node){min(t.y,*ddq),max(t.y,*ddq)});
			if(mp[(node){min(t.x,*ddq),max(t.x,*ddq)}]==2)
				st.insert((node){min(t.x,*ddq),max(t.x,*ddq)});
			e[*ddq].erase(t.y);
		}
		e[t.y].clear();
		++i;
		if(i==n-1)
		{
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
}


Measured memory_bytes: 38144
#include <bits/stdc++.h>
using namespace std;
signed main(){
  string s;
  cin>>s;
  unordered_map<char,int> m;
  for(int i=0;i<4;i++){
    m[s[i]]++;
  }
  for(auto p:m){
    if(p.second!=2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

int pow5(int k){
    int k2 = k * k;
    return k2 * k2 * k;
}

int main(){
    int x;
    cin >> x;
    int A = 0;
    int Bp = -1;
    int Bm = -1;

    int ansA, ansB;
    bool ans = false;
    while(!ans){
        A++;

        while(true){
            if (pow5(A) - pow5(Bp + 1) == x){
                ansA = A;
                ansB = Bp + 1;
                ans = true;
                break;
            }        
            else if (Bp + 1 >= A || pow5(A) - pow5(Bp+1) < x){
                break;
            }
            Bp++;
        }

        for(int i = 0; pow5(A) + pow5(i) <= x && i <= A; i++){
            if (pow5(A) + pow5(i) == x){
                ansA = A;
                ansB = -i;
                ans = true;
                break;
            }
        }

    }
    cout << ansA << " " << ansB << endl;
    return 0;
}

Measured memory_bytes: 3224
list_C = [ list(map(int,input().split(" "))) for i in range(3)]
ans = "Yes"

if list_C[0][0] - list_C[0][1] != list_C[1][0] - list_C[1][1] or list_C[0][0] - list_C[0][1] != list_C[2][0] - list_C[2][1]:
    ans = "No"

if list_C[0][0] - list_C[0][2] != list_C[1][0] - list_C[1][2] or list_C[0][0] - list_C[0][2] != list_C[2][0] - list_C[2][2]:
    ans = "No"

if list_C[0][1] - list_C[0][2] != list_C[1][1] - list_C[1][2] or list_C[0][1] - list_C[0][2] != list_C[2][1] - list_C[2][2]:
    ans = "No"

if list_C[0][0] - list_C[1][0] != list_C[0][1] - list_C[1][1] or list_C[0][0] - list_C[1][0] != list_C[0][2] - list_C[1][2]:
    ans = "No"

if list_C[0][0] - list_C[2][0] != list_C[0][1] - list_C[2][1] or list_C[0][0] - list_C[2][0] != list_C[0][2] - list_C[2][2]:
    ans = "No"

if list_C[1][0] - list_C[2][0] != list_C[1][1] - list_C[2][1] or list_C[1][0] - list_C[2][0] != list_C[1][2] - list_C[2][2]:
    ans = "No"

print(ans)

Measured memory_bytes: 3188
/// --- In the name of ALLAH --- ///


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


typedef long long              ll;
typedef vector<int>            vi;
typedef vector<ll>             vl;
typedef vector<vi>             vvi;
typedef vector<vl>             vvl;
typedef pair<int,int>          pii;
typedef pair<double, double>   pdd;
typedef pair<ll, ll>           pll;
typedef vector<pii>            vii;
typedef vector<pll>            vll;
typedef double                 dl;

#define endl                   '\n'
#define PB                     push_back
#define F                      first
#define S                      second
#define all(a)                 (a).begin(),(a).end()
#define rall(a)                (a).rbegin(),(a).rend()
#define sz(x)                  (ll)x.size()
#define wt                     ll t; cin>>t; while(t--)
#define input(a,n)             for(int i=0;i<n;i++) cin>>a[i];

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define mod 10000007
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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


const ll mx=1e9;



//q=51;

//ll b[q+1][q+1];


 main()
{
    optimize();
    string s,t,u;
    ll i,n,c=0;

    cin>>s>>t;
    n=sz(s);
    if(s==t)
        cout<<"Yes"<<endl;
    else
    {
       u=s;
       for(i=0;i<n;i++)
       {
           u=u.back()+u;
           u.pop_back();
           if(u==t)
           {
               c++;
               cout<<"Yes"<<endl;
               break;
           }
       }
       if(c==0)
        cout<<"No"<<endl;
    }









    return 0;
}






























































































Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n,k; cin >>n >>k;
  vector<int> x(n);
  rep(i, n) cin >>x[i];
  if (lower_bound(all(x), 0) == x.end() || *lower_bound(all(x), 0) > 0){
    x.push_back(0); sort(all(x)); n++; k++;
  }
  // ろうそくが必ず座標0にも置かれている問題に正規化
  // 座標0以外のろうそくk-1本に火をつける問題になる
  int i0 = lower_bound(all(x), 0) - x.begin(); // 0 のindex

  // 座標0に1本あればよいときはサヨナラ
  if (k == 1){ cout <<0 <<endl; return 0; }

  int res = INT_MAX;

  // x[i0] = 0 の位置に1本あるとして、xj < 0 と xj > 0 で合わせてk-1本確保する必要がある
  // xj < 0 の範囲にろうそくが i 本あるとしてそれぞれの場合を調べる
  for (int i=0; i<k; i++){
    int j1 = i0 - i;
    int j2 = i0 + (k-1) - i;
    if (j1 < 0 || j2 >= n) continue;
    chmin(res, abs(x[j1]) + abs(x[j2]) + min(abs(x[j1]), abs(x[j2])));
  }

  cout <<res <<endl;
}


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

int main() {
  int n;
  cin >> n;
  int left(0), right(n-1);
  char a[n];
  int ans(0);
  for (int i = 0; i < n; ++i) cin >> a[i];
  while (left < right) {
    while (left < right && a[left] == 'R') left++;
    while (left < right && a[right] == 'W') right--;
    if (left < right) {
      ans++;
      left++;
      right--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

sys.setrecursionlimit(10000)


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


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


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


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


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


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


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


def error_mat_print(m):
    for r in m:
        print(r, file=sys.stderr)

def mt(f):
    import time

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

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

    return wrap


@mt
def slv(L, A):

    dp = [[sys.maxsize] * (L+1) for _ in range(6)]
    for i in range(5):
        dp[i][0] = 0
    # dp[0][0] = 0

    def s(a, t):
        if t == 0 or t == 4:
            return a
        if t == 1 or t == 3:
            if a == 0:
                return 2
            else:
                return a % 2
        else:
            return (a+1) % 2

    for i, a in enumerate(A):
        t = dp[0][i]
        dp[0][i+1] = t + a
        t = min(t, dp[1][i])
        dp[1][i+1] = t+ ((a%2) if a != 0 else 2)
        t = min(t, dp[2][i])
        dp[2][i+1] = t + ((a+1)%2)
        t = min(t, dp[3][i])
        dp[3][i+1] =t + ((a%2) if a != 0 else 2)
        t = min(t, dp[4][i])
        dp[4][i+1] = t + a

        # error_print(a)
        # error_mat_print(dp)

    return min([dp[i][L] for i in range(5)])

def main():
    L = read_int()
    A = [read_int() for _ in range(L)]
    print(slv(L, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 56248
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

class Main{
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final vec[][] mat = new vec[n][];
        for(int i = 0; i<n; i++){
            final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            final int u = Integer.parseInt(st.nextToken());
            final int k = Integer.parseInt(st.nextToken());
            mat[u] = new vec[k];
            for(int j = 0; j<k; j++){
                mat[u][j] = new vec(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
            }
        }
        final int[] cost = new int[n];
        Arrays.fill(cost, Integer.MAX_VALUE);
        cost[0] = 0;
        final PriorityQueue<vec> pq = new PriorityQueue<vec>();
        pq.add(new vec(0, 0));
        while(!pq.isEmpty()){
            final int t = pq.peek().t;
            final int c = pq.poll().c;
            if(cost[t]<c) continue;
            for(final vec v:mat[t]){
                final int nc = c+v.c;
                if(nc<cost[v.t]){
                    cost[v.t] = nc;
                    pq.add(new vec(v.t, nc));
                }
            }
        }
        final StringBuilder sb = new StringBuilder();
        for(int i = 0; i<n; i++){
            sb.append(i).append(' ').append(cost[i]).append('\n');
        }
        System.out.print(sb);
    }
}

class vec implements Comparable<vec>{
    final int t;
    final int c;
    vec(int to, int cost){
        t = to;
        c = cost;
    }
    @Override
    public int compareTo(vec other){
        return c-other.c;
    }

}

Measured memory_bytes: 85328
#include<bits/stdc++.h>
#define ll long long
#define pb(a) push_back(a)
using namespace std;
int solveC()
{
    int x,n;
    cin>>x>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++)
    cin>>arr[i];
    //sort(arr.begin(),arr.end());
    
}
bool solve()
{
    ll x,y;
    cin>>x>>y;
    ll tt=y-2*x;
    if(tt<0 || tt%2!=0) return false;
    ll t=tt/2;
    ll cc=x-t;
    if(cc<0) return false;
    return true;
}
int main()
{
    if(solve()) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int INF=1e9+7;
const int maxn=2e5+5;
int a[100];
int main()
{
    int n,m;

    cin>>n>>m;

    for (int q=1;q<=n;q++)
    {
        int t;
        cin>>t;
        while (t--)
        {
            int x;
            cin>>x;
            a[x]++;
        }
    }

    int s=0;
    for (int q=1;q<=m;q++)
    {
        if (a[q]==n) s++;
    }

    cout<<s<<endl;


   

}

Measured memory_bytes: 256
/*
 * PrintAFrame.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
#include <vector>
using namespace std;

typedef struct {
	int a_H, a_W;
}DataSet;

int main(void) {

	vector<DataSet> vecDataSet;
	while (1) {
		DataSet data;
		int H, W = 0;
		cin >> H >> W;
		if ((0 == H) && (0 == W)) {
			break;
		}
		data.a_H = H;
		data.a_W = W;
		vecDataSet.push_back(data);
	}

	for (unsigned int i = 0; i < vecDataSet.size(); i++) {
		DataSet data = vecDataSet.at(i);
		for (int i = 0; i < data.a_H; i++) {
			for (int j = 0; j < data.a_W; j++) {
				if ( (i == 0) || (i == data.a_H - 1) ) {
					cout << "#";
				} else if ( (j == 0) || (j == data.a_W - 1) ) {
					cout << "#";
				} else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> pi;
#define PI 3.14159265359
long long mod=1000000007;
//int count=INT_MAX;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    //scanf("%d",&t);
    
    for(int l=0;l<t;l++){
        long double a,b;
        cin>>a>>b;
        long double ans=a*b;
        cout<<(long long)ans;
        // long long n;
        // cin>>n;
        // if(n==1){
        //     cout<<"0";
        //     continue;
        // }
        // int count=0;
        // while (n % 2 == 0)  
        // {  
        //     count++;//cout << 2 << " ";  
        //     n = n/2; 
        // }  
    
        // // n must be odd at this point. So we can skip  
        // // one element (Note i = i +2)  
        // for (int i = 3; i <= sqrt(n); i = i + 2)  
        // {  
        //     // While i divides n, print i and divide n  
        //     while (n % i == 0)  
        //     {  
        //         count++;//cout << i << " ";  
        //         n = n/i;  
        //     }  
        // }  
    
        // // This condition is to handle the case when n  
        // // is a prime number greater than 2  
        // if (n > 2)  
        //     count++;//cout << n << " ";
        // cout<<count;

    }
    
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int get_value(int sign, int x){
    if(sign == 0)   return -x;
    else    return x;
}

const char __sign[2] = {'-', '+'};

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

    string s;
    cin >> s;
    int n = s.length();
    vector<int> foo(n);
    for(int i = 0; i < n; ++i)  foo[i] = s[i] - '0';
    vector<char> c(n);
    c[3] = '=';
    int sum = foo[0];
    for(int i = 0; i < 2; ++i){
        sum += get_value(i, foo[1]);
        for(int j = 0; j < 2; ++j){
            sum += get_value(j, foo[2]);
            for(int k = 0; k < 2; ++k){
                sum += get_value(k, foo[3]);
                if(sum == 7){
                    c[0] = __sign[i], c[1] = __sign[j], c[2] = __sign[k];
                    for(int id = 0; id < n; ++id){
                        cout << foo[id] << c[id];
                    }
                    cout << 7 << endl;
                    return 0;
                }
                sum -= get_value(k, foo[3]);
            }
            sum -= get_value(j, foo[2]);
        }
        sum -= get_value(i, foo[1]);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int c[10001];
bool map[10001];
int n;
void DFS(int key){
    if(key<0||key>=n)return;
    int bef,aft;
    bef=key-1;
    while(true){
        if(bef<0)break;
        if(map[bef]&&c[bef]!=c[key])break;
        bef--;
    }
    bef++;
    aft=key+1;
    while(true){
        if(aft==n)break;
        if(map[aft]&&c[aft]!=c[key])break;
        aft++;
    }
    aft--;
    int cnt=0;
    for(int i=bef;i<=aft;i++)cnt+=map[i];
    if(cnt>3){
        for(int i=bef;i<=aft;i++)map[i]=false;
        DFS(bef-1);
    }
}
int main(){
    while(true){
    cin>>n;
    if(n==0)break;
    int ans=n;
    for(int i=0;i<n;i++)cin>>c[i];
    for(int ch=0;ch<n;ch++){
        int keep=c[ch];
        for(int aft=1;aft<=3;aft++){
            if(aft!=keep){
                c[ch]=aft;
                for(int i=0;i<n;i++)map[i]=true;
                DFS(ch);
                int cnt=0;
                for(int i=0;i<n;i++)cnt+=map[i];
                ans=min(ans,cnt);
            }
        }
        c[ch]=keep;
    }
    cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
using namespace std;
int main(){
    int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
    int x3,y3,x4,y4;
    x3 = x2-(y2-y1); y3 = y2+(x2-x1);
    x4 = x3-(y3-y2); y4 = y3+(x3-x2);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int r,c,s[10][10000],n;

int f(int d[10][10000],bool t[10]){
	int max=0,i,j,jk;
	for(i=0;i<r;i++){
		if(t[i]){
			for(j=0;j<c;j++){
				d[i][j]= !d[i][j];
			}
		}
	}
	/*for(i=0;i<r;i++){
			for(j=0;j<c;j++){
				printf("%d",d[i][j]);
			}
			puts("");
	}*/
	for(i=0;i<c;i++){
		jk=0;
		for(j=0;j<r;j++){
			jk+=d[j][i];
		}
		if(jk>r-jk) max+=jk;
		else max+=r-jk;
	}
	//printf("%d\n",max);
	for(i=0;i<r;i++){
		if(t[i]){
			for(j=0;j<c;j++){
				d[i][j]= !d[i][j];
			}
		}
	}
	return max;
}
void search(bool turn[10],int k){
	if(r==k){
		int o;
		/*for(int i=0;i<r;i++){
			printf("%d",turn[i]);
		}
		puts("");*/
		o=f(s,turn);
		if(o>n)n=o;
	}
	else{
		turn[k]=true;
		search(turn,k+1);
		turn[k]=false;
		search(turn,k+1);
	}
}

int main(){
	int i,j;
	bool b[10];
	for(;;){
		scanf("%d%d",&r,&c);
		if(!r && !c)break;
		n=0;
		for(i=0;i<r;i++) for(j=0;j<c;j++) scanf("%d",&s[i][j]);
		search(b,0);
		printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#define debug cout

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int m,n,b[510],r[510],V;
vint G[1010];
int match[1010];
bool used[1010];

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

void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v]=true;
	rep(i,sz(G[v])){
		int u=G[v][i],w=match[u];
		if(w<0||!used[w]&&dfs(w)){
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(){
	int res=0;
	memset(match,-1,sizeof(match));
	rep(v,V){
		if(match[v]<0){
			memset(used,0,sizeof(used));
			if(dfs(v))++res;
		}
	}
	return res;
}

int main() {
	IL{
		cin>>m>>n;
		if(m==0&&n==0)break;
		rep(i,m)cin>>b[i];
		rep(i,n)cin>>r[i];
		V=m+n;
		rep(i,1010)G[i].clear();
		rep(i,m)rep(j,n)if(gcd(b[i],r[j])>1)add_edge(i,j+m);
		cout<<bipartite_matching()<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>
using namespace std;

const int typeNum = 26;

void solve(long long D, std::vector<long long> c, std::vector<std::vector<long long> > s){
    std::chrono::system_clock::time_point  start, end; // 型は auto で可
    start = std::chrono::system_clock::now(); // 計測開始時間
    end = std::chrono::system_clock::now(); 
    double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();

    // initial t
    vector<long long> t = vector<long long>(D);
    int i=0;
    for (auto &tt : t) {
      tt = i + 1;
      i = (i + 1) % typeNum;
    }

    long long pastSut = 0;
    long long iterator = 0;

    while (true) {
        // change id and value
        long long changedIndex = iterator % t.size();
        if (changedIndex < 0) changedIndex += t.size();
        long long randomValue = (iterator * 18973) % typeNum + 1;
        if (randomValue < 1) randomValue += typeNum;
        long long pastValue = t[changedIndex];
        t[changedIndex] = randomValue;

        // current sutisfuction
        long long sut = 0;

        // make table
        vector<vector<long long> > table;
        for (int i=0;i<typeNum;++i) {
            table.push_back(vector<long long>(D));

            for (int j=0;j<D; ++j) {
                table[i][j] = -1;
            }
        }

        for (int i=0; i<D; ++i) {
            vector<long long> &target = table[t[i] - 1];
            for (int j=i; j<target.size() ;++j) {
                target[j] = i;
            }
        }

        for (int d = 0; d < D; ++d) {
            sut += s[d][t[d] - 1];

            // minus
            for (int i=0;i<typeNum;++i) {
                sut -= c[i] * (d - table[i][d]);
            }

            // todays sutisfuction
            //cout << sut << endl;
        }

        if (sut > pastSut) {
          // change
          pastSut = sut;
        }else{
          // cancel
          t[changedIndex] = pastValue;
        }

        iterator++;

        end = std::chrono::system_clock::now(); 
         elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
         if (elapsed > 1970) break;

         //break;
    }

    for (long long &tt : t) {
      cout << tt << endl;
    }

    // result sutisfuction
    //cout << pastSut << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long D;
    scanf("%lld",&D);
    std::vector<long long> c(26);
    for(int i = 0 ; i < 26 ; i++){
        scanf("%lld",&c[i]);
    }
    std::vector<std::vector<long long> > s(D, std::vector<long long>(26));
    for(int i = 0 ; i < D ; i++){
        for(int j = 0 ; j < 26 ; j++){
            scanf("%lld",&s[i][j]);
        }
    }
    solve(D, std::move(c), std::move(s));
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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 (b<a) { a=b; return 1; } return 0; }

bool solve(const vector<pair<int,int>> &v) {
  int N = v.size();
  int consume = 0;
  REP(i, N) {
    consume += v[i].second;
    if (consume > v[i].first) {
      return false;
    }
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> v(N);
  REP(i, N) {
    int A, B;
    cin >> A >> B;
    v[i] = make_pair(B, A);
  }
  sort(ALL(v));

  cout << (solve(v) ? "Yes" : "No") << endl;
  return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

int main(){
  char buf[1024];
  int r,D,x;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d %d", &r, &D, &x);

  int index=1;

  while(index<=10){
    x=r*x-D;
    printf("%d\n", x);
    index++;
  }

  return 0;

}


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

using namespace std;


int main() {
    int n, k, ans = 0;
    cin >> n;
    vector<int> cnt(1000005, 0);
    for (int i = 0; i < n; i++) {
        cin >> k;
        cnt[k]++;
    }
    vector<int> vis(1000005, 0);
    for (int i = 1; i <= 1000005; i++) {
        if (cnt[i] == 0 || vis[i])
            continue;
        if (cnt[i] == 1 && vis[i] == 0)
            ans++;
        for (int j = i; j <= 1000005; j += i)
            vis[j] = 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 10712
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long

int N;
int A[111];

int main()
{
	scanf("%d", &N);
	for(int i=1; i<=N; i++)
		scanf("%d", &A[i]);
	sort(A+1, A+N+1);
	int res = 0;
	for(int i=1; i<=N; i++)
		for(int j=i+1; j<=N; j++)
			for(int k=j+1; k<=N; k++)
			{
				if (A[i] != A[j] && A[j] != A[k] && A[k] != A[i])
				{
					if (A[i]+A[j] > A[k]) res++;
				}
			}
	printf("%d", res);
	return 0;
}

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

using namespace std;

int main()
{
	long N;
	int D1, D2;
	int s = 0;

	cin >> N;
	for (long i = 0; i < N; i++) {
		cin >> D1 >> D2;

		if (D1 == D2) s++;
		else s = 0;

		if (s == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return (0);
}


Measured memory_bytes: 3124
using System;
using System.IO;

namespace ABC123B
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var time = new int[5];
            var total = 0;
            var max = 0;
            var maxIndex = 0;

            for (int i = 0; i < 5; i++)
            {
                time[i] = int.Parse(Console.ReadLine());
                var wait = time[i] % 10 == 0 ? 0 : 10 - time[i] % 10;
                if (wait > max)
                {
                    max = wait;
                    maxIndex = i;
                }
                total += time[i] + wait;
            }

            var last = time[maxIndex] % 10 == 0 ? 0 : 10 - time[maxIndex] % 10;
            total -= last;
            Console.WriteLine(total);
        }
    }
}


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

#define endl '\n'

void solvetask(){
    int n; cin >> n;
    if (n <= 599) cout << 8;
    else if (n <= 799) cout << 7;
    else if (n <= 999) cout << 6;
    else if (n <= 1199) cout << 5;
    else if (n <= 1399) cout << 4;
    else if (n <= 1599) cout << 3;
    else if (n <= 1799) cout << 2;
    else if (n <= 1999) cout << 1;
    cout << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solvetask();
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<ll> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
//ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

ll func(ll a, ll b)
{
	ll ma, mi, n, m, l, x, y, ans;
	if (a % 2 == 0) {
		if (b % 2 == 0) {
			x = y = b / 2;
		} else {
			x = b / 2 + 1;
			y = b - x;
		}
	} else {
		if (b % 2 == 0) {
			x = y = b / 2;
		} else {
			x = b / 2 + 1;
			y = b - x;
		}
	}
	ans = min(a,b);
	REP(i, a)
	{
		n = x*i;
		m = y*i;
		l = a*b - n - m;
		ma = max({ n,m,l });
		mi = min({ n,m,l });
		ans = min(ma - mi, ans);
	}
	return ans;
}

int main()
{
	ll a, b, ans;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0) {
		cout << 0 << endl;
		return 0;
	} else {
		ans = func(a, b);
		ans = min(ans, func(b, a));
		cout << ans << endl;
		return 0;
	}
}

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 L[] = new int[N];
        int max = 0;
        int total = 0;
      for(int i=0;i<N;i++){
        L[i] = sc.nextInt();
        if(L[i] > max){
          max = L[i];
        }
        total += L[i];
      }
      
      if(max < total - max){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }      
	}
}

Measured memory_bytes: 22996
H,W = map(int,(input().split()))
L = [[] for _ in range(H)]

for i in range(H):
    L[i] = list(input())

for i in range(H):
    for j in range(W):

        if L[i][j] == "#":

            c = 0
            if i-1 >= 0:
                if L[i-1][j] == "#":
                    c += 1
            if i+1 <= H-1:
                if L[i+1][j] == "#":
                    c += 1
            if j-1 >= 0:
                if L[i][j-1] == "#":
                    c += 1
            if j+1 <= W-1:
                if L[i][j+1] == "#":
                    c += 1

            if c == 0:
                print("No")
                break
    
    else:
        continue
    break
else:
    print("Yes")

Measured memory_bytes: 39408
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>

using namespace std;

int main(){
	int p1;
	int p2;
	int p3;
	int j1;
	int j2;
	cin >> p1 >> p2 >> p3 >> j1 >> j2;
	cout << min({ p1, min (p2, p3)  }) + min({ j1, j2 }) - 50 << endl;

	return 0;
}

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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a*b <= b*c && a*b <= a*c){
        if(c % 2) cout << a*b << endl;
        else cout << 0 << endl;
    } else if(b*c <= a*b && b*c <= a*c){
        if(a % 2) cout << b*c << endl;
        else cout << 0 << endl;
    } else {
        if(b % 2) cout << a*c << endl;
        else cout << 0 << endl;        
    }
    return 0;
}

Measured memory_bytes: 256
s = str(input())
t = str(input())
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1]==t[j-1]:
            dp[i][j] = dp[i-1][j-1] +1
        else:
            dp[i][j] = max(dp[i][j-1], dp[i-1][j])

ans = ''
i = len(s)
j = len(t)
while (i>0) & (j>0):
    if dp[i][j] == dp[i-1][j]:
        i -=1
    elif dp[i][j] == dp[i][j-1]:
        j -=1
    else:
        ans = s[i-1] +ans
        i -=1
        j -=1
print(ans)

Measured memory_bytes: 112220
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N, K;
  int ans=0;
  int R, S, P;
  string T;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;
  for(int i=K; i<T.size(); i++){
    if(T[i]==T[i-K]) T[i]='n';
  }
  for(int i=0; i<T.size(); i++){
    if(T[i]=='r') ans+=P;
    if(T[i]=='s') ans+=R;
    if(T[i]=='p') ans+=S;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const  long double eps = 1e-2;
const long double pi = acos(-1.0);
using namespace std;



void solve(){
    int n;
    cin >> n;
    ll x, y;
    cin >> x >> y;
    
    n--;
    for (int i = 0; i < n; i++){
        ll new_x, new_y;
        cin >> new_x >> new_y;
        ll k = 1;
        if (new_x < x || new_y < y){
             k = (x + new_x - 1) / new_x;
            if (k < (y + new_y - 1) / new_y) k = (y + new_y - 1) / new_y;
            
        }
        x = new_x * k;
        y = new_y * k;
       // cout << x << " " << y << " " << k << endl;
    }
    cout << x + y << endl;
}
int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(3);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++){
         solve();
    }
}

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

const int maxn=100010;
int n;
int a[maxn];
char s[maxn];

bool check(int x){
	for(int i=n-x+2;i<=x;i++) if(a[i]!=a[i-1]) return false;
	return true;
}

int main(){

	scanf("%s",s+1); n=strlen(s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'0';
	int l=n/2, r=n, ans=l;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)) ans=mid, l=mid+1; else r=mid-1;
	}
	printf("%d\n", ans);
	return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

constexpr int inf = 1.01e9;
constexpr i64 inf64 = 4.01e18;
constexpr double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T &val) {
    fill((T *)ary, (T *)(ary + size), val);
}

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;
    vector<i64> a(N);
    rep(i,0,N) cin >> a[i];

    vector<i64> b(N,-1);
    for(i64 i=N-1; i>=0; --i){
        print(i);
        print(b);
        i64 j=i+1,box=-1,sum=0;
        rep(k,1,N+1){
            i64 l=j*k;
            if(l-1>=N) break;
            print(l-1);
            if(b[l-1]==-1){
                box=l-1;
                continue;
            }
            sum+=b[l-1];
        }
        print(box);
        print(sum);
        if(box!=-1) b[box]=(sum+a[i])%2;
        else if(sum%2!=a[i]){
            cout << -1 << endl;
            return;
        }
    }

    vector<i64> ans;
    rep(i,0,N){
        if(b[i]!=0) ans.emplace_back(i+1);
    }
    i64 M=ans.size();
    cout << ans.size() << endl;
    rep(i,0,M){
        cout << ans[i];
        if(i==M-1) cout << endl;
        else cout << " ";
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
void rec(int d, ll val, vector<ll> &v){
  v.pb(val);
  if(d==10) return ;
  rep(i,-1,2){
    ll add = val%10 + i;
    if(0<=add && add<=9){
      rec(d+1, val*10+add, v);
    }
  }
}
int main(){
  ll K; cin>>K;  
  vector<ll> v;
  rep(i,1,10) rec(1, i, v);
  sort(all(v));
  cout << v[K-1] << endl;
  return 0;
}


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

int main(){ 
  int N,M;
  cin >> N >> M;
  
  cout << (N * (N - 1) + M * (M - 1)) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	int a, b;
	cin >> a >> b;
	string s = "Odd";
	if ((a*b) % 2 == 0)
	{
		s = "Even";
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#create date: 2020-06-28 21:05

import sys
stdin = sys.stdin
import numpy as np

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    d = ni()
    c = np.array(na())
    s = list()
    for i in range(d):
        a = na()
        s.append(a)
    t = list()
    for i in range(d):
        t.append(ni()-1)

    period = np.zeros(26)
    last_day = np.zeros(26)
    v = 0

    for day in range(1, d+1):
        last_day[t[day-1]] = day
    
        v += s[day-1][t[day-1]]
        v -= (sum(c * (day - last_day)))
        print(int(v))
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 27292
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
x,k,d=gsmi
if x>=0
  if x>=k*d
    puts x-k*d 
  else
    div=x/d
    mod=x%d
    k-=div
    x-=d*div
    puts k.even? ? mod : (x-d).abs
  end
else
  if -x>=k*d
    puts (x+k*d).abs
  else
    div=-x/d
    mod=-x%d
    k-=div
    x+=d*div
    puts k.even? ? mod : (mod-d).abs
  end
end

Measured memory_bytes: 14364