akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<string.h>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f;
int che[505][505];
int road[505][505];
int main()
{
    int N,M,Q;
    scanf("%d %d %d",&N,&M,&Q);
    for(int i=1;i<=M;++i)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        che[l][r]++;
    }
    for(int i=N;i>0;--i)
        for(int j=1;j<=N;++j)
        road[i][j]=che[i][j]+road[i][j-1]+road[i+1][j]-road[i+1][j-1];
    for(int i=1;i<=Q;++i)
    {
        int q,p;
        scanf("%d%d",&q,&p);
        printf("%d\n",road[q][p]);
    }
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define ALL(v) v.begin(),v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }
using Graph = vector<vector<int>>;
using CP = std::complex<double>;
int main()
{
    double a, b;
    cin >> a >> b;
    double h, m;
    cin >> h >> m;
    h *= 5;
    h += m/12.0;
    double t = abs(h-m)*6;
    //cout << t << endl;
    const double pi = acos(-1.0);
    double rad= t*pi/180;
    double c = cos(rad);
    //if(c < 0) c *= -1.0;
    //cout << c << endl;

    double alpha = (h * 60 + m) / 720 * (pi * 2);
    double beta = m / 60 * (pi * 2);
    double theta = alpha - beta;
    //cout << theta << endl;

    double l = a*a+b*b-2.0*a*b*cos(rad);
    l = sqrt(l);
    cout << fixed << setprecision(10) << l << endl;
    //cout << l << endl;


    return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
long long a,b,c,d;

int main()
{
    cin>>a>>b>>c>>d;


    long long ans1=b-a+1;
    long long tmp=c*d/__gcd(c,d);

    long long res1=b/c-a/c;
    if(a%c==0)
        res1++;

    long long res2=b/d-a/d;
    if(a%d==0)
        res2++;

    long long res3=b/tmp-a/tmp;
    if(a%tmp==0)
        res3++;
    //cout<<ans1<<' ' <<res1<<' ' <<res2<<' ' <<res3<<endl;
    cout<<ans1-res1-res2+res3<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
import copy
N = int(input())
b = list(map(int, input().split()))
a = copy.copy(b)
a.insert(0, b[0])

for i in range(N-1):
    if a[i] > b[i]:
        a[i] = b[i]
    if a[i+1] > b[i]:
        a[i + 1] = b[i]
    else:
        continue
        
print(sum(a))
        

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

using namespace std;

int main(void) {
  int w, h, x, y;
  cin >> w >> h >> x >> y;

  cout << double(w) * double(h) / 2.0 << " " << ((x * 2 == w) && (y * 2 == h))
       << endl;
}

Measured memory_bytes: 256
def resolve():
    def Dijkstra(s, n, edge, inf=float("inf")):
        import heapq
        d = [inf] * n
        used = [False] * n
        d[s] = 0
        used[s] = True
        queue = []
        path = [-9999] * n
        for e in edge[s]:
            heapq.heappush(queue, e + [s])
        while len(queue):
            dist, point, before = heapq.heappop(queue)
            if used[point]:
                continue
            d[point] = dist
            used[point] = True
            path[point] = before
            for nextdist, nextp in edge[point]:
                if not used[nextp]:
                    heapq.heappush(queue, [dist + nextdist, nextp, point])
        return d, path
    n, m = map(int, input().split())
    inf = 10 ** 10
    from collections import defaultdict
    edge = defaultdict(list)
    for _ in range(m):
        x, y = [int(x) - 1 for x in input().split()]
        edge[x].append([1, y])
        edge[y].append([1, x])
    l, p = Dijkstra(0, n, edge, inf)
    if min(p[1:]) < -1:
        print("No")
    else:
        print("Yes")
        for i in p[1:]:
            print(i + 1)


if __name__ == '__main__':
    resolve()


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

int main(){
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	std::cout << ((abs(a - c) <= d || abs(a - b) <= d && abs(b - c) <= d) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

bool kaibun(string s,ll x,ll y){
    for (ll i=x;i<y;i++){
        if (s[i]!=s[y-1-i]){
            return false;
        }
    }
    return true;
}

int main(){
    ld n,ans;
    cin >> n;
    n=n/3;
    ans=n*n*n;
    cout << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=200005;

int n,cnt,last[N],p[N],sg[N],p1,p2,tim,arr[N];
bool vis[N];
struct edge{int to,next;bool del;}e[N];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void addedge(int u,int v)
{
	e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
}

int get_mex(int x)
{
	int ans;
	for (int i=last[x];i;i=e[i].next) if (!e[i].del) vis[sg[e[i].to]]=1;
	for (int i=0;;i++) if (!vis[i]) {ans=i;break;}
	for (int i=last[x];i;i=e[i].next) if (!e[i].del) vis[sg[e[i].to]]=0;
	return ans;
}

void dfs(int x)
{
	arr[x]=tim;
	for (int i=last[x];i;i=e[i].next)
		if (!arr[e[i].to]) dfs(e[i].to);
		else if (arr[e[i].to]==tim) p1=x,p2=e[i].to,e[i].del=1;
	sg[x]=get_mex(x);
}

int main()
{
	n=read();
	for (int i=1;i<=n;i++) p[i]=read(),addedge(p[i],i);
	for (int i=1;i<=n;i++) if (!arr[i]) tim++,dfs(i);
	int s1=get_mex(p1);
	vis[s1]=1;
	int s2=get_mex(p1);
	vis[s1]=0;
	if (sg[p2]!=s1) {puts("POSSIBLE");return 0;}
	sg[p1]=s2;
	int x=p1;
	while (x!=p2) x=p[x],sg[x]=get_mex(x);
	if (sg[p2]==s1) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>
#define INF 600001
void mergeSort(int *,int,int);
void merge(int *,int,int,int);
int cnt=0;

int main(){
  int i, n;
  int s[INF];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  
  mergeSort(s,0,n);

  for(i=0;i<n-1;i++){
    printf("%d ",s[i]);
  }
  
  printf("%d\n",s[i]);
  printf("%d\n",cnt);
  return 0;
}


void merge(int *A,int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  int R[INF],L[INF];
  
  n1 = mid - left;
  n2 = right - mid;
 
  for( i = 0 ;i< n1;i++){
    L[i] = A[left + i];
  }
  
  for( i = 0;i< n2;i++){
    R[i] = A[mid + i];
  }
  
  L[n1] = 999999999;
  R[n2] = 999999999;
  i = 0;
  j = 0;
  
  for (k = left;k< right;k++){
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      cnt++;
    }
    else {
      A[k] = R[j];
      j = j + 1;
      cnt++;
    }
  }
}


void mergeSort(int *A,int left,int right){
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}




Measured memory_bytes: 5616
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	S := nextBytes()

	dp := make([][]int, N+1)

	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, N+1)
	}
	for i := N - 1; i >= 0; i-- {
		for j := N - 1; j >= 0; j-- {
			if S[i] == S[j] {
				dp[i][j] = dp[i+1][j+1] + 1
			} else {
				dp[i][j] = 0
			}
		}
	}

	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			now := min(dp[i][j], j-i)
			ans = max(ans, now)
		}
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 207872
using System;
using System.Linq;

namespace _032_PlasticBoard
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			int rectangleCount = 0;
			int diamondCount = 0;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int[] inputNum = inputStr.Split (',').Select (int.Parse).ToArray ();

				bool isRectangle = inputNum[0] * inputNum[0] + inputNum[1] * inputNum[1] == inputNum[2] * inputNum[2];

				if (isRectangle)
				{
					rectangleCount++;
				}

				if (inputNum[0] == inputNum[1])
				{
					diamondCount++;
				}
			}

			Console.WriteLine (rectangleCount);
			Console.WriteLine (diamondCount);
		}
	}
}

Measured memory_bytes: 9380
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a,b;
    scanf("%ld%ld", &a, &b);

    printf("%ld\n", (a+b)%24);


    return 0;
}



Measured memory_bytes: 128
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    A=list(map(int,input().split()))
    p=list(map(int,input().split()))
    if A[1]==0:
        print(A[0])
        sys.exit()
    X=A[0]
    N=A[1]
    for i in range(N+100):
        X1=X-i
        X2=X+i
        if X1 not in p:
            print(X1)
            sys.exit()
        if X2 not in p:
            print(X2)
            sys.exit()
    

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
#include<iostream>
using namespace std;
int main()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(90);
double r,pi=3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
cin>>r;
r*=pi;
cout<<r*2<<endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
int main(){
  int i, j, n, t=0;
  cin >> n;
  pair<int, int> a[n];
  for(i=0; i<n; i++)
    cin >> a[i].second >> a[i].first;
  sort(a, a+n);
  for(i=0; i<n; i++){
    t+=a[i].second;
    if(a[i].first<t){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

pair<int, int> solve(string s) {
	int tot = 0;
	int mn = 0;
	for (auto x : s) {
		if (x == '(') tot++;
		else tot--;
		mn = min(mn, tot);
	}
	return {tot, mn};
}

string rp(string s) {
	reverse(s.begin(), s.end());
	for (auto &t : s) {
		if (t == '(') t = ')';
		else t = '(';
	}
	return s;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
		
	int n;
	cin >> n;
	vector<string> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	vector<pair<pair<int, int>, string>> pb;
	vector<pair<pair<int, int>, string>> nb;
	for (int i = 0; i < n; i++) {
		int tot, mn;
		tie(tot, mn) = solve(a[i]);
		if (tot >= 0) {
			pb.push_back({{mn, 0}, a[i]});
		} else {
			string s = rp(a[i]);
			tie(tot, mn) = solve(s);
			nb.push_back({{mn, 0}, s});
		}
	}
	sort(pb.rbegin(), pb.rend());
	sort(nb.rbegin(), nb.rend());
	string res;
	for (auto t : pb) {
		res += t.second;
	}
	reverse(nb.begin(), nb.end());
	for (auto t : nb) {
		res += rp(t.second);
	}
	{
		int tot, mn;
		tie(tot, mn) = solve(res);
		if (tot == 0 && mn >= 0) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
}


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

int main(){
char x;
cin >> x;
//if(x=='A'||x=='B'||x=='C'||x=='D'||x=='E'||x=='F'||x=='G'||x=='H'||x=='I'||x=='J'||x=='K'||x=='L'||x=='M'||x=='N'||x=='O'||x=='P'||x=='Q'||x=='R'||x=='S'||x=='T'||x=='U'||x=='V'||x=='W'||x=='X'||x=='Y'||x=='Z') cout << "A" << endl;
if(isupper(x)) cout << "A" << endl;
else cout << "a" << endl;


}

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

int main() {
    int N;
    cin >> N;
    int tmp = 2;
    while(true){
        if(N < tmp) break;
        tmp *= 2;
    }
    if(N == 1) {
        cout << 1 << endl;
    }else{
        cout << tmp / 2 << endl;
    }
}

Measured memory_bytes: 256
// Justice will be served
// شهید حاج قاسم سلیمانی

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

#define all(x) x.begin() , x.end()

#define PB push_back
#define F first
#define S second
#define _sz(x) (int)x.size()

#define debug(x) cerr << #x << " = " << x << endl

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

const int MAX_N = -1 ;
const int inf = 2e9 + 19 ;

int main() {
        ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
        int x , y ;
        cin >> x >> y ;
        cout << 6 - (x + y) ;
        return (0) ;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=998244353;
//const long long LMOD=154590409516822759;
const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Pil pair<int,long long>
#define Pli pair<long long,int>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Swp swap
#define Bre break
#define Beg begin
#define Upb upper_bound
#define Lwb lower_bound
#define Str string
int main()
{
	string st;
	cin>>st;
	int g=0,mx=0;
	for(int i=0;i<st.Sz();i++)
	{
		if(st[i]=='R')g++;
		else g=0;
		mx=max(mx,g);
	}
	Pf("%d",mx);
	return 0;
}

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

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

    int max = int(sqrt(n))+1;
    int s = 0;

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

    for (int x = 1; x <= max; ++x) {
        for (int y = 1; y <= max; ++y) {
            for (int z = 1; z <= max; ++z) {
                int f = x * x + y * y + z * z + x * y + y * z + z * x;
                if (f <= n) r[f] += 1;
            }
        }
    }

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

    return 0;
}



Measured memory_bytes: 3076
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
//#define mod 1000000007
#define mod 998244353


int N,M;
int A[200005],B[200005];

struct dijkstra_normal{
    int V;
    vector<pair<int,int> > *edges;
    dijkstra_normal(int N): V(N){
        edges=new vector<pair<int,int> >[V];
    }
    void push(int a,int b, int c){
        edges[a].pb( mp(b,c) );
    }
    int *solve(int start){
        int *d; 
        d=new int[V];
        int *bef;
        bef=new int[V];

        priority_queue< pair<int,int> , vector< pair<int,int> >, greater< pair<int,int> > > q;
        fill(d, d + V, LLINF);
        fill(bef, bef + V, LLINF);

        q.push(mp(0,start));
        d[start]=0;
        bef[start]=0;
        //printf("test");
        while(!q.empty()){
            pair<int,int> p=q.top();q.pop();
            int now=p.second;int cost=p.first;
            if(d[now]<cost)continue;
            rep(e,edges[now].size()){
                int to=edges[now][e].first;int cst=edges[now][e].second;
                if(d[to]>d[now]+cst){
                    bef[to]=now;//前を記録
                    d[to]=d[now]+cst;
                    q.push(mp(d[to],to));
                }
            }
        }
        printf("Yes\n");
        rep(i,V){
            if(i==0)continue;
            printf("%lld\n",bef[i]+1);
        }
        return d;
    }
    void clear(){
        delete[] edges;
    }
};

signed main(){
    scanf("%lld %lld",&N,&M);
    dijkstra_normal dijk(N);
    //printf("%lld %lld\n",N,M);
    rep(i,M){
        scanf("%lld %lld",&A[i],&B[i]);A[i]--;B[i]--;
        dijk.push(A[i],B[i],1);
        dijk.push(B[i],A[i],1);
    }

    double ans=0;
    //printf("test1");
    int *d=dijk.solve(0);
    dijk.clear();

    return 0;
}


Measured memory_bytes: 22188
import java.io.*;
public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		
		boolean issame = true;
		for (int i = 0; i < A.length(); i++) {
			if (A.charAt(i) != B.charAt(i)) {
				issame = false;
				break;
			}
		}
		
		if (issame) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
						
	}
}

Measured memory_bytes: 32544
#include <stdio.h>

int main() {
  char S[3];
  int priceOfRamen = 700;

  int i;

  scanf("%s", S);

  for (i = 0; i < 3; i++) {
    if (S[i] == 'o') {
      priceOfRamen += 100;
    }
  }

  printf("%d\n", priceOfRamen);
}


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

int main()
{
	int n,c=0;
	cin>>n;
	char s[n];
	cin>>s;
	for(int i=0;i<n;i++)
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
			c++;
	cout<<c<<endl;
	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
int numofbits5(long bits)
{
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}
ll dp[1 << 10][1000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  dp[0][0] = 1;
  rep(i,1 << 10){
    rep(k,10){
      if(i & (1 << k)) continue;
      rep(l,800){
        dp[i | (1 << k)][l + (numofbits5(i)+1) * k] += dp[i][l];
      }
    }
  }
  ll n,s;
  while(cin >> n >> s){
    ll ans = 0;
    if(s > 999) cout << ans << endl;
    else{
      rep(i,1 << 10){
        if(numofbits5(i) == n) ans += dp[i][s];
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 11224
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int k=1;
		while(k==1){
			int H=sc.nextInt();
			int W=sc.nextInt();
			if(H==0&&W==0)
				break;
			for ( int i = 0; i < H; i++ ){
			    for ( int j = 0; j < W; j++ ){
			        if((i%2==0&&j%2==1) || (i%2==1&&j%2==0))
			        	System.out.print(".");
			        else
			        	System.out.print("#");
			    }
			    System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 34416
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
//int read(){int a;scanf("%lld",&a);return a;}

const int mod = 1e9 + 7;

ll inv[200010];
ll fac[200010], fac_inv[200010];

ll C(int n, int k) {
	if (k < 0 or k > n) return 0;
	return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}

void comb_init()
{
	int N = 200005;
	inv[1] = 1;

	for (int i = 2; i <= N; ++i) {
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	}

	fac[0] = fac_inv[0] = 1;

	for (int i = 1; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % mod;
		fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
	}
}

int N;
int a[100010];
bool used[100010];

signed main()
{
	cin >> N;

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

	int l, r;

	rep(i, N + 1) {
		cin >> a[i];
		if (used[a[i]]) {
			r = i + 1;
			rep(j, i) {
				if (a[j] == a[i]) {
					l = j + 1;
					break;
				}
			}
		}
		used[a[i]] = true;
	}

	comb_init();

	int s = r - l - 1;

	rep1(k, N + 1) {
		int ans = 0;

		ans += C(N + 1 - 2, k);
		ans %= mod;

		if (k - 2 >= 0) {
			ans += C(N + 1 - 2, k - 2);
			ans %= mod;
		}

		if (N + 1 - 2 >= k - 1) {
			ans += C(N + 1 - 2, k - 1) * 2 % mod;
			ans %= mod;
		}

		if (N + 1 - s - 2 >= k - 1) {
			ans += (mod - C(N + 1 - s - 2, k - 1)) * 2 % mod;
			ans %= mod;
			ans += C(N + 1 - s - 2, k - 1);
			ans %= mod;
		}

		cout << ans << endl;
	}
}



Measured memory_bytes: 6784
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int N;
  cin >> N;
  int* W = new int[N];
  int sa=0, sb=0;
  for(int i=0; i<N; i++){
    cin >> W[i];
    sb += W[i];
  }
  int r = abs(sa-sb);
  for(int i=0; i<N-1; i++){
    sa += W[i];
    sb -= W[i];
    r = min(r, abs(sa-sb));
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 1; i <= (int)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int gcd(int a, int b, int c){
    int d;
    d = gcd(a, b);
    d = gcd(d, c);
    return d;
}

int main(){
    int k;
    ll ans = 0;
    cin >> k;

    rep(i, k){
        rep(j, k){
            rep(l, k){
                ans += gcd(i, j, l);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3588
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

X, A = map(int, input().split())
print(0 if X < A else 10)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) (v).begin() (v).end()
#define m 998244353
#define pb push_back
#define sz(v) (v).size()
#define ll long long

int main()
{
       ll n;
       cin>>n;
       ll a[n+1];
       ll p[n+1];
       ll tot=0;

       for(int i=1;i<=n;i++) cin>>a[i],a[i]%=2,p[i]=0;
       for(ll i=n;i>0;i--)
       {
               ll ret=0;
        for(ll j=i;j<=n;j+=i)
                if(p[j])
                        ret^=1;
        
        if(ret!=a[i])
                p[i]=1,tot++;
        

       }
       cout<<tot<<"\n";
       if(tot)
       for(int i=1;i<=n;i++)
       if(p[i])
        cout<<i<<" ";
}





Measured memory_bytes: 3968
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=8010,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,sum[5][N],ys[150];
ll ans;
char s[N];

int main() {
	qr(n); scanf("%s",s+1);
	ys['R']=1;ys['G']=2; ys['B']=3;
	for(int i=1;i<=n;i++) {
		sum[1][i]=sum[1][i-1];
		sum[2][i]=sum[2][i-1];
		sum[3][i]=sum[3][i-1];
		sum[ys[s[i]]][i]++;
	}
	for(int i=1;i<n;i++)
		for(int j=i+1,k;j<n;j++) if(s[i]^s[j]) {
			k=j*2-i;
			ans+=sum[6-ys[s[i]]-ys[s[j]]][n]-
				 sum[6-ys[s[i]]-ys[s[j]]][j]-
				 (ys[s[k]]==6-ys[s[i]]-ys[s[j]]);
		}
	pr2(ans);
	return 0;
}



Measured memory_bytes: 3812
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<string>
using namespace std;
int main(){
long long int a,b;
cin>>a>>b;
if(a<=0&&b>=0){
cout<<"Zero"<<endl;
}
else if(a>0&&b>0){
cout<<"Positive"<<endl;
}
else if(a<0&&b<0&&(b-a+1)%2==0)
cout<<"Positive"<<endl;
else if(a<0&&b<0&&(b-a+1)%2==1)
cout<<"Negative"<<endl;
}




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

// 小数点以下桁数
// fixed << setprecision(i)

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

int main()
{
  int n;
  vector<int> d(100000);

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> d[i];
  sort(d.begin(), d.begin() + n);
  cout << d[n/2] - d[n/2-1] << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

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

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    map<char, ll> M;

    REP(i, S.length()){
        M[S[i]]++;
    }
    if(M['a'] == 1 && M['b'] == 1 && M['c'] == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int, int>;

int main() {
    int N, K;
    cin >> N >> K;
    priority_queue<Pair> que;
    for(int i = 0; i < N; ++i) {
        int t, d;
        cin >> t >> d;
        que.emplace(d, t);
    }
    int64_t ans = 0, total = 0, neta = 0;
    vector<int> cnt(N + 1);
    priority_queue<Pair, vector<Pair>, greater<Pair>> sushi;
    auto push = [&](int d, int t) {
        if(!cnt[t]) neta++;
        else sushi.emplace(d, t);
        total += d;
        cnt[t]++;
    };
    auto pop = [&]() -> Pair {
        auto[d, t] = sushi.top(); sushi.pop();
        total -= d;
        cnt[t]--;
        if(!cnt[t]) neta--;
        return {d, t};
    };
    while(!que.empty()) {
        auto[d, t] = que.top(); que.pop();
        if(K) {
            K--;
            push(d, t);
        } else {
            if(sushi.empty()) break;
            auto[d2, t2] = pop();
            if(!cnt[t]) push(d, t);
            else push(d2, t2);
        }
        ans = max(ans, total + neta * neta);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5336
from sys import stdin
input = stdin.readline


def main():
  N, M = list(map(int, input().split()))
  A_B = [list(map(int, input().split())) for _ in range(M)]

  A_B.sort(key=lambda x: x[1])

  added = [A_B[0][1]]
  for i in range(1, M):
    pre_b = added[-1]
    a, b = A_B[i]
    if pre_b <= a:
      added.append(b)

  print(len(added))


if(__name__ == '__main__'):
  main()

Measured memory_bytes: 28644
(let ((n (read))
      (ans 0)
      (pre 0)
      temp
      (tempans 0))
  (dotimes (i n)
    (setf temp (read))
    (if (<= temp pre) (progn (incf tempans)
                             (setf ans (max ans tempans)))
        (setf tempans 0))
    (setf pre temp))
  (princ ans))


Measured memory_bytes: 57704
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    double x1, y1, x2, y2;
    double d;
    cin >> x1 >> y1 >> x2 >> y2;
    d = sqrt(pow(x2-x1, 2)+pow(y2-y1, 2));
    printf("%lf", d);
    return 0;
}


Measured memory_bytes: 3208
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
#define ll long long
using namespace std;
ll n, m, i, j, k, t=0;
int main(){
	cin>>n;
	m=n+1;
	while(m>=10){
		m/=10;
		t++;
	} 
	cout<<t*9+m-1;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lo;
lo a,b,c,d,e,x,y,n,m,t,a1[500005],a2[500005];
string s1,s2,s3,s4,s[105];
bool as=false,as2=false;
char c1,c2,c3,c4;
int main(){
    cin>>s1>>s2;
    for(lo i=0;i<3;i++){
        if(s1[i]==s2[i]){
            x++;
        }
    }
    cout<<x;
    return 0;
}

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

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

int main() {
    int k,a,b; cin >> k >> a >> b;
    bool ans = false;
    for(int i = 1; i <= 1000; i++){
        if(a <= k*i && k*i <= b) ans = true;
    }
    if(ans){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3632
// -_-
#include <bits/stdc++.h>
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mod 1000000007
#define  sort1(v) sort(v.begin(), v.end()) 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;

 
signed main() 
{

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

	read(n);

	double p[n+1];
	fori(i, 1, n) cin >> p[i];

	double dp[n+1][n+1];

	dp[1][0] = 1-p[1];
	dp[1][1] = p[1];

	fori(i, 2, n)
	{
		fori(j, 0, i)
		{
			if(j == 0) dp[i][j] = dp[i-1][j]*(1-p[i]);
			else if(j == i) dp[i][j] = dp[i-1][i-1]*p[i];
			else dp[i][j] = (dp[i-1][j]*(1-p[i])) + (dp[i-1][j-1]*p[i]);
		}
	}
	double ans = 0;
	fori(i, (n+1)/2, n) ans += dp[n][i];
	cout << setprecision(10) << ans;

	return 0;
}

Measured memory_bytes: 70400
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1046527;
const int NIL=-1;
int n,k;
ll w[100005];
int half_find(ll x)
{
    int i=0;
    for(int j=0;j<k;j++)
    {
        ll ent=0;
        while(ent+w[i]<=x)
        {
            //cout<<ent<<endl;
            ent+=w[i];
            i++;
            if(i==n)
                return n;
        }
    }
    return i;
}
int main()
{
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&w[i]);
    }
    //sort(w,w+n);
    ll ant=0;
    ll l=0,r=1e9;
    while(l<r-1)
    {
        //cout<<1;
        ll mid=(l+r)/2;
        //cout<<half_find(mid);
        if(half_find(mid)>=n)
            r=mid;
        else
            l=mid;
    }
    printf("%lld\n",r);
    return 0;
}



Measured memory_bytes: 3988
/*
 * atcoder/abc133_3rd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * a_1 + a_2 + ... + a_N = b_1 + b_2 + ... + b_N = S
 * b_1 = S - (b_2 + b_3 + ... + b_N)
 * a_i = (b_i + b_i+1) / 2より、
 * b_1 = S - 2 * (a_2 + a_4 + ... + a_N-1)
 *
 * b_i+1 = 2 * a_i - b_i
 */
int N;
vector<ll> A, B;
void solve() {
  cin >> N;
  A.resize(N);
  B.resize(N);
  B[0] = 0;
  loop(n,0,N) {
    cin >> A[n];
    B[0] += A[n];
    if (n%2==1) B[0] -= 2 * A[n];
  }

  loop(b_i,1,N) {
    B[b_i] = 2 * A[b_i-1] - B[b_i-1];
  }
  dump(B);
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

int main (){
    int n,c,b,f,r,v,i,j,k,apart[5][4][11]={};
    cin >> n;
    for( c = 0; c < n; c++){
        cin >> b >> f >> r >> v;
        if (b == 1){
            i = 1;
            j = f;
            k = r;
            apart[i][j][k] = apart[i][j][k] + v;
        }
        else if (b == 2){
            i = 2;
            j = f;
            k = r;
            apart[i][j][k] = apart[i][j][k] + v;
        }
        else if (b == 3){
            i = 3;
            j = f;
            k = r;
            apart[i][j][k] = apart[i][j][k] + v;
        }
        else if (b == 4){
            i = 4;
            j = f;
            k = r;
            apart[i][j][k] = apart[i][j][k] + v;
        }
    }
    for (i = 1; i < 4; i++){
        for (j = 1; j < 4; j++ ){
            for (k = 1; k < 11; k++){
                cout << " " << apart[i][j][k];
            }
        cout << '\n';        
        }
        cout << "####################" << '\n';
    }
    for (j = 1; j < 4; j++){
        for (k = 1; k < 11; k++){
            cout << " " << apart[4][j][k];
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int n, A[21];

//O(n^2)
int solve(int i, int m) {
	if (m == 0)return 1;
	if (i >= n)return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> A[i];
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int m; cin >> m;
		if (solve(0, m))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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 MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int n;
	cin >> n;

	cout << 0 << endl;
	string s1;
	cin >> s1;
	if(s1 == "Vacant")return 0;
	string x = s1;
	int S = 0;
	int G = n-1;

	while(1){
		int nx = (S+G)-(S+G)/2;
		cout << nx << endl;
		string s;
		cin >> s;
		if(s == "Vacant")return 0;
		if((s == x && S%2 == nx%2) || (s != x && S%2 != nx%2)){
			S = nx;
			x = s;
		}else{
			G = nx-1;
		}
	}
	



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://abc146.contest.atcoder.jp/tasks/abc146_d

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

main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];

  auto b=a;
  sort(b.begin(),b.end());
  ll midr=n/2;
  ll midl=n/2-1;
  ll ans=b[midr]-b[midl];
  cout<<(ans)<<endl;


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
namespace mp = boost::multiprecision;
using ll = mp::cpp_int;
using namespace std;

ll lcm( ll x, ll y ){
	return x*y/__gcd(x, y);
}

int main(){
	int n; cin >> n;
	vector<ll> t(n);
	for( auto &k : t ) cin >> k;
	for( int i = 1; i < n; ++i ){
		t[i] = lcm( t[i-1], t[i] );
	}
	cout << t[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define loop(i, a, b) for(li i=a; i<=b; i++)
#define stuff ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long li;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<li, li> lii;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ii> vii;
typedef vector<lii> vlii;
li mod = 1e9+7;
li expo(li base, li exponent)
{
	li ans=1;
	while(exponent)
	{
		if(exponent&1) ans = (ans*base)%mod;
		base = (base*base)%mod;
		exponent >>= 1;
	}
	return ans;
}
li gcd(li x, li y)
{
	if(y==0) return x;
	return gcd(y, x%y);
}


typedef tree<li, null_type, less<li>,
rb_tree_tag, tree_order_statistics_node_update> ordered_set;


vector<li> ar;
li n, m, q;
vector<pair<lii, lii> > qu;
li ans=0;
void calc(li pre, li in)
{
	if(in==n)
	{
		li tmp=0;
		for(auto pr : qu)
		{
			li a=pr.fi.fi, b=pr.fi.se, c=pr.se.fi, d=pr.se.se;
			if(ar[b-1]-ar[a-1]==c) tmp+=d;
		}
		ans = max(ans, tmp);
		return ;
	}
	for(li i=pre; i<=m; i++)
	{
		ar.pb(i);
		calc(i, in+1);
		ar.pop_back();
	}
}
int main()
{
	stuff;
	// #ifndef ONLINE_JUDGE 
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// freopen("error.txt", "w", stderr);
	// #endif

	cin >> n >> m >> q;
	qu.resize(q);
	loop(i, 0, q-1)
	{
		cin >> qu[i].fi.fi >> qu[i].fi.se >> qu[i].se.fi >> qu[i].se.se;
	}
	calc(1, 0);
	cout << ans;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <vector>

int main()
{
	double velocity = 0;
	while (std::cin >> velocity) {
		double time = velocity / 9.8;
		double y = 4.9 * time * time;
		int floor = static_cast<int>(y / 5.0) + 2;
		std::cout << floor << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define vi vector<int>
#define pb push_back
#define p push
#define sll stack<long long>
#define qll queue<long long>
#define vll vector<long long>
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define fork(n) for(int k=0;k<n;k++)
#define fori1(n) for(int i=1;i<n;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pi 3.14159265358979323
#include <math.h>
#define yn(n) if(n)cout<<"yes\n";else cout<<"no\n";
#define Yn(n) if(n)cout<<"Yes\n";else cout<<"No\n";
#define YN(n) if(n)cout<<"YES\n";else cout<<"NO\n";
#define mp   make_pair 
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll sum = 0;
int md(int n){
	if(n>0)return n;
	else return -n;
}
string str1,str2;
void solve(){
	ll n,d;cin>>n;
	if(n%2==0){
		cout<<"-1\n";return;
	}
	if(n==7||n==1){
		cout<<"1\n";return;
	}
	ll ans=2;
	ll rem=77%n;ll r2=10%n;
	fori(12345671){
		if(rem==0)break;
		r2=(10*r2)%n;
		rem=((7%n)*r2+rem)%n;
		ans++;
	}
	if(ans==12345673)cout<<"-1\n";
	else cout<<ans;
}


int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
 
     cin.tie(0);
    ios::sync_with_stdio(false);
   
	
	int t;
	t=1;
	//cin >> t;
	while(t--){
		solve();
	}	
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

Measured memory_bytes: 3604
long m,r=1e9,l,c,s,i,N,a[1<<17];
main(){
	for(;~scanf("%d",a+i++););
	for(;r-l>1;c>*a*(*a+1)/4?r=m:(l=m)){
		int b[2<<17]={};
		m=l+r>>1;b[s=*a]=1;
		for(N=c=i=0;i<*a;b[s]++)c+=N+=a[++i]>m?-b[++s]:b[s--];
	}
	printf("%d",r);
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    long long n, q;
    cin >> n;
    vector<long long> a(n);
    
    for(int i=0;i<n;i++)
        cin >> a[i];

    cin >> q;
    for (int i = 0; i < q; i++)
    {
        long long com,b,e;
        cin >> com >> b >> e;
        if(com == 0)
            cout << *min_element(a.begin()+b,a.begin()+e) << endl;
        else if (com == 1)
            cout << *max_element(a.begin() + b, a.begin() + e) << endl;
    }

    return 0;
}


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x  (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

const int N=1e5+5;
vector<int>V[N];
int vis[N];
stack<int>st;

void dfs(int s){
    vis[s]=1;
    for(int u:V[s]) if(!vis[u]) dfs(u);
    st.push(s);
}

int dis[N];
int call(int s){
    vis[s]=1;
    int mx=0;
    for(int u:V[s]) {
        if(!vis[u]) mx=max(mx,1+call(u));
        else mx=max(mx,1+dis[u]);
    }
    return dis[s]=mx;
}

int main()
{
    int n,m;
    cin >> n >> m;
    FOR(i,1,m){
        int u,v;
        cin >> u >> v;
        V[u].pb(v);
    }
    FOR(i,1,n) if(!vis[i]) dfs(i);
    MEM(vis,0);
    int ans=0;
    while(!st.empty()){
        int u=st.top();
        st.pop();
        if(!vis[u]) ans=max(ans,call(u));
    }
    cout << ans;
}


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

int state[200005];
int a[200005];
int main() {


	long long n, k;

	for (int i = 0; i < 200005; i++) {
		state[i] = -1;
	}

	cin >> n >> k;


	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int cnt = 0;
	int now = 1;
	state[now] = 0;
	now = a[1];
	bool jyun = true;
	while (1) {
		cnt++;

		if (cnt >= k) {
			jyun = false;
			break;
		}
		else if (state[now] == -1) {
			state[now] = cnt;
			now = a[now];
		}
		else break;
		
	}
	int ans;
	if (jyun == true) {
		int jyunkan = cnt - state[now];
		long long kd = k - state[now];

		long long amari = kd % jyunkan;
		
		for (int i = 1; i < 200005; i++) {
			if (state[i] == state[now] + amari) {
				ans = i;
				break;
			}
		}
	}
	else {
		ans = now;
	}
	//cout << now << endl;
	//for (int i = 0; i <= n; i++) {
	//	cout << state[i] << " ";
	//}
	//cout << endl;
	//cout << jyunkan << endl;
	cout << ans << endl;



}

Measured memory_bytes: 5152
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n;
string s, t;

int main() {
    fast_io;

    cin >> n >> s >> t;
    for (ll i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }

    return 0;
}
/*

*/


Measured memory_bytes: 256