akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

bool is_connected(vector<vector<int>> &Graph, vector<int> &nodes, int start) {
    bool visited[26] = {false};
    queue<int> q;
    q.push(start);
    while ( ! q.empty()) {
        int node = q.front();
        q.pop();
        visited[node] = true;
        for (int i=0; i<26; ++i) {
            if (Graph[node][i] && ! visited[i]) {
                q.push(i);
            }
        }
    }
    for (int x : nodes) {
        if ( ! visited[x]) return false;
    }
    return true;
}

int main() {
    int n;
    while (cin >> n && n) {
        vector<vector<int>> Graph(26, vector<int>(26));
        vector<int> nodes;
        vector<int> d(26, 0);
        string s;
        int b, f;
        for (int i=0; i<n; ++i) {
            cin >> s;
            b = s.back() - 'a';
            f = s.front() - 'a';
            d[b] ++;
            d[f] --;
            Graph[b][f] = true;
            nodes.push_back(b);
            nodes.push_back(f);
        }
        bool ok = is_connected(Graph, nodes, f);
        for (int x : d) {
            if (x != 0) {
                ok = false;
                break;
            }
        }
        cout << (ok ? "OK" : "NG") << endl;
    }
    return 0;
}

Measured memory_bytes: 1352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int s,a,b,c;
  cin >> s;
  a = s/100;
  b = (s - 100*a)/10;
  c = (s - 100*a - 10*b);
  
  cout << a+b+c <<endl;

}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int 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 pn(s) cout << #s << " " << s << endl

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

void printVector(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N;
    cin >> N;

    int a[N];
    FOR(i, 0, N){
        cin >> a[i];
    }

    int prevColor = -1;
    int count = 0;
    FOR(i, 0, N){
        if(prevColor == a[i]){
            count++;
            prevColor = -1;
        }else{
            prevColor = a[i];
        }
    }

    p(count);
        
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define inf 1e18+9
using namespace std;
const int N=200009;
int a[N];
int n,k,ans=-1,z=0;
vector <int> p,m;
int count(int s){
	int sum=0;
	if(s>=0){
		sum+=z*(p.size()+m.size())+p.size()*(long long)m.size()+z*(z-1)/2;
		int i=0,j=(long long)p.size()-1;
		while(i<j){
			while(j>=0 and p[j]*p[i]>s)j--;
			sum+=max(j-i,0ll);
			i++;
		}
		i=0,j=(long long)m.size()-1;
		while(i<j){
			while(j>=0 and m[j]*m[i]>s)j--;
			sum+=max(j-i,0ll);
			i++;
		}
	}
	else if(s<0){
		int i=0,j=m.size()-1;
		while(i<p.size()){
			while(j>=0 and i<p.size() and m[j]*p[i]>=-s)j--;
			sum+=j+1;
			i++;
		}
		sum=p.size()*(long long)m.size()-sum;
	}
	return sum;
}
int32_t main(){
	if(fopen("input.txt", "r"))
		freopen("input.txt", "r", stdin),
		freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]>0)p.push_back(a[i]);
		else if(a[i]<0)m.push_back(-a[i]);
		else z++;
	}
	sort(p.begin(),p.end());
	sort(m.begin(),m.end());
	int lo=-inf,hi=inf;
	while(hi>=lo){
		int mid=(hi+lo)/2;
		int c=count(mid);
		if(c>=k){
			ans=mid;
			hi=mid-1;
		}
		else lo=mid+1;
	}
	cout << ans ;
}

Measured memory_bytes: 3572
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

n,m = map(int, input().split())
G = [[1]*n for i in range(n)]
for i in range(n):
    G[i][i] = 0
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a][b] = 0
    G[b][a] = 0

from collections import deque

used = [0]*n
tmp = []

def bfs(start):
    if used[start]:
        return True
    d = {-1:0, 1:0}
    que = deque()
    que.append((start, 1))
    while que:
        cur, flag = que.popleft()
        if used[cur] == flag:
            continue
        elif used[cur]:
            return False
        used[cur] = flag
        d[flag] += 1
        for to in range(n):
            if G[cur][to] and used[to] == 0:
                que.append((to, -flag))
    tmp.append(list(d.values()))
    return True

if not all(bfs(i) for i in range(n)):
    print(-1)
else:
    s = set([0])
    target = (n+1)//2
    for l in tmp:
        t = set()
        for a in l:
            for b in s:
                if a+b <= target:
                    t.add(a+b)
        s = t
    k = max(s)
    l = n-k
    ans = k*(k-1)//2 + l*(l-1)//2
    print(ans)

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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  sort(A.begin(), A.end());

  // 常に体力が最小のモンスターが次に小さいモンスターを攻撃する
  while (A.size() > 1) {
    // 最小のモンスターが次に小さいモンスターを攻撃する
    // A.at(1) -= A.at(0);
    A.at(1) = A.at(1) % A.at(0);

    // 攻撃されたモンスターが死んだか
    if (A.at(1) <= 0) {
      A.erase(A.begin() + 1);
      continue;
    }

    // 最小のモンスターが入れ替わったか
    if (A.at(0) > A.at(1)) {
      swap(A.at(0), A.at(1));
    }
  }

  cout << A.at(0) << endl;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

Ki G;
map<P,int> ans; // 辺の情報はmapに<P,int>に保存するのが賢い

void dfs(int pre,int now){
    int c=1;
    for(auto &next:G[now]){
        if(pre==next) continue;
        if(c==ans[{pre,now}]) c++;
        ans[{next,now}]=ans[{now,next}]=c;
        dfs(now,next);
        c++;
    }
}

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

    int n;
    cin>>n;
    G.resize(n);
    vector<P> ed;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        ed.pb(P(a,b));
        G[a].pb(b);
        G[b].pb(a);
    }

    dfs(-1,0);

    ll memo=0;
    rep(i,n){
        memo=max(memo,(ll)G[i].size());
    }
    cout<<memo<<endl;

    rep(i,n-1){
        cout<<ans[ed[i]]<<endl;
    }
    
    

    
}

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

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

    vector<int> exist(310);
    rep(i,n) { int t; cin >> t; exist[105+t]=1; }

    int ans = x;
    rep(d, n+1) {
        if (!exist[105+x-d]) { ans = x-d; break; }
        if (!exist[105+x+d]) { ans = x+d; break; }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <algorithm>

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while( 1 ) {
		int e;
		cin >> e;
		if( e == 0 ) break;
		unsigned long long int ans = e;
		for(long long int z = 0; z*z*z <= e; z++) {
			for(long long int y = 0; z*z*z + y*y <= e; y++) {
				long long int x = e - z*z*z - y*y;
				if( x + y + z <= ans ) ans = x + y + z;
			}
		}
		cout << ans << endl;
	}

	//while(1){}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n);
  re(i, n){
    std::cin >> a[i];
    a[i] = (i==0?0:a[i-1]) + a[i];
  }
  ll c = 0, ans = 0, t = 0;
  // -
  for(int i=0;i<n;i++){
    if(i%2==0&&a[i]+c>=0) ans += abs(a[i]+c)+1, c -=  abs(a[i]+c)+1;
    else if(i%2==1&&a[i]+c<=0) ans+=abs(a[i]+c)+1, c+= abs(a[i]+c)+1;
  }
  t = ans, c = 0, ans = 0;
  // +
  for(int i=0;i<n;i++){
    if(i%2==1&&a[i]+c>=0) ans += abs(a[i]+c)+1, c -=  abs(a[i]+c)+1;
    else if(i%2==0&&a[i]+c<=0) ans+=abs(a[i]+c)+1, c+= abs(a[i]+c)+1;
  }
  std::cout << min(ans, t) << '\n';
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())
    K = int(input())
    print('Yay!'if max(A, B, C, D, E) - min(A, B, C, D, E) <= K else ':(')


if __name__ == "__main__":
    main()


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A+B)>(C+D)) {
    cout << "Left" << endl;
  }
  
  if ((A+B)==(C+D)) {
    cout << "Balanced" << endl;
  }
  
  if ((A+B)<(C+D)) {
    cout << "Right" << endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    
    
    string s;
    cin >> s;
    if (s == "Y"){
      cout << "Four" << endl;
      break;
    }
    
    if(i == N-1){
      cout << "Three" << endl;
    }
  
  }
}
  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int L, R;
    cin >> L >> R;
    int ans;
    if(R / 2019 == L / 2019){
        L %= 2019;
        R %= 2019;
        ans = L * (L + 1) % 2019;
        rng(i,L,R){
            rng(j,i+1,R+1){
                ans = min(ans,i * j % 2019);
            }
        }
        //cout << "true" << endl;
    }
    else{
        ans = 0;
        //cout << "false" << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main (void)
{
    long long N;
    long long in;
    long long ac,wa,tle,re;
    char c;

    int s=0;

    char *AC="AC";
    char *WA="WA";
    char *TLE="TLE";
    char *RE="RE";

    char header[4];

    ac=0;
    wa=0;
    tle=0;
    re=0;

    scanf("%lld",&N);

    for(in=0;in<N;in++){

        //get judge
        scanf("%s",header);

        //classing judge
        if(strcmp(AC,header)==0){
            ac++;

        }else if(strcmp(WA,header)==0){
            wa++;

        }else if(strcmp(TLE,header)==0){
            tle++;

        }else if(strcmp(RE,header)==0){
            re++;

        }
        
    }

    printf("AC x %lld\n",ac);
    printf("WA x %lld\n",wa);
    printf("TLE x %lld\n",tle);
    printf("RE x %lld\n",re);



    return 0 ;

}

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;


int main() {
    int k; cin >> k;
    cout << k/2 * (k - k/2) << endl;

    return 0;
}


    


Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)
count = 0

while true
    left = h.index{|i| i > 0 }
    if left.nil?
        break
    end

    right = nil
    for i in left..h.length-1
        if h[i] == 0
            right = i - 1
            break
        end
    end
    if right.nil?
        right = h.length-1
    end

    d = h[left..right].min
    for j in left..right
        h[j] -= d
    end
    count += d
end

puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    map<char, string> cards;
    map<char, int> idx;
    string T = "abc";
    for(auto e : T){
        idx[e] = 0;
        cin >> cards[e];
    }

    char t = 'a';
    while(true){
        if(idx[t] == cards[t].size()){
            cout << (char)(t - 'a' + 'A') << endl;
            break;
        }
        t = cards[t][idx[t]++];
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

count = [0 for i in range(10**5+1)]

for a_i in A:
    count[a_i] += 1

bef_ans = 0
for i in range(Q):
    B, C = map(int, input().split())
    tmp = count[B]
    count[B] = 0
    count[C] += tmp
    ans = 0
    if i == 0:
        for j in range(10**5+1):
            ans += j*count[j]
    else:
        ans = bef_ans - B*tmp + C*tmp
    print(ans)
    bef_ans = ans


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<vector<LL>> a(N,vector<LL>(N));
	repp(i,0,N) repp(j,0,N) cin >> a[i][j];
	vector<LL> s(1<<N,0),dp(1<<N,0);
	repp(i,1,1<<N){
		int j = 0;
		while(!(i&(1<<j))) ++j;
		repp(k,j+1,N) if((i&(1<<k))) s[i] += a[j][k];
		s[i] += s[i^(1<<j)];
	}
	repp(i,0,1<<N) for(int m = (((1<<N)-1)^i) ; m > 0 ; m = (m-1)&(((1<<N)-1)^i)){
		dp[i^m] = max(dp[i^m],dp[i]+s[m]);
	}
	cout << dp[(1<<N)-1] << endl;
	return 0;
}


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

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

    vector<int> v(m + 1, 0);
    vector<vector<int> > a(n + 1, v);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            // cout << "a[" << i << ", " << j << "] ?";
            cin >> a[i][j];
            a[i][m] += a[i][j];
            a[n][j] += a[i][j];
            a[n][m] += a[i][j];
        }
    }

    for (int i = 0; i < n + 1; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cout << a[i][j] << " ";
        }
        cout << a[i][m] << endl;
        // cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();
		if(s.length()<4) {
			System.out.println("No");
			return;
		}
		if(s.substring(0,4).equals("YAKI"))  System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 21844
"""
~~ Author : Bhaskar
~~ Dated : 07~06~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi,log
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")

def solve():
    a,b = map(int,sys.stdin.readline().split())
    ok = False
    for i in range(0,101):
        for j in range(0,101):
            if i + j == a and 2*i+4*j == b:
                ok = True
                break
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    # try:
    #     sys.stdin = open("input.txt","r")
    # except :
    #     pass
    solve()



"""

2*x + 4*y = b


"""


Measured memory_bytes: 9484
n = int(input())
ps = list(map(int, input().split(" ")))
res = 0
for i in range(1, n-1):
    p1 = ps[i-1]
    p2 = ps[i]
    p3 = ps[i+1]
    minimum = min(p1, p2, p3)
    maximum = max(p1, p2, p3)
    if p2 != minimum and p2 != maximum:
        res += 1
print(res)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    string S;
    cin >> N;
    cin >> S;
    ll countR[N], countG[N], countB[N];
    REP(i, N)
    {
        countR[i] = 0;
        countG[i] = 0;
        countB[i] = 0;
    }
    if (S[0] == 'R') countR[0] = 1;
    else if (S[0] == 'G') countG[0] = 1;
    else if (S[0] == 'B') countB[0] = 1;
    for (int i = 1; i < N; ++i)
    {
        if (S[i] == 'R') 
        {
            countR[i] = countR[i - 1] + 1;
            countG[i] = countG[i - 1];
            countB[i] = countB[i - 1];
        }
        else if (S[i] == 'G') 
        {
            countR[i] = countR[i - 1];
            countG[i] = countG[i - 1] + 1;
            countB[i] = countB[i - 1];
        }
        else if (S[i] == 'B') 
        {
            countR[i] = countR[i - 1];
            countG[i] = countG[i - 1];
            countB[i] = countB[i - 1] + 1;
        }
    }

    ll ans = 0;
    for (int i = 0; i < N - 2; ++i)
    {
        for (int j = i + 1; j < N - 1; ++j)
        {
            if (S[i] != S[j])
            {
                if (S[i] == 'R' && S[j] == 'G')
                {
                    ans += countB[N - 1] - countB[j];
                    if (2 * j - i < N && S[2 * j - i] == 'B') ans--;
                }
                else if (S[i] == 'R' && S[j] == 'B')
                {
                    ans += countG[N - 1] - countG[j];
                    if (2 * j - i < N && S[2 * j - i] == 'G') ans--;
                }
                else if (S[i] == 'G' && S[j] == 'R')
                {
                    ans += countB[N - 1] - countB[j];
                    if (2 * j - i < N && S[2 * j - i] == 'B') ans--;
                }
                else if (S[i] == 'G' && S[j] == 'B')
                {
                    ans += countR[N - 1] - countR[j];
                    if (2 * j - i < N && S[2 * j - i] == 'R') ans--;
                }
                else if (S[i] == 'B' && S[j] == 'R')
                {
                    ans += countG[N - 1] - countG[j];
                    if (2 * j - i < N && S[2 * j - i] == 'G') ans--;
                }
                else if (S[i] == 'B' && S[j] == 'G')
                {
                    ans += countR[N - 1] - countR[j];
                    if (2 * j - i < N && S[2 * j - i] == 'R') ans--;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3736
n, t = map(int, input().split())
ls_ct = [[int(_) for _ in input().split()] for _ in range(n)]

ans = 1001

for i in range(n):
    if ls_ct[i][0] <= ans and ls_ct[i][1] <= t:
        ans = ls_ct[i][0]
        
if ans == 1001:
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 3060
#include<iostream>

int main() {
	int a, b;
	int ans;


	std::cin >> a >> b;

	ans = a + b;
	if (ans < a - b) {
		ans = a - b;
	}
	if (ans < a*b) {
		ans = a*b;
	}
	

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    ll cnt = 0,ind = 0;
    for(ll i = 0;i < S.size();i++){
        if(S[i] != 'W')continue;
        cnt += i - ind;
        ind++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

get_point = []
score = 0

for i in range(n):
    if t[i] == 'r':
        if i - k < 0 or get_point[i-k] != 'p':
            score += p
            get_point.append('p')
        else:
            get_point.append('e')
    elif t[i] == 's':
        if i - k < 0 or get_point[i-k] != 'r':
            score += r
            get_point.append('r')
        else:
            get_point.append('e')
    elif t[i] == 'p':
        if i - k < 0 or get_point[i-k] != 's':
            score += s
            get_point.append('s')
        else:
            get_point.append('e')

print(score)


Measured memory_bytes: 47600
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int h, w;
    const long long d = 1000000000 + 7;
    cin >> h >> w;
    vector<string> a(h);
    long long dp[h][w];
    for (int i=0; i<h; ++i){
        cin >> a[i];
    }
    for (int i=0; i<h; ++i){
        for (int j=0; j<w; ++j){
            dp[i][j] = 0;
        }
    }
    for (int i=0; i<h; ++i){
        for (int j=0; j<w; ++j){
            if(a[i][j] == '#'){continue;}
            if(i == 0 && j == 0){
                dp[0][0] = 1;
            }
            else {
                if(j - 1 >= 0 && i - 1 >= 0){
                    dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % d;
                }
                else if(j - 1 >= 0){
                    dp[i][j] = dp[i][j-1];
                }
                else if(i - 1 >= 0){
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; ++i) cout << s.at(i) << t.at(i);
    cout << endl;
    return 0;
}


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

int main(){
	int r,c;
	cin>>r>>c;

	int num[101][101]={};
	for(int i=0;i<r;i++){
	  for(int j=0;j<c;j++){ 
	    cin>>num[i][j];
	  }
	}
	for(int i=0;i<r;i++){
	  for(int j=0;j<c;j++){ 
	    num[r][c] +=num[i][j];
	  }
	}
	for(int i=0;i<r;i++){
	  int sum=0;
	  for(int j=0;j<c;j++){ 
	    sum +=num[i][j];
	  }
	  num[i][c] =sum;
	}
	for(int j=0;j<c;j++){ 
	  int sum=0;
	  for(int i=0;i<r;i++){
	      sum +=num[i][j];
	  }
	  num[r][j] =sum;
	}
	for(int i=0;i<=r;i++){
	  for(int j=0;j<=c;j++){
	    if(j) cout<<" ";
	    cout<<num[i][j];
	  }
	cout<<endl;
    }
  return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n-1; i >= 0; i--)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd2(i, s, n) for (ll i = n-1; i >= (s); i--)

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep2(i, 1, n) {
        if (a[i] < a[i-1]) {
            ans += a[i-1]-a[i]; 
            a[i] += a[i-1]-a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4792
#include <iostream>
using namespace std;
 
int main()
{
    int m, f, r;
 
    for (cin >> m >> f >> r; ~m | ~f | ~r; cin >> m >> f >> r){
 
        if (m == -1 || f == -1) cout << 'F' << endl;
        else if (m + f >= 80) cout << 'A' << endl;
        else if (m + f >= 65) cout << 'B' << endl;
        else if (m + f >= 50 || (m + f >= 30 && r >= 50)) cout << 'C' << endl;
        else if (m + f >= 30) cout << 'D' << endl;
        else cout << 'F' << endl;
    }
 
    return 0;
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    lint x;
    cin >> x;
    vector<lint> base;
    for(lint i = -150; i <= 150; i++) base.pb(pow(i, 5));
    for(lint i = -150; i <= 150; i++) {
        for(lint j = -150; j <= 150; j++) {
            if(x == base[i+150] - base[j+150]) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
    
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    for(int i=0; i<H; i++) cin >> S[i];
    if(H==1 && W == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            bool flg = false;
            if(S[i][j] == '#') {
                if(i+1 < H && S[i+1][j] == '#') {
                    flg = true;
                }
                else if(i-1 >= 0 && S[i-1][j] == '#') {
                    flg = true;
                }
                else if(j+1 < W && S[i][j+1] == '#') {
                    flg = true;
                }
                else if(j-1 >= 0 && S[i][j-1] == '#') {
                    flg = true;
                }
            }
            else if(S[i][j] == '.') flg = true;
            if (flg == false) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main() {
    int pwr[] = {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
    int A, B;
    string ans;
    cin >> A >> B;
    if (pwr[A] > pwr[B]) ans = "Alice";
    else if (pwr[A] < pwr[B]) ans = "Bob";
    else ans = "Draw";
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter

N= int(input())
A = list(map(int, input().split()))
Q = int(input())

counter = Counter(A)

baseline = sum(k*v for k, v in counter.items())
#print(baseline)

for i in range(Q):
    b, c = map(int, input().split())
    n = counter.pop(b, 0)
    baseline += n * (c - b)
    counter[c] += n
    print(baseline)

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

int main() {
  int N;
  cin >> N;
  if(N == 1) {
    cout << "Hello World" << endl;
  } else if(N == 2) {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class Main {
	static boolean debug = false;

	public static void main(String[] args) throws IOException {

		UserScanner scan = new UserScanner();
		PrintWriter pwriter = new PrintWriter(System.out);

		int n = scan.nextInt();
		int kw = scan.nextInt();
		Knap knap = new Knap(n);
		for (int i = 0; i < n; i++)
			knap.addItem(i, scan.nextInt(), scan.nextInt());
		pwriter.println(knap.getAnswer(kw));

		pwriter.flush();
		scan.close();
		System.exit(0);
	}
}

class Knap {
	int[] v, w;
	int[][] hist;

	public Knap(int n) {
		v = new int[n];
		w = new int[n];
	}

	public int getAnswer(int kw) {
		hist = new int[v.length][kw + 1];
		for (int i = 0; i < hist.length; i++)
			for (int j = 0; j < hist[0].length; j++)
				hist[i][j] = -1;
		return getMaxValue(kw, v.length - 1);
	}

	private int getMaxValue(int kw, int e) {
		if (kw < 0)
			return Integer.MIN_VALUE / 2;
		if (e < 0)
			return 0;
		if (hist[e][kw] >= 0)
			return hist[e][kw];
		int max = Math.max(this.v[e] + getMaxValue(kw - this.w[e], e - 1), getMaxValue(kw, e - 1));
		hist[e][kw] = max;
		return max;
	}

	public void addItem(int i, int v, int w) {
		this.v[i] = v;
		this.w[i] = w;
	}

}

class UserScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean read() throws IOException {
		ptr = 0;
		buflen = in.read(buffer);
		if (buflen <= 0)
			return false;
		else
			return true;
	}

	private byte getByte() throws IOException {
		if (ptr >= buflen)
			read();
		if (isCtlSpace(buffer[ptr])) {
			return -1;
		} else
			return buffer[ptr++];
	}

	private void skipCtlSpace() throws IOException {
		if (ptr >= buflen)
			read();
		if (isCtlSpace(buffer[ptr])) {
			ptr++;
			skipCtlSpace();
		}
	}

	private boolean isCtlSpace(byte b) {
		if (b <= ' ' || b > '~')
			return true;
		else
			return false;
	}

	public void close() throws IOException {
		in.close();
	}

	public String next() throws IOException {
		skipCtlSpace();
		StringBuilder sb = new StringBuilder();
		byte b;
		while ((b = getByte()) != -1) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() throws IOException {
		skipCtlSpace();
		int n = 0;
		boolean minus = false;
		byte b;
		while ((b = getByte()) != -1) {
			if (b == '-')
				minus = true;
			else {
				n *= 10;
				n += (b - '0');
			}
		}
		if (minus)
			return n * -1;
		else
			return n;
	}
}

Measured memory_bytes: 29628
N, M, Q = map(int, input().split())
dp = [[0]*N for i in range(N)]
for i in range(M):
  l, r = map(int, input().split())
  dp[r-1][l-1] += 1
for i in range(N):
  for j in range(N-1, 0, -1):
    dp[i][j-1] += dp[i][j]
for j in range(N):
  for i in range(N-1):
    dp[i+1][j] += dp[i][j]
for i in range(Q):
  p, q = map(int, input().split())
  print(dp[q-1][p-1])

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

using namespace std;

char str[10010];
int a, b;

int main() {
    while(scanf("%d %d", &a, &b) != EOF) {
        scanf("%s", str);
        if (a < 1 || a > 5 || b < 1 || b > 5 || strlen(str) != a + b + 1 || str[a] != '-') {
            printf("No\n");
        }
        else {
            bool flag = true;
            for (int i = 0; i < strlen(str); i++) {
                if (i != a && (str[i] < '0' || str[i] > '9')) {
                    flag = false;
                    break;
                }
            }
            if (flag) printf("Yes\n");
            else printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
//全华班
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define LL long long
#define pll pair<LL, LL>
#define pii pair<int, int>

const LL mod = 1e9 + 7;
const int maxn = 1e5 + 5;
const LL inf = 0x3f3f3f3f;
const double eps = 1e-8;
const double pi = acos(-1.0);

int w[maxn], v[maxn], dp[maxn];

int main() {
	int n, W; cin >> n >> W;
	for(int i = 1; i <= n; ++i) {
		cin >> w[i] >> v[i];
	}
	memset(dp, 0x3f, sizeof dp);
	dp[0] = 0;
	for(int i = 1; i <= n; ++i) {
		for(int j = maxn - 1; j >= v[i]; --j) {
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	for(int i = maxn - 1; i > 0; --i) {
		if(dp[i] > W) continue;
		cout << i << endl; break;
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int count = 0;
  for(int i = 1;i <= n;i++){
    count += i;
    if(count >= n){
      for(int j = 1;j <= i;j++){
        if(count - n != j && j != i){
          cout << j << " ";
        }else if(j == i){
          cout << j;
        }
      }
      break;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int x, n;
  cin >> x >> n;
  if (n == 0) {
    cout << x << endl;
    return 0;
  }
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  if (x < p[0] || p[n - 1] < x) {
    cout << x << endl;
    return 0;
  }
  int ans = -1;
  int diff = (int)1e9;
  for (int y = p[0] - 1; y <= p[n - 1] + 1; ++y) {
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      if (y == p[i]) {
        ok = false;
      }
    }
    if (ok) {
      if (abs(y - x) < diff) {
        ans = y;
        diff = abs(y - x);
      }
    }
  }
  if (ans == -1) {
    if (abs(p[0] - 1 - x) < abs(p[n - 1] + 1 - x)) {
      cout << p[0] - 1 << endl;
    } else {
      cout << p[n - 1] + 1 << endl;
    }
  } else {
    if (abs(p[0] - 1 - x) < diff) {
      ans = p[0] - 1;
      diff = abs(p[0] - 1 - x);
    }
    if (abs(p[n - 1] + 1 - x) < diff) {
      ans = p[n - 1] - 1;
      diff = abs(p[n - 1] + 1 - x);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> now(3, 0);
  ll res = 3;
  bool ok = 1;
  for (int i = 0; i < n; i++){
    ll a;
    cin >> a;
    
    if (i != 0){
      if (a == now[0] && now[0] == now[1] && now[1] == now[2]){
        res *= 3;
        res %= MOD;
        now[2]++;
      }
      else if (a == now[0] && now[0] == now[1]){
        res *= 2;
        res %= MOD;
        now[1]++;
      }
      else if (a == now[0]){
        now[0]++;
      }
      else if (a == now[1] && now[1] == now[2]){
        res *= 2;
        res %= MOD;
        now[2]++;
      }
      else if (a == now[1]){
        now[1]++;
      }
      else if (a == now[2]){
        now[2]++;
      }
      else
        ok = 0;
    }
    else {
      if (a == 0)
        now[2]++;
      else
        ok = 0;
    }
  }

  if (ok)
    cout << res << endl;
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ll long long
#define mp make_pair
#define MAXN 1e6
const int mod=1e9+7;

void solve()
{
  int n,x;
  cin>>n;
  ll dp[n];
  vector<int> V;
  for(int i=0;i<n;i++)
  {
    dp[i]=INT_MAX;
    cin>>x;
    V.pb(x);
  }
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(V[i]-V[i-1]),dp[i-2]+abs(V[i-2]-V[i]));
  }
  cout<<dp[n-1]<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 1528
#!/usr/bin/env python3
import sys


def solve(O: str, E: str):
    print("".join(oi + ei for oi, ei in zip(O, E + " ")).strip())


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    O = next(tokens)  # type: str
    E = next(tokens)  # type: str
    solve(O, E)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;//ノードの数
int q;//操作回数
int par[100010];
int rank[100010];
bool marked[100010];
void init(int v){
	par[1] = 1;
	marked[1] = true;
	for(int i = 2;i <=n;i++){
		par[i] = i;
		marked[i]= false;
	}
}
int getnode(int x){
	if(marked[x])
		return x;
	else
		return getnode(par[x]);
}
int main(){
	long long sum;
	while(cin>>n>>q,n||q){
		init(n);
		sum = 0;
		for(int i = 2;i <=n;i++){
			int a;
			cin>>a;
			par[i] =a;
		}
		for(int i = 0;i < q;i++){
			char op;
			int k;
			cin>>op>>k;
			if(op=='Q'){
				while(!marked[k]) k =par[k];
				sum +=k;
			}
			if(op=='M'){
				marked[k] = true;
			}
		}
		cout <<sum<<endl;
	}
}

Measured memory_bytes: 1648
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 1;
//***********//

int main() {
	ll X;
	ll p = -1000000;
	ll q = 1000000;
	cin >> K >> X;
	for (i = max(p, X - K + 1); i <= min(q, X + K - 1); i++) {
		cout << i << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

ll check(ll n){
  ll ans;
  n/=5;
  if(n<1){
    return 0;
  }
  else{
    ans=n+check(n);
  }
  return ans;
}

int main(){
  ll n;
  cin>>n;
  if(n%2==0){
    n/=2;
    cout<<check(n)<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;


int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  i64 a; float b;
  cin >> a >> b;
  i64 c = b * 100 + 0.1;
  kek((a * c) / 100);
}


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

int main(){
    int n;
    cin >> n;
    long long lucas[87];

    lucas[0] = 2; lucas[1] =1;
    for(int i = 2; i <= 86; i++){
        lucas[i] = lucas[i-1] + lucas[i-2];
    }
    cout << lucas[n] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
 
map<ll,ll> lcm;
set<ll> c;
void prime_factor(ll n){
	map<ll,ll> res;
	for(ll i = 2; i * i  <= n; i++) {
		bool flag = false;
		while(n % i == 0){
			res[i]++;
			n /= i;
			flag = true;
		}
		if (flag){
			lcm[i] = max(lcm[i],res[i]);
			c.insert(i);
		}
	}
	if (n != 1){
		res[n] = 1;
		lcm[n] = max(lcm[n],res[n]);
		c.insert(n);
	}
}
 
ll mod_pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1){
			res = res * x % mod;
		}
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}
 
 
int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	ll m = 0;
	for(int i = 0; i < n; i++) {
		cin>>a[i];
		prime_factor(a[i]);
		m = max(m,a[i]);
	}
	ll l = 1;
	// for(auto i = c.begin();i != c.end();i++) {
	// 	cout << *i << endl;
	// }
	for (auto i = c.begin();i != c.end();i++){
		l *= ((mod_pow(*i,lcm[*i])) % mod);
		l %= mod;
    }
	l %= mod;
	
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		ans += (l * mod_pow(a[i],mod - 2)) % mod;
	}
	cout << ans % mod << endl;
	
	return 0;
}

Measured memory_bytes: 1408
## ABC 060 b
import sys
a,b,c = (int(_) for _ in input().split())

m = []
n = 0
while(True):
    t = (a*n)%b
    if(t in m):
        print('NO')
        sys.exit()
    else:
        m.append(t)
    if(t == c):
        print('YES')
        sys.exit()
    n += 1

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,N,x,cnt=0,ans=0;
  cin>>N;
  vector<ll> v;
  rep1(i,N+1){
    cin>>x;
    if(x==i){
      v.push_back(x);
    }
  }
  rep(i,(ll)v.size()){
    if(i<(ll)v.size()-1&&v[i]+1==v[i+1]){
        i++;
    }
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>

int fibs[50] = {1, 1};

int fib(int n)
{
	if (n == 0 || n == 1) return fibs[n];
	if (fibs[n]) return fibs[n];
	return fibs[n] = fib(n - 1) + fib(n - 2);    // pay attension to here.
}

int main()
{
	int n;
	std::cin >> n;
	std::cout << fib(n) << std::endl;

	return 0;
}


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

int main(){
	int n;
	int a[100010];
	cin>>n;
	for(int i=0;i<n;i++){
        cin>>a[i];
	}
	int i;
	for( i=1;i<n;i++){
        if(a[i]-1>=a[i-1]){
            a[i]--;
        }
        else if(a[i]>=a[i-1]){
            ;
        }
        else{
            cout<<"No"<<endl;
            break;
        }
	}
	if(i==n) cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 640