akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
 
int W, H;
char P[60][10];
int Flag[60][11];
int dy[] = {0, 0, 1, -1}, dx[] = {-1, 1, 0, 0};
 
vector< pair< int, int > > graph[600];
vector< pair< int, int > > segment[600];
 
void FILL_Block(int x, int y, const char block, const int num)
{
  Flag[y][x] = num;
  segment[num].push_back(make_pair(y, x));
  for(int i = 0; i < 4; i++) {
    int nx = dx[i] + x, ny = dy[i] + y;
    if(nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
    if(P[ny][nx] == '.') continue;
    if(Flag[ny][nx]) continue;
    if(P[ny][nx] == block) FILL_Block(nx, ny, block, num);
    if(P[ny][nx] != block && i == 2) {
      graph[num].push_back(make_pair(ny, nx));
    }
  }
}
 
bool rec(int x, int y, int& c)
{
  int Local = c;
  FILL_Block(x, y, P[y][x], Local);
 
  int xmin = 114, xmax = -114;
  for(int i = 0; i < segment[Local].size(); i++) {
    pair< int, int >& p = segment[Local][i];
    if(p.first == 0 || (P[p.first - 1][p.second] != '.' && P[p.first - 1][p.second] != P[p.first][p.second])) {
      xmin = min(xmin, p.second);
      xmax = max(xmax, p.second + 1);
    }
  }
  for(int i = 0; i < graph[Local].size(); i++) {
    pair< int, int >& aaa = graph[Local][i];
    if(Flag[aaa.first][aaa.second]) continue;
    int addNum = ++c;
    if(!rec(aaa.second, aaa.first, c)) return(false);
    for(int j = 0; j < segment[addNum].size(); j++) {
      segment[Local].push_back(segment[addNum][j]);
    }
  }
  int cost = 0;
  for(int i = 0; i < segment[Local].size(); i++) {
    cost += segment[Local][i].second * 2 + 1;
  }
  return(xmin * 2 * segment[Local].size() < cost && cost < xmax * 2 * segment[Local].size());
}
 
int main()
{
  while(cin >> W >> H, W) {
    for(int i = 0; i < 600; i++) graph[i].clear(), segment[i].clear();
    fill_n(*Flag, 60 * 11, 0);
    int c = 1;
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        cin >> P[H - i - 1][j];
      }
    }
    bool ret;    
    for(int j = 0; j < W; j++) {
      if(P[0][j] != '.') {
        ret = rec(j, 0, c);
        break;
      }
    }
    if(ret) cout << "STABLE" << endl;
    else cout << "UNSTABLE" << endl;
  }
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T, U;
    ll A, B;
    cin >> S >> T >> A >> B >> U;
    if (S == U)
        A--;
    else
        B--;
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    x = int(input().rstrip())

    def get_sieve_of_eratosthenes(n: int):
        candidate = [i for i in range(2, n + 1)]

        primes = []
        while len(candidate) > 0:
            prime = candidate[0]
            candidate = [num for num in candidate if num % prime != 0]
            primes.append(prime)
        return primes

    # xまでの素数
    primes = get_sieve_of_eratosthenes(x)

    ans = x
    if not x in primes:
        while True:
            if any([ans % prime == 0 for prime in primes]):
                ans += 1
                continue
            break

    print(ans)




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 104260
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long K, long long S){
  ll ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      ll z = S - x - y;
      if(x + y + z == S && 0 <= z && z <= K){ans++;}
    }
  }
  cout << ans << endl;
}

int main(){
    long long K;
	scanf("%lld",&K);
	long long S;
	scanf("%lld",&S);
    solve(K, S);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s,p;
  cin>>s>>p;
  if(s=="H"&&p=="H")
  {
     cout<<"H"<<endl;
  }
  if(s=="D"&&p=="D")
  {
     cout<<"H"<<endl;
  }
  if(s=="H"&&p=="D")
  {
     cout<<"D"<<endl;
  }
  if(s=="D"&&p=="H")
  {
     cout<<"D"<<endl;
  }

}


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

#define fastio  ios::sync_with_stdio(false); cin.tie(0);
ll maxLL(ll a, ll b){
    return a>b?a:b;
}
class BeingZero{
    public:
        ll maxHappiness(int n){
            ll dp[n][3];
            ll mxAns = LLONG_MIN;
            for(int j=0;j<3;j++){
                cin>>dp[0][j];
                mxAns = maxLL(mxAns, dp[0][j]);
            }
            int a, b, c;
            for(int i=1;i<n;i++){
                for(int j=0;j<3;j++){
                    cin>>dp[i][j];
                    dp[i][j] += maxLL(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
                    mxAns = maxLL(mxAns, dp[i][j]);
                }
            }
            return mxAns;
        }
};

int main() {
    fastio;
    BeingZero bz;
    int n;
    while(cin>>n)
        cout<<bz.maxHappiness(n)<<"\n";
    return 0;
}



Measured memory_bytes: 5976
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62

MOD = 1000000007  # type: int


def solve(K: int, S: str):
    def cmb(n, r, p):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return fact[n] * factinv[r] * factinv[n - r] % p

    p = MOD
    N = K + len(S)  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用

    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

    ans = 0
    for k in range(K + 1):
        remain = K - k
        ans += pow(26, k, MOD) * pow(25, remain, MOD) * cmb(remain + len(S) - 1, remain, MOD)
    print(ans % MOD)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(K, S)


if __name__ == '__main__':
    (main())


Measured memory_bytes: 174272
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    int sl = s.length();
    int tl = t.length();
    if(sl +1 == tl  && t.substr(0, tl-1) == s)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            var Ai = new long[N];
            for (var i = 0; i < N; i++) Ai[i] = A[i] - i - 1;
            Ai = Ai.OrderBy(l => l).ToArray();
            var b = 0L;
            if (N % 2 != 0)
            {
                b = Ai[N / 2];
            }else
            {
                b = (Ai[N / 2 - 1] + Ai[N / 2]) / 2;
            }
            var ans = 0L;
            for(var i = 0; i < N; i++)
            {
                ans += Math.Abs(Ai[i] - b);
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 42272
#include<iostream>
#include<vector>

using namespace std;

int main(void){

	int a=9876,b;
	int cnt=0;
	vector<int> a_arr;
	vector<int> b_arr;	

	while(a != 0){
	
		cin >> a;
		cin >> b;
		a_arr.push_back(a);
		b_arr.push_back(b);
		cnt++;

	}

	for(int test=0;test<cnt-1;test++){
		for(int i=0;i<a_arr[test];i++){
			for(int j=0;j<b_arr[test];j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3120
// In The Name Of Allah

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int inf = 1e18;
const int maxx = 1e5 + 19;

int n, m, a[maxx], ans;
vector<int> adj[maxx];
int vis[maxx], cmp[maxx], cnt = 1;

void dfs(int root) {
    vis[root] = cnt;
    cmp[a[root]] = cnt;
    for (auto i : adj[root])
        if (!vis[i])
            dfs(i);
}

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> a[i], a[i]--;
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--;
        u--;
        adj[v].push_back(u);
        adj[u].push_back(v);
    }
    for (int i = 0; i < n; i++)
        if (!vis[i])
            dfs(i), cnt++;
    for (int i = 0; i < n; i++)
        if (vis[i] == cmp[i])
            ans++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 10112
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin >> s;
	if( s[3]==s[2] && s[5]==s[4]) 
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<bitset>

using namespace std;

// Problem https://atcoder.jp/contests/abc079/tasks/abc079_c
string solver(string fourNumber){
    string result;
    result.clear();
//    int test = 1 << 3;
//    cout << "1 << 3 = " << test << endl; 
    for(int bitPattern=0;bitPattern<(1<<3);bitPattern++){
        int tmp = 0;
        tmp = (int)(fourNumber.at(0) - '0');
        for(int k=0;k<3;k++){
            int tmp2 = 0;
            int bitChecker;
            tmp2 = (int)(fourNumber.at(k+1)-'0');
            bitChecker = bitPattern & 1 << k;
            if(0 < bitChecker){
                tmp = tmp + tmp2;
            }
            else{
                tmp = tmp - tmp2;
            }
        }
        if(tmp == 7){
            result.push_back(fourNumber.at(0));
            for(int k=0;k<3;k++){
                int bitChecker;
                int picUpNumber = (int)(fourNumber.at(k+1));
                bitChecker = bitPattern & (1 << k);
                if(0 < bitChecker){
                    result.push_back('+');
                    result.push_back(fourNumber.at(k+1));
                }
                else{
                    result.push_back('-');
                    result.push_back(fourNumber.at(k+1));
                }
            }
            result.append("=7\n");
            break;
        }
    }

    return result;
}


int main(void){
    string answer;
    string ABCD;
    cin >> ABCD;
    answer = solver(ABCD);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

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

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

int main() {
  int n,k;
  cin>>n>>k;
  int r,s,p;
  cin>>r>>s>>p;
  string t;
  cin>>t;
  ll ans=0;
  for(int i=0;i<min(n,k);i++){
    int cnt=0;
    for(int j=i;j<n;j+=k){
      if(j==i){
        if(t[j]=='r')ans+=p;
        else if(t[j]=='s')ans+=r;
        else ans+=s;
        cnt++;
      }
      else{
        if(t[j]!=t[j-k]){
          if(t[j]=='r')ans+=p;
          else if(t[j]=='s')ans+=r;
          else ans+=s;
          cnt=1;
        }
        else{
          if(cnt%2==0){
            if(t[j]=='r')ans+=p;
            else if(t[j]=='s')ans+=r;
            else ans+=s;
          }
          cnt++;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3764
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
using namespace std;

int main(){
    string s;
    bool f = true;
    int head, tail;
    cin >> s;
    REP(i, s.size()) {
        if(f && s[i] == 'A') {
            head = i;
            f = false;
        }
        if(s[i] == 'Z') tail = i;
    }
    cout << tail - head + 1 << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define MAX (200000 + 1)
int table [MAX];
int main() {
  int N, K; cin >> N >> K;
  for (auto i{0}; i < N; ++i) {
    int A; cin >> A;
    table[A] += 1;
  }

  sort(table, table + N + 1, greater<int>());

  int result{0};
  for (int i = K; i < MAX && table[i] > 0; ++i) {
    result += table[i];
  }

  cout << result << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
  int a=0, b=0, k=0, count=0;
  scanf("%d %d %d", &a, &b, &k);
  for (int i=100; i>0; i--) {
    if (a%i == 0 && b%i == 0) {
      count++;
      if (count == k) {
        printf("%d\n", i);
        return 0;
      }
    }
  }
  printf("ans not found\n");
  return 0;
}  
       


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {




        public static void Main(String[] args) {
            string line;

            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line); if (n == 0) { break; }

                int[] train = new int[24 * 60 * 60];
                for (int i = 0; i < n; i++) {
                    string[] strs = Console.ReadLine().Split(' ');
                    int zenhanTime = hyouToInt(strs[0]);
                    int kouhanTime = hyouToInt(strs[1]);
                    train[zenhanTime]++;
                    train[kouhanTime]--;

                }
                int max = 0;
                int count = 0;
                for(int i=0; i<24*60*60; i++){
                    count += train[i];
                    if (max < count) { max = count; }
                }
                Console.WriteLine(max);
                







            }
        }
        public static int hyouToInt(string str) {
            string[] strs = str.Split(':');
            int time = int.Parse(strs[0]) * 60 * 60 + int.Parse(strs[1]) * 60 + int.Parse(strs[2]);
            return time;
        }





    }
}

Measured memory_bytes: 6908
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int nSum = (N * (N-1)) / 2;
        int mSum = (M * (M-1)) / 2;
        System.out.println(nSum + mSum);

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

#define NOT_YET -1
#define CAT 1
#define RABBIT 0

int8_t memo[500][500+1];

bool is_cat(string &s, int b, int e){
    if(memo[b][e] != NOT_YET)
        return memo[b][e];
    
    if(e - b == 0) return true;
    
    if(s[b] == 'm' && s[e-1] == 'w'){
        bool ret = false;
        for(int i=b; i<e; i++){
            if(s[i] == 'e')
                ret |= is_cat(s, b+1, i) && is_cat(s, i+1, e-1);
            if(ret) break;
        }
        return memo[b][e] = ret;
    }else{
        return memo[b][e] = false;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(memo, -1, sizeof(memo));
    
    string s;
    cin >> s;
    cout << (is_cat(s, 0, s.size()) ? "Cat" : "Rabbit") << endl;
    
    return 0;
}

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

public class Program
{
    const int MAX_N=20;
    static int n,m;
    static List<double>[] Lab = new List<double>[MAX_N];
    static double sq(double d){return d*d;}
    static double distance(int i,int j)
    {
        return sq(Lab[i][0]-Lab[j][0])+sq(Lab[i][1]-Lab[j][1])+sq(Lab[i][2]-Lab[j][2]);
    }
    static IEnumerable<List<T>> combinations<T>(List<T> ints, int rest, bool root=true)
    {
	if(rest<=0){
	    yield return new List<T>();
            yield break;
        }
        if(ints.Count<=0)
        {
	    yield break;
        }
        for(int i=0;i<ints.Count;i++)
        {
            List<T> a=new List<T>(ints.Skip(i+1));
            foreach(List<T> b in combinations(a,rest-1,false))
            {
                b.Add(ints[i]);
                if(root) b.Reverse();
                yield return b;
            }
        }
    }
    public static void Main()
    {
        List<int> ints=Console.ReadLine().Split(new char[]{' '}).AsEnumerable().Select(int.Parse).ToList();
        n=ints[0];
        m=ints[1];
	double max=0;
        for(int i=0;i<n;i++){
            Lab[i]=Console.ReadLine().Split(new char[]{' '}).AsEnumerable().Select(double.Parse).ToList();
        }
        foreach(var c in combinations(Enumerable.Range(0,n).ToList(),m)){
	    double sum=0;
            for(int i=0;i<c.Count;i++){
	        for(int j=i+1;j<c.Count;j++){
                    sum+=distance(c[i],c[j]);
		}
	    }
	    if(max<sum){max=sum;}
        }
	Console.WriteLine(max.ToString("0.00000"));
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

vector<PPI> v;

void write() {
  int num, times;
  cin >> num >> times;

  int before = 0, i = 0;
  if(v.empty()) v.pb(PPI(P(0, times - 1), num));
  else {
    while(i < v.size()) {
      if (v[i].fi.fi - before >= times) {
        v.insert(v.begin() + i, PPI(P(before, before + times - 1), num));
        // rep(i, v.size()) cout << v[i].se << " [" << v[i].fi.fi << ", " << v[i].fi.se << "]" << endl;
        return;
      } else {
        PPI tmp = v[i];
        times -= (tmp.fi.fi - before);
        if (tmp.fi.fi - before > 0) {
          v.insert(v.begin() + i, PPI(P(before, tmp.fi.fi - 1), num));
          i += 2;
        } else {
          i++;
        }
        before = tmp.fi.se + 1;
      }
    }
    v.insert(v.end(), PPI(P(before, before + times - 1), num));
  }
  // rep(i, v.size()) cout << v[i].se << " [" << v[i].fi.fi << ", " << v[i].fi.se << "]" << endl;
}

void remove() {
  int num;
  cin >> num;
  repr(i, v.size()) {
    if (v[i].se == num) v.erase(v.begin() + i);
  }
  // rep(i, v.size()) cout << v[i].se << " [" << v[i].fi.fi << ", " << v[i].fi.se << "]" << endl;
}

void read() {
  int j;
  cin >> j;
  rep(i, v.size()) {
    if (v[i].fi.fi <= j && j <= v[i].fi.se) {
      cout << v[i].se << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main(){
  cin.sync_with_stdio(false);
  int n;
  while(cin >> n, n) {
    v.clear();
    rep(i, n) {
      char cmd;
      cin >> cmd;
      switch(cmd) {
        case 'W':
        write(); break;
        case 'D':
        remove(); break;
        case 'R':
        read(); break;
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

bool is_palindrome(string s){
    string raw_s = s;
    reverse(s.begin(), s.end());
    return raw_s == s;
}

int main(){
    string S;

    cin >> S;

    int s_len = S.length();
    int part_len = (s_len - 1) / 2;

    if(
      is_palindrome(S) &&
      is_palindrome(S.substr(0, part_len)) &&
      is_palindrome(S.substr((s_len + 3) / 2 - 1, part_len))
    )
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n = list(str(input()))
l = len(n)

if n[l-1] == '3':
    print('bon')
elif n[l-1] == '0' or n[l-1] == '1' or n[l-1] == '6' or n[l-1] == '8':
    print('pon')
else:
    print('hon')

Measured memory_bytes: 9112
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc =new Scanner(System.in);
		String tile = sc.next();
		//System.out.println("tile");
		String[] tilec = tile.split("");

		int counter1=0;
		int counter2=0;
		for(int i=0;i<tilec.length;i++){
			if(i%2 == 0){
				if(tilec[i].equals("0")){
					counter1++;
				}
			}else{
				if(tilec[i].equals("1")){
					counter1++;
				}
			}
		}

		for(int i=0;i<tilec.length;i++){
			if(i%2 == 0){
				if(tilec[i].equals("1") ){
					counter2++;
				}
			}else{
				if(tilec[i].equals("0") ){
					counter2++;
				}
			}
		}

		if(counter1 >= counter2){
			System.out.println(counter2);
		}else{
			System.out.println(counter1);
		}
	}
}

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

int main(){
    int x[5];
    int ans;
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
    for(int i=0;i<5;i++){
        if(0 == x[i]){
            ans = i + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException{
		
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String line = br.readLine();
		String[] ArrayX = new String[2];
		int[] Numbers = new int[2];
		int divite;
		int amari;
		double syosu;
		
				
		ArrayX = line.split(" ");
		Numbers[0] = Integer.parseInt(ArrayX[0]);
		Numbers[1] = Integer.parseInt(ArrayX[1]);
		
		divite = Numbers[0]/Numbers[1];
		amari =Numbers[0]%Numbers[1];
		
		syosu = ((double)Numbers[0]/(double)Numbers[1]);
		String after = String.format("%.5f", syosu);


		
		
		System.out.println(divite + " " + amari + " " + after);
	}

}

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll X,Y;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> X >> Y;
    if (X % Y != 0) cout << X;
    else cout << -1;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int c=0;
  int i;
  for(i=0;i<s.length();i++)
  {
    if(s[i]!=t[i])
      c++;
  }
  cout<<c;
}

Measured memory_bytes: 3824
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
bool prime[1000550];
int main()
{
  for(int i =2 ;i <=1000500;i++){
    prime[i] =true;
  }
  prime[0] = false;
  prime[1] = false;
  for(int i = 2;i*i<=1000500;i++){
    if(prime[i]){
      for(int j = 2*i;j <=1000500;j +=i){
	prime[j] = false;
      }
    }
  }
  int a,d,n;
  int ans;
  while(cin>>a>>d>>n,a||d||n){
    long long int sum =a;
    bool flag = false;
    int cnt;
    while(!flag){
      cnt = 0;
      for(unsigned long long int i = sum;cnt!=n;i+=d){
	if(prime[i]){
	  cnt++;
	  if(cnt==n){
	    ans = i;
	    flag = true;
	  }
	}
      }
    }
    cout <<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  priority_queue<double, vector<double>, greater<double> > vv;
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
    vv.push(v.at(i));
  }
  for (int i = 0; i < N-1; i++){
    double a = vv.top();
    vv.pop();
    double b = vv.top();
    vv.pop();
    vv.push((a+b)/2.0);
  }
  double ans = vv.top();
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int n;
int s;
vector<int> num;

long long memo[102][21];

//i+1項目以降の和がs-sumになる通りの数
long long solve(int i, int sum){
    if(sum < 0 || sum > 20) return 0;
    if(memo[i][sum] != -1)return memo[i][sum];

    if(i==n){
        return (sum == s) ? 1 : 0;
    }
    return memo[i][sum] = solve(i+1,sum+num[i]) + solve(i+1,sum-num[i]);
}

int main(){
    for(int i=0; i < 102*21; i++){
        *(*memo + i) = -1;
    }
    int tmp;
    cin >> n;
    n--;
    for(int i=0;i<n;i++){
        cin >> tmp;
        num.push_back(tmp);
    }
    cin >> s;
    cout << solve(1,num[0]) << endl;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define pii             pair<int,int>
#define pll             pair<long long,long long>
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost           ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;

/*
int bs(int l,int r,int n)
{
    int mid,res=inf;

    while(l<=r)
    {
        mid=l+(r-l)/2;

        if(check(mid,n))
        {
            r=mid-1;
            res=min(res,mid);
        }
        else
            l=mid+1;

    }

    return res;
}
*/


//--------------------------code starts here---------------------------------------


#define mx 100005
int parent[mx];



void makeSet(int u)
{
    parent[u]=u;
}

void init(int n)
{
    for(int i=0;i<=n;i++)
        makeSet(i);
}

int Find(int u)
{
    if(u==parent[u])
        return u;

    return parent[u]=Find(parent[u]);
}

void Union(int u,int v)
{
    int p=Find(u);
    int q=Find(v);

    if(p!=q)
    {
        parent[q]=p;
    }
}



int main()
{
    int n,m,u,v,w;
    sii(n,m);

    init(n);

    Rep(i,1,m)
    {
        sii(u,v);

        Union(u,v);
    }

    set<int> st;

    Rep(i,1,n)
    {
        st.insert(Find(i));
    }

    cout<<st.size()-1;




    return 0;
}


Measured memory_bytes: 7860
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<string> bubblesort(vector<string> seq)
{
  for (int i = 1; i < seq.size(); ++i)
    for (int j = i; 0 < j; --j)
      if (seq[j][1] < seq[j-1][1])
        swap(seq[j-1], seq[j]);
  return seq;
}

vector<string> selectionsort(vector<string> seq)
{
  for (int i = 0; i < seq.size(); ++i)
  {
    int mini = i;
    for (int j = i; j < seq.size(); ++j) {
      if (seq[j][1] < seq[mini][1])
        mini = j;
    }
    swap(seq[mini], seq[i]);
  }
  return seq;
}


int main()
{
  int n;
  vector<string> seq;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    string tmp;
    cin >> tmp;
    seq.push_back(tmp);
  }

  vector<string> res_b = bubblesort(seq);
  vector<string> res_s = selectionsort(seq);

  cout << res_b[0];
  for (int i = 1; i < res_b.size(); ++i)
    cout << " " << res_b[i];
  cout << endl << "Stable" << endl;

  cout << res_s[0];
  for (int i = 1; i < res_s.size(); ++i)
    cout << " " << res_s[i];
  cout << endl << ((res_b==res_s)? "Stable" : "Not stable") << endl;
}


Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int n; cin >> n;
  vector<int> p(n);
  for (int i=0; i<n; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i=1; i<n-1; i++) {
    if (p[i-1] > p[i] && p[i] > p[i+1]){
      ans++;
    }
    if (p[i-1] < p[i] && p[i] < p[i+1]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
ll a[100010], b[100010];
 
int main() {
	// your code goes here
	ll i, j, n, ans=0;
	cin>>n;
	for(i=1; i<=n; ++i)	cin>>a[i]>>b[i];
	for(i=n; i>=1; --i) {
		if((a[i]+ans)%b[i]==0)	continue;
		a[i]+=ans;
		ans+=(b[i]-a[i]%b[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import bisect
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ai = a[-1]
idx = bisect.bisect_left(a, ai//2)
if abs(ai//2-a[idx]) == abs(ai//2-a[idx-1]):
    if ai % 2 == 0 or idx == len(a)-1:
        print(ai, a[idx-1])
    else:
        print(ai, a[idx])
elif abs(ai//2-a[idx]) > abs(ai//2-a[idx-1]):
    print(ai, a[idx-1])
else:
    print(ai, a[idx])

Measured memory_bytes: 14052
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n;
signed main(){
	scanf("%lld",&n);
	int k,flag=1,cnt=0;
	while (n){
		k=n%10;
		n/=10;
		if (n)flag&=(k==9);
		cnt++;
	}
	printf("%lld\n",(cnt-1)*9+(flag?k:k-1));
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

#define MAX 1010

signed main() {
	static bool east[MAX][MAX] = {};
	static int dp[MAX][MAX] = {};
	for (int H, W, N; cin >> H >> W >> N&&H;) {
		fill(east[0], east[MAX], false);
		fill(dp[0], dp[MAX], 0);
		rep(i, 0, H)rep(j, 0, W) {
			cin >> east[i][j];
		}
		dp[0][0] = N - 1;
		rep(i, 0, H + 1)rep(j, 0, W + 1) {
			if (dp[i][j] == 0) continue;
			dp[i + 1][j] += dp[i][j] / 2;
			dp[i][j + 1] += dp[i][j] / 2;
			if (dp[i][j] % 2 == 1) {
				if (east[i][j])dp[i][j + 1] += 1;
				else dp[i + 1][j] += 1;
			}
		}
		rep(i, 0, H + 1)rep(j, 0, W + 1) {
			dp[i][j] += east[i][j];
			dp[i][j] %= 2;
		}
		int i = 0, j = 0;
		while (i < H && j < W) {
			if (dp[i][j] % 2 == 0)i++;
			else if (dp[i][j] % 2 == 1)j++;
		}
		cout << (i + 1) << " " << (j + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 8012
/* Coached by rainboy */
#include <stdio.h>

long long gcd(long long a, long long b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	long long a, b, d, p;
	int ans;

	scanf("%lld%lld", &a, &b);
	d = gcd(a, b);
	ans = 1;
	for (p = 2; p <= d / p; p++)
		if (d % p == 0) {
			ans++;
			while (d % p == 0)
				d /= p;
		}
	if (d > 1)
		ans++;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
import math


def combinations_count(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
al = list(map(str, input().split()))
d = defaultdict(lambda: 0)
dd = defaultdict(lambda: 0)
dd_1 = defaultdict(lambda: 0)
for a in al:
    d[a] += 1

sam = 0
for key, value in d.items():
    dd[key] = combinations_count(value, 2)
    dd_1[key] = combinations_count(value-1, 2)
    sam += dd[key]
# print(d)
# print(dd)
# print(sam)
for a in al:
    value = d[a]
    print(sam - dd[a] + dd_1[a])


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

int main(){
    int n,k;
    int ans=0;
    cin >> n >> k;
    while(n/k  !=0){
        n/=k;
        ans++;
    }
    cout << ans+1 << endl;
}

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

int N, M;

int main() {
    cin >> N >>  M;
    vector<int> Problems;
    int Co(0), Pe(0);
    int a; string s;

    Problems.assign(N + 1, 0);

    for (int i = 0; i < M; i++) {
        cin >> a >> s;
        if (s == "WA") {
            if (Problems[a] <= 0)
                Problems[a]--;
        }
        else {
            if (Problems[a] <= 0) {
                Pe -= Problems[a];
                Co++;
                Problems[a] = 1;
            }
        }
    }

    cout << Co << " " << Pe;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M;
	cin >> N >> M;
	cout << N + M / 2 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int n,m,q;
int a[60],b[60],c[60],d[60];
vector<int> A;
int ans=0;

void dfs(int x){  
    if(A.size()==n){
        int tmp=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i]) tmp+=d[i];
        }
        ans=max(ans,tmp);
        return;
    }
    A.push_back(x);
    for(int i=x;i<=m;i++) dfs(i);
    A.pop_back();

}

int main(){
    cin>>n>>m>>q;
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--,b[i]--;
    }

    for(int i=1;i<=m;i++){
        A.clear();
        dfs(i);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

string ch[105];

bool cmp(string a,string b){
	return a<b;
}

int main(){
	int N,L;
	cin>>N>>L;
	for(int i=0 ; i<N ; i++)cin>>ch[i];
	sort(ch,ch+N,cmp);
	for(int i=0 ; i<N ; i++)cout<<ch[i];
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
aa = a[::-1]
mod = 10**9+7

for i in range(1,n):
    aa[i] = aa[i]+aa[i-1]

aa = aa[::-1]
ans = 0

for i in range(n-1):
    ans += a[i]*aa[i+1]%mod

print(ans%mod)

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if(a == 1){
        ans += 300000;
    }
    else if(a == 2){
        ans += 200000;
    }
    else if(a == 3){
        ans += 100000;
    }
    if(b == 1){
        ans += 300000;
    }
    else if(b == 2){
        ans += 200000;
    }
    else if(b == 3){
        ans += 100000;
    }
    if(a==1 && b==1){
        ans += 400000;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vd;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vd> vvd;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;

const int MOD = 1e9+7;
const int nax = 1e5+5;
vvi adj(nax);
vb visited(nax);
vvll state(nax, vll(2, 0));

void dfs(int u)
{

    visited[u] = 1;
    if(adj[u].size() == 1 && u != 1){
        state[u][0] = state[u][1] = 1;
        return;
    }
    vi arr;
    for(auto v: adj[u])
    {
        if(!visited[v])
        {
            arr.push_back(v);
            dfs(v);
        }
    }
    ll l, r; l = r = 1;
    for(auto v: arr)
    {
        l = (l* (state[v][0] + state[v][1]) % MOD)%MOD;
        r = (r * state[v][0])%MOD;
    }
    state[u][0] = l;
    state[u][1] = r;
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    // state[1][0] = 1;
    // state[1][1] = 1;
    dfs(1);
    if(n ==1)
        cout << 2 << endl;
    else
        cout << (state[1][0] + state[1][1])%MOD << endl;
}

Measured memory_bytes: 22272
#include<iostream>
using namespace std;
const long maxn = 100000 + 10;
int main()
{
	char a[maxn];
    long ans,s,t,i;
	ans = 0; cin >> s;
	for (i = 1; i <= s; i++) cin >> a[i];
	t = 1;
	while (t <= s)
	{
		while (a[t + 1] == a[t]) t++;
		ans++; t++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define watch(x); cout<<#x<<"="<<x<<endl;
#define watch2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long

int32_t main() 
{ 
    fast
    int n;
    cin>>n;
    int temp;
    std::vector<int> arr(n);
    for(int i=0;i<n-1;i++){
    	cin>>temp;
    	arr[temp-1]++;
    }
    for(int i=0;i<n;i++)
    	cout<<arr[i]<<endl;

    return 0; 
} 


Measured memory_bytes: 4768
use text_io::*;
use std::process::exit;
use im_rc::HashMap;
use std::cmp::min;

fn main(){
    let mut a:usize = read!();
    let mut b:usize = read!();
    let mut c:usize = read!();
    if a+b+c>21 {
        println!("bust")
    }
    else {
        println!("win")
    }
}

Measured memory_bytes: 2132
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int N, Z, W;
  cin >> N >> Z >> W;
  vector<int> a(N);
  rep(i, 0, N) { cin >> a[i]; }
  cout << max(abs(W - a[N - 1]), (N >= 2 ? abs(a[N - 1] - a[N - 2]) : 0))
       << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
K = int(input())
X = list(map(int, input().split()))
ans = 0

for i in range(N):
    if X[i] <= (K - X[i]):
        ans += (X[i] * 2)
    else:
        ans += ((K - X[i]) * 2)
print (ans)

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

using namespace std;

int main()
{
    int n,index = 0;
    cin >> n;
    if(n==0)
        cout << "No"<<endl;
    for(int i = 0;i<15;i++)
    {
        for(int j = 0;j <= 25;j++)
        {
            if(i*7+j*4==n){
                index = 1;
                break;
            }

        }
    }
    if(index==1)
        cout << "Yes"<<endl;
    else
        cout << "No"<<endl;
    return 0;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N,K;cin>>N>>K;
    ll ans=K;
    FOR(i,1,N){
        ans*=(K-1);
    }
    cout<<ans<<"\n";
}

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

int main()
{
    ll n, m;
    cin >> n >> m;
    ll sum = 0;
    for(int i = 1; i <= m; i++)
    {
        int te;
        cin >> te;
        sum += te;
    }
    if(sum>= n)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    vi x(5); rep(i,5) cin >> x[i];
    int ans = 0;

    rep(i,5){
        if(x[i] == 0) ans = i+1;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int dish = scan.nextInt();
		int[] arrayD = new int[dish];
		int[] arrayM = new int[dish];
		int[] arrayA = new int[dish-1];
		int sum = 0;

		for(int i=0;i<dish;i++) {
			arrayD[i] = scan.nextInt();

		}
		for(int i=0;i<dish;i++) {
			arrayM[i] = scan.nextInt();
			sum += arrayM[i];
		}
		for(int i=0;i<dish-1;i++) {
			arrayA[i] = scan.nextInt();
		}
		for(int i=1;i<dish;i++) {
			if(arrayD[i-1]+1==arrayD[i]) {
				sum += arrayA[arrayD[i-1]-1];
			}
		}
		System.out.println(sum);
		scan.close();
	}

}


Measured memory_bytes: 21844
n, c, k = gets.split.map(&:to_i)
ts = n.times.map { gets.to_i }.sort!

ans = 1
base = ts.last
ps = [base]

(n - 2).downto(0) do |i|
  if ts[i] + k < base || (ts[i] + k <= base + k && ps.count == c)
    ans += 1
    base = ts[i]
    ps = []
  end

  ps << ts[i]
end

puts ans


Measured memory_bytes: 4640
#include <stdio.h>
int main()
{
	int a[3],task=0,dai,chu,sho;
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	if(a[0]>=a[1]&&a[0]>=a[2]&&a[1]>=a[2])
	{
		dai=a[0];
		chu=a[1];
		sho=a[2];
	}
	
	else if(a[0]>=a[1]&&a[0]>=a[2]&&a[2]>=a[1])
	{
		dai=a[0];
		chu=a[2];
		sho=a[1];
	}
	
	else if(a[1]>=a[0]&&a[1]>=a[2]&&a[0]>=a[2])
	{
		dai=a[1];
		chu=a[0];
		sho=a[2];
	}
	
	else if(a[1]>=a[0]&&a[1]>=a[2]&&a[2]>=a[0])
	{
		dai=a[1];
		chu=a[2];
		sho=a[0];
	}
	
	else if(a[2]>=a[0]&&a[2]>=a[1]&&a[0]>=a[1])
	{
		dai=a[2];
		chu=a[0];
		sho=a[1];
	}
	
	else if(a[2]>=a[0]&&a[2]>=a[1]&&a[1]>=a[0])
	{
		dai=a[2];
		chu=a[1];
		sho=a[0];
	}
	
	task=dai-sho;
	printf("%d",task);
	
	return 0;
}

Measured memory_bytes: 128
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $tree = [];
  $tree2 = [];
  for($i=1; $i<=$n; $i++){
    $tree2[$i] = [];
    for($j=1; $j<=$n; $j++){
      if($i == $j){
        $tree2[$i][$j] = 0;
      }else{
        $tree2[$i][$j] = PHP_INT_MAX;
      }
    }
  }
  for($i=0; $i<$m; $i++){
    list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));
    if(!isset($tree[$a])) $tree[$a] = [];
    $tree[$a][$b] = $c;
    $tree2[$a][$b] = $c;
    $tree2[$b][$a] = $c;
  }

  for($k=1; $k<=$n; $k++){
    for($i=1; $i<=$n; $i++){
      for($j=1; $j<=$n; $j++){
        $tree2[$i][$j] = min($tree2[$i][$j], $tree2[$i][$k]+$tree2[$k][$j]);
      }
    }
  }

  $ans = 0;

  foreach($tree as $i => $t){
    foreach($t as $j => $v){
      if($v != $tree2[$i][$j]){
//        echo $i." ".$j." ".$v." ".$tree2[$i][$j].PHP_EOL;
        $ans++;
      }
    }
  }

  echo $ans;

Measured memory_bytes: 16696