akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] a = new int[n];
		int ct = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt() % 2;
			if (a[i] == 0) {
				ct++;
			}
		}
		if (ct == 0 || ct == n) {
			out.println(0);
		} else if ((n - ct) % 2 == 0) {
			out.println(n - 2);
		} else {

			out.println(n - 1);
		}
		out.flush();
	}
}


Measured memory_bytes: 100108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<tuple<string,int,int>>list(N);
  for(int i=0;i<N;i++){
    cin>>get<0>(list.at(i))>>get<1>(list.at(i));
    get<2>(list.at(i))=i+1;
    get<1>(list.at(i))=-1*get<1>(list.at(i));
  }
  sort(list.begin(),list.end());
  for(int i=0;i<N;i++){
    cout<<get<2>(list.at(i))<<endl;
  }
}

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	m *= 6;
	h *= 30;
	h += 30 * (m / 360.0);
	double l = max(h, m);
	double s = min(h, m);
	double ang = l - s;
	if (180 <= ang) ang = 360 - ang;
	double ans = sqrt(a * a + b * b - 2 * a * b * cos(ang * M_PI / 180.0));
	cout << fixed << setprecision(20) << ans << endl;
}


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

string S, T;
int A, B;
string U;
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> S >> T >> A >> B >> U;
    if (S==U) cout << A-1 << " " << B << endl;
    else cout << A << " " << B-1 << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    vi check(n);
    rep(i, n) {
        while(i < n and s[i] == 'x') i++;
        if(i != n) {
            check[i]++;
        }
        i += c;
    }
    rep(i, n-1) {
        check[i+1] += check[i];
    }
    if(check[n-1] > k) return 0;
    vi ans;
    for(int i = n-1; i >= 0; i--) {
        while(i >= 0 and s[i] == 'x') i--;
        if(i != -1) {
            if(!i or check[i-1] != check[i]) {
                ans.emplace_back(i+1);
            }
        }
        i -= c;
    }
    reverse(all(ans));
    rep(i, ans.size()) {
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 5156
#include <stdio.h>
#include <set>
using namespace std;
int main(){
    int n,m,now,ans;
    set<int> s;
    unsigned int temp;
    while(true){
        scanf("%d%d",&n,&m);
        if(n==0&&m==0)return 0;
        s.clear();
        s.insert(m);
        now=ans=0;
        for(int i=0;i<n;i++){
            scanf("%u",&temp);
            now=(now+static_cast<int>(temp%m))%m;
            ans=max(ans,(m+now-*s.upper_bound(now))%m);
            s.insert(now);
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 4028
//TYPE
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>

using namespace std;
typedef long long ll;
#define cls(x) memset(x,0,sizeof(x))


const int INF = 0x3f3f3f3f;
const int SZ = 100;


char table[SZ][SZ];

int h, w;

bool is_valid(int x, int y, char chr) {
  return x >= 0 && x < h && y >= 0 && y < w && table[x][y] == chr;
}

void dfs(int x, int y, char chr) {
  if(!is_valid(x,y,chr)) return;
  table[x][y] = '.';
  dfs(x+1,y,chr);
  dfs(x-1,y,chr);
  dfs(x,y+1,chr);
  dfs(x,y-1,chr);
}

int main() {
  while(1) {
    cin >> h >> w;
    if(h == 0 && w == 0) break;
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        cin >> table[i][j];
      }
    }
    int ret = 0;
    for(int i = 0; i < h; ++i) {
      for(int j = 0; j < w; ++j) {
        if(table[i][j] != '.') {
          dfs(i, j, table[i][j]);
          ret++;
        }
      }
    }
    cout << ret << endl;
  }
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll base = 1e6;
int D;
int C[30];
int S[400][30];

ll score(vector<int>& t)
{
  vector<int> last(30, 0);
  ll s = 0LL;
  REP(i,D){
    s += S[i][t[i]];
    last[t[i]] = (i+1);
    REP(j,26){
      s -= C[j] * (i+1-last[j]);
    } 
  }
  return s;
}

vector<int> init(int sub)
{
  vector<int> t(D);
  REP(i,D) t[i] = (i+sub)%26;
  return t;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  auto T = init(0);
  ll max_score = 0LL;
  REP(sub,26){
    auto tmp = init(sub);
    ll sc = score(tmp);
    if(max_score<sc){
      max_score = sc;
      T = tmp;
    }
  }
  
  int ti = clock();
  while(clock() - ti < 190 * CLOCKS_PER_SEC / 100){ 
    int d = rand365(mt);
    int q = rand26(mt);
    int old = T[d];
    T[d] = q;
    ll tmp = score(T);
    if(max_score<tmp){
      max_score = tmp;
    }else{
      T[d] = old;
    }
  }
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3720
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int y,m,d;
	while (cin >> y >> m >> d) {
		if (y < 1868 || (y == 1868 && m < 9 ) || (y == 1868 && m == 9 && d <= 7)) {
			cout << "pre-meiji" << endl;
		} else if ((y == 1868 && m == 9 && d > 7) || (y == 1868 && m > 9) || (y >= 1869 && y < 1912) || (y == 1912 && m < 7) || (y == 1912 && m == 7 && d <= 29)){
			cout << "meiji " << y - 1867 << " " << m << " " << d << endl;
		} else if ((y == 1912 && m == 7 && d > 29) || (y == 1912 && m > 7) || (y >= 1913 && y < 1926) || (y == 1926 && m < 12) || (y == 1926 && m == 12 && d <= 24)) {
			cout << "taisho " << y - 1911 << " " << m << " " << d << endl;
		} else if ((y == 1926 && m == 12 && d > 24) || (y >= 1927 && y < 1989) || (y == 1989 && m == 1 && d <= 7)) {
			cout << "showa " << y - 1925 << " " << m << " " << d << endl;
		} else {
			cout << "heisei " << y - 1988 << " " << m << " " << d << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

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

	if ((a * b) % 2 == 0)
	{
		cout << "Even" << endl;
	}
	else
	{
		cout << "Odd" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n, m, c = gets.chomp.split(" ").map(&:to_i)
bs = gets.chomp.split(" ").map(&:to_i)

passed = 0
n.times do
    as = gets.chomp.split(" ").map(&:to_i)
    total = 0
    as.each_with_index do |a, i|
        total += a * bs[i]
    end
    val = total + c
    if val > 0
        passed += 1
    end
end

print passed

Measured memory_bytes: 14340
#include<iostream>
#include<algorithm>
using namespace std;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int MAP[91][91];
int MAX;
int h,w;
void func(int y,int x,int cnt);
int main(void){
	int i,j;
	while(1){
		MAX=-1;
		cin>>w>>h;
		if(w==0&&h==0) break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				cin>>MAP[i][j];
			}
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(MAP[i][j]==1){
					func(i,j,0);
				}
			}
		}
		cout<<MAX<<endl;
	}
	return 0;
}
void func(int y,int x,int cnt){
	int i;
	int xx,yy;
	MAX=max(MAX,cnt);
	for(i=0;i<4;i++){
		yy=y+dy[i];
		xx=x+dx[i];
		if(xx>=0&&yy>=0&&yy<h&&xx<w&&MAP[yy][xx]==1){
			MAP[yy][xx]=0;
			func(yy,xx,cnt+1);
			MAP[yy][xx]=1;
		}
	}
}



Measured memory_bytes: 3048
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque 
def main():
    N = int(readline())
    to = [[] for _ in range(N)]
    wight = [[] for i in range(N)]
    for _ in range(N-1):
        u, v, w = map(int, readline().split())
        u-=1
        v-=1
        to[u].append(v)
        to[v].append(u)
        wight[u].append(w)
        wight[v].append(w)

    dq = deque()
    dq.append(0)
    dist = [-1 for _ in range(N)]
    dist[0] = 0
    while len(dq)>0:
        v = dq.popleft()
        for i in range(len(to[v])):
            nx = to[v][i] 
            cost = wight[v][i]
            if dist[nx] != -1:
                continue
            dist[nx] = (dist[v]+cost)%2
            dq.append(nx)

    for i in dist:
        print(i)
if __name__ == '__main__':
    main()


Measured memory_bytes: 38316
#include <iostream>
using namespace std;
int a[2000001],b[2000001],c[10001];
int n,m;

void CountingSort(int k){
	for(int i=0;i<=k;i++){
		c[i]=0;
	}
	for(int i=0;i<n;i++){
		c[a[i]]++;
	}

	for(int i=1;i<=k;i++){
		c[i]=c[i]+c[i-1];
	}
	for(int i=n-1;i>=0;i--){
		b[c[a[i]]]=a[i];
		c[a[i]]--;
	}
}

int main(){
	cin >>n;
	for(int i=0;i<n;i++){
		cin >>a[i];
		if(m<a[i])m=a[i];
	}
	CountingSort(m);

	for(int i=1;i<n;i++){
		cout << b[i]<<" ";
	}
	cout <<b[n]<<endl;

	return 0;
}

Measured memory_bytes: 18720
import collections
n = int(input())
wl = []
for i in range(n):
  wl.append(input())
  
s = collections.Counter(wl)
m = max(s.values())
ans = []
for k,v in s.items():
  if (v == m):
    ans.append(k)
for w in sorted(ans):
  print(w,sep=' ')


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

void solveA(){
  int n,a,b;
  cin >> n >> a >> b;

  cout << min(a,b) << " " << max(0,a+b-n) << endl;
}
void solveB(){
  int n;
  string a,b,c;
  cin >> n >> a >> b >> c;

  int ans = 0;
  for(int i=0;i<n;i++){
    set<int> st;
    st.insert(a[i]);
    st.insert(b[i]);
    st.insert(c[i]);
    ans += st.size()-1;
  }
  cout << ans << endl;  
}

void solveC(){
}
void solveD(){
}

int main(){
  solveB();
}


Measured memory_bytes: 256
/*
 * Lesson3B１つの整数 x を読み込み、それをそのまま出力するプログラム
 * x が 0 のとき入力の終わりを示し、このデータセットに対する出力を行ってはいけない
 * @author 前島佑介
 * @version 2014/12/2
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

// 1-B １つの整数 x を読み込んで、x の３乗を計算し結果を出力するプログラム
class Main {

	// プログラムのエントリポイント
	public static void main(String[] args) {

		try{
			//キーボードからの入力準備
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

			//入力値を格納する場所を初期化
			String strLine = "";

			//入力値をint型に置き換える場所を0以外で初期化
			int intNum = 1;

			//入力値をint型で保存する場所
			ArrayList<String> strArray = new ArrayList<String>();

			//入力値の取得にループさせる
			for(int i = 0; true; i++) {

				//1行読み込む
				strLine = insBR.readLine();

				//入力値を保存
				strArray.add(strLine);

				//読み込んだ文字列をint型へキャスト
				intNum  = Integer.parseInt(strLine);

				//入力値が0だったら
				if(intNum == 0) {

					//ループから抜ける
					break;
				}
			}

			//出力用にループさせる
			for(int i = 0; i < strArray.size() - 1; i++) {

				//出力
				System.out.println("Case " + (i+1) + ": " + strArray.get(i));
			}

		//例外処理
		}catch(IOException e) {

			//例外時の出力
			System.out.println(e);
		}catch(NumberFormatException e) {


			//数値以外の入力値で出力
			System.out.println("数値で入力して下さい");
		}
	}
}

Measured memory_bytes: 27452
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

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

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int k,x;cin>>k>>x;
	if(500*k>=x)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
const int maxn=2e3+10;
int main()
{
    ll x,k,d,flag=1;
    cin>>x>>k>>d;
    if(x<0)x=-x;
    ll ans=0;
    if(x/d>k)ans=x-k*d;
    else
    {
        k-=x/d;
        x=x%d;
        if(k%2==0)ans=x;
        else ans=x-d;
    }
    if(ans<0)ans=-ans;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,l,n) for(ll i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)



int main() {
	fast;
	ll n;
	cin>>n;
	cout<<3*n*n;
}


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

int main ()
{
    int a,b,i,x=0;
    scanf("%d%d",&a,&b);
    char s[a+b+5];
    scanf("%s",s);
    for(i=0;i<(a+b+1);i++){
        if(i==a){
            if(s[i]!='-'){
                printf("No");
                return 0;
            }
        }
        else{
            if(s[i]>='0'&&s[i]<='9'){
                    x++;
            }
        }
    }
    if(x==(a+b)) printf("Yes");
    else printf("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
map<char,int>m;
for(int i=0;i<s.size();i++){
    m[s[i]]++;
}
for(int i=0;i<s.size();i++){
    if(m[s[i]]%2!=0){
        cout<<"No";
        return 0;
    }
}
cout<<"Yes";
return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X,A,B = MI()
    C=B-A
    if C<=0:
        print("delicious")
    elif C<=X:
        print("safe")
    else:
        print("dangerous")
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
use std::io::*;
use std::str::FromStr;
use std::cmp::min;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: u64 = read();
    let a: u64 = read();
    let b: u64 = read();
    println!("{}", min(n * a, b));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int flag=1,turn =1;
    while(a>0 && c>0){
        if(turn&1){
            c-= b;
            if(c<=0){
                flag= 1;
                break;
            }
        }
        else{
            a-= d;
            if(a<=0){
                flag=0;
                break;
            }
        }
        turn++;
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
}

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;
    cin >> s;
    
    ll n = s.size();
    ll cnt_W = 0;
    ll ans = 0;
    
    for(ll i = 0 ; i < n; i++){
        if(s[i]=='W'){
            cnt_W++;
            ans+=i;
        }
    }
    
    for(ll i = 0; i < cnt_W; i++){
        ans -= i;
    }
    
    cout << ans << endl;
}


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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;
const int N = 1e6 + 5;

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

    string str;
    cin>>str;

    int count = 0;
    int maxval = 0;

    for(int i=0; i<str.size();i++)
    {
        if(str[i] == 'R')
            count++;
        else
            count = 0;
        maxval = max(maxval,count);
    }

    cout<<maxval<<endl;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(Args...)
#endif
using ll = long long;
using namespace __gnu_pbds;
using namespace std;
template<class T>
using indexed_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

char grid[69][69];

void shit() {
	int h, w; cin >> h >> w;
    // char grid[h][w];
    for(int i = 1; i <= h; ++i) for(int j = 1; j <= w; ++j) cin >> grid[i][j];
    int cnt = 0;
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) {
            if (grid[i][j] == '#' && grid[i][j - 1] != '#' && grid[i - 1][j] != '#' && grid[i][j + 1] != '#' && grid[i + 1][j] != '#') ++cnt;
        }
    }
    cout << (!cnt ? "Yes\n" : "No\n");
}

int32_t main() {
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		shit();
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    string s;

    cin >> s;

    if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
n = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
list_c = list(map(int, input().split()))

before = n
result = 0
for i in range(n):
    result += list_b[list_a[i] - 1]
    if before + 1 == list_a[i] - 1:
        result += list_c[before]
    before = list_a[i] - 1
print(result)

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

#define ll long long
#define eb emplace_back
#define nl '\n'
#define deb(x) cerr << #x" = " << x << nl
#define in() ( { int a ; scanf("%d", &a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;


int32_t main()
{
    ll n, m; cin >> n >> m; cout << ((n == 1 || m == 1) ? 1 : (n * m + 1) / 2) << nl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;


int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i=0; i<N; i++) {
        cin >> S[i];
    }
    std::sort(S.begin(), S.end());
    
    vector<pair<string, int>> ans;
    
    int num = 0;
    int max_num = 0;
    string current;
    for (int i=0; i<N; i++) {
        string s = S[i];
        if (current!=s) {
            ans.push_back(std::make_pair(current, num));
            if (num>max_num) {
                max_num = num;
            }
            num = 0;
        }
        num ++;
        current = s;
        if (i==N-1) {
            ans.push_back(std::make_pair(current, num));
            if (num>max_num) {
                max_num = num;
            }
        }
    }
    
    
    int ans_size = ans.size();
    for (int i=0; i<ans_size; i++) {
        if (ans[i].second == max_num) {
            cout << ans[i].first << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 18804
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n, q;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> q;
  set<P> vp;
  vector<tuple<int, int, int>> ve;

  REP(i, n) {
    int l, r, x;
    cin >> l >> r >> x;
    l -= x; r -= x;
    ve.push_back(tie(x, l, r));
  }

  sort(ve.begin(), ve.end());

  REP(i, q) {
    int d;
    cin >> d;
    vp.insert(P(d, i));
  }

  vector<int> ans(q, -1);
  REP(i, n) {
    int x, l, r;
    tie(x, l, r) = ve[i];

    auto it = vp.lower_bound(P(l, -1));
    while(it != vp.end()) {
      if(it->first >= r) break;
      ans[it->second] = x;
      vp.erase(it++);
    }
  }

  REP(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 15676
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  vector<char> zero(0,0), one(0,0);
  for(int i=0; i<S.size(); i++){
    if(i%2==0){
      zero.push_back('0');
      one.push_back('1');  
    }
    else{
      zero.push_back('1');
      one.push_back('0');  
    }    
  }
  int ans=0, temp=0;
  for(int i=0; i<S.size(); i++){
    if(S[i]!=zero[i]) ans++;
    if(S[i]!=one[i]) temp++;
  }
  ans=min(ans, temp);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int d[11][10];

int main(void){
	int k=nextpint();
	for(int i=0; i<=9; i++){
		d[0][i]=1;
	}
	for(int j=1; j<11; j++){
		d[j][0]=d[j-1][0]+d[j-1][1];
		for(int i=1; i<=8; i++){
			d[j][i]=d[j-1][i-1]+d[j-1][i]+d[j-1][i+1];
		}
		d[j][9]=d[j-1][8]+d[j-1][9];
	}
	int n=0;
	int f=0;
	int j, i;
	for(j=0; j<11; j++){
		for(i=1; i<=9; i++){
			n+=d[j][i];
			if(n>=k){
				n-=d[j][i];
				f=1;
				break;
			}
		}
		if(f) break;
	}
	putchar(i+'0');
	for(j--; j>=0; j--){
		k=k-n;
		n=0;
		if(i!=0){
			n+=d[j][i-1];
			if(n>=k){
				n-=d[j][i-1];
				i=i-1;
				putchar(i+'0');
				continue;
			}
		}
			n+=d[j][i];
			if(n>=k){
				n-=d[j][i];
				putchar(i+'0');
			}else{
				i++;
				putchar(i+'0');
			}
	}
	putchar(10);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MAXN=210;
int n,flag,ans,vis[MAXN],col[MAXN],s[MAXN][MAXN];
char c[MAXN];
void dfs (int x,int u) {
	col[x]=u;
	for (int i=1;i<=n;i++) {
		if (s[x][i]) {
			if (col[i]==col[x]) {flag=0;}
			else if (!col[i]) {dfs(i,u==1?2:1);}
		}
	}
	return;
}
int bfs (int x) {
	memset(vis,0,sizeof(vis));
	queue <int> q;
	q.push(x);
	int res=0;
	vis[x]=1;
	while (!q.empty()) {
		int a=q.front();
		q.pop();
		res=max(res,vis[a]);
		for (int i=1;i<=n;i++) {
			if (vis[i]) {continue;}
			if (s[a][i]) {vis[i]=vis[a]+1;q.push(i);}
		}
	}
	return res;
}
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%s",c+1);
		for (int j=1;j<=n;j++) {
			s[i][j]=c[j]-'0';
		}
	}
	flag=1;
	dfs(1,1);
	if (!flag) {printf("-1");return 0;}
	for (int i=1;i<=n;i++) {ans=max(ans,bfs(i));}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
import sys


def main():
    n = int(sys.stdin.readline())

    if n < 105:
        print(0)
        exit()

    dp = [0] * 201
    ans = 0

    for i in range(1, n + 1):
        for j in range(105, n + 1):
            if j % i == 0:
                dp[j] += 1

    for i in range(105, n + 1, 2):
        if dp[i] >= 8:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

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

Measured memory_bytes: 256
x, k, d = map(int, input().split())
if abs(x)>k*d:
  print(abs(x)-k*d)
  quit()

onaji = abs(x)//d
nokori = k-onaji
if nokori%2==0:
  print(abs(x)-d*onaji)
else:
  print(abs(abs(x)-d*(onaji+1)))


Measured memory_bytes: 61724
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

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

void solve_A(){
    string n;
    cin >> n;

    int m = n.size();
    if(n[m-1] == '3'){
        cout << "bon";
    } else if(n[m-1] == '0' || n[m-1] == '1' || n[m-1] == '6' || n[m-1] == '8'){
        cout << "pon";
    } else cout << "hon";

}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 3592
import java.util.HashMap;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();

    long lim = (long) Math.sqrt(n);
    long res = 0;
    HashMap<Long, Integer> map = new HashMap<Long, Integer>();

    if (isPrime(n)) {
      System.out.println(1);
      return;
    }

    long devideNum = 2;

    while ((n != 1) && (devideNum <= lim)) {
      if (isPrime(devideNum)) {
        while (n % devideNum == 0) {
          if (map.containsKey(devideNum)) {
            map.put(devideNum, (map.get(devideNum)) + 1);
          } else {
            map.put(devideNum, 1);
          }
          n /= devideNum;
        }
      }
      devideNum++;
    }

    if (n != 1) {
      map.put(n, 1);
    }

    for (long key : map.keySet()) {
      int tmp = map.get(key);
      int i = 1;
      while (true) {
        if (tmp - i >= 0) {
          tmp -= i;
          i++;
          res++;
        } else {
          break;
        }
      }
    }
    System.out.println(res);

  }

  static boolean isPrime(long n) {

    if (n == 2) {
      return true;
    } else if ((n < 2) || (n % 2 == 0)) {
      return false;
    } else {
      long lim = (long) Math.sqrt(n);
      for (int i = 3; i <= lim; i += 2) {
        if (n % i == 0) {
          return false;
        }
      }
      return true;
    }

  }
}

Measured memory_bytes: 36376
import java.util.*;
            import java.lang.*;
            import java.io.*; 
             
             
           public class Main {
                public static void main(String[] args){
                  Scanner sc  = new Scanner(System.in);
                   int a= sc.nextInt();
                   String s = sc.next();
                   if(a>=3200)
                     System.out.println(s);
                   else
                     System.out.println("red");
                }
              }

Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
int  main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a == b && b == c)
	{
		printf("1");
	} 
	else
	if (a != b && a != c && b != c)
	{
		printf("3");
	}
	else printf("2");
	system("pause");
}

Measured memory_bytes: 504
import java.util.*
import java.math.*

fun main(args: Array<String>) {
    var (N,K,B) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val S = readLine()!!
//    val D = readLine()!!.split(" ").map { it.toLong() }
    var ans = "Yes"
    println(Math.min(N*K,B))
}


Measured memory_bytes: 37880
n = map(int, input().split())
list_num = list(n)
list_num.sort()
list_str = []
for i in list_num:
    i = str(i)
    list_str.append(i)

max_str = list_str[-1] + list_str[1]
max_int = int(max_str)
print(max_int + int(list_str[0]))


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

class Dice{
	int top, n, s, e, w;
public:
	Dice();
	void roll(char dir);
	void turn(char dir);
	int getNum(char dir);
};

Dice::Dice(){
	top = 1;
	n = 5;
	s = 2;
	e = 3;
	w = 4;
}

void Dice::roll(char dir){
	switch (dir){
	case 'N':
		n = top;
		top = s;
		s = 7 - n;
		break;
	case 'S':
		s = top;
		top = n;
		n = 7 - s;
		break;
	case 'E':
		e = top;
		top = w;
		w = 7 - e;
		break;
	case 'W':
		w = top;
		top = e;
		e = 7 - w;
		break;
	}
}

void Dice::turn(char dir){
	switch (dir){
	case 'R':
		n = w;
		w = s;
		s = e;
		e = 7 - w;
		break;
	case 'L':
		n = e;
		e = s;
		s = w;
		w = 7 - e;
		break;
	}
}

int Dice::getNum(char dir){
	switch (dir){
	case 'T':return top;
	case 'N':return n;
	case 'E':return e;
	case 'W':return w;
	case 'S':return s;
	case 'B':return 7 - top;
	default: return -1;
	}
}

int main(void){
	int **d, n, c;
	Dice *dice;
	bool answer = true;

	cin >> n;

	d = new int*[n];
	dice = new Dice[n];

	for (int i = 0; i < n; i++){
		d[i] = new int[6];
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < 6; j++){
			cin >> d[i][j];
		}
	}

	for (int i = 0; i < n - 1; i++){
		c = 0;
		while (d[0][dice[0].getNum('T') - 1] != d[i+1][dice[i+1].getNum('T') - 1]){
			if (c < 4)	dice[i+1].roll('S');
			else dice[i+1].roll('E');
			c++;
			if (c == 8)	break;
		}
		c = 0;
		while (d[0][dice[0].getNum('S') - 1] != d[i+1][dice[i+1].getNum('S') - 1]){
			dice[i+1].turn('R');
			c++;
			if (c == 5)	break;
		}
	}

	
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			if (d[i][dice[i].getNum('T') - 1] == d[j][dice[j].getNum('T') - 1] &&
				d[i][dice[i].getNum('E') - 1] == d[j][dice[j].getNum('E') - 1] &&
				d[i][dice[i].getNum('N') - 1] == d[j][dice[j].getNum('N') - 1] &&
				d[i][dice[i].getNum('W') - 1] == d[j][dice[j].getNum('W') - 1] &&
				d[i][dice[i].getNum('S') - 1] == d[j][dice[j].getNum('S') - 1] &&
				d[i][dice[i].getNum('B') - 1] == d[j][dice[j].getNum('B') - 1] ){

				i = j = n;
				answer = false;
			}
		}		
	}

	if (answer){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 1156
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

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

    if (x<30) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3592
from itertools import product


def dist(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])


N, *xy = map(int, open(0).read().split())
points = [(x, y) for x, y in zip(*[iter(xy)] * 2)]
values = [-float("inf") for _ in range(4)]
outrims = [points[0], points[0], points[0], points[0]]
for x, y in points:
    for i, (opx, opy) in enumerate(product([1, -1], repeat=2)):
        v = opx * x + opy * y
        if v > values[i]:
            values[i] = v
            outrims[i] = (x, y)

ans = 0
for p in points:
    for o in outrims:
        ans = max(ans, dist(p, o))
print(ans)


Measured memory_bytes: 55012
s = input("")
t = input("")
k = 0

if len(s) == len(t):
    s += "?"

for i in range(len(s)-len(t)):
    cnt = 0
    for j in range(len(t)):
        if t[j] == s[i+j]:
            cnt += 1
    k = max(k, cnt)

print(len(t)-k)

Measured memory_bytes: 9120
#include <iostream>
using namespace	std;
int h,w,c[50][50];
void dfs(int y,int x){
  c[y][x]=0;
  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++)
      if(0<=y+i&&y+i<h&&0<=x+j&&x+j<w)
        if(c[y+i][x+j]) dfs(y+i,x+j);
}

int main(){

  for(;cin>>w>>h,w;){
    int r=0;
    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++) for(int j=0;j<w;j++){
        if(c[i][j]){
          r++;
          dfs(i,j);
        }
      }
    cout<<r<<endl;
  }
  return 0;

}

Measured memory_bytes: 3160
#include<iostream>
#include<string>
#include<map>
#include<string.h>
#include<vector>
#include<set>
#include<stdio.h>
#include<math.h>
//#include<algothm>
#include<queue>
typedef long long ll;
typedef long double ld;
using namespace std;
int p,q,ans;
int dp[110];
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	int a[109];
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		dp[a[i]]=1;
	}
	for(int i=0;i<x;i++)
	{
		p+=dp[i];
	}
	for(int i=x+1;i<=n;i++)
	{
		q+=dp[i];
	}
	ans=min(p,q);
	cout<<ans<<endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"sync"
)

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	s := ScanWord()

	P(strings.Repeat("x", len(s)))
	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int64) []int64 {
	length := int(n)
	arr := make([]int64, n)
	for i := 0; i < length; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func Mx(args ...int64) int64 {
	maxVal := MN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Mn(args ...int64) int64 {
	minVal := MX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;
vector <pair<int, int> > dist_pairs[2001];
int main(){
  int N;
  int X;
  int Y;
  cin >> N >> X >> Y;
  X --;
  Y --;


  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      int dist = j - i;
      dist = min(dist, abs(X - i) + 1 + abs(Y - j));
      dist_pairs[dist].push_back(make_pair(i, j));
    }
  }
  for(int k = 1; k < N; k++){
    cout << dist_pairs[k].size() << endl;
    /*
    int ans = 0;
    for(int i = 0; i < N; i++){
      if(i < X){

      }
      set <int> points;
      points.insert(i + k);
      if(i <= X && i + k > X){
        points.insert(Y + k - (X - i));
        points.insert(Y - (k - (X - i)));
      }
      if(i - k <= X && X < i){
        points.insert(Y + k - (i - X));
        points.insert(Y - (k - (i - X)));
      }
      for(auto it = points.begin(); it != points.end(); it++){
        if(*it > i && *it < N){
          ans ++;
          cout << i << " " << *it << endl;
        }
      }
    }
    cout << ans << endl;
    */
  }
  return 0;
}


Measured memory_bytes: 23808
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
h = list(li())
h.append(0)

# 非ゼロの左端を選んでいるか
haveleft = False
ans = 0

while any([hk > 0 for hk in h]):
    for k in range(len(h)):
        if not haveleft:
            if h[k] == 0:
                continue
            else:
                haveleft = True
                h[k] -= 1
                
        else:
            if h[k] == 0:
                ans += 1
                haveleft = False
            else:
                h[k] -= 1
            
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		String s = in.next();
		String t = in.next();
		int gcd = gcd(n,m);
		int n1 = n/gcd;
		int m1 = m/gcd;
		int nIdx = 0;
		int mIdx = 0;
		boolean flag = true;
		while(nIdx<n) {
			if(s.charAt(nIdx)!=t.charAt(mIdx)) {
				flag = false;
				break;
			}else {
				nIdx += n1;
				mIdx += m1;
			}
		}
		if(flag) {
			System.out.println((long)n*(long)m/gcd);
		}else {
			System.out.println(-1);
		}
	}
	
	public static int gcd(int a,int b) {
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}

}


Measured memory_bytes: 27600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define _USE_MATH_DEFINES
#include <cmath>

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

using namespace std;
typedef long long ll;

const int MAXN = 2e5 + 10;

int main() {
   int n;
   ll  ans = 0, x = 0, y = 0;
   int a[MAXN];

   cin >> n;
   rep1(i, n) scanf("%d", &a[i]);
   for (int i = 1, j = 1; i <= n; i++) {
      x ^= a[i];
      y += a[i];
      while (x != y) {
         x ^= a[j];
         y -= a[j];
         j++;
      }
      ans += i - j + 1;
   }
   cout << ans << endl;
   return(0);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n;
    cin >> n;
    map<int,int> mp;
    vector<int> a(n-1);
    for (int i = 0; i < n-1; ++i) {
        cin >> a[i];
        mp[a[i]-1]++;
    }
    for (int i = 0; i < n; ++i) {
        cout << mp[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 13520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int r; cin >> r;
  double c = 2 * acos(-1) * r;
  cout << setprecision(10) << fixed << c << endl;

  return 0;
}


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

using namespace std;

const int N = 1e6 + 6;

char s[N], t[N];
int f[N], rig[N];
int n;

int calc(int maxi) {
  int add = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] != '?') continue;
    if (rig[i+1] + (add + 1) * 2 <= maxi) {
      ++add;
      s[i] = '1';
    }
    else {
      s[i] = '0';
    }
  }
  int now = 0, low = 0, hig = 0;
  // printf("%s\n", s);
  for (int i = 0; i < n; ++i) {
    now += (s[i] == '1' ? 1 : -1);
    low = min(low, now);
    hig = max(hig, now);
  }
  return abs(hig - low);
}

int main() {
  scanf("%s", s);
  n = strlen(s);
  f[0] = 0;
  int maxi = 0;
  for (int i = 0; i < n; ++i) {
    f[i+1] = f[i] + (s[i] == '1') * 2 - 1;
    maxi = max(maxi, f[i+1]);
  }
  rig[n] = f[n];
  for (int i = n-1; i >= 0; --i) {
    rig[i] = max(rig[i+1], f[i]);
  }
  for (int i = 0; i < n; ++i)
    t[i] = s[i];
  int ans = calc(maxi);
  for (int i = 0; i < n; ++i)
    s[i] = t[i];
  ans = min(ans, calc(maxi+1));
  for (int i = 0; i < n; ++i)
    s[i] = t[i];
  ans = min(ans, calc(maxi+2));
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 13592
N = int(input())
S = input()

pls = S.count("R") * S.count("G") * S.count("B")
minus_count = 0
for i in range(len(S)):
    for j in range(i + 1, len(S)):
        if S[i] == S[j]:
            continue
        dis = j - i
        k = j + dis
        if k > len(S) - 1:
            break
        if S[i] == S[k]:
            continue
        elif S[j] == S[k]:
            continue
        minus_count += 1
print(pls - minus_count)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll pow_kai(int a, int n)
{ //aのn乗を計算します。
	ll x = 1;
	while (n > 0)
	{ //全てのbitが捨てられるまで。
		if (n & 1)
		{ //1番右のbitが1のとき。
			x = (x * a) % MOD;
		}
		a = (a * a) % MOD;
		n >>= 1; //bit全体を右に1つシフトして一番右を捨てる。
	}
	return x % MOD;
}

int main()
{
	int d;
	ll g;
	cin >> d >> g;
	vector<int> p(d), c(d);
	rep(i,d){
		cin >> p[i] >> c[i];
	}
	int ans = INF;
	for (int i = 0; i < (1 << d); i++)
	{
		ll point = 0;
		int count = 0;
		int r = 0;
		for (int k = 0; k < d; k++)
		{
			if(i & (1<<k)){
				point += c[k] + 100 * (k + 1) * p[k];
				count += p[k];
			}else{
				r = k;
			}
		}
		if(point < g){
			int a = ceil(1.0*(g - point) / (100 * (r + 1)));

			count += a <= p[r] ? a : INF;
		}
		ans = min(ans, count);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256