akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

m, b, c = MAP()
# print(min(abs(a - c), abs(a - b)))
if abs(m - b) < abs(m - c):
    print("A")
else:
    print("B")

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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

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

  if (X >= 400 && X <= 599)
    cout << 8 << endl;
  else if (X >= 600 && X <= 799)
    cout << 7 << endl;
  else if (X >= 800 && X <= 999)
    cout << 6 << endl;
  else if (X >= 1000 && X <= 1199)
    cout << 5 << endl;
  else if (X >= 1200 && X <= 1399)
    cout << 4 << endl;
  else if (X >= 1400 && X <= 1599)
    cout << 3 << endl;
  else if (X >= 1600 && X <= 1799)
    cout << 2 << endl;
  else if (X >= 1800 && X <= 1999)
    cout << 1 << endl;

  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector< vector<char> >S(H, vector<char>(W) );
  vector< vector<char> >T(H + 2, vector<char>(W + 2) );
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> S[i][j];
    }
  }
  
  for(int i = 0; i < H + 2; i++){
    for(int j = 0; j < W + 2; j++){
      if(i == 0 || i == H + 1 || j == 0 || j == W + 1)
        T[i][j] = '#';
      else
        T[i][j] = S[i - 1][j - 1];
    }
  }
  
   for(int i = 0; i < H + 2; i++){
    for(int j = 0; j < W + 2; j++){
      cout << T[i][j];
      if(j == W + 1)
        cout << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;

int main(){
	cin>>n;
	int ans=INF;
	for(int i=0;i<=n/6;i++){
		int t=n;
		int s=i;
		int tans=0;
		t-=6*i;
		while(s>0){
			tans+=(s%6);
			s/=6;
		}
		while(t>0){
			tans+=(t%9);
			t/=9;
		}
		ans=min(tans,ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i, n){
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;

    int ans = 0;
    bool ok = false;
    rep(i, n){
        if(ok){
            ans += t[i];
        }
        if(s[i] == x){
            ok = true;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
// for(long long i = 0;i < num; i++){}
int main() {
    //
    int n, m;
    int cnt = 0;

    cin >> n >> m;

    vector<vector<int>> vec(m);
    vector<int> power(m);

    for (int i = 0; i < m; i++) {
        int x, tmp;
        cin >> x;
        for (int j = 0; j < x; j++) {
            cin >> tmp;
            tmp--;
            vec.at(i).push_back(tmp);
        }
    }

    for (int i = 0; i < m; i++) cin >> power.at(i);

    for (int bit = 0; bit < (1 << n); bit++) {
        bool chk = true;

        for (int i = 0; i < m; i++) {
            int tmpCnt = 0;
            for (int j = 0; j < vec.at(i).size(); j++) {
                // for(auto j : vec[i]){
                if (bit & (1 << vec.at(i).at(j))) tmpCnt++;
            }

            if (tmpCnt % 2 != power.at(i)) chk = false;
        }

        if (chk == true) cnt++;
    }

    cout << cnt;
    //
}


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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    vector<int> h(n);
    rep(i,n)cin>>h[i];
    vector<int> r(n);
    r[n-1]=0;
    for(int i=n-2; i>=0; i--){
        if(h[i]>=h[i+1])r[i]=r[i+1]+1;
        else r[i]=0;
    }
    int M = 0;
    rep(i,n)M=max(M,r[i]);
    cout<<M<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const int inf = 1000000000;

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N) cin >> X[i];
  int L = X[0], R = X[0];
  rep(i, N) {
    L = min(L, X[i]);
    R = max(R, X[i]);
  }
  int ans = inf;
  for (int i = L; i <= R; i++) {
    int cost = 0;
    rep(j, N) cost += (X[j] - i) * (X[j] - i);
    ans = min(ans, cost);
  }
  cout << ans << endl;

  return 0;
}

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

#define ll long long 
#define sz(x) ((int)x.size())
#define inf (1000*1000*1000+9)
#define infl (1ll*inf*inf)
#define all(a) a.begin(),a.end()
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)


void solve(){
	int n,m; cin>>n>>m; 
	vector<pair<int,int>> cost(m+1); 
	for(int i=1;i<=m;i++){
		int a,b; cin>>a>>b; 
		int mask=0; 
		for(int j=0;j<b;j++){
			int c; cin>>c; c--;  
			mask^=(1<<c); 
		}
		cost[i]={a,mask}; 
	}
	vector<vector<int>> dp(m+1,vector<int> (1<<n,inf)); 
	dp[0][0]=0; 
	for(int i=1;i<=m;i++){
		for(int mask=0;mask<(1<<n);mask++){
			dp[i][mask]=min(dp[i-1][mask],dp[i-1][mask&~cost[i].second]+cost[i].first); 
		}
	}
	if(dp[m][(1<<n)-1]==inf){
		cout<<-1<<endl; 
		return; 
	}
	cout<<dp[m][(1<<n)-1]<<endl; 
}

int main(){
	clock_t beg=clock(); 
	fast_io; 
	solve(); 	
	clock_t end=clock(); 
	fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}

Measured memory_bytes: 16384
#include <iostream>
#include<ios>
#include <vector>
using namespace std;
using ll = long long;
const ll INF=INT64_MAX>>3;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll ans = 0;
    for(int i =1; i <= N; i++) {
        if(i%3!=0 && i%5!=0) {
            ans+=i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<queue>
using namespace std;
struct tt{
	int sx,sy,ss;
};
struct tst{
	int ssx,ssy;
};
int s[4][2]={1,0,-1,0,0,1,0,-1};
int n,m,ans=0;
char a[25][25];
int b[25][25]={0};
void dfs(int x,int y ,int z)
{
	int i;
	queue<tt>p;
	tt st;
	st.sx=x;
	st.sy=y;
	st.ss=z;
	p.push(st);
	while(!p.empty() )
	{
		tt sst,h;
		sst=p.front() ;
		p.pop();
		for(i=0;i<4;i++)
		{
			h.sx=sst.sx+s[i][0];
			h.sy=sst.sy+s[i][1];
			h.ss=sst.ss+1;
//			printf("%d %d %d\n",h.sx,h.sy,h.ss);
			if(h.sy>=0&&h.sx>=0&&h.sx<n&&h.sy<m&&a[h.sx][h.sy]=='.'&&b[h.sx][h.sy]==0)
			{
				p.push(h);
				b[h.sx][h.sy]=h.ss;
				if(h.ss>ans) ans=h.ss;
			}
		}
	 } 
}
void dfss(int x,int y)
{
	int i;
	queue<tst>q;
	tst a1;
	a1.ssx=x;
	a1.ssy=y;
	q.push(a1);
	while(!q.empty() )
	{
		tst a2,a3;
		a3=q.front() ;
		q.pop();
		for(i=0;i<4;i++)
		{
			a2.ssx=a3.ssx+s[i][0];
			a2.ssy=a3.ssy+s[i][1];
			if(a2.ssx>=0&&a2.ssy>=0&&a2.ssx<n&&a2.ssy<m&&a[a2.ssx][a2.ssy]=='.'&&b[a2.ssx][a2.ssy]!=0)
			{
				q.push(a2);
				b[a2.ssx][a2.ssy]=0;
			}
		}
	 } 
}
int main()
{
	int i,j;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
	}
	for(i=0;i<n;i++)
	{
		
		for(j=0;j<m;j++)
		{
			if(a[i][j]=='.'&&b[i][j]==0)
			{
//				printf("%d %d\n",i,j);
				b[i][j]=1;
				dfs(i,j,0);
				b[i][j]=0;
				dfss(i,j);
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll sum=0;
        for(ll a=1;a<=n;a++)
        {
            for(ll b=1;b<=n;b++)
            {
                for(ll c=1;c<=n;c++)
                {
                    sum+=__gcd(__gcd(a,b),c);
                }
            }
        }
        cout<<sum<<endl;
    }


    return 0;
}


Measured memory_bytes: 3660
from heapq import heapify, heappush, heappop

pq = []
heapify([])
while True:
    S = input()
    if S == "end":
        break
    elif S == "extract":
        print(-1 * heappop(pq))
    else:
        com, k = S.split()
        k = -1 * int(k)
        heappush(pq, k)



Measured memory_bytes: 45304
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	LLI h, n;
	cin >> h >> n;
	LLI sum = 0;
	REP(i, n)
	{
		LLI tmp;
		cin >> tmp;
		sum += tmp;
	}
	if (h <= sum)
		cout << "Yes";
	else cout << "No";

	return 0;
}


Measured memory_bytes: 256
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

typedef long long LL;

static const LL MOD = 1000000007;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll& r) { return (x + r.x) % MOD; }
	modll operator+=(const modll & r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll & r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll & r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll & r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll & r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

LL n;
LL k;
modll ans;
vector<vector<int>> edges;
vector<int> vis;

void dfs(int node, int p, LL pps) {
	vis[node] = 1;
	if (p < 0) {
		ans *= k;
	} else {
		ans *= (k - pps - 1);
	}
	LL cnt = p >= 0;
	for (int next : edges[node]) {
		if (!vis[next]) {
			dfs(next, node, cnt);
			++cnt;
		}
	}
}

int main(int argc, char *argv[]) {
	ans = 1;
	cin >> n >> k;
	edges.clear();
	edges.resize(n);
	vis = vector<int>(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	dfs(0, -1, {});
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
 
#include <deque>
 
#include <stdio.h>
 
#include <cstdio>
 
#include <algorithm>
 
#include<bits/stdc++.h>
 
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define sp <<" "
#define nw <<"\n"
#define ca "Case "<<tc++<<": "
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define ull unsigned LL
#define check cout<<"* ";
#define show_vector for(int q=0;q<v.size();q++){cout<<v[q]<<" ";}
#define REP(i,n) for (int i=0;i<(n);++i)
#define N_MAX 26
 
 
const int inf=1<<30;
const long long int INF=1e10;
const int MOD=1e9+7;
const int maxn = 1e5+10;
int a[200005],b[1000005];
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
/*
int ck_prime(int n)
{
    int coun;
     coun=0;
     if(n>1){
      for(int i=2;i*i<=n;i++){
        if( n%i==0 ){
            coun++;
            break;
          }
        }
      }
     if(n==1){
       coun=coun;
         }
    if(coun==0){
           return 1; // n is prime
        }
    return 0;
}
*/
int main()
{
    char c;
    cin>>c;
    switch(c){
       case 'A':
           cout<<"T" nw;
           break;
       case 'T':
            cout<<"A" nw;
            break;
       case 'C':
            cout<<"G" nw;
            break;
       case 'G':
            cout<<"C" nw;
            break;
    }
}
 

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int m = n - i - j;
			if (m < 0) continue;
			int money = 10000 * i + 5000 * j + 1000 * m;
			if (money == y) {
				cout << i << " " << j << " " << m << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main()
{
	int n,a,b,c;
	long long s;
	s=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		s=s*i%1000000007;	
	}
	printf("%lld\n",s);
}

Measured memory_bytes: 128
import fractions
N = int(input())
T = []


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


for i in range(N):
    t = int(input())
    T.append(t)


M = T[0]
for i in range(1, N):
    M = lcm(M, T[i])

print(M)


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

int main(int argc,char** argv){
	int num=0; //Init
	string S;
	cin >> S;
	for(int i=0;i<4;i++){
		if(S[i] == '+')
			num++;
		else if(S[i] == '-')
			num--;
	}

	cout << num << endl;
	return 0;
}

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

signed main(){
    string s;
    cin >> s;
    int flag = 1;
    for(int i=0;i<s.size();i++){
        if((i&1) && s[i] == 'R') flag = 0;
        if((i%2 == 0) && s[i] == 'L') flag = 0;
    }
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#!/usr/bin/perl

# 全て数値化して読む
my ($n,$y) = map {$_ - 0} split(/\s+/o,<STDIN>);

if( $y > $n * 10000 or $y < $n * 1000 ){
  print "-1 -1 -1\n";
  exit(0);
}

$yk = $y/1000;

my $sen = $yk % 10;

my $s5; my $s1; my $s10;

if( $sen >= 5 ){
  $s5 = 1;
  $s1 = $sen - 5;
} else {
  $s5 = 0;
  $s1 = $sen;
}

if( $n - $s5 - $s1 < 0 ){
  print "-1 -1 -1\n";
  exit(0);
}

$s10 = ($n - $s5 - $s1);

my $tv = ( 10 * $s10 + 5 * $s5 + $s1 );

if( $tv < $yk ){
  print "-1 -1 -1\n";
  exit(0);
}

my $dif = $tv - $yk;

if( $dif == 0 ){
  print "$s10 $s5 $s1\n";
  exit(0);
}

my ($ts10, $ts5, $ts1) = ($s10, $s5, $s1);

my $res = '';

while( $dif >= 90){
  last if $ts10 < 10;
  $dif -= 90;
  $ts10 -= 10;
  $ts1  += 10;
}

if( $ts10 >= 0 and $dif == 0 ){
  print "$ts10 $ts5 $ts1\n";
  exit(0);
}

while( $dif > 0 ){
  last if $ts10 < 2;
  $dif -= 10;
  $ts10 -= 2;
  $ts5  += 2;
}

if( $ts10 >= 0 and $dif == 0 ){
  print "$ts10 $ts5 $ts1\n";
  exit(0);
}

if( $s5 <= 0 ){
  print "-1 -1 -1\n";
  exit(0);
}

($ts10, $ts5, $ts1) = ($s10 - 4, 0, $s1+5*$s5);

if( $ts10 < 0 ){
  print "-1 -1 -1\n";
  exit(0);
}

my $tv =( 10 * $ts10 + 5 * $ts5 + $ts1 );

$dif = $tv - $yk;

while( $dif >= 90){
  last if $ts10 < 10;
  $dif -= 90;
  $ts10 -= 10;
  $ts1  += 10;
}

if( $ts10 >= 0 and $dif == 0 ){
  print "$ts10 $ts5 $ts1\n";
  exit(0);
}

while( $dif > 0 ){
  last if $ts10 < 2;
  $dif -= 10;
  $ts10 -= 2;
  $ts5  += 2;
}

if( $ts10 >= 0 and $dif == 0 ){
  print "$ts10 $ts5 $ts1\n";
  exit(0);
}

print "-1 -1 -1\n";

exit(0);


Measured memory_bytes: 512
import java.util.*;

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

        int N = scanner.nextInt();
        Map<Long, Long> map = new HashMap<>();

        long sum = 0;
        for (int i = 0 ; i < N ; i++) {
            Long A = scanner.nextLong();
            sum += A;
            if (map.containsKey(A)) {
                map.put(A, map.get(A) + 1);
            } else {
                map.put(A, 1L);
            }
        }

        int Q = scanner.nextInt();
        for (int i = 0 ; i < Q ; i++) {
            long B = scanner.nextLong();
            long C = scanner.nextLong();

            if (map.containsKey(B)) {
                long count = map.get(B);
                sum = sum - B * count + C * count;
                System.out.println(sum);
                map.put(B, 0L);
                if (map.containsKey(C)) {
                    map.put(C, map.get(C) + count);
                } else {
                    map.put(C, count);
                }
            } else {
                System.out.println(sum);
            }
        }
    }
}


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

typedef long long ll;
using namespace std;

int main() {
  double a,b;
  int c;
  scanf("%lf", &a);
  scanf("%lf", &b);

  c = ceil((a+b)/2);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b);
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c);
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n";
#define ck printf("continue\n")
#define debug(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 << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define state tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define Z 505  //check the limits, man
#define N 100001
const ll INF = 1e10;
int main()
{
    string str;
    llin(str);
    if(str=="Sunny")
        printf("Cloudy");
    else if(str=="Cloudy")
        printf("Rainy");
    else
        printf("Sunny");
    lin;
}









Measured memory_bytes: 256
def main():
	n, *a = map(int, open(0).read().split())
	dp = [[0] * (n + 1) for _ in range(n + 1)]
	for t, (c, k) in enumerate(sorted((c, k) for k, c in enumerate(a))[::-1]):
		for i in range(t + 1):
			j = t - i
			if dp[i + 1][j] <= (s := dp[i][j] + c * abs(i - k)): dp[i + 1][j] = s
			if dp[i][j + 1] <= (s := dp[i][j] + c * abs(n - 1 - k - j)): dp[i][j + 1] = s
	print(max(dp[i][~i] for i in range(n + 1)))

if __name__ == '__main__':
	main()


Measured memory_bytes: 136188
#include <stdio.h>


int main(void){
  int n, i;
  long l[86] = {0};
  l[0] = 2;
  l[1] = 1;
  scanf("%d", &n);
  for(i=2;i<=n;i++){
    l[i] = l[i-1] + l[i-2];
  }
  printf("%ld\n",l[n]);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<math.h>
#include<stdlib.h>
#include<cstring>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
const int Max = 1e5+5;
const int mod = 1e9+7;
const int Hash = 10000;
const int INF = 1<<30;
const ll llINF = 1e18;

int n;
int arr[Max];
int main( )
{
    //freopen("input.txt", "r", stdin);
    while(~scanf("%d", &n))
    {
        for(int i=1; i<=n; i++)
            scanf("%d", arr+i);
        int light[Max];
        memset(light, 0, sizeof(light));
        light[1] = 1;
        int k = arr[1], ans = 1;
        while(light[k]==0)
        {
            if(k == 2)
            {
                cout<<ans<<endl;
                break;
            }
            ans++;
            light[k] = 1;
            k  = arr[k];
        }
        if(k != 2)
            cout<<-1<<endl;
    }
    return 0;
}


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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int n,m,a[1000005];

int main()
{
	n=read();
	for ( int i=2;i<=n;i++ ) a[read()]++;
	for ( int i=1;i<=n;i++ ) printf("%d\n",a[i]);
}

Measured memory_bytes: 4372
def insertion_sort(arr, interval)
  count = 0

  size = arr.size
  interval.upto(size - 1) do |i|
    v = arr[i]
    j = i - interval
    while j >= 0 && arr[j] > v
      arr[j + interval] = arr[j]
      j -= interval
      count += 1
    end
    arr[j + interval] = v
  end

  count
end

def shell_sort(arr)
  count = 0
  intervals = create_intervals(arr.size)
  intervals.each { |interval| count += insertion_sort(arr, interval) }
  {G: intervals, count: count}
end

def create_intervals(size)
  h = 1
  intervals = [1]
  loop do
    h = 3 * h + 1
    break if size < h
    intervals.unshift(h)
  end
  intervals
end

arr = readlines[1..-1].map(&:to_i)
result = shell_sort(arr)
puts result[:G].size
puts result[:G].join("\s")
puts result[:count]
puts arr



Measured memory_bytes: 98416
#include<iostream>
using namespace std;
int main(){
	int a[100];
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=n-1;i>=0;i--){
		cout<<a[i];
		if(i!=0){
			cout<<" ";
		}
	}
	cout<<endl;
}

Measured memory_bytes: 1160
import java.util.Scanner;
import static java.lang.Math.*;

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

	private static void print(Scanner in) {
		int i = 0, n = in.nextInt();
		while (true) {
			if (n == 1) {
				System.out.printf("%.0f\n", pow(2, i));
				break;
			}
			if ((n & 1) == 1)
				System.out.printf("%.0f ", (n & 1) * pow(2, i));
			n >>= 1;
			i++;
		}
	}
}

Measured memory_bytes: 19224
// https://atcoder.jp/contests/abc120/tasks/abc120_a

package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	n := b / a
	if n > c {
		n = c
	}
	fmt.Println(n)
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

bool comp(const pair<int, int> p1, const pair<int, int> p2){
    return p1.second < p2.second;
}

bool bridge[100001];

bool isConnect(int start, int end){
    for(int i = start; i < end; i++){
        if(!bridge[i]){
            return false;
        }
    }
    return true;
}

void solve(){
    int n, m, l, r, res=0;
    vector<pair<int, int> > v;

    cin >> n >> m;
    for(int i = 0; i < n; i++) bridge[i] = true;
    for(int i = 0; i < m; i++){
        cin >> l >> r;
        v.push_back({l, r});
    }
    sort(v.begin(), v.end(), comp);
    for(int i = 0; i < m; i++){
        if(isConnect(v[i].first, v[i].second)){
            bridge[v[i].second-1] = false;
            res++;
        } 
    }
    cout << res << endl;
}

int main() {
    solve();
    return 0;
}

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

const int INF = 1e9;
int h,w,k;
char ch[15][1005];
int ans = INF;
int c[15][1005];
int num[15];

bool check(int j) {
  for(int i = 0; i < h; i++) {
    num[i] += c[i][j];
    // cout << c[i][j] << endl;
  }

  for(int i = 0; i < h; i++) {
    if(num[i] > k) return false;
  }
  return true;
 
}

  

int main() {
  cin >> h >> w >> k;

  for(int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < w; j++) {
      ch[i][j] = s[j];
    }
  }

  for(int i = 0; i < (1 << (h - 1)); i++) {
    int g = 0;
    vector<int> id(h,0);
    for(int j = 0; j < h; j++) {
      id[j] = g;
      if((i>>j) & 1) g++;
    }
    int tmp = g;

    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
	c[i][j] = 0;
      }
    }

    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
	c[id[i]][j] += (ch[i][j] - '0');
      }
    }
			
    for(int k = 0; k < h; k++) num[k] = 0;
    
    for(int j = 0; j < w; j++) {
      if(!check(j)) {
	for(int k = 0; k < h; k++) num[k] = 0;
	tmp++;
	if(!check(j)) {
	  tmp = INF;
	  break;
	}
      }
    }
    //   cout << ans <<"   "<< tmp <<  endl;
    ans = min(ans,tmp);
    
  }
  cout << ans << endl;
}
      
 
      
	
	


Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(N):
    if a[i] > x:
        ans += a[i] - x
        a[i] = x

for i in range(N-1):
    if a[i] + a[i+1] > x:
        ans += a[i] + a[i+1] - x
        a[i+1] -= a[i] + a[i+1] - x

print(ans)


Measured memory_bytes: 14052
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,x,y;
  cin>>n>>x>>y;
  vector<int> result(n+1,0);
  for(int l=1;l<=n;l++){
    for(int r=l+1;r<=n;r++){
      if(r<=x||y<=l){
        result[r-l]++;
      }else if(l<=x&&y<=r){
        int dist=1+x-l+r-y;
        result[dist]++;
      }else {
        int dist_direct=r-l;
        int dist_nodirect=abs(l-x)+1+abs(y-r);
        result[min(dist_direct,dist_nodirect)]++;
      }
    }
  }
  for(int i=1;i<=n-1;i++){
    cout<<result[i]<<endl;
  }

  return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

string word1,word2;

const int size=3005;
int matrix[size][size];

void print(int x,int y){
  if(x<=0 || y<=0)
    return;
  if(word1[x-1]==word2[y-1]){
    print(x-1,y-1);
    printf("%c",word1[x-1]);
  }
  else{
    if(matrix[x-1][y]>matrix[x][y-1])
      print(x-1,y);
    else
      print(x,y-1);
  }
}

void lcs(int i1,int i2){

  for(int i=0;i<=i1;i++)
    matrix[i][0]=0;
  for(int i=1;i<=i2;i++)
    matrix[0][i]=0;

  for(int i=1;i<=i1;i++){
    for(int j=1;j<=i2;j++){
      if(word1[i-1]==word2[j-1])
        matrix[i][j]=1+matrix[i-1][j-1];
      else
        matrix[i][j]=max(matrix[i-1][j],matrix[i][j-1]);
    }
  }
  print(i1,i2);
  printf("\n");
}
int main(){

  cin>>word1;
  cin>>word2;

  lcs(word1.size(),word2.size());

  return 0;
}


Measured memory_bytes: 35712
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}
use input::*;

fn main() {
    let (mut a, mut b, k): (usize, usize, usize);
    input!(a, b, k);

    p(b * (k / a));
}


Measured memory_bytes: 4352
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int m = in.nextInt();
        int answer = (24-m) + 24;
        System.out.println(answer);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	int n;
	cin >> n;
	unordered_map<string, int> p = {};
	int maxna = 0;
	vector<string> s(n);
	rep(i, n) {
		cin >> s[i];
		p[s[i]]++;
		maxna = max(maxna, p[s[i]]);
	}
	vector<string> ans;
	rep(i, n) {
		if (p[s[i]] == maxna) {
			ans.emplace_back(s[i]);
			p[s[i]] = -1;
		}
	}
	sort(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
	

	return 0;
}

Measured memory_bytes: 28228
n=int(input())
a=3
b=4
c=4
d=1
e=1
f=1
g=4
h=9
i=12
j=22
for x in range(3,n):
    anew=i
    bnew=c+d+e+h
    cnew=b+i
    dnew=c
    enew=g
    fnew=c
    gnew=b+i
    hnew=d+e+f+h+j
    inew=a+b+f+g+i+j
    jnew=a*2+d+e+f+(g+h+j)*2
    a=anew
    b=bnew
    c=cnew
    d=dnew
    e=enew
    f=fnew
    g=gnew
    h=hnew
    i=inew
    j=jnew
Sum=a+b+c+d+e+f+g+h+i+j
print(Sum%(10**9+7))
    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
 
typedef long long ll;
typedef std::pair<int,int> pii;
 
using namespace std;
 
long double sqr(long double c) { /* c の平方根を返す*/

      long double xn;
      long long int i,n;

      n=10;
      xn=0;

      do { /* 平方根に最も近い大きい方の整数を探す */

          xn+=1;

      } while (xn*xn<c);

      for (i=0;i<n;i++) {

          xn=(xn+c/xn)/2; /* 交点のx 座標を求める */

      }

      return xn; /* 求めた近似値を返す */

  }
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    long double a,b,c;
    cin >> a >> b >> c;
 
    string ans = 2 * sqr(a*b) + a + b < c ? "Yes" : "No";
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const ll mod = 1e9 + 7;				//adjust mod value according to your need
int main()
{
	SPEED
	ll n, w;
	cin >> n >> w;
	ll weight[n+1];
	ll value[n+1];

	weight[0] = 0;
	value[0] = 0;
	for (ll i = 1; i <= n; ++i)
	{
		cin >> weight[i] >> value[i]; 
	}

	ll dp[n+1][w+1];
	for (ll i = 0; i <= n; i++) 
	{ 
	    for (ll j = 0; j <= w; j++) 
	    { 
	        if (i==0 || j==0) 
	            dp[i][j] = 0; 
	        else if (weight[i] <= j) 
	            dp[i][j] = max(value[i] + dp[i-1][j-weight[i]],  dp[i-1][j]); 
	        else
	            dp[i][j] = dp[i-1][j]; 
	    } 
	} 
	cout << dp[n][w];
	return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b,d,r;
double f;
cin>>a>>b;
d=a/b;
r=a%b;
f=(double)a/(double)b;
printf("%d %d %.5lf\n",d,r,f);
return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,d,ans; cin>>n>>d;
  ans=n/(2*d+1);
  if(ans*(2*d+1)==n){
    cout<<ans<<endl;
  }else cout<<ans+1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u;
map<LL,LL>ww,cc;
LL ar[50000001];
LL br[50000001];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
       map<string,LL>mp;
       cin>>n;
       for(i=0;i<n;i++)
       {
           cin>>a;
           mp[a]++;
       }
       cout<<"AC x "<<mp["AC"]<<endl;
       cout<<"WA x "<<mp["WA"]<<endl;
       cout<<"TLE x "<<mp["TLE"]<<endl;
       cout<<"RE x "<<mp["RE"]<<endl;
    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3672
#include <stdio.h>
int binSearch(int);

int S[100000];
int n;
int main(){
  int i,k,l;
  int T[50000],q,C=0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }
  for(i = 0; i < q; i++){
    if(binSearch(T[i])) C++;
  }
  printf("%d\n",C);
  return 0;
}
int binSearch(int key){
  int left = 0;
  int right = n;
  int mid;
  while( left < right){
    mid = (left + right) / 2;
    if(S[mid] == key) return 1;
    else if(key < S[mid]) right = mid;
    else left = mid + 1;
  }
  
  return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;

  vector<int64_t> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  bool ok = true;
  int cnt = 0;
  while (ok) {
    ok = false;
    for (int i = 0; i < n; ++i) {
      if (a[i] % 2 == 0) {
        a[i] /= 2;
        ok = true;
        ++cnt;
        break;
      }
    }
  }

  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>

int main(void){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);
  if(A * B * C == 5 * 7 * 5){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
s = input()
count = 0
s = s.replace('BC','X')
s = s.replace('B','Z').replace('C','Z')
s = s.split('Z')
for i in s:
    ac = 0
    for j in range(len(i)):
        if i[j] == 'A':
            ac += 1
        if i[j] == 'X':
            count += ac
print(count)

Measured memory_bytes: 5412
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int ans = 0;
    for(int i = 1; i < B;){
        i += (A-1);
        ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int n; cin >> n;
	vint d(n);
	rep(i, n) cin >> d[i];

	ll ans = 0;
	rep(i, n-1){
		rep2(j, i+1, n){
			ans += d[i]*d[j];
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
main(i,n,s,M,m,S){for(;scanf("%d",&n),n;printf("%d\n",(S-M-m)/(n-2)))for(i=S=M=0,m=1000;i<n;i++)scanf("%d",&s),M=M>s?M:s,m=m<s?m:s,S+=s;}

Measured memory_bytes: 0
N , M = map(int, input().split())

ab = []
for _ in range(N):
    a, b = map(int, input().split())
    ab.append([a, b])

cd = []
for _ in range(M):
    c, d = map(int, input().split())
    cd.append([c, d])

# print(ab)
# print(cd)

for i in range(N):
    a, b = ab[i]
    tmp = float('inf')
    p = -1
    for j in range(M):
        c, d = cd[j]
        dist = abs(a-c)+abs(b-d)
        if tmp > dist:
            tmp = dist
            p = j+1
    print(p)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean nfirst = false;
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			if (nfirst)
				System.out.println();
			nfirst = true;
			int[] h = new int[4];
			for (int i = 0; i < 4; i++)
				h[i] = sc.nextInt();
			int m = 10 * h[0] + 50 * h[1] + 100 * h[2] + 500 * h[3];
			int r = m - n;
			int[] rs = { 0, 0, 0, 0 };
			while (r >= 500) {
				rs[3]++;
				r -= 500;
			}
			while (r >= 100) {
				rs[2]++;
				r -= 100;
			}
			while (r >= 50) {
				rs[1]++;
				r -= 50;
			}
			while (r >= 10) {
				rs[0]++;
				r -= 10;
			}
			int[] result = new int[4];
			for (int i = 0; i < 4; i++) {
				result[i] = h[i] - rs[i];
				if (result[i] < 0)
					result[i] = 0;
			}
			if (result[0] != 0)
				System.out.println("10 " + result[0]);
			if (result[1] != 0)
				System.out.println("50 " + result[1]);
			if (result[2] != 0)
				System.out.println("100 " + result[2]);
			if (result[3] != 0)
				System.out.println("500 " + result[3]);
		}
		sc.close();
	}
}

Measured memory_bytes: 34184
function main(input) {
	var a = input[0].split(' ');
	var s = parseInt(a[0])%60;
	var m = parseInt(parseInt(a[0])/60%60);
	var h = parseInt(parseInt(a[0])/60/60);
	console.log(h+":"+m+":"+s);
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});

Measured memory_bytes: 7648
#include <bits/stdc++.h> //AtCoder
//#include <iostream> //Codeforces
//#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}//最大公約数
int lcm(int a,int b){return a/gcd(a,b)*b;}//最小公倍数

/****************************** START ******************************/

signed main(){
  int X,K,D;
  cin >> X >> K >> D;
  if (X < 0){
    X = -X;
  }
  int ans;
  
  if (X / D >= K){
    ans = X - K * D;
  }
  else {
    K -= X / D;
    int A = X % D;
    if (K % 2 == 0){
      ans = A;
    } else {
      ans = D - A;
    } 
  }
  cout << ans;
}

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

#define show_vars(args...) {\
  string vars_names = #args;\
  replace(begin(vars_names), end(vars_names), ',', ' ');\
  stringstream _ss(vars_names);\
  istream_iterator<string> it(_ss);\
  _show_vars(it, args); }

// base case
void _show_vars(istream_iterator<string>) {}

template<typename T, typename ...Types>
void _show_vars(istream_iterator<string> it, T val, Types ... args) {
  cout << *it++ << " = " << val << endl;
  _show_vars(it, args...);
}

// overload to be able to print vector
template<typename T, typename ...Types>
void _show_vars(istream_iterator<string> it, vector<T> val, Types ... args) {
  cout << *it++ << " = \n";
  for(const auto& v: val) cout << v << " ";
  cout << endl;
  _show_vars(it, args...);
}


int main(int argc, char* argv[]) {
  int k;
  cin >> k;
  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << v[k-1] << endl;
  
  return 0;
}




Measured memory_bytes: 256
n = int(input())
l = [int(x) for x in input().split()]
#print(l)

for i in range(n-1)[::-1]:
    if l[i] - 1 == l[i+1]:
        l[i] = l[i] - 1
    else:
        continue
    
#print(l)

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')


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

const int codei[4] = {1, 1, -1, -1};
const int codej[4] = {-1, 1, -1, 1};

int main() {
    ll X;
    cin >> X;
    vector<ll> num(10001);
    for (ll i = 0; i < 10001; ++i) {
        num.at(i) = i;
        rep(j,4) num.at(i) *= i;
    }
    rep(i,10001) for (int j = i + 1; j < 10001; ++j) {
        rep(k,4) if (num.at(i) * codei[k] - num.at(j) * codej[k] == X) {
            cout << i * codei[k] << " " << j * codej[k] << endl;
            return 0;
        }
    }
}


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

int main() {
  int N;
  cin>>N;
  bool a=false;
  int n;
  n=N/100000000+N/10000000%10+N/1000000%10+N/100000%10+N/10000%10+N/1000%10+N/100%10+N/10%10+N%10;
if(N%n==0)
a=true; 
if(a)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl; 

}

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

int q;
vector<int>v;
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>q;
    while (q--) {
        int f,x; cin>>f;
        if (f!=2) cin>>x;
        if (f==0) v.push_back(x);
        if (f==1) cout<<v[x]<<'\n';
        if (f==2) v.pop_back();
    }
}


Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair

using namespace std;
int n,a[4][4],have[105];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++) cin>>a[i][j];
    }
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int b;
        cin>>b;
        have[b]=true;
    }
    int dem=0;
    for(int i=1;i<=3;i++)
    {
        bool ok=true;
        for(int j=1;j<=3;j++) if(!have[a[i][j]]) ok=false;
        if(ok) dem++;
    }
    for(int i=1;i<=3;i++)
    {
        bool ok=true;
        for(int j=1;j<=3;j++) if(!have[a[j][i]]) ok=false;
        if(ok) dem++;
    }
    if(have[a[1][1]]&&have[a[2][2]]&&have[a[3][3]]) dem++;
    if(have[a[1][3]]&&have[a[2][2]]&&have[a[3][1]]) dem++;
    if(dem>=1) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,f[200010],a[100010],b[100010],pp;
ll m;
bool pan(int x){
	memset(f,0,sizeof(f));pp=100000;
	for (int i=1;i<=n;i++)if (a[i]>=x) b[i]=1;else b[i]=0;
	ll sum=0,ansn=0,sum2=0;
	for (int i=1;i<=n;i++){
		if (b[i]==1){
			ansn+=f[pp-1-sum];sum++;f[pp+1-sum]++;ansn++;
		}else{
			ansn-=f[pp-sum];sum--;f[pp-1-sum]++;
		}
		sum2+=ansn;
	}
	if (sum2>=m) return true;return false;
}
int main(){
	scanf("%d",&n);
	m=((ll)n)*(n+1)/2;
	m=(m+1)/2;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int l=1,r=1e9,mid;
	while (l+1<r){
		mid=(l+r)/2;
		if (pan(mid))l=mid;else r=mid;
	}
	if (pan(r))cout<<r<<endl;else cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1792