akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int N,i,S[31]={0};
void dfs(int d,int n,int s)
{
	int i;
	if(n==0)
		for(i=0;S[i];i++)
			printf("%d%s",S[i],S[i+1]==0?"\n":" ");
	for(i=(s>n?n:s);i>0;i--)
	{
		S[d]=i;
		dfs(d+1,n-i,i);
		S[d]=0;
	}
}


int main()
{
	for(;scanf("%d",&N),N;)
	{
		memset(S,0,124);
		dfs(0,N,N);
	}
	return 0;
}

Measured memory_bytes: 600
//************************
//*  Date: 2018.9.22     *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n;

int main()
{
	cin>>n;
	for(int i=n;i<=999;i++)
	{
		int p=i;
		int a=p%10;
		p/=10;
		int b=p%10;
		p/=10;
		int c=p%10;
		if(a==b&&b==c)
		{
			//cout<<a<<b<<c<<endl;
			cout<<i<<endl;
			rt0;
		}
	}
	rt0;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll A, B;

int main() {
	scanf("%lld %lld", &A, &B);
	ll ans = max(A + B, max(A - B, A * B));
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;};
void qmod(ll &a,ll b){a=(a*b)%MOD;};
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  string s; cin>>s;
  ll bufa=0;
  ll bufbc=0;
  ll n=s.size();
  for(i=0;i<n;){
    if(s[i]=='A'){
      bufa++;
      i++;
    }
    else if(i+1<n&&s[i]=='B'&&s[i+1]=='C'){
      result+=bufa;
      i+=2;
    }
    else{
      bufa=0;
      bufbc=0;
      i++;
    }

  }
  cout<<result<<endl;
  
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace Test01
{    
    struct Student
    {
        public int num;
        public int order;
    }
    class Program
    {       
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Student[] st = new Student[N];
            for(int i = 0; i < N; i++)
            {
                st[i] = new Student() { num = i + 1, order = A[i]};
            }

            st = st.OrderBy(x => x.order).ToArray();

            Console.Write(st[0].num);
            for (int i = 1; i < N; i++) Console.Write($" {st[i].num}");
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 31192
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

n=l()[0]
A=l()
d={}
for i in range(n):
    if(A[i] not in d):
        d[A[i]]=0
    d[A[i]]+=1
total=0
for ks in d:
    total+=(d[ks]*(d[ks]-1)//2)
for i in range(n):
    cur_tot=total-(d[A[i]]*(d[A[i]]-1)//2)+((d[A[i]]-1)*(d[A[i]]-2)//2)
    print(cur_tot)




Measured memory_bytes: 27172
#include <iostream>
#include <iomanip>

int gcd(int x, int y)
{
    if(x < y){
        std::swap(x, y);
    }
    while(y > 0){
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int lcm(int x, int y)
{
    int a = x;
    int b = y;
    while(a != b){
        if(a < b){
            a += x;
        }else{
            b += y;
        }
    }
    return a;
}
int main()
{
    while(true){
        int a, b;
        std::cin >> a >> b;
        if(std::cin.eof()) break;
        std::cout << gcd(a, b) << " " << lcm(a, b) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2988
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;

bool comp(const pii &a, const pii &b){
	return a.second < b.second;
}

int main(){
	int n;
	cin >> n;
	vector<pii> a(n);
	for(int i=0; i<n; i++){
		int x,l;
		cin >> x >> l;
		a[i] = pii(x-l, x+l);
	}
	sort(a.begin(), a.end(), comp);

	int ans = 1;
	int last = a[0].second;
	for(int i=1; i<n; i++){
		if(last <= a[i].first){
			last = a[i].second;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int sum=0;
  int i=0;
  while(sum<n){
    i++;
    sum += i;
  }
  for(int j=1; j<=i; j++){
    if(j==sum-n)continue;
    cout << j << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll dp[3333][3333];
void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

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

	ll n, s;cin >> n >> s;
	vector<ll> v(n);REP(i, n)cin >> v[i];

	REP(i, n){
		mod_add(dp[i+1][v[i]], i + 1);
		for(ll j = 1;j < 3333;j++){
			if(j + v[i] < 3333)mod_add(dp[i+1][j+v[i]], dp[i][j]);
			mod_add(dp[i+1][j], dp[i][j]);
		}
	}

	ll ans = 0;
	REP(i, n)mod_add(ans, dp[i+1][s]);
	cout << ans << endl;

	//SHOW2d(dp, n+1, s+1);

	return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> P(M);
    vector<string> S(M);
    int AC = 0;
    int WA = 0;
    vector<int> pre(N);
    vector<bool> OK(N, false);
    for (int i = 0; i < M; i++)
    {
        cin >> P[i] >> S[i];
        if(OK[P[i]] == false && S[i] == "WA"){
            pre[P[i]]++;
        }
        else if(OK[P[i]] == false && S[i] == "AC"){
            WA += pre[P[i]];
            AC++;
            OK[P[i]] = true;
        }
    }
    cout << AC << " " << WA << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

void chmin(int* a, int b ){
  if(*a > b) *a = b;
}

int main(){
  char s[11] = {'\0'};
  cin >> s;

  int min = 99999999;
  for(int i=1; s[i+1]!='\0'; i++){
    char temp[3];
    temp[0] = s[i-1];
    temp[1] = s[i];
    temp[2] = s[i+1];
    int checkint = atoi(temp);
    chmin(&min, abs(checkint - 753) );
    if( checkint == 753 ){
      min = 0;
      break;
    }
  }
  cout << min;

  return 0;
}


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

using namespace std;

int main(){

	int N;

	cin >> N;

	long a[87];

	a[0] = 2;
	a[1] = 1;

	for(int i = 2;i <= N;i++){
		a[i] =  a[i-2] + a[i-1];
	}

	cout << a[N] << endl;

    return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    int a[N];
    map<int, int> mp;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        mp[a[i]] = i;
    }

    int cnt = 0;

    sort(a, a + N);

    for(int i = 0; i < N; i++){
        int dis = abs(mp[a[i]] - i);
        if(dis % 2 != 0) cnt++;
    }

    cout << (cnt + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 5376
a = list(input())
b = list(input())
c = list(input())
moji = a[0]
select = "a"
lengtha = len(a)
lengthb = len(b)
lengthc = len(c)
while True:
  if select == "a":
    if lengtha == 0:
      print("A")
      break;
    else:
      select = a[0]
      del a[0]
      lengtha -= 1
  elif select == "b":
    if lengthb == 0:
      print("B")
      break;
    else:
      select = b[0]
      del b[0]
      lengthb -= 1
  else:
    if lengthc==0:
      print("C")
      break;
    else:
      select = c[0]
      del c[0]
      lengthc -= 1

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <bitset>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;

int main() {
  int h,w; cin>>h>>w;
  string s[h];
  for(int i=0;i<h;i++) cin>>s[i];
  
  queue<P> que; que.push({0,0});
  bool u[h][w]; fill(u[0],u[h],false); u[0][0]=true;

  while(!que.empty()) {
    P o = que.front(); que.pop();
    int x = o.first, y = o.second;
    if (x != h-1 && s[x+1][y] == '#' && !u[x+1][y]) {
      u[x+1][y]=true; que.push({x+1,y});
    }
    if (y != w-1 && s[x][y+1] == '#' && !u[x][y+1]) {
      u[x][y+1]=true; que.push({x,y+1});
    }
  }

  int ct = 0;
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      if (s[i][j]=='#') ct++;
    }
  }
  if (ct != h+w-1) u[h-1][w-1]=false;

  if (u[h-1][w-1]) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}
// Thank you for making problems and running the contest

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	me = []
	for i in range(5):
		tmp = int(input())
		me.append(tmp)

	aa = 999999999
	ii = 0
	for i, vol in enumerate(me):
		tt = vol % 10
		if tt != 0 and tt < aa:
			aa = tt
			ii = i

	for i, vol in enumerate(me):
		if ii == i:
			continue
		tt = vol % 10
		if tt != 0:
			aa = 10 - tt
			me[i] += aa

	ans = 0
	for i, vol in enumerate(me):
		ans += vol
	print(ans)
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3188
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(a[k-1])

Measured memory_bytes: 3060
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();

		pr.println(t / a * b);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 25172
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);

    int i = 1;
    for (; i<=n; ++i) {
        int x = i;
        if (x % 3 == 0) {
            printf(" %d", i);
        } else {
            do {
                if (x % 10 == 3) {
                    printf(" %d", i);
                    break;
                } else {
                    x /= 10;
                }
            } while (x);
        }
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 2148
#include<string>
#include <iostream>
#include<vector>
#include <algorithm>
#include<queue>
#include<map>
#define T long long

struct S{
	int kx;
	int ky;
	int cx;
	int cy;
	int depth;
};



int main(void){
	int n;
	std::map<std::string,int> m;
	std::cin >>n;
	std::cin.ignore();
	for(int i=0;i<n;i++){
		std::string s;
		std::getline(std::cin, s);
		m[s] = 1;
	}
	std::cout << m.size()<<std::endl;
}


Measured memory_bytes: 19228
import itertools
# ありうる数列全探索する
def main():
    # input
    N,M,Q = map(int, input().split())
    a = [0]*Q
    b = [0]*Q
    c = [0]*Q
    d = [0]*Q
    for i in range(Q):
        a[i],b[i],c[i],d[i] = map(int, input().split())
    # 数列A(要素数N,1<=Ai<=M)について全パターンを出す
    arrA = itertools.combinations_with_replacement([i for i in range(1,M+1)], N)
    # 全探索
    max1 = 0
    for arr in arrA:
        tmp = 0
        for i in range(Q):
            if arr[b[i]-1]-arr[a[i]-1] == c[i]:
                tmp+=d[i]
        max1 = max(tmp,max1)

    print(max1)

main()


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

int main(void){
    
    ll N,a,b;
    vector<ll> A,B;
    bool dif=false;
    cin >> N;
    ll All=0;
    REP(i,N){
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
        if(a!=b){
            dif=true;
        }
        All+=a;
    }
    
    if(!dif){
        cout << 0 << endl;
        return 0;
    }
    
    ll Ans=INF;
    REP(i,N){
        if(A[i]>B[i]){
            Ans=min(Ans,B[i]);
        }
    }
    
    cout << All-Ans << endl;
    
    return 0;
}



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

int main(){
    int N, M; cin >> N >> M;
    vector<string> s(M), c(M); for(int i = 0; i < M; ++i) cin >> s[i] >> c[i];

    bool result = false;
    vector<string> st(N); for(int i = 0; i < N; ++i) st[i] = "0";
    vector<bool> r(N); for(int i = 0; i < N; ++i) r[i] = false;

    for(int i = 0; i < M; ++i) {
        if(stoi(s[i]) == 1 && c[i] == "0" && N != 1) {
            result = true;
            break;
        } else if(r[stoi(s[i]) - 1] == false) {
            st[stoi(s[i]) - 1] = c[i];
            r[stoi(s[i]) - 1] = true;
        } else if(r[stoi(s[i]) - 1] == true) {
            if(st[stoi(s[i]) - 1] != c[i]) {
                result = true;
                break;
            }
        }
    }

    if(result == true) {
        cout << -1 << endl;
    } else if(st[0] == "0" && N != 1) {
        st[0] = "1";
        for(int i = 0; i < N; ++i) {
            cout << st[i];
        }
    } else {
        for(int i = 0; i < N; ++i) {
            cout << st[i];
        }
    }
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> s(N);
  int sum = 0;
  rep(i, N) {
    cin >> s[i];
    sum += s[i];
  }

  std::sort(s.begin(), s.end());
  if (sum % 10 == 0) {
    rep(i, N) {
      if (s[i] % 10 != 0) {
        sum -= s[i];
        break;
      }
    }
  }

  if (sum % 10 == 0) sum = 0;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const ll MOD = 1000000007;

int main() {
   int n, m; scanf("%d%d", &n, &m);
   vector<pi> j(n);
   for (auto& i : j)
      scanf("%d%d", &i.f, &i.s);
   sort(all(j));
   int cur = 0;
   priority_queue<int> pq;
   int ans = 0;
   for (int i = 1; i <= m; ++i) {
      while (cur < n && j[cur].f <= i) {
         pq.push(j[cur].s);
         ++cur;
      }
      if (!pq.empty()) {
         ans += pq.top();
         pq.pop();
      }
   }
   printf("%d", ans);
   return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int A = scan.nextInt();
    int B = scan.nextInt();
    System.out.println(A <= B / N ? A * N : B);
  }
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, h, w;
    cin >> n >> h >> w;

    int ans = 0;
    while(--n >= 0){
        int a, b;
        cin >> a >> b;
        if(h <= a && w <= b)
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
int s[10002];
int main(){
	while(1){
	int n,ans;
	cin >> n;
	if(n == 0)break;
	ans = n;
	for(int i = 1;i <= n;i++)cin >> s[i];

	for(int i = 1;i <= n-3;i++){
		int ch[4]={0};
		for(int j = 0;j <= 3;j++)ch[s[i+j]]++;
		if(max(ch[1],max(ch[2],ch[3])) != 3)continue;
		int hi;
		for(int u = 1;u <= 3;u++)if(ch[u] == 3)hi = u;
		int r = i,l = i+3;
		while(r-1 >= 1 && s[r-1] == hi)r--;
		while(l+1 <= n && s[l+1] == hi)l++;
		r--,l++;
		s[0] = 4,s[n+1] = 5;
		while(r >= 1 && l <= n){
			if(s[r] != s[l])break;
			int nr = r,nl = l;
			int co = 2;
			while(nr-1 >= 1 && s[nr-1] == s[r])nr--,co++;
			while(nl+1 <= n && s[nl+1] == s[l])nl++,co++;
			if(co < 4){
				break;
			}
			r = nr,l = nl;
			if(r == 1 || l == n)goto out;
			if(s[r-1] != s[l+1])goto out;
			r--,l++;
		}
		r++,l--;
		out:
		;
		ans = min(ans,r-1+n-l);
	}
	printf("%d\n",ans);
}
	return 0;
}


Measured memory_bytes: 1184
#define s(X,Y,Z) (t=X,X=Y,Y=t,f(Z?&X:&Y))
f(int*a){*a=(*a&7)<<4|*a>>4;}k,m,a,b,c,t,r;main(n){while(scanf("%d",&n),n){for(r=1,a=97,b=82,c=67;n--;scanf(" %c%*s",&k),m=k-76,t=m%6==0?s(c,b,m):1<m&&m<8?s(b,a,m^7):s(c,a,m>0),r+=a&7);printf("%d\n",r);}}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int a, b;
  int ans;
  
  cin >> a >> b;
  
  ans = a+b;
  if(ans%2 != 0) cout << "IMPOSSIBLE" << endl;
  else{
    ans /= 2;
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  string w;
  cin >> w;
  sort(w.begin(), w.end());

  char c = ' ';
  int counter = 0, tmp = 0;
  for (int i = 0; i < w.length(); i++) {
    if (w[i] != c) {
      c = w[i];
      if (tmp % 2 != 0) {
        puts("No");
        return 0;
      }
      counter += tmp;
      tmp = 1;
    } else {
      tmp++;
    }
  }
  counter += tmp;
  if (counter % 2 == 0)
    puts("Yes");
  else
    puts("No");
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    edge(int f,int t) : from(f), to(t){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

template<class T>
T LIS (const vector<T> &a){
    int n = (int)a.size();
    vector<T> dp(n,INF);
    for(int i = 0; i<n; i++){
        auto it = lower_bound(dp.begin(),dp.end(),a[i]);
        *it = a[i];
    }

    return lower_bound(dp.begin(),dp.end(),INF) - dp.begin();
}

void dfs(string s,int n,char m){
    if(s.size()==n){
        cout << s << endl;
    }
    else{
        for(int i = 'a'; i < m+1; i++){
            if(i==m){
                dfs(s+char(i),n,char(m+1));
            }
            else{
                dfs(s+char(i),n,char(m));
            }

        }
    }
    
}

int main(){
    int n;
    cin >> n;
    dfs("",n,'a');
}

Measured memory_bytes: 1536
s = input()
k = int(input())
substrings = []
if len(s) < 8:
    for i in range(1, len(s) + 1):
        substrings.extend([s[_:_ + i] for _ in range(len(s) - i + 1)])
else:
    for i in range(1, 8):
        substrings.extend([s[_:_ + i] for _ in range(len(s) - i + 1)])

print(sorted(list(set(substrings)))[k - 1])


Measured memory_bytes: 7632
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++) cin >> A[i];
    int min_v = A[0];
    int max_profit = A[1] - A[0];

    for(int i=1; i<N; i++) {
        max_profit = max(A[i] - min_v, max_profit);
        min_v = min(A[i], min_v);
    }
    cout << max_profit << endl;
}


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

int main(void) {
    int n[3];

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n[0] >> n[1] >> n[2];
    sort(n, n + 3);
    cout << (n[0] * n[1]) / 2 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1000000;
int tim,tt,tp,cnt,n,gg,pt;
bool w[N];
int a[N],b[N],head[N],to[N],nxt[N],low[N],dfn[N],c[N],v[N],ls[N],rs[N],sc[N],st[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void tarjan(int x) {
    dfn[x]=low[x]=++tim;
    w[x]=1,v[++tp]=x;
    for(int i=head[x];i;i=nxt[i]) {
	int y=to[i];
	if(!dfn[y]) {
	    tarjan(y);
	    low[x]=min(low[x],low[y]);
	}
	else if(w[y])
	    low[x]=min(low[x],dfn[y]);
    }
    if(dfn[x]==low[x]) {
	int y;++gg;
	do c[y=v[tp--]]=gg,w[y]=0; while(x!=y);
    }
}
inline void lnk(int x,int y) {
    to[++tt]=y,nxt[tt]=head[x],head[x]=tt;
}
inline void insert(int l,int r,int p,int z,int &y) {
    if(!y) y=++cnt;
    if(l==r) {lnk(y,z);return;}
    int mid=(l+r)>>1;
    if(p<=mid) insert(l,mid,p,z,ls[y]);
    else insert(mid+1,r,p,z,rs[y]);
}
inline void query(int l,int r,int L,int R,int z,int x) {
    if(!x||L>R) return;
    if(L<=l&&r<=R) {lnk(z,x);return;}
    int mid=(l+r)>>1;
    if(L<=mid) query(l,mid,L,R,z,ls[x]);
    if(R>mid) query(mid+1,r,L,R,z,rs[x]);
}
inline int find(int x) {return lower_bound(st+1,st+1+pt,x)-st;}
inline bool check(int k) {
    int rt=0;
    cnt=n+n+1,tt=0;
    memset(ls,0,sizeof(ls));
    memset(rs,0,sizeof(rs));
    memset(dfn,0,sizeof(dfn));
    memset(head,0,sizeof(head));
    for(int i=1;i<=n;i++) {
	insert(1,pt,a[i],i*2+1,rt);
	insert(1,pt,b[i],i*2,rt);
    }
    for(int i=1;i<=n;i++) {
	query(1,pt,find(st[a[i]]-k+1),a[i]-1,i*2,rt);
	query(1,pt,a[i]+1,find(st[a[i]]+k)-1,i*2,rt);
	query(1,pt,find(st[b[i]]-k+1),b[i]-1,i*2+1,rt);
	query(1,pt,b[i]+1,find(st[b[i]]+k)-1,i*2+1,rt);
    }
    for(int i=1;i<=cnt;i++) {
	if(ls[i]) lnk(i,ls[i]);
	if(rs[i]) lnk(i,rs[i]);
    }
    for(int i=2;i<=cnt;i++)
	if(!dfn[i]) tarjan(i);
    for(int i=2;i<=n+n;i+=2)
	if(c[i]==c[i+1]) return 0;
    return 1;
}
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) {
	int x=gi(),y=gi();
	st[++pt]=x,st[++pt]=y;
	a[i]=x,b[i]=y;
    }
    sort(st+1,st+1+pt);
    for(int i=1;i<=pt;i++) sc[i]=i;
    for(int i=1;i<=n;i++) {
	a[i]=sc[find(a[i])]++;
	b[i]=sc[find(b[i])]++;
    }
    int l=1,r=1e9;
    while(l<=r) {
	int mid=(l+r)>>1;
	if(check(mid)) l=mid+1;
	else r=mid-1;
    }
    cout<<r;
    return 0;
}

Measured memory_bytes: 40320
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)

//C++で提出



// string s="AAA";    s.size() =3    (sのサイズ) ...1
// vector <int> a;    配列a(サイズは0) ...2
// a.push_back(10);   配列のサイズが一つ増えて一番後ろに10を代入 ...2
// A.pop_back();   最後の要素が消去される
// sort(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)より前までを小さい順に並び替えてa[0]から代入していく...3
// reverse(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)までを逆の順にしてa[0]から代入していく
// s.substr(3,2)   配列s[3]から2個の文字を抜き出した文字列 (s[3]とs[4]) ...4
// strcmp(s1,s2)  文字列が等しければ0を出力　s1>s2なら1 s1<s2なら-1を出力　C言語用なので配列は、s1[100]にする...5





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

	char s[100000];
	rep(i, 0, n) cin >> s[i];
	int Ans = 1;


	rep(i, 0, n - 1) {
		if (s[i] == s[i + 1]) {
			continue;
		}
		else Ans++;
	}

	cout << Ans;
}

Measured memory_bytes: 384
n, m = map(int, input().split())
nnode = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    nnode[a-1] += 1
    nnode[b-1] += 1
for i in nnode:
    if i%2==1:
        print('NO')
        break
else:
    print('YES')

Measured memory_bytes: 3956
import kotlin.math.min

fun main() {
    val s = next()
    val t = next()
    println(res(s, t))
}

fun res(s: String, t: String): Int {
    var result = t.length
    for (i in 0..s.length-t.length) {
        val tmpStr = s.substring(i, t.length+i)
        var cnt = t.length
        for (j in tmpStr.indices) {
            if (t[j] == tmpStr[j]) cnt--
        }
        result = min(cnt, result)
    }
    return result
}


fun next() = readLine()!!

Measured memory_bytes: 36224
using System;

namespace _0050
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string r1 = s.Replace("apple", "??????");
            string r2 = r1.Replace("peach", "apple");
            string r3 = r2.Replace("??????", "peach");
            Console.WriteLine(r3);
        }
    }
}

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

int main(){
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    vector<int> S, B(N + 1, -1);
    int v = 1;
    while(B.at(v) == -1){
        B.at(v) = S.size();
        S.push_back(v);
        v = A.at(v - 1);
    }
    int T = S.size() - B.at(v);
    int L = B.at(v);
    if(K < L){
        cout << S.at(K) << endl;
    }
    else{
        K = (K - L) % T;
        cout << S.at(L + K) << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int inf = 1000000000;
int di[4] = {0, 1, 0, -1};
int dj[4] = {1, 0, -1, 0};

int main(){
  int h, w; cin >> h >> w;
  char a[h][w];
  int dist[h][w];
  rep(i, h)rep(j, w) dist[i][j] = inf;
  deque <P> d;
  rep(i, h)rep(j, w){
    cin >> a[i][j];
    if (a[i][j] == '#'){
      dist[i][j] = 0;
      d.emplace_back(P(i, j));
    }
  }
  while (d.size() > 0){
    int now_i = d.front().first;
    int now_j = d.front().second;
    d.pop_front();
    rep(i, 4){
      int nex_i = now_i + di[i];
      int nex_j = now_j + dj[i]; 
      if (nex_i < 0 || nex_i >= h||nex_j < 0 || nex_j >= w) continue;
      else if (a[nex_i][nex_j] ==  '#')continue;
      else{
        dist[nex_i][nex_j] = min(dist[now_i][now_j] + 1,  dist[nex_i][nex_j]);
        a[nex_i][nex_j] = '#';
        d.emplace_back(P(nex_i, nex_j));
      }
    }
  }
  int ans = 0;
  rep(i, h)rep(j, w) {
    ans = max(ans, dist[i][j]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 16144
#include<bits/stdc++.h>
using namespace std;
int n,k,maxn=0;
int a[100005];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>k;
        a[k]++,a[k-1]++,a[k+1]++;
    }
    for(int i=0;i<=100000;i++)
        maxn=max(maxn,a[i]);
    cout<<maxn<<endl;
    return 0;
} 

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;
typedef long long ll;

int main(){
    int r,D,x;
    cin >> r >> D >> x;
    for (int i=i; i<10;i++){
        x = r * x -D;
        cout << x << endl;
    }

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import *
from functools import *
from collections import *
from heapq import heapify, heappop, heappush, heappushpop
import math

INF = float('inf')
NIL = - 1

import time
from functools import wraps


def stop_watch(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        elapsed_time = time.time() - start
        print(f'{elapsed_time} [ms]')
        return result

    return wrapper


def gcd(a, b):
    """
    Greatest Common Divisor
    Euclidean Algortihm
    """
    if a < b:
        gcd(b, a)
    while b != 0:
        a, b = b, a % b
    return a


def is_prime(n):
    if n < 2:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
    return True


def main():
    K = int(input())
    num_list = range(1, K + 1)

    total = 0

    for a in range(1, K + 1):
        if a == 1:
            total += K ** 2
            continue
        for b in range(1, K + 1):
            if b == 1:
                total += K
                continue
            tmp = gcd(a, b)
            if tmp == 1:
                total += K
                continue
            tmp_b = is_prime(tmp)
            for c in range(1, K + 1):
                if c == 1:
                    total += 1
                    continue
                if tmp_b:
                    if c % tmp == 0:
                        total += tmp
                        continue
                    else:
                        total += 1
                        continue
                else:

                # print(a, b, c)
                # print(gcd(tmp, c))
                    total += gcd(tmp, c)
    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75116
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a<=c&&c<=b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

typedef long long ll;
int x,y,z,k;
ll a[1005];
ll b[1005];
ll c[1005];

int main() {
  cin >> x >> y >> z >> k;
  for(int i = 0; i < x; i++) cin >> a[i];
  for(int i = 0; i < y; i++) cin >> b[i];
  for(int i = 0; i < z; i++) cin >> c[i];
  sort(a,a+x,greater<ll> ());
  sort(b,b+y,greater<ll> ());
  sort(c,c+z,greater<ll> ());
  
  priority_queue<ll> q,qq;

  for(int i = 0; i < x; i++) {
    for(int j = 0; j < y; j++) {
      q.push(a[i] + b[j]);
 
    }
  }

  for(int i = 0; i < min(k,x*y); i++) {
       ll tmp = q.top();
      q.pop();
    for(int j = 0; j < z; j++) {
   
      qq.push(tmp + c[j]);
    }
  }

  for(int i = 0; i < k; i++) {
    ll ans = qq.top();
    qq.pop();
    cout << ans << endl;
  }
}
			     


Measured memory_bytes: 43236
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  string S;
  cin >> S;
  if(S[5] == '0' && S[6] <= '4' ){
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll h,w,n,now=0;
	cin >> h >> w >> n;
	vll a(n);
	vvll mas(h,vll(w,0));
	rep(i,n) cin >> a[i];
	rep(i,h){
		if(i%2){
			for(ll j=w-1;j>=0;--j){
				mas[i][j]=now+1;
				a[now]--;
				if(a[now]==0) now++;
			}
		}
		else{
			rep(j,w){
				mas[i][j]=now+1;
				a[now]--;
				if(a[now]==0) now++;
			}
		}
	}
	rep(i,h){
		rep(j,w) cout << mas[i][j] << (j==w-1?"\n":" ");
	}
	return 0;
}


Measured memory_bytes: 476
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <cstddef>

using namespace std;
typedef long long ll;

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  while(M--) {
    int A, B;
    cin >> A >> B;
    A--; B--;
    UF.unite(A, B);
  }

  int ans = 0;
  for (int i=0; i < N; i++) {
    ans = max(ans, UF.size(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4048
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
    a,b = map(int, input().split())
    A[i] = a
    B[i] = b

num = 10**9+1
for i in range(N):
    if A[i] > B[i]:
        num = min(num, B[i])

if num == 10**9+1:
    print(0)
else:
    print(sum(A)-num)


Measured memory_bytes: 4596
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, n, x, a) for (int i = (x), a = 0; a < (n);  \
                              i = (i + 1) % (n), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;


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

    int N;
    cin >> N;

    int A[20], B[20], C[19];

    for0(i, N){ cin >> A[i];}
    for0(i, N){ cin >> B[i];}
    for0(i, N - 1){ cin >> C[i];}

    int now;
    int result = 0;
    int before = -100;
    for0(i, N){
        now = A[i];
        result += B[now - 1];
        if (before + 1 == now) result += C[before - 1];
        before = now;
    }

    cout << result;

    return 0;
}


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

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

    int count = std::count(topping.cbegin(), topping.cend(), 'o');

    cout << 700 + count * 100 << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    a, b, c, d = list(map(int, input().rstrip('\n').split()))
    import fractions
    lcm = c * d // fractions.gcd(c, d)
    print((b - a + 1) - ((b // c - (a - 1) // c) + (b // d - (a - 1) // d) - (b // lcm - (a - 1) // lcm)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 64364
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n,m;
  cin>>n>>m;
  int used[111111]={};
  int dp[111111]={};
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    used[a]=1;
  }
  dp[0]=1;
  for(int i=0;i<n;i++){
    if(used[i])continue;
    dp[i+1]+=dp[i];
    dp[i+1]%=MOD;
    dp[i+2]+=dp[i];
    dp[i+2]%=MOD;
  }
  cout<<dp[n]<<endl;
  return 0;
}


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

using namespace std;

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

  bool flag = true;
  for(int i = 0;i < s.length();i++){
    if(!(i % 2) && s[i] == 'L') flag = false;
    else if(i % 2 && s[i] == 'R') flag = false;
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;    
}


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

int main() { 
	string S;
  cin >> S;
  int f=0;
  int bi =0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'||S.at(i)=='G'||S.at(i)=='T'||S.at(i)=='C'){
    f++;
    }else{
    	if(bi<f){
          bi=f;
        }
      f=0;
    }
  }
      	if(bi<f){
          bi=f;
        }

  cout << bi << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
str_lis = ['']*N
ans_dic = defaultdict(int)
for i in range(N):
    tmp = S()
    tmp = tuple(sorted(tmp))
    ans_dic[tmp] += 1
ans = 0
for v in ans_dic.values():
    ans += comb(v, 2, exact=True)

print(ans)


Measured memory_bytes: 61456
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>     
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N];
ll pref[N], k, ans;
ordered_set < pair <ll, int> > s;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n >> k;
   for (int i = 1; i <= n; i ++) {
      cin >> a[i];
      pref[i] = pref[i - 1] + a[i];
   }
   for (int i = 1; i <= n; i ++) {
      s.in ({pref[i - 1] - k * (i - 1), i - 1});
      ans += s.order_of_key ({pref[i] - 1ll * k * i, mod});
   }
   cout << ans;
   //(pref[r] - pref[l - 1]) / (r - l + 1) >= k
   //pref[r] - pref[l - 1] >= k * (r - (l - 1))
   //pref[r] - pref[l - 1] >= k * r - k * (l - 1)
   //pref[r] - k * r >= pref[l - 1] - k * (l - 1)
}               
 
signed main () {                                       
  // #ifdef QWERTY
  //    freopen("input", "r", stdin);
  // #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 18460
#include<bits/stdc++.h>
using namespace std;
int A[100100],ans;
int main()
{
	int N,K;
	cin>>N>>K;
	for(int i=0;i<N;i++)
		cin>>A[i];
	N-=K;
	ans++;
	ans+=(N+K-2)/(K-1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
a=[0,0,0,0]
for i in range(3):
  x,y=map(int,input().split())
  a[x-1]+=1
  a[y-1]+=1
b=1
for i in range(4):
  if a[i]==3:
    print("NO")
    b=0
    break
if(b):
  print("YES")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
   int n ;cin>>n ;
   vector<ll>A(n) ;
   rep(i,n) cin>>A[i] ;
 bool ok=1 ;
 if(A[0]!=0) ok=0 ;
 ll ans=0 ;
 rep(i,n-1){
   if(A[i+1]-A[i]>=2) ok=0 ;
   if(A[i+1]<=A[i]) ans+=A[i] ;
 }
 if(ok==0) cout<<-1<<endl ;
 else
 cout<<ans+A[n-1]<<endl ;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    int n; cin >> n;
    int ans = 0;
    int b = 0, a = 0, ba = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(int i = 0; i < s.size()-1; i++){
            if(s[i]=='A' && s[i+1]=='B'){ans++;}
        }
        if(s[0]=='B' && s[s.size()-1]=='A'){ba++;}
        else if(s[0]=='B'){b++;}
        else if(s[s.size()-1]=='A'){a++;}
    }
    ans += max(0, ba-1);
    if(ba>0 && a>0){ans++; a--;}
    if(ba>0 && b>0){ans++; b--;}
    ans += min(a, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/***********************************************
#
#      Filename: b.cpp
#
#        Author: Comsyl - ylsong15@fudan.edu.cn
#   Description: ---
#        Create: 2017-05-19 22:59:13
***********************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 20;
int x[maxn];
bool vis[maxn];
ll ans;
int n, k;

void incr() {
    int pre = x[0];
    ll cnt = 0;
    for (int i = 1; i < n; ++ i) {
        if (vis[i]) {
            if (x[i] <= pre) {
                cnt += pre+1 - x[i];
                pre ++;
            } else {
                pre = x[i];
            }
        } else {
            if (x[i] > pre)
                pre = x[i];
        }
    }
    if (cnt < ans)
        ans = cnt;
}

void dfs(int cur, int count) {
    if (count == k) {
        incr();
        return ;
    }
    if (cur == n) return ;
    if (count + n-cur < k) return ;
    vis[cur] = true;
    dfs(cur+1, count+1);
    vis[cur] = false;
    dfs(cur+1, count);
}


int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; ++ i) {
        cin >> x[i];
    }
    ans = 1L << 60;
    vis[0] = true; dfs(1, 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256