akhauriyash/Code-Regression huggingface dataset:
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string S;
	scan(N>>S);
	int rnum=0;
	rep(i,N) if(S[i]=='R') rnum++;
	int ans=0;
	rep(i,rnum) if(S[i]=='W') ans++;
	prin(ans);
	return 0;
}


Measured memory_bytes: 3720
package  main
import (
        "fmt"
        "sort"
)

func main  () {
        var a, n, x, an, ana int
        ni := []int{}
        fmt.Scan(&n)
        for i := 0 ; i < n ; i++ {
                fmt.Scan(&a)
                ni = append (ni, a)
        }
        sort.Sort(sort.IntSlice(ni))
        y := n - 1 
        for i := 0 ; i < n ; i ++ {
                z := y - i
                if x == 0 {
                        an = an + ni[z]
                        x += 1
                }  else if x == 1 {
                        x = 0
                        ana = ana + ni[z]
                }
        }
        fmt.Println(an-ana)
}


Measured memory_bytes: 512
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
a = [int(x) for x in input().split()]

sold_day = set()
buy_day = set()

for i in range(1, n):
    if a[i] > a[i - 1]:
        sold_day.add(i)
        sold_day.discard(i - 1)

money = 1000
stock = 0

sold_day = list(sold_day)
sold_day.sort()

s = 0

for i in sold_day:
    temp = a[s:i]
    min_value = min(temp)
    x = money // min_value
    money -= min_value * x
    money += x * a[i]
    s = i + 1
print(money)


Measured memory_bytes: 61852
s = input()

i = len(s)
p = ''
while i>=5:
    if s[i-5:i] == 'dream':
        i -= 5
    elif s[i-5:i] == 'erase':
        i -= 5
    elif i>= 6 and s[i-6:i] == 'eraser':
        i -= 6
    elif i>= 7 and s[i-7:i] == 'dreamer':
        i -= 7
    else:
        print('NO')
        exit()
if i == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    string s; cin >> s;
    ll mn = INF;
    rep(i,s.size()-2){
        ll tmp = (s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
        mn = min(mn,abs(tmp-753));
    }
    cout << mn << endl;
}


Measured memory_bytes: 256
#include <iostream> 
#include <algorithm>
#include <cmath>
#include <vector>
#include <tuple>
#include <queue>  
#define ll long long
  
using namespace std; 

int N,M,L;

ll inf = 99999999999999;

int main() {
    cin >> N >> M >> L;
    ll dist[N][N]; // Oil refill, left (-1 is impossible)
    ll dist_oil[N][N];

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dist[i][j] = -1;
        }
    }

    for (int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        if (L >= C) {
            dist[A-1][B-1] = C;
            dist[B-1][A-1] = C;
        }
    }

    for (int i = 0; i < N; i++) {
        dist[i][i] = 0;
    }

    // Floyd!!!
    for (int k = 0; k < N; k ++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {

                if ((dist[i][k] != -1) & (dist[k][j] != -1)) {

                    if (((dist[i][k] + dist[k][j]) < dist[i][j]) | (dist[i][j] == -1)) {
                        dist[i][j] = dist[i][k] + dist[k][j];
                    }    
                }    
            }
        }
    }

    for (int i = 0; i < N; i ++) {
        for (int j = 0; j < N; j++) {
            dist_oil[i][j] = (dist[i][j] > L) | (dist[i][j] == -1) ? -1 : 1;
        }
    }

    for (int k = 0; k < N; k ++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {

                if ((dist_oil[i][k] != -1) & (dist_oil[k][j] != -1)) {

                    if (((dist_oil[i][k] + dist_oil[k][j]) < dist_oil[i][j]) | (dist_oil[i][j] == -1)) {
                        dist_oil[i][j] = dist_oil[i][k] + dist_oil[k][j];
                    }    
                }    
            }
        }
    }

    int Q;
    cin >> Q;
    int answers[Q];
    for (int i = 0; i < Q; i++) {
        int u, v;
        cin >> u >> v;
        answers[i] = dist_oil[u-1][v-1];
    }

    for (int i = 0; i < Q; i++) {
        if (answers[i] == -1) cout << answers[i] << endl;
        else cout << answers[i] - 1 << endl;
    }

}

Measured memory_bytes: 2304
import std.algorithm, std.conv, std.range, std.stdio, std.string;

const alpha = 26, a = 'a';

void main()
{
  auto n = readln.chomp.to!size_t;

  auto b = new int[](alpha), bs = new int[](alpha);
  b[] = int.max;

  foreach (_; 0..n) {
    auto s = readln.chomp;
    bs[] = 0;
    foreach (c; s) ++bs[c-a];
    foreach (i; 0..alpha) b[i] = min(b[i], bs[i]);
  }

  foreach (i; 0..alpha)
    foreach (j; 0..b[i])
      write(cast(char)(a+i));
  writeln;
}


Measured memory_bytes: 256
v=[-1,2,5,5,4,5,6,3,7,6]

N,M=map(int, input().split())
A=sorted(map(int, input().split()), reverse=True)

dp=[0]*(N+999)
mp=[[] for _ in range(N+999)]

for a in reversed(A):
	dp[v[a]] = 1
	mp[v[a]] = [a]

for i in range(N+1):
	for a in A:
		if i-v[a] >= 0 and dp[i-v[a]] > 0 and dp[i] < 1 + dp[i-v[a]]:
			dp[i] = 1 + dp[i-v[a]]
			mp[i] = [a] + mp[i-v[a]]

print("".join(map(str, mp[N])))


Measured memory_bytes: 256392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll dp[42][(1<<17)+10];
int n,x,y,z;
int main()
{
    while(cin>>n>>x>>y>>z)
    {
        ll ans=1;
        for(int i=0;i<n;i++)
            ans=ans*10%mod;
        int now=(1<<x-1)|(1<<x+y-1)|(1<<x+y+z-1);
        int S=(1<<x+y+z)-1;
        dp[0][0]=1;
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<=S;j++)
            {
                for(int k=1;k<=10;k++)
                {
                    int cur=(j<<k)|(1<<k-1);
                    cur&=S;
                    if((cur&now)!=now)
                        dp[i][cur]=(dp[i][cur]+dp[i-1][j])%mod;
                }
            }
        }
        for(int i=0;i<=S;i++)
            ans=(ans-dp[n][i]+mod)%mod;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 42240
#include <stdio.h>

int main(){

  int num[100], i,j,n,f=0,a=0,z,c=0;


  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
  
  for(i=0;i<n-1;i++){
    f=1;
    
    while(f){
      f=0;
      
      for(j=n-1;j>0;j--){
	if(num[j] < num[j-1]){
	  
	  z=num[j];
	  num[j]=num[j-1];
	  num[j-1]=z;
	  c+=1;

	  f=1;
	}
      }
    }
  }

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

  printf("%d\n",num[n-1]);
  printf("%d\n",c);
  return 0;
}
	
    




Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

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

    int n = S.size();

    ll dp[n+10][13];
    rep(i,n+1) rep(j,13) dp[i][j] = 0;
    dp[0][0] = 1;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 13; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                if (S[i] != '?' && S[i] != ('0' + k)) continue;

                dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
                dp[i + 1][(j * 10 + k) % 13] %= mod;
            }
        }
    }

    cout << dp[n][5] << endl;
    return 0;
}

Measured memory_bytes: 10624
n = int(input())
s = list(input().strip())

min = -1

for i in range(n):
    if i == 0:
        turn = s[i+1:n].count("E")
    else:
        if s[i-1] == "W" and s[i] == "W":
            turn += 1
        elif s[i-1] == "W" and s[i] == "E":
            next
        elif s[i-1] =="E" and s[i] =="W":
            next
        else:
            turn -=1
    if min == -1 or min >= turn:
        min = turn
        
    

print(min)


Measured memory_bytes: 8140
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ull unsigned long long
#define endl '\n'

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5+1;
const ll P = 31;
const double PI = acos(-1.0);

int main() {
//  freopen("angle2.in", "r", stdin);
//  freopen("angle2.out", "w", stdout);
    IOS
    ll n;
    cin >> n;
    ll x =  (n%1000 == 0) ? n/1000 : n/1000+1;
    cout << (x*1000)-n << endl;
}
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 3700
#include <iostream>

using namespace std;

int main()
{
    int A, B, L;
    cin >> A >> B;
    L = 2 * B;
    if (A <= L)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << A - L << endl;
    }
    return 0;
}

Measured memory_bytes: 888
# coding: utf-8
import math

a, b, C = map(float, input().split())
S =  0.5 * a * b * math.sin(C * math.pi / 180)
L = a + b + (a ** 2 + b ** 2 - 2 * a * b * math.cos(C * math.pi / 180)) ** 0.5
h = 2 * S / a

print("%f\n%f\n%f" % (S, L, h))


Measured memory_bytes: 5716
s=input()
if 1<=int(s[0])*10+int(s[1])<=12:
  if 1<=int(s[2])*10+int(s[3])<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=int(s[2])*10+int(s[3])<=12:
    print("YYMM")
  else:
    print("NA")

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


int main (){
 int A , B , C , D ;
 cin >> A >> B >> C >> D ;
 int X =( A + D -1)/ D ;
 int Y =( C + B -1)/ B ;
 cout <<( X >= Y ? "Yes" : "No" )<< "\n" ;
  return 0;
}

Measured memory_bytes: 3644
N=int(input())
s=[0, 3, 2]
s=[int(input()) for i in range(N)]
ans=sum(s)
min=max(s)
if ans%10==0:
    for i in range(N):
        if min>s[i] and s[i]%10!=0:
            min=s[i]
    ans-=min
if ans%10==0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3064
#include<iostream>

int main(void){
	int a, b, c, t;
	
	std::cin >> a >> b >> c;
	
	/*まず a と b を並べる*/
	if (a > b){ 
		t = a;
		a = b;
		b = t;
	}
	
	/*そして 3 パターンに場合分け*/
	if (c <= a) std::cout << c << " " << a << " " << b << std::endl;
	else if (c >= b) std::cout << a << " " << b << " " << c << std::endl;
	else std::cout << a << " " << c << " " << b << std::endl;
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>


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

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;

using namespace std;
typedef long long ll;


int dh[] = { 1,0,-1,0 };
int dw[] = { 0,1,0,-1 };

vector<int> BFS01(int start, vector<vector<pair<int, int>>>& g) {
	vector<int> d(g.size(), inf);
	d[start] = 0;
	deque<int> dq; dq.emplace_back(start);
	vector<bool> used(g.size());
	while (!dq.empty()) {
		int cur = dq.front();
		dq.pop_front();
		if (used[cur]) continue;
		used[cur] = true;
		for (auto nxt : g[cur]) {
			int to, cost; tie(to, cost) = nxt;
			if (chmin(d[to], d[cur] + cost)) {
				if (cost == 0) dq.emplace_front(to);
				else dq.emplace_back(to);
			}
		}
	}
	return d;
}

int main()
{

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

	int H, W; cin >> H >> W;
	int sh, sw; cin >> sh >> sw; sh--; sw--;
	int th, tw; cin >> th >> tw; th--; tw--;
	vector<string> vs(H); for (int i = 0; i < H; i++) cin >> vs[i];
	vector<vector<pair<int, int>>> g(H * W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (vs[i][j] == '#') continue;
			for (int k = 0; k < 4; k++) {
				int nh = i + dh[k];
				int nw = j + dw[k];
				if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
				if (vs[nh][nw] == '#') continue;
				g[i * W + j].emplace_back(nh * W + nw, 0);
			}
			for (int k = -2; k <= 2; k++) {
				for (int l = -2; l <= 2; l++) {
					int nh = i + k;
					int nw = j + l;
					if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
					if (vs[nh][nw] == '#') continue;
					g[i * W + j].emplace_back(nh * W + nw, 1);
				}
			}
		}
	}
	auto d = BFS01(sh * W + sw, g);
	int res = d[th * W + tw];
	if (res == inf) res = -1;
	cout << res << endl;
}


Measured memory_bytes: 120540
import Control.Monad
import Data.List

main = do
    n <- readLn
    ss <- map sort <$> replicateM n getLine
    putStrLn $ solve ['a'..'z'] ss

solve [] xss = []
solve (c:cs) xss | any null xss' = []
                 | all (==c) (map head xss') = c : solve (c:cs) (map tail xss')
                 | otherwise = solve cs xss'
    where xss' = map (dropWhile (<c)) xss

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
 double a,b,n;
 ll ans;
 cin>>a>>b>>n;
 double y;
 y = min(b-1,n)/b;
 ans =y*a;
 cout<<ans;
}

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

#define ff first
#define endl "\n"
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fr(i,x,n) for(ll i=x;i>=n;i--)
inline ll min(ll a, ll b, ll c) { return min(min(a, b), c);}
inline ll max(ll a, ll b, ll c) { return max(max(a, b), c);}
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

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



int main() {
	fastio();

	ll n, k; cin >> n >> k;
	ll s=0;
	ll h[n + 1] = {}; f(i, 1, n) cin >> h[i],s+=h[i];
	if (k >= n) cout << 0;
	else {
		sort(h, h + n + 1);
		ll m=0;
		fr(i,n,n-k+1) m+=h[i];
		cout<<s-m;
	}

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  vector<ll> diff(n);
  ll minv = 0;
  int ans = 0;
  rep(i, 0, n) {
    diff[i] = a[i] - b[i];
    if (diff[i] < 0) {
      minv += diff[i];
      ans++;
    }
  }

  sort(diff.rbegin(), diff.rend());
  if (minv < 0) {
    rep(i, 0, n) {
      minv += diff[i];
      ans++;
      if (minv >= 0)
        break;
    }
  }

  if (minv < 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
}


Measured memory_bytes: 5580
#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int U;
#define L 2194304
bool HA[L];
char T[256];

int main() {
    U n, s, t;
    char c;
    T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
    scanf("%d", &n);
    while ( getchar() != '\n' );
    for ( register U i = 0; i++ < n; ) {
        s = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            s += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[s] = true;
        } else {
            puts( HA[s] ? "yes" : "no" );
        }
    }
    return 0;
}

Measured memory_bytes: 2100
#include <iostream>

int main()
{
    int N, K;
    std::cin >> N >> K;
    long long count = 0;
    for (long long i = K; i <= N + 1; i++)
    {
        long long min = i * (i - 1) / 2;
        long long max = N * i - min;
        count = (count + max - min + 1) % 1000000007;
        // * [0, 1, 2, 3, 4, 5, 6] ここから2個
        // (0, 1) : 1
        // (0, 2) : 2
        // (0, 3), (1, 2): 3
        // (0, 4), (1, 3): 4
        // (0, 5), (1, 4), (2, 3) : 5
        // (0, 6), (1, 5), (2, 4) : 6
        // (1, 6), (2, 5), (3, 4) : 7
        // (2, 6), (3, 5): 8
        // (3, 6), (4, 5): 9
        // (4, 6): 10
        // (5, 6): 11 = (6-1) + 6
        // 11通り
        // 2N - 1

        // [0, 1, 2, 3, 4, 5, 6] ここから3個
        // (0, 1, 2): 3
        // (0, 1, 3): 4
        // (0, 1, 4), (0, 2, 3):5
        // (0, 1, 5), (1, 2, 3), (0, 2, 4): 6 = 1 + 5 = 2 + 4
        // (0, 1, 6), (0, 2, 5), (0, 3, 4), (1, 2, 4):7
        // ..
        // (4, 5, 6) : 15 = (6-2) + (6-1) + (6-0)
        // 13通り
    }
    std::cout << count << std::endl;
}

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

int main() {
  int N,f,sum;
  cin >> N;
  f = N;
  while(N>0){
  if((N%10)!=0){
    sum+=N%10;
    N=N/10;
  }
  else break;
  }
  if((f%sum)==0) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//			#include <ext/pb_ds/assoc_container.hpp>
//			#include <ext/pb_ds/tree_policy.hpp>

		using ll = long long;
		using ld = long double;
		#define rep(i, a, n) for(ll i = (a); i < (n); i++)
		#define per(i, a, n) for(ll i = (n-1); i >= (a); i--)
		#define F first
		#define S second
		#define endl "\n"
		#define all(x) begin(x), end(x)
		#define maxx(a, b) a = max(a, b)
		#define minn(a, b) a = min(a, b)
		#define db(x) cerr<<#x<<" = "<<x<<endl
		#define N 1111111
		#define mod 998244353
		#define rt return
		#define inf 1234567891123456789ll

		using namespace std;
//			random_device rd;
//			mt19937 mt(rd());
//			using namespace __gnu_pbds;
//
//			typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

		#define error(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

		void err(istream_iterator<string> it) {}
		template<typename T, typename... Args>
		void err(istream_iterator<string> it, T a, Args... args)
		{
			cerr<<*it<<" = "<<a<<endl;
			err(++it, args...);
		}

		ll modlaber(ll a, ll m = mod)
		{
			rt ((a+m)%m+m)%m;
		}

		ll a[N];

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

			ll n; cin>>n;
			rep(i,1,101)
				rep(j,1,101)
					rep(k,1,101)
						a[i*i+j*j+k*k+i*j+j*k+i*k]++;
			rep(i,1,n+1)
				cout<<a[i]<<endl;

			rt 0;
		}




















Measured memory_bytes: 4068
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

A = sorted([a for a,_ in AB])
B = sorted([b for _,b in AB])

if N % 2 == 1: # 奇数
    MIN = A[(N + 1) // 2 - 1]
    MAX = B[(N + 1) // 2 - 1]

else: # 偶数
    MIN = A[N // 2 - 1] + A[N // 2]
    MAX = B[N // 2 - 1] + B[N // 2]

print(MAX - MIN + 1)

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, Group[int(1e5+5)];
vector <int> Graph[int(1e5+5)];

int Solve(int start){
  queue <int> que; que.push(start);

  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int j : Graph[Q]){
      if (Group[j] == start) continue;
      Group[j] = start;
      que.push(j);
    }
  }

  return 0;
}

int main(){
  cin >> N >> M;
  for (int i = 1; i <= N; i++) Group[i] = i;

  for (int i = 0; i < M; i++){
    int A, B; cin >> A >> B;
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }


  int ans = 0;
  for (int i = 1; i <= N; i++){
    if (Group[i] != i) continue;
    ans++;
    Solve(i);
  }

  cout << ans - 1 << endl;

  return 0;
}

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

using namespace std;

int main()
{
    double n,a,sum=0;

    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>a;
        sum += (1/a);
    }

    cout<<1/sum<<endl;

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
   long long int n,x;
    scanf("%lld %lld",&n,&x);
   long long int a[n],i,s=0,max=0;
    for(i=0; i<n; i++){
        scanf("%lld",&a[i]);
        s+=a[i];
    }
    x-=s;
    for(i=0; i<n; i++){
        if((x/a[i])>max){
            max=x/a[i];
        }
    }
      //  printf("%d\n",max);
        printf("%lld\n",max+n);
        return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n, m;
    cin>>n>>m;
    print((n*(n-1))/2 + (m*(m-1))/2);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
   
}


Measured memory_bytes: 256
n = int(input())
an = [int(i) for i in input().split()]
bn = [int(i) for i in input().split()]
cn_1 = [int(i) for i in input().split()]
score = bn[an[0] - 1]
for i in range(1, n):
    score += bn[an[i] - 1]
    if an[i] - an[i - 1] == 1:
        score += cn_1[an[i - 1] - 1]

print(score)

Measured memory_bytes: 3064
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    L = A[N-1]
    ans = -1
    for a in A[:N-1]:
        if abs(L/2 - a) < abs(L/2 - ans): ans = a
    print(L, ans)


    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vecint v(n);
  REP(i,n) cin>>v[i];
  vecint a = v;
  sort(ALL(a));
  REP(i,n) {
    int idx = lower_bound(ALL(a), v[i]) - begin(a);
    if (idx < n/2) {
      cout << a[n/2] << endl;
    } else {
      cout << a[n/2-1] << endl;
    }
  }
  return 0;
}


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

using namespace std;
using ll = long long int;
#define long ll

template <typename T>
struct SegmentTree {
    using F = function<T(T, T)>;

    const T e;
    const F f;
    size_t sz;
    vector<T> tree;

    SegmentTree(size_t n, const F &f, const T &e = 0) : f(f), e(e) {
        sz = 1;
        while(sz < n) sz <<= 1;
        tree.assign(2*sz, e);
    }

    void set(typename vector<T>::iterator begin, typename vector<T>::iterator end) {
        copy(begin, end, tree.begin() + sz);
        for(size_t k=sz-1; k>0; k--)
            tree[k] = f(tree[2*k+0], tree[2*k+1]);
    }

    void update(size_t k, const T &x) {
        k += sz;
        tree[k] = x;
        while(k >>= 1)
            tree[k] = f(tree[2*k+0], tree[2*k+1]);
    }

    T query(size_t a, size_t b) const {
        T l = e, r = e;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) l = f(l, tree[a++]);
            if(b & 1) r = f(tree[--b], r);
        }
        return f(l, r);
    }

    T operator[](const size_t k) const {
        return tree[sz + k];
    }
};

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

    ll n;
    cin >> n;
    ll nn = 1ll<<n;
    vector<ll> s(nn);
    for(auto &e: s) cin >> e;

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

    ll p = s[0];
    s[0] = 1;
    for(ll i=1; i<nn; i++)
        if(s[i] == p)
            s[i] = s[i-1];
        else
            p = s[i], s[i] = 1 + s[i-1];

    ll m = s[nn-1];

    SegmentTree<long> st(m+1, [&](long a, long b){return a + b;}, 0);
    for(ll i=0; i<nn; i++)
        st.update(s[i], st[s[i]]+1);

    vector<ll> ss;
    ss.push_back(m);
    st.update(m, st[m]-1);
    for(ll i=0; i<n; i++) {
        vector<ll> pre = ss;
        for(auto &v: pre) {
            // [ok, v)にスライムがいる
            ll ok = 0, ng = v;
            while(abs(ok - ng) > 1) {
                ll mid = (ok + ng)/2;
                (st.query(mid, v) > 0 ? ok : ng) = mid;
            }
            if(!st.query(ok, v)) {
                cout << "No" << endl;
                return 0;
            }
            st.update(ok, st[ok]-1);
            ss.push_back(ok);
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 13676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
vector<int> v(3),a;
for(int i=0;i<3;i++)cin>>v[i];
int ans=0;
for(int i=0;i<3;i++){
    if(find(a.begin(),a.end(),v[i])==a.end()){a.push_back(v[i]);ans++;}
    
}
cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
using namespace std;
int main()
{
    long long x,k,d;
    cin>>x>>k>>d;
    x = llabs(x);
    long long temp = x/d;
    if(temp%2==0&&k%2==0)
    {
        if(k>=temp)
        {
            cout<<(x-(temp*d))<<endl;
            //continue;
        }
        else
        {
            cout<<(x-(k*d))<<endl;
            //continue;
        }
    }
    else if(temp%2==0&&k%2!=0)
    {
        if(k>temp)
        {
            cout<<min((x-((temp-1)*d)),llabs(x-((temp+1)*d)));
            //continue;
        }
        else
        {
            cout<<(x-(k*d))<<endl;
            //continue;
        }
    }
    else if(temp%2!=0&&k%2==0)
    {
        if(k>temp)
        {
            cout<<min((x-((temp-1)*d)),llabs(x-((temp+1)*d)));
            //continue;
        }
        else
        {
            cout<<(x-(k*d))<<endl;
            //continue;
        }
    }
    else if(temp%2!=0&&k%2!=0)
    {
         if(k>=temp)
        {
            cout<<(x-(temp*d))<<endl;
            //continue;
        }
        else
        {
            cout<<(x-(k*d))<<endl;
            //continue;
        }
    }
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
string S;
ll F[100010][4] = {{0}},inf = 1e9+7;

ll mult(ll n,ll m){
	if (m<=0) return 1;
	else if(m==1) return n;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (n*t)%inf;
	}
}

int main(){
	cin >> S;
	ll N = S.size();
	for(int i=1;i<=N;i++){
		if(S[i-1]=='A') F[i][0]++;
		if(S[i-1]=='B') F[i][1]++;
		if(S[i-1]=='C') F[i][2]++;
		if(S[i-1]=='?') F[i][3]++;
		for(int j=0;j<4;j++){
			if(i>=2) F[i][j] += F[i-1][j];	
		}
	}
	ll ans = 0;
	for(int i=1;i<=N;i++){
		if(S[i-1]=='B'){
			ans = (ans+(F[N][2]-F[i][2])*F[i-1][0]*mult(3,F[N][3]))%inf;
			ans = (ans+(F[N][3]-F[i][3])*F[i-1][0]*mult(3,F[N][3]-1))%inf;
			ans = (ans+(F[N][2]-F[i][2])*F[i-1][3]*mult(3,F[N][3]-1))%inf;
			ans = (ans+(F[N][3]-F[i][3])*F[i-1][3]*mult(3,F[N][3]-2))%inf;
		}
		if(S[i-1]=='?'){
			ans = (ans+(F[N][2]-F[i][2])*F[i-1][0]*mult(3,F[N][3]-1))%inf;
			ans = (ans+(F[N][3]-F[i][3])*F[i-1][0]*mult(3,F[N][3]-2))%inf;
			ans = (ans+(F[N][2]-F[i][2])*F[i-1][3]*mult(3,F[N][3]-2))%inf;
			ans = (ans+(F[N][3]-F[i][3])*F[i-1][3]*mult(3,F[N][3]-3))%inf;
		}
//		cout << i << " " << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(){
    int a[10005];
    int N,ans=0;
    cin >>N;
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int j=0;j<N;j++){
        for(int k=0;k<50;k++){
            if(a[j]%2==0){
                ans++;
                a[j]=a[j]/2;
            }
        }
    }
        cout<< ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#define mod 1000000007

using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
	ll m=a,n=b;
	ll t;
	while(a%b!=0){
		t=b;
		b=a%b;
		a=t;
	}
	//最小公倍数 
	return m/b*n;//先除后乘，注意不要溢出 
}

int main() {
	ll n;
	scanf("%lld",&n);
	ll a,b;
	scanf("%lld",&a);
	for(int i=2;i<=n;i++){
		scanf("%lld",&b);
		a=gcd(a,b);
	}
	printf("%lld",a);
	return 0;
}


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

int main()
{
  list<int> l,ll;
  list<int>::iterator start,end;
  int n,r,i,p,c;
  while(cin>>n>>r,n||r){
    l.clear();
    for(i=1;i<=n;i++)l.push_front(i);
    while(r-->0){
      cin>>p>>c;
      start=end=l.begin();
      advance(start,p-1);
      advance(end,p-1+c);
      ll.clear();
      ll.splice(ll.begin(),l,start,end);
      l.splice(l.begin(),ll);
    }
    cout<<*l.begin()<<endl;
  }
}

Measured memory_bytes: 0
A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
#N = int(input())
#al = list(map(int,input().split()))

if V <= W:
    print('NO')
    exit()
if abs(B-A)/(V-W) <= T:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int max = 0;
    int maxx = 0;
    for (int i = 0; i < n; ++i) {
        if (max < p[i]) {
            max = p[i];
            maxx = i;
        }
    }
    p[maxx] /= 2;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += p[i];
    }
    cout << sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int L; cin>>L;
  double X=L/3.0;
  printf("%.10lf\n",X*X*X);
  }


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
  }
  int ans = 1,tmp = h.at(0);
  for(int i = 1; i < n; i++){
    if(h.at(i) >= tmp) ans++;
    tmp = max(tmp, h.at(i));
  }
  cout << ans;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
//#define _CRT_NONSTDC_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <fstream>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <ctime>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
 
 
using namespace std;
typedef long long ll;
typedef long double ld;
                        
#define all(x)   (x).begin(), (x).end()           /*sorting STL */
#define fastio	 ios_base::sync_with_stdio(0);  cin.tie(nullptr);  cout.tie(nullptr)
 
#define TRIPmin(a, b, c) 	min(a, min(b, c))
#define TRIPmax(a, b, c)    max(a, max(b, c))
#define fillchar(a,x) 		memset(a, x, sizeof (a))
 
// #define MOD		(1000000000+7)
 
/***********************************************************************/


int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll tmp = x/d, kk, xx = x;
	x = x - tmp * d;
	kk = k - tmp;
	
	if(kk < 0) {
		cout << xx - k * d;
	}
	else {
		if(kk % 2 == 0) {
			cout << abs(x);
		}
		else {
			ll tmp1 = x + d, tmp2 = x - d;
			cout << min(abs(tmp1), abs(tmp2));
		}
	}
	// cout << x << " " << k;

	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
struct pro{
	long long i;
	long long p;
	long long c;
	long long s;
	pro(long long _i,long long _p, long long _c) {
		i = _i;
		p = _p;
		c = _c;
		s = p * (i * 100) + c;
	}
};
bool use[11];

long long rec(vector<pro> p,int G){

	if (G <= 0) return 0;
	long long res = 100000000;
	for (size_t i = 0; i < p.size(); i++)
	{
		if (!use[i]) {
			use[i] = true;
			int iv = p[i].i * 100;
			int pp = p[i].p;
			if (iv * pp >= G) {

				res = min(res, (long long)(((double)G / (double)iv) + 0.9));
			}
			else {
				res = min(res, rec(p,G - p[i].s) + pp);
			}
			use[i] = false;
		}
	}
	return res;
}
void AllGreen() {
	int D, G;
	cin >> D >> G;
	vector<pro> pp;
	for (size_t i = 0; i < D; i++)
	{
		long long p, c;
		cin >> p >> c;
		pro ap(i + 1, p, c);
		pp.push_back(ap);
	}
	int count = 0;
	memset(use, 0, sizeof(use));
	cout << rec(pp,G);
}
int main() {
	AllGreen();
	return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  if(s.size()==1 && s.at(0)==t.at(0) && t.size() == s.size()+1){
   cout << "Yes" << endl;
    return 0;
  }
  
  if(s==t.substr(0,s.size()) && t.size() == s.size()+1){
  cout << "Yes" << endl;
  }else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 3564
#include<stdio.h>
int main(){
	int i=0,a=0,b=0,c=0,flag=1;
	char sa[105],sb[105],sc[105];
	gets(sa);
	gets(sb);
	gets(sc);
	while(1){
		if(flag==1){
			if(sa[i]=='a'){
				i++;
				a++;
			}
			else if(sa[i]=='b'){
				i=b;
				a++;
				flag=2;
			}
			else if(sa[i]=='c'){
				i=c;
				a++;
				flag=3;
			}
			else{
				printf("A\n");
				break;
			}
		}
		if(flag==2){
			if(sb[i]=='a'){
				i=a;
				b++;
				flag=1;
			}
			else if(sb[i]=='b'){
				i++;
				b++;
			}
			else if(sb[i]=='c'){
				i=c;
				flag=3;
				b++;
			}
			else{
				printf("B\n");
				break;
			}
		}
		if(flag==3){
			if(sc[i]=='a'){
				i=a;
				c++;
				flag=1;
			}
			else if(sc[i]=='b'){
				i=b;
				c++;
				flag=2;
			}
			else if(sc[i]=='c'){
				i++;
				c++;
			}
			else{
				printf("C\n");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        long[] ary = new long[100];
        for(int i=0; i<n; i++){
            ary[i] = Long.parseLong(sc.next());
        }
        int count = 0;
        for(int i=0; i<n-2; i++){
            for(int j=i+1; j<n-1; j++){
                if(ary[i] != ary[j]){
                    for(int k=j+1; k<n; k++){
                        if(ary[i] !=  ary[k] && ary[j] != ary[k]){
                            long max = Math.max(ary[i], Math.max(ary[j], ary[k]));
                            long min = Math.min(ary[i], Math.min(ary[j], ary[k]));
                            long mid = ary[i] + ary[j] + ary[k] - max - min;
                            if(min + mid > max){
                                count++;
                            }
                        }
                    }
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35952
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  cout<<3*N*N<<endl;

}


Measured memory_bytes: 256
INF = float('inf')

N = int(input())

h = list(map(int,input().split()))

dp = [INF] * N

dp[0] = 0


if N ==1:
    print(dp[0])
elif N == 2:
    dp[1] = h[1]-h[0]
    print(dp[1])
else:
    dp[1] = abs(h[1]-h[0])
    for i in range(2, N):
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))
    print(dp[N-1])

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

map<int, bool> have;

int main()
{
	int n;
	cin>>n;
	int k;
	for(int i=0;i<n;i++) 
	{
		cin>>k;
		if(have[k]) have.erase(k);
		else have[k] = true;
	}
	cout<<have.size()<<endl;
	return 0;
}

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

typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int
main()
{
  vector<int> V(3); cin >> V[0] >> V[1] >> V[2];
  SORT(V);

  int ans = 0;
  if ((V[1] - V[0]) % 2) { V[0]++; V[2]++; ans++; }

  ans += (V[1] - V[0]) / 2;
  ans += V[2] - V[1];

  ANS(ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;}

Measured memory_bytes: 5888
x1, y1, x2, y2 = map(int, input().split())
x = (x2 - x1)
y = (y2 - y1)

x3 = x2 - y
y3 = y2 + x
x4 = x1 - y
y4 = y1 + x
print(x3, y3, x4, y4)


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

int main() {
  string a, b;
  cin >> a >> b;
  
  if (a == "H") {
    cout << b << endl;
  } else {
    if (b == "H") {
      cout << "D" << endl;
    } else {
      cout << "H" << endl;
    }
  }
  
  
}

Measured memory_bytes: 3512
if __name__ == '__main__':
    n = int(input())

    total = 0
    data = [[0] * 9 for i in range(9)]
    for i in range(1, n + 1):
        str_num = str(i)
        top = str_num[0]
        bottom = str_num[-1]
        if bottom == '0':
            continue
        else:
            data[int(top) - 1][int(bottom) - 1] += 1

    for i in range(9):
        for j in range(9):
            total += (data[i][j] * data[j][i])

    print(total)

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

int main() {
    int n,a;
    cin >> n;
    vector<int> card;
    int alice = 0, bob = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        card.push_back(a);
    }
    sort(card.begin(), card.end(), greater<int>());
    for (int i = 0; i < n; i++) {
        if ((i + 1) % 2 == 1) {
            alice += card[i];
        }
        else {
            bob += card[i];
        }
    }
    cout << alice - bob << endl;
}

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

using namespace std;

int main(){
    int time[5];
    int sum=0,ans=999;
    cin >> time[0] >> time[1] >> time[2] >> time[3] >> time[4];
    for(int i=0;i<5;i++){
        if(time[i]%10 != 0){
            int tmp = (time[i] + 10) - (time[i] % 10);
            sum += tmp;
        }else{
            sum += time[i];
        }
    }
    for(int i=0;i<5;i++){
        int tmp = sum;
        if(time[i]%10 != 0){
            tmp -= (time[i] + 10) - (time[i] % 10);
            tmp += time[i];
        }
        if(tmp < ans){
            ans = tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from heapq import heappush, heappop


def dijkstra(graph: list, n: int, v_s: int, INF: int = float('inf')) -> list:
    # graph[v_from] = [(cost, v_to), ...]
    dist = [INF] * n

    dist[v_s] = 0
    heap = [(0, v_s)]  # heap = [(dist[v], v), ...]
    while heap:
        dist2v, v_from = heappop(heap)
        if dist[v_from] < dist2v:
            continue
        for cost, v_to in graph[v_from]:
            dist_cand = dist2v + cost
            if dist_cand < dist[v_to]:
                dist[v_to] = dist_cand
                heappush(heap, (dist[v_to], v_to))
    return dist


n, m, s, t = map(int, input().split())
s -= 1
t -= 1
g_yen = [[] for _ in range(n)]
g_snu = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    # for yen
    g_yen[u].append((a, v))
    g_yen[v].append((a, u))
    # for snuke
    g_snu[u].append((b, v))
    g_snu[v].append((b, u))

d_yen = dijkstra(g_yen, n, s)
d_snu = dijkstra(g_snu, n, t)

d = [d_yen[i] + d_snu[i] for i in range(n)]

ans = [10**15] * n
ans[n - 1] = d[n - 1]
for i in reversed(range(n - 1)):
    ans[i] = min(ans[i + 1], d[i])

for i in range(n):
    ans[i] = 10**15 - ans[i]

print(*ans, sep='\n')


Measured memory_bytes: 122604
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
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;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }

bool ng=false;
vec posi;

void dfs(pvvec &G,int now){
    for(auto p:G[now]){
        int next,dist;
        tie(next,dist)=p;
        if(posi[next]==INF){ // 未訪問
            posi[next]=posi[now]+dist;
            dfs(G,next);
        }
        else{ // 訪問済みならチェック
            if(posi[next]!=posi[now]+dist){
                ng=true;
                return;
            }
        }
    }
    return;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    posi.assign(n,INF);

    pvvec G(n);
    rep(i,m){
        int a,b,c;cin>>a>>b>>c;a--;b--;
        G[a].eb(b,c);
        G[b].eb(a,-c);
    }

    rep(i,n){
        if(posi[i]==INF){ // 新しい始まりなら0に初期化
            posi[i]=0;
        }
        dfs(G,i);
    }

    if(ng){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    
}

Measured memory_bytes: 16512