akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
ll gcd(ll a,ll b){
if(b==0)return a;
else return gcd(b,a%b);
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll n;
    cin>>n;
    ll p=360;
    for(ll i=1;i<=1000;i++){
        if((n*i)%p==0){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	char c;
	cin >> c;

	if (c == 'A')
		cout << 'T' << endl;
	if (c == 'T')
		cout << 'A' << endl;
	if (c == 'G')
		cout << 'C' << endl;
	if (c == 'C')
		cout << 'G' << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cnt = 0;
		
		for(int i=1; i<=N; i++) {
			for(int j=1 ; j<=N; j++) {
				for (int k=1; k<=N; k++) {
					cnt++;
				}
			}
		}
		System.out.print(cnt);

		System.out.println();

		sc.close();
	}
}




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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
    string s, t; cin >> s >> t;
    int l = s.length();
    char end;
    string t_new = t;
    REP(i, l){
        if(s == t_new){cout << "Yes" << endl; return 0;}
//        cout << t_new << endl;
        end = t_new[0];
        REP(j, l - 1){
            t_new[j] = t_new[j + 1];
        }
        t_new[l - 1] = end;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		double[] tmp = GetDoubles(4);
		int N = GetInt();
		double[] x = new double[N + 2];
		double[] y = new double[N + 2];
		double[] r = new double[N + 2];
		x[0] = tmp[0];
		y[0] = tmp[1];
		x[N + 1] = tmp[2];
		y[N + 1] = tmp[3];
		for(int i = 1; i <= N; i++)
		{
			x[i] = GetDouble();
			y[i] = GetDouble();
			r[i] = GetDouble();
		}

		double[,] cost = new double[N + 2, N + 2];
		for(int i = 0; i < N + 2; i++)
		{
			for(int j = 0; j < N + 2; j++)
			{
				double dx = x[j] - x[i];
				double dy = y[j] - y[i];
				cost[i, j] = Max(0.0, Sqrt(dx * dx + dy * dy) - (r[i] + r[j]));
			}
		}

		double[] d = dijkstra(cost, 0);
		Console.WriteLine($"{d[N + 1]:F12}");
	}

	private double[] dijkstra(double[,] cost, int s)
	{
		int V = cost.GetLength(0);
		double INF = double.MaxValue / (double)V;		
		bool[] used = new bool[V];
		double[] d = Enumerable.Repeat(INF, V).ToArray();
		d[s] = 0;

		while(true)
		{
			int v = -1;
			for(int u = 0; u < V; u++)
				if(!used[u] && (v == -1 || d[u] < d[v]))
					v = u;

			if(v == -1)
				break;
			used[v] = true;

			for(int u = 0; u < V; u++)
				d[u] = Math.Min(d[u], d[v] + cost[v, u]);
		}

		return d;
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

int main() {
	int N; cin >> N;
    priority_queue<ll> q;
    for (int i = 0; i < N; i++) {
        ll x; cin >> x; q.emplace(x);
    }
    ll res = 0;
    while (q.size()) {
        ll x = q.top(); q.pop();
        ll t = (x + res) / N;
        if (t == 0) continue;
        res += t;
        q.push(x - t * (N+1));
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define fi first
#define se second
const int LEN = 2e5+5;
const int LEN5 = 1e5+5;
const int MOD = 1e9+7;
typedef long long ll;
int N,ar[22][22]; ll dp[22][1 << 22];
int lim;

ll sol(int n, int m) {
   // cout<<n<<" "<<m<<endl;
   
   if(n == N) return m == lim;
   if (dp[n][m] != -1) return dp[n][m];

   dp[n][m] = 0;
   for(int i=0;i<N;i++) {
      // cout<<ar[n][i]<<endl;
      if (ar[n][i] && !((1 << i)&m)) {
         // cout<<n<<" "<<i<<endl;
         dp[n][m] += sol(n+1,m | (1 << i));
      }
   }
   dp[n][m] %= MOD;
   return dp[n][m];
}

int main() {

   // freopen ("myfile.txt","r",stdin);
   // freopen ("myfile.txt","w",stdout);

   // ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0);
   ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0);
   cin>>N;
   lim = (1 << N) -1;
   for(int i = 0;i<N;i++) {
      for(int k = 0;k<N;k++)
         cin>>ar[i][k];
   }
   for(int i = 0;i<22;i++) {
      for(int k = 0;k<(1 << 21);k++) {
         dp[i][k] = -1;
      }
   }
   cout<<sol(0,0)<<endl;

}   

Measured memory_bytes: 405760
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main(void){

	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(abs(a-c) <= d){
		cout << "Yes" << endl;
	}else if(abs(a-b) <= d && abs(b-c) <=d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cassert>
#include <deque>
#include <queue>
#include <map>
#include <utility>
#include <set>
// g++ -std=c++11 <filename>
#define FOR(j,k,n) for (int j = k; j < (int)(n); j++)
#define MAXN 100000000000000000
#define newl printf("\n")
#define fi first
#define se second
#define test(t)  int t; cin>>t; for(int tes = 0; tes < t; tes++)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> plli;
void inn(long long int &ix) {scanf("%lld",&ix);}
void inn(long long int &ix,long long int &iy) {scanf("%lld%lld",&ix,&iy);}
void inn(int &ix) {scanf("%d",&ix);}
void inn(int &ix,int &iy) {scanf("%d%d",&ix,&iy);}
void inn(long double & ix) {scanf("%LF",&ix);}
void outt(long long int ix) {printf("%lld",ix);}
void outt(long long int ix, char cx) {printf("%lld%c",ix,cx);}
void outt(int ix) {printf("%d",ix);}
void outt(int ix, char cx) {printf("%d%c",ix,cx);}
void outt(long double ix, char cx){printf("%.9LF%c",ix,cx);}
void outt(long double ix){printf("%.9LF",ix);}
void pline() {printf("\n");}

const int MM = 1200000;
lli m,n,k,p1,p2,p3,p,f,a[MM];
string s,s1,s2;
lli state[60];
int main(){
	// Have you solved the problem completely?    

	cin>>n;
	cin>>s1>>s2;
	lli ans = 1;
	lli mod = (1000000007);
	for(int i=0; i<n; i++)
	{
		if(s1[i] == s2[i])
		{
			state[i] = 2;
		}
		else if(i && s1[i]==s1[i-1])
		{
			state[i] = -1;
		}
		else
		{
			state[i] = 1;
		}
	}
	ans = 3;
	if(state[0]==1)
		ans *= 2;
	for(int i=1; i<n; i++)
	{	
		if((state[i]==2 && state[i-1]==2) || (state[i]==1 && state[i-1]==2))
			ans = (ans*2)%mod;
		else if(state[i]==1 && state[i-1]==-1)
			ans = (ans*3)%mod;
	}
	cout<<ans;
   	return 0;
}


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

int main(void){
    int H, W;
    cin >> H >> W;
    string s[H];
    for(int i = 0; i < H; i++)
        cin >> s[i];
    for(int i = 0 ; i < H; i++){
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N, i, j, v, l;
	
	scanf("%d", &N);
	
	int A[N];
	
	for(i=0; i<N; i++){
	    scanf("%d", &A[i]);
    }
	
	for(i = 0; i < N; i++){
	    v = A[i];
	    j = i - 1;
	
	while(j >= 0 && A[j] > v){
	    A[j+1] = A[j];
	    j--;
	}
	
	A[j+1]=v;
	
	for(l=0; l<N; l++){
	    printf("%d", A[l]);
	    
	    if(l<N-1){
	        printf(" ");
	        
	    }
	}
	
	printf("\n");
	}
	
	return 0;
}
    




Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-min
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// min-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return INF; // min
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return min(lv,rv); // min
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmin(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};

int main() {
  ll n,x;
  cin >> n >> x;
  segtree T(n);
  for(ll i=0;i<n;i++) {
    ll tmp;
    cin >> tmp;
    T.Set(i,i+1,tmp);
  }
  ll ans=inf;
  for(ll i=0;i<n;i++) {
    ll tans=x*i;
    for(ll j=0;j<n;j++) {
      ll v=T.Getmin(max(j-i,0LL),j+1);
      if(j-i<0) {
        v=min(v,T.Getmin(n+j-i,n));
      }
      tans+=v;
    }
    ans=min(ans,tans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <map>
#include <vector>
#include <string>

using namespace std;




int main(int argc, char *argv[])
{
	int n;

	cin >> n;

	if (n == 1){
		cout << "Hello World" << endl;
	}
	else{
		int a, b;

		cin >> a;
		cin >> b;

		cout << a + b << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};

int main(){
    
    ll L[100];
    L[0] = 2;
    L[1] = 1;
    for(ll i = 2; i < 90; i++)L[i] = L[i - 1] + L[i - 2];
    ll N;
    cin >> N;
    cout << L[N] << endl;
    
    return 0;
}

Measured memory_bytes: 256
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#pragma GCC      optimize ("Ofast")
#include         <bits/stdc++.h>
#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
using namespace std;

const int N = (int)1e5 + 10;
int memo[N][3], happiness[N][3];
int n;

//dp (i, j) max happiness till ith day if jth task was done ith day

int dp (int i, int j) {
	if (i == 1) {
		return happiness[1][j];
	}
	else if (memo[i][j] != -1)
		return memo[i][j];
	else {
		int val = INT_MIN;
		for (int k = 0; k < 3; ++k) {
			if (k == j) continue;
			val = max (val, dp (i - 1, k));
		}
		return memo[i][j] = happiness[i][j] + val;
	}
}



int main() {
	IOS; PREC;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		for (int k = 0; k < 3; ++k) {
			cin >> happiness[i][k];
			memo[i][k] = -1;
		}
	}
	int ans = INT_MIN;
	for (int k = 0; k < 3; ++k)
		ans = max(ans, dp (n, k));
	cout << ans << '\n';

	return EXIT_SUCCESS;
}




Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[1000000][3];
ll dpt[1000000][3];

ll solve(ll x,ll r,ll p){
    if(r==x)
        return 0;
    if(dpt[r][p]!=-1)
        return dpt[r][p];
    ll a1=0,a2=0,a0=0,ans=0;
    if(p==0){
        a1=dp[r][p]+solve(x,r+1,1);
        a2=dp[r][p]+solve(x,r+1,2);
    }
    if(p==1){
        a0=dp[r][p]+solve(x,r+1,0);
        a2=dp[r][p]+solve(x,r+1,2);
    }
    if(p==2){
        a0=dp[r][p]+solve(x,r+1,0);
        a1=dp[r][p]+solve(x,r+1,1);
    }
    ans=max(a1,max(a2,a0));
    dpt[r][p]=ans;
    return ans;
}

int main()
{
    ll x,i,j,a=0,s1,s2,s3,v=0;
    cin>>x;
    for(i=0;i<x;i++){
        cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
        dpt[i][0]=-1;
        dpt[i][1]=-1;
        dpt[i][2]=-1;
    }
    s1=solve(x,0,0);
    s2=solve(x,0,1);
    s3=solve(x,0,2);
    v=max(s1,max(s3,s2));
    cout<<v<<endl;
}



Measured memory_bytes: 14720
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
lapse=0

for i in range(n-1):
    if a*(x[i+1]-x[i])>b:
        lapse+=b
    else:
        lapse+=a*(x[i+1]-x[i])
print(lapse)

Measured memory_bytes: 62704
#include<stdio.h>
int main()
{
    long long i,j,t;
    while(scanf("%lld%lld",&i,&j)!=EOF)
    {
        if(i==1&&j==1)
            t=1;
        else if(i==1)
            t=j-2;
        else if(j==1)
            t=i-2;
        else
        {
            t=(i-2)*(j-2);
        }
        printf("%lld\n",t);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define MAX_N (200000)

int main(){
    int N;
    int buka_kazu[MAX_N+2];
    int joushi_bango;

    scanf("%d", &N);

    for(auto i=0; i<N+2; i++){
        buka_kazu[i] = 0;
        // printf("%d %d\n", i, buka_kazu[i]);
    }

    for(auto i=2; i<N+1; i++){
        scanf("%d", &joushi_bango);
        // printf("%d %d\n", joushi_bango, buka_kazu[joushi_bango]);
        buka_kazu[joushi_bango]++;
        // printf("%d %d\n", joushi_bango, buka_kazu[joushi_bango]);
    }

    for(auto i=1; i<N+1; i++){
        printf("%d\n", buka_kazu[i]);
    }

    return(0);
}

Measured memory_bytes: 2512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	
	cout << ((N - M) * 100 + M * 1900) *(1 << M) << endl;
}

Measured memory_bytes: 256
//2018年  3月 23日 金曜日 02:40:07 JST-
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
int cnt[MAX_N];
bool exist[MAX_N];

void solve() {
	cin >> N >> M;
	rep(i, 0, N) cnt[i] = 1;
	exist[0] = true;
	rep(i, 0, M) {
		int a, b; cin >> a >> b; a--; b--;
		if(cnt[a] == 1) {
			if(exist[a]) {
				exist[a] = false;
				exist[b] = true;
			}
		}
		else {
			if(exist[a]) exist[b] = true;
		}
		cnt[a]--; cnt[b]++;
	}
	cout << accumulate(exist, exist + N, 0) << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N / 1000;
  b = N % 1000 / 100;
  c = N % 1000 % 100 / 10;
  d = N % 1000 % 100 % 10;
 
  if ( a == b && b == c ) {
    cout << "Yes" << endl;
  }
  else if ( b == c && c == d ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int n,A[2000100],B[2000100];

void CountingSort(int *A,int *B,int k){
    int* C=new int[k+1];
    for(int i=0;i<=k;++i){
        C[i]=0;
    }

    for(int i=1;i<=n;++i){
        ++C[A[i]];
    }

    for(int i=1;i<=k;++i){
        C[i]+=C[i-1];
    }

    for(int i=n;i>=1;--i){
        B[C[A[i]]]=A[i];
        --C[A[i]];
    }
    
    delete[] C;
}

int main(){
    cin>>n;

    int max=0;
    
    for(int i=1;i<=n;++i){
        cin>>A[i];
        max=(A[i]>max?A[i]:max);
    }

    CountingSort(A,B,max);
    
    for(int i=1;i<=n;++i){
        cout<<B[i];

        if(i!=n){
            cout<<" ";
        }
        else{
            cout<<"\n";
        }
    }
}


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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

bool isoverflow(ll a, ll b) {
	if(a==0||b==0) return false;
	ll res = a*b;
	if(a==res/b) return false;
	else return true;
}
void solve() {
	int n;
	cin >> n;
	ll a[n];
	bool zero=0;
	F0R(i, n) {
		cin>>a[i];
		if(a[i] == 0) zero=1;
	}

	if(zero) {
		cout<<0;return;
	}
	// sort(ALLn(a,n));

	ll ans = 1;

	F0R(i,n) {
		
		if(a[i]>1000000000000000000/ans) {
			cout<<-1;
			return;
		}
		ans *= a[i];
		
	}
	
	cout<<ans;
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
}



Measured memory_bytes: 4360
#include<stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
void recursive(int);
void initialize();
void printBoard();
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int X[N][N];
int main(){
  int r,c;
  initialize();

  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      X[i][j]=0;

  int k;
  scanf("%d",&k);
  for(int i=0;i<k;i++){
  scanf("%d%d",&r,&c);
  X[r][c]=1;
  }

recursive(0);
return 0;
}

void initialize(){
  for(int i=0;i<N;i++){row[i]=FREE,col[i]=FREE;}
  for(int i=0;i<2*N-1;i++){
    dpos[i]=FREE;dneg[i]=FREE;}
}

void printBoard(){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j)return;
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(row[i]==j)
	printf("Q");
      else
      printf(".");}
    printf("\n");
  }
}

void recursive(int i){
  if(i==N){
    printBoard();return;}
  for(int j=0;j<N;j++){
    if(NOT_FREE==col[j]||NOT_FREE==dpos[i+j]||NOT_FREE==dneg[i-j+N-1])
      continue;
    row[i]=j;col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}




Measured memory_bytes: 2692
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

def zen(n,used, new):

    usednum = len(used|set([new]))
    #print("keta",usednum)
    if n == 0:
        if usednum == 3:
            return 1
        else:
            return 0

    if usednum == 3:
        return 3**n
    if usednum == 2:
        return 3**n - 2**n
    if usednum == 1:
        return 3**n - 2*(2**n) +1
    return 3**n - 3*(2**n) + 3

def simo_init(n):
    if n == 0:
        return 0
    return 3 ** n - 3 * (2 ** n) + 3

n = input()
digit = len(n)

answer = 0
for i in range(digit):
    answer += simo_init(i)

def get_simo(n, dig,used):
    global answer
    if n == "":
        if len(used) == 3:
            answer += 1
        return
    if int(n[0]) > 3:
        answer += zen(dig-1, used, 3)
    if int(n[0]) > 5:
        answer += zen(dig-1, used, 5)
    if int(n[0]) > 7:
        answer += zen(dig-1, used, 7)

    #print("all: ",answer)
    #print("dig: ", dig, n)
    first = int(n[0])
    if first in [3,5,7]:
        get_simo(n[1:], dig-1, used|set([first]))


get_simo(n,digit,set())
print(answer)

#print(zen(3,set()))


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

import numpy
import scipy

N = int(input())
D = []
for n in range(N):
    D.append(int(input()))
#print(D)

Ds = sorted(D, reverse=True)
#print(Ds)

c = 0
for i, d in enumerate(Ds):
    if i == 0:
        c += 1
    if d < Ds[i-1]:
        c += 1

print(c)

Measured memory_bytes: 12508
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    string s;cin >> s;
    int n = s.size()+1;
    vector<ll> a(n);
    ll ans = 0;
    rep(i,n-1){
        if(s[i] == '<'){
            a[i+1] = max(a[i]+1, a[i+1]);
        }
    }
    for(int i = n-2; i >= 0; i--){
        if(s[i] == '>'){
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    rep(i,n) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 4740
#include <stdio.h>

int main(void){
    int X,A[100005]={},i,j;
    scanf("%d",&X);
    if (X==2) {
        printf("2\n");
        return 0;
    }
    else{
        A[0]=2;
        for (i=3; ; i++) {
            int f=1;
            for (j=0; A[j]!='\0'; j++) {
                if (i%A[j]==0) {
                    f=0;
                    break;
                }
            }
            if (f) {
                A[j]=i;
                if (i>=X) {
                    printf("%d\n",i);
                    return 0;
                }
            }
        }
    }
}


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

using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    int ans = 1, cur = 0;
    for(int i = 0; i < n; ++i){
        int tmp; cin >> tmp;
        if(tmp + cur <= x)ans++;
        cur += tmp;
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll a[N];
ll sum[N];
const ll mod=1e9+7;
int main(){
	ll n;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=n;i>=1;i--){
		sum[i]=(sum[i+1]+a[i])%mod;
	}
	ll ans=0;
	for(int i=1;i<=n-1;i++){
		ans=(ans+a[i]*sum[i+1]%mod)%mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6880
#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli p,t=0,n,i;
	cin>>p>>n;
	lli a[n],b[n];
	rep(i,0,n){
		cin>>a[i];
	}
	lli ans=0;
	sort(a,a+n);
	rep(i,0,n-1){
		b[i]=a[i+1]-a[i];
	}
	b[n-1]=a[0]+p-a[n-1];
	sort(b,b+n);
	rep(i,0,n-1){
		ans+=b[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6760
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readContents 3 >>= putStrLn . showRes . solve
    where
        showRes b
            | b = "YES"
            | otherwise = "NO" 

solve :: [[Int]] -> Bool
solve = (== ans) . map mf . group . sort . map length . group . sort . concat
    where
        mf = (,) <$> head <*> length
        ans = [(1, 2), (2, 2)]


readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
N = int(input())
Data = list(map(int,input().split()))
Dic = {}
for d in Data:
    if not d in Dic:
        Dic[d] = 0
    Dic[d]+=1

even = 0
odd  = 0
for k,v in Dic.items():
    if v % 2 == 0:
        even += 1
    else:
        odd += 1

if even % 2 == 0:
    ans = even + odd
else:
    ans = even + odd -1

print(ans)


Measured memory_bytes: 18272
n=int(input())
s=input()
ans=0

for i in range(10):
    for j in range(10):
        for k in range(10):
            x=s.find(str(i))
            if x!=-1:
                y=s.find(str(j),x+1)
                if y!=-1:
                    z=s.find(str(k),y+1)
                    if z!=-1:
                        ans+=1

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

using namespace std;
using ll = long long;

#define Input(x) scanf("%lld",&x);

ll n;
ll a[234567];
ll sum[234567];

bool cond(int index,ll limit)
{
	int nowind = index;
	nowind = lower_bound(sum + nowind, sum + n + n + 1, sum[nowind] + limit) - sum;
	if (nowind > index + n)
	{
		return false;
	}
	nowind = lower_bound(sum + nowind, sum + n + n + 1, sum[nowind] + limit) - sum;
	if (nowind > index + n)
	{
		return false;
	}
	nowind = lower_bound(sum + nowind, sum + n + n + 1, sum[nowind] + limit) - sum;
	if (nowind > index + n)
	{
		return false;
	}
	return true;
}

int main()
{
	Input(n);
	for (int i = 0; i < n; ++i)
	{
		Input(a[i]);
		a[i + n] = a[i];
	}
	sum[0] = 0;
	for (int i = 1; i <= 2 * n; ++i)
	{
		sum[i] = sum[i - 1] + a[i - 1];
	}
	ll answer = 0;
	for (int i = 0; i < n; ++i)
	{
		ll cmin = 0, cmax = sum[n];
		for (int j = 0; j < 100; ++j)
		{
			ll find = (cmin + cmax) / 2;
			if (cond(i, find))
			{
				cmin = find;
			}
			else
			{
				cmax = find;
			}
			if (cmax - cmin <= 1)break;
		}
		answer = max(answer, cmin);
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 5852
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
bool pr[1000007];
void sieve(){pr[0]=1;pr[1]=1;for(int i=2;i<sqrt(1000007);i++){for(int j=2*i;j<=1000007;j+=i){pr[j]=1;}}}
ll fashtpower(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x;res%=MOD;y=y>>1;x=x*x;x%=MOD;}return res;}
ull lopow(ll x,ll y){ull res=1ULL;while(y){if(y&1)res*=(ull)x;y>>=1;x*=x;}return res;}
int main(){
	ios_base::sync_with_stdio(0);
		ll n;
		cin>>n;
		ll l,r;
		ll ans=0;
		for(ll i=0;i<n;i++){
			cin>>l>>r;
			ans=ans+r-l+1;
			//if(ans>n) ans=n;
		}
		cout<<ans<<"\n";
		
	
}

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

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

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

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

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

/* main */

signed main(){
    string S;
    cin >> S;
    FOR(i,0,7){
        string pre = S.substr(0,i);
        string back = S.substr(S.size()-7+i);
        debug(pre)
        debug(back)
        if(pre + back == "keyence"){
            YES(1)
            return 0;
        }
    }
    YES(0)
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

int factorial(int n){
    if(n == 1) return 1;
    return n * factorial(n-1);
}

int main(void){

    int n; cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0;i < n;i++) cin >> p[i];
    for(int i = 0;i < n;i++) cin >> q[i];

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

    map<vector<int>, int> mp;
    int i = 0;
    do{
        //mp[a] = mp.size();
        mp[a] = i++;
    }while(next_permutation(a.begin(), a.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  ll T;
  cin >> N >> T;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  ll ret = 0;
  rep(i,v.size()){
    ll a = T;
    if(i+1<v.size() && v[i+1]-v[i]<T){
      a = v[i+1]-v[i];
    }
    ret += a;
  }
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 2420
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
diff = []
for i in range(N-1):
    diff.append(A[i+1] - A[i])
diff.append(abs(K - A[N-1] + A[0]))
diff.sort()
print(K - diff[N-1])


Measured memory_bytes: 26444
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m,K;

int ned[22][22][2];

ll f[(1<<19)+5],g[(1<<19)+5];

void Work(){
	f[0]=1;
	REP(i,0,m-1)
		REP(j,0,n-1){
			memcpy(g,f,sizeof(f));memset(f,0,sizeof(f));
			REP(sta,0,(1<<n)-1)if(g[sta]){
				g[sta]%=mod;
				int c=(sta>>j)&1;
				if(c){
					if(!ned[i][j][0])f[sta]+=g[sta];
				}
				else{
					if(!ned[i][j][1])f[sta]+=g[sta];
					if(!ned[i][j][0]){
						int nxt=sta;
						nxt&=((1<<n)-1)^((1<<j)-1);
						int pos=nxt&(-nxt);
						nxt=sta^pos;
						nxt^=1<<j;
						f[nxt]+=g[sta];
					}
				}
			}
		}
	ll ans=0;
	REP(sta,0,(1<<n)-1)ans+=f[sta]%mod;
	iout(ans%mod);
}

void Init(){
	read(n,m,K);n--;
	REP(i,1,K){
		int x,y,z;
		read(x,y,z);
		ned[x-1][y-1][z]=1;
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 8576
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 5min
int main(void){
  int n;
  int a, b;
  
  scanf("%d", &n);
  if(n == 1){
    printf("Hello World\n");
  }if(n == 2){
    scanf("%d%d", &a, &b);
    printf("%d\n", a + b);
  }
  
  return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		char[] line = br.readLine().toCharArray();

		for(int i = 0; i < line.length; ++i) {
			if (Character.isUpperCase(line[i])) {
				line[i]=Character.toLowerCase(line[i]);
			} else {
				line[i]=Character.toUpperCase(line[i]);
			}
		}
		System.out.println(line);
	}
}

Measured memory_bytes: 24116
from heapq import heappush, heappop
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, Q = map(int, readline().split())
STX = [[int(x) for x in readline().split()] for _ in range(N)]
EVENT = []
for s, t, x in STX:
    EVENT.append((s-x, 1, x))
    EVENT.append((t-x, 0, x))

for i in range(Q):
    d = int(readline())
    EVENT.append((d, 2, i))

ans = [-1] * Q

EVENT.sort()


STOP = set()
h = []
for t, op, x in EVENT:
    if op == 2 and STOP:
        while h and h[0] not in STOP:
            heappop(h)
        ans[x] = h[0]
    elif op == 1:
        STOP.add(x)
        heappush(h, x)
    elif op == 0:
        STOP.remove(x)

print("\n".join(map(str, ans)))


Measured memory_bytes: 143764
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;

int main()
{
    string s;

    cin >> s;

    int i = 0;
    int cnt = 0;
    while (i < (int)s.size() - 1) {

        if (s[i] == '0' && s[i+1] == '1') {
            cnt += 2;
            //s = s.substr(0, i) + s.substr(i + 2, s.size() - (i + 2));
           s= s.erase(i, 2);
            if(i!=0)i--;
        }
        else if (s[i] == '1' && s[i+1] == '0') {
            cnt += 2;
           // s = s.substr(0, i) + s.substr(i + 2, s.size() - (i + 2));
           s= s.erase(i, 2);
            if(i!=0)i--;
        }
        else {
            i++;
        }

     /*   cout << s << endl;
        cout << s.size()<<i << endl;
        */
    }
    cout << cnt << endl;
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 3728
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;


struct Edge{ll from,to;};

//非再帰トポロジカルソート 隣接リストを渡す 返り値のサイズがnじゃないならnot DAG
std::vector<ll> topo_sort(std::vector<std::vector<ll>>& graph){
  ll n=graph.size();
  std::vector<ll> res,num(n,0);
  std::queue<ll> que;
  rep(i,0,n){
    for(ll j:graph[i])num[j]++;
  }
  rep(i,0,n){
    if(num[i]==0)que.push(i);
  }
  while(!que.empty()){
    ll u=que.front();que.pop();
    res.push_back(u);
    for(ll i:graph[u]){
      num[i]--;
      if(num[i]==0)que.push(i);
    }
  }

  return res;
}
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,m;
  std::cin>>n>>m;
  std::vector<std::vector<ll>> graph(n);

  rep(i,0,m){
    ll x,y;
    std::cin>>x>>y;
    x--;y--;
    graph[x].push_back(y);
  }

  std::vector<ll> a=topo_sort(graph),dp(n,0);
  for(ll i=n-1;i>=0;i--){
    ll now=a[i],max=0;
    for(ll j:graph[now]){
      max=std::max(max,dp[j]+1);
    }
    dp[now]=max;
  }

  ll ans=0;
  rep(i,0,n)ans=std::max(ans,dp[i]);
  std::cout<<ans;

  return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,ans=0;
	string str;
	cin>>n;
	cin>>str;
	for(unsigned int i=0;i<str.size();i++)
	{
		if(str[i]=='A')
		{
			if(str[i+1]=='B')
				if(str[i+2]=='C')
				{
					ans++;
					i+=2;
				}
		}
	}
	cout<<ans<<'\n';
	return 0;
}

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

/*
コンテスト日程: D日 = 365日
s d,i: d日にタイプiのコンテストを行った時の満足度
c i:1日のタイプiのコンテストの満足度の下がりやすさ
*/

int z[] = {
    18398,
35037,
51140,
65837,
79325

};

int D;
int c[26],cc[26] = {0};
int s[365][26];
int t[365];
bool x[26] = {0};

/**/

int main(){
    cin >> D;
    int csum = 0;
    for(int i = 0;i < 26;i++){
        cin >> c[i];
        //cc[i] = c[i];
        csum += c[i];
    }
    for(int i = 0;i < D;i++){
        for(int j = 0;j < 26;j++){
            cin >> s[i][j];
        }
    }
    for(int i = 0;i < D;i++){
        cin >> t[i];
    }
    /**/
    /*満足度 + */
    int pans = 0,nans = 0;
    for(int i = 0;i < D;i++){
        pans += s[i][t[i] - 1];
        for(int j = 0;j < 26;j++){
            
            cc[j]++;
            if(t[i] - 1 == j){
                cc[j] = 0;
            } 
            nans += c[j]*cc[j];
        }
        
        cout << pans - nans << endl;
    }

    
    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


int main() {

    int x; cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}





Measured memory_bytes: 3592
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

def palindrome?(s)
  n=s.size
  (n/2).times do|i|
    if s[i]!=s[n-1-i]
        return false
    end
  end
  return true
end
s=get_nsp
t=s.dup
t.delete("x")
if not palindrome?(t)
    puts -1
    exit
elsif s.join("")==t.join("")
    puts 0
    exit
end
head=0
tail=s.size-1
ans=0
while head<=tail
  if s[head]!=s[tail]
      ans+=1
      if s[head]=="x"
        head+=1
      else
        tail-=1
      end
  else
      head+=1
      tail-=1
  end
end
puts ans

Measured memory_bytes: 9836
A, B = [int(i) for i in input().split(' ')]
if B <= 1:
    print(0)
elif B <= A:
    print(1)
elif A < B:
    counter = 1
    B -= A
    counter += int(B / (A-1))
    if B % (A-1) != 0:
        counter +=1
    print(counter)
    

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
int n,a[nmax],i,p[nmax],ans;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)
	{
		p[a[i]]=p[a[i]-1]+1;
		ans=max(ans,p[a[i]]);
	}
	cout<<n-ans<<endl;
    return 0;
}

Measured memory_bytes: 1920
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
An = 0

for i in range(n-1):
    for j in range(i+1,n):
        c = 0
        for k in range(d):
            c+=(x[i][k]-x[j][k])**2
        if c**0.5%1==0:
            An += 1
 
print(An)

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

#define rep(X, N) for (ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(), (V).end()
#define endl "\n"

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;

int main(){

    int n;
    cin >> n;

    int cont = 0;
    int m = 0;

    rep(i, n){
        int a, b;
        cin >> a >> b;

        if(a == b){
            cont++;
        }else{
            cont = 0;
        }

        m = max(m, cont);
    }

    if(m >= 3){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

#define QUEUE_MAX 100005
#define NAME_MAX 100
#define HEAD_INIT 1
#define PROCESS_END 0
#define TAIL_END 1
#define VER_INIT 0
#define LOOP_INIT 1
#define EXIT_SUCCESS 0
#define NEXT_ITEM( x ) ( ( x ) + 1 )

typedef struct {
	unsigned char aubG_Dp_name[ NAME_MAX ];
	signed long slG_Drem_time;
} Process;

Process st_queue[ NEXT_ITEM( QUEUE_MAX ) ];
unsigned long ulG_Dqueue_head = HEAD_INIT;
unsigned long ulG_Dqueue_tail;
unsigned long ulG_Ddata_cnt;

signed long judge_min( 
signed long slW_Ddata_first, 
signed long slW_Ddata_second )
{
	if( slW_Ddata_first < slW_Ddata_second ){
		return slW_Ddata_first;
	}
	else{
		return slW_Ddata_second;
	}
}

void enqueue( 
Process st_queue_add )
{
	st_queue[ ulG_Dqueue_tail ] = st_queue_add;
	if( ulG_Dqueue_tail == QUEUE_MAX ){
		ulG_Dqueue_tail = TAIL_END;
	}
	else{
		ulG_Dqueue_tail++;
	}
}

Process dequeue( void )
{
	Process st_queue_calc;

	st_queue_calc = st_queue[ ulG_Dqueue_head ];
	if( ulG_Dqueue_head == QUEUE_MAX ){
		ulG_Dqueue_head = HEAD_INIT;
	}
	else{
		ulG_Dqueue_head++;
	}
	return st_queue_calc;
}

int main( void )
{
	unsigned long ulW_Dtotal_time = VER_INIT;
	signed long slW_Dcalc;
	unsigned long ulW_Cloop_cnt;
	unsigned long ulW_Dquantum;
	Process st_queue_calc;

	scanf( "%d %d", &ulG_Ddata_cnt, &ulW_Dquantum );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt <= ulG_Ddata_cnt; ulW_Cloop_cnt++ ){
		scanf( "%s %d", st_queue[ ulW_Cloop_cnt ].aubG_Dp_name, &st_queue[ ulW_Cloop_cnt ].slG_Drem_time );
	}
	ulG_Dqueue_tail = NEXT_ITEM( ulG_Ddata_cnt );
	while( ulG_Dqueue_head != ulG_Dqueue_tail ){
		st_queue_calc = dequeue();
		slW_Dcalc = judge_min( ulW_Dquantum, st_queue_calc.slG_Drem_time );
		st_queue_calc.slG_Drem_time -= slW_Dcalc;
		ulW_Dtotal_time += slW_Dcalc;
		if( st_queue_calc.slG_Drem_time > PROCESS_END ){
			enqueue( st_queue_calc );
		}
		else{
			printf( "%s %d\n", st_queue_calc.aubG_Dp_name, ulW_Dtotal_time );
		}
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 11536