akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
	string s;
	int ans = 0;
	cin >> s;
	string prev;
	int n = s.length();
	int i = 0;
	while(i<n){
	    if(s[i]!=s[i+1]){
	        ans++;
	        i++;
	    }
	    else if(i+2<n && s[i]==s[i+1]){
	        ans+=2;
	        i+=3;
	    }
	    else{
	        ans++;
	        break;
	    }
	}
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	string x;cin>>x;
	int n=x.size(),tnt=0,ans=n;
	for(int i=n-1;i>=0;i--){
		if(x[i]=='T') tnt++;
		else if(x[i]=='S'&&tnt>0){
			tnt--;
			ans-=2;
		}
	}

	cout<<ans<<"\n";
}

Measured memory_bytes: 640
import math
import functools
N,X = map(int,input().split())
A = list(map(int,input().split()))
mylist=[abs(X-A[0])]

for i in range(len(A)-1):
    mylist.append(abs(A[i+1]-A[i]))

print(functools.reduce(math.gcd, mylist))

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

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

  int c, t;
  int ans = INT_MAX;
  for(int i = 0;i < n;i++){
    cin >> c >> t;
    if(T >= t){
      ans = min(ans, c);
    }
  }

  if(ans < INT_MAX){
    cout << ans << endl;
  }else{
    cout << "TLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for D - I hate Factorization
	var X int
	fmt.Scan(&X)

	for A := -1000; A <= 1000; A++ {
		for B := -1000; B <= 1000; B++ {
			if (A*A*A*A*A)-(B*B*B*B*B) == X {
				fmt.Println(A, B)
				return
			}
		}
	}
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
  string s;
  cin >> s;

  cout << ((s[0] == '7' || s[1] == '7' || s[2] == '7') ? "Yes" : "No") << endl;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}

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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1e18+1;

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

	while ( n-- ) {
		int a, b;
		cin >> a >> b;
		bool flag = a < b;
		while ( a != b ) {
			cout << a << " ";
			if ( flag ) {
				if ( a == 9 ) {
					a = 5;
					flag = false;
				}
				else a++;
			} else {
				if ( a == 0 ) {
					a = 1;
					flag = true;
				} else if ( a == 9 ) {
					a = 5;
				} else {
					a--;
				}
			}
		}
		cout << b << endl;
	}
	return 0;
}



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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
int takahasi=A;
  int aoki=C;
  while(takahasi>0&&aoki>0){
   aoki=aoki-B;
    if(aoki<=0){
     cout<<"Yes"<<endl; 
    break;
    }
    takahasi=takahasi-D;
    if(takahasi<=0){
     cout<<"No"<<endl; 
    break;
    }  
  }
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

#define ll long long 
using namespace std;


int main(){
    ll N,D,cnt = 0;
    cin >> N >> D;
    int ans = N/(2*D+1);
    if(N%(2*D+1) != 0)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
function move(x,arr){
var d1=arr[0];
var d2=arr[1];
var d3=arr[2];
var d4=arr[3];
var d5=arr[4];
var d6=arr[5];
var after=[];
if(x=="N")after=[d2,d6,d3,d4,d1,d5];
if(x=="S")after=[d5,d1,d3,d4,d6,d2];
if(x=="E")after=[d4,d2,d1,d6,d5,d3];
if(x=="W")after=[d3,d2,d6,d1,d5,d4];
return after;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var dice=Arr[0].split(" ").map(Number);
Arr.shift();
Arr.shift();
var NSEW="NSEW".split("");

Arr.forEach(function(v){
   var a=(v.split(" "))[0]-0;
   var b=(v.split(" "))[1]-0;
   while((dice[0]==a && dice[1]==b)==false){
      var r = Math.floor(Math.random () * 4) ;
      dice=move(NSEW[r],dice)
   }
   console.log(dice[2]);
});

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

vector<tuple<int, int, int> > v;
int X, K, Q;
int rs[100100];

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

    std::cin >> X;
    std::cin >> K;
    for(int i=1;i<=K;++i){
        std::cin >> rs[i];
        v.emplace_back(rs[i], 2, -1);
    }
    std::cin >> Q;
    for(int i=0;i<Q;++i){
        int t, a;
        std::cin >> t >> a;

        v.emplace_back(t, 1, a);
    }

    sort(v.begin(), v.end());
    
    ll l = 0, u = X, s = 0;
    int lastTime = 0;
    bool reversed = false; // Aが下のとき，true
    for(int i=0;i<v.size();++i){
        int t, qt, some;
        tie(t, qt, some) = v[i];

        int passedTime = t - lastTime;
        if(qt == 1){
            // 最後に砂時計を返したときまで + それから で計算
            ll res = max(min<ll>(some, u), l) + s;
            if(!reversed){
                res -= passedTime;
            }else{
                res += passedTime;
            }

            res = max(min<ll>(res, X), 0ll);
            std::cout << res << std::endl;
        }else{
            if(!reversed){
                if(l + s <= passedTime){
                    if(passedTime - s >= u){
                        l = u = s = 0;
                    }else{
                        l = passedTime - s;
                        s = s - passedTime;
                    }
                }else{
                    s = s - passedTime;
                }
            }else{
                if(u + s >= X - passedTime){
                    if(X - passedTime - s <= l){
                        l = u = X;
                        s = 0;
                    }else{
                        u = X - passedTime - s;
                        s = s + passedTime;
                    }
                }else{
                    s = s + passedTime;
                }
            }

            reversed = !reversed;
            lastTime = t;
        }
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define INF 1000000000000000
#define MAXN (int)(1e7)+1
#define MOD 1000000007

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pwi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector< vector<pair<int,lli > > > wGraph;
typedef vector<vector<int> > graph;
//typedef vector<vector<int> > matrix;

int main(){

    /*ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(4);*/

    int n;
    cin>>n;

    int ar[n][3];
    for(int i = 0;i<n;++i){
        cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    }

    int dp[n+1][3];

    for(int i = 0;i<=n;++i){
        if(i == 0){
            dp[i][0] = 0;
            dp[i][1] = 0;
            dp[i][2] = 0;
        }else{
            dp[i][0] = max(dp[i-1][1]+ar[i-1][1],dp[i-1][2]+ar[i-1][2]);
            dp[i][1] = max(ar[i-1][0]+dp[i-1][0],ar[i-1][2]+dp[i-1][2]);
            dp[i][2] = max(ar[i-1][0]+dp[i-1][0],ar[i-1][1]+dp[i-1][1]);
        }
    }

    cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<endl;

    return 0;
}


Measured memory_bytes: 2560
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    double r;
    cin >> r;
    cout << setprecision(10);
    cout << 2 * r *  M_PI << endl;
    return 0;
}

Measured memory_bytes: 3788
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N=sc.nextInt(),M=sc.nextInt(),s[]=new int[M],c[]=new int[M];
		Map<Integer,Integer> a=new HashMap<Integer,Integer>();
		int ans=0;
		for(int i=0;i<M;i++) {
			s[i]=sc.nextInt();
			c[i]=sc.nextInt();
			if(!a.containsKey(s[i]-1)) {
				a.put(s[i]-1, c[i]);
			}else {
				if(a.get(s[i]-1)!=c[i]) {
					ans=-1;
					break;
				}
			}
		}
		if(a.containsKey(0)&&N!=1)if(a.get(0)==0)ans=-1;
		if(M==0&&N==1) ans=0;
		else if(ans!=-1) {
			for(int i=0;i<N;i++) {
				if(a.containsKey(i)) {
					ans+=a.get(i)*(int)Math.pow(10,N-i-1);
				}else if(i==0){
					ans+=(int)Math.pow(10, N-1);
				}
			}
		}
		System.out.println(ans);
	}
}

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

int main() {
  int k;
  string s;

  cin >> k >> s;

  if (k >= (int)s.size())
    cout << s;
  else {
    for (size_t i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "...";
  }
}

Measured memory_bytes: 3584
IDENTIFICATION DIVISION.
PROGRAM-ID. 158B.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(100).
01 N          PIC 9(19).
01 A          PIC 9(18).
01 B          PIC 9(18).
01 X          PIC 9(18).
01 Y          PIC 9(18).
01 SUM-A      PIC 9(19).
01 SUM-B      PIC 9(19).
01 CNT        PIC 9(18).
01 BK-CNT     PIC 9(19).

01 OUT-CNT    PIC Z(18)9.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO N A B.
    
  COMPUTE CNT = N / (A + B)
 
  EVALUATE TRUE
    WHEN A = 0 
      MOVE 0 to OUT-CNT
    WHEN B = 0
      MOVE N TO OUT-CNT
    WHEN OTHER
      COMPUTE SUM-A = A * CNT
      COMPUTE SUM-B = B * CNT

      PERFORM UNTIL (N <= SUM-A + SUM-B)
        COMPUTE SUM-A = SUM-A + A
        COMPUTE SUM-B = SUM-B + B
      END-PERFORM

      COMPUTE BK-CNT = SUM-A + SUM-B - N
      IF (BK-CNT <= B)
        MOVE SUM-A TO OUT-CNT 
      ELSE
        COMPUTE OUT-CNT = SUM-A - (BK-CNT - B)
      END-IF
  END-EVALUATE.
      
  DISPLAY OUT-CNT.
 
MAIN-EXIT.
  STOP RUN.


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

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

    set<string> S;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 19120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n,k,ans=0;cin>>n>>k;
  rep(i,n){
    int a;cin>>a;
    if(a>=k)ans++;
  }
  cout<<ans<<endl;
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  char b;
  cin >> b;
  
  if(b == 'A') cout << 'T' << endl;
  if(b == 'T') cout << 'A' << endl;
  if(b == 'C') cout << 'G' << endl;
  if(b == 'G') cout << 'C' << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int a = 0;
		int b = 0;
		int c = 0;
		
		for(int i = 0 ; i < n ; i++) {
			int x = sc.nextInt();
			if(x % 2 != 0) {
				a++;
			}
			if(x % 4 == 0) {
				b++;
			}
			if(x % 2 == 0 && x % 4 != 0) {
				c++;
			}
		}
		
		if(b >= a) {
			System.out.println("Yes");
		}
		
		if(b < a) {
			if(a - b == 1 && c == 0) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}

	}

}


Measured memory_bytes: 47796
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])

for i in range(M):
    b.append(b[i] + B[i])
    
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 133924
import java.util.*;
class  Main{
	Scanner sc= new Scanner(System.in);
	void aaaa(){
		int gundam=0;
		int n=sc.nextInt();
		int[] N=new int[n];
		for(int i=0;i<n;i++)N[i]=sc.nextInt();
		int q=sc.nextInt();
		for(int i=0;i<q;i++){
			int Q=sc.nextInt();
			int L=0;
			int R=n-1;
			while(N[L]<=Q&&Q<=N[R]){
				int cent=(L+R)/2;
				if(N[cent]==Q){
					gundam++;
					break;
				}else if(N[cent]>Q)R=cent-1;
				else L=cent+1;
			}
		}
		System.out.println(gundam);
	}
	public static void main(String[]args){
		new Main().aaaa();
	}
}

Measured memory_bytes: 76308
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (200010)
#define P (998244353)
int n,x[N],y[N],p[N],ul[N],ur[N],dl[N],dr[N],tmp[N],ans,a,b,c,d,pw[N]{1};
void cdq(int l,int r);
signed main(){
	Rd(n);
	Frn1(i,1,n)Rd(x[i]),Rd(y[i]),p[i]=i,pw[i]=(pw[i-1]<<1)%P;
	ans=n*pw[n-1]%P,sort(p+1,p+n+1,[](int a,int b){return x[a]<x[b];}),cdq(1,n);
	Frn1(i,1,n){
		a=pw[ul[i]]-1,b=pw[ur[i]]-1,c=pw[dl[i]]-1,d=pw[dr[i]]-1;
		ans+=a*d%P+b*c%P;
		ans+=a*b%P*c%P+a*b%P*d%P+a*c%P*d%P+b*c%P*d%P;
		ans=(ans+a*b%P*c%P*d%P)%P;
	}
	wr(ans),exit(0);
}
void cdq(int l,int r){
	if(l==r)return;
	int md((l+r)>>1);
	cdq(l,md),cdq(md+1,r);
	int i(l),j(md+1),k(l);
	while(i<=md||j<=r){
		if(j>r||i<=md&&y[p[i]]<y[p[j]])dr[p[i]]+=j-md-1,ur[p[i]]+=r-j+1,tmp[k++]=p[i++];
		else dl[p[j]]+=i-l,ul[p[j]]+=md-i+1,tmp[k++]=p[j++];
	}
	copy(tmp+l,tmp+r+1,p+l);
}

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

using namespace std;

int main() {
    long long n;
    cin >> n;
    long long max_i = 0;
    for (long long i = 1; i <= static_cast<long long>(sqrt(n)); ++i) {
        if (n%i == 0) {
            max_i = i;
        }
    }
    cout << max_i - 1 + (n/max_i) - 1 << endl;
    //long long m = static_cast<long long>(sqrt(n));
    //if (n == m*m) {
    //    cout << 2*m-2 << endl;
    //}
    //long long minus_ans;
    //while (true) {
    //    if (n%m == 0) {
    //        minus_ans = n/m+m-2;
    //        break;
    //    }
    //    --m;
    //}
    //long long plus_ans;
    //m = static_cast<long long>(sqrt(n));
    //while (true) {
    //    if (n%m == 0) {
    //        plus_ans = n/m+m-2;
    //        break;
    //    }
    //    ++m;
    //}

    //cout << min(minus_ans, plus_ans) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, k;
    std::cin >> n >> k;
    std::vector<i64> a(n), f(n);
    for (auto &e : a) std::cin >> e;
    for (auto &e : f) std::cin >> e;

    std::sort(f.begin(), f.end());
    std::sort(a.begin(), a.end(), std::greater<>());

    i64 l = -1, r = 0;
    for (int i = 0; i < n; i++) r = std::max(r, a[i] * f[i]);
    while (r - l > 1) {
        i64 mid = (l + r) / 2, ss = 0;
        for (int i = 0; i < n; i++) {
            i64 t = (a[i] * f[i] - mid + f[i] - 1) / f[i];
            t = std::max(t, 0ll);
            ss += t;
        }
        if (ss <= k) r = mid;
        else l = mid;
    }

    std::cout << r << std::endl;

    return 0;
}


Measured memory_bytes: 3456
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  l,x = map(int,input().split())
  c.append((l-x,l+x))
  
from operator import itemgetter
c = sorted(c,key=itemgetter(0))
c = sorted(c,key=itemgetter(1))

ans = 1
chk = c[0][1]
for i,j in c:
  if i >= chk:
    ans +=1
    chk = j
    
print(ans)

Measured memory_bytes: 19124
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;


template<lint mod>
struct Int_{
  unsigned x;
  unsigned mpow(Int_ a,unsigned k){
    Int_ res=1;
    while(k){
      if(k&1) res=res*a;
      a=a*a;
      k>>=1;
    }
    return res.x;
  }
  unsigned inverse(Int_ a){
    return mpow(a,mod-2);
  }
  Int_(): x(0) { }
  Int_(long long sig) {
    int sigt=sig%mod;
    if(sigt<0) sigt+=mod;
    x=sigt;
  }
  unsigned get() const { return (unsigned)x; }
  
  Int_ &operator+=(Int_ that) { if((x += that.x) >= mod) x -= mod; return *this; }
  Int_ &operator-=(Int_ that) { if((x += mod - that.x) >= mod) x -= mod; return *this; }
  Int_ &operator*=(Int_ that) { x = (unsigned long long)x * that.x % mod; return *this; }
  Int_ &operator=(Int_ that) { x=that.x; return *this;}
  Int_ &operator/=(Int_ that) { x=(unsigned long long) x * inverse(that.x)%mod; return *this;}
  bool operator==(Int_ that) const { return x==that.x; }
  bool operator!=(Int_ that) const { return x!=that.x; }

  Int_ operator-() const { return Int_(0)-Int_(*this);}
  Int_ operator+(Int_ that) const { return Int_(*this) += that; }
  Int_ operator-(Int_ that) const { return Int_(*this) -= that; }
  Int_ operator*(Int_ that) const { return Int_(*this) *= that; }
  Int_ operator/(Int_ that) const { return Int_(*this) /= that; }

};

namespace std{
  template<lint mod>
  ostream &operator <<(ostream& out,const Int_<mod>& a){
    out<<a.get();
    return out;
  }
  template<lint mod>
  istream &operator >>(istream& in,Int_<mod>& a){
    in>>a.x;
    return in;
  }
};

typedef Int_<1000000007> Int;
Int dp[4005][4005];
Int comb[4005][4005];
pi ps[200005];
int n;
int main(){
  comb[0][0]=1;
  REP(i,4002) REP(j,4002){
    comb[i+1][j]+=comb[i][j];
    comb[i][j+1]+=comb[i][j];
  }
  cin>>n;
  int M=2000;
  REP(i,n){
    scanf("%d%d",&ps[i].fr,&ps[i].sc);
    dp[M-ps[i].fr][M-ps[i].sc].x++;
  }

  REP(i,4002) REP(j,4002){
    dp[i+1][j]+=dp[i][j];
    dp[i][j+1]+=dp[i][j];
  }

  Int res=0;
  REP(i,n){
    res+=dp[M+ps[i].fr][M+ps[i].sc];
  }
  REP(i,n){
    res-=comb[ps[i].fr*2][ps[i].sc*2];
  }
  res/=2;
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 127104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    vector<Pi> g(3);
    rep(i,3) cin>>g[i].fi>>g[i].se;
    double ma=0;
    auto calc=[](Pi a,Pi b){
        return sqrt((a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se));
    };
    double sum=0;
    rep(i,3){
        double ret=calc(g[i],g[(i+1)%3]);
        chmax(ma,ret);
        sum+=ret;
    }
    FOR(i,1,3){
        g[i].fi-=g[0].fi;
        g[i].se-=g[0].se;
    }
    double s=abs(g[1].fi*g[2].se-g[1].se*g[2].fi);
    double r=s/sum;
    auto solve=[&](double x)->bool{
        return ma*(r-x)>=2.0*x*r;
    };
    double ng=r,ok=0,mid;
    rep(_,100){
        mid=(ok+ng)/2;
        if(solve(mid)) ok=mid;
        else ng=mid;
    }
    cout<<setprecision(15)<<ok<<endl;
}

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

    using namespace std;

    int main()
    {
        int h;
        int a;
        int temp=0;

        cin>>h;
        cin>>a;


        while(h>0)
        {
            h=h-a;
            temp++;
        }
        cout<<temp;


        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    rep(i,n-1){
        REP(j,i+1,n){
            auto itr = lower_bound(all(a),a[i]+a[j]);
            ans += max(0LL,distance(a.begin(),itr)-1-j);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc131/tasks/abc131_e
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, k: usize
    };
    let mut edges = vec![];
    for i in 0..n-1 {
        edges.push((i, n-1));
    }
    let all = (n-2)*(n-1)/2;
    if k > all {
        println!("-1");
        return;
    } else if k < all {
        let mut all = all;
        'lp: for i in 0..n-1 {
            for j in i+1..n-1 {
                edges.push((i, j));
                all -= 1;
                if all == k {
                    break 'lp;
                }
            }
        }
    }

    println!("{}", edges.len());
    for e in edges {
        println!("{} {}", e.0+1, e.1+1);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	// 7x = 1(mod 5)
	int a, b, c;
	std::cin >> a >> b >> c;
	for(int i = 1; i <= b;i++){
		if (i * a% b == c) {
			std::cout << "YES" << std::endl;
			return 0;
		}
	}
	std::cout << "NO" << std::endl;
	return 0;
}

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

int main()
{
	int N, V[50], C[50],dif=0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}

	for (int i = 0; i < N; i++) {
		if (V[i] - C[i] > 0)dif += V[i] - C[i];
	}
	cout << dif << endl;
	return 0;
}


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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int H, W, h, w;
   cin >> H >> W >> h >> w;
   if (H % h == 0 && W % w == 0) {
      cout << "No\n";
      return 0;
   }
   cout << "Yes\n";
   for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
         if (i % h == h - 1 && j % w == w - 1) {
            cout << -1000 * (h * w - 1) - 1 << " ";
         } else {
            cout << 1000 << " ";
         }
      }
      cout << "\n";
   }
}


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

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a[200001];
    cin >> n;
    unordered_map<llong,llong> M;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ++M[a[i]];
    }

    vector<llong> P2;
    llong k = 2;
    while (1) {
        P2.push_back(k);
        k *= 2;
        if (k > 2 * 1000000000) break;
    }

    sort(a, a + n, greater<int>());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (M.find(a[i]) == M.end()) continue;
        if (M[a[i]] == 1) M.erase(a[i]);
        else --M[a[i]];
        for (vector<llong>::iterator itr = P2.end() - 1; itr != P2.begin() - 1; --itr) {
            llong target_key = *itr - a[i];
            // cout << *itr << " " << a[i] << endl;
            if (target_key <= 0) break;
            if (M.find(target_key) != M.end()) {
                // cout << "find" << " " << a[i] << " " << target_key << " " << M[target_key] << endl;
                ++ans;
                if (M[target_key] == 1) M.erase(target_key);
                else --M[target_key];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9288
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;
#define N 100009
#define mod 1000000007

int main(){
    int n,k;
    cin>>n>>k;
    long data[n+1];
    for (int i=1; i<=n; i++) cin>>data[i];
    
    
    ll sum_left[n+1],sum_right[n+1];
    sum_left[0]=0;
    sum_right[0]=0;
    for (int i=1; i<=n; i++) sum_left[i]=sum_left[i-1]+data[i];
    for (int i=1; i<=n; i++) sum_right[i]=sum_right[i-1]+data[n+1-i];
    
    ll sum[n+1][n+1];
    for (int i=0; i<=n; i++){
        for (int j=0; j<=n; j++) sum[i][j]=-10000000000000;
    }
    
    vector<ll> ans;
    int count=0;
    if (n>=k){
        for (int i=0; i<=k; i++){
            for (int j=0; j<=k-i; j++){
                vector<ll> data1;
                for (int p=1; p<=i; p++) data1.push_back(data[p]);
                for (int p=1; p<=j; p++) data1.push_back(data[n-p+1]);
                sort(data1.begin(),data1.end());
                sum[i][j]=sum_left[i]+sum_right[j];
                count+=1;
                int p=min(k-i-j,i+j);
                for (int h=0; h<p; h++){
                    if (data1[h]>=0) break;
                    sum[i][j]-=data1[h];
                }
                ans.push_back(sum[i][j]);
            }
        }
        ll max=-10000000000000;
        for (int i=0; i<count; i++){
            if (max<ans[i]) max=ans[i];
        }
        cout<<max<<endl;
    }
    
    else{ //n<k
        for (int i=0; i<=n; i++){
            for (int j=0; j<=n-i; j++){
                vector<ll> data1;
                for (int p=1; p<=i; p++) data1.push_back(data[p]);
                for (int p=1; p<=j; p++) data1.push_back(data[n-p+1]);
                sort(data1.begin(),data1.end());
                data1.push_back(0);
                sum[i][j]=sum_left[i]+sum_right[j];
                count+=1;
                int p=min(k-i-j,i+j);
                for (int h=0; h<p; h++){
                    if (data1[h]>=0) break;
                    sum[i][j]-=data1[h];
                }
                ans.push_back(sum[i][j]);
            }
        }
        ll max=-10000000000000;
        for (int i=0; i<count; i++){
            if (max<ans[i]) max=ans[i];
        }
        cout<<max<<endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
//const long mod=(long)1e9+7;
inline void solve(void){
  int N;in(N);
  map<string,int>m;
  rep(i,N){
    string S;in(S);
    m[S]++;
  }
  int max_cnt=0;
  for(auto e:m){
    if(e.sd>max_cnt)max_cnt=e.sd;
  }
  vector<string>v;
  for(auto e:m){
    if(e.sd==max_cnt)v.pb(e.ft);
  }
  sort(all(v));
  for(auto e:v){
    out(e);
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 26096
#include<stdlib.h>
#include<stdio.h>
#include<string.h>


typedef struct{
  int x;
  char c;
}card;

int main(){
  int i,j,n,hantei,mini;
  card **A,**B,*swap;
  scanf("%d",&n);
  A=malloc(n*sizeof(card *));
  B=malloc(n*sizeof(card *)); 
  for(i=0;i<n;i++) A[i]=malloc(sizeof(card));
  for(i=0;i<n;i++) B[i]=malloc(sizeof(card));
  for(i=0;i<n;i++){
    scanf(" %c %d",&(A[i]->c),&(A[i]->x));
  }
  for(i=0;i<n;i++){
    B[i]->x=A[i]->x;
    B[i]->c=A[i]->c;
  }
  for(i=0;i<n-1;i++){
    hantei=0;
    for(j=n-1;j>=i+1;j--){
      if((A[j]->x)<(A[j-1]->x)){
        swap=A[j];
        A[j]=A[j-1];
        A[j-1]=swap;
        hantei=1;
      }
    }
    if(hantei==0) break;
  }
  for(i=0;i<n-1;i++) printf("%c%d ",A[i]->c,A[i]->x);
  printf("%c%d\n",A[n-1]->c,A[n-1]->x);
  printf("Stable\n");
  
  for(i=0;i<n-1;i++){
    mini=i;
    for(j=i+1;j<n;j++){
      if((B[mini]->x)>(B[j]->x)) mini=j;
    }
    if(mini!=i){
      swap=B[mini];
      B[mini]=B[i];
      B[i]=swap;
    }
  }
  for(i=0;i<n-1;i++) printf("%c%d ",B[i]->c,B[i]->x);
  printf("%c%d\n",B[n-1]->c,B[n-1]->x);
  for(i=0;i<n;i++){
    if(A[i]->c!=B[i]->c){
      printf("Not stable\n");
      return 0;
    }
  }
  printf("Stable\n");
  return 0;
}
  

Measured memory_bytes: 608
from decimal import*
from fractions import*
import math
import functools


import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inputt = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines 

s,t=input().split()
a,b=input().split()
u=input()
if(u==s):
    a=int(a)-1
else:
    b=int(b)-1
print(a,end=" ")
print(b)

Measured memory_bytes: 5076
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second

//CHECK FOR N = 1 OR OTHER DUMB TESTS 

using namespace std;

int main() {
	//ifstream cin("tst.in");
	//ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	string s;
	cin >> s;
	int p = 0;
	int mx = 0;
	int pp;
	while (p < s.size()) {
		pp = p;
		while (pp < s.size() && s[pp] == s[p])
			pp++;
		mx = max(mx, pp - p);
		p = pp;
	}
	if (mx >= 3)
		cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int b = int.Parse(input[0]);
		int c = int.Parse(input[1]);
      	if(b < 6)
			Console.WriteLine(0);
      	else if(b <= 12)
			Console.WriteLine(c/2);
      	else
			Console.WriteLine(c);
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int n=s.size();
    int res=0;
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            res++;
        }
    }
    cout<<res<<endl;
}

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

int main(int argc, char const *argv[])
{
    string S; cin >> S;
    int n = S.size();
    if (S[n-1] == 's') S += 'e';
    S += 's';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int i = 0;
  while (i < n) {
    int j = i;
    while (i < n && a[i] == a[j]) i++;
    ans += (i - j) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s=input()
n=len(s)+1
lst=[]
now='<'
cnt=0
for i in range(n-1):
    if s[i]!=now:
        lst.append(cnt)
        cnt=1
        now=s[i]
    else:
        cnt+=1
lst.append(cnt)
if len(lst)%2==1:
    lst.append(0)
ans=0
for i in range(0,len(lst),2):
    x=lst[i]
    y=lst[i+1]
    if x>=y:
        ans+=0.5*x*(1+x)+0.5*y*(y-1)
    else:
        ans+=0.5*y*(1+y)+0.5*x*(x-1)
print(int(ans))



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

int main() {
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i%2==0)cout << s[i];
  }
  return 0;  
    

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9;

ll gcd(ll x, ll y) {
    if(x < y) swap(x, y);
    if(y == 0) return x;
    return gcd(x%y, y);
}

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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = b - (b / c + b /d - b/lcm(c, d));
    ans -= (a - 1) - ((a - 1)/c + (a -1)/d - (a-1)/lcm(c, d));

    cout << ans << endl;
}

Measured memory_bytes: 888
k,a,b=map(int,input().split())
ans=1
if b-a<=2: #交換するメリットがない k回すべて一枚増やす
    print(ans+k)
else:
    if k<(a+1):
        print(ans+k)
    else:
        zan=(k-(a-1))
        if zan%2==0:
            print(a+(zan//2)*(b-a))
        else:
            print(a+(zan//2)*(b-a)+1)

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if(a <= 8 && b <= 8) Console.WriteLine("Yay!");
            else Console.WriteLine(":(");

        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

int main() {
    double a, b, C, S;
    cin >> a >> b >> C;
    
    
    printf("%.7f\n", (0.5) * (a * b * sin((C * M_PI)/180)));
    printf("%.7f\n", (a + b + sqrt(a * a + b * b - 2 * a * b *cos((C * M_PI)/180))));
    printf("%.7f\n", b * sin(M_PI * C / 180));
    
    return 0;
    
}


Measured memory_bytes: 3564
/*** akshaykumar99 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll a, b,c,k;
    cin>>a>>b>>c>>k;
    ll ans = 0;
    ans += min(a,k);
    k-=min(a,k);
    k-=min(b,k);
     ans -= min(c,k);
    k-=min(c,k);
    cout<<ans<<'\n';

}

int32_t main()
{
    IOS(); 
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;
const int inf = 2e18;

struct word {
    int a, b, c;
};

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> works(N);
    for (int i = 0; i < N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        works[i] = {a, b, c};
    }
    vector<vector<int>> dp(N + 1, vector<int>(3, -1));
    for (int i = 0; i < 3; i++) dp[N][i] = 0;
    for (int i = N - 1; i >= 0; i--) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                dp[i][j] = max(dp[i][j], dp[i + 1][k] + works[i][j]);
            }
        }
    }
    cout << max(dp[0][0], max(dp[0][1], dp[0][2])) << endl;
}



Measured memory_bytes: 11136
#include<stdio.h>
#include<stdlib.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int g(int a,int b,int c){
  if(b<=a&&a<=c)return a;
  return a<b?b:c;
}
int main(){
  int n,i,j,t=0,nt,f[100010],a[100010],b[100010],d[2][100010],r[2]={};
  long long s[2]={};
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d %d",&a[i],&b[i]);
  for(i=0;i<n;i++)hin(-a[i]);
  for(i=0;i<n;i++)d[0][i]=hout()-1;
  R=C=1;
  for(i=0;i<n;i++)hin(b[i]);
  for(i=0;i<n;i++)d[1][i]=hout()-1;
  for(i=0;i<n;i++)f[i]=0;
  for(j=0;j<2;j++){
    for(i=0;i<n;i++)f[i]=0;
    r[0]=r[1]=t=0;
    for(i=j;i<n+j;i++){
      while(f[d[i%2][r[i%2]]])r[i%2]++;
      //printf("%d %d\n",a[d[i%2][r[i%2]]],b[d[i%2][r[i%2]]]);
      nt=g(t,a[d[i%2][r[i%2]]],b[d[i%2][r[i%2]]]);
      s[j]+=abs(nt-t);
      t=nt;
      f[d[i%2][r[i%2]]]=1;
    }
    s[j]+=abs(t);
  }
  printf("%lld\n",s[0]<s[1]?s[1]:s[0]);
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s[n];
    int count=0,counta=0,countb=0;
    int countc;
    int countd=0;
    for(int i=0;i<n;i++)cin >> s[i];
    for(int i=0;i<n;i++){
        countc=0;
        for(int j=0;j<s[i].size();j++){
            if(j!=s[i].size()-1){
                if(s[i][j]=='A'&&s[i][j+1]=='B')count++;
            }
            else if(s[i][j]=='A'){counta++; countc++;}
        }
        if(s[i][0]=='B'){countb++;countc++;}
        if(countc==2)countd++;
    }
    if (countd!=0&&countd==counta&&countd==countb)count--;
    cout << count+min(counta,countb) << endl;
}

Measured memory_bytes: 768
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String w = sc.next();
        sc.close();
        
        int[] cnt = new int[26];
        for(int i = 0; i < w.length(); i++){
            cnt[(int)(w.charAt(i)-'a')]++;
        }
        for(int i = 0; i < 26; i++){
            if(cnt[i]%2 == 1){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
char S[10]="FESTIVAL";
 
const double EPS=1e-8;
 
string fest(long long K,int i)
{
  string ret;
  if(i==7){
    for(int t=0;t<K;t++){
      ret+=S[i];
    }
  }
  else if(K==1){
    for(int t=i;t<8;t++){
      ret+=S[t];
    }
  }
  else if(K>0){
    int N=(int)min(200ll,(long long)(sqrt((double)K)+EPS));
    //printf("%lld %d\n",K,N);
    long long D=K/N;
    int R=K%D;
    if(R==0){
      D--;
      R=N;
    }
    string s1=fest(D,i+1);
    for(int t=0;t<N;t++){
      ret+=S[i];
    }
    for(int t=0;t<s1.size()-7+i;t++){
      ret+=s1[t];
    }
    for(int t=0;t<R;t++){
      ret+=S[i];
    }
    for(int t=s1.size()-7+i;t<s1.size();t++){
      ret+=s1[t];
    }
  }
  return ret;
}
 
int main()
{
  long long K;
  scanf("%lld",&K);
  string s=fest(K,0);
  printf("%s\n",s.c_str());
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<stdlib.h>

int gcd(int a,int b){
    if(a % b == 0) return abs(b);
    else return abs(gcd(b,a % b));
}

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    int c[a];
    for(int i = 0;i < a;i++){
        scanf("%d",&c[i]);
        c[i] = abs(c[i] - b);
    }
    int d = c[0];
    for(int i = 1;i < a;i++){
        d = gcd(d,c[i]);
    }
    
    printf("%d\n",d);
}

Measured memory_bytes: 512