akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll H, W, N; cin >> H >> W >> N;
	map<pair<ll, ll>, ll> m;

	for (int n = 0; n < N;n++) {
		ll a, b; cin >> a >> b;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3;j++) {
				if (a - i >= 1 && b - j >= 1 && a - i + 2 <= H && b - j + 2 <= W) {
					m[make_pair(a - i, b - j)]++; 
				}

			}
		}
	}

	vector<ll> ans(10, 0);
	for (auto it = m.begin(); it != m.end();it++) ans[it->second]++;
	ans[0] = (H - 2)*(W - 2) - m.size();
	for (int i = 0; i < 10;i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 56576
package main

import (
	"bufio"
	f "fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		f.Println(err)
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	var n int
	f.Scan(&n)
	arr := scanSlice(n)

	ans := ans(n, arr)

	f.Println(ans)
}

func max(nums []int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func ans(n int, arr []int) int {
	maxInt := arr[0]
	diff := 0
	cnt := 0
	for i := 1; i < n; i++ {
		///f.Printf("いまから%vを比較します\n", arr[i])
		if maxInt > arr[i] {
			diff = maxInt - arr[i]
			arr[i] += diff
			cnt += diff
		} else {
			maxInt = arr[i]
		}
		//f.Printf("追加した段数の合計は現在%v\n", cnt)
	}

	//f.Printf("差分の合計は:%v\n", cnt)
	return cnt
}


Measured memory_bytes: 5924
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int P[200010];

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> P[i];
	int ans=0, mn=N+1;
	for(int i=0; i<N; ++i){
		if(P[i]<mn){
			++ans;
			mn=P[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

    string s;
    cin >> s;

    for(size_t i = 0; i < s.size(); ++i){
        if(s[i] == ',')
            s[i] = ' ';
    }
    cout << s << endl;

    return 0;
};

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int w,h;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
main()
{
	while(cin>>w>>h,w)
	{
		queue<pair<int,int> >P;
		string s[22];
		int cnt=1;
		bool used[22][22]={};
		for(int i=0;i<h;i++)cin>>s[i];
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)
		{
			if(s[i][j]=='@')
			{
				P.push(make_pair(i,j));
				used[i][j]=1;
			}
		}
		while(!P.empty())
		{
			int x=P.front().first,y=P.front().second;P.pop();
			for(int r=0;r<4;r++)
			{
				int tx=dx[r]+x,ty=y+dy[r];
				if(tx<0||ty<0||tx>=h||ty>=w||s[tx][ty]=='#'||used[tx][ty])continue;
				used[tx][ty]=1;
				P.push(make_pair(tx,ty));
				cnt++;
			}
		}
		cout<<cnt<<endl;
	}
}



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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

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

    int n;
    cin >> n;
    n %= 10;
    if(n==3) cout << "bon\n";
    else if(n==0 || n==1 || n==6 || n==8) cout << "pon\n";
    else cout << "hon\n";

    return 0;
}


Measured memory_bytes: 3620
//Print Test Cases
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String input;
		int count =1;
		while (!(input = in.readLine()).equals("0")){
			System.out.println("Case "+count+": "+input);
			count++;
		}
	}
}

Measured memory_bytes: 27984
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static long[] a,p;
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		a=new long[s[0]+1];
		p=new long[s[0]+1];
		a[0]=1;p[0]=1;
		for(int i=1;i<=s[0];i++){
			a[i]=a[i-1]*2+3;
			p[i]=p[i-1]*2+1;
		}
		Console.WriteLine(fu(s[0],s[1]));
	}
	static long fu(long n,long x){
		if(x==1){return (n==0)?1:0;}
		else if(1<x&&x<=1+a[n-1]){return fu(n-1,x-1);}
		else if(x==2+a[n-1]){return p[n-1]+1;}
		else if(2+a[n-1]<x&&x<=2+2*a[n-1]){return p[n-1]+1+fu(n-1,x-2-a[n-1]);}
		else {return 2*p[n-1]+1;}
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  pair<int, int> m;
  pair<int, int> s;
  m = make_pair(0,0);
  s = make_pair(0,0);
  for(int i = 0; i < n ;i++){
    cin>> a[i];
    if(m.first < a[i]){
      m.first = a[i];
      m.second = i;
    }
  }
  for(int i = 0 ; i < n ; i++){
    if(i == m.second) continue;
    if(s.first < a[i]){
      s.first = a[i];
      s.second = i;
    }
  }
  for(int i = 0; i < n ; i++){
    if(i == m.second){
      cout << s.first << endl;
    }
    else cout << m.first << endl;
  }
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;

class State
{
public:
	int x,y,c,f,sw;
	State(int x, int y, int c, int f, int sw)
		:x(x),y(y),c(c),f(f), sw(sw)
	{}

	bool operator<(const State& s) const
	{
		return c > s.c;
	}
};

int W, H, S;
int dx[] = { -1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
bool vis[55][55][2][1<<10];

string field[50];
string switches[50][10];

int toInt(char c)
{
	c = tolower(c);

	return c - 'a';
}

int calcInit(char c)
{
	if(isupper(c)) return 1;
	if(c == '^') return 1;

	return 0;
}

int calcFloor(int x, int y, int sw, char c)
{
	int res = calcInit(c);
	for(int i=0; i<S; i++) {
		if(switches[y][i][x] != '*') continue;
		if((sw >> i) & 1) res =  ( res + 1 ) % 2;
	}

	return res;
}

void qpush(int x, int y, int c, int f, int sw, queue<State>& q)
{
	if(vis[x][y][f][sw]) return;
	vis[x][y][f][sw] = 1;

	q.push(State(x,y,c,f,sw));
}

int main()
{
	cin >> W >> H;



	for(int i=0; i<H; i++) 
		cin >> field[i];


	cin >> S;
	for(int k=0; k<S; k++)
	for(int i=0; i<H; i++)
		cin >> switches[i][k];

	memset(vis, 0, sizeof(vis));

	int sx,sy;
	for(int i=0; i<H; i++)
	for(int j=0; j<W; j++)
		if(field[i][j] == '%') { sx = j; sy = i; }

	queue<State> q;
	qpush(sx, sy, 0, 0, 0, q);

	int res = -1;
	while(!q.empty()) {
		State s = q.front(); q.pop();

		if(field[s.y][s.x] == '&') {
			res = s.c;
			break;
		}

		if(field[s.y][s.x] == '|') {
				for(int i=0; i<2; i++) {
					qpush(s.x,s.y,s.c+1,i,s.sw,q);
				}
		}

		if(isalpha(field[s.y][s.x])) {
			int tsw = s.sw ^ (1<<(toInt(field[s.y][s.x])));
			int tf = calcFloor(s.x,s.y,tsw,field[s.y][s.x]);
			qpush(s.x,s.y,s.c+1,tf,tsw,q);
		}

		for(int i=0; i<4; i++) {
			int tx = s.x + dx[i];
			int ty = s.y + dy[i];
			int tc = s.c + 1;
			int tf = s.f;

			if(field[ty][tx] == '#') continue;
			if(field[ty][tx] != '|') {
				if(tf != calcFloor(tx, ty, s.sw, field[ty][tx])) continue;
			}

			qpush(tx,ty,tc,tf,s.sw, q);
		}
	}

	cout << res << endl;
}

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

int n, m, x;
int c[15], a[15][15];

int main() {
    int ans = 1e9;
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) cin >> a[i][j];
    }

    for (int bits = 0; bits < (1 << n); bits++) {
        int d[15];
        int cnt = 0;
        for (int i = 0; i < n; i++) d[i] = 0;
        for (int i = 0; i < n; i++) {
            if (bits & (1 << i)) {
                cnt += c[i];
                for (int j = 0; j < m; j++) d[j] += a[i][j];
            }
        }
        bool ok = true;
        for (int i = 0; i < m; i++) {
            if (d[i] < x) {
                ok = false;
            }
        }
        if (ok) ans = min(ans,cnt); 
    }
    if (ans == 1e9) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3632
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
typedef long long ll ;
#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
using namespace std;
const int maxn = 2000*100+5 ;
const ll inf = 9223372036854775807 ;
const ll mod = 1e9 + 7 ;
ll n , q  ,t  , x , v  , sum  , seg[3][4*maxn] , sz; 
void upd(ll id , ll l , ll r , ll y , ll x , ll lx , ll rx)
{
	if(rx <= l || lx >= r) 
	{
		return ; 
	}
	if(rx <= r && lx >= l)
	{
		seg[id][x] = min(seg[id][x] , y) ; 
		return ; 
	}
	ll mid = lx + rx >> 1 ; 
	upd(id , l , r , y , x << 1 , lx , mid) ; 
	upd(id , l , r , y , x << 1 | 1 , mid , rx) ; 
}
ll get(ll id , ll i , ll x , ll lx , ll rx )
{
	if(rx - lx == 1)
	{
		return seg[id][x] ; 
	}
	ll mid = lx + rx >> 1 ; 
	if(i < mid)
	{
		return min(seg[id][x] , get(id , i , x << 1 , lx , mid)) ; 
	}
	else
	{
		return min(seg[id][x] , get(id  , i , x << 1 |1 , mid , rx)) ;
	}
}
int main()
{
	migmig ;
	cin>>n >> q; 
	sz = 1 ; 
	while(sz <= n) sz *= 2 ; 
	sum = (n-2) * (n-2) ; 
	for(int i = 0 ; i < 4 * maxn ; i ++ ) seg[2][i] = seg[1][i] = n ; 
	for(int i = 1 ; i<= q ; i ++ )
	{
		cin>>t>>x ; 
		v = get(t , x , 1 , 0 , sz ) ; 
		sum -= (v-2) ;
		//cout<<i <<" : "<<sum <<" " << v <<" upding " << 3-t <<" " << v <<" " << x << endl ;  
		upd(3 - t  , 1 , v , x , 1 , 0 , sz) ; 
	}
	cout<<sum ; 
}








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

#define mod 1000000007
using ll=long long;

ll modpow(ll n,ll m=mod-2){
  ll r=1;
  while(m){
    r=r*((m%2)?n:1)%mod,n=n*n%mod,m>>=1;
  }
  return r;
}

int main(){
	
	int n;
	cin >> n;

	ll ans = modpow(10,n);
	ans=ans+modpow(8,n);
	ans=ans%mod;
	ans=ans-modpow(9,n);
	ans=ans%mod;
	ans=ans-modpow(9,n);
	ans=ans%mod;

	ans=(ans+mod)%mod;
	cout << ans << endl;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

constexpr ll INF = 1e15;

constexpr ll mod = 1e9 + 7;

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

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



Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf = br.readLine();
		int cubic = Integer.parseInt(buf);
		cubic = cubic * cubic * cubic;
		System.out.println(cubic);
	}
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
    int x,n;
    cin >> x >> n;
    VI p(n);
    set<int> pp;
    rep(i,n){
      cin >> p.at(i);
      pp.insert(p.at(i));
    }
    int mn=10000000;
    int ans;
    for(int i=120;i>=-120;i--){
        if(pp.count(i)){}
        else{
          if(mn>=abs(i-x)){
            ans=i;
          }
          mn=min(abs(x-i),mn);
        }
    }
    cout << ans << endl;
    
  }


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

int main()
{
    int a,b,c,d,n;
    int first1,last1,s=0;
   // freopen("input.txt","r",stdin);
   int t,k;
  // cin>>n>>t>>k>>d;
  cin>>t>>k;
  if(t==k)
  {
      cout<<"Yes\n";
  }
  else
  {
      cout<<"No\n";
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from math import gcd, ceil
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


def main():
    A, B = map(int, input().split())
    print(A * B)


if __name__ == '__main__':
    main()


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

#define rep(i, n) for (int i = 0; i < n; i++)

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

    double num = 0;
    int cnt = 0;
    int lp = N;
    while (lp > 0)
    {
        if (lp % 2 != 0) {
            cnt++;
            lp--;
        } else
        {
            lp--;
            continue;
        }
    }
    num = (double)cnt / N;

    cout << fixed << setprecision(10) << num << endl;
    
    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N,M;
	cin >> N >> M;
	map<int,int> m;
	FOR(i,0,N){
		int K;
		cin >> K;
		FOR(j,0,K){
			int A;
			cin >> A;
			m[A]++;
		}
	}
	ll ans = 0;
	FOR(i,1,M+1){
		ans += m[i] == N;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int h, w, dp[1005][1005];
char c[1005][1005];
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)cin >> c[i][j];
	}
	
	for (int i = 0; i < h; i++) {
		if (c[i][0] == '#')break;
		dp[i][0] = 1;
	}
	for (int i = 0; i < w; i++) {
		if (c[0][i] == '#')break;
		dp[0][i] = 1;
	}
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (c[i][j] == '#')continue;
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % INF;
		}
	}
	cout << dp[h - 1][w - 1] % INF << endl;
	endre;
}

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
vector<int> p;

int main(){
  int n;
  cin>>n;
  int z[n+1]={};
  for(int i=1;i<=n;i++){
    int t;
    cin>>t;
    p.push_back(t);
    z[t]=i;
  }
  int m=p[0];
  int ans=0,tmp=0;
  for(int i=2;i<=n;i++){
    if(z[i-1]<z[i]){
      tmp++;
    }else{
      ans=max(ans,tmp);
      tmp=0;
    }
  }
  ans=max(ans,tmp);
  cout<<n-ans-1<<endl;

  return 0;
}


Measured memory_bytes: 2168
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> m = new TreeMap<>();
        for (int i = 1; i <= n; i++) {
            m.put(sc.nextInt(), i);
        }

        StringBuilder sb = new StringBuilder();
        for (Entry<Integer, Integer> ent : m.entrySet()) {
            sb.append(ent.getValue());
            sb.append(" ");
        }

        sb.append("\n");
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 66404
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string a;

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

  if( 'a' <= a[0] && a[0] <= 'z')
    std::cout << 'a' << std::endl;
  else
    std::cout << 'A' << std::endl;

  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		
		int start = 0;
		int startcount = 0;
		int finish = 0;
		
		for(int i = 0;i<s.length();i++){
			
			if(s.substring(i, i+1).equals("Z")){
				finish = i;//末尾のZを切り取るので限界まで調べて更新し続ける
			}
			
			
			if(s.substring(i, i+1).equals("A")&&startcount==0){
				start = i;
				startcount = 1;//先頭のAを切り取りたいので最初に見つけたAのみでいい
			}
			
		}
		
		
		//System.out.println(s.substring(start, finish+1));
		System.out.println(s.substring(start, finish+1).length());
		
		
		
		
		
		
		
		
	}

}


Measured memory_bytes: 40040
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define REYNA(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, pair <int, ll> > PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int inf = 1e9+9;
const ll mod = 1e9+696969;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
const int maxn = 510;
bool a[maxn][maxn];

bool canBeGenerated[maxn];
bool atLeastOneBlack;
int n;

int main()
{
	boost;
	cin >> n;
	FOR(i, 1, n)
		FOR(j, 1, n) {
			char zn;
			cin >> zn;
			a[i][j] = (zn == '#'?0:1);
			if (!a[i][j]) {
				atLeastOneBlack = true;
				canBeGenerated[j] = true;
			}
		}
	
	int ROW = 2 * n + 5;
	FOR(i, 1, n) {
		int rowCost = 0;
		FOR(j, 1, n) rowCost += a[i][j];
		if (!canBeGenerated[i]) ++rowCost;
		ROW = min(ROW, rowCost);
	}
	
	if (!atLeastOneBlack) OUT(-1);
	int second_cost = 0;
	FOR(j, 1, n) {
		bool add = false;
		FOR(i, 1, n) add |= a[i][j];
		second_cost += add;
	}
	
	cout << ROW + second_cost;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
	float x[4] = { 0.0 };
	float y[4] = { 0.0 };
	int n = 0;
	int i;
	scanf("%d", &n);
	while (n-- > 0){
		for (i = 0; i < 4; i++)
			scanf("%f %f", &x[i], &y[i]);
		for (i = 0; i < 4; i += 2) {
			x[i] -= x[i + 1];
			y[i] -= y[i + 1];
		}
		/*
		if (x[0] == 0.0 || x[2] == 0.0){
			if (x[0] == 0.0 && x[2] == 0.0)
				printf("YES\n");
			else
				printf("NO\n");
		}
		
		else*/ if ((y[0] / x[0]) == (y[2] / x[2]))
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 616
#include<stdio.h>
int main (void){
	int f = 1;
	char S[101];
	scanf("%s",S);
	for (int i = 0; i < 101; ++i){
		if (i % 2 == 0){
			if (S[i] == 'L'){
				f = 0;
			}
		}else if(i % 2 == 1){
			if (S[i] == 'R'){
				f = 0;
			}
		}
	}
	if (f == 1){
		printf("Yes");
	}else {
		printf("No");
	}
	return 0;
}

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

int N, K;

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

int main(){
	cin >> N >> K;
	int a;
	int max = 0;
	cin >> a;
	if(a > max) max = a;
	for(int i = 1; i < N; i++){
		int input;
		cin >> input;
		a = gcd(a, input);
		if(input > max) max = input;
	}
	//cout << max << endl;
	//cout << a << endl;
	if(K <= max && K % a == 0) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << 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; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  string s;
  LL k;
  cin >> s >> k;
  k--;

  REP(i, SZ(s)) {
    if(s[i] != '1') {
      cout << s[i] << endl;
      return;
    }
    if(i == k){
      cout << '1' << endl;
      return;
    }
  }
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    set<char> se;
    rep(i,s.size()){
        if(s[i] == t[i]) se.insert(s[i]);
        else{
            if(se.find(s[i]) != se.end() || se.find(t[i]) != se.end()){
                cout << "No" << endl;
                return 0;
            }
            se.insert(t[i]);
            char u = s[i];
            char v = t[i];
            for(int j = i; j < s.size(); j++){
                if(s[j] == u) s[j] = v;
                else if(s[j] == v) s[j] = u;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 916
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ggr getchar();getchar();return 0;
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int a[114];
signed main() {
	int n, cnt = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	for (int i = 1; i < n; i++) {
		if (a[i - 1] < a[i]) {
			cnt += abs(a[i] - a[i - 1]);
		}
	}
	cout << cnt + a[0] << endl;
	ggr
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
    basic_ostream<charTDummy, traitsDummy> &(
      basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int A = read(), B = read();

  if (B % A == 0)
    print(A + B);
  else
    print(B - A);

  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int a, b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline


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


def main():
    n = int(input())
    al = []
    bl = []
    for _ in range(n):
        a, b = map(int, input().split())
        al.append(a)
        bl.append(b)
    ans = 0
    for (i, a) in reversed(list(enumerate(al))):
        b = bl[i]
        a += ans
        a = a % b
        if a == 0:
            continue
        ans += b - a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27100
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int a, b, c;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    bool flag = false;
    if (a == b && a != c)
        flag = true;
    if (a == c && a != b)
        flag = true;
    if (b == c && a != c)
        flag = true;
    if (flag)
        cout << "Yes" << endl;
    else {
        cout << "No" << endl;
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

int N, i, j, k, tmp, h, w, t;

int main(void) {
	int A, B, ans;
	scanf("%d %d", &A, &B);
	ans = A + B;
	ans = max(A - B, ans);
	ans = max(A * B, ans);
	printf("%d", ans);

	return 0;
}

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

#define N 1000000
#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )

static int k_operafan[ 2 ][ N ];

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;
  int mode;

  memset ( k_operafan, -1, sizeof ( k_operafan ) );
  k_operafan[ 0 ][ 0 ] = k_operafan[ 1 ][ 0 ] = 0;
  for ( mode = 0; mode <= 1; ++mode )
  for ( i = 1; i < N; ++i )
  {
    k_operafan[ mode ][ i ] = i;
    for ( j = 1; ; ++j )
    {
      const int c = j * ( j + 1 ) * ( j + 2 ) / 6;

      if ( i - c < 0 )
        break ;
      if ( mode && ( c % 2 == 0 ) )
        continue ;

      k_operafan[ mode ][ i ] = MIN( k_operafan[ mode ][ i ]
                                   , k_operafan[ mode ][ i - c ] + 1 );
    }
  }

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( n == 0 ) break ;

    printf ( "%d %d\n", k_operafan[ 0 ][ n ], k_operafan[ 1 ][ n ] );
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 8420
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var set = new Set();
var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var ans = 0;
  for(var i = 0; i < 2; i++){
    var d = solve(n - i);
    for(var j = 0; j < d.length; j++){
      var t = d[j], m = n;
      while(m % t === 0)m /= t;
      if(m % t === 1)
        ans++;
    }
  }
  return ans;
}

function solve(x){
  if(x === 1)return [];
  var r = [x];
  for(var i = 2; i*i <= x; i++){
    if(x % i === 0){
      if(!set.has(i))set.add(i), r.push(i);
      if(!set.has(x/i))set.add(x/i), r.push(x/i);
    }
  }
  return r;
}

Measured memory_bytes: 9548
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int a, b; cin >> a >> b;
  auto ans = (a*b % 2 != 0) ? "Odd" : "Even";
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
n = int(input())
S = [int(x) for x in input().split()]
S.sort()
q = int(input())
T = [int(x) for x in input().split()]
T.sort()

import bisect

ans = 0
s = set()
for i in S:
    if i not in s:
        idx_left = bisect.bisect_left(T, i)
        idx_right = bisect.bisect_right(T, i)
        ans += idx_right - idx_left
        s.add(i)

print(ans)




Measured memory_bytes: 16896
#include<iostream>

using namespace std;

int main(){
   
    int A, B;
    int ac, bc;
    double old = 0.08, n = 0.1;
    double a, b, ad, bd;
    cin >> A >> B;

    for ( int i = 0 ;  i < 1100 ; i++ ){
        // cout << "_" << i << "_" << endl;
        a = i * old;
        b = i * n;
        // cout << a << "," << b << endl;
        ac = (int)a*10;
        bc = (int)b*10;
        ad = (double) ac / 10;
        bd = (double)bc / 10;
        // cout << ac << "," << bc << endl;
        // cout << ad << "," << bd << endl;
        if ((ad == A) && (bd == B))
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	    ll p=1000000007;
	    ll n,k;
	    cin>>n>>k;
	    ll sum=0;
	    for(ll i=k;i<=(n+1);i++)
	    {
	    	ll val=n*i-i*(i-1)+1;
	    	val=val%p;
	    	sum=(sum+val)%p;
	    }
	    cout<<sum;
}

Measured memory_bytes: 3616
#include <stdio.h> 

int main(){
	int a;
	int b;
	int c;

	char buf[256];
	fgets(buf,256,stdin);
	sscanf(buf,"%d %d %d" ,&a,&b,&c);

	if(c>=a && c<=b){
	printf("Yes\n");
	}else{
	printf("No\n");
	}	



	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	ans := 0
	ok := true
	for ok {
		for i, n := range A {
			if n%2 != 0 {
				ok = false
			} else {
				A[i] /= 2
			}
		}
		if ok {
			ans++
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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





int main() {
	int a, b;
	cin >> a >> b;

	int ans;
	if (a + b <= 16) {
		
		if (a > 8 || b > 8) {
			cout << ":(";
		}
		else {
			cout << "Yay!";
		}

	}else {
		cout << ":(";
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <sstream>

using namespace std;

int main() {
    string str;
    getline(cin, str);

    stack<int> sta;
    stringstream ss(str);
    string item;
    while (getline(ss, item, ' ')) {
        if ('0' <= item[0] && item[0] <= '9') {
            sta.push(stoi(item));
            continue;
        }

        int r = sta.top();
        sta.pop();
        int l = sta.top();
        sta.pop();

        switch (item[0]) {
        case '+':
            sta.push(l + r);
            break;
        case '-':
            sta.push(l - r);
            break;
        case '*':
            sta.push(l * r);
            break;
        default:
            break;
        }
    }
    
    cout << sta.top() << endl;

    return 0;
}

Measured memory_bytes: 3200
N, Ma, Mb = map(int, input().split())
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

INF = 10 ** 5
nums = 401

dp = [[[INF for _ in range(nums+100)] for _ in range(nums+100)] for _ in range(N+1)]

dp[0][0][0] = 0

for i in range(N):
    for sum_a in range(nums):
        for sum_b in range(nums):
            #if dp[i][sum_a][sum_b] == INF:
            #    continue
            dp[i+1][sum_a+a[i]][sum_b+b[i]] = min(dp[i+1][sum_a+a[i]][sum_b+b[i]], dp[i][sum_a][sum_b] + c[i])
            dp[i+1][sum_a][sum_b] = min(dp[i+1][sum_a][sum_b], dp[i][sum_a][sum_b])
            #dp[i+1][sum_a+a[i]][sum_b+b[i]] = min(dp[i+1][sum_a+a[i]][sum_b+b[i]], dp[i][sum_a][sum_b] + c[i])
            #print(i, dp[i][sum_a][sum_b], sum_a, sum_b)


res = INF
for i in range(1, nums):
    for j in range(1, nums):
        if i * Mb == j * Ma:
            res = min(res, dp[N][i][j])

if res == INF:
    res = -1

print(res)


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

int main() {
    ll n;
    cin >> n;
    vector<double> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    double ans = 0;
    for(ll i = 0; i < n; i++) ans += 1 / a[i];
    ans = 1 / ans;
    printf("%.10f\n", ans);
    
    

    
}


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

int main(){
    int A, B, C;
    cin >> A >> B >> C;

    int res = 0;
    int count = 0;
    int week = 0;
    week = A * 7 + B;

    while (res + week <= C) {
        res += week;
        count += 7;
    }

    int rest = 0;
    rest = C - res;
    if (rest%A == 0){
        if (rest > 7*A){
            count += 7;
        } else {
            count += (rest/A);
        }
    } else {
        if (rest > 7*A){
            count += 7;
        } else {
            count += (rest/A) + 1;
        }
    }
    cout << count << endl;
}


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

int main(){
    ll n;
    cin>>n;
    for(ll i=-200;i<201;i++){
        for(ll j=-200;j<201;j++){
            if(pow(i,5)-pow(j,5)==n){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main() {

	ll n, T; cin >> n >> T;
	
	vector<ll> t(n);
	for (ll i = 0; i < n; i++) {
		cin >> t[i];
	}

	ll ans = 0;
	for (ll i = 0; i < n - 1; i++) {
		ans += min(T, t[i + 1] - t[i]);
	}
	ans += T;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
s = input()
sum=0
for bit in range(1 << len(s)-1):
  list_i  = [i for i in s]
  count=0
  for i in range(len(s)-1):
    if bit & (1<<i):
      count += 1
      list_i.insert(i+count,'+')
  ans=''
  for i in list_i:
    ans += i
  for i in ans.split('+'):
    sum += int(i)
print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,ans=0,c;
scanf("%d%d",&a,&b);
for (int i=1;i<=b;i++){
scanf("%d",&c);
ans+=c;
}
if (ans>=a)
printf("Yes");
else printf("No");
return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}

const int inf = 1'000'000'007;


void solve() {
  string s;
  cin >> s;
  map<char, int> cnt;
  for (auto i : s) {
    cnt[i]++;
  }
  if ((cnt['S'] > 0) + (cnt['N'] > 0) == 1) {
    cout << "No\n";
    return;
  }
  if ((cnt['E'] > 0) + (cnt['W'] > 0) == 1) {
    cout << "No\n";
    return;
  }
  cout << "Yes\n";
}

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

  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3624
N, C = gets.split.map(&:to_i)
xs = Array.new(N)
vs = Array.new(N)
ans = 0

N.times do |i|
  xs[i], vs[i] = gets.split.map(&:to_i)
end

sum_right = Array.new(N)
sum_left = Array.new(N)
max_right = Array.new(N)
max_left = Array.new(N)

N.times do |i|
  if i == 0
    prev_right = 0
    prev_left  = 0
    next_r = xs[0]
    next_l = C - xs[N-1]
  else
    prev_right = sum_right[i-1]
    prev_left  = sum_left[i-1]
    next_r = xs[i] - xs[i-1]
    next_l = xs[N-(i-1)-1] - xs[N-i-1]
  end

  sum_right[i] = vs[i] - next_r + prev_right
  sum_left[i]  = vs[N - i - 1] - next_l + prev_left
end

r_now_max = 0
l_now_max = 0
N.times do |i|
  max_right[i] = [sum_right[i],r_now_max].max
  r_now_max = [r_now_max, sum_right[i]].max
  max_left[i] = [sum_left[i],l_now_max].max
  l_now_max = [l_now_max, sum_left[i]].max
end

r = 0
l = 0
N.times do |i|
  tmp_max_l = N-i-2 < 0 ? 0 : max_left[N - i - 2]
  tmp_max_r = N-i-2 < 0 ? 0 : max_right[N - i - 2]
  r = sum_right[i] - xs[i] + tmp_max_l
  l = sum_left[i] - (C - xs[N - i - 1]) + tmp_max_r
  ans = [ans,r,l,sum_right[i],max_left[i]].max
end
#p sum_right
#p sum_left
#puts ""
#p max_right
#p max_left

puts ans


Measured memory_bytes: 6524
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

if A1 < B1:
  A1, A2, B1, B2 = B1, B2, A1, A2

xa = A1*T1 + A2*T2
xb = B1*T1 + B2*T2
if xa > xb:
  print(0)
elif xa == xb:
  print('infinity')
else:
  d1 = (A1 - B1) * T1
  d2 = xb - xa
  n = d1 // d2
  if d1 % d2 == 0:
    print(2*n)
  else:
    print(2*n + 1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>b) swap(a,b);
    for(int c=a;c<=b;++c)
        if(a*b*c&1) return !printf("Yes\n");
    return !printf("No\n");
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
long A[50], P[50];

long f(int N, long X) {
  if (N == 0) {
    if (X <= 0) return 0;
    else return 1;
  } else if (X <= 1 + A[N-1]) {
    return f(N-1, X-1);
  } else {
    return P[N-1] + 1 + f(N-1, X-2-A[N-1]);
  }
}

int main() {
  int N;
  long X;
  scanf("%d %ld", &N, &X);
  A[0] = P[0] = 1;
  for (int i=1; i<N; i++) {
    A[i] = 2 * A[i-1] + 3;
    P[i] = 2 * P[i-1] + 1;
  }
  printf("%ld\n", f(N, X));
}


Measured memory_bytes: 128