akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

long long H[100000];
int dp_to_left[100000];
int dp_to_right[100000];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }


    /*for(int i = 1; i < N; i++){
        if(H[i - 1] <= H[i]){
            dp_to_left[i] = dp_to_left[i - 1] + 1;
        }
    }
    */


    for(int i = N - 2; i >= 0; i--){
        if(H[i + 1] <= H[i]){
            dp_to_right[i] = dp_to_right[i + 1] + 1;
        }
    }    
    
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans = max(ans, dp_to_right[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    int n;
    cin>>n;
    int a[100007][3];
    f(i,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
    vi dp0(n),dp1(n),dp2(n);
    dp0[0]=a[0][0];
    dp1[0]=a[0][1];
    dp2[0]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp0[i]=a[i][0]+max(dp1[i-1],dp2[i-1]);
        dp1[i]=a[i][1]+max(dp0[i-1],dp2[i-1]);
        dp2[i]=a[i][2]+max(dp1[i-1],dp0[i-1]);
    }
    cout<<max(max(dp0[n-1],dp1[n-1]),dp2[n-1])<<endl;
    
    
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int nTotal = szArr.Length;
            long[] arr = new long[nTotal];

            long sum = 0;
            for (int i = 0; i < arr.Length; ++i)
            {
                arr[i] = long.Parse(szArr[i]);
            }

            long a = arr[0];
            long b = arr[1];
            long c = arr[2];
            sum = a + b + c;

            long max = 0;
            for (int i = 0; i < arr.Length; ++i)
            {
                if (arr[i] > max)
                {
                    max = arr[i];
                }
            }

            if ((max * 3) % 2 == sum % 2)
            {
                Console.WriteLine((max * 3 - sum) / 2);

            }
            else
            {
                Console.WriteLine(((max + 1) * 3 - sum) / 2);

            }

        }
    }
}


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

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0;  k <= c; k++){
        if(i * 500 + j * 100 + k * 50 == x){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,t = LI()
    k = t//a
    print(k*b)
    return

#B
def B():
    n = I()
    v = LI()
    c = LI()
    ans = 0
    for i in range(n):
        if v[i] > c[i]:
            ans += (v[i]-c[i])
    print(ans)
    return

#C
def C():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a, a)
    n = I()
    a = LI()
    if n <= 1000:
        ans = 1
        for i in range(n):
            b = a[:i]+a[i+1:]
            g = b[0]
            for j in b[1:]:
                g = gcd(g,j)
            ans = max(ans,g)
        print(ans)
    else:
        m = math.ceil(n**0.5)
        while len(a) < m**2:
            n += 1
            a.append(a[-1])
        f = [0 for i in range(m)]
        for i in range(m):
            b = a[m*i:m*(i+1)]
            g = b[0]
            for j in b[1:]:
                g = gcd(g,j)
            f[i] = g
        ans = 1
        for i in range(n):
            j = i//m
            c = f[:j]+f[j+1:]+a[m*j:i]+a[i+1:m*(j+1)]
            g = c[0]
            for k in c[1:]:
                g = gcd(g, k)
            ans = max(ans,g)
        print(ans)
    return

#D
def D():
    n = I()
    a = LI()
    k = 0
    for i in a:
        if i < 0:
            k += 1
    ans = 0
    m = float("inf")
    for i in a:
        ans += abs(i)
        m = min(m,abs(i))
    if k%2:
        ans -= 2*m
    print(ans)
    return


#Solve
if __name__ == "__main__":
    C()


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	
	int N; cin >> N;
	vector<int> H(N, 0);
	vector<int> a(N, 0);


	REP(i,N) cin >> H[i];

	FOR(i,1,N){
		if(H[i] <= H[i-1]) a[i] = a[i-1] + 1;
	}

	int ans = 0;
	REP(i,N+1){
		ans = max(ans, a[i]);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	string S;
	cin >> N >> S;
	if (S.size() <= N) cout << S << endl;
	else {
		for (int i = 0; i < N; i++) {
			cout << S[i];
		}
		cout << "..." << endl;
	}
}


Measured memory_bytes: 3640
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll X;cin>>X;
    ll tmp=360;
    ll cnt=0;
    while(1){
        if(tmp==0)break;
        tmp-=X;
        if(tmp<0)tmp+=360;
        cnt++;
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include <unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
//struct edge {int to,cost;};
#define VMAX 200+10
    ll N,A[100010];
    ll F[100010];
    ll l,r;
    ll ans;

ll LP(ll x,ll y){
    if(y==0)return 1;
    if(y%2==0)return LP((x*x)%MOD,y/2);
    else return LP(x,y-1)*x%MOD;
}
ll Fact[100010];
ll Com[100010];
void FC(ll x){
    Fact[0]=Com[0]=1;
    ll temp=1;
    EREP(i,x){
        temp=temp*i%MOD;
        Fact[i]=temp;
        Com[i]=LP(temp,MOD-2);
    }
}
ll MC(ll x,ll y){
    if(y==0)return 1;
    if(x<y)return 0;
    return Fact[x]*(Com[y]*Com[x-y]%MOD)%MOD;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,100010)F[i]=-1;
    REP(i,N+1){
        cin>>A[i];
        if(F[A[i]]==-1)F[A[i]]=i;
        else{
            l=F[A[i]];
            r=i;
        }
    }
    FC(N+2);
    REP(i,N+1){
        DEB(MC(N+1,i+1))DEB(MC(l+N-r,i))END
    cout<<(MC(N+1,i+1)-MC(l+N-r,i) + MOD)%MOD<<endl;
    }
    return 0;
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
// template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long int
#define ull unsigned long long int
 
#define lp(i,n) 	    for(int i=0;i<(int)(n);i++)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);i++)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);i--)
 
#define all(v)  	 ((v).begin()), ((v).end())
#define sz(v)    	 ((int)((v).size()))
#define clr(v, d)    memset(v, d, sizeof(v))
#define PB           push_back
#define MP           make_pair
#define N 100005
 
#define PI 3.14159265359
 
 
ll nChooseR(int n,int k);
ll gcd(ll a, ll b);
vector<string> split(string target,unsigned char c );


ll n,k,t,m,x,y,a[N],b[N];

bool isPrime(ll h);
string s;

 

ll ans;

ll mod=1e9 +7;




int main() {
// freopen("pyramid.in","r",stdin); 
  //freopen("output.txt","w",stdout); 
cout.precision(10);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

cin>>k>>n;
lp(i,n)cin>>a[i]>>b[i];
vector<ll>dp(k+1,1e15);
dp[0]=0;
lpi(i,1,k+1)
	lp(j,n){
		if(a[j]>=i)
			dp[i]=min(dp[i],b[j]);
		else
			dp[i]=min(dp[i],b[j]+dp[i-a[j]]);
	}

cout<<dp[k];
}
 
	
ll nChooseR( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;
   	ll result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}
 
ll gcd(ll a, ll b){
	return b==0?a:gcd(b,a%b);
	}
 
 
vector<string> split(string target,unsigned char c ){
	string d="";
	vector<string>arr;
	for(auto n:target)
	{
		if(n!=c)
		d+=n;
		else if(d!="")
		arr.push_back(d),d="";
	}
	if (d!="")
	arr.push_back(d),d="";
	return arr;
}
// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
 
class Proc{
public:
  string nam;
  int tim;
  Proc(){
    nam = "";
    tim = 0;
  }
};
 
Proc Q[100001];
 
class Queue{
private:
  int fp;
  int rp;
public:
  Queue(){
    fp = 0;
    rp = 0;
  }
  int next(int p) const{
    return (p+1)%100001;
  }
  bool isFull() const{
    return (next(rp) == fp);
  }
  bool isEmpty() const{
    return (rp == fp);
  }
  void push(Proc d){
    if(isFull()){
      return;
    }
    Q[rp] = d;
    rp = next(rp);
  }
  Proc front(){
    if(isEmpty()){
      Proc er;
      er.tim = -1;
      return er;
    }
 
    return Q[fp];
  }
  void pop(){
    if(isEmpty()){
      return;
    }
    fp = next(fp);
  }
};
 
int main(){
  Queue que;
 
  int n,q;
  cin >> n >> q;
 
  for(int i=0;i<n;i++){
    Proc p;
    cin >> p.nam >> p.tim;
 
    que.push(p);
  }
 
  int total_tim = 0;
 
  while(!que.isEmpty()){
    Proc p = que.front();
    que.pop();
 
    if(p.tim <= q){
      total_tim += p.tim;
 
      cout << p.nam << ' ' << total_tim << endl;
    }else{
      total_tim += q;
      p.tim -=q;
 
      que.push(p);
    }
  }
 
  return 0;
}


Measured memory_bytes: 7008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
long long GCD(int a, int b){
    int r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main(void){
    int K;
    cin >> K;
    long long ans = 0;
    int a,b,c;
    a = b = c = 1;
    while(a <= K){
        b = c = 1;
        while(b <= K){
            c = 1;
            while(c <= K){
                int G = GCD(a,GCD(b,c));
                ans += G;
                c++;
            }
            b++;
        }
        a++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
///////////////////////////

#define N 200005
ll n;
vector<ll>v[N];
ll col[N];
void dfs(ll id,ll par){
    for(auto x:v[id]){
        if(x==par)continue;
        col[x]=3-col[id];
        dfs(x,id);
    }
}
int main(){fastio
    cin>>n;
    rep(i,1,n-1){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    col[1]=1;
    dfs(1,-1);
    ll s1=0,s2=0;
    rep(i,1,n){
        if(col[i]==1)s1++;
        else s2++;
    }
    if(s1>s2){
        swap(s1,s2);
        rep(i,1,n)col[i]=3-col[i];
    }
    ll ans[n+1];
    queue<ll>q1,q2,q3;
    rep(i,1,n){
        if(i%3==0)q3.push(i);
        else if(i%3==1)q1.push(i);
        else q2.push(i);
    }
    if(s1<=n/3){
        rep(i,1,n){
            if(col[i]==1){
                ans[i]=q3.front();q3.pop();
            }else{
                if(!q1.empty()){ans[i]=q1.front();q1.pop();}
                else if(!q2.empty()){ans[i]=q2.front();q2.pop();}
                else {ans[i]=q3.front();q3.pop();}
            }
        }
    }else{
        rep(i,1,n){
            if(col[i]==1){
                if(!q1.empty()){ans[i]=q1.front();q1.pop();}
                else{ans[i]=q3.front();q3.pop();}
            }else{
                if(!q2.empty()){ans[i]=q2.front();q2.pop();}
                else{ans[i]=q3.front();q3.pop();}
            }
        }
    }
    rep(i,1,n){
        cout<<ans[i]<<" ";
    }
    
    return 0;
}


Measured memory_bytes: 20352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  ll n, m;
  cin >> n >> m;
  if (n > m) {
    swap(n, m);
  }

  ll ans = 0;

  if (n == 1) {
    if (m == 1) {
      ans = 1;
    } else {
      ans = (m - 2);
    }
  } else {
    ans = (n - 2) * (m - 2);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
if n>=m:
    print(0)
else:
    D = [0]*(m-1)
    for i in range(1, m):
        D[i-1] = abs(X[i] - X[i-1])
    D.sort()
    print(sum(D[:m-n]))

Measured memory_bytes: 13960
#include<iostream>
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;

typedef pair<int,int> P;

int main()
{
  int n,x,y;
  char mp[9][9];
  int dx[4] = {-1,1,0,0};
  int dy[4] = {0,0,-1,1};
  
  cin >> n;

  for(int i = 0;i < n;i++){
    
    queue<P> que;

    for(int j = 0;j < 8;j++){
      cin >> mp[j];
    }
    //cin >> x >> y;
    scanf("%d %d",&x,&y);
    //for(int j = 0;j < 8;j++)

    que.push(P(x-1,y-1));
    while(!que.empty()){
      P now = que.front();que.pop();
      mp[now.second][now.first] = '0';
      for(int j = 0;j < 4;j++){
	for(int k = 1;k <= 3;k++){
	  int ny = now.second + dy[j] * k;
	  int nx = now.first + dx[j] * k;
	  if(0 <= nx && nx < 8 && 0 <= ny && ny < 8){
	    if(mp[ny][nx] == '1'){
	      que.push(P(nx, ny));
	      //mp[ny][nx] = '0';
	    }	  
	  }
	}
      }
    }
    cout << "Data " << i+1 << ":" << endl;
    for(int j = 0;j < 8;j++){
      cout << mp[j] << endl;
    }
  }
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  lli A,B;
  cin >> A  >>B;
  if(A==0||B==0)
    cout << "Zero" << endl;
  else if(A<0&&B>0)
    cout << "Zero" << endl;
  else if(A>0&&B<0)
    cout << "Zero" << endl;
  else if(A+B>0)
    cout << "Positive" << endl;
  else {
    if((B-A)%2==0)
    cout << "Negative" << endl;
    else
    cout << "Positive" << endl;      
  }
}


Measured memory_bytes: 256
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
INF = float('inf')
dp = [INF]*(H+1)
dp[0] = 0
for i in range(1,H+1):
  for k in AB:
    a = k[0]
    b = k[1]
    tmp = max(0,i-a)
    dp[i] = min(dp[i],dp[tmp]+b)
    
print(dp[H])

Measured memory_bytes: 43228
import qualified Data.ByteString.Char8 as C
import           Data.Maybe ( fromJust )
import qualified Data.Vector.Unboxed as U

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,y] <- getParms
  putStrLn $ otsdm n y

type Yen = Int
type Mai = Int
type Pochi = (Int,Int,Int) -- #s of 10000,5000,1000 bills

otsdm'
  :: Mai -> Yen -> [Pochi]
otsdm' n y
  = [(a,b,n-a-b) 
      | let a0 = y `quot` 10000
      , a <- [0 .. a0]
      , let b0 = (y - 10000*a) `quot` 5000
      , b <- [0 .. b0]
      ]

gok
  :: Pochi -> Yen
gok (a,b,c) = 10000*a +5000*b + 1000*c 

otsdm
  :: Mai -> Yen -> String
otsdm n y
  | U.null os   = "-1 -1 -1"
  | otherwise = show a ++ " " ++ show b ++ " " ++ show c
  where
    os = U.filter (\o -> y == gok o) $ U.fromList $ otsdm' n y
    (a,b,c) = U.head os

Measured memory_bytes: 2428
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,h[256];
char s[2333];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;i++)h[s[i]]=1;
	if(h['S']^h['N']||h['E']^h['W'])puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<algorithm>
typedef long long int64;
inline int64 getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int64 x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
const int N=3e5+1,mod=998244353;
int fac[N],ifac[N];
void exgcd(const int &a,const int &b,int &x,int &y) {
	if(!b) {
		x=1,y=0;
		return;
	}
	exgcd(b,a%b,y,x);
	y-=a/b*x;
}
inline int inv(const int &x) {
	int ret,tmp;
	exgcd(x,mod,ret,tmp);
	return (ret%mod+mod)%mod;
}
inline int power(int a,int k) {
	int ret=1;
	for(;k;k>>=1) {
		if(k&1) ret=(int64)ret*a%mod;
		a=(int64)a*a%mod;
	}
	return ret;
}
inline int C(const int &n,const int &m) {
	return (int64)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main() {
	int n=getint(),a=getint(),b=getint();
	int64 k=getint();
	for(register int i=fac[0]=1;i<=n;i++) {
		fac[i]=(int64)fac[i-1]*i%mod;
	}
	ifac[n]=inv(fac[n]);
	for(register int i=n;i>=1;i--) {
		ifac[i-1]=(int64)ifac[i]*i%mod;
	}
	int ans=0;
	for(register int i=0;i<=n&&(int64)a*i<=k;i++) {
		if((k-(int64)a*i)%b!=0) continue;
		const int64 j=(k-(int64)a*i)/b;
		if(j>n) continue;
		(ans+=(int64)C(n,i)*C(n,j)%mod)%=mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 100003;
int n, m, c[N], d[N], cnt;
LL ans[N], x[N], k;
bool vis[N];
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++) scanf("%lld", x + i), c[i] = i;
	for(Rint i = n;i;i --) x[i] -= x[i - 1];
	scanf("%d%lld", &m, &k);
	for(Rint i = 1;i <= m;i ++){
		int v; scanf("%d", &v); swap(c[v], c[v + 1]);
	}
	for(Rint i = 1;i <= n;i ++) if(!vis[i]){
		cnt = 0;
		for(Rint j = i;!vis[j];j = c[j]) vis[d[cnt ++] = j] = true;
		for(Rint j = 0;j < cnt;j ++)
			ans[d[j]] = x[d[(j + k) % cnt]];
	}
	for(Rint i = 1;i <= n;i ++){
		ans[i] += ans[i - 1];
		printf("%lld.0\n", ans[i]);
	}
}

Measured memory_bytes: 3840
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
 
 
int main(){
int n;
int d;
int x;
int a[101];
int i,j=1;
int temp=0;
int temp2=0;
scanf("%d",&n);
scanf("%d%d",&d,&x);
for(i=0;i<n;i++){
	scanf("%d",&a[i]);
	
}
for(i=0;i<n;i++){
	
	for(j=1;j<=d;j++){
		//printf("!%d\n",a[i]*j+1);
	if(a[i]*j+1<=d){
	temp2++;
	//printf("%d\n",temp2);
	}
	}
	temp2++;
	
	
}
printf("%d\n",temp2+x);
	return 0;
}

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

using namespace std ;

const int MAX = 110 ;

int arr[MAX][20] ;
int cost[MAX][20] ;

int ans = -2e9 ;
int n ;

void solve(int idx, int mask)
{
	if(idx == 10)
	{
		if(mask == 0)
			return ;
		int sum = 0 ;
		for(int i = 0 ; i < n ; ++i)
		{
			int cnt = 0 ;
			for(int j = 0 ; j < 10 ; ++j)
			{
				int x = mask & (1 << j) ;
				if(x > 0 && arr[i][j] == 1)
					cnt++ ;
			}
			sum += cost[i][cnt] ;
		}
		ans = max(ans , sum) ;
		return ;
	}
	solve(idx+1 , mask) ;
	solve(idx+1 , mask | (1 << idx)) ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
	{
		for(int j = 0 ; j < 10 ; ++j)
			cin>>arr[i][j] ;
	}
	for(int i = 0 ; i < n ; ++i)
	{
		for(int j = 0 ; j <= 10 ; ++j)
		{
			cin>>cost[i][j] ;
		}
	}
	solve(0,0) ;
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 256
x = []
y = []
5.times do
  s = gets.chomp
  if s[-1] == "0"
    x << s.to_i
  else
    y << s
  end
end
t = 0
x.each do |i|
  t += i
end
y.sort{|a,b| a[-1] <=> b[-1]}.map(&:to_i).reverse.each_with_index do |i, idx|
  if y.size-1 == idx
    t += i
  else
    t += (i.to_f/10).ceil*10
  end
end
p t

Measured memory_bytes: 1788
N,L = map(int,input().split())
A = list(map(int,input().split()))

flg = 0
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        last = i
        flg = 1
        break

if flg == 0:
    print('Impossible')
else:
    print('Possible')
    last += 1
    # x = list(range(last+1,N))
    x = list(range(N-1,last,-1))
    y = list(range(1,last))
    for a in x:
        print(a)
    for a in y:
        print(a)

    print(last)


Measured memory_bytes: 14060
# include <iostream>
# define MAX_W 102
# define MAX_H 102
# define Red 2 //????????????????????????????????¨??????????????????

int w, h;
int board[MAX_H][MAX_W];
int dy[6] = { 0, -1, -1, 0, 1,  1 };
int dx[2][6] = { { -1,  0,  1, 1, 1, 0 },{ -1, -1,  0, 1, 0, -1 } };


int dfs(int x, int y) {
	int res = 0;
	board[y][x] = Red;
	for (int i = 0; i < 6; ++i) {
		int nx = x + dx[( y+1 )% 2][i];
		int ny = y + dy[i];
		if (ny >= 0 && nx >= 0 && nx < (w + 2) && ny < (h + 2)) {
			if (board[ny][nx] == 0)
				res += dfs(nx, ny);
			else if (board[ny][nx] == 1)
				++res;
		}
	}
	return res;
}

int main() {
	std::cin >> w >> h;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j)
			std::cin >> board[i][j];
	}
	
	
	int res = dfs(0, 0);
	std::cout << res << std::endl;
	return 0;
}

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

using namespace std;

int main(){

	int n;
	cin >> n;

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

	return 0;
}



Measured memory_bytes: 256
mod = 1e9+7
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    m = {}
    N = int(raw_input())
    
    for i in range(1, N+1):
        s = str(i)
        first = s[0]
        last = s[-1]
        key = first + last
        m[key] = m.get(key, 0) + 1
    
    ans = 0
    
    #print(m)
    
    for key1 in m:
        for key2 in m:
            #if key1 == key2:
            #    continue
            if key1[0] == key2[1] and key1[1] == key2[0]:
                ans += m[key1] * m[key2]
    
    print(ans)
    
    
    

main()

Measured memory_bytes: 32668
# coding: utf-8
# Your code here!
import sys
N, M = map(int, input().split())

#入力がなければ1桁の0だけ答えとなる
if M == 0:
    if N == 1:
        print(0)
        sys.exit()
    elif N == 2:
        print(10)
        sys.exit()
    else:
        print(100)
        sys.exit()

mylist = [float('INF') for n in range(N)]

#print(mylist)

for n in range(M):
    s, c  = map(int, input().split())
    if mylist[s-1] == float('INF') or mylist[s-1] == c:
        mylist[s-1] = c
    #桁の重複があればだめ
    else:
        print(-1)
        sys.exit()
#print(mylist)
if N == 1 and mylist[0] == 0:
    print(0)
    sys.exit()


myans = ''
mycnt = 0
for m in mylist:
    #先頭が0はだめ
    if m == 0 and mycnt == 0:
        print(-1)
        sys.exit()
    #infの場合
    elif m == float('INF'):
        if mycnt != 0:
            myans += str(0)
        else:
            myans += str(1)
        mycnt += 1
    else:
        myans += str(m)
        mycnt += 1
print(myans)

Measured memory_bytes: 3064
K = int(input())
from math import gcd

sum_gcd = [0]*K
for i in range(1,K+1):
    c = 0
    for j in range(1,K+1):
        c += gcd(i,j)
    sum_gcd[i-1] = c
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        ans += sum_gcd[gcd(a,b)-1]

print(ans)

Measured memory_bytes: 64608
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <climits>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define FILL(mat, x) memset(mat, x, sizeof(mat))
#define BIT(n, b) ((n>>b) & 1)

#define INF 1<<31-1
using namespace std;

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

int n;
ll top[256], btm[256], dp[256][256];

ll rec(int lo, int up){
	
	ll res = INF;
	
	if(up <= lo)
		return 0;
	if(dp[lo][up] >= 0)
		return dp[lo][up];
	
	for(int k = lo+1; k <= up; ++k){
		ll tmp = rec(lo, k-1) + rec(k, up) + top[lo]* btm[k-1]* top[k]* btm[up];
		res = min(res, tmp);
	}
	
	return dp[lo][up] = res;	
}

int main(){
	
	cin >> n;
	
	for(int i = 0; i < n; ++i){	
		cin >> top[i] >> btm[i];
	}
	
	NCLR(dp);
	cout << rec(0,n-1) << endl;
	
	return 0;
}

Measured memory_bytes: 1688
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int res=0;
  int n;
  cin>>n;
  rep(i,n+1)
  {
    chmax(res,i&-i);
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
using namespace std;

int main()
{
  int N;
  scanf("%d", &N);
  int M;
  scanf("%d", &M);
  int ans = 1;
  for (int i = N; i <= M; ++i)
  {
    if (M % i == 0)
    {
      ans = M / i;
      break;
    }
  }
  printf("%d\n", ans);

  return 0;
}


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

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

struct BIT {
	BIT(int n) : s(n + 1), n(n) {}
	int sum(int k) {
		int r = 0;
		for (; k > 0; k -= k & -k) r += s[k];
		return r;
	}
	void add(int i, int v) {
		for (int k = i + 1; k <= n; k += k & -k) s[k] += v;
	}
	vector<int> s;
	int n;
};
int main()
{
	lolo N;
	cin >> N;
	vec A(N);
	vec A1((N + 1) / 2);
	map<lolo, bool> guuki;
	FOR(i, N) {
		cin >> A[i];
		guuki[A[i]] = (i % 2 == 0);
	}
	vec TOTAL(A);
	sort(ALL(TOTAL));

	lolo ans = 0;
	FOR(i, N) {
		if (guuki[TOTAL[i]] and i % 2 == 1)
			ans += 1;
	}
	cout << ans << endl;
	
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll a, b, n; cin >> a >> b >> n;
  ll x = min(b-1, n);
  cout << (a * x) / b - a * (x / b) << endl;

}
























Measured memory_bytes: 3608
n, m = map(int, input().split())
l = 1
r = n
for _ in range(m):
    l0, r0 = map(int, input().split())
    l = max(l, l0)
    r = min(r, r0)
    if l > r:
        print(0)
        exit()
print(r - l + 1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000;
struct query{int L,idx;};
struct sack{int v,w;};
int n,q,v[300000],w[300000],ans[100010];
vector<int>G[300000];
vector<query>qs[300010];
vector<sack>a;
bool used[300010];
int ma[4096];
vector<P>V;
int foo=10;
int solve(int L,int typ=0){
    int N=a.size();
    if(N<=foo){
        int ans=0;
        rep(i, (1 << N)) {
			int vsum = 0, wsum = 0;
			rep(j, N) {
				if ((i >> j) & 1) {
					vsum += a[j].v, wsum += a[j].w;
				}
			}
            if(wsum<=L)chmax(ans,vsum);
		}
        return ans;
    }
    if(N==foo+1){
        V.clear();
	    rep(i, (1 << foo)) {
		    int vsum = 0, wsum = 0;
		    rep(j,foo) {
				if ((i >> j) & 1) {
					vsum += a[j].v, wsum += a[j].w;
				}
			}
			V.push_back({ wsum,vsum });
		}
		sort(all(V));
        fill(ma,ma+4096,0);
		ma[0] = V[0].second;
		for (int i = 1; i < V.size(); i++) {
			ma[i] = max(ma[i - 1], V[i].second);
		}
    }
    if(typ==1)return -1;
		int ans = 0;
		rep(i, (1 << (N - foo))) {
			int vsum = 0, wsum = 0;
			rep(j, N - foo) {
				if ((i >> j) & 1) {
					vsum += a[foo + j].v, wsum += a[foo + j].w;
				}
			}
			if (wsum <= L) {
				ans = max(ans, ma[lower_bound(all(V), make_pair(L - wsum, INF)) - V.begin() - 1] + vsum);
			}
		}
        return ans;
}
void dfs(int x){
    used[x]=true;
    a.pb({v[x],w[x]});
    if(a.size()==foo+1)solve(100000,1);
    for(query Q:qs[x]){
        ans[Q.idx]=solve(Q.L);
    }
    for(int i:G[x]){
        if(!used[i]){
            dfs(i);
            a.pop_back();
        }
    }
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    for(int i=2;i<=n;i++){
        int j=i/2;
        G[i-1].pb(j-1);
        G[j-1].pb(i-1);
    }
    rep(i,n)cin>>v[i]>>w[i];
    cin>>q;
    rep(i,q){
        int V,L;
        cin>>V>>L;
        V--;
        qs[V].pb({L,i});
    }
    dfs(0);
    rep(i,q)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 31692
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        int a[] = new int[N+1];
        a[0] = 0;
        for(int i = 1; i < a.length; i++){
            a[i] = sc.nextInt();
            if(i%2 == 1 && a[i]%2 == 1){
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35616
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n;string s; cin>>n>>s;
    int ans = 0;
    rep(i,n-2){
        if(s[i] == 'A')if(s[i+1]=='B')if(s[i+2]=='C')++ans;
    }
    cout<<ans<<endl;return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
LL N, M, S;
LL A[50];
LL ceil(LL d, LL n) {return (d+n-1)/n;}
bool ok(LL x) {
  if(M < S-x) return false;
  LL s = 0;
  for(auto i=0; i<N; ++i) s += max(0ll, ceil(A[i]+x+1-N, N+1));
  return s <= x;
}
int main() {
  scanf("%lld", &N);
  M=N*(N-1);
  for(auto i=0; i<N; ++i) scanf("%lld", A+i), S+=A[i];
  LL l = -1, h = 1e18;
  while(l+1 < h) {
    LL m = (l+h)>>1;
    if(ok(m)) h = m;
    else      l = m;
  }
  for(auto x=max(0ll,h-N*N); x<=h; ++x) if(ok(x)) {
    printf("%lld\n",x);
    break;
  }
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int ans = 0;
    rep2(i, 1, n + 1) {
        if (i <= k) {
            ans += x;
        } else {
            ans += y;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1e9 + 7;
using namespace std;
//int v[100001] = {};

int main()
{
    IOS
    int n;
    cin >> n;
    ll sum = 0;
    for(int i=1;i<=n;i++)
    {
        ll a;
        cin >> a;
        sum += a-1;
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,max;
  cin >> A >> B;
  vector<int> V(3);
  V[0] = A+B;
  V[1] = A-B;
  V[2] = A*B;
  max = V[0];
  for(int i = 1; i<3; i++){
   if(V[i] > max) max = V[i]; 
  }
  
  cout << max << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define W 8
#define H 8

/*

¨ÅPA«ÅQ

A		E		G
¨ «		¨ «	 	  ¨ *
- *	 	  ¨	*	- -
---		-----	-----
@12		  121	    1 */

#define A 12
#define E 121
#define G 1 /*

D		F		C
  «		«		¨ ¨ ¨ *
- *		¨@«		-------
-		  *		    111
---		---
  2		212 */

#define D 2
#define F 212
#define C 111 /*

B
«
«
«
*
---
222 */

#define B 222 /*

*/

int main(void){
	char a[W][H]; int x, y, t=0;
	
	while(1){
		t=0;
		for(y=0; y<H; y++){ for(x=0; x<W; x++) a[x][y]=getchar()-'0'; getchar(); }
		for(y=0; y<H; y++) for(x=0; x<W; x++) if(a[x][y]!=0) goto end; end:
		while(1){
			if(a[x+1][y]!=0 && x+1<W) x++, t=t*10+1;
			else if(a[x][y+1]!=0 && y+1<H) y++, t=t*10+2;
			else break;
		}
		switch(t){
			case A: printf("A\n"); break;	case B: printf("B\n"); break;
			case C: printf("C\n"); break;	case D: printf("D\n"); break;
			case E: printf("E\n"); break;	case F: printf("F\n"); break;
			case G: printf("G\n"); break;
		}
		if(getchar()==EOF) return 0;	/*ósðÇÝÌÄ*/
	}
}

Measured memory_bytes: 0
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.19 21:00:50
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

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

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int A, B, doku;
    cin >> A >> B >> doku;
    
    // calculation
    if (A + B >= doku - 1) {
        cout << doku + B << "\n";
    } else {
        cout << A+B+1 + B << "\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
//
//        int a = 11;
//        int b = 5;
//        int c = 5;
        Scanner cin = new Scanner(System.in);
        int R = cin.nextInt();
        if (R<=1199) System.out.println("ABC");
        else if (R>1199&&R<2800) System.out.println("ARC");
        else System.out.println("AGC");
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
inline void read (int &x) {
	char ch = getchar(); int f = 0; x = 0;
	while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x;
} string str; map <string, int> mp; int ans; int n;
signed main() {
	read (n);
	for (int i = 1; i <= n; ++i) {
		cin >> str; 
		if (!mp[str]) ++ans; mp[str] = 1;
	} cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll D;
    cin >> D;
    vector<ll> C(26);
    vector<ll> T(D);
    vector<ll> last(26);
    REP(i,26)cin >> C[i];
    vector<vector<ll>> S(D,vector<ll>(26));
    REP(i,D){
        REP(l,26)cin >> S[i][l];
    }
    REP(i,D)cin >> T[i];
    REP(i,D)T[i]--;
    ll score = 0;
    REP(i,D){
        last[T[i]] = i+1;
        score += S[i][T[i]];
        REP(l,26){
            score -= C[l] * (i+1 -last[l]);
        }
        cout << score << "\n";
    }
}

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

int q, n;
int P[10010];
bool w;
int a, b;

void init(int N) {
  for (int i=0; i<N; i++) P[i] = i;
}

int root(int a) {
  if (P[a] == a) return a;
  return (P[a] = root(P[a]));
}

bool is_same_set(int A, int B) {
  return root(A) == root(B);
}

void unite(int A, int B) {
  P[root(A)] = root(B);
}

int main() {
  cin >> n >> q;
  init(n);
  for (int i=0; i<q; i++) {
    cin >> w >> a >> b;
    if (w) {
      if (is_same_set(P[a], P[b])) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    } else {
      unite(P[a], P[b]);
    }
  }
}


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

signed main() {
  string S;
  cin >> S; 
  for(int i=0; i<S.size()-1; i++) {
    if(S[i] == S[i+1]) {
      puts("Bad"); return 0;
    }
  }
  puts("Good");
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif



int N, K;
ulli h, minim = INF;
vector<ulli> hs;

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

	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> h;
		hs.push_back(h);
	}
	sort(hs.begin(), hs.end());
	for(int i = K-1; i < N; i++){
		minim = min(minim, hs[i] - hs[i-(K-1)]);
	}
	cout << minim;

	return 0;
}


Measured memory_bytes: 1400