akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque

V = list(input())
S = deque()
S.extend(V)
Q = int(input())

memo = []
r = 0
for i in range(Q):
    c = sys.stdin.readline().split()
    #print(c)
    if c[0] == '1':
        r += 1
        continue
    else:
        if c[1] == '1':
            memo.append((r, c[2]))
        else:
            memo.append((r+1, c[2]))
        
#print(memo)        
if r % 2 == 1:
    S.reverse()

for m in memo:
    s, l = m
    s = r - s
    if s % 2 == 0:
        S.appendleft(l)
    else:
        S.append(l)    

print(''.join(S))

Measured memory_bytes: 25096
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007;
const int maxn=2000010;
int inv[maxn],fac[maxn],ifac[maxn];
int C(int n,int m) {return (ll)fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
void init(int n) {
	fac[0]=ifac[0]=inv[0]=inv[1]=1;
	rep(i,2,n) inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	rep(i,1,n) fac[i]=(ll)fac[i-1]*i%mod,ifac[i]=(ll)ifac[i-1]*inv[i]%mod;
}
int main() {
	int r1=read(),c1=read(),r2=read(),c2=read();
	init(2000005);
	ll ans=0;
	rep(x,r1,r2) (ans+=C(x+c2+1,x+1)-C(x+c1,x+1))%=mod;
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}
/*
C(2,2)+C(3,2)+ --- + C(n-1,k) + C(n,k)
=C(1,k) + -- + C(n,k)  C(n+1,k+1)-C() 
 + C(1,k+1)
*/

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  int counta = 0;
  int countb = 0;
  for( int i = 0;i < N; i++) {
    if( S.at(i) == 'a') {
      if (counta < A + B) {
        cout << "Yes" << endl;
        counta++;
      }
      else {
        cout << "No" << endl;
      }
    }
    else if( S.at(i) == 'b') {
      if(counta < A + B && countb < B) {
        cout << "Yes" << endl;
        counta++;
        countb++;
      }
      else{
        cout << "No" << endl;
      }
    }
    else{
      cout << "No" << endl;
    }
  }
}



Measured memory_bytes: 896
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>

struct DisjointSet {
  std::vector<int> rank, p;
  DisjointSet() = default;
  DisjointSet(const int n) {
    rank.resize(n, 0);
    p.resize(n, 0);
    for (int i = 0; i < n; ++i) makeSet(i);
  }

  void makeSet(int i) {
    p[i] = i;
    rank[i] = 0;
  }

  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }

  bool same(int x, int y) { return findSet(x) == findSet(y); }

  void unite(int x, int y) {
    auto rep_x = findSet(x), rep_y = findSet(y);
    if (rank[rep_x] < rank[rep_y])
      p[rep_x] = rep_y;
    else if (rank[rep_x] > rank[rep_y])
      p[rep_y] = rep_x;
    else {
      p[rep_x] = rep_y;
      rank[rep_y]++;
    }
  }
};

struct Edge {
  int source;
  int target;
  int weight;

  Edge() = default;
  Edge(int s, int t, int w) : source(s), target(t), weight(w){};
};

int MST(std::vector<Edge> edges, int V) {
  std::sort(edges.begin(), edges.end(),
            [](Edge x, Edge y) { return x.weight < y.weight; });
  std::vector<Edge> K;

  DisjointSet djs(V);

  for (auto edge : edges) {
    if (!djs.same(edge.source, edge.target)) {
      djs.unite(edge.source, edge.target);
      K.push_back(edge);
    }
  }

  auto sum_weight = 0;
  for (auto edge : K) sum_weight += edge.weight;

  return sum_weight;
}

int main() {
  int V, E, s, t, w;

  std::vector<Edge> edges;

  std::cin >> V >> E;
  for (size_t i = 0; i < E; ++i) {
    std::cin >> s >> t >> w;
    edges.push_back(Edge(s, t, w));
  }

  std::cout << MST(edges, V) << std::endl;
}



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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define endl '\n'
#define mod 1000000007

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

int main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	ll n,p;
	cin >> n >> p;
	if(n == 1){
		cout << p << endl;
		return 0;
	}
	ll ans = 1;
	for(ll i=2;i*i<=p;i++){
		if(p%i==0){
			ll count = 0;
			while(p%i==0){
				p/=i;
				count++;
			}
			ll here = count/n;
			ans *= pow(i,here);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int M, D;
	get2int(M, D);

	int ans = 0;
	for (int m = 1; m <= M; m++) {
		for (int d = 22; d <= D; d++) {
			int d1 = d % 10;
			int d2 = d / 10;
			if ((d1 >= 2) &&
				(d2 >= 2) &&
				((d1 * d2) == m)) {
				ans++;
			}
		}
	}
	printf("%d\n", ans);
}


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;

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

  cout << 700 + count(S.begin(), S.end(), 'o') * 100 << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define N 1000005
#define sc scanf
#define pb push_back

ll n;
ll a[100];

int main() {

    sc("%lld", &n);

    for(int i=1; i<=n; ++i) {
        sc("%lld", &a[i]);
    }

    ll curMoney = 1000;
    ll curStock = 0;

    for(int i=1; i<=n; ++i) {

        if(i == n) {
            curMoney += (a[i] * curStock);
            break;
        }

        if(a[i+1] > a[i]) {
            curStock += (curMoney/a[i]);
            curMoney %= a[i];
        }
        else if(a[i+1] < a[i]) {
            curMoney += (a[i] * curStock);
            curStock = 0;
        }
    }

    printf("%lld\n", curMoney);
}


Measured memory_bytes: 3820
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    int N;cin >> N;
    int nowT = 0,nowX = 0,nowY = 0;
    string ans = "Yes";
    for(int i = 0;i<N;i++){
        int T,X,Y;cin >> T >> X >> Y;
        int dist = abs(nowX-X)+abs(nowY-Y);
        int times = T-nowT;
        if(times < dist || times % 2 != dist % 2){
            ans = "No";
        }
        nowT = T;nowX = X;nowY = Y;
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b,c;cin>>a>>b>>c;

  if(a==b)out(c)
  else if(b==c)out(a)
  else if(c==a)out(b)

  return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = ""

for i in range(1,99):
    if n <= 26 ** i:
        n -= 1
        for j in range(i):
            ans += chr(ord('a') + n % 26)
            n //= 26
        break
    else:
        n -= 26 ** i

print(ans[::-1])

Measured memory_bytes: 9184
X = int(input())
L = [i ** 5 for i in range(0, 500)]
for i in L:
    for j in L:
        if i + j == X:
            print(int(i**0.2), -int(j**0.2))
            exit()
        if i - j == X:
            print(int(i**0.2), int(j**0.2))
            exit()
        if -i + j == X:
            print(-int(i**0.2), -int(j**0.2))
            exit()
        if -i - j == X:
            print(-int(i**0.2), int(j**0.2))
            exit()



Measured memory_bytes: 9460
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if( (abs(a-c)<=d || (d >= abs(a -b)) && (d >= abs(b-c)))){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#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];
  vector<pair<int, int>> B(N);
  for (int i = 0; i < N; ++i)
    B[i] = make_pair(A[i], i + 1);
  sort(B.begin(), B.end());
  for (int i = 0; i < N; ++i)
    if (i == N - 1)
      cout << B[i].second << endl;
    else
      cout << B[i].second << ' ';
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e5 +7;
ll dp[MAXN];
int main()
{
    int n, W; scanf("%d%d", &n, &W);
    ll ans = 0;
    for (int i = 1, w, v; i <= n; i++)
    {
        scanf("%d%d", &w, &v);
        for (int j = W; j >= w; --j) ans = max(ans, dp[j] = max(dp[j], dp[j - w] + v));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int N,*a;
  int nowpm;
  int i,j,k,count=0;
  scanf("%d",&N);
  a=(int *)calloc(N,sizeof(int));
  for(i=0;i<N;i++) scanf("%d",&a[i]);

  if(N<2){
    puts("1");
    free(a);
    return 0;
  }

  if(a[0]==a[1]) nowpm=0;
  else nowpm=(a[0]<a[1]?1:-1);
  count=1;

  for(i=2;i<N;i++){
    if(a[i-1]>a[i]){
      if(nowpm==1){
	count++;
	if(a[i]==a[i+1]) nowpm=0;
	else nowpm=(a[i]<a[i+1]?1:-1);
	i++;
      }else{
	nowpm=-1;
      }
    }else if(a[i-1]<a[i]){
      if(nowpm==-1){
	count++;
	if(a[i]==a[i+1]) nowpm=0;
	else nowpm=(a[i]<a[i+1]?1:-1);
	i++;
      }else{
	nowpm=1;
      }
    }
  }
  printf("%d\n",count);
  free(a);
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] houses = new int[n];
        int prev = sc.nextInt();
        houses[0] = prev;
        int max = 0;
        int sum = 0;
        for (int i = 1; i < n; i++) {
            int place = sc.nextInt();
            int gap = place - prev;
            max = Integer.max(max, gap);
            prev = place;
            sum += gap;
            houses[i] = place;
        }
        int gap = houses[0] + k - houses[n-1];
        max = Integer.max(max, gap);
        sum += gap;
        sum -= max;
        System.out.println(sum);
    }
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l;
    int r;
    cin >> l >> r;
    sum += r - l + 1;
  } 
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main() {
	int N;
	int T[100],i,j;
	int M;
	int P[100],X[100];
	scanf("%d",&N);
	for(i=0; i<N; i++) {
		scanf("%d",&T[i]);
	}
	scanf("%d",&M);
	for(i=0; i<M; i++) {
		scanf("%d %d",&P[i],&X[i]);
	}
	for(i=0; i<M; i++) {
		int sum=0;
		for(j=0; j<N; j++) {
			if(j!=P[i]-1) {
				sum+=T[j];
			} else {
				sum+=X[i];
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  int count=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    if(i/10000==i%10&&i/1000%10==i/10%10){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, D: int):
    from math import ceil
    print(ceil(N/(2*D+1)))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(N, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>

main(){
  char data[101];
  int i,temp,ans,p;

  while(1){
    if(scanf("%c", &data[0])==EOF) break;
    if(data[0]=='\n') continue;
    for(i=1;i<100;i++){
      scanf("%c", &data[i]);
      if(data[i]=='\n'){
	temp=i;
	break;
      }
    }
    
    ans=0; 
    p=0;
    for(i=temp-1;i>=0;i--){
      if(data[i]=='I'){
	if(p<=1){
	  p=1;
	  ans+=1;
	}
	else ans-=1;
      }
      if(data[i]=='V'){
	if(p<=2){
	  p=2;
	  ans+=5;
	}
	else ans-=5;
      }
      if(data[i]=='X'){
	if(p<=3){
	  p=3;
	  ans+=10;
	}
	else ans-=10;
      }
      if(data[i]=='L'){
	if(p<=4){
	  p=4;
	  ans+=50;
	}
	else ans-=50;
      }
      if(data[i]=='C'){
	if(p<=5){
	  p=5;
	  ans+=100;
	}
	else ans-=100;
      }
      if(data[i]=='D'){
	if(p<=6){
	  p=6;
	  ans+=500;
	}
	else ans-=500;
      }
      if(data[i]=='M'){
	if(p<=7){
	  p=7;
	  ans+=1000;
	}
	else ans-=1000;
      }
    }

    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
# include<iostream>
# include<cstring>
# include<cstdio>
# include<cstdlib>
# include<algorithm>
using namespace std;
const int MAX=2e3+1;
int n,k,tot;
int num[26];
int pos[26][MAX];
string a;
string b[MAX<<7];
string Read()
{
	string a="";
	char ch=getchar();
	for(;ch>'z'||ch<'a';ch=getchar());
	for(;ch>='a'&&ch<='z';a+=ch,ch=getchar());
	return a;
}
int read()
{
    int x=0;
    char ch=getchar();
    for(;!isdigit(ch);ch=getchar());
    for(;isdigit(ch);x=x*10+ch-48,ch=getchar());
    return x;
}
int main()
{
	a=Read(),n=a.length();
	k=read();
	//for(int i=0;i<n;++i)
	//  pos[a[i]-'a'][++num[a[i]-'a']]=i;
	for(int i=0;i<n;++i)
	  {
	  	for(int j=1;j<=k;++j)
	  	  {
	  	  	if(i+j-1>=n) break;
	  	  	if(j==1) b[++tot]+=a[i];
	  	  	else b[tot+1]=b[tot]+a[i+j-1],++tot;
		  }
	  }
	sort(b+1,b+1+tot);
	int L=unique(b+1,b+1+tot)-b;
	cout<<b[k];
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
		int A,B;
		cin>>A>>B;
		int ans=0;
		if(A>B){
			ans=A;
			A--;
		}else{
			ans=B;
			B--;
		}
		if(A>B){
			ans+=A;
			A--;
		}else{
			ans+=B;
			B--;
		}
		ce(ans)
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type Drink struct {
	value int
	num   int
}

type dr []Drink

func (d dr) Len() int {
	return len(d)
}

func (d dr) Swap(i, j int) {
	d[i], d[j] = d[j], d[i]
}
func (d dr) Less(i, j int) bool {
	return d[i].value < d[j].value
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	list := make(dr, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i].value, &list[i].num)
	}
	sort.Sort(list)

	okane := 0
	numDrink := 0
	for i := 0; i < n; i++ {
		for j := 0; j < list[i].num; j++ {
			if numDrink != m {
				okane += list[i].value
				numDrink++
			} else {
				break
			}
		}
	}
	fmt.Println(okane)
}


Measured memory_bytes: 5504
#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>;
int main(){
  int n;
  cin >> n;
  vector <int> l(n);
  rep(i,n) cin >> l[i];
  int ans=0;
  rep(i,n) rep(j,n) rep(k,n){
    if(i<j && j<k){
      if(l[i] == l[j]) continue;
      if(l[i] == l[k]) continue;
      if(l[k] == l[j]) continue;
      if((ll)l[i]+l[j]+l[k] <= max({l[i],l[j],l[k]})*2) continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3564
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
std::map<char,int> M ;
int T ;
int c,t;
int MAX = 1 << 30 ;
int ans = MAX;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N >> T ;
  REP(i,N){
    cin >> c >> t ;
    if( t <= T )
    {
      ans = min(ans,c);
    }
  }
  if(ans != MAX){
    cout << ans <<endl;
  }else{
    cout << "TLE" << endl;
  }


  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 256
//package atcoder.beginnercontest.r176;

import java.util.Scanner;

/**
 * @author pribic (Priyank Doshi)
 * @since 29/08/20
 */
public class Main {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int n = sc.nextInt();
      long ans = 0;
      int lastVal = -1;
      for(int i = 0; i < n; i++) {
        if(lastVal == -1) {
          lastVal = sc.nextInt();
        } else {
          int curVal = sc.nextInt();
          if(curVal < lastVal) {
            ans += lastVal - curVal;
          }
          lastVal = Math.max(lastVal, curVal);
        }
      }
      
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 58716
#include <iostream>

int main() {
  int n; std::cin >> n;
  bool inc7 = false;
  while (n) {
    if (n % 10 == 7) inc7 = true;
    n /= 10;
  }
  if (inc7) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
}

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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    int N;
	
    vector<int> v(5);
  	for(int i=0;i<5;i++) {
      cin >> v.at(i);
    }
    cin >> N;

    for(int i=0;i<5;i++) {
    	for(int j=i+1;j<5;j++) {
          	if(abs(v.at(i)-v.at(j))>N) { 
          		cout << ":(" << endl;
          		return 0;
          	}
        }
    }

  	cout << "Yay!" << endl;
  
    return (0);
}


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

void show(int* a, int n)
{
    for(int i = 0; i < n - 1; i++) cout << a[i] << " ";
    cout << a[n - 1] << endl;
}

int BubbleSort(int* a, int n)
{
    int i, c, count;
    bool inv = true;
    count = 0;

    while(inv){
        inv = false;
        for(i = n - 1; i > 0; i--){
            if(a[i] < a[i - 1]){
                c = a[i];
                a[i] = a[i - 1];
                a[i - 1] = c;
                count++;
                inv = true;
            }
        }
    };
    show(a, n);
    return count;
}

int main()
{
    int n, a[100];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    cout << BubbleSort(a, n) << endl;
    return 0;
}

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

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

            int ans = a - (b + b);
            if (ans < 0)
                ans = 0;

            Console.WriteLine(ans);


        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int w, a, b;

int main(){
  cin >> w >> a >> b;
  if(b + w < a) cout << (a - (b + w)) << endl;
  else if(a + w < b) cout << (b - (a + w)) << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()

ans = 0
w = -1
for i, s in enumerate(S.replace("A", "0").replace("BC", "1")):
    if "01".find(s) >= 0:
        if w < 0:
            w = i
    else:
        w = -1

    if w >= 0:
        if s == "1":
            ans += i - w
            w += 1
print(ans)


Measured memory_bytes: 3560
#include <stdio.h>
struct dice{
    int d[6], tmp[6];
};
struct dice dice1;
struct dice dice2;
void init1(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice1.d[i]=n[i];
    }
}
void init2(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice2.d[i]=n[i];
    }
}
void throwdice(char c){
    int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}
int compare(){
    int i;
    for(i=0;i<6;i++){
        if(dice1.d[i]!=dice2.d[i]){
            return 0;
        }
    }
    return 1;
}
int main()
{
    int n[6];
    int i,j;
    int ok=0;
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init1(n);
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init2(n);
    for(i=0;i<4;i++){
        for(j=0;j<4;j++){
            throwdice('N');
            throwdice('E');
            throwdice('S');
            if(compare()) ok=1;
        }
        throwdice('N');    
    }
    throwdice('E');
    for(i=0;i<2;i++){
        for(j=0;j<4;j++){
            throwdice('N');
            throwdice('E');
            throwdice('S');
            if(compare()) ok=1;
        }
        throwdice('W');    
        throwdice('W');    
    }
    if(ok) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 580
//abc140_b.cpp
//Wed Oct  9 23:42:54 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n],b[n],c[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
		a[i]--;
	}
	for (int i=0;i<n;i++){
		cin >> b[i];
	}
	for (int i=0;i<n-1;i++){
		cin >> c[i];
	}

	int ans = 0;
	for (int i=0;i<n;i++){
		ans += b[a[i]];
		if (i>0 && a[i]==a[i-1]+1){
			ans+=c[a[i-1]];
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int H, W,i,j;
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++) {
                if(i==0 || i==H-1 || j==0 || j==W-1){
                printf("#");
                }
                else {
                printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
/////////////////////////(๑•﹏•๑｀)/////////////////////////
///AtCoder Beginner Contest 102///

int main() {
	ll N; SCLLD(N);
	vector<ll> A;
	vector<ll> B;

	FORq(i,1,N){
		ll x; SCLLD(x);
		B.PB(x-i); // not original
		A.PB(x);
	}

	sort(B.begin(),B.end());
	ll b1,b2;
	b1 = B[N/2 - 1];
	b2 = B[N/2];

	ll ans1,ans2;
	ans1 = 0; ans2 = 0;

	REP(i,N){
		ans1 += abs(A[i] - (i+1 + b1));
		ans2 += abs(A[i] - (i+1 + b2));
	}

	ll ans = min(ans1,ans2);
	PRINTLLD(ans);
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cctype>
using namespace std;


struct memory{
	int size;
	int count;
	bool deleted;
	
	memory( int s, bool d )
		: size(s), count(0), deleted(d) {}
};

typedef list<memory>::iterator lmitr;


list<memory> memlist;
lmitr vars[26];
lmitr nullitr, undefitr;
vector<lmitr> allocated;	//新規確保されたメモリ(+α)

string input;
int pos;
int M;
int leak;


void error(){
	cout << "Error\n";
	exit(0);
}


lmitr malloc_( int num ){
	if( num <= M ){
		M -= num;
		lmitr ret = memlist.insert( memlist.end(), memory( num, false ) );
		allocated.push_back( ret );
		return ret;
	}
	return nullitr;
}

void free_( lmitr it ){
	if( it->deleted ){
		error();
	}

	if( it != nullitr ){
		M += it->size;
		it->deleted = true;
	}
}

lmitr clone( lmitr it ){
	if( it->deleted ){
		error();
	}
	
	if( M < it->size || it == nullitr ){
		return nullitr;
	}
	
	M -= it->size;
	lmitr ret = memlist.insert( memlist.end(), memory( it->size, false ) );
	allocated.push_back( ret );
	return ret;
}

void assign( int v, lmitr itr ){
	if( vars[v] != itr ){
		if( vars[v] != nullitr && vars[v] != undefitr ){
			--vars[v]->count;
			if( vars[v]->count == 0 ){
				allocated.push_back( vars[v] );		//GC待ち
			}
		}
		
		vars[v] = itr;
		++itr->count;
	}
}


lmitr expression(){
	if( isupper( input[pos] ) ){
		if( input[pos+1] == 'U' ){	//NULL
			pos += 4;
			return nullitr;
		}

		int v = input[pos] - 'A';
		++pos;
		if( input[pos] == '=' ){	//assignment
			++pos;
			lmitr ret = expression();
			assign( v, ret );
			return ret;
		}
		else{
			return vars[v];
		}
	}
	
	if( input[pos] == '(' ){
		++pos;	//(
		lmitr ret = expression();
		++pos;	//)
		return ret;
	}
	
	if( input[pos] == 'm' ){	//malloc(
		char *p;
		int size = strtol( input.c_str() + (pos + 7), &p, 10 );
		pos = p - input.c_str() + 1;	// )
		return malloc_( size );
	}
	
	if( input[pos] == 'c' ){	//clone(
		pos += 6;
		lmitr it = expression();
		++pos;	// )
		return clone( it );
	}
	
	abort();	//unexpected
}


void solve(){
	while( cin >> input ){
		pos = 0;
		
		if( input[0] == 'f' ){
			pos = 5;	//free(
			free_( expression() );
		}
		else{
			expression();
		}


		for( int j = 0; j < allocated.size(); ++j ){
			if( allocated[j]->count == 0 ){
				if( !allocated[j]->deleted ){
					leak += allocated[j]->size;
				}
				memlist.erase( allocated[j] );
			}
		}
		allocated.clear();
	}
	
	cout << leak << endl;
}


int main(){
	nullitr = memlist.insert( memlist.end(), memory( 0, false ) );
	undefitr = memlist.insert( memlist.end(), memory( 0, true ) );
	
	fill( vars, vars + 26, undefitr );
	
	cin >> M;
	solve();
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n>> k;
    vector<mint> x(k+1,mint(0));
    mint ans = mint(0);
    for(ll i=k;i>=1;--i){
        mint t = mint(k/i);
        t = t.pow(n);
        t -= x[i];
        ans += t*mint(i);
        for(ll j=1;j*j<=i;++j){
            if(i%j>0)continue;
            if(j*j==i){
                x[j] += t;
            }else{
                x[j] += t;
                x[i/j] += t;
            }
        }
    }   
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3948
// 挿入ソート
// O(n^2)　安定

#include <stdio.h>

void disp(int A[], int N){
    int i;

    // 表示
    for(i = 0; i < N; i++){
        if (i == 0) printf("%d", A[i]);
        else printf(" %d", A[i]);
    }

    // 改行を出力
    printf("\n");
}

void insertSort(int A[], int N) {
    int i, j, v;

    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;

        while((j >= 0)&&(A[j] > v)){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        disp(A, N);
    }
}

int main(){

    int A[100];
    int N, i;

    scanf("%d", &N);

    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }

    disp(A, N);

    insertSort(A, N);

    return 0;
}


Measured memory_bytes: 2000
def main():
    n = int(input())
    l = list(map(int, input().split()))
    count = 0
    for i in range(n):
        for j in range(i, n):
            for k in range(j, n):
                if l[i] != l[j] and l[j] != l[k] and l[k] != l[i] and l[i]+l[j] > l[k] and l[j]+l[k] > l[i] and l[k]+l[i] > l[j]:
                    count += 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72940
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N, A, B;
vector<ll> H;

bool can_clear(ll num){
    auto V = H;
    
    // 全体にB*numダメージ
    FOR(i, 0, N){
        V[i] -= B*num;
    }

    ll C = A-B;
    // 残りCをnum回で倒せるか
    FOR(i, 0, N){
        if(V[i]>0){
            ll cast_num;
            if(V[i]%C==0){
                cast_num = V[i]/C;
            }else{
                cast_num = V[i]/C + 1;
            }
            
            num -= cast_num;
            if(num<0){
                return false;
            }
        }
    }
    return true;
}

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

    // input
    cin >> N >> A >> B;
    
    H.resize(N);
    FOR(i, 0, N){
        cin >> H.at(i);
    }

    ll left = 0; // 無理
    ll right = 2000000000; // 絶対可能

    while(left+1!=right){
        ll center = (left + right) / 2;        
        if(can_clear(center)){
            right = center;
        }else{
            left = center;
        }
    }

    p(right);
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vvi				vector< vi > 
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define loop(i,n)		for(int i=0;i<n;i++)
#define Loop(i,n)		for(int i=1;i<=n;i++)
#define sz(a)			(a.size())
#define all(c) 			c.begin(),c.end()
#define tr(c,i) 		for(auto i = c.begin(); i != c.end(); i++)
#define present(c,x) 	(c.find(x) != c.end())
#define cpresent(c,x) 	(find(all(c),x) != c.end())
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void Gur27()
{
    ios::sync_with_stdio(0); cin.tie(0); 

}
 
int32_t main()
{
    Gur27();
    int n;
    cin>>n;
    int v[n];
    loop(i,n)
        cin>>v[i];
    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(v[1]-v[0]);
    for(int k=3;k<=n;k++)
    {
        dp[k]=min(abs(v[k-1]-v[k-2])+dp[k-1],abs(v[k-1]-v[k-3])+dp[k-2]);
        
    }
    cout<<dp[n];
    
    return 0;
}

Measured memory_bytes: 1792
s=input()

n=len(s)
x=[1]*n
x[n-1]=0
y=[1]*n
y[0]=0
z=[0]*n

for i in range(0,n-1):
	if s[i]=='R' and s[i+1]=='R':
		x[i+1]+=x[i]
		x[i]=0
	if s[i]=='L':
		x[i]=0   

for i in range(n-1,0,-1):
	if s[i]=='L' and s[i-1]=='L':
		y[i-1]+=y[i]
		y[i]=0
	if s[i]=='R':
		y[i]=0

i=1
while i<=n-2:
	if x[i]>1:
		if x[i]%2==0:
			x[i]=x[i]//2
			x[i+1]=x[i]
		else:
			x[i]=x[i]//2+1
			x[i+1]=x[i]-1
		i+=1
	i+=1
        
i=n-2
while i>=1:
	if y[i]>1:
		if y[i]%2==0:
			y[i]=y[i]//2
			y[i-1]=y[i]
		else:
			y[i]=y[i]//2+1
			y[i-1]=y[i]-1
		i-=1
	i-=1

for i in range(n):
	z[i]=x[i]+y[i]

print(*z)

Measured memory_bytes: 50876
#include<iostream>
#include<set>
using namespace std;
typedef long long ll;

ll f(ll n, ll b){
    ll ret = 0;
    while(n){
        ret += n%b;
        n /= b;
    }
    return ret;
}

int main(){
    ll n, s;
    cin >> n >> s;
    
    if(n <= s){
        cout << (n == s ? n+1 : -1)<< endl;
        return 0;
    }

    for(ll b = 2; b*b <= n; b++){
        if(f(n, b) == s){
            cout << b << endl;
            return 0;
        }
    }

    set<ll> ans;
    for(ll b = 2; (b-1)*(b-1) <= n-s; b++){
        if((n-s)%(b-1) == 0){
            ans.insert(b);
            ans.insert((n-s)/(b-1)+1);
        }
    }

    for(ll v : ans){
        if(f(n, v) == s){
            cout << v << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 384
package main

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

type process struct {
	name string
	time int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()

	var (
		n, quantum int
		err        error
	)
	splited := strings.Split(sc.Text(), " ")
	n, err = strconv.Atoi(splited[0])
	if err != nil {
		panic(err)
	}
	quantum, err = strconv.Atoi(splited[1])
	if err != nil {
		panic(err)
	}

	q := make(chan process, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		splited = strings.Split(sc.Text(), " ")
		t, err := strconv.Atoi(splited[1])
		if err != nil {
			panic(err)
		}

		p := process{
			name: splited[0],
			time: t,
		}

		q <- p
	}

	progress := 0
	for p := range q {
		if p.time > quantum {
			p.time -= quantum
			progress += quantum
			q <- p
		} else {
			progress += p.time
			fmt.Printf("%s %d\n", p.name, progress)

			if len(q) == 0 {
				close(q)
			}
		}
	}
}



Measured memory_bytes: 5388
from collections import Counter

n,k,q = map(int,input().split())
a = [int(input()) for _ in range(q)]
p = [k]*n

ac = Counter(a)

for i in range(n):
    p[i] -= 1*(q-ac[i+1])

[print("Yes" if j >= 1 else "No") for j in p]

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

int main()
{
	vector<vector<int>> ass(3, vector<int>(3));
	for (auto &&as : ass)
	{
		for (auto &&a : as)
		{
			cin >> a;
		}
	}
	int n;
	cin >> n;
	vector<int> bs(n);
	for (auto &&b : bs)
	{
		cin >> b;
	}

	vector<vector<bool>> css(3, vector<bool>(3, false));
	for (auto &&b : bs)
	{
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (ass[i][j] == b)
				{
					css[i][j] = true;
				}
			}
		}
	}

	for (int i = 0; i < 3; i++)
	{
		bool flag = true;
		for (int j = 0; j < 3; j++)
		{
			flag &= css[i][j];
		}

		if (flag)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	for (int j = 0; j < 3; j++)
	{
		bool flag = true;
		for (int i = 0; i < 3; i++)
		{
			flag &= css[i][j];
		}

		if (flag)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	if ((css[0][0] && css[1][1] && css[2][2]) || (css[0][2] && css[1][1] && css[2][0]))
	{
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
     
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
  }
  
  sort(all(p));
  
  double ans = p[0];
  repo(i,n){
    ans=(ans+p[i])/2;
  }
  
  cout << fixed << setprecision (20);  
  cout << ans << endl;
  
}


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

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

  int n, m;
  cin >> n >> m;

  vector<vector<int>> g(n);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  vector<int> dist(n, -1), prv(n);
  queue<int> q;
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();

    for (int to: g[v]) {
      if (dist[to] != -1) continue;
      dist[to] = dist[v] + 1;
      prv[to] = v;
      q.push(to);
    }
  }

  cout << "Yes\n";
  for (int i = 1; i < n; ++i) {
    cout << prv[i] + 1 << '\n';
  }
}

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

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    string S;
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}


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

const int MAX_N = 100000;
int V[ MAX_N + 10 ];

int main()
{
int i;
int a;
int N;
int iMax;
int iSum;

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

	cin >> N;

	if( N == 1 )
	{
		cout << 1 << endl;

		return 0;
	}

	for( i = 0; i < N; i++ )
	{
		cin >> a;

		V[ a ]++;
	}

	iMax = V[ 0 ] + V[ 1 ] + V[ 2 ];
	for( i = 3; i <= MAX_N; i++ )
		iMax = max( iMax, V[ i - 2 ] + V[ i - 1 ] + V[ i ] );

	cout << iMax << endl;

	return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int x,y;
int main(){
  cin >> x >> y;
  int ans = x + y + 2;
  rep(i,0,x){
    if((i * y) % x == 0){
      ans--;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3108
n=int(input())
abc=[[int(i) for i in input().split()] for _ in range(n)]
dp=abc+[[0]*3]*100010
for i in range(1,n):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+abc[i][0]
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+abc[i][1]
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+abc[i][2]
print(max(dp[n-1]))

Measured memory_bytes: 65240
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  ll N=S.size();
  llvec a(N, 0);
  map<ll, ll> cnt;
  reverse(ALL(S));
  ll cum = 0;
  rep(i, N){
    cum =mod(cum+(S[i]-'0')*modpow(10,i,2019),2019);
    a[i]=cum;
    cnt[cum]++;
  }

  ll ans = cnt[0];
  for(auto i: cnt){
    ans += i.second*(i.second-1)/2;
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 5144
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	string s;
	cin>>s;
	bool even=(s.length()%2==0);
	bool same=(s[0]==s[s.length()-1]);
	if(even ^ same)
		cout<<"Second";
	else
		cout<<"First";
	return 0;
}



Measured memory_bytes: 3780