akhauriyash/Code-Regression huggingface dataset:
if __name__ == '__main__':
    [N, C, K] = [int(i) for i in input().split()]

    T = []
    for i in range(N):
        T.append(int(input()))
    T.sort()

    counter = 1

    num_people = 0

    flag = False

    for time in T:
        num_people += 1
        if flag:
            if time - first_time <= K and num_people <= C:
                continue
            else:
                counter += 1
                num_people = 1
                first_time = time

        else:
            first_time = time
            flag = True

    print(counter)


Measured memory_bytes: 7444
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int a = vs[0];
			int b = vs[1];
			int ans = -1;
			int x = 0, y = 0;
			for (int i = 1; i < 2000; i++) {
				if (a == (i * 8) / 100 && b == (i * 10) / 100) {
					ans = i;
					break;
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}


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

int main(){
  int N;cin >> N;
  vector<int> A(N);
  int U=100,L=-100;
  for(int i=0;i<N;i++){
    cin >> A[i];
    U = min(U,A[i]);
    L = max(L,A[i]);
  }
  ll ans = 10000000;
  for(int x=U;x<=L;x++){
    ll sum = 0;
    for(int i=0;i<N;i++){
      sum += (x-A[i])*(x-A[i]);
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  string s1,s2;
  cin >> s1;
  cin >> s2;
  ll ans;
  auto isTate = [&](int i) {
    return s1[i] == s2[i];
  };
  bool isT = false;
  
  rep(i,N) {
    if(i == 0) {
      if(isTate(0)) {
        ans = 3;
        isT = true;
      } else {
        ans = 6;
        i++;
      }
      continue;
    }
    if(isTate(i)) {
      if(isT) {
        ans *= 2;
      }
      isT = true;
    } else {
      if(isT) {
        ans *= 2;
      } else {
        ans *= 3;
      }
      isT = false;
      i++;
    }
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  char s;
  cin >> s;
  if(s =='A'){
    cout << "T" << endl;
  }else if( s == 'C'){
    cout << "G" << endl;
  }else if( s == 'T'){
    cout << "A" << endl;
  }else{
    cout << "C"<<endl;
  }
}

Measured memory_bytes: 256
h = int(input())

count = 0
width = 0

while(1):
  if h == 1:
    count += pow(2,width)
    break
  if h >=2:
    if h%2 == 1:
      h = h-1
    h = h//2
    count += 1*pow(2,width)
    width += 1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	vector<string>arr(h);
	for(int i=0;i<h;i++){
		cin>>arr[i];
	}
	vector<vector<int>>dp(h,vector<int>(w,0));
	dp[0][0]=1;
	for(int j=1;j<w;j++){
		if(arr[0][j]=='.')
			dp[0][j]=dp[0][j-1]%mod;
	}
	for(int i=1;i<h;i++){
		if(arr[i][0]=='.')
			dp[i][0]=dp[i-1][0]%mod;
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(arr[i][j]=='.'){
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[h-1][w-1];
	return 0;
}

Measured memory_bytes: 5248
A,B,N=map(int,input().split())
ans=0
if N<B:
    for i in range(N,N+1):
        if ((A*i)//B)-A*(i//B)>ans:
            ans=((A*i)//B)-A*(i//B)
else:
    if ((A*(B-1))//B)-A*((B-1)//B)>ans:
            ans=((A*(B-1))//B)-A*((B-1)//B)
print(ans)


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int A[20];
    int B[20];
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> A[i];
    }
     for (int i=0;i<n;i++){
        cin >> B[i];
    }   
    int ans = 0;
    for (int i=0;i<n;i++){
        ans += max(0,A[i]-B[i]);
    }     
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo P
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

	int N,P;

//aのb乗
int beki(int a,int b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}

int main(){
	

	cin>>N>>P;
	
	string S;
	cin>>S;
	
	if(P>=30){
		int temp = 1;
		map<int,int> mp;
		mp[0]++;
		int sum = 0;
		long long ans = 0;
		for(int i=0;i<S.size();i++){
			sum = mod(sum * 10);
			sum = mod(sum + (S[i]-'0'));
			ans += mp[mod(sum * gyakugen(temp))];
			
			mp[mod(sum*gyakugen(temp))]++;
			temp = mod(temp * 10);
		}
		
		cout<<ans<<endl;
	}
	else{
		vector<vector<long long>> dp(S.size()+1,vector<long long> (P,0));
		
		//dp[0][0] = 1;
		
		for(int i=0;i<S.size();i++){
			for(int j=0;j<P;j++){
				dp[i+1][mod(j*10 + S[i] - '0')] += dp[i][j];
			}
			dp[i+1][mod(S[i]-'0')]++;
		}
		
		long long ans = 0;
		
		for(int i=1;i<=S.size();i++){
			ans += dp[i][0];
			//cout<<dp[i][0]<<endl;
		}
		cout<<ans<<endl;
	}
	
    return 0;
}



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

int main() {
  string s;
  char x[100];
  cin >> s;

  int l = s.length() - 2;
  int last = 0;
  for (int i = 0; i < s.length(); i++) {
    x[i] = s[i];
    last++;
  }
  last--;

  cout << x[0] << l << x[last];

  return 0;
}

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

using namespace std;

#define ll long long
#define mod (ll)1000000007

const ll INF = 1e11;

void solve(){

    int h, w; cin >> h >> w;
    
    int dp[h][w];
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            char c; cin >> c;
            dp[i][j] = (c == '.' ? -1 : 0);
        }
    }
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(dp[i][j] == 0) continue;
            if(i == 0 && j == 0) dp[i][j] = 1;
            else if(i == 0) dp[i][j] = dp[i][j-1];
            else if(j == 0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
        }
    }
    cout << dp[h-1][w-1] << endl;

    return;
}


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

    solve();    

	return 0;
}



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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 N;
vector<u64> a, parent, visited;

void findpath(u64 i){
        if (parent[i] != -1) {
            findpath(parent[i]);
        }
        visited[i] = 1;
        cout << a[i] << endl;
}

bool cmp(u64 a, u64 b){
    return a >= b;
}

int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    vector<u64> M, indexer;
    a.resize(N), parent.resize(N, -1), visited.resize(N, 0);
    for (u64 i = 0; i < N; i++) {
        cin >> a[i];
    }
    M.push_back(a[0]);
    indexer.push_back(0);
    for (auto it = a.begin() + 1; it != a.end(); it++) {
        if (*it <= M.back()) {
            M.push_back(*it);
            parent[it - a.begin()] = indexer.back();
            indexer.push_back(it - a.begin());
        } else {
            auto location = lower_bound(M.begin(), M.end(), *it, cmp);
            *location = *it;
            if (location != M.begin()) {
                parent[it - a.begin()] = indexer[location - M.begin() - 1];
            }
            indexer[location - M.begin()] = it - a.begin();
        }
    }
    
    cout << M.size() << endl;
    //findpath(indexer.back());
    
    
    
    
    return 0;
}


Measured memory_bytes: 7440
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int N = 1000000;
signed main() {
	int n;
	while (cin >> n, n) {
		vector<int>v(n); rep(i, 0, n)cin >> v[i]; sort(all(v));
		//vector<bool>vf(N, false); rep(i, 0, n)vf[v[i]] = true;
		bool f(false),first(true);

		rep(i, 0, n-1) {
			if (f == false) {

				if (v[i] == v[i + 1] - 1) {
					if (first)first = false;
					else cout << " ";

					cout << v[i] << "-";
					f = true;
				}
				else {
					if (first)first = false;
					else cout << " ";
					cout << v[i];
				}
			}
			else {
				if (f&&v[i] != v[i + 1] - 1) {
					cout << v[i];
					f = false;
				}
			}
		}
		if (!f&&!first)cout << " ";
		cout << v[n - 1];
		cout << endl;
		
		//rep(i, 0, N) {
		//	if (vf[i]) {
		//		if (f == false) {
		//			if (first)first = false;
		//			else cout << " ";

		//			cout << i << "-";
		//			f = true;
		//		}
		//	}
		//	else {
		//		if (f == true) {
		//			cout << i - 1;
		//			f = false;
		//		}
		//	}
		//}
		//cout << endl;

	}
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int left = A + B;
  int right = C + D;
  
  if (left == right) {
 	 cout << "Balanced" << endl; // 偽
  } else if (left > right) {
 	 cout << "Left" << endl; // 偽
  } else {
 	 cout << "Right" << endl; // 偽
  }
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;

int n,a[N],s[N],bit[N];

void add(int i,int x) {
	for(;i<N;i+=i&-i) {
		bit[i]+=x;
	}
}

int sum(int i) {
	int s=0;
	for(;i>0;i-=i&-i) {
		s+=bit[i];
	}
	return s;
}

LL cal(int x) {
	for(int i=0;i<N;i++) {
		bit[i]=0;
	}
	int w=1e5+1;
	s[0]=0;
	for(int i=1;i<=n;i++) {
		s[i]=s[i-1]+(a[i]>x);
	}
	LL res=0;
	add(w,1);
	for(int i=1;i<=n;i++) {
		int u=i-2*s[i]+w;
		res+=sum(u-1);
		add(u,1);
	}
	return res;
}

bool check(int x) {
	LL y=cal(x);
	//printf("x=%d y=%lld\n",x,y);
	LL M=(LL)(n+1)*n/2;
	return y>=M/2+1;
}

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

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

long long int MOD = 1e9 + 7;
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long int n,k;
	long long int res = 0;

	cin >> n >> k;

	long long int sum1 = 0;
	long long int sum2 = 0;
	long long int lo = 0;
	long long int hi = n;

	for(int i=0;i<k;i++)
	{
		sum1 += lo;
		sum1%=MOD;
		lo++;
		sum2 += hi;
		sum2%=MOD;
		hi--;
	}

	for(int i=k;i<=n+1;i++)
	{
		//cout << sum1 << ' ' << sum2 << ' ' << lo << ' ' << hi << ' ' << i << '\n';
		long long int val = (sum2 +1)%MOD;
		val = (val - sum1)%MOD;
		if(val<0)
		{
			val+=MOD;
		}
		res = (res + val)%MOD;
		sum1 += lo;
		sum1%=MOD;
		lo++;
		sum2 += hi;
		sum2%=MOD;
		hi--;
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int q;
    cin>>q;
    V<int> k(q);
    for(int i=0;i<q;i++)cin>>k[i];
    for(int i=0;i<q;i++){
          ll d=0,m=0,dm=0,ans=0;
          queue<char> que;
          for(int j=0;j<n;j++){
              if(que.size()>=k[i]){
                  char c=que.front();que.pop();
                  if(c=='D'){
                      dm-=m;
                      d--;
                  }
                  else if(c=='M'){
                      m--;
                  }
              }
              char c=s[j];
              que.push(c);
              if(c=='C')ans+=dm;
              else if(c=='M'){
                  m++;
                  dm+=d;
              }
              else if(c=='D'){
                    d++;
              }
          }
          cout<<ans<<endl;
    }
}

Measured memory_bytes: 2332
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	ll k,n;
	ll a[200100];
	ll b[200100];
	cin>>k>>n;
	rep(i,n)
		cin>>a[i];
	rep(i,n-1)
		b[i]=a[i+1]-a[i];
	b[n-1]=k+a[0]-a[n-1];
	sort(b,b+n);
	cout<<k-b[n-1]<<endl;
	return 0;
}



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

long long mmin(long long x,long long y){
	return x<y?x:y;
}

int main(){
	long long a,b,c; scanf("%lld%lld%lld",&a,&b,&c);
	if(a%2!=0&&b%2!=0&&c%2!=0) printf("%lld\n",mmin(a*b,mmin(b*c,a*c)));
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 256
import sys
import heapq

input = sys.stdin.readline

N,M = map(int,input().split())

data = list(map(int,input().split()))

minus = lambda x:-x

data = list(map(minus,data))
#print(data)

heapq.heapify(data)
#print(data)

for i in range(M):
    x = heapq.heappop(data)
    x = - (abs(x) // 2)
    heapq.heappush(data,x)
    #print(data)

print(-sum(data))
    

Measured memory_bytes: 14172
#include<iostream>
using namespace std;int main(){int n,y;while(true){cin>>n;if(n==0)break;cin>>y;int b,r,t;double best=n,set;for(int u=0;u<n;u++){cin>>b>>r>>t;double ans;if(t==1)ans=n*(100+r*y)/100.0;if(t==2){ans=n;for(int i=0;i<y;i++)ans=ans*(100+r)/100.0;}if(ans>best){best=ans;set=b;}}cout<<set<<endl;}return 0;}

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

int main(){
    int n;
    cin >> n;
    for(int i=1; i<10; ++i){
        for(int j=1; j<10 ; ++j){
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 int main() {
   string s;
   int f = 0;
   cin >> s;
   for(int i=0;i<4;i++){
     for(int j=0;j<3;j++){
       if(s.at(i) == s.at(j))f++;
     }
   }
     if(f == 6){cout << "Yes" << endl;}
     else {cout << "No" << endl;}
     return 0;
   }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
int main() {
	int year,month,day;
	vector<pair<string, int>> status = {make_pair("heisei",1989),make_pair("showa",1926),make_pair("taisho",1912),make_pair("meiji", 1868)};
	while(cin >> year >> month >> day) {
		string str;
		int st = 0;
		if(year > 1989 || (year == 1989 && month > 1) || (year == 1989 && month == 1 && day >= 8)) st = 0;
		else if(year > 1926 || (year == 1926 && month == 12 && day >= 25)) st = 1;
		else if(year > 1912 || (year == 1912 && month > 7) || (year == 1912 && month == 7 && day >= 30)) st = 2;
		else if(year > 1868 || (year == 1868 && month > 9) || (year == 1868 && month == 9 && day >= 8)) st = 3;
		else str = "pre-meiji";
		if(str == "pre-meiji") cout << str << endl;
		else printf("%s %d %d %d\n", status[st].first.c_str(), year - status[st].second + 1, month, day);
	}
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    ll a, b; cin >> a >> b;
    map<ll, ll> A;
    for (ll i = 2; i * i <= a; i++) {
        while (a % i == 0) {
            A[i]++;
            a /= i;
        }
    }
    if (a != 1)A[a] = 1;
    map<ll, ll> B;
    for (ll i = 2; i * i <= b; i++) {
        while (b % i == 0) {
            B[i]++;
            b /= i;
        }
    }
    if (b != 1)B[b] = 1;

    ll ans = 1;
    for (auto i : A)if (B[i.first])ans++;
    cout<<ans<<"\n";
}


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

int n, k;
int sol = 1e9;

struct str{
	
	int x;
	int y;
	int z;
	
};

pair< pair<int, int>, int > p[15];

int main () {

	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i ++) {
		scanf("%d%d", &p[i].first.first, &p[i].first.second);
		p[i].second = i+1;
	}
	
	sort(p, p + n);
	do {
		
	
		int tren = k, po = 0;
		int kol = 0;
		while (tren > 0) {
			int l = 1, r = p[po].first.first-1;
			while (l < r) {
				int mid = (l + r) / 2;
				if (tren - mid*(100*p[po].second) <= 0) r = mid;
				else l = mid+1;
			}
			
			if (tren - l*(100*p[po].second) <= 0) {
				tren = 0;
				kol += l;
				break;
			}
			
			/*for (int i = 1; i < p[po].first.first; i ++) {
				if (tren - i*(100*p[po].second) <= 0) {
					tren = 0;
					kol += i;
					break;
				}
			}*/
			
			tren -= p[po].first.first*100*p[po].second+p[po].first.second;
			kol += p[po].first.first;
			if (tren <= 0) break;
			
			
			po ++;
		}
		
		sol = min(sol, kol);
		
	} while (next_permutation(p,p + n));
	
	printf("%d", sol);

	return 0;
}

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

typedef long long LL;

const int MAXN=200005,MOD=1000000007;

int n,a[MAXN],b[MAXN],cnt[MAXN],inv[MAXN],C[MAXN],pre[MAXN][2];

void add(int x,int d)
{
	for (;x<=n;x+=x&-x)
		(C[x]+=d)%=MOD;
}

int sum(int x)
{
	int ret=0;
	for (;x;x-=x&-x)
		(ret+=C[x])%=MOD;
	return ret;
}

int work(int s)
{
	for (int i=1;i<=n;i++)
		C[i]=0;
	int ret=0;
	for (int i=1;i<=n;i++)
	{
		add(a[i]+1,pre[a[i]][1]);
		int k=(sum(a[i])-sum(b[a[i]])+MOD)%MOD;
		ret=(ret+(LL)k*pre[a[i]][0])%MOD;
	}
	return (LL)ret*s%MOD*inv[2]%MOD;
}

int main()
{
	#ifdef KeyID
		freopen("read.txt","r",stdin);
	#endif
	scanf("%d",&n);
	inv[1]=1;
	for (int i=2;i<=n;i++)
		inv[i]=(LL)(MOD-MOD/i)*inv[MOD%i]%MOD;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	int all=1;
	for (int i=1,sum=0;i<=n;i++)
	{
		if (i<=sum)
		{
			printf("0");
			return 0;
		}
		if (i-sum==1)
		{
			pre[i][0]=pre[i][1]=1;
			b[i]=i;
		}
		else
		{
			pre[i][0]=(LL)pre[i-1][0]*inv[i-sum]%MOD*(i-sum-1)%MOD;
			pre[i][1]=(LL)pre[i-1][1]*(i-sum)%MOD*inv[i-sum-1]%MOD;
			b[i]=b[i-1];
		}
		all=(LL)all*(i-sum)%MOD;
		(sum+=cnt[i])%=MOD;
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		ans=(ans+(LL)cnt[i]*(cnt[i]-1)/2)%MOD;
	ans=(LL)ans*inv[2]%MOD;
	for (int i=n;i>=1;i--)
	{
		add(a[i],1);
		(ans+=sum(a[i]-1))%=MOD;
	}
	ans=(LL)ans*all%MOD;
	(ans+=work(all))%=MOD;
	reverse(a+1,a+n+1);
	(ans+=MOD-work(all))%=MOD;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

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

typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int x = n % 10;
	if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9)puts("hon");
	else if (x == 0 || x == 1 || x == 6 || x == 8)puts("pon");
	else puts("bon");
	return 0;
}

Measured memory_bytes: 3596
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
plus = []
sum = 0
num = 0
for i in range(n):
    diff = A[i] - B[i]
    if diff < 0:
        sum -= diff
        num += 1
    else:
        plus.append(diff)
# ここから まず、引いても全部正だったとき(負がない)つまりnum = 0の時は何もしなくていい
if num == 0:
    print(0)
    exit()
else:
    res = num
    # plusの大きい物順にする
    plus = sorted(plus,reverse=True)
    p = 0
    for i in range(len(plus)):
        p += plus[i]
        res += 1
        if p >= sum:
            break
    if p >= sum:
        print(res)
    else:
        print(-1)


Measured memory_bytes: 19188
#!/usr/bin/env python3
import sys


def solve(L: int):
    print(format((L/3.0)**3.0, ".10f"))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    solve(L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
// シャキョウ of youyin
#include <bits/stdc++.h>
using namespace std;

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

typedef long long ll;
const int inf = 1e5;
int main() {
	ll N;
	cin >> N;

	vector<vector<int>> to(N);

	vector<vector<int>> dist(N,vector<int>(N,inf));
	for(int i = 0; i < N; i++) dist[i][i] = 0;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++){
			char c; cin >> c;
			if(c == '1') {
				to[i].push_back(j);
				dist[i][j] = 1;
			}
		}
	}

	vector<ll> visited(N,-1);

	queue<int> Q; Q.push(0);
	while(!Q.empty()){
		int p = Q.front(); Q.pop();

		for(auto u :to[p]){
			if(visited[u] != -1) { // -1 は未到達を意味する
				if(visited[u] == visited[p]) {
					cout << -1 << endl; return 0; // この時、二部グラフ構成出来ない。　
				} else {
					continue;
				}
			}

			visited[u] = visited[p] + 1;
			Q.push(u);
		}
	}

	// ここを通過すれば、二部グラフと言える
	// 次に、最長の距離を求める

	// Warshall - Floyd
	rep(k,N) rep(i,N) rep(j,N){
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	}
	int ans = 0;
	rep(i,N){
		rep(j,N){
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans + 1 << endl;
}



Measured memory_bytes: 640
/*
   Username : moondancer
   Name : Moon Dancer
*/


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

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    int a[n],s[n];
    int m=1e9+7;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        s[i]=a[i];
        if(i)
            s[i]=(s[i]+s[i-1])%m;
    }
    int ans=0;
    for (int i = 1; i < n; ++i)
    {
        ans=(ans+(s[i-1]*a[i])%m)%m;
    }
    cout<<ans;
    return 0;
}

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

int main(){
  int K;
  cin >> K;
  int n=1;
  int S = 7;
  if ((K % 2 == 0) || (K % 5 == 0)){
    cout << "-1" << endl;
    return 0;
  }
  while(S != 0){
    if (S >= K)
      S -= K;
    else{
      S = S*10 + 7;
      n++;
      if (n>K){
        //cout << "-1" << endl;
        //return 0;
      }
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <queue>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>

using namespace std;
using lli = long long int;

class xorshift {
public:
	int random() {
		return std::rand();
	}
};

template <class T>
class Treap {
	xorshift rnd;
	struct Node {
		T key;
		int priority;
		Node* l, * r;
		Node(T key, int priority) : key(key), priority(priority), l(nullptr), r(nullptr) {}
	} *root = nullptr;
	using Tree = Node *;

	void split(Tree t, T key, Tree& l, Tree& r) {
		if (!t) {
			l = r = nullptr;
		}
		else if (key < t->key) {
			split(t->l, key, l, t->l), r = t;
		}
		else {
			split(t->r, key, t->r, r), l = t;
		}
	}

	void merge(Tree& t, Tree l, Tree r) {
		if (!l || !r) {
			t = l ? l : r;
		}
		else if (l->priority > r->priority) {
			merge(l->r, l->r, r), t = l;
		}
		else {
			merge(r->l, l, r->l), t = r;
		}
	}

	void insert(Tree& t, Tree item) {
		if (!t) {
			t = item;
		}
		else if (item->priority > t->priority) {
			split(t, item->key, item->l, item->r), t = item;
		}
		else {
			insert(item->key < t->key ? t->l : t->r, item);
		}
	}

	void erase(Tree& t, T key) {
		if (t->key == key) {
			merge(t, t->l, t->r);
		}
		else {
			erase(key < t->key ? t->l : t->r, key);
		}
	}

	bool find(Tree& t, T key) {
		if (!t) {
			return false;
		}
		else if (t->key == key) {
			return true;
		}
		else {
			return find(key < t->key ? t->l : t->r, key);
		}
	}

	//keyより大きいもので一番小さいものを返す
	T upperBound(Tree& t, T key) {
		if (!t) {
			return numeric_limits<T>().max();
		}
		else if (t->key > key) {
			return std::min(upperBound(t->l, key), t->key);
		}
		else {
			return upperBound(t->r, key);
		}
	}

	//keyより小さいもので一番大きいものを返す。
	T lowerBound(Tree& t, T key) {
		if (!t) {
			return numeric_limits<T>().min();
		}
		else if (t->key < key) {
			return std::max(lowerBound(t->r, key), t->key);
		}
		else {
			return lowerBound(t->l, key);
		}
	}

public:
	void insert(T key) {
		insert(root, new Node(key, rnd.random()));
	}

	void erase(T key) {
		erase(root, key);
	}

	bool find(T key) {
		return find(root, key);
	}

	T upperBound(T key) {
		return upperBound(root, key);
	}

	T lowerBound(T key) {
		return lowerBound(root, key);
	}
};

lli A[200000 + 1] = {};

int main(void) {

	Treap<lli> treap;

	lli N, ans = 0;

	cin >> N;

	treap.insert(0);
	treap.insert(N + 1);

	for (lli i = 0; i < N; i++) {
		lli t;
		cin >> t;
		A[t] = i + 1;
	}

	for (lli i = 1; i <= N; i++) {

		lli upper = treap.upperBound(A[i]);
		lli lower = treap.lowerBound(A[i]);

		//cout << lower << " " << A[i] << " " << upper << endl;
		//cout << (A[i] - lower) * (upper - A[i]) * i<< endl;

		treap.insert(A[i]);

		ans += (A[i] - lower) * (upper - A[i]) * i;

	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 11136
import queue 
MOD = 10**9 +7
INF = 10**9
def main():
    n,m = map(int,input().split())
    V0 = [[] for _ in range(n)]
    V1 = [[] for _ in range(n)]
    V2 = [[] for _ in range(n)]
    for _ in range(m):
        u,v = map(int,input().split())
        u -= 1
        v -= 1
        V0[u].append(v)
        V1[u].append(v)
        V2[u].append(v)
    
    s,t = map(int,input().split())
    s -= 1
    t -= 1
    
    d0 = [-1]*n
    d1 = [-1]*n
    d2 = [-1]*n
    d0[s] = 0

    q = queue.Queue()
    q.put([s,0])
    while q.qsize() != 0:
        p = q.get()
        mod = p[1]
        v = p[0]
        if mod == 0:
            for e in V0[v]:
                if d1[e] == -1:
                    d1[e] = d0[v] + 1
                    q.put([e,1])

        elif mod == 1:
            for e in V1[v]:
                if d2[e] == -1:
                    d2[e] = d1[v] + 1
                    q.put([e,2])
        
        else:
            for e in V2[v]:
                if d0[e] == -1:
                    d0[e] = d2[v] + 1
                    q.put([e,0])
    
    if d0[t] == -1:
        print(-1)
    else:
        print(d0[t]//3)
   
if __name__=='__main__':
    main()



Measured memory_bytes: 104936
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    while (!S.empty()) {
        int u = S.top(); S.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int s, t, m, q;

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8944
#include<bits/stdc++.h>
using namespace std;
int xx1,yy1,xx2,yy2,xx3,yy3,xx4,yy4;
int main(){
	cin>>xx1>>yy1>>xx2>>yy2;
	xx3=xx1-(yy2-yy1);
	yy3=yy1+(xx2-xx1);
	xx4=xx2-(yy2-yy1);
	yy4=yy2+(xx2-xx1);
	cout<<xx4<<" "<<yy4<<" "<<xx3<<" "<<yy3<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1e9 + 5;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> dp(n, INF);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j : {i + 1, i + 2}) {
      if (j < n) {
        dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
      }
    }
  }
  cout << dp[n - 1] << "\n";
  return 0; 
}


Measured memory_bytes: 3972
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#include <cassert>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
//typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll K = 38;
ll N = K*(K-1) + 1;
ll a[100][100];
ll cnt[5000];
int main(){
  rep(i,K-1){
    rep(j,K-1){
      a[i][j] = i*(K-1) + j + (K+1);
      //cerr << " " << a[i][j];
    }
    //cerr << endl;
  }
  cout << N << " " << K << endl;
  rep(i,N){
    if(i==0){
      rep(j,K){
        if(j==0){
          cout << j+1;
          cnt[j+1]++;
        }
        else{
          cout << " " << j+1;
          cnt[j+1]++;
        }
      }
      cout << endl;
    }
    else if((i-1) / (K-1) == 0){
      cout << "1";
      cnt[1]++;
      ll tmp2 = (i-1) % (K-1);
      rep(j,K-1){
        cout << " " << a[tmp2][j];
        cnt[a[tmp2][j]]++;
      }
      cout << endl;
    }
    else{
      cout << (i-1) / (K-1) + 1;
      ll tmp = (i-1)/(K-1);
      cnt[tmp+1]++;
      ll tmp2 = (i-1) % (K-1);
      rep(j,K-1){
        cout << " " << a[j][(tmp2+j*tmp)%(K-1)];
        cnt[a[j][(tmp2+j*tmp)%(K-1)]]++;
      }
      cout << endl;
    }
  }
  /*
  rep(i,N){
    cerr << " " << cnt[i+1];
  }
  cerr << endl;
  */
}


Measured memory_bytes: 640
let n = read_line () |> int_of_string in
let s = read_line () in
let rec loop i acc =
    if i < 0 then acc else
        let acc = if s.[i] = 'A' && s.[i + 1] = 'B' && s.[i + 2] = 'C' then acc + 1 else acc in
        loop (i - 1) acc
in
loop (String.length s - 3) 0 |> Printf.printf "%d\n"

Measured memory_bytes: 384
n, h, *A = map(int, open(0).read().split())
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
    if h <= 0:
        n = i
        h = 0
        break
    if b[i] < a:
        n = i
        break
    h -= b[i]
print(n - (-h // a))


Measured memory_bytes: 31848
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int len = s.length();
    if(s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
'use strict'

function Main(input) {
    // 7,5,3の組み合わせを基底数3の序数と見なしつつ解きます
    const N = parseInt(input.trim())
    const faces = [7, 5, 3]
    const base = faces.length

    let count = 0
    // n桁、i番目の組み合わせを求めます
    for (let len = base; len <= N.toString().length; len++) {
        for (let i = 0; i < Math.pow(base, len); i++) {
            // 組み合わせの作成
            const combo = convertToBaseX(i, base, len).map(x => faces[x])
            // 検証＆カウント
            const condA = parseInt(combo.join('')) <= N
            const condB = faces.every((x) => combo.indexOf(x) !== -1)
            if (condA && condB)
                count += 1

            //console.log([convertToBaseX(i, base, len).join(''), combo.join(''), [condA, condB].join()])
        }
    }
    const output = count
    console.log(output)
}

function convertToBaseX(num, base, minLength) {
    const digits = minLength == null ? [] : new Array(minLength).fill(0)
    let temp = num
    for (let i = 0; temp !== 0; i++) {
        digits[i] = temp % base
        temp = Math.floor(temp / base)
    }
    return digits
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10596
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>a>>n;
    int arr[n];
    unordered_map<int ,bool > m;
    for(int i=0;i<n;i++){
      cin>>arr[i];
      m[arr[i]] = true;
    }

    int diff = 0;

   	while(1){

   		if(m[a - diff] == false){
   			cout<<a-diff<<endl;
   			return;
   		}
   		if(m[a + diff] == false){
   			cout<<a+diff<<endl;
   			return;
   		}


   		diff++;

   	}


}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


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

namespace ABC099A
{
    class Program
    {
        static void Main(string[] args)
        {
           


                var word = Console.ReadLine().Split();
                int a = int.Parse(word[0]);
            if (a <= 999)
                Console.WriteLine("ABC");
            else
                Console.WriteLine("ABD");
               




                Console.ReadKey();



            }
        }
    }



Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long somme = 0;
		for(long i = 1 ; i <= n; i++) {
			if(i % 3 == 0 || i % 5 == 0) {
				
			}else {
				somme += i;
			}
		}
		System.out.println(somme);
	}
}


Measured memory_bytes: 35772
using System;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            string line = null;
            int num = 0;
            while( (line = Console.ReadLine()) != null )
            {
                int input = int.Parse(line);
                if (input == 0)
                    break;

                Console.WriteLine(
                   string.Format("Case {0}: {1}",
                    ++num, input ));
            }

        }
    }
}

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
void fail() {
    cout << -1 << endl;
    exit(0);
}
int main() {
    int N, M; cin >> N >> M;
    vector<int> S(M), C(M);
    for (int i = 0; i < M; i++) cin >> S[i] >> C[i], S[i]--;
    vector<int> ans(N, -1);
    for (int i = 0; i < M; i++) {
        if (ans[S[i]] == -1 || ans[S[i]] == C[i]) {
            ans[S[i]] = C[i];
        } else {
            fail();
        }
    }
    if (N != 1 && ans[0] == 0) fail();
    if (ans[0] == -1) ans[0] = (N == 1 ? 0 : 1);
    for (int i = 0; i < N; i++) {
        if (ans[i] == -1) ans[i] = 0;
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
N=int(input())
S=input()
lis=list(S)
C= collections.Counter(lis)
count=list(C.values())
c=0
for i in range(N):
    for j in range(i,(N+i-1) // 2+1):
        if(lis[i]!=lis[j]):
            if(lis[j]!=lis[2*j-i]):
                if(lis[i]!=lis[2*j-i]):
                    c+=1
if(len(count)==3):
    print(count[0]*count[1]*count[2]-c)
else:
    print(0)


Measured memory_bytes: 9468
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  string S; cin >> S;
  for (int i = 0; i < S.size(); ++i) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (S[i] == 'R') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int human, food;
    cin >> human >> food;

    vector<int> favoriteFoods(food);

    for (int i = 0; i < human; i++)
    {
        int favorite = 0;
        cin >> favorite;

        for (int r = 0; r < favorite; r++)
        {
            int foodNo = 0;
            cin >> foodNo;

            favoriteFoods.at(foodNo - 1)++;
        }
    }

    int allFavorite = 0;

    for (int i = 0; i < favoriteFoods.size(); i++)
    {
        if (human == favoriteFoods.at(i))
            allFavorite++;
    }

    cout << allFavorite << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 305;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int32_t main() {
	FAST;

	int l, r, d;
	cin >> l >> r >> d;

	int cnt = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) cnt++;
	}
	cout << cnt; 
	
}

Measured memory_bytes: 3584
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    switch(sc.nextLine())
    {
      case "SUN":
        System.out.println("7");
        break;
        case "SAT":
        System.out.println("1");
        break;
        case "FRI":
        System.out.println("2");
        break;
        case "THU":
        System.out.println("3");
        break;
        case "WED":
        System.out.println("4");
        break;
        case "TUE":
        System.out.println("5");
        break;
        case "MON":
        System.out.println("6");
        break;
    }
  }
}

Measured memory_bytes: 21204
// --霊長類の暇つぶし競プロ
// --（飲んだくれ中 @ 飲み屋）
// -- 生中２杯目
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
#define SWAP(x,y) 		((x!=y)&&(x^=y,y^=x,x^=y))

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

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

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

	string w;
	int flg[26] = {0};
	int ans = 0;

	cin >> w;

	for (int i = 0; i < w.size(); i++) {
		flg[w[i] - 'a']++;
	}

	for (int i = 0; i < 26; i++) {
		if (flg[i] > 0) {
			if (flg[i] % 2 == 1) {
				ans = 1;
			}
		}
	}

	if(ans){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}


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

int main(){
    string s;
    cin>>s;
    switch (s[0]){
        case 'S':
            cout<<"Cloudy"<<endl;
            break;
        case 'C':
            cout<<"Rainy"<<endl;
            break;
        case 'R':
            cout<<"Sunny"<<endl;
            break;
        default:
            break;
    }
    return 0;
}

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

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

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    int a;
    for (int i=0; i<n; i++){
        cin >> a;
        que.push(make_pair(a, i));
    }    

    while(!que.empty()){
        cout << que.top().second + 1 << ' ';
        que.pop();
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 1780
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	mm := make(map[int]int)
	for i := 2; i <= n; i++ {
		for k, v := range factorize(i) {
			mm[k] += v
		}
	}

	ans := 1
	for _, v := range mm {
		ans = (ans * (v + 1)) % (1e9 + 7)
	}
	fmt.Println(ans)
}

func factorize(n int) map[int]int {
	m := make(map[int]int)
	for n%2 == 0 {
		n /= 2
		m[2]++
	}

	for i := 3; i*i <= n; i += 2 {
		if n%i != 0 {
			continue
		}
		for n%i == 0 {
			n /= i
			m[i]++
		}
	}
	if n != 1 {
		m[n]++
	}
	return m
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    string S;
    cin >> S;
    int num = S.size();
    if (S[num-1] == 's') {
        S += "es";       
    }
    else {
        S += 's';
    }
    cout << S << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

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

int main(){
	long double x1,x2,y1,y2,d;
	cin >> x1 >> y1 >> x2 >> y2;
	d = powl(powl(x1 - x2, 2.0) + powl(y1 - y2, 2.0), 0.5);
	cout << fixed << d << "\n";
	return 0;
}

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

int main() {
    int X, A, B, N;
    cin >> X >> A >> B >> N;
    while(N--) {
        string S; cin >> S;
        if(S == "nobiro") X += A;
        else if(S == "tidime") X += B;
        else X = 0;
        X = max(0, X);
    }
    cout << X << endl;
    return 0;
}



Measured memory_bytes: 3208