akhauriyash/Code-Regression huggingface dataset:
using System;

namespace C
{
    class Cont
    {
        public void LCSLength(char[] A, char[] B)
        {
            int m = A.Length, n = B.Length, i, j;
            char[] X = new char[m + 1];
            char[] Y = new char[n + 1];
            for (i = 1; i < X.Length; i++)
            {
                X[i] = A[i - 1];
            }
            for (i = 1; i < Y.Length; i++)
            {
                Y[i] = B[i - 1];
            }
            int[,] c = new int[m+1, n+1];
            for (i = 1; i <= m; i++)
            {
                c[i, 0] = 0;
            }
            for (j = 0; j <= n; j++)
            {
                c[0, j] = 0;
            }
            for (i = 1; i <= m; i++)
            {
                for (j = 1; j <= n; j++)
                {
                    if (X[i] == Y[j])
                    {
                        c[i, j] = c[i - 1, j - 1] + 1;
                    }
                    else if (c[i - 1, j] >= c[i, j - 1]){
                        c[i, j] = c[i - 1, j];
                    }
                    else
                    {
                        c[i, j] = c[i, j - 1];
                    }
                }
            }
            Console.WriteLine(c[m, n]);
        }
    }

    class C
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int q=int.Parse(input), i;
            Cont cont = new Cont();
            for (i = 0; i < q; i++)
            {
                char[] X = Console.ReadLine().ToCharArray();
                char[] Y = Console.ReadLine().ToCharArray();
                cont.LCSLength(X, Y);
            }
        }
    }
}



Measured memory_bytes: 34996
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>
#include <iomanip>

using namespace std;
vector<vector<int> > to, cost;

void dfs(vector<int>& v, int num, int c, int from) {
	v[num] = c;
	for (size_t i = 0; i < to[num].size(); i++)
	{
		if(to[num][i] == from) continue;
		dfs(v, to[num][i], c + cost[num][i], num);
	}
}

int main() {
	int n;
	cin >> n;
	vector<vector<int> > to_l(n+1), cost_l(n+1);
	for (size_t i = 0; i < n-1; i++)
	{
		int a, b, w;
		cin >> a >> b >> w;
		to_l[a].push_back(b);
		cost_l[a].push_back(w);
		to_l[b].push_back(a);
		cost_l[b].push_back(w);
	}
	to = vector<vector<int> >(to_l);
	cost = vector<vector<int> >(cost_l);
	vector<int> v(n+1, 0);
	dfs(v, 1, 0, 1);
	for (size_t i = 1; i < n+1; i++)
	{
		if(v[i] % 2 == 0) cout << 1 << endl;
		else cout << 0 << endl;
	}

}


Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

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

//-------------------ここから回答する-----------------------

void solve(void)
{
    string o, e;
    cin >> o >> e;
    string ans = "";
    rep(i, o.length())
    {
        ans += o[i];
        if (i < e.length())
            ans += e[i];
    }
    cout << ans << endl;
}
int main(void)
{
    solve();
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;
template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}
template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};

/* ここからコード開始 */


int main(){
  kyopro;
  ll N;
  cin >> N;
  vector<vector<vector<vector<ll>>>> DP(N+1, vector<vector<vector<ll>>>(5, vector<vector<ll>>(5, vector<ll>(5))));
  DP[0][0][0][0] = 1;
  rep(i, 0, N){
    rep(b3, 0, 5){
      rep(b2, 0, 5){
        rep(b1, 0, 5){
          rep(now, 1, 5){
            if(b3 == 1 && b2 == 3 && now == 2) continue;
            if(b3 == 1 && b1 == 3 && now == 2) continue;
            if(b2 == 1 && b1 == 3 && now == 2) continue;
            if(b2 == 1 && b1 == 2 && now == 3) continue;
            if(b2 == 3 && b1 == 1 && now == 2) continue;
            DP[i+1][b2][b1][now] += DP[i][b3][b2][b1] % MOD;
          }
        }
      }
    }
  }
  ll sum{};
  rep(b3, 1, 5){
    rep(b2, 1, 5){
      rep(b1, 1, 5){
        sum += DP[N][b3][b2][b1] % MOD;
      }
    }
  }
  cout << sum % MOD << rt;
}

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

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 T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;



int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if((a<c && c<b) || (b<c && c<a)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100];
	int k,l,i;
	scanf("%d",&k);
	scanf("%s",s);
	l=strlen(s);
	if(k<l)
	{for(i=0;i<k;i++)
	printf("%c",s[i]);
	printf("...");
	}
	else printf("%s",s);
	return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll k;
  cin >> k;
  
  cout << 50 << "\n";
  
  vector<ll> x(50);
  for(int i = 0; i < 50; i++) x.at(i) += i + (k / 50);
  
  k %= 50;
  for(int i = 0; i < k; i++){
    for(int j = 0; j < 50; j++){
      if(i == j) x.at(j) += 50;
      else x.at(j)--;
    }
  }
  
  for(int i = 0; i < 50; i++){
    if(i) cout << " ";
    cout << x.at(i);
  }
  cout << "\n";
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long X;
        X = sc.nextLong();
        long A;
        A = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(X, A);
    }
}

class Solver {
    public void solve(long X, long A) {
        if (X < A) {
            System.out.println(0);
        }
        else {
            System.out.println(10);
        }
    }
}



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

int main(){
  int n,k,ib[100000],n0=-1,mbe=INT_MAX;
  cin>>n>>k;
  for(int i=0; i<n; i++){
    cin>>ib[i];
    if(i>0&&ib[i-1]<=0&&ib[i]>0){
      n0 = i-1;
    }
  }
  if(n0==-1&&ib[n-1]<0)n0=n-1;
  else if(n0==-1)n0=0;
  for(int i=0; i<k+1; i++){
    if(n0-k+i+1<0||n0+i>n-1)continue;
    //cout<<n0+i-(k-1)<<" "<<n0+i<<endl;
    int f=ib[n0+i-(k-1)];
    int e=ib[n0+i];
    if(f<0&&0<e){
      if(abs(f)<abs(e))f=abs(f)*2; else e=abs(e)*2;
      mbe = min(mbe,abs(f)+abs(e));
    }else if(e<0){
      mbe = min(mbe,abs(f));
    }else{
      mbe = min(mbe,abs(e));
    }
  }
  cout<<mbe<<endl;
}



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

int main() {
  int N;
  int l;
  int t;
  int kyaku = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> l >> t;
    kyaku += t - l + 1;
  }
  cout << kyaku << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 2050
#define M 100005
#define ll long long
#define inf 0x3f3f3f3f
int n, m;
int x1[N], y1[N], c1[N];
int x2[N], y2[N], c2[N];
int fir[N], nex[M], tar[M], cap[M], len[M], cnt = 1;
int vis[N], d[N], dx[N];
ll dis[N];
void add(int a, int b, int c, int d)
{
	++cnt;
	tar[cnt] = b;
	cap[cnt] = c;
	len[cnt] = d;
	nex[cnt] = fir[a];
	fir[a] = cnt;
}
void Add(int a, int b, int c, int d)
{
	add(a, b, c, d);
	add(b, a, 0, -d);
}
int aug(int s, int t, int augco)
{
	if (s == t)
		return augco;
	int augc = augco, delta;
	vis[s] = 1;
	for (int i = fir[s]; i; i = nex[i])
	{
		int v = tar[i];
		if (cap[i] && dis[s] == dis[v] + len[i] && !vis[v])
		{
			delta = aug(v, t, min(augc, cap[i]));
			cap[i] -= delta;
			cap[i ^ 1] += delta;
			augc -= delta;
			if (augc == 0)
				return augco;
		}
	}
	return augco - augc;
}
void SPFA(int s)
{
	memset(dis, 0x3f, sizeof(dis));
	dis[s] = 0;
	vis[s] = 1;
	queue<int>q;
	q.push(s);
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		for (int i = fir[x]; i; i = nex[i])
		{
			int v = tar[i];
			if (cap[i ^ 1])
			{
				if (dis[v] > dis[x] + len[i ^ 1])
				{
					dis[v] = dis[x] + len[i ^ 1];
					if (!vis[v])
						vis[v] = 1, q.push(v);
				}
			}
		}
		vis[x] = 0;
	}
}
ll sap(int s, int t, int g)
{
	int flow = 0;
	ll cost = 0;
	SPFA(t);
	while (1)
	{
		int delta = 0;
		memset(vis, 0, sizeof(vis));
		while ((delta = aug(s, t, inf)))
		{
			flow += delta;
			cost += dis[s] * delta;
			memset(vis, 0, sizeof(vis));
		}
		ll c = 1ll << 60;
		for (int x = 1; x <= g; x++)
			if (vis[x])
				for (int i = fir[x]; i; i = nex[i])
					if (cap[i] && !vis[tar[i]])
						c = min(c, dis[tar[i]] + len[i] - dis[x]);
		for (int i = 1; i <= g; i++)
			if (vis[i])
				dis[i] += c;
		if (c == 1ll << 60)
			break;
	}
	return cost;
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d%d", &x1[i], &y1[i], &c1[i]);
		Add(1, i + 6, c1[i], 0);
	}
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d%d", &x2[i], &y2[i], &c2[i]);
		Add(n + i + 6, 2, c2[i], 0);
	}
	for (int i = 1; i <= n; i++)
	{
		Add(i + 6, 3, inf, -x1[i] -y1[i]);
		Add(i + 6, 4, inf, -x1[i] +y1[i]);
		Add(i + 6, 5, inf, +x1[i] -y1[i]);
		Add(i + 6, 6, inf, +x1[i] +y1[i]);
	}
	for (int i = 1; i <= n; i++)
	{
		Add(3, n + i + 6, inf, +x2[i] +y2[i]);
		Add(4, n + i + 6, inf, +x2[i] -y2[i]);
		Add(5, n + i + 6, inf, -x2[i] +y2[i]);
		Add(6, n + i + 6, inf, -x2[i] -y2[i]);
	}
	printf("%lld\n", -sap(1, 2, n * 2 + 6));
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
//#define SIZE 200005
//#define INF 1000000005LL
#define SIZE 1<<16
#define INF 1e18
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int V,E;
ll d[17][17];
ll dp[SIZE][17];

void bitDP_init(){
  fill(d[0],d[17],INF);
}

ll bitDP(){
  fill(dp[0],dp[SIZE],INF);
  dp[0][0] = 0;
  for(int S=0;S<1<<V;S++){
    rep(v,0,V) rep(u,0,V){ //Sを通り次にvに進む
      if(S>>u & 1){
        dp[S][v] = min(dp[S][v],dp[S-(1<<u)][u]+d[u][v]);
      }
    }
  }
  return dp[(1<<V)-1][0];
}

int main(){

  cin >> V >> E;
  bitDP_init();
  rep(i,0,E){
    int s,t;
    ll D;
    cin >> s >> t >> D;
    d[s][t] = D;
  }

  ll ans = bitDP();
  if(ans >= INF) ans = -1;

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 11804
#include<iostream>
using namespace std;
int main()
{
  int x, y;
  cin >> x >> y;
  
  if (y % 2 != 0) {
    cout << "No" << endl;
  }
  else if (y < x*2) {
    cout << "No" << endl;
  }
  else if (x*4 < y) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 3040
S = input().split(" ")
stack=[]

while len(S)>1:
    for s in S:
        if s=="+":
            s1=stack.pop(-1)
            s2=stack.pop(-1)
            stack.append(s1+s2)
        elif s=="-":
            s1=stack.pop(-1)
            s2=stack.pop(-1)
            stack.append(s2-s1)
        elif s=="*":
            s1=stack.pop(-1)
            s2=stack.pop(-1)
            stack.append(s1*s2)
        else:
            stack.append(int(s))
    S=stack
print(S[0])



Measured memory_bytes: 5600
N, K = map(int, input().split())
l = list(map(int, input().split()))
dp = [0]+[float('inf')]*(N-1)
for i in range(N):
    for k in range(1, K+1):
        if i < N-k:
            dp[i+k] = min(dp[i+k], dp[i]+abs(l[i+k]-l[i]))
print(dp[-1])

Measured memory_bytes: 55264
n,m = map(int,raw_input().split(" "))
a = []
for x in range(n):
  q = map(int,raw_input().split(" "))
  a.append(q)

a.sort(key=lambda a:a[0])

ans = 0
now = 0

for x in range(n):
  if now + a[x][1] >= m:
    ans = ans + a[x][0] * (m-now)
    print ans
    exit(0)
  ans += a[x][0] * a[x][1]
  now += a[x][1]


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

typedef long long ll;
typedef pair<int, int> P;

int main() {
    int N, D, A;
    cin >> N >> D >> A;
    vector<P> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i].first >> P[i].second;
    }
    sort(P.begin(), P.end());
    D = 2 * D;
    ll total = 0;
    queue<pair<ll, ll>> que;
    ll res = 0;
    for (int i = 0; i < N; i++) {
        ll x = P[i].first;
        ll h = P[i].second;
        while (!que.empty() && que.front().first < x) {
            total -= que.front().second;
            que.pop();
        }
        h -= total;
        if (h > 0) {
            ll num = (h + A - 1) / A;
            res += num;
            ll damage = num * A;
            total += damage;
            que.push(pair<ll, ll>(x + D, damage));
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
using namespace std;
int main() {
  int a,b;
  string s;
  cin >> a >> b;
  if(a < b) {
    s = "<";
  } else if(a > b) {
    s = ">";
  } else {
    s = "==";
  }
  cout << "a " + s + " b" << "\n";
  return 0;
}


Measured memory_bytes: 3180
/**
*    created: 03.07.2020 17:03:06
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) cout << c << endl;
    else if (b == c) cout << a << endl;
    else cout << b << endl;
    return 0;
}

Measured memory_bytes: 3628
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
N=int(input())
ans=0
for j in range(N):
    if (j+1)%3!=0 and (j+1)%5!=0:
        ans += j+1
print(ans)


Measured memory_bytes: 27028
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
	int N;
	cin >> N;
	int result = 0;

	if (N % 2)
		result = N * 2;
	else
		result = N;
	cout << result << endl;
	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++)

int main(){
    long long int X;
    cin >> X;

    long long int count = 0;
    long long int total = 100;
    
    for(int i=0;;i++) {
        count += 1;
        total = total * 1.01;
        if(total>=X){
            break;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define ll long long 

class Solver
{
private:
	ll n;
	vector<ll> a;
public:
	Solver() {
		cin >> n;
		for (ll i = 0; i < n; ++i)
		{
			ll tmp;
			cin >> tmp;
			a.push_back(tmp);
		}
	}

	void exec() {
		ll count = 0;
		ll eve_cnt = 0;
		ll odd_cnt = 0;
		for (ll i = 0; i < n; ++i)
		{
			if(a[i] % 2 == 0){
				eve_cnt++;
			} else {
				odd_cnt++;
			}
		}
		cout << pow(3, n) - pow(2, eve_cnt) << endl;
	}
	
};

int main() {
	Solver ce = Solver();
	ce.exec();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

ll gcd( ll a, ll b )
{
    while( b )
    {
        a %= b;
        swap(a,b);
    }
    return a;
}

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

int main() 
{
    fastio();

    ll n,m;
    cin>>n>>m;
    vector<ll>a(n), twos(n);
    ll num = 1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        while( a[i] % 2 == 0 )
        {
            twos[i]++;
            a[i] /= 2;
        }
        num = lcm( num, a[i] );
    }

    for(int i=0;i<n;i++)
    {
        if( twos[i] != twos[0] )
        {
            cout<<0,nl;
            return 0;
        }
    }

    for(int i=0;i<twos[0]-1;i++)
        num *= 2;

    ll ans = m/num - m/(2*num);
    cout<<ans,nl;



    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;


// ------------------------

void solve() {
    string S; cin >> S;

    int len = S.size();
    if(len % 2 != 0){
        cout << "No" << "\n";
        return;
    }

    for (int i = 0; i < len; i += 2){
        if( (S[i] != 'h') or (S[i+1] != 'i') ){
            cout << "No" << "\n";
            return;
        }
    }


    cout << "Yes" << "\n";
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main() {
    long long K ;
    cin >> K ;
    
    if( K%2 == 0 || K%5 ==0 ){
        cout << -1 << endl;
    }
    
    int cnt=1 ;
    
    int m=7%K ;
    
    for( int i=0 ; i<K ; i++){
        
            if( m == 0 ){
                cout << cnt << endl;
                break;
            }
        
        cnt ++ ;
        
        m = (m*10 + 7)%K ;
        
    }
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	ll a[100000];
	ll goukei = 0;
	rep(i, N) {
		cin >> a[i];
		goukei ^= a[i];
	}

	int M = 60;
	int r = 0;
	for (int i = M - 1; i >= 0; i--) {
		if (!(goukei >> i & 1)) {
			for (int j = r; j < N; j++) {
				if (a[j] >> i & 1) {
					swap(a[r], a[j]);

					for (int j = r + 1; j < N; j++) {
						if (a[j] >> i & 1) {
							a[j] ^= a[r];
						}
					}
					if (!(a[0] >> i & 1)) {
						a[0] ^= a[r];
					}
					r++;
					break;
				}
			}
		}
	}

	co(a[0] + (a[0] ^ goukei));

	Would you please return 0;
}

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

int main(){
    int n; cin >> n;
    double ans=0;
    vector <double> A(n);
    
    for (int i=0; i<n; i++) {
        cin >> A[i];
        ans+=1.0/A[i];
    }
    
    cout << 1.0/ans << endl;
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
using namespace std;
const int N = 1e3 + 5;
int main(){

	
	string a, b;
	int n,m;
	cin >> a >> b;
	a += b;
	n = stoi(a);
	m = sqrt(n);
	if (n == m*m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;







}

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

namespace aojpro
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            var team = new Dictionary<int, int>();

            for(int i = 1; i <= n; i++)
            {
                team[i] = 0;
            }

            string[] str;
            for (int i = 0; i < n * (n - 1) / 2; i++)
            {
                str = Console.ReadLine().Split(' ');

                int x = int.Parse(str[0]);
                int y = int.Parse(str[1]);
                int a = int.Parse(str[2]);
                int b = int.Parse(str[3]);

                if(a > b)
                {
                    team[x] += 3;
                }
                else if(a == b)
                {
                    team[x] += 1;
                    team[y] += 1;
                }
                else
                {
                    team[y] += 3;
                }


            }            
            
            
            var rank = team.OrderByDescending(x => x.Value);            

            int u = 1;
            int rk = 1;
            int point = -1;
            var ans = new int[n + 1]; 

            foreach(var s in rank)
            {               
                if(s.Value == point)
                {
                    ans[s.Key] = rk;
                    u++;
                }
                else
                {
                    rk = u;
                    u++;
                    ans[s.Key] = rk;
                    point = s.Value;
                }
            }

            for(int i = 1; i <= n; i++)
            {
                Console.WriteLine(ans[i]);
            }


        }
    }
}



Measured memory_bytes: 18204
#include<stdio.h>
#include<cmath>
#include<iostream>
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    double s, l, h;
    
    double rad;
    double PI = acos(-1);
    rad = c * PI / 180;
    
    s = 0.5 * a * b * sin(rad);
    l = a + b + sqrt(pow(a, 2.0) + pow(b, 2.0) - (2 * a * b * cos(rad)));
    h = b * sin(rad);
    printf("%lf\n", s);
    printf("%lf\n", l);
    printf("%lf\n", h);
}


Measured memory_bytes: 3432
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"math"
	"math/big"
	"os"
)

var reader *bufio.Reader
var writer *bufio.Writer

var inputFile = flag.String("input", "", "")

func init() {
	flag.Parse()
	var i io.Reader
	if *inputFile != "" {
		i, _ = os.Open(*inputFile)
	} else {
		i = os.Stdin
	}
	reader = bufio.NewReaderSize(i, 1<<20)
	writer = bufio.NewWriterSize(os.Stdout, 1<<20)
}

func println(a ...interface{}) {
	_, _ = fmt.Fprintln(writer, a...)
}

func printf(format string, a ...interface{}) {
	_, _ = fmt.Fprintf(writer, format, a...)
}

func scanf(format string, a ...interface{}) {
	_, _ = fmt.Fscanf(reader, format, a...)
}

func scan(a interface{}) {
	_, _ = fmt.Fscan(reader, a)
}

func NextInt64() int64 {
	var res int64
	scan(&res)
	return res
}

func NextInt() int {
	var res int
	scan(&res)
	return res
}

func NextIntArray(n int) []int {
	res := make([]int, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextString() string {
	var res string
	scan(&res)
	return res
}

func NextBigInt() *big.Int {
	n := new(big.Int)
	n, _ = n.SetString(NextString(), 10)
	return n
}

func AbsInt64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func MinInt64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func main() {
	defer writer.Flush()

	n := NextInt()

	data := NextInt64Array(3 * n)

	cost := make([][]int64, n)
	for i := range cost {
		cost[i] = data[3*i : 3*i+3]
	}

	dp := make([][]int64, n+1)
	dp[0] = []int64{0, 0, 0}

	for i := 0; i < n; i++ {
		dp[i + 1] = []int64{math.MaxInt64, math.MaxInt64, math.MaxInt64}
		for prev, value := range dp[i] {
			for step, c := range cost[i] {
				if step == prev {
					continue
				}
				dp[i + 1][step] = MinInt64(dp[i + 1][step], value - c)
			}
		}
	}
	println(-MinInt64(dp[n][0], MinInt64(dp[n][1], dp[n][2])))
}


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

int main(){
    int n,x=0;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    //pair型のmpを全探索
    for(auto p : mp) mx = max(mx, p.second);
    //mxの文字列を表記する
    for(auto p : mp){
        if (p.second != mx) continue;
        cout << p.first << "\n";
    } 
    return 0;
}

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

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l; i<=r; ++i){
        if(i%d==0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
def l(a,b,r,c)
    ret = 0
    if a == 0
        ret = b
    elsif a == r
        ret = r+2*c-b
    elsif b == c
        ret = c+a
    else
        ret = 2*r+2*c-a
    end
    return ret
end

r,c,n = gets.split.map(&:to_i)
a = Hash.new
b = []
n.times do |i|
    w,x,y,z = gets.split.map(&:to_i)
    if (w == 0 || w == r || x == 0 || x == c) && (y == 0 || y == r || z == 0 || z == c)
        p = l(w,x,r,c)
        q = l(y,z,r,c)
        a[p] = i
        a[q] = i
        b << p << q
    end
end
b.sort!
c = []
b.each do |num|
    if c.empty? || a[c[-1]] != a[num]
        c << num
    else
        c.pop
    end
end
puts (c.empty? ? "YES" : "NO")

Measured memory_bytes: 20984
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define fr(i,n) for(i = 0; i <n; i++)
#define rep(i,n) for(i = 1; i <= n; i++)
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);


int main()
{
    fastinput;
    LL n,i,j,t,temp,tc;
    LL x,k,d;
    cin>>x>>k>>d;
    x=fabs(x);
    LL ans=-1;
    LL c1=x%d;
    LL choice1=c1;
    LL choice2=fabs(c1-d);
    LL reqd1=x/d;
    LL reqd2=x/d+1;
    if(k>reqd1)
    {
        if(reqd1%2==k%2)
        {
            ans=choice1;
        }
        else
        {
            ans=choice2;
        }
        
    }
    else
    {
        ans=x-k*d;
    }
    cout<<ans<<endl;
    

    return 0;
}


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


class Program {

	static int testN=3;
	static long mod = 1000000007;
	//static long mod =998244353; 
	static System.IO.StringReader sr;
	static void Main(string[] args) {
		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";
		int res = 0;
		string num = "";

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int n = vals[0];
		int b = vals[1];
		while ( true ) {
			int t = n % b;
			num = t + num;
			n = n / b;
			if ( n <= 0 ) { break; }
		}
			Console.WriteLine(num.Length);

		return;

	}




	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = new string[3];
            int[] cnt = new int[3];
            for (int i = 0; i < 3; i++)
            {
                s[i] = Console.ReadLine();
                cnt[i] = 0;
            }

            int now = 0;

            for(;;)
            {
                if(cnt[now] == s[now].Length)
                {
                    Console.WriteLine((char)('A' + now));
                    return;
                }
                cnt[now]++;
                now = s[now][cnt[now]-1] - 'a';
            }
        }
    }
}


Measured memory_bytes: 2648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        // string a = Console.ReadLine();
        int[] n = Read.ints();
        int[] a = Read.ints();
        Array.Sort(a);
        int sum = 0;
        for(int i = 0;i<n[1] ; i++) {sum += a[a.Length - 1 - i]; }
        Console.WriteLine(sum);  Console.ReadLine();  }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
#include <stdio.h>

int main(void){
  int N;
  scanf("%d",&N);

  int t[N],v[N];
  int endtime = 0,time = 0;

  for(int i = 0;i < N;i++) scanf("%d",&t[i]);
  for(int i = 0;i < N;i++) scanf("%d",&v[i]);
  for(int i = 0;i < N;i++) endtime += t[i];

  double speed[2*endtime];
  double ans = 0;

  for(int i = 0;i < 2*endtime;i++) speed[i] = 60000;
  for(double i = 0;i < endtime;i += 0.5){
    double sample[N+2];
    sample[N] = i;
    sample[N+1] = endtime-i;
    time = 0;
    for(int j = 0;j < N;j++){
      if(i < time) sample[j] = v[j]+(time-i);
      else if(time+t[j] < i) sample[j] = v[j]+(i-(time+t[j]));
      else sample[j] = v[j];
    time += t[j];
    }
    for(int j = 0;j < N+2;j++){
      if(speed[(int)(i*2)] > sample[j])
        speed[(int)(i*2)] = sample[j];
    }
  }

  for(int i = 0;i < 2*endtime;i++){
    ans += 0.25*(speed[i]+speed[i+1]);
  }

  printf("%lf\n",ans);
  return 0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())
if (n == 1 and m == 0):
    print(0)
    exit()
if (m == 0):
    print('1' + '0' * (n - 1))
    exit()
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        if (s == 1 and c == 0 and n >= 2):
            print(-1)
            exit()
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ok = False
if (n == 1):
    start = 0
else:
    start = 10 ** (n - 1)
for i in range(start, 10 ** n):
    for k, v in dic.items():
        if (str(i)[k - 1] != str(v)):
            break
    else:
        print(i)
        exit()


Measured memory_bytes: 38384
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- 出力
    putStrLn $ show $ a `div` 3


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e3 + 9, M = 3e4 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll w[N], s[N], val[N];
int idx[N];
ll dp[N][M];

ll cmp(int a, int b) {
  return w[a] + s[a] > w[b] + s[b];
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> w[i] >> s[i] >> val[i];
  vector<int> idx;
  for (int i = 0; i < n; ++i)
    idx.push_back(i);
  sort(idx.begin(), idx.end(), cmp);
  for (int i = 0; i < n; ++i)
    cerr << w[idx[i]] << ' ' << s[idx[i]] << ' ' << val[idx[i]] << endl;
  ll bestAnswer = 0;
  for (int i = 0; i < n; ++i) {
    for (int remWeight = M - 1; remWeight >= 0; --remWeight) {
      if(i)
        dp[i][remWeight] = max(dp[i][remWeight], dp[i-1][remWeight]); // bestAnswer so far
      if(remWeight - w[idx[i]] >= 0) {
        ll temp = val[idx[i]];
        if(i)
          temp += dp[i-1][remWeight];
        int myW = min(remWeight - w[idx[i]], s[idx[i]]);
        dp[i][myW] = max(dp[i][myW], temp);
        bestAnswer = max(bestAnswer, dp[i][myW]);
      }
    }
  }
  cout << bestAnswer;
  return 0;
}


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

using namespace std;

int main()
{
  string s, p, text;
  cin >> s >> p;
  text = s + s.substr(0, p.length() - 1);
  if (text.find(p) != string::npos)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3204
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int x;
	cin >> x;
	vector<ll> n(401);
	for(int i = -200; i< 201;i++){
		n.at(i+200) = pow(i,5);

	}
	reps(i, 401){
		reps(j, 400){
			if(n.at(i) + x == n.at(j)){
				j = j-200;
				i = i-200;
				cout << j << " " << i << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4112
n = int(input())
def calcNum(l):
    if(l == 1):
        return 9
    return 10**l - 10**(l-1)

def getdigit(num):
    digit=0
    while(num != 0):
        num //= 10
        digit+=1
    return digit

# 100 -> 3
digit = getdigit(n)
ans = 0
if(digit % 2 == 0):
    amari = 0
else:
    amari = n - 10**(digit-1)+1
# print(digit, amari)
# 100 -> 0, 1, 2
for i in range(0, digit):
    if i % 2 != 0:
        # print("level",i)
        ans += calcNum(i)
# print(ans)
print(ans+amari)


Measured memory_bytes: 39856
#include <stdio.h>
#include<string.h>
int main(void){
	int N,M;
	char s[100][10];
	char t[100][10];
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%s",&s[i]);
	}
	scanf("%d",&M);
	for(int i=0;i<M;i++){
		scanf("%s",&t[i]);
	}
	int max = 0;
	int X	= 0;
	for(int i=0;i<N;i++){
		X=1;
		for(int j=i+1;j<N;j++){
			if( strcmp(s[i],s[j])==0){
				X++;
			}
		}
		for(int j=0;j<M;j++){
			if( strcmp(s[i],t[j]) ==0){
				X--;
			}
		}
		if( max < X){
			max = X;
		}		
	}	
	printf("%d",max);	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
    char a[10],b[10],c[10];
    scanf("%s %s %s",a,b,c);
    int l,ll;
    l=strlen(a);
    ll=strlen(b);
    if(a[l-1]==b[0]&&b[ll-1]==c[0])
        printf("YES\n");
    else
        printf("NO\n");

}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int CheckIncre(vector<int> V, int i){
    int num;
    if(V.at(i+1)>V.at(i)) num=1;
    else if(V.at(i+1)==V.at(i)) num=0;
    else if(V.at(i+1)<V.at(i)) num=-1;
    return num;
}

int main(){
    int N; cin>>N;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    if(N==1){cout<<1<<endl;exit(0);}

    int ans=1;
    int incre=CheckIncre(A,0);
    rep(n,0,N-1){
        int _incre=CheckIncre(A,n);
        if(incre*_incre==-1){
            ans++;
            n++;
            if(n<N-1) incre=CheckIncre(A,n);
        }
        else if(incre==0) incre=_incre;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#define ll long long
using namespace std;

int main() {
    string s,t;
    cin>> s >> t;
    string sub = t.substr(0, t.length() - 1);
//    cout<<sub;
    if (sub == s) cout<<"Yes";
    else cout<<"No";
}


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

using namespace std;
typedef long long ll;

string codes[] = {"AC", "WA", "TLE", "RE"};

int main() {
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; i++) {
        string res;
        cin >> res;
        m[res]++;
    }
    for (string code : codes) {
        cout << code << " x " << m[code] << "\n";
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int curMin = 1e8;
  int ans = 0;
  rep(i,n) {
    curMin = min(curMin, p[i]);
    if (curMin == p[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
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> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;
ll mod = 1e9+7;

ll p(ll n, ll m){
    if(m == 0) return 1;
    ll ans = 1, cnt = m;
    while(cnt > 0){
        ans *= n-cnt+1;
        ans %= mod;
        cnt--;
    }
    return ans;
}

int main(){
    cout << fixed << setprecision(20);
    int n,m; cin >> n >> m;
    if(abs(n-m) > 1){
        cout << 0 << endl;
        return 0;
    }
    if(n == m) cout << 2*p(n,n)*p(m,m) % mod << endl;
    else cout << (p(n,n)*p(m,m)) % mod << endl;
    return 0;
}


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

#define reint register int
#define coint const int

using namespace std;

typedef long long ll;

coint SIZE = 100000 + 5;

ll li[SIZE];

inline int getint(void) {
    reint x = 0, ch = getchar();
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >= '0' && ch <= '9';
        x = (x << 1) + (x << 3) + (ch - '0'), ch = getchar());
    return x;
}

int main(void) {
    coint n = getint();
    for (reint i = 1; i <= n; ++i) li[i] = getint();
    int flg = 1;
    for (reint i = n - 1; i; --i) {
        if (li[i] > li[i + 1]) --li[i];
        if (li[i] > li[i + 1]) flg = 0;
    }
    puts(flg ? "Yes" : "No");
    return 0;
}



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

int main() {
    int a, b;
    int res;
    cin >> a >> b;
    if (a>b){
      res +=a;
      --a;
    }
    else{
      res +=b;
      --b;
    }
     if (a>b){
      res +=a;
      --a;
    }
    else{
      res +=b;
      --b;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	private static final FastIn in = new FastIn();
	private static final PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		Solver sol = new Solver();
		sol.solve();
		out.close();
	}

	private static final class Solver {
		public void solve() {
			int[] a = new int[3];
			for (int i = 0; i < 3; ++i) a[i] = in.nextInt();
			int f = 0, s = 0;
			for (int i = 0; i < 3; ++i) if (a[i] % 5 == 0) f++; else if (a[i] % 7 == 0) s++;
			if (f == 2 && s == 1) out.println("YES");
			else out.println("NO");
		}
	}

	private static final class FastIn {
		private BufferedReader br;
		private StringTokenizer st;

		public FastIn() {
			br = new BufferedReader(new InputStreamReader(System.in), 1 << 20);
			st = null;
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 34692
### constant

TBL = {'m' => 1000, 'c' => 100, 'x' => 10, 'i' => 1}

### subroutines

def mcxi2num(mcxi)
  pos = 0
  len = mcxi.length
  num = 0

  while pos < len
    ch0 = mcxi[pos]
    pos += 1
    if ch0 >= '0' && ch0 <= '9'
      ch1 = mcxi[pos]
      pos += 1
      num += ch0.to_i * TBL[ch1]
    else
      num += TBL[ch0]
    end
  end
  num
end

def num2mcxi(num)
  dm = num / 1000
  dc = (num % 1000) / 100
  dx = (num % 100) / 10
  di = num % 10

  mcxi = ''
  if dm > 0
    mcxi += dm.to_s if dm > 1
    mcxi += 'm'
  end
  if dc > 0
    mcxi += dc.to_s if dc > 1
    mcxi += 'c'
  end
  if dx > 0
    mcxi += dx.to_s if dx > 1
    mcxi += 'x'
  end
  if di > 0
    mcxi += di.to_s if di > 1
    mcxi += 'i'
  end

  mcxi
end

### main

n = gets.to_i

n.times do
  mcxi0, mcxi1 = gets.strip.split
  puts num2mcxi(mcxi2num(mcxi0) + mcxi2num(mcxi1))
end

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

using namespace std;

int main()
{
    long long  n,w[101],v[101],i,M,j;
    cin>>n>>M;
    for(i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    long long f[n+1][M+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=M;j++)
        {
            f[i][j]=0;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=M;j++)
        {
            if(j<w[i])
            f[i][j]=f[i-1][j];
            else
            f[i][j]=max(f[i-1][j-w[i]]+v[i],f[i-1][j]);
        }
    }
    cout<<f[n][M];
    return 0;
}


Measured memory_bytes: 79104